From fe4f1515376af9158addf251a521fe9967278664 Mon Sep 17 00:00:00 2001 From: Jonghyun Park Date: Mon, 26 Apr 2021 21:50:07 +0900 Subject: [PATCH 1/5] feat: add edu-applauncher component and page (WIP) When user accesses /edu-applauncher URL, it will automatically create a session and launch jupyter notebook. If there is already a session, only launch jupyter. --- src/backend-ai-app.ts | 3 + src/components/backend-ai-edu-applauncher.ts | 200 +++++++++++++++++++ src/components/backend-ai-webui.ts | 1 + 3 files changed, 204 insertions(+) create mode 100644 src/components/backend-ai-edu-applauncher.ts diff --git a/src/backend-ai-app.ts b/src/backend-ai-app.ts index 2e4cca513e..8b935ec964 100644 --- a/src/backend-ai-app.ts +++ b/src/backend-ai-app.ts @@ -102,6 +102,9 @@ const loadPage = (page, params: Record = {}) => (dispatch) => { case 'import': import('./components/backend-ai-import-view.js'); break; + case 'edu-applauncher': + import('./components/backend-ai-edu-applauncher.js'); + break; case 'unauthorized': import('./components/backend-ai-permission-denied-view.js'); break; diff --git a/src/components/backend-ai-edu-applauncher.ts b/src/components/backend-ai-edu-applauncher.ts new file mode 100644 index 0000000000..4bd9ce07d1 --- /dev/null +++ b/src/components/backend-ai-edu-applauncher.ts @@ -0,0 +1,200 @@ +/** +u@license + Copyright (c) 2015-2021 Lablup Inc. All rights reserved. + */ +import {get as _text, translate as _t, translateUnsafeHTML as _tr} from 'lit-translate'; +import {css, CSSResultArray, CSSResultOrNative, customElement, html, property} from 'lit-element'; +import {BackendAIPage} from './backend-ai-page'; + +import {BackendAiStyles} from './backend-ai-general-styles'; +import { + IronFlex, + IronFlexAlignment, + IronFlexFactors, + IronPositioning +} from '../plastics/layout/iron-flex-layout-classes'; + +import 'weightless/button'; +import 'weightless/icon'; +import 'weightless/card'; + +import '@material/mwc-icon/mwc-icon'; + +import {default as PainKiller} from './backend-ai-painkiller'; +import './backend-ai-app-launcher'; +import './lablup-activity-panel'; +import './lablup-loading-spinner'; + +/** + Backend.AI Education App Launcher + + Example: + + + ... content ... + + +@group Backend.AI Web UI + @element backend-ai-edu-applauncher + */ + +@customElement('backend-ai-edu-applauncher') +export default class BackendAiEduApplauncher extends BackendAIPage { + @property({type: Object}) notification = Object(); + + constructor() { + super(); + } + + static get styles(): CSSResultOrNative | CSSResultArray { + return [ + BackendAiStyles, + IronFlex, + IronFlexAlignment, + IronFlexFactors, + IronPositioning, + // language=CSS + css` + ` + ]; + } + + render() { + // language=HTML + return html` + + `; + } + + firstUpdated() { + if (typeof globalThis.backendaiclient === 'undefined' || globalThis.backendaiclient === null) { + document.addEventListener('backend-ai-connected', () => { + this._createEduSession(); + }, true); + } else { // already connected + } + } + + async _viewStateChanged(active) { + await this.updateComplete; + if (!this.active) { + return; + } + } + + /** + * Randomly generate session ID + * + * @return {string} Generated session ID + * */ + generateSessionId() { + let text = ''; + const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + for (let i = 0; i < 8; i++) { + text += possible.charAt(Math.floor(Math.random() * possible.length)); + } + return text + '-session'; + } + + async _createEduSession() { + // Check if there is existing compute session + const fields = [ + 'session_id', 'name', 'status', 'status_info', 'service_ports', 'mounts', + ]; + const statuses = ['RUNNING', 'RESTARTING', 'TERMINATING', 'PENDING', 'PREPARING', 'PULLING'].join(','); + const accessKey = ''; + // const groupId = globalThis.backendaiclient.current_group_id(); + const sessions = await globalThis.backendaiclient.computeSession.list( + fields, statuses, accessKey, 10 * 1000 + ); + + let sessionId; + let servicePorts; + if (sessions.compute_session_list.total_count > 0) { + console.log('reusing an existing session...'); + // TODO: different response depending on existing session's status + // how to deal with if there are multiple sessions? + const sessionStatus = sessions.compute_session_list.items[0].status; + if (sessionStatus !== 'RUNNING') { + this.notification.text = `Your session is in status ${sessionStatus}. Please retry after some time by reloading`; + this.notification.show(true); + } + sessionId = sessions.compute_session_list.items[0].session_id; + servicePorts = JSON.parse(sessions.compute_session_list.items[0].service_ports || '{}'); + } else { // no existing compute session. create one. + console.log('creating a new session...'); + // TODO: hard-coded parameters -> replace session-template API call + const imageName = 'cr.backend.ai/testing/ngc-tensorflow:20.11-tf2-py3'; + const sessionName = this.generateSessionId(); + const config = { + domain: 'default', + group_name: 'default', + scaling_group: 'default', + maxWaitSeconds: 30, + cpu: 1, + mem: '2g', + // mounts: [], + }; + try { + const response = await globalThis.backendaiclient.createIfNotExists( + imageName, sessionName, config, 30000 + ); + sessionId = response.sessionId; + servicePorts = response.servicePorts; + } catch (err) { + console.error(err); + if (err && err.message) { + if ('statusCode' in err && err.statusCode === 408) { + this.notification.text = _text('session.launcher.sessionStillPreparing'); + } else { + if (err.description) { + this.notification.text = PainKiller.relieve(err.description); + } else { + this.notification.text = PainKiller.relieve(err.message); + } + } + this.notification.detail = err.message; + this.notification.show(true, err); + } else if (err && err.title) { + this.notification.text = PainKiller.relieve(err.title); + this.notification.show(true, err); + } + } + } + + // Launch app. + const availableServiceNames = servicePorts.map((s) => s.name); + if (availableServiceNames.includes('rstudio')) { + this._openServiceApp(sessionId, 'rstudio'); + } else if (availableServiceNames.includes('jupyter')) { + this._openServiceApp(sessionId, 'jupyter'); + } else { + // TODO: how to deal with else? + console.log('how to deal?'); + } + } + + async _openServiceApp(sessionId, appName) { + const appLauncher = this.shadowRoot.querySelector('#app-launcher'); + appLauncher.indicator = await globalThis.lablupIndicator.start(); + appLauncher._open_wsproxy(sessionId, appName, null, null) + .then(async (resp) => { + console.log(resp); + if (resp.url) { + await appLauncher._connectToProxyWorker(resp.url, ''); + appLauncher.indicator.set(100, _text('session.applauncher.Prepared')); + setTimeout(() => { + // globalThis.open(resp.url, '_self'); + globalThis.open(resp.url); + }); + } else { + } + }); + } +} + +declare global { + interface HTMLElementTagNameMap { + 'backend-ai-edu-applauncher': BackendAiEduApplauncher; + } +} diff --git a/src/components/backend-ai-webui.ts b/src/components/backend-ai-webui.ts index 9ae40afdc1..251d298aff 100644 --- a/src/components/backend-ai-webui.ts +++ b/src/components/backend-ai-webui.ts @@ -1488,6 +1488,7 @@ export default class BackendAIWebUI extends connect(store)(LitElement) { + From 08215a3fa3545284b42dd1990f5c9bdf70921bfc Mon Sep 17 00:00:00 2001 From: Jonghyun Park Date: Mon, 26 Apr 2021 23:48:06 +0900 Subject: [PATCH 2/5] feat: add session template list SDK --- src/lib/backend.ai-client-es6.js | 2 +- src/lib/backend.ai-client-node.js | 45 ++++++++++++++++++++++++++ src/lib/backend.ai-client-node.ts | 52 +++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+), 1 deletion(-) diff --git a/src/lib/backend.ai-client-es6.js b/src/lib/backend.ai-client-es6.js index 3d792ab0b0..c464c72bfb 100644 --- a/src/lib/backend.ai-client-es6.js +++ b/src/lib/backend.ai-client-es6.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).ai=t()}}((function(){for(var t=function(t){var e;return function(i){return e||t(e={exports:{},parent:i},e.exports),e.exports}},e=t((function(t,e){(function(e,n){(function(){"use strict";var h;t.exports=R,R.ReadableState=E,K.EventEmitter;var f,l=function(t,e){return t.listeners(e).length},c=u({}).Buffer,d=n.Uint8Array||function(){},p=a({});f=p&&p.debuglog?p.debuglog("stream"):function(){};var m,g,v,y=gt.getHighWaterMark,b=lt.codes,M=b.ERR_INVALID_ARG_TYPE,w=b.ERR_STREAM_PUSH_AFTER_EOF,_=b.ERR_METHOD_NOT_IMPLEMENTED,S=b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;z(R,it);var k=ft.errorOrDestroy,A=["error","close","destroy","pause","resume"];function E(t,e,i){h=h||o({}),t=t||{},"boolean"!=typeof i&&(i=e instanceof h),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=y(this,t,"readableHighWaterMark",i),this.buffer=new ut,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(m||(m=s({}).StringDecoder),this.decoder=new m(t.encoding),this.encoding=t.encoding)}function R(t){if(h=h||o({}),!(this instanceof R))return new R(t);var e=this instanceof h;this._readableState=new E(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),it.call(this)}function x(t,e,i,r,n){f("readableAddChunk",e);var s,o=t._readableState;if(null===e)o.reading=!1,function(t,e){if(f("onEofChunk"),!e.ended){if(e.decoder){var i=e.decoder.end();i&&i.length&&(e.buffer.push(i),e.length+=e.objectMode?1:i.length)}e.ended=!0,e.sync?P(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,T(t)))}}(t,o);else if(n||(s=function(t,e){var i,r;return r=e,c.isBuffer(r)||r instanceof d||"string"==typeof e||void 0===e||t.objectMode||(i=new M("chunk",["string","Buffer","Uint8Array"],e)),i}(o,e)),s)k(t,s);else if(o.objectMode||e&&e.length>0)if("string"==typeof e||o.objectMode||Object.getPrototypeOf(e)===c.prototype||(e=function(t){return c.from(t)}(e)),r)o.endEmitted?k(t,new S):B(t,o,e,!0);else if(o.ended)k(t,new w);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!i?(e=o.decoder.write(e),o.objectMode||0!==e.length?B(t,o,e,!1):q(t,o)):B(t,o,e,!1)}else r||(o.reading=!1,q(t,o));return!o.ended&&(o.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=1073741824?t=1073741824:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function P(t){var i=t._readableState;f("emitReadable",i.needReadable,i.emittedReadable),i.needReadable=!1,i.emittedReadable||(f("emitReadable",i.flowing),i.emittedReadable=!0,e.nextTick(T,t))}function T(t){var e=t._readableState;f("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,C(t)}function q(t,i){i.readingMore||(i.readingMore=!0,e.nextTick(L,t,i))}function L(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function O(t){f("readable nexttick read 0"),t.read(0)}function N(t,e){f("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),C(t),e.flowing&&!e.reading&&t.read(0)}function C(t){var e=t._readableState;for(f("flow",e.flowing);e.flowing&&null!==t.read(););}function $(t,e){return 0===e.length?null:(e.objectMode?i=e.buffer.shift():!t||t>=e.length?(i=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):i=e.buffer.consume(t,e.decoder),i);var i}function U(t){var i=t._readableState;f("endReadable",i.endEmitted),i.endEmitted||(i.ended=!0,e.nextTick(D,i,t))}function D(t,e){if(f("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var i=e._writableState;(!i||i.autoDestroy&&i.finished)&&e.destroy()}}function W(t,e){for(var i=0,r=t.length;i=e.highWaterMark:e.length>0)||e.ended))return f("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?U(this):P(this),null;if(0===(t=I(t,e))&&e.ended)return 0===e.length&&U(this),null;var r,n=e.needReadable;return f("need readable",n),(0===e.length||e.length-t0?$(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),i!==t&&e.ended&&U(this)),null!==r&&this.emit("data",r),r},R.prototype._read=function(t){k(this,new _("_read()"))},R.prototype.pipe=function(t,i){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=t;break;case 1:n.pipes=[n.pipes,t];break;default:n.pipes.push(t)}n.pipesCount+=1,f("pipe count=%d opts=%j",n.pipesCount,i);var s=i&&!1===i.end||t===e.stdout||t===e.stderr?m:o;function o(){f("onend"),t.end()}n.endEmitted?e.nextTick(s):r.once("end",s),t.on("unpipe",(function e(i,s){f("onunpipe"),i===r&&s&&!1===s.hasUnpiped&&(s.hasUnpiped=!0,f("cleanup"),t.removeListener("close",d),t.removeListener("finish",p),t.removeListener("drain",h),t.removeListener("error",c),t.removeListener("unpipe",e),r.removeListener("end",o),r.removeListener("end",m),r.removeListener("data",u),a=!0,!n.awaitDrain||t._writableState&&!t._writableState.needDrain||h())}));var h=function(t){return function(){var e=t._readableState;f("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&l(t,"data")&&(e.flowing=!0,C(t))}}(r);t.on("drain",h);var a=!1;function u(e){f("ondata");var i=t.write(e);f("dest.write",i),!1===i&&((1===n.pipesCount&&n.pipes===t||n.pipesCount>1&&-1!==W(n.pipes,t))&&!a&&(f("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function c(e){f("onerror",e),m(),t.removeListener("error",c),0===l(t,"error")&&k(t,e)}function d(){t.removeListener("finish",p),m()}function p(){f("onfinish"),t.removeListener("close",d),m()}function m(){f("unpipe"),r.unpipe(t)}return r.on("data",u),function(t,e,i){if("function"==typeof t.prependListener)return t.prependListener("error",i);t._events&&t._events.error?Array.isArray(t._events.error)?t._events.error.unshift(i):t._events.error=[i,t._events.error]:t.on("error",i)}(t,0,c),t.once("close",d),t.once("finish",p),t.emit("pipe",r),n.flowing||(f("pipe resume"),r.resume()),t},R.prototype.unpipe=function(t){var e=this._readableState,i={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,i)),this;if(!t){var r=e.pipes,n=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var s=0;s0,!1!==n.flowing&&this.resume()):"readable"===t&&(n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,f("on readable",n.length,n.reading),n.length?P(this):n.reading||e.nextTick(O,this))),r},R.prototype.addListener=R.prototype.on,R.prototype.removeListener=function(t,i){var r=it.prototype.removeListener.call(this,t,i);return"readable"===t&&e.nextTick(j,this),r},R.prototype.removeAllListeners=function(t){var i=it.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||e.nextTick(j,this),i},R.prototype.resume=function(){var t=this._readableState;return t.flowing||(f("resume"),t.flowing=!t.readableListening,function(t,i){i.resumeScheduled||(i.resumeScheduled=!0,e.nextTick(N,t,i))}(this,t)),t.paused=!1,this},R.prototype.pause=function(){return f("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(f("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},R.prototype.wrap=function(t){var e=this,i=this._readableState,r=!1;for(var n in t.on("end",(function(){if(f("wrapped end"),i.decoder&&!i.ended){var t=i.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(n){f("wrapped data"),i.decoder&&(n=i.decoder.write(n)),i.objectMode&&null==n||(i.objectMode||n&&n.length)&&(e.push(n)||(r=!0,t.pause()))})),t)void 0===this[n]&&"function"==typeof t[n]&&(this[n]=function(e){return function(){return t[e].apply(t,arguments)}}(n));for(var s=0;s>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function o(t){var e=this.lastTotal-this.lastNeed,i=function(t,e,i){if(128!=(192&e[0]))return t.lastNeed=0,"\ufffd";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"\ufffd";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"\ufffd"}}(this,t);return void 0!==i?i:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function h(t,e){if((t.length-e)%2==0){var i=t.toString("utf16le",e);if(i){var r=i.charCodeAt(i.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],i.slice(0,-1)}return i}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function a(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var i=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,i)}return e}function u(t,e){var i=(t.length-e)%3;return 0===i?t.toString("base64",e):(this.lastNeed=3-i,this.lastTotal=3,1===i?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-i))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function l(t){return t.toString(this.encoding)}function c(t){return t&&t.length?this.write(t):""}e.StringDecoder=n,n.prototype.write=function(t){if(0===t.length)return"";var e,i;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";i=this.lastNeed,this.lastNeed=0}else i=0;return i=0?(n>0&&(t.lastNeed=n-1),n):--r=0?(n>0&&(t.lastNeed=n-2),n):--r=0?(n>0&&(2===n?n=0:t.lastNeed=n-3),n):0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=i;var r=t.length-(i-this.lastNeed);return t.copy(this.lastChar,0,r),t.toString("utf8",e,r)},n.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}})),o=t((function(t,i){(function(i){(function(){"use strict";var r=Object.keys||function(t){var e=[];for(var i in t)e.push(i);return e};t.exports=f;var n=e({}),s=h({});z(f,n);for(var o=r(s.prototype),a=0;a-1))throw new M(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(k.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(k.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),k.prototype._write=function(t,e,i){i(new p("_write()"))},k.prototype._writev=null,k.prototype.end=function(t,i,r){var n=this._writableState;return"function"==typeof t?(r=t,t=null,i=null):"function"==typeof i&&(r=i,i=null),null!=t&&this.write(t,i),n.corked&&(n.corked=1,this.uncork()),n.ending||function(t,i,r){i.ending=!0,I(t,i),r&&(i.finished?e.nextTick(r):t.once("finish",r)),i.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(k.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(k.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),k.prototype.destroy=ft.destroy,k.prototype._undestroy=ft.undestroy,k.prototype._destroy=function(t,e){e(t)}}).call(this)}).call(this,R,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})})),a=t((function(t,e){})),u=t((function(t,e){(function(t){(function(){"use strict";e.Buffer=i,e.SlowBuffer=function(t){return+t!=t&&(t=0),i.alloc(+t)},e.INSPECT_MAX_BYTES=50;function t(t){if(t>2147483647)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=i.prototype,e}function i(t,e,i){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return s(t)}return r(t,e,i)}function r(e,r,n){if("string"==typeof e)return function(e,r){if("string"==typeof r&&""!==r||(r="utf8"),!i.isEncoding(r))throw new TypeError("Unknown encoding: "+r);var n=0|a(e,r),s=t(n),o=s.write(e,r);return o!==n&&(s=s.slice(0,o)),s}(e,r);if(ArrayBuffer.isView(e))return o(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(O(e,ArrayBuffer)||e&&O(e.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=2147483647)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+2147483647..toString(16)+" bytes");return 0|t}function a(t,e){if(i.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||O(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var s=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return L(t).length;default:if(s)return n?-1:q(t).length;e=(""+e).toLowerCase(),s=!0}}function u(t,e,i){var r=t[e];t[e]=t[i],t[i]=r}function l(t,e,r,n,s){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),N(r=+r)&&(r=s?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(s)return-1;r=t.length-1}else if(r<0){if(!s)return-1;r=0}if("string"==typeof e&&(e=i.from(e,n)),i.isBuffer(e))return 0===e.length?-1:c(t,e,r,n,s);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):c(t,[e],r,n,s);throw new TypeError("val must be string, number or Buffer")}function c(t,e,i,r,n){var s,o=1,h=t.length,a=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;o=2,h/=2,a/=2,i/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(n){var f=-1;for(s=i;sh&&(i=h-a),s=i;s>=0;s--){for(var l=!0,c=0;cn&&(r=n):r=n;var s=e.length;r>s/2&&(r=s/2);for(var o=0;o>8,n=i%256,s.push(n),s.push(r);return s}(e,t.length-i),t,i,r)}function M(t,e,i){return 0===e&&i===t.length?f.fromByteArray(t):f.fromByteArray(t.slice(e,i))}function w(t,e,i){i=Math.min(t.length,i);for(var r=[],n=e;n239?4:u>223?3:u>191?2:1;if(n+l<=i)switch(l){case 1:u<128&&(f=u);break;case 2:128==(192&(s=t[n+1]))&&(a=(31&u)<<6|63&s)>127&&(f=a);break;case 3:s=t[n+1],o=t[n+2],128==(192&s)&&128==(192&o)&&(a=(15&u)<<12|(63&s)<<6|63&o)>2047&&(a<55296||a>57343)&&(f=a);break;case 4:s=t[n+1],o=t[n+2],h=t[n+3],128==(192&s)&&128==(192&o)&&128==(192&h)&&(a=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&h)>65535&&a<1114112&&(f=a)}null===f?(f=65533,l=1):f>65535&&(f-=65536,r.push(f>>>10&1023|55296),f=56320|1023&f),r.push(f),n+=l}return function(t){var e=t.length;if(e<=_)return String.fromCharCode.apply(String,t);for(var i="",r=0;rthis.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return A(this,e,i);case"utf8":case"utf-8":return w(this,e,i);case"ascii":return S(this,e,i);case"latin1":case"binary":return k(this,e,i);case"base64":return M(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,i);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}.apply(this,arguments)},i.prototype.toLocaleString=i.prototype.toString,i.prototype.equals=function(t){if(!i.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===i.compare(this,t)},i.prototype.inspect=function(){var t="",i=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,i).replace(/(.{2})/g,"$1 ").trim(),this.length>i&&(t+=" ... "),""},i.prototype.compare=function(t,e,r,n,s){if(O(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),!i.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===s&&(s=this.length),e<0||r>t.length||n<0||s>this.length)throw new RangeError("out of range index");if(n>=s&&e>=r)return 0;if(n>=s)return-1;if(e>=r)return 1;if(this===t)return 0;for(var o=(s>>>=0)-(n>>>=0),h=(r>>>=0)-(e>>>=0),a=Math.min(o,h),u=this.slice(n,s),f=t.slice(e,r),l=0;l>>=0,isFinite(i)?(i>>>=0,void 0===r&&(r="utf8")):(r=i,i=void 0)}var n=this.length-e;if((void 0===i||i>n)&&(i=n),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var s=!1;;)switch(r){case"hex":return d(this,t,e,i);case"utf8":case"utf-8":return p(this,t,e,i);case"ascii":return m(this,t,e,i);case"latin1":case"binary":return g(this,t,e,i);case"base64":return v(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return y(this,t,e,i);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var _=4096;function S(t,e,i){var r="";i=Math.min(t.length,i);for(var n=e;nn)&&(i=n);for(var s="",o=e;oi)throw new RangeError("Trying to access beyond buffer length")}function x(t,e,r,n,s,o){if(!i.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>s||et.length)throw new RangeError("Index out of range")}function B(t,e,i,r,n,s){if(i+r>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function I(t,e,i,r,n){return e=+e,i>>>=0,n||B(t,0,i,4),b.write(t,e,i,r,23,4),i+4}function P(t,e,i,r,n){return e=+e,i>>>=0,n||B(t,0,i,8),b.write(t,e,i,r,52,8),i+8}i.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,i||R(t,e,this.length);for(var r=this[t],n=1,s=0;++s>>=0,e>>>=0,i||R(t,e,this.length);for(var r=this[t+--e],n=1;e>0&&(n*=256);)r+=this[t+--e]*n;return r},i.prototype.readUInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),this[t]},i.prototype.readUInt16LE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]|this[t+1]<<8},i.prototype.readUInt16BE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]<<8|this[t+1]},i.prototype.readUInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},i.prototype.readUInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},i.prototype.readIntLE=function(t,e,i){t>>>=0,e>>>=0,i||R(t,e,this.length);for(var r=this[t],n=1,s=0;++s=(n*=128)&&(r-=Math.pow(2,8*e)),r},i.prototype.readIntBE=function(t,e,i){t>>>=0,e>>>=0,i||R(t,e,this.length);for(var r=e,n=1,s=this[t+--r];r>0&&(n*=256);)s+=this[t+--r]*n;return s>=(n*=128)&&(s-=Math.pow(2,8*e)),s},i.prototype.readInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},i.prototype.readInt16LE=function(t,e){t>>>=0,e||R(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},i.prototype.readInt16BE=function(t,e){t>>>=0,e||R(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},i.prototype.readInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},i.prototype.readInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},i.prototype.readFloatLE=function(t,e){return t>>>=0,e||R(t,4,this.length),b.read(this,t,!0,23,4)},i.prototype.readFloatBE=function(t,e){return t>>>=0,e||R(t,4,this.length),b.read(this,t,!1,23,4)},i.prototype.readDoubleLE=function(t,e){return t>>>=0,e||R(t,8,this.length),b.read(this,t,!0,52,8)},i.prototype.readDoubleBE=function(t,e){return t>>>=0,e||R(t,8,this.length),b.read(this,t,!1,52,8)},i.prototype.writeUIntLE=function(t,e,i,r){t=+t,e>>>=0,i>>>=0,r||x(this,t,e,i,Math.pow(2,8*i)-1,0);var n=1,s=0;for(this[e]=255&t;++s>>=0,i>>>=0,r||x(this,t,e,i,Math.pow(2,8*i)-1,0);var n=i-1,s=1;for(this[e+n]=255&t;--n>=0&&(s*=256);)this[e+n]=t/s&255;return e+i},i.prototype.writeUInt8=function(t,e,i){return t=+t,e>>>=0,i||x(this,t,e,1,255,0),this[e]=255&t,e+1},i.prototype.writeUInt16LE=function(t,e,i){return t=+t,e>>>=0,i||x(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeUInt16BE=function(t,e,i){return t=+t,e>>>=0,i||x(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeUInt32LE=function(t,e,i){return t=+t,e>>>=0,i||x(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},i.prototype.writeUInt32BE=function(t,e,i){return t=+t,e>>>=0,i||x(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},i.prototype.writeIntLE=function(t,e,i,r){if(t=+t,e>>>=0,!r){var n=Math.pow(2,8*i-1);x(this,t,e,i,n-1,-n)}var s=0,o=1,h=0;for(this[e]=255&t;++s>0)-h&255;return e+i},i.prototype.writeIntBE=function(t,e,i,r){if(t=+t,e>>>=0,!r){var n=Math.pow(2,8*i-1);x(this,t,e,i,n-1,-n)}var s=i-1,o=1,h=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&0===h&&0!==this[e+s+1]&&(h=1),this[e+s]=(t/o>>0)-h&255;return e+i},i.prototype.writeInt8=function(t,e,i){return t=+t,e>>>=0,i||x(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},i.prototype.writeInt16LE=function(t,e,i){return t=+t,e>>>=0,i||x(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeInt16BE=function(t,e,i){return t=+t,e>>>=0,i||x(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeInt32LE=function(t,e,i){return t=+t,e>>>=0,i||x(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},i.prototype.writeInt32BE=function(t,e,i){return t=+t,e>>>=0,i||x(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},i.prototype.writeFloatLE=function(t,e,i){return I(this,t,e,!0,i)},i.prototype.writeFloatBE=function(t,e,i){return I(this,t,e,!1,i)},i.prototype.writeDoubleLE=function(t,e,i){return P(this,t,e,!0,i)},i.prototype.writeDoubleBE=function(t,e,i){return P(this,t,e,!1,i)},i.prototype.copy=function(t,e,r,n){if(!i.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return s},i.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!i.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var s=t.charCodeAt(0);("utf8"===n&&s<128||"latin1"===n)&&(t=s)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&i<57344){if(!n){if(i>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===r){(e-=3)>-1&&s.push(239,191,189);continue}n=i;continue}if(i<56320){(e-=3)>-1&&s.push(239,191,189),n=i;continue}i=65536+(n-55296<<10|i-56320)}else n&&(e-=3)>-1&&s.push(239,191,189);if(n=null,i<128){if((e-=1)<0)break;s.push(i)}else if(i<2048){if((e-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function L(t){return f.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(T,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function j(t,e,i,r){for(var n=0;n=e.length||n>=t.length);++n)e[n+i]=t[n];return n}function O(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function N(t){return t!=t}}).call(this)}).call(this,u({}).Buffer)})),f={toByteArray:function(t){var e,i,r=v(t),n=r[0],s=r[1],o=new d(function(t,e,i){return 3*(e+i)/4-i}(0,n,s)),h=0,a=s>0?n-4:n;for(i=0;i>16&255,o[h++]=e>>8&255,o[h++]=255&e;return 2===s&&(e=c[t.charCodeAt(i)]<<2|c[t.charCodeAt(i+1)]>>4,o[h++]=255&e),1===s&&(e=c[t.charCodeAt(i)]<<10|c[t.charCodeAt(i+1)]<<4|c[t.charCodeAt(i+2)]>>2,o[h++]=e>>8&255,o[h++]=255&e),o},fromByteArray:function(t){for(var e,i=t.length,r=i%3,n=[],s=0,o=i-r;so?o:s+16383));return 1===r?(e=t[i-1],n.push(l[e>>2]+l[e<<4&63]+"==")):2===r&&(e=(t[i-2]<<8)+t[i-1],n.push(l[e>>10]+l[e>>4&63]+l[e<<2&63]+"=")),n.join("")}},l=[],c=[],d="undefined"!=typeof Uint8Array?Uint8Array:Array,p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",m=0,g=p.length;m0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");return-1===i&&(i=e),[i,i===e?0:4-i%4]}function y(t,e,i){for(var r,n,s=[],o=e;o>18&63]+l[n>>12&63]+l[n>>6&63]+l[63&n]);return s.join("")}c["-".charCodeAt(0)]=62,c["_".charCodeAt(0)]=63;var b={read:function(t,e,i,r,n){var s,o,h=8*n-r-1,a=(1<>1,f=-7,l=i?n-1:0,c=i?-1:1,d=t[e+l];for(l+=c,s=d&(1<<-f)-1,d>>=-f,f+=h;f>0;s=256*s+t[e+l],l+=c,f-=8);for(o=s&(1<<-f)-1,s>>=-f,f+=r;f>0;o=256*o+t[e+l],l+=c,f-=8);if(0===s)s=1-u;else{if(s===a)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,r),s-=u}return(d?-1:1)*o*Math.pow(2,s-r)},write:function(t,e,i,r,n,s){var o,h,a,u=8*s-n-1,f=(1<>1,c=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:s-1,p=r?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(h=isNaN(e)?1:0,o=f):(o=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-o))<1&&(o--,a*=2),(e+=o+l>=1?c/a:c*Math.pow(2,1-l))*a>=2&&(o++,a/=2),o+l>=f?(h=0,o=f):o+l>=1?(h=(e*a-1)*Math.pow(2,n),o+=l):(h=e*Math.pow(2,l-1)*Math.pow(2,n),o=0));n>=8;t[i+d]=255&h,d+=p,h/=256,n-=8);for(o=o<0;t[i+d]=255&o,d+=p,o/=256,u-=8);t[i+d-p]|=128*m}},M={},w=u({}),_=w.Buffer;function S(t,e){for(var i in t)e[i]=t[i]}function k(t,e,i){return _(t,e,i)}_.from&&_.alloc&&_.allocUnsafe&&_.allocUnsafeSlow?M=w:(S(w,M),M.Buffer=k),k.prototype=Object.create(_.prototype),S(_,k),k.from=function(t,e,i){if("number"==typeof t)throw new TypeError("Argument must not be a number");return _(t,e,i)},k.alloc=function(t,e,i){if("number"!=typeof t)throw new TypeError("Argument must be a number");var r=_(t);return void 0!==e?"string"==typeof i?r.fill(e,i):r.fill(e):r.fill(0),r},k.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return _(t)},k.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return w.SlowBuffer(t)};var A,E,R={},x=R={};function B(){throw new Error("setTimeout has not been defined")}function I(){throw new Error("clearTimeout has not been defined")}function P(t){if(A===setTimeout)return setTimeout(t,0);if((A===B||!A)&&setTimeout)return A=setTimeout,setTimeout(t,0);try{return A(t,0)}catch(e){try{return A.call(null,t,0)}catch(e){return A.call(this,t,0)}}}!function(){try{A="function"==typeof setTimeout?setTimeout:B}catch(t){A=B}try{E="function"==typeof clearTimeout?clearTimeout:I}catch(t){E=I}}();var T,q=[],L=!1,j=-1;function O(){L&&T&&(L=!1,T.length?q=T.concat(q):j=-1,q.length&&N())}function N(){if(!L){var t=P(O);L=!0;for(var e=q.length;e;){for(T=q,q=[];++j1)for(var i=1;i4294967295)throw new RangeError("requested too many random bytes");var s=i.allocUnsafe(e);if(e>0)if(e>65536)for(var o=0;o0&&o.length>n&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=o.length,h=a,console&&console.warn&&console.warn(h)}return t}function J(t,e,i){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},n=function(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}.bind(r);return n.listener=i,r.wrapFn=n,n}function Q(t,e,i){var r=t._events;if(void 0===r)return[];var n=r[e];return void 0===n?[]:"function"==typeof n?i?[n.listener||n]:[n]:i?function(t){for(var e=new Array(t.length),i=0;i0&&(s=e[0]),s instanceof Error)throw s;var o=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw o.context=s,o}var h=n[t];if(void 0===h)return!1;if("function"==typeof h)Z(h,this,e);else{var a=h.length,u=et(h,a);for(i=0;i=0;s--)if(i[s]===e||i[s].listener===e){o=i[s].listener,n=s;break}if(n<0)return this;0===n?i.shift():function(t,e){for(;e+1=0;r--)this.removeListener(t,e[r]);return this},V.prototype.listeners=function(t){return Q(this,t,!0)},V.prototype.rawListeners=function(t){return Q(this,t,!1)},V.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):tt.call(t,e)},V.prototype.listenerCount=tt,V.prototype.eventNames=function(){return this._eventsCount>0?D(this._events):[]};var it=K.EventEmitter;function rt(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,r)}return i}function nt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function st(t,e){for(var i=0;i0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,i=""+e.data;e=e.next;)i+=t+e.data;return i}},{key:"concat",value:function(t){if(0===this.length)return ot.alloc(0);for(var e,i,r,n=ot.allocUnsafe(t>>>0),s=this.head,o=0;s;)e=s.data,i=n,r=o,ot.prototype.copy.call(e,i,r),o+=s.data.length,s=s.next;return n}},{key:"consume",value:function(t,e){var i;return tn.length?n.length:t;if(s===n.length?r+=n:r+=n.slice(0,t),0==(t-=s)){s===n.length?(++i,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=n.slice(s));break}++i}return this.length-=i,r}},{key:"_getBuffer",value:function(t){var e=ot.allocUnsafe(t),i=this.head,r=1;for(i.data.copy(e),t-=i.data.length;i=i.next;){var n=i.data,s=t>n.length?n.length:t;if(n.copy(e,e.length-t,0,s),0==(t-=s)){s===n.length?(++r,i.next?this.head=i.next:this.head=this.tail=null):(this.head=i,i.data=n.slice(s));break}++r}return this.length-=r,e}},{key:at,value:function(t,e){return ht(this,function(t){for(var e=1;e2?"one of ".concat(e," ").concat(t.slice(0,i-1).join(", "),", or ")+t[i-1]:2===i?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}dt("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),dt("ERR_INVALID_ARG_TYPE",(function(t,e,i){var r,n,s,o;if("string"==typeof e&&("not ","not "===e.substr(0,"not ".length))?(r="must not be",e=e.replace(/^not /,"")):r="must be",s=t,(void 0===o||o>s.length)&&(o=s.length)," argument"===s.substring(o-" argument".length,o))n="The ".concat(t," ").concat(r," ").concat(pt(e,"type"));else{var h=function(t,e,i){return"number"!=typeof i&&(i=0),!(i+".".length>t.length)&&-1!==t.indexOf(".",i)}(t)?"property":"argument";n='The "'.concat(t,'" ').concat(h," ").concat(r," ").concat(pt(e,"type"))}return n+". Received type ".concat(typeof i)}),TypeError),dt("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),dt("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),dt("ERR_STREAM_PREMATURE_CLOSE","Premature close"),dt("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),dt("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),dt("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),dt("ERR_STREAM_WRITE_AFTER_END","write after end"),dt("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),dt("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),dt("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),lt.codes=ct;var mt=lt.codes.ERR_INVALID_OPT_VALUE,gt={getHighWaterMark:function(t,e,i,r){var n=function(t,e,i){return null!=t.highWaterMark?t.highWaterMark:e?t[i]:null}(e,r,i);if(null!=n){if(!isFinite(n)||Math.floor(n)!==n||n<0)throw new mt(r?i:"highWaterMark",n);return Math.floor(n)}return t.objectMode?16:16384}},vt={};(function(t){(function(){function e(e){try{if(!t.localStorage)return!1}catch(r){return!1}var i=t.localStorage[e];return null!=i&&"true"===String(i).toLowerCase()}vt=function(t,i){if(e("noDeprecation"))return t;var r=!1;return function(){if(!r){if(e("throwDeprecation"))throw new Error(i);e("traceDeprecation")?console.trace(i):console.warn(i),r=!0}return t.apply(this,arguments)}}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});var yt=Et,bt=lt.codes,Mt=bt.ERR_METHOD_NOT_IMPLEMENTED,wt=bt.ERR_MULTIPLE_CALLBACK,_t=bt.ERR_TRANSFORM_ALREADY_TRANSFORMING,St=bt.ERR_TRANSFORM_WITH_LENGTH_0,kt=o({});function At(t,e){var i=this._transformState;i.transforming=!1;var r=i.writecb;if(null===r)return this.emit("error",new wt);i.writechunk=null,i.writecb=null,null!=e&&this.push(e),r(t);var n=this._readableState;n.reading=!1,(n.needReadable||n.length0,(function(t){r||(r=t),t&&o.forEach(Ot),h||(o.forEach(Ot),s(r))}))}));return e.reduce(Nt)},$t={};($t=$t=e({})).Stream=$t,$t.Readable=$t,$t.Writable=h({}),$t.Duplex=o({}),$t.Transform=yt,$t.PassThrough=It,$t.finished=n({}),$t.pipeline=Ct;var Ut={},zt=M.Buffer,Dt=$t.Transform;function Kt(t){Dt.call(this),this._block=zt.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}z(Kt,Dt),Kt.prototype._transform=function(t,e,i){var r=null;try{this.update(t,e)}catch(n){r=n}i(r)},Kt.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(i){e=i}t(e)},Kt.prototype.update=function(t,e){if(function(t,e){if(!zt.isBuffer(t)&&"string"!=typeof t)throw new TypeError("Data must be a string or a buffer")}(t),this._finalized)throw new Error("Digest already called");zt.isBuffer(t)||(t=zt.from(t,e));for(var i=this._block,r=0;this._blockOffset+t.length-r>=this._blockSize;){for(var n=this._blockOffset;n0;++s)this._length[s]+=o,(o=this._length[s]/4294967296|0)>0&&(this._length[s]-=4294967296*o);return this},Kt.prototype._update=function(){throw new Error("_update is not implemented")},Kt.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var i=0;i<4;++i)this._length[i]=0;return e},Kt.prototype._digest=function(){throw new Error("_digest is not implemented")},Ut=Kt;var Wt={},Zt=M.Buffer,Ft=new Array(16);function Vt(){Ut.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function Ht(t,e){return t<>>32-e}function Gt(t,e,i,r,n,s,o){return Ht(t+(e&i|~e&r)+n+s|0,o)+e|0}function Xt(t,e,i,r,n,s,o){return Ht(t+(e&r|i&~r)+n+s|0,o)+e|0}function Yt(t,e,i,r,n,s,o){return Ht(t+(e^i^r)+n+s|0,o)+e|0}function Jt(t,e,i,r,n,s,o){return Ht(t+(i^(e|~r))+n+s|0,o)+e|0}z(Vt,Ut),Vt.prototype._update=function(){for(var t=Ft,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);var i=this._a,r=this._b,n=this._c,s=this._d;i=Gt(i,r,n,s,t[0],3614090360,7),s=Gt(s,i,r,n,t[1],3905402710,12),n=Gt(n,s,i,r,t[2],606105819,17),r=Gt(r,n,s,i,t[3],3250441966,22),i=Gt(i,r,n,s,t[4],4118548399,7),s=Gt(s,i,r,n,t[5],1200080426,12),n=Gt(n,s,i,r,t[6],2821735955,17),r=Gt(r,n,s,i,t[7],4249261313,22),i=Gt(i,r,n,s,t[8],1770035416,7),s=Gt(s,i,r,n,t[9],2336552879,12),n=Gt(n,s,i,r,t[10],4294925233,17),r=Gt(r,n,s,i,t[11],2304563134,22),i=Gt(i,r,n,s,t[12],1804603682,7),s=Gt(s,i,r,n,t[13],4254626195,12),n=Gt(n,s,i,r,t[14],2792965006,17),i=Xt(i,r=Gt(r,n,s,i,t[15],1236535329,22),n,s,t[1],4129170786,5),s=Xt(s,i,r,n,t[6],3225465664,9),n=Xt(n,s,i,r,t[11],643717713,14),r=Xt(r,n,s,i,t[0],3921069994,20),i=Xt(i,r,n,s,t[5],3593408605,5),s=Xt(s,i,r,n,t[10],38016083,9),n=Xt(n,s,i,r,t[15],3634488961,14),r=Xt(r,n,s,i,t[4],3889429448,20),i=Xt(i,r,n,s,t[9],568446438,5),s=Xt(s,i,r,n,t[14],3275163606,9),n=Xt(n,s,i,r,t[3],4107603335,14),r=Xt(r,n,s,i,t[8],1163531501,20),i=Xt(i,r,n,s,t[13],2850285829,5),s=Xt(s,i,r,n,t[2],4243563512,9),n=Xt(n,s,i,r,t[7],1735328473,14),i=Yt(i,r=Xt(r,n,s,i,t[12],2368359562,20),n,s,t[5],4294588738,4),s=Yt(s,i,r,n,t[8],2272392833,11),n=Yt(n,s,i,r,t[11],1839030562,16),r=Yt(r,n,s,i,t[14],4259657740,23),i=Yt(i,r,n,s,t[1],2763975236,4),s=Yt(s,i,r,n,t[4],1272893353,11),n=Yt(n,s,i,r,t[7],4139469664,16),r=Yt(r,n,s,i,t[10],3200236656,23),i=Yt(i,r,n,s,t[13],681279174,4),s=Yt(s,i,r,n,t[0],3936430074,11),n=Yt(n,s,i,r,t[3],3572445317,16),r=Yt(r,n,s,i,t[6],76029189,23),i=Yt(i,r,n,s,t[9],3654602809,4),s=Yt(s,i,r,n,t[12],3873151461,11),n=Yt(n,s,i,r,t[15],530742520,16),i=Jt(i,r=Yt(r,n,s,i,t[2],3299628645,23),n,s,t[0],4096336452,6),s=Jt(s,i,r,n,t[7],1126891415,10),n=Jt(n,s,i,r,t[14],2878612391,15),r=Jt(r,n,s,i,t[5],4237533241,21),i=Jt(i,r,n,s,t[12],1700485571,6),s=Jt(s,i,r,n,t[3],2399980690,10),n=Jt(n,s,i,r,t[10],4293915773,15),r=Jt(r,n,s,i,t[1],2240044497,21),i=Jt(i,r,n,s,t[8],1873313359,6),s=Jt(s,i,r,n,t[15],4264355552,10),n=Jt(n,s,i,r,t[6],2734768916,15),r=Jt(r,n,s,i,t[13],1309151649,21),i=Jt(i,r,n,s,t[4],4149444226,6),s=Jt(s,i,r,n,t[11],3174756917,10),n=Jt(n,s,i,r,t[2],718787259,15),r=Jt(r,n,s,i,t[9],3951481745,21),this._a=this._a+i|0,this._b=this._b+r|0,this._c=this._c+n|0,this._d=this._d+s|0},Vt.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 t=Zt.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t},Wt=Vt;var Qt={},te=u({}).Buffer,ee=new Array(16),ie=[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],re=[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],ne=[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],se=[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],oe=[0,1518500249,1859775393,2400959708,2840853838],he=[1352829926,1548603684,1836072691,2053994217,0];function ae(){Ut.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function ue(t,e){return t<>>32-e}function fe(t,e,i,r,n,s,o,h){return ue(t+(e^i^r)+s+o|0,h)+n|0}function le(t,e,i,r,n,s,o,h){return ue(t+(e&i|~e&r)+s+o|0,h)+n|0}function ce(t,e,i,r,n,s,o,h){return ue(t+((e|~i)^r)+s+o|0,h)+n|0}function de(t,e,i,r,n,s,o,h){return ue(t+(e&r|i&~r)+s+o|0,h)+n|0}function pe(t,e,i,r,n,s,o,h){return ue(t+(e^(i|~r))+s+o|0,h)+n|0}z(ae,Ut),ae.prototype._update=function(){for(var t=ee,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);for(var i=0|this._a,r=0|this._b,n=0|this._c,s=0|this._d,o=0|this._e,h=0|this._a,a=0|this._b,u=0|this._c,f=0|this._d,l=0|this._e,c=0;c<80;c+=1){var d,p;c<16?(d=fe(i,r,n,s,o,t[ie[c]],oe[0],ne[c]),p=pe(h,a,u,f,l,t[re[c]],he[0],se[c])):c<32?(d=le(i,r,n,s,o,t[ie[c]],oe[1],ne[c]),p=de(h,a,u,f,l,t[re[c]],he[1],se[c])):c<48?(d=ce(i,r,n,s,o,t[ie[c]],oe[2],ne[c]),p=ce(h,a,u,f,l,t[re[c]],he[2],se[c])):c<64?(d=de(i,r,n,s,o,t[ie[c]],oe[3],ne[c]),p=le(h,a,u,f,l,t[re[c]],he[3],se[c])):(d=pe(i,r,n,s,o,t[ie[c]],oe[4],ne[c]),p=fe(h,a,u,f,l,t[re[c]],he[4],se[c])),i=o,o=s,s=ue(n,10),n=r,r=d,h=l,l=f,f=ue(u,10),u=a,a=p}var m=this._b+n+f|0;this._b=this._c+s+l|0,this._c=this._d+o+h|0,this._d=this._e+i+a|0,this._e=this._a+r+u|0,this._a=m},ae.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 t=te.alloc?te.alloc(20):new te(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t},Qt=ae;var me={},ge=M.Buffer;function ve(t,e){this._block=ge.alloc(t),this._finalSize=e,this._blockSize=t,this._len=0}ve.prototype.update=function(t,e){"string"==typeof t&&(e=e||"utf8",t=ge.from(t,e));for(var i=this._block,r=this._blockSize,n=t.length,s=this._len,o=0;o=this._finalSize&&(this._update(this._block),this._block.fill(0));var i=8*this._len;if(i<=4294967295)this._block.writeUInt32BE(i,this._blockSize-4);else{var r=(4294967295&i)>>>0,n=(i-r)/4294967296;this._block.writeUInt32BE(n,this._blockSize-8),this._block.writeUInt32BE(r,this._blockSize-4)}this._update(this._block);var s=this._hash();return t?s.toString(t):s},ve.prototype._update=function(){throw new Error("_update must be implemented by subclass")},me=ve;var ye,be=M.Buffer,Me=[1518500249,1859775393,-1894007588,-899497514],we=new Array(80);function _e(){this.init(),this._w=we,me.call(this,64,56)}function Se(t){return t<<30|t>>>2}function ke(t,e,i,r){return 0===t?e&i|~e&r:2===t?e&i|e&r|i&r:e^i^r}z(_e,me),_e.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},_e.prototype._update=function(t){for(var e,i=this._w,r=0|this._a,n=0|this._b,s=0|this._c,o=0|this._d,h=0|this._e,a=0;a<16;++a)i[a]=t.readInt32BE(4*a);for(;a<80;++a)i[a]=i[a-3]^i[a-8]^i[a-14]^i[a-16];for(var u=0;u<80;++u){var f=~~(u/20),l=0|((e=r)<<5|e>>>27)+ke(f,n,s,o)+h+i[u]+Me[f];h=o,o=s,s=Se(n),n=r,r=l}this._a=r+this._a|0,this._b=n+this._b|0,this._c=s+this._c|0,this._d=o+this._d|0,this._e=h+this._e|0},_e.prototype._hash=function(){var t=be.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},ye=_e;var Ae,Ee=M.Buffer,Re=[1518500249,1859775393,-1894007588,-899497514],xe=new Array(80);function Be(){this.init(),this._w=xe,me.call(this,64,56)}function Ie(t){return t<<5|t>>>27}function Pe(t){return t<<30|t>>>2}function Te(t,e,i,r){return 0===t?e&i|~e&r:2===t?e&i|e&r|i&r:e^i^r}z(Be,me),Be.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},Be.prototype._update=function(t){for(var e,i=this._w,r=0|this._a,n=0|this._b,s=0|this._c,o=0|this._d,h=0|this._e,a=0;a<16;++a)i[a]=t.readInt32BE(4*a);for(;a<80;++a)i[a]=(e=i[a-3]^i[a-8]^i[a-14]^i[a-16])<<1|e>>>31;for(var u=0;u<80;++u){var f=~~(u/20),l=Ie(r)+Te(f,n,s,o)+h+i[u]+Re[f]|0;h=o,o=s,s=Pe(n),n=r,r=l}this._a=r+this._a|0,this._b=n+this._b|0,this._c=s+this._c|0,this._d=o+this._d|0,this._e=h+this._e|0},Be.prototype._hash=function(){var t=Ee.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},Ae=Be;var qe,Le=M.Buffer,je=[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],Oe=new Array(64);function Ne(){this.init(),this._w=Oe,me.call(this,64,56)}function Ce(t,e,i){return i^t&(e^i)}function $e(t,e,i){return t&e|i&(t|e)}function Ue(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function ze(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function De(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}z(Ne,me),Ne.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},Ne.prototype._update=function(t){for(var e,i=this._w,r=0|this._a,n=0|this._b,s=0|this._c,o=0|this._d,h=0|this._e,a=0|this._f,u=0|this._g,f=0|this._h,l=0;l<16;++l)i[l]=t.readInt32BE(4*l);for(;l<64;++l)i[l]=0|(((e=i[l-2])>>>17|e<<15)^(e>>>19|e<<13)^e>>>10)+i[l-7]+De(i[l-15])+i[l-16];for(var c=0;c<64;++c){var d=f+ze(h)+Ce(h,a,u)+je[c]+i[c]|0,p=Ue(r)+$e(r,n,s)|0;f=u,u=a,a=h,h=o+d|0,o=s,s=n,n=r,r=d+p|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=s+this._c|0,this._d=o+this._d|0,this._e=h+this._e|0,this._f=a+this._f|0,this._g=u+this._g|0,this._h=f+this._h|0},Ne.prototype._hash=function(){var t=Le.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},qe=Ne;var Ke,We=M.Buffer,Ze=new Array(64);function Fe(){this.init(),this._w=Ze,me.call(this,64,56)}z(Fe,qe),Fe.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},Fe.prototype._hash=function(){var t=We.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},Ke=Fe;var Ve,He=M.Buffer,Ge=[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],Xe=new Array(160);function Ye(){this.init(),this._w=Xe,me.call(this,128,112)}function Je(t,e,i){return i^t&(e^i)}function Qe(t,e,i){return t&e|i&(t|e)}function ti(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function ei(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function ii(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function ri(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function ni(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function si(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function oi(t,e){return t>>>0>>0?1:0}z(Ye,me),Ye.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},Ye.prototype._update=function(t){for(var e=this._w,i=0|this._ah,r=0|this._bh,n=0|this._ch,s=0|this._dh,o=0|this._eh,h=0|this._fh,a=0|this._gh,u=0|this._hh,f=0|this._al,l=0|this._bl,c=0|this._cl,d=0|this._dl,p=0|this._el,m=0|this._fl,g=0|this._gl,v=0|this._hl,y=0;y<32;y+=2)e[y]=t.readInt32BE(4*y),e[y+1]=t.readInt32BE(4*y+4);for(;y<160;y+=2){var b=e[y-30],M=e[y-30+1],w=ii(b,M),_=ri(M,b),S=ni(b=e[y-4],M=e[y-4+1]),k=si(M,b),A=e[y-14],E=e[y-14+1],R=e[y-32],x=e[y-32+1],B=_+E|0,I=w+A+oi(B,_)|0;I=(I=I+S+oi(B=B+k|0,k)|0)+R+oi(B=B+x|0,x)|0,e[y]=I,e[y+1]=B}for(var P=0;P<160;P+=2){I=e[P],B=e[P+1];var T=Qe(i,r,n),q=Qe(f,l,c),L=ti(i,f),j=ti(f,i),O=ei(o,p),N=ei(p,o),C=Ge[P],$=Ge[P+1],U=Je(o,h,a),z=Je(p,m,g),D=v+N|0,K=u+O+oi(D,v)|0;K=(K=(K=K+U+oi(D=D+z|0,z)|0)+C+oi(D=D+$|0,$)|0)+I+oi(D=D+B|0,B)|0;var W=j+q|0,Z=L+T+oi(W,j)|0;u=a,v=g,a=h,g=m,h=o,m=p,o=s+K+oi(p=d+D|0,d)|0,s=n,d=c,n=r,c=l,r=i,l=f,i=K+Z+oi(f=D+W|0,D)|0}this._al=this._al+f|0,this._bl=this._bl+l|0,this._cl=this._cl+c|0,this._dl=this._dl+d|0,this._el=this._el+p|0,this._fl=this._fl+m|0,this._gl=this._gl+g|0,this._hl=this._hl+v|0,this._ah=this._ah+i+oi(this._al,f)|0,this._bh=this._bh+r+oi(this._bl,l)|0,this._ch=this._ch+n+oi(this._cl,c)|0,this._dh=this._dh+s+oi(this._dl,d)|0,this._eh=this._eh+o+oi(this._el,p)|0,this._fh=this._fh+h+oi(this._fl,m)|0,this._gh=this._gh+a+oi(this._gl,g)|0,this._hh=this._hh+u+oi(this._hl,v)|0},Ye.prototype._hash=function(){var t=He.allocUnsafe(64);function e(e,i,r){t.writeInt32BE(e,r),t.writeInt32BE(i,r+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},Ve=Ye;var hi,ai=M.Buffer,ui=new Array(160);function fi(){this.init(),this._w=ui,me.call(this,128,112)}z(fi,Ve),fi.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},fi.prototype._hash=function(){var t=ai.allocUnsafe(48);function e(e,i,r){t.writeInt32BE(e,r),t.writeInt32BE(i,r+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t},hi=fi;var li,ci;(ci=li=function(t){t=t.toLowerCase();var e=ci[t];if(!e)throw new Error(t+" is not supported (we accept pull requests)");return new e}).sha=ye,ci.sha1=Ae,ci.sha224=Ke,ci.sha256=qe,ci.sha384=hi,ci.sha512=Ve;var di=mi,pi=K.EventEmitter;function mi(){pi.call(this)}z(mi,pi),mi.Readable=e({}),mi.Writable=h({}),mi.Duplex=o({}),mi.Transform=yt,mi.PassThrough=It,mi.finished=n({}),mi.pipeline=Ct,mi.Stream=mi,mi.prototype.pipe=function(t,e){var i=this;function r(e){t.writable&&!1===t.write(e)&&i.pause&&i.pause()}function n(){i.readable&&i.resume&&i.resume()}i.on("data",r),t.on("drain",n),t._isStdio||e&&!1===e.end||(i.on("end",o),i.on("close",h));var s=!1;function o(){s||(s=!0,t.end())}function h(){s||(s=!0,"function"==typeof t.destroy&&t.destroy())}function a(t){if(u(),0===pi.listenerCount(this,"error"))throw t}function u(){i.removeListener("data",r),t.removeListener("drain",n),i.removeListener("end",o),i.removeListener("close",h),i.removeListener("error",a),t.removeListener("error",a),i.removeListener("end",u),i.removeListener("close",u),t.removeListener("close",u)}return i.on("error",a),t.on("error",a),i.on("end",u),i.on("close",u),t.on("close",u),t.emit("pipe",i),t};var gi={},vi=M.Buffer,yi=di.Transform,bi=s({}).StringDecoder;function Mi(t){yi.call(this),this.hashMode="string"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}z(Mi,yi),Mi.prototype.update=function(t,e,i){"string"==typeof t&&(t=vi.from(t,e));var r=this._update(t);return this.hashMode?this:(i&&(r=this._toString(r,i)),r)},Mi.prototype.setAutoPadding=function(){},Mi.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},Mi.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},Mi.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},Mi.prototype._transform=function(t,e,i){var r;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(n){r=n}finally{i(r)}},Mi.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(i){e=i}t(e)},Mi.prototype._finalOrDigest=function(t){var e=this.__final()||vi.alloc(0);return t&&(e=this._toString(e,t,!0)),e},Mi.prototype._toString=function(t,e,i){if(this._decoder||(this._decoder=new bi(e),this._encoding=e),this._encoding!==e)throw new Error("can't switch encodings");var r=this._decoder.write(t);return i&&(r+=this._decoder.end()),r};var wi;function _i(t){gi.call(this,"digest"),this._hash=t}z(_i,gi=Mi),_i.prototype._update=function(t){this._hash.update(t)},_i.prototype._final=function(){return this._hash.digest()},wi=function(t){return"md5"===(t=t.toLowerCase())?new Wt:"rmd160"===t||"ripemd160"===t?new Qt:new _i(li(t))};var Si={},ki=M.Buffer,Ai=ki.alloc(128);function Ei(t,e){gi.call(this,"digest"),"string"==typeof e&&(e=ki.from(e)),this._alg=t,this._key=e,e.length>64?e=t(e):e.length<64&&(e=ki.concat([e,Ai],64));for(var i=this._ipad=ki.allocUnsafe(64),r=this._opad=ki.allocUnsafe(64),n=0;n<64;n++)i[n]=54^e[n],r[n]=92^e[n];this._hash=[i]}z(Ei,gi),Ei.prototype._update=function(t){this._hash.push(t)},Ei.prototype._final=function(){var t=this._alg(ki.concat(this._hash));return this._alg(ki.concat([this._opad,t]))},Si=Ei;var Ri,xi=function(t){return(new Wt).update(t).digest()},Bi=M.Buffer,Ii=Bi.alloc(128);function Pi(t,e){gi.call(this,"digest"),"string"==typeof e&&(e=Bi.from(e));var i="sha512"===t||"sha384"===t?128:64;this._alg=t,this._key=e,e.length>i?e=("rmd160"===t?new Qt:li(t)).update(e).digest():e.lengthLi||e!=e)throw new TypeError("Bad key length")},Oi={};(function(t){(function(){var e;e=t.browser?"utf-8":t.version?parseInt(t.version.split(".")[0].slice(1),10)>=6?"utf-8":"binary":"utf-8",Oi=e}).call(this)}).call(this,R);var Ni,Ci=M.Buffer,$i=function(t,e,i){if(Ci.isBuffer(t))return t;if("string"==typeof t)return Ci.from(t,e);if(ArrayBuffer.isView(t))return Ci.from(t.buffer);throw new TypeError(i+" must be a string, a Buffer, a typed array or a DataView")},Ui=M.Buffer,zi=Ui.alloc(128),Di={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function Ki(t,e,i){var r=function(t){return"rmd160"===t||"ripemd160"===t?function(t){return(new Qt).update(t).digest()}:"md5"===t?xi:function(e){return li(t).update(e).digest()}}(t),n="sha512"===t||"sha384"===t?128:64;e.length>n?e=r(e):e.length>>0},writeUInt32BE:function(t,e,i){t[0+i]=e>>>24,t[1+i]=e>>>16&255,t[2+i]=e>>>8&255,t[3+i]=255&e},ip:function(t,e,i,r){for(var n=0,s=0,o=6;o>=0;o-=2){for(var h=0;h<=24;h+=8)n<<=1,n|=e>>>h+o&1;for(h=0;h<=24;h+=8)n<<=1,n|=t>>>h+o&1}for(o=6;o>=0;o-=2){for(h=1;h<=25;h+=8)s<<=1,s|=e>>>h+o&1;for(h=1;h<=25;h+=8)s<<=1,s|=t>>>h+o&1}i[r+0]=n>>>0,i[r+1]=s>>>0},rip:function(t,e,i,r){for(var n=0,s=0,o=0;o<4;o++)for(var h=24;h>=0;h-=8)n<<=1,n|=e>>>h+o&1,n<<=1,n|=t>>>h+o&1;for(o=4;o<8;o++)for(h=24;h>=0;h-=8)s<<=1,s|=e>>>h+o&1,s<<=1,s|=t>>>h+o&1;i[r+0]=n>>>0,i[r+1]=s>>>0},pc1:function(t,e,i,r){for(var n=0,s=0,o=7;o>=5;o--){for(var h=0;h<=24;h+=8)n<<=1,n|=e>>h+o&1;for(h=0;h<=24;h+=8)n<<=1,n|=t>>h+o&1}for(h=0;h<=24;h+=8)n<<=1,n|=e>>h+o&1;for(o=1;o<=3;o++){for(h=0;h<=24;h+=8)s<<=1,s|=e>>h+o&1;for(h=0;h<=24;h+=8)s<<=1,s|=t>>h+o&1}for(h=0;h<=24;h+=8)s<<=1,s|=t>>h+o&1;i[r+0]=n>>>0,i[r+1]=s>>>0},r28shl:function(t,e){return t<>>28-e}},Fi=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];Zi.pc2=function(t,e,i,r){for(var n=0,s=0,o=Fi.length>>>1,h=0;h>>Fi[h]&1;for(h=o;h>>Fi[h]&1;i[r+0]=n>>>0,i[r+1]=s>>>0},Zi.expand=function(t,e,i){var r=0,n=0;r=(1&t)<<5|t>>>27;for(var s=23;s>=15;s-=4)r<<=6,r|=t>>>s&63;for(s=11;s>=3;s-=4)n|=t>>>s&63,n<<=6;n|=(31&t)<<1|t>>>31,e[i+0]=r>>>0,e[i+1]=n>>>0};var Vi=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];Zi.substitute=function(t,e){for(var i=0,r=0;r<4;r++)i<<=4,i|=Vi[64*r+(t>>>18-6*r&63)];for(r=0;r<4;r++)i<<=4,i|=Vi[256+64*r+(e>>>18-6*r&63)];return i>>>0};var Hi=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];Zi.permute=function(t){for(var e=0,i=0;i>>Hi[i]&1;return e>>>0},Zi.padSplit=function(t,e,i){for(var r=t.toString(2);r.length0;r--)e+=this._buffer(t,e),i+=this._flushBuffer(n,i);return e+=this._buffer(t,e),n},Ji.prototype.final=function(t){var e,i;return t&&(e=this.update(t)),i="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),e?e.concat(i):i},Ji.prototype._pad=function(t,e){if(0===e)return!1;for(;e>>1];i=Zi.r28shl(i,s),r=Zi.r28shl(r,s),Zi.pc2(i,r,t.keys,n)}},er.prototype._update=function(t,e,i,r){var n=this._desState,s=Zi.readUInt32BE(t,e),o=Zi.readUInt32BE(t,e+4);Zi.ip(s,o,n.tmp,0),s=n.tmp[0],o=n.tmp[1],"encrypt"===this.type?this._encrypt(n,s,o,n.tmp,0):this._decrypt(n,s,o,n.tmp,0),s=n.tmp[0],o=n.tmp[1],Zi.writeUInt32BE(i,s,r),Zi.writeUInt32BE(i,o,r+4)},er.prototype._pad=function(t,e){for(var i=t.length-e,r=e;r>>0,s=l}Zi.rip(o,s,r,n)},er.prototype._decrypt=function(t,e,i,r,n){for(var s=i,o=e,h=t.keys.length-2;h>=0;h-=2){var a=t.keys[h],u=t.keys[h+1];Zi.expand(s,t.tmp,0),a^=t.tmp[0],u^=t.tmp[1];var f=Zi.substitute(a,u),l=s;s=(o^Zi.permute(f))>>>0,o=l}Zi.rip(s,o,r,n)};var rr={},nr={};function sr(t){this.iv=new Array(8);for(var e=0;e>s%8,t._prev=Ar(t._prev,i?r:n);return o}function Ar(t,e){var i=t.length,r=-1,n=Sr.allocUnsafe(t.length);for(t=Sr.concat([t,Sr.from([e])]);++r>7;return n}_r.encrypt=function(t,e,i){for(var r=e.length,n=Sr.allocUnsafe(r),s=-1;++s>>24]^f[p>>>16&255]^l[m>>>8&255]^c[255&g]^e[v++],o=u[p>>>24]^f[m>>>16&255]^l[g>>>8&255]^c[255&d]^e[v++],h=u[m>>>24]^f[g>>>16&255]^l[d>>>8&255]^c[255&p]^e[v++],a=u[g>>>24]^f[d>>>16&255]^l[p>>>8&255]^c[255&m]^e[v++],d=s,p=o,m=h,g=a;return s=(r[d>>>24]<<24|r[p>>>16&255]<<16|r[m>>>8&255]<<8|r[255&g])^e[v++],o=(r[p>>>24]<<24|r[m>>>16&255]<<16|r[g>>>8&255]<<8|r[255&d])^e[v++],h=(r[m>>>24]<<24|r[g>>>16&255]<<16|r[d>>>8&255]<<8|r[255&p])^e[v++],a=(r[g>>>24]<<24|r[d>>>16&255]<<16|r[p>>>8&255]<<8|r[255&m])^e[v++],[s>>>=0,o>>>=0,h>>>=0,a>>>=0]}var $r=[0,1,2,4,8,16,32,64,128,27,54],Ur=function(){for(var t=new Array(256),e=0;e<256;e++)t[e]=e<128?e<<1:e<<1^283;for(var i=[],r=[],n=[[],[],[],[]],s=[[],[],[],[]],o=0,h=0,a=0;a<256;++a){var u=h^h<<1^h<<2^h<<3^h<<4;u=u>>>8^255&u^99,i[o]=u,r[u]=o;var f=t[o],l=t[f],c=t[l],d=257*t[u]^16843008*u;n[0][o]=d<<24|d>>>8,n[1][o]=d<<16|d>>>16,n[2][o]=d<<8|d>>>24,n[3][o]=d,d=16843009*c^65537*l^257*f^16843008*o,s[0][u]=d<<24|d>>>8,s[1][u]=d<<16|d>>>16,s[2][u]=d<<8|d>>>24,s[3][u]=d,0===o?o=h=1:(o=f^t[t[t[c^f]]],h^=t[t[h]])}return{SBOX:i,INV_SBOX:r,SUB_MIX:n,INV_SUB_MIX:s}}();function zr(t){this._key=Or(t),this._reset()}zr.blockSize=16,zr.keySize=32,zr.prototype.blockSize=zr.blockSize,zr.prototype.keySize=zr.keySize,zr.prototype._reset=function(){for(var t=this._key,e=t.length,i=e+6,r=4*(i+1),n=[],s=0;s>>24,o=Ur.SBOX[o>>>24]<<24|Ur.SBOX[o>>>16&255]<<16|Ur.SBOX[o>>>8&255]<<8|Ur.SBOX[255&o],o^=$r[s/e|0]<<24):e>6&&s%e==4&&(o=Ur.SBOX[o>>>24]<<24|Ur.SBOX[o>>>16&255]<<16|Ur.SBOX[o>>>8&255]<<8|Ur.SBOX[255&o]),n[s]=n[s-e]^o}for(var h=[],a=0;a>>24]]^Ur.INV_SUB_MIX[1][Ur.SBOX[f>>>16&255]]^Ur.INV_SUB_MIX[2][Ur.SBOX[f>>>8&255]]^Ur.INV_SUB_MIX[3][Ur.SBOX[255&f]]}this._nRounds=i,this._keySchedule=n,this._invKeySchedule=h},zr.prototype.encryptBlockRaw=function(t){return Cr(t=Or(t),this._keySchedule,Ur.SUB_MIX,Ur.SBOX,this._nRounds)},zr.prototype.encryptBlock=function(t){var e=this.encryptBlockRaw(t),i=jr.allocUnsafe(16);return i.writeUInt32BE(e[0],0),i.writeUInt32BE(e[1],4),i.writeUInt32BE(e[2],8),i.writeUInt32BE(e[3],12),i},zr.prototype.decryptBlock=function(t){var e=(t=Or(t))[1];t[1]=t[3],t[3]=e;var i=Cr(t,this._invKeySchedule,Ur.INV_SUB_MIX,Ur.INV_SBOX,this._nRounds),r=jr.allocUnsafe(16);return r.writeUInt32BE(i[0],0),r.writeUInt32BE(i[3],4),r.writeUInt32BE(i[2],8),r.writeUInt32BE(i[1],12),r},zr.prototype.scrub=function(){Nr(this._keySchedule),Nr(this._invKeySchedule),Nr(this._key)},Lr.AES=zr;var Dr={},Kr=M.Buffer,Wr=Kr.alloc(16,0);function Zr(t){var e=Kr.allocUnsafe(16);return e.writeUInt32BE(t[0]>>>0,0),e.writeUInt32BE(t[1]>>>0,4),e.writeUInt32BE(t[2]>>>0,8),e.writeUInt32BE(t[3]>>>0,12),e}function Fr(t){this.h=t,this.state=Kr.alloc(16,0),this.cache=Kr.allocUnsafe(0)}Fr.prototype.ghash=function(t){for(var e=-1;++e0;e--)r[e]=r[e]>>>1|(1&r[e-1])<<31;r[0]=r[0]>>>1,i&&(r[0]=r[0]^225<<24)}this.state=Zr(n)},Fr.prototype.update=function(t){var e;for(this.cache=Kr.concat([this.cache,t]);this.cache.length>=16;)e=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(e)},Fr.prototype.final=function(t,e){return this.cache.length&&this.ghash(Kr.concat([this.cache,Wr],16)),this.ghash(Zr([0,t,0,e])),this.state},Dr=Fr;var Vr=M.Buffer;function Hr(t,e,i,r){gi.call(this);var n=Vr.alloc(4,0);this._cipher=new Lr.AES(e);var s=this._cipher.encryptBlock(n);this._ghash=new Dr(s),i=function(t,e,i){if(12===e.length)return t._finID=Vr.concat([e,Vr.from([0,0,0,1])]),Vr.concat([e,Vr.from([0,0,0,2])]);var r=new Dr(i),n=e.length,s=n%16;r.update(e),s&&(s=16-s,r.update(Vr.alloc(s,0))),r.update(Vr.alloc(8,0));var o=8*n,h=Vr.alloc(8);h.writeUIntBE(o,0,8),r.update(h),t._finID=r.state;var a=Vr.from(t._finID);return Rr(a),a}(this,i,s),this._prev=Vr.from(i),this._cache=Vr.allocUnsafe(0),this._secCache=Vr.allocUnsafe(0),this._decrypt=r,this._alen=0,this._len=0,this._mode=t,this._authTag=null,this._called=!1}z(Hr,gi),Hr.prototype._update=function(t){if(!this._called&&this._alen){var e=16-this._alen%16;e<16&&(e=Vr.alloc(e,0),this._ghash.update(e))}this._called=!0;var i=this._mode.encrypt(this,t);return this._decrypt?this._ghash.update(t):this._ghash.update(i),this._len+=t.length,i},Hr.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var t=pr(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(t,e){var i=0;t.length!==e.length&&i++;for(var r=Math.min(t.length,e.length),n=0;n0||r>0;){var a=new Wt;a.update(h),a.update(t),e&&a.update(e),h=a.digest();var u=0;if(n>0){var f=s.length-n;u=Math.min(n,h.length),h.copy(s,f,0,u),n-=u}if(u0){var l=o.length-r,c=Math.min(r,h.length-u);h.copy(o,l,u,u+c),r-=c}}return h.fill(0),{key:s,iv:o}},Qr={},tn=M.Buffer;function en(t,e,i){gi.call(this),this._cache=new nn,this._cipher=new Lr.AES(e),this._prev=tn.from(i),this._mode=t,this._autopadding=!0}z(en,gi),en.prototype._update=function(t){var e,i;this._cache.add(t);for(var r=[];e=this._cache.get();)i=this._mode.encrypt(this,e),r.push(i);return tn.concat(r)};var rn=tn.alloc(16,16);function nn(){this.cache=tn.allocUnsafe(0)}en.prototype._final=function(){var t=this._cache.flush();if(this._autopadding)return t=this._mode.encrypt(this,t),this._cipher.scrub(),t;if(!t.equals(rn))throw this._cipher.scrub(),new Error("data not multiple of block length")},en.prototype.setAutoPadding=function(t){return this._autopadding=!!t,this},nn.prototype.add=function(t){this.cache=tn.concat([this.cache,t])},nn.prototype.get=function(){if(this.cache.length>15){var t=this.cache.slice(0,16);return this.cache=this.cache.slice(16),t}return null},nn.prototype.flush=function(){for(var t=16-this.cache.length,e=tn.allocUnsafe(t),i=-1;++i16)throw new Error("unable to decrypt data");for(var i=-1;++i16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e}else if(this.cache.length>=16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e;return null},an.prototype.flush=function(){if(this.cache.length)return this.cache};var un={};un.createCipheriv=Qr.createCipheriv,un.createDecipheriv=sn.createDecipheriv;var fn={"des-ecb":{key:8,iv:0}};fn["des-cbc"]=fn.des={key:8,iv:8},fn["des-ede3-cbc"]=fn.des3={key:24,iv:8},fn["des-ede3"]={key:24,iv:0},fn["des-ede-cbc"]={key:16,iv:8},fn["des-ede"]={key:16,iv:0};var ln={exports:{}};!function(t,e){"use strict";function i(t,e){t.super_=e;var i=function(){};i.prototype=e.prototype,t.prototype=new i,t.prototype.constructor=t}function r(t,e,i){if(r.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(i=e,e=10),this._init(t||0,e||10,i||"be"))}var n;"object"==typeof t?t.exports=r:e.BN=r,r.BN=r,r.wordSize=26;try{n=a({}).Buffer}catch(S){}function s(t,e,i){for(var r=0,n=Math.min(t.length,i),s=e;s=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return r}function o(t,e,i,r){for(var n=0,s=Math.min(t.length,i),o=e;o=49?h-49+10:h>=17?h-17+10:h}return n}r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,e){return t.cmp(e)>0?t:e},r.min=function(t,e){return t.cmp(e)<0?t:e},r.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===e?this._parseHex(t,r):this._parseBase(t,e,r),"-"===t[0]&&(this.negative=1),this.strip(),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initArray=function(t,e,i){if(t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r=0;r-=3)s=t[r]|t[r-1]<<8|t[r-2]<<16,this.words[n]|=s<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===i)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this.strip()},r.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=6)n=s(t,i,i+6),this.words[r]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,r++);i+6!==e&&(n=s(t,e,i+6),this.words[r]|=n<>>26-o&4194303),this.strip()},r.prototype._parseBase=function(t,e,i){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=e)r++;r--,n=n/e|0;for(var s=t.length-i,h=s%r,a=Math.min(s,s-h)+i,u=0,f=i;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},r.prototype.inspect=function(){return(this.red?""};var h=["","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],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function l(t,e,i){i.negative=e.negative^t.negative;var r=t.length+e.length|0;i.length=r,r=r-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,h=67108863&o,a=o/67108864|0;i.words[0]=h;for(var u=1;u>>26,l=67108863&a,c=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=c;d++){var p=u-d|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[d])+l)/67108864|0,l=67108863&o}i.words[u]=0|l,a=0|f}return 0!==a?i.words[u]=0|a:i.length--,i.strip()}r.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var r=0,n=0,s=0;s>>24-r&16777215)||s!==this.length-1?h[6-a.length]+a+i:a+i,(r+=2)>=26&&(r-=26,s--)}for(0!==n&&(i=n.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var l=u[t],c=f[t];i="";var d=this.clone();for(d.negative=0;!d.isZero();){var p=d.modn(c).toString(t);i=(d=d.idivn(c)).isZero()?p+i:h[l-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length,0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16)},r.prototype.toBuffer=function(t,e){return this.toArrayLike(n,t,e)},r.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},r.prototype.toArrayLike=function(t,e,i){var r=this.byteLength(),n=i||Math.max(1,r);this.strip();var s,o,h="le"===e,a=new t(n),u=this.clone();if(h){for(o=0;!u.isZero();o++)s=u.andln(255),u.iushrn(8),a[o]=s;for(;o=4096&&(i+=13,e>>>=13),e>=64&&(i+=7,e>>>=7),e>=8&&(i+=4,e>>>=4),e>=2&&(i+=2,e>>>=2),i+e},r.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,i=0;return 0==(8191&e)&&(i+=13,e>>>=13),0==(127&e)&&(i+=7,e>>>=7),0==(15&e)&&(i+=4,e>>>=4),0==(3&e)&&(i+=2,e>>>=2),0==(1&e)&&i++,i},r.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var i=0;it.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var e,i;this.length>t.length?(e=this,i=t):(e=t,i=this);for(var r=0;rt.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-i),this.strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,e){var i=t/26|0,r=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(i=this,r=t):(i=t,r=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i,r,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(i=this,r=t):(i=t,r=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,d=0|o[1],p=8191&d,m=d>>>13,g=0|o[2],v=8191&g,y=g>>>13,b=0|o[3],M=8191&b,w=b>>>13,_=0|o[4],S=8191&_,k=_>>>13,A=0|o[5],E=8191&A,R=A>>>13,x=0|o[6],B=8191&x,I=x>>>13,P=0|o[7],T=8191&P,q=P>>>13,L=0|o[8],j=8191&L,O=L>>>13,N=0|o[9],C=8191&N,$=N>>>13,U=0|h[0],z=8191&U,D=U>>>13,K=0|h[1],W=8191&K,Z=K>>>13,F=0|h[2],V=8191&F,H=F>>>13,G=0|h[3],X=8191&G,Y=G>>>13,J=0|h[4],Q=8191&J,tt=J>>>13,et=0|h[5],it=8191&et,rt=et>>>13,nt=0|h[6],st=8191&nt,ot=nt>>>13,ht=0|h[7],at=8191&ht,ut=ht>>>13,ft=0|h[8],lt=8191&ft,ct=ft>>>13,dt=0|h[9],pt=8191&dt,mt=dt>>>13;i.negative=t.negative^e.negative,i.length=19;var gt=(u+(r=Math.imul(l,z))|0)+((8191&(n=(n=Math.imul(l,D))+Math.imul(c,z)|0))<<13)|0;u=((s=Math.imul(c,D))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(p,z),n=(n=Math.imul(p,D))+Math.imul(m,z)|0,s=Math.imul(m,D);var vt=(u+(r=r+Math.imul(l,W)|0)|0)+((8191&(n=(n=n+Math.imul(l,Z)|0)+Math.imul(c,W)|0))<<13)|0;u=((s=s+Math.imul(c,Z)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(v,z),n=(n=Math.imul(v,D))+Math.imul(y,z)|0,s=Math.imul(y,D),r=r+Math.imul(p,W)|0,n=(n=n+Math.imul(p,Z)|0)+Math.imul(m,W)|0,s=s+Math.imul(m,Z)|0;var yt=(u+(r=r+Math.imul(l,V)|0)|0)+((8191&(n=(n=n+Math.imul(l,H)|0)+Math.imul(c,V)|0))<<13)|0;u=((s=s+Math.imul(c,H)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(M,z),n=(n=Math.imul(M,D))+Math.imul(w,z)|0,s=Math.imul(w,D),r=r+Math.imul(v,W)|0,n=(n=n+Math.imul(v,Z)|0)+Math.imul(y,W)|0,s=s+Math.imul(y,Z)|0,r=r+Math.imul(p,V)|0,n=(n=n+Math.imul(p,H)|0)+Math.imul(m,V)|0,s=s+Math.imul(m,H)|0;var bt=(u+(r=r+Math.imul(l,X)|0)|0)+((8191&(n=(n=n+Math.imul(l,Y)|0)+Math.imul(c,X)|0))<<13)|0;u=((s=s+Math.imul(c,Y)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(S,z),n=(n=Math.imul(S,D))+Math.imul(k,z)|0,s=Math.imul(k,D),r=r+Math.imul(M,W)|0,n=(n=n+Math.imul(M,Z)|0)+Math.imul(w,W)|0,s=s+Math.imul(w,Z)|0,r=r+Math.imul(v,V)|0,n=(n=n+Math.imul(v,H)|0)+Math.imul(y,V)|0,s=s+Math.imul(y,H)|0,r=r+Math.imul(p,X)|0,n=(n=n+Math.imul(p,Y)|0)+Math.imul(m,X)|0,s=s+Math.imul(m,Y)|0;var Mt=(u+(r=r+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(c,Q)|0))<<13)|0;u=((s=s+Math.imul(c,tt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(E,z),n=(n=Math.imul(E,D))+Math.imul(R,z)|0,s=Math.imul(R,D),r=r+Math.imul(S,W)|0,n=(n=n+Math.imul(S,Z)|0)+Math.imul(k,W)|0,s=s+Math.imul(k,Z)|0,r=r+Math.imul(M,V)|0,n=(n=n+Math.imul(M,H)|0)+Math.imul(w,V)|0,s=s+Math.imul(w,H)|0,r=r+Math.imul(v,X)|0,n=(n=n+Math.imul(v,Y)|0)+Math.imul(y,X)|0,s=s+Math.imul(y,Y)|0,r=r+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var wt=(u+(r=r+Math.imul(l,it)|0)|0)+((8191&(n=(n=n+Math.imul(l,rt)|0)+Math.imul(c,it)|0))<<13)|0;u=((s=s+Math.imul(c,rt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(B,z),n=(n=Math.imul(B,D))+Math.imul(I,z)|0,s=Math.imul(I,D),r=r+Math.imul(E,W)|0,n=(n=n+Math.imul(E,Z)|0)+Math.imul(R,W)|0,s=s+Math.imul(R,Z)|0,r=r+Math.imul(S,V)|0,n=(n=n+Math.imul(S,H)|0)+Math.imul(k,V)|0,s=s+Math.imul(k,H)|0,r=r+Math.imul(M,X)|0,n=(n=n+Math.imul(M,Y)|0)+Math.imul(w,X)|0,s=s+Math.imul(w,Y)|0,r=r+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,tt)|0)+Math.imul(y,Q)|0,s=s+Math.imul(y,tt)|0,r=r+Math.imul(p,it)|0,n=(n=n+Math.imul(p,rt)|0)+Math.imul(m,it)|0,s=s+Math.imul(m,rt)|0;var _t=(u+(r=r+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(c,st)|0))<<13)|0;u=((s=s+Math.imul(c,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(T,z),n=(n=Math.imul(T,D))+Math.imul(q,z)|0,s=Math.imul(q,D),r=r+Math.imul(B,W)|0,n=(n=n+Math.imul(B,Z)|0)+Math.imul(I,W)|0,s=s+Math.imul(I,Z)|0,r=r+Math.imul(E,V)|0,n=(n=n+Math.imul(E,H)|0)+Math.imul(R,V)|0,s=s+Math.imul(R,H)|0,r=r+Math.imul(S,X)|0,n=(n=n+Math.imul(S,Y)|0)+Math.imul(k,X)|0,s=s+Math.imul(k,Y)|0,r=r+Math.imul(M,Q)|0,n=(n=n+Math.imul(M,tt)|0)+Math.imul(w,Q)|0,s=s+Math.imul(w,tt)|0,r=r+Math.imul(v,it)|0,n=(n=n+Math.imul(v,rt)|0)+Math.imul(y,it)|0,s=s+Math.imul(y,rt)|0,r=r+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(r=r+Math.imul(l,at)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(c,at)|0))<<13)|0;u=((s=s+Math.imul(c,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(j,z),n=(n=Math.imul(j,D))+Math.imul(O,z)|0,s=Math.imul(O,D),r=r+Math.imul(T,W)|0,n=(n=n+Math.imul(T,Z)|0)+Math.imul(q,W)|0,s=s+Math.imul(q,Z)|0,r=r+Math.imul(B,V)|0,n=(n=n+Math.imul(B,H)|0)+Math.imul(I,V)|0,s=s+Math.imul(I,H)|0,r=r+Math.imul(E,X)|0,n=(n=n+Math.imul(E,Y)|0)+Math.imul(R,X)|0,s=s+Math.imul(R,Y)|0,r=r+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(k,Q)|0,s=s+Math.imul(k,tt)|0,r=r+Math.imul(M,it)|0,n=(n=n+Math.imul(M,rt)|0)+Math.imul(w,it)|0,s=s+Math.imul(w,rt)|0,r=r+Math.imul(v,st)|0,n=(n=n+Math.imul(v,ot)|0)+Math.imul(y,st)|0,s=s+Math.imul(y,ot)|0,r=r+Math.imul(p,at)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,at)|0,s=s+Math.imul(m,ut)|0;var kt=(u+(r=r+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,ct)|0)+Math.imul(c,lt)|0))<<13)|0;u=((s=s+Math.imul(c,ct)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(C,z),n=(n=Math.imul(C,D))+Math.imul($,z)|0,s=Math.imul($,D),r=r+Math.imul(j,W)|0,n=(n=n+Math.imul(j,Z)|0)+Math.imul(O,W)|0,s=s+Math.imul(O,Z)|0,r=r+Math.imul(T,V)|0,n=(n=n+Math.imul(T,H)|0)+Math.imul(q,V)|0,s=s+Math.imul(q,H)|0,r=r+Math.imul(B,X)|0,n=(n=n+Math.imul(B,Y)|0)+Math.imul(I,X)|0,s=s+Math.imul(I,Y)|0,r=r+Math.imul(E,Q)|0,n=(n=n+Math.imul(E,tt)|0)+Math.imul(R,Q)|0,s=s+Math.imul(R,tt)|0,r=r+Math.imul(S,it)|0,n=(n=n+Math.imul(S,rt)|0)+Math.imul(k,it)|0,s=s+Math.imul(k,rt)|0,r=r+Math.imul(M,st)|0,n=(n=n+Math.imul(M,ot)|0)+Math.imul(w,st)|0,s=s+Math.imul(w,ot)|0,r=r+Math.imul(v,at)|0,n=(n=n+Math.imul(v,ut)|0)+Math.imul(y,at)|0,s=s+Math.imul(y,ut)|0,r=r+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,ct)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,ct)|0;var At=(u+(r=r+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(c,pt)|0))<<13)|0;u=((s=s+Math.imul(c,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(C,W),n=(n=Math.imul(C,Z))+Math.imul($,W)|0,s=Math.imul($,Z),r=r+Math.imul(j,V)|0,n=(n=n+Math.imul(j,H)|0)+Math.imul(O,V)|0,s=s+Math.imul(O,H)|0,r=r+Math.imul(T,X)|0,n=(n=n+Math.imul(T,Y)|0)+Math.imul(q,X)|0,s=s+Math.imul(q,Y)|0,r=r+Math.imul(B,Q)|0,n=(n=n+Math.imul(B,tt)|0)+Math.imul(I,Q)|0,s=s+Math.imul(I,tt)|0,r=r+Math.imul(E,it)|0,n=(n=n+Math.imul(E,rt)|0)+Math.imul(R,it)|0,s=s+Math.imul(R,rt)|0,r=r+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(k,st)|0,s=s+Math.imul(k,ot)|0,r=r+Math.imul(M,at)|0,n=(n=n+Math.imul(M,ut)|0)+Math.imul(w,at)|0,s=s+Math.imul(w,ut)|0,r=r+Math.imul(v,lt)|0,n=(n=n+Math.imul(v,ct)|0)+Math.imul(y,lt)|0,s=s+Math.imul(y,ct)|0;var Et=(u+(r=r+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(C,V),n=(n=Math.imul(C,H))+Math.imul($,V)|0,s=Math.imul($,H),r=r+Math.imul(j,X)|0,n=(n=n+Math.imul(j,Y)|0)+Math.imul(O,X)|0,s=s+Math.imul(O,Y)|0,r=r+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(q,Q)|0,s=s+Math.imul(q,tt)|0,r=r+Math.imul(B,it)|0,n=(n=n+Math.imul(B,rt)|0)+Math.imul(I,it)|0,s=s+Math.imul(I,rt)|0,r=r+Math.imul(E,st)|0,n=(n=n+Math.imul(E,ot)|0)+Math.imul(R,st)|0,s=s+Math.imul(R,ot)|0,r=r+Math.imul(S,at)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(k,at)|0,s=s+Math.imul(k,ut)|0,r=r+Math.imul(M,lt)|0,n=(n=n+Math.imul(M,ct)|0)+Math.imul(w,lt)|0,s=s+Math.imul(w,ct)|0;var Rt=(u+(r=r+Math.imul(v,pt)|0)|0)+((8191&(n=(n=n+Math.imul(v,mt)|0)+Math.imul(y,pt)|0))<<13)|0;u=((s=s+Math.imul(y,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(C,X),n=(n=Math.imul(C,Y))+Math.imul($,X)|0,s=Math.imul($,Y),r=r+Math.imul(j,Q)|0,n=(n=n+Math.imul(j,tt)|0)+Math.imul(O,Q)|0,s=s+Math.imul(O,tt)|0,r=r+Math.imul(T,it)|0,n=(n=n+Math.imul(T,rt)|0)+Math.imul(q,it)|0,s=s+Math.imul(q,rt)|0,r=r+Math.imul(B,st)|0,n=(n=n+Math.imul(B,ot)|0)+Math.imul(I,st)|0,s=s+Math.imul(I,ot)|0,r=r+Math.imul(E,at)|0,n=(n=n+Math.imul(E,ut)|0)+Math.imul(R,at)|0,s=s+Math.imul(R,ut)|0,r=r+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,ct)|0)+Math.imul(k,lt)|0,s=s+Math.imul(k,ct)|0;var xt=(u+(r=r+Math.imul(M,pt)|0)|0)+((8191&(n=(n=n+Math.imul(M,mt)|0)+Math.imul(w,pt)|0))<<13)|0;u=((s=s+Math.imul(w,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(C,Q),n=(n=Math.imul(C,tt))+Math.imul($,Q)|0,s=Math.imul($,tt),r=r+Math.imul(j,it)|0,n=(n=n+Math.imul(j,rt)|0)+Math.imul(O,it)|0,s=s+Math.imul(O,rt)|0,r=r+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(q,st)|0,s=s+Math.imul(q,ot)|0,r=r+Math.imul(B,at)|0,n=(n=n+Math.imul(B,ut)|0)+Math.imul(I,at)|0,s=s+Math.imul(I,ut)|0,r=r+Math.imul(E,lt)|0,n=(n=n+Math.imul(E,ct)|0)+Math.imul(R,lt)|0,s=s+Math.imul(R,ct)|0;var Bt=(u+(r=r+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(k,pt)|0))<<13)|0;u=((s=s+Math.imul(k,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(C,it),n=(n=Math.imul(C,rt))+Math.imul($,it)|0,s=Math.imul($,rt),r=r+Math.imul(j,st)|0,n=(n=n+Math.imul(j,ot)|0)+Math.imul(O,st)|0,s=s+Math.imul(O,ot)|0,r=r+Math.imul(T,at)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(q,at)|0,s=s+Math.imul(q,ut)|0,r=r+Math.imul(B,lt)|0,n=(n=n+Math.imul(B,ct)|0)+Math.imul(I,lt)|0,s=s+Math.imul(I,ct)|0;var It=(u+(r=r+Math.imul(E,pt)|0)|0)+((8191&(n=(n=n+Math.imul(E,mt)|0)+Math.imul(R,pt)|0))<<13)|0;u=((s=s+Math.imul(R,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(C,st),n=(n=Math.imul(C,ot))+Math.imul($,st)|0,s=Math.imul($,ot),r=r+Math.imul(j,at)|0,n=(n=n+Math.imul(j,ut)|0)+Math.imul(O,at)|0,s=s+Math.imul(O,ut)|0,r=r+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,ct)|0)+Math.imul(q,lt)|0,s=s+Math.imul(q,ct)|0;var Pt=(u+(r=r+Math.imul(B,pt)|0)|0)+((8191&(n=(n=n+Math.imul(B,mt)|0)+Math.imul(I,pt)|0))<<13)|0;u=((s=s+Math.imul(I,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(C,at),n=(n=Math.imul(C,ut))+Math.imul($,at)|0,s=Math.imul($,ut),r=r+Math.imul(j,lt)|0,n=(n=n+Math.imul(j,ct)|0)+Math.imul(O,lt)|0,s=s+Math.imul(O,ct)|0;var Tt=(u+(r=r+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(q,pt)|0))<<13)|0;u=((s=s+Math.imul(q,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(C,lt),n=(n=Math.imul(C,ct))+Math.imul($,lt)|0,s=Math.imul($,ct);var qt=(u+(r=r+Math.imul(j,pt)|0)|0)+((8191&(n=(n=n+Math.imul(j,mt)|0)+Math.imul(O,pt)|0))<<13)|0;u=((s=s+Math.imul(O,mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863;var Lt=(u+(r=Math.imul(C,pt))|0)+((8191&(n=(n=Math.imul(C,mt))+Math.imul($,pt)|0))<<13)|0;return u=((s=Math.imul($,mt))+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,a[0]=gt,a[1]=vt,a[2]=yt,a[3]=bt,a[4]=Mt,a[5]=wt,a[6]=_t,a[7]=St,a[8]=kt,a[9]=At,a[10]=Et,a[11]=Rt,a[12]=xt,a[13]=Bt,a[14]=It,a[15]=Pt,a[16]=Tt,a[17]=qt,a[18]=Lt,0!==u&&(a[19]=u,i.length++),i};function d(t,e,i){return(new p).mulp(t,e,i)}function p(t,e){this.x=t,this.y=e}Math.imul||(c=l),r.prototype.mulTo=function(t,e){var i=this.length+t.length;return 10===this.length&&10===t.length?c(this,t,e):i<63?l(this,t,e):i<1024?function(t,e,i){i.negative=e.negative^t.negative,i.length=t.length+e.length;for(var r=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}i.words[s]=h,r=o,o=n}return 0!==r?i.words[s]=r:i.length--,i.strip()}(this,t,e):d(this,t,e)},p.prototype.makeRBT=function(t){for(var e=new Array(t),i=r.prototype._countBits(t)-1,n=0;n>=1;return r},p.prototype.permute=function(t,e,i,r,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*s+1]=8191&n,n>>>=13;for(s=2*e;s>=26,e+=r/67108864|0,e+=n>>>26,this.words[i]=67108863&n}return 0!==e&&(this.words[i]=e,this.length++),this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),i=0;i>>n}return e}(t);if(0===e.length)return new r(1);for(var i=this,n=0;n>>26-i<<26-i;if(0!==i){var s=0;for(e=0;e>>26-i}s&&(this.words[e]=s,this.length++)}if(0!==r){for(e=this.length-1;e>=0;e--)this.words[e+r]=this.words[e];for(e=0;e>>n<s)for(this.length-=s,a=0;a=0&&(0!==u||a>=r);a--){var f=0|this.words[a];this.words[a]=u<<26-n|f>>>n,u=f&o}return h&&0!==u&&(h.words[h.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},r.prototype.ishrn=function(t,e,i){return this.iushrn(t,e,i)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){var e=t%26,i=(t-e)/26,r=1<>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},r.prototype.isubn=function(t){if(t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[r+i]=67108863&n}for(;r>26,this.words[r+i]=67108863&n;if(0===o)return this.strip();for(o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},r.prototype._wordDiv=function(t,e){var i=(this.length,t.length),n=this.clone(),s=t,o=0|s.words[s.length-1];0!=(i=26-this._countBits(o))&&(s=s.ushln(i),n.iushln(i),o=0|s.words[s.length-1]);var h,a=n.length-s.length;if("mod"!==e){(h=new r(null)).length=a+1,h.words=new Array(h.length);for(var u=0;u=0;l--){var c=67108864*(0|n.words[s.length+l])+(0|n.words[s.length+l-1]);for(c=Math.min(c/o|0,67108863),n._ishlnsubmul(s,c,l);0!==n.negative;)c--,n.negative=0,n._ishlnsubmul(s,1,l),n.isZero()||(n.negative^=1);h&&(h.words[l]=c)}return h&&h.strip(),n.strip(),"div"!==e&&0!==i&&n.iushrn(i),{div:h||null,mod:n}},r.prototype.divmod=function(t,e,i){return this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),"mod"!==e&&(n=o.div.neg()),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),e),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new r(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var i=0!==e.div.negative?e.mod.isub(t):e.mod,r=t.ushrn(1),n=t.andln(1),s=i.cmp(r);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},r.prototype.modn=function(t){for(var e=(1<<26)%t,i=0,r=this.length-1;r>=0;r--)i=(e*i+(0|this.words[r]))%t;return i},r.prototype.idivn=function(t){for(var e=0,i=this.length-1;i>=0;i--){var r=(0|this.words[i])+67108864*e;this.words[i]=r/t|0,e=r%t}return this.strip()},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new r(1),s=new r(0),o=new r(0),h=new r(1),a=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++a;for(var u=i.clone(),f=e.clone();!e.isZero();){for(var l=0,c=1;0==(e.words[0]&c)&&l<26;++l,c<<=1);if(l>0)for(e.iushrn(l);l-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(u),s.isub(f)),n.iushrn(1),s.iushrn(1);for(var d=0,p=1;0==(i.words[0]&p)&&d<26;++d,p<<=1);if(d>0)for(i.iushrn(d);d-- >0;)(o.isOdd()||h.isOdd())&&(o.iadd(u),h.isub(f)),o.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),n.isub(o),s.isub(h)):(i.isub(e),o.isub(n),h.isub(s))}return{a:o,b:h,gcd:i.iushln(a)}},r.prototype._invmp=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new r(1),o=new r(0),h=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var a=0,u=1;0==(e.words[0]&u)&&a<26;++a,u<<=1);if(a>0)for(e.iushrn(a);a-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);for(var f=0,l=1;0==(i.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(i.iushrn(f);f-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o)):(i.isub(e),o.isub(s))}return(n=0===e.cmpn(1)?s:o).cmpn(0)<0&&n.iadd(t),n},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),i=t.clone();e.negative=0,i.negative=0;for(var r=0;e.isEven()&&i.isEven();r++)e.iushrn(1),i.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;i.isEven();)i.iushrn(1);var n=e.cmp(i);if(n<0){var s=e;e=i,i=s}else if(0===n||0===i.cmpn(1))break;e.isub(i)}return i.iushln(r)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){var e=t%26,i=(t-e)/26,r=1<>>26,o&=67108863,this.words[s]=o}return 0!==n&&(this.words[s]=n,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t);var r=0|this.words[0];e=r===t?0:rt.length)return 1;if(this.length=0;i--){var r=0|this.words[i],n=0|t.words[i];if(r!==n){rn&&(e=1);break}}return e},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new w(t)},r.prototype.toRed=function(t){return t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return this._forceRed(t)},r.prototype.redAdd=function(t){return this.red.add(this,t)},r.prototype.redIAdd=function(t){return this.red.iadd(this,t)},r.prototype.redSub=function(t){return this.red.sub(this,t)},r.prototype.redISub=function(t){return this.red.isub(this,t)},r.prototype.redShl=function(t){return this.red.shl(this,t)},r.prototype.redMul=function(t){return this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return this.red._verify1(this),this.red.pow(this,t)};var m={k256:null,p224:null,p192:null,p25519:null};function g(t,e){this.name=t,this.p=new r(e,16),this.n=this.p.bitLength(),this.k=new r(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){g.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function y(){g.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){g.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function M(){g.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function w(t){if("string"==typeof t){var e=r._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function _(t){w.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}g.prototype._tmp=function(){var t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},g.prototype.ireduce=function(t){var e,i=t;do{this.split(i,this.tmp),e=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(e>this.n);var r=e0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},g.prototype.split=function(t,e){t.iushrn(this.n,0,e)},g.prototype.imulK=function(t){return t.imul(this.k)},i(v,g),v.prototype.split=function(t,e){for(var i=Math.min(t.length,9),r=0;r>>22,n=s}n>>>=22,t.words[r-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,i=0;i>>=26,t.words[i]=n,e=r}return 0!==e&&(t.words[t.length++]=e),t},r._prime=function(t){if(m[t])return m[t];var e;if("k256"===t)e=new v;else if("p224"===t)e=new y;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new M}return m[t]=e,e},w.prototype._verify1=function(t){},w.prototype._verify2=function(t,e){},w.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},w.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},w.prototype.add=function(t,e){this._verify2(t,e);var i=t.add(e);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},w.prototype.iadd=function(t,e){this._verify2(t,e);var i=t.iadd(e);return i.cmp(this.m)>=0&&i.isub(this.m),i},w.prototype.sub=function(t,e){this._verify2(t,e);var i=t.sub(e);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},w.prototype.isub=function(t,e){this._verify2(t,e);var i=t.isub(e);return i.cmpn(0)<0&&i.iadd(this.m),i},w.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},w.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},w.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},w.prototype.isqr=function(t){return this.imul(t,t.clone())},w.prototype.sqr=function(t){return this.mul(t,t)},w.prototype.sqrt=function(t){if(t.isZero())return t.clone();if(3===this.m.andln(3)){var e=this.m.add(new r(1)).iushrn(2);return this.pow(t,e)}for(var i=this.m.subn(1),n=0;!i.isZero()&&0===i.andln(1);)n++,i.iushrn(1);var s=new r(1).toRed(this),o=s.redNeg(),h=this.m.subn(1).iushrn(1),a=this.m.bitLength();for(a=new r(2*a*a).toRed(this);0!==this.pow(a,h).cmp(o);)a.redIAdd(o);for(var u=this.pow(a,i),f=this.pow(t,i.addn(1).iushrn(1)),l=this.pow(t,i),c=n;0!==l.cmp(s);){for(var d=l,p=0;0!==d.cmp(s);p++)d=d.redSqr();var m=this.pow(u,new r(1).iushln(c-p-1));f=f.redMul(m),u=m.redSqr(),l=l.redMul(u),c=p}return f},w.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},w.prototype.pow=function(t,e){if(e.isZero())return new r(1).toRed(this);if(0===e.cmpn(1))return t.clone();var i=new Array(16);i[0]=new r(1).toRed(this),i[1]=t;for(var n=2;n=0;n--){for(var u=e.words[n],f=a-1;f>=0;f--){var l=u>>f&1;s!==i[0]&&(s=this.sqr(s)),0!==l||0!==o?(o<<=1,o|=l,(4==++h||0===n&&0===f)&&(s=this.mul(s,i[o]),h=0,o=0)):h=0}a=26}return s},w.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},w.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},r.mont=function(t){return new _(t)},i(_,w),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(e),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new r(0)._forceRed(this);var i=t.mul(e),n=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=i.isub(n).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(ln,this),ln=ln.exports;var cn={exports:{}};!function(t,e){"use strict";function i(t,e){t.super_=e;var i=function(){};i.prototype=e.prototype,t.prototype=new i,t.prototype.constructor=t}function r(t,e,i){if(r.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(i=e,e=10),this._init(t||0,e||10,i||"be"))}var n;"object"==typeof t?t.exports=r:e.BN=r,r.BN=r,r.wordSize=26;try{n=a({}).Buffer}catch(S){}function s(t,e,i){for(var r=0,n=Math.min(t.length,i),s=e;s=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return r}function o(t,e,i,r){for(var n=0,s=Math.min(t.length,i),o=e;o=49?h-49+10:h>=17?h-17+10:h}return n}r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,e){return t.cmp(e)>0?t:e},r.min=function(t,e){return t.cmp(e)<0?t:e},r.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===e?this._parseHex(t,r):this._parseBase(t,e,r),"-"===t[0]&&(this.negative=1),this.strip(),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initArray=function(t,e,i){if(t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r=0;r-=3)s=t[r]|t[r-1]<<8|t[r-2]<<16,this.words[n]|=s<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===i)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this.strip()},r.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=6)n=s(t,i,i+6),this.words[r]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,r++);i+6!==e&&(n=s(t,e,i+6),this.words[r]|=n<>>26-o&4194303),this.strip()},r.prototype._parseBase=function(t,e,i){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=e)r++;r--,n=n/e|0;for(var s=t.length-i,h=s%r,a=Math.min(s,s-h)+i,u=0,f=i;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},r.prototype.inspect=function(){return(this.red?""};var h=["","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],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function l(t,e,i){i.negative=e.negative^t.negative;var r=t.length+e.length|0;i.length=r,r=r-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,h=67108863&o,a=o/67108864|0;i.words[0]=h;for(var u=1;u>>26,l=67108863&a,c=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=c;d++){var p=u-d|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[d])+l)/67108864|0,l=67108863&o}i.words[u]=0|l,a=0|f}return 0!==a?i.words[u]=0|a:i.length--,i.strip()}r.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var r=0,n=0,s=0;s>>24-r&16777215)||s!==this.length-1?h[6-a.length]+a+i:a+i,(r+=2)>=26&&(r-=26,s--)}for(0!==n&&(i=n.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var l=u[t],c=f[t];i="";var d=this.clone();for(d.negative=0;!d.isZero();){var p=d.modn(c).toString(t);i=(d=d.idivn(c)).isZero()?p+i:h[l-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length,0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16)},r.prototype.toBuffer=function(t,e){return this.toArrayLike(n,t,e)},r.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},r.prototype.toArrayLike=function(t,e,i){var r=this.byteLength(),n=i||Math.max(1,r);this.strip();var s,o,h="le"===e,a=new t(n),u=this.clone();if(h){for(o=0;!u.isZero();o++)s=u.andln(255),u.iushrn(8),a[o]=s;for(;o=4096&&(i+=13,e>>>=13),e>=64&&(i+=7,e>>>=7),e>=8&&(i+=4,e>>>=4),e>=2&&(i+=2,e>>>=2),i+e},r.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,i=0;return 0==(8191&e)&&(i+=13,e>>>=13),0==(127&e)&&(i+=7,e>>>=7),0==(15&e)&&(i+=4,e>>>=4),0==(3&e)&&(i+=2,e>>>=2),0==(1&e)&&i++,i},r.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var i=0;it.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var e,i;this.length>t.length?(e=this,i=t):(e=t,i=this);for(var r=0;rt.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-i),this.strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,e){var i=t/26|0,r=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(i=this,r=t):(i=t,r=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i,r,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(i=this,r=t):(i=t,r=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,d=0|o[1],p=8191&d,m=d>>>13,g=0|o[2],v=8191&g,y=g>>>13,b=0|o[3],M=8191&b,w=b>>>13,_=0|o[4],S=8191&_,k=_>>>13,A=0|o[5],E=8191&A,R=A>>>13,x=0|o[6],B=8191&x,I=x>>>13,P=0|o[7],T=8191&P,q=P>>>13,L=0|o[8],j=8191&L,O=L>>>13,N=0|o[9],C=8191&N,$=N>>>13,U=0|h[0],z=8191&U,D=U>>>13,K=0|h[1],W=8191&K,Z=K>>>13,F=0|h[2],V=8191&F,H=F>>>13,G=0|h[3],X=8191&G,Y=G>>>13,J=0|h[4],Q=8191&J,tt=J>>>13,et=0|h[5],it=8191&et,rt=et>>>13,nt=0|h[6],st=8191&nt,ot=nt>>>13,ht=0|h[7],at=8191&ht,ut=ht>>>13,ft=0|h[8],lt=8191&ft,ct=ft>>>13,dt=0|h[9],pt=8191&dt,mt=dt>>>13;i.negative=t.negative^e.negative,i.length=19;var gt=(u+(r=Math.imul(l,z))|0)+((8191&(n=(n=Math.imul(l,D))+Math.imul(c,z)|0))<<13)|0;u=((s=Math.imul(c,D))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(p,z),n=(n=Math.imul(p,D))+Math.imul(m,z)|0,s=Math.imul(m,D);var vt=(u+(r=r+Math.imul(l,W)|0)|0)+((8191&(n=(n=n+Math.imul(l,Z)|0)+Math.imul(c,W)|0))<<13)|0;u=((s=s+Math.imul(c,Z)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(v,z),n=(n=Math.imul(v,D))+Math.imul(y,z)|0,s=Math.imul(y,D),r=r+Math.imul(p,W)|0,n=(n=n+Math.imul(p,Z)|0)+Math.imul(m,W)|0,s=s+Math.imul(m,Z)|0;var yt=(u+(r=r+Math.imul(l,V)|0)|0)+((8191&(n=(n=n+Math.imul(l,H)|0)+Math.imul(c,V)|0))<<13)|0;u=((s=s+Math.imul(c,H)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(M,z),n=(n=Math.imul(M,D))+Math.imul(w,z)|0,s=Math.imul(w,D),r=r+Math.imul(v,W)|0,n=(n=n+Math.imul(v,Z)|0)+Math.imul(y,W)|0,s=s+Math.imul(y,Z)|0,r=r+Math.imul(p,V)|0,n=(n=n+Math.imul(p,H)|0)+Math.imul(m,V)|0,s=s+Math.imul(m,H)|0;var bt=(u+(r=r+Math.imul(l,X)|0)|0)+((8191&(n=(n=n+Math.imul(l,Y)|0)+Math.imul(c,X)|0))<<13)|0;u=((s=s+Math.imul(c,Y)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(S,z),n=(n=Math.imul(S,D))+Math.imul(k,z)|0,s=Math.imul(k,D),r=r+Math.imul(M,W)|0,n=(n=n+Math.imul(M,Z)|0)+Math.imul(w,W)|0,s=s+Math.imul(w,Z)|0,r=r+Math.imul(v,V)|0,n=(n=n+Math.imul(v,H)|0)+Math.imul(y,V)|0,s=s+Math.imul(y,H)|0,r=r+Math.imul(p,X)|0,n=(n=n+Math.imul(p,Y)|0)+Math.imul(m,X)|0,s=s+Math.imul(m,Y)|0;var Mt=(u+(r=r+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(c,Q)|0))<<13)|0;u=((s=s+Math.imul(c,tt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(E,z),n=(n=Math.imul(E,D))+Math.imul(R,z)|0,s=Math.imul(R,D),r=r+Math.imul(S,W)|0,n=(n=n+Math.imul(S,Z)|0)+Math.imul(k,W)|0,s=s+Math.imul(k,Z)|0,r=r+Math.imul(M,V)|0,n=(n=n+Math.imul(M,H)|0)+Math.imul(w,V)|0,s=s+Math.imul(w,H)|0,r=r+Math.imul(v,X)|0,n=(n=n+Math.imul(v,Y)|0)+Math.imul(y,X)|0,s=s+Math.imul(y,Y)|0,r=r+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var wt=(u+(r=r+Math.imul(l,it)|0)|0)+((8191&(n=(n=n+Math.imul(l,rt)|0)+Math.imul(c,it)|0))<<13)|0;u=((s=s+Math.imul(c,rt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(B,z),n=(n=Math.imul(B,D))+Math.imul(I,z)|0,s=Math.imul(I,D),r=r+Math.imul(E,W)|0,n=(n=n+Math.imul(E,Z)|0)+Math.imul(R,W)|0,s=s+Math.imul(R,Z)|0,r=r+Math.imul(S,V)|0,n=(n=n+Math.imul(S,H)|0)+Math.imul(k,V)|0,s=s+Math.imul(k,H)|0,r=r+Math.imul(M,X)|0,n=(n=n+Math.imul(M,Y)|0)+Math.imul(w,X)|0,s=s+Math.imul(w,Y)|0,r=r+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,tt)|0)+Math.imul(y,Q)|0,s=s+Math.imul(y,tt)|0,r=r+Math.imul(p,it)|0,n=(n=n+Math.imul(p,rt)|0)+Math.imul(m,it)|0,s=s+Math.imul(m,rt)|0;var _t=(u+(r=r+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(c,st)|0))<<13)|0;u=((s=s+Math.imul(c,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(T,z),n=(n=Math.imul(T,D))+Math.imul(q,z)|0,s=Math.imul(q,D),r=r+Math.imul(B,W)|0,n=(n=n+Math.imul(B,Z)|0)+Math.imul(I,W)|0,s=s+Math.imul(I,Z)|0,r=r+Math.imul(E,V)|0,n=(n=n+Math.imul(E,H)|0)+Math.imul(R,V)|0,s=s+Math.imul(R,H)|0,r=r+Math.imul(S,X)|0,n=(n=n+Math.imul(S,Y)|0)+Math.imul(k,X)|0,s=s+Math.imul(k,Y)|0,r=r+Math.imul(M,Q)|0,n=(n=n+Math.imul(M,tt)|0)+Math.imul(w,Q)|0,s=s+Math.imul(w,tt)|0,r=r+Math.imul(v,it)|0,n=(n=n+Math.imul(v,rt)|0)+Math.imul(y,it)|0,s=s+Math.imul(y,rt)|0,r=r+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(r=r+Math.imul(l,at)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(c,at)|0))<<13)|0;u=((s=s+Math.imul(c,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(j,z),n=(n=Math.imul(j,D))+Math.imul(O,z)|0,s=Math.imul(O,D),r=r+Math.imul(T,W)|0,n=(n=n+Math.imul(T,Z)|0)+Math.imul(q,W)|0,s=s+Math.imul(q,Z)|0,r=r+Math.imul(B,V)|0,n=(n=n+Math.imul(B,H)|0)+Math.imul(I,V)|0,s=s+Math.imul(I,H)|0,r=r+Math.imul(E,X)|0,n=(n=n+Math.imul(E,Y)|0)+Math.imul(R,X)|0,s=s+Math.imul(R,Y)|0,r=r+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(k,Q)|0,s=s+Math.imul(k,tt)|0,r=r+Math.imul(M,it)|0,n=(n=n+Math.imul(M,rt)|0)+Math.imul(w,it)|0,s=s+Math.imul(w,rt)|0,r=r+Math.imul(v,st)|0,n=(n=n+Math.imul(v,ot)|0)+Math.imul(y,st)|0,s=s+Math.imul(y,ot)|0,r=r+Math.imul(p,at)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,at)|0,s=s+Math.imul(m,ut)|0;var kt=(u+(r=r+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,ct)|0)+Math.imul(c,lt)|0))<<13)|0;u=((s=s+Math.imul(c,ct)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(C,z),n=(n=Math.imul(C,D))+Math.imul($,z)|0,s=Math.imul($,D),r=r+Math.imul(j,W)|0,n=(n=n+Math.imul(j,Z)|0)+Math.imul(O,W)|0,s=s+Math.imul(O,Z)|0,r=r+Math.imul(T,V)|0,n=(n=n+Math.imul(T,H)|0)+Math.imul(q,V)|0,s=s+Math.imul(q,H)|0,r=r+Math.imul(B,X)|0,n=(n=n+Math.imul(B,Y)|0)+Math.imul(I,X)|0,s=s+Math.imul(I,Y)|0,r=r+Math.imul(E,Q)|0,n=(n=n+Math.imul(E,tt)|0)+Math.imul(R,Q)|0,s=s+Math.imul(R,tt)|0,r=r+Math.imul(S,it)|0,n=(n=n+Math.imul(S,rt)|0)+Math.imul(k,it)|0,s=s+Math.imul(k,rt)|0,r=r+Math.imul(M,st)|0,n=(n=n+Math.imul(M,ot)|0)+Math.imul(w,st)|0,s=s+Math.imul(w,ot)|0,r=r+Math.imul(v,at)|0,n=(n=n+Math.imul(v,ut)|0)+Math.imul(y,at)|0,s=s+Math.imul(y,ut)|0,r=r+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,ct)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,ct)|0;var At=(u+(r=r+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(c,pt)|0))<<13)|0;u=((s=s+Math.imul(c,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(C,W),n=(n=Math.imul(C,Z))+Math.imul($,W)|0,s=Math.imul($,Z),r=r+Math.imul(j,V)|0,n=(n=n+Math.imul(j,H)|0)+Math.imul(O,V)|0,s=s+Math.imul(O,H)|0,r=r+Math.imul(T,X)|0,n=(n=n+Math.imul(T,Y)|0)+Math.imul(q,X)|0,s=s+Math.imul(q,Y)|0,r=r+Math.imul(B,Q)|0,n=(n=n+Math.imul(B,tt)|0)+Math.imul(I,Q)|0,s=s+Math.imul(I,tt)|0,r=r+Math.imul(E,it)|0,n=(n=n+Math.imul(E,rt)|0)+Math.imul(R,it)|0,s=s+Math.imul(R,rt)|0,r=r+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(k,st)|0,s=s+Math.imul(k,ot)|0,r=r+Math.imul(M,at)|0,n=(n=n+Math.imul(M,ut)|0)+Math.imul(w,at)|0,s=s+Math.imul(w,ut)|0,r=r+Math.imul(v,lt)|0,n=(n=n+Math.imul(v,ct)|0)+Math.imul(y,lt)|0,s=s+Math.imul(y,ct)|0;var Et=(u+(r=r+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(C,V),n=(n=Math.imul(C,H))+Math.imul($,V)|0,s=Math.imul($,H),r=r+Math.imul(j,X)|0,n=(n=n+Math.imul(j,Y)|0)+Math.imul(O,X)|0,s=s+Math.imul(O,Y)|0,r=r+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(q,Q)|0,s=s+Math.imul(q,tt)|0,r=r+Math.imul(B,it)|0,n=(n=n+Math.imul(B,rt)|0)+Math.imul(I,it)|0,s=s+Math.imul(I,rt)|0,r=r+Math.imul(E,st)|0,n=(n=n+Math.imul(E,ot)|0)+Math.imul(R,st)|0,s=s+Math.imul(R,ot)|0,r=r+Math.imul(S,at)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(k,at)|0,s=s+Math.imul(k,ut)|0,r=r+Math.imul(M,lt)|0,n=(n=n+Math.imul(M,ct)|0)+Math.imul(w,lt)|0,s=s+Math.imul(w,ct)|0;var Rt=(u+(r=r+Math.imul(v,pt)|0)|0)+((8191&(n=(n=n+Math.imul(v,mt)|0)+Math.imul(y,pt)|0))<<13)|0;u=((s=s+Math.imul(y,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(C,X),n=(n=Math.imul(C,Y))+Math.imul($,X)|0,s=Math.imul($,Y),r=r+Math.imul(j,Q)|0,n=(n=n+Math.imul(j,tt)|0)+Math.imul(O,Q)|0,s=s+Math.imul(O,tt)|0,r=r+Math.imul(T,it)|0,n=(n=n+Math.imul(T,rt)|0)+Math.imul(q,it)|0,s=s+Math.imul(q,rt)|0,r=r+Math.imul(B,st)|0,n=(n=n+Math.imul(B,ot)|0)+Math.imul(I,st)|0,s=s+Math.imul(I,ot)|0,r=r+Math.imul(E,at)|0,n=(n=n+Math.imul(E,ut)|0)+Math.imul(R,at)|0,s=s+Math.imul(R,ut)|0,r=r+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,ct)|0)+Math.imul(k,lt)|0,s=s+Math.imul(k,ct)|0;var xt=(u+(r=r+Math.imul(M,pt)|0)|0)+((8191&(n=(n=n+Math.imul(M,mt)|0)+Math.imul(w,pt)|0))<<13)|0;u=((s=s+Math.imul(w,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(C,Q),n=(n=Math.imul(C,tt))+Math.imul($,Q)|0,s=Math.imul($,tt),r=r+Math.imul(j,it)|0,n=(n=n+Math.imul(j,rt)|0)+Math.imul(O,it)|0,s=s+Math.imul(O,rt)|0,r=r+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(q,st)|0,s=s+Math.imul(q,ot)|0,r=r+Math.imul(B,at)|0,n=(n=n+Math.imul(B,ut)|0)+Math.imul(I,at)|0,s=s+Math.imul(I,ut)|0,r=r+Math.imul(E,lt)|0,n=(n=n+Math.imul(E,ct)|0)+Math.imul(R,lt)|0,s=s+Math.imul(R,ct)|0;var Bt=(u+(r=r+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(k,pt)|0))<<13)|0;u=((s=s+Math.imul(k,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(C,it),n=(n=Math.imul(C,rt))+Math.imul($,it)|0,s=Math.imul($,rt),r=r+Math.imul(j,st)|0,n=(n=n+Math.imul(j,ot)|0)+Math.imul(O,st)|0,s=s+Math.imul(O,ot)|0,r=r+Math.imul(T,at)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(q,at)|0,s=s+Math.imul(q,ut)|0,r=r+Math.imul(B,lt)|0,n=(n=n+Math.imul(B,ct)|0)+Math.imul(I,lt)|0,s=s+Math.imul(I,ct)|0;var It=(u+(r=r+Math.imul(E,pt)|0)|0)+((8191&(n=(n=n+Math.imul(E,mt)|0)+Math.imul(R,pt)|0))<<13)|0;u=((s=s+Math.imul(R,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(C,st),n=(n=Math.imul(C,ot))+Math.imul($,st)|0,s=Math.imul($,ot),r=r+Math.imul(j,at)|0,n=(n=n+Math.imul(j,ut)|0)+Math.imul(O,at)|0,s=s+Math.imul(O,ut)|0,r=r+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,ct)|0)+Math.imul(q,lt)|0,s=s+Math.imul(q,ct)|0;var Pt=(u+(r=r+Math.imul(B,pt)|0)|0)+((8191&(n=(n=n+Math.imul(B,mt)|0)+Math.imul(I,pt)|0))<<13)|0;u=((s=s+Math.imul(I,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(C,at),n=(n=Math.imul(C,ut))+Math.imul($,at)|0,s=Math.imul($,ut),r=r+Math.imul(j,lt)|0,n=(n=n+Math.imul(j,ct)|0)+Math.imul(O,lt)|0,s=s+Math.imul(O,ct)|0;var Tt=(u+(r=r+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(q,pt)|0))<<13)|0;u=((s=s+Math.imul(q,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(C,lt),n=(n=Math.imul(C,ct))+Math.imul($,lt)|0,s=Math.imul($,ct);var qt=(u+(r=r+Math.imul(j,pt)|0)|0)+((8191&(n=(n=n+Math.imul(j,mt)|0)+Math.imul(O,pt)|0))<<13)|0;u=((s=s+Math.imul(O,mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863;var Lt=(u+(r=Math.imul(C,pt))|0)+((8191&(n=(n=Math.imul(C,mt))+Math.imul($,pt)|0))<<13)|0;return u=((s=Math.imul($,mt))+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,a[0]=gt,a[1]=vt,a[2]=yt,a[3]=bt,a[4]=Mt,a[5]=wt,a[6]=_t,a[7]=St,a[8]=kt,a[9]=At,a[10]=Et,a[11]=Rt,a[12]=xt,a[13]=Bt,a[14]=It,a[15]=Pt,a[16]=Tt,a[17]=qt,a[18]=Lt,0!==u&&(a[19]=u,i.length++),i};function d(t,e,i){return(new p).mulp(t,e,i)}function p(t,e){this.x=t,this.y=e}Math.imul||(c=l),r.prototype.mulTo=function(t,e){var i=this.length+t.length;return 10===this.length&&10===t.length?c(this,t,e):i<63?l(this,t,e):i<1024?function(t,e,i){i.negative=e.negative^t.negative,i.length=t.length+e.length;for(var r=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}i.words[s]=h,r=o,o=n}return 0!==r?i.words[s]=r:i.length--,i.strip()}(this,t,e):d(this,t,e)},p.prototype.makeRBT=function(t){for(var e=new Array(t),i=r.prototype._countBits(t)-1,n=0;n>=1;return r},p.prototype.permute=function(t,e,i,r,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*s+1]=8191&n,n>>>=13;for(s=2*e;s>=26,e+=r/67108864|0,e+=n>>>26,this.words[i]=67108863&n}return 0!==e&&(this.words[i]=e,this.length++),this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),i=0;i>>n}return e}(t);if(0===e.length)return new r(1);for(var i=this,n=0;n>>26-i<<26-i;if(0!==i){var s=0;for(e=0;e>>26-i}s&&(this.words[e]=s,this.length++)}if(0!==r){for(e=this.length-1;e>=0;e--)this.words[e+r]=this.words[e];for(e=0;e>>n<s)for(this.length-=s,a=0;a=0&&(0!==u||a>=r);a--){var f=0|this.words[a];this.words[a]=u<<26-n|f>>>n,u=f&o}return h&&0!==u&&(h.words[h.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},r.prototype.ishrn=function(t,e,i){return this.iushrn(t,e,i)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){var e=t%26,i=(t-e)/26,r=1<>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},r.prototype.isubn=function(t){if(t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[r+i]=67108863&n}for(;r>26,this.words[r+i]=67108863&n;if(0===o)return this.strip();for(o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},r.prototype._wordDiv=function(t,e){var i=(this.length,t.length),n=this.clone(),s=t,o=0|s.words[s.length-1];0!=(i=26-this._countBits(o))&&(s=s.ushln(i),n.iushln(i),o=0|s.words[s.length-1]);var h,a=n.length-s.length;if("mod"!==e){(h=new r(null)).length=a+1,h.words=new Array(h.length);for(var u=0;u=0;l--){var c=67108864*(0|n.words[s.length+l])+(0|n.words[s.length+l-1]);for(c=Math.min(c/o|0,67108863),n._ishlnsubmul(s,c,l);0!==n.negative;)c--,n.negative=0,n._ishlnsubmul(s,1,l),n.isZero()||(n.negative^=1);h&&(h.words[l]=c)}return h&&h.strip(),n.strip(),"div"!==e&&0!==i&&n.iushrn(i),{div:h||null,mod:n}},r.prototype.divmod=function(t,e,i){return this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),"mod"!==e&&(n=o.div.neg()),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),e),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new r(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var i=0!==e.div.negative?e.mod.isub(t):e.mod,r=t.ushrn(1),n=t.andln(1),s=i.cmp(r);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},r.prototype.modn=function(t){for(var e=(1<<26)%t,i=0,r=this.length-1;r>=0;r--)i=(e*i+(0|this.words[r]))%t;return i},r.prototype.idivn=function(t){for(var e=0,i=this.length-1;i>=0;i--){var r=(0|this.words[i])+67108864*e;this.words[i]=r/t|0,e=r%t}return this.strip()},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new r(1),s=new r(0),o=new r(0),h=new r(1),a=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++a;for(var u=i.clone(),f=e.clone();!e.isZero();){for(var l=0,c=1;0==(e.words[0]&c)&&l<26;++l,c<<=1);if(l>0)for(e.iushrn(l);l-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(u),s.isub(f)),n.iushrn(1),s.iushrn(1);for(var d=0,p=1;0==(i.words[0]&p)&&d<26;++d,p<<=1);if(d>0)for(i.iushrn(d);d-- >0;)(o.isOdd()||h.isOdd())&&(o.iadd(u),h.isub(f)),o.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),n.isub(o),s.isub(h)):(i.isub(e),o.isub(n),h.isub(s))}return{a:o,b:h,gcd:i.iushln(a)}},r.prototype._invmp=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new r(1),o=new r(0),h=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var a=0,u=1;0==(e.words[0]&u)&&a<26;++a,u<<=1);if(a>0)for(e.iushrn(a);a-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);for(var f=0,l=1;0==(i.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(i.iushrn(f);f-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o)):(i.isub(e),o.isub(s))}return(n=0===e.cmpn(1)?s:o).cmpn(0)<0&&n.iadd(t),n},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),i=t.clone();e.negative=0,i.negative=0;for(var r=0;e.isEven()&&i.isEven();r++)e.iushrn(1),i.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;i.isEven();)i.iushrn(1);var n=e.cmp(i);if(n<0){var s=e;e=i,i=s}else if(0===n||0===i.cmpn(1))break;e.isub(i)}return i.iushln(r)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){var e=t%26,i=(t-e)/26,r=1<>>26,o&=67108863,this.words[s]=o}return 0!==n&&(this.words[s]=n,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t);var r=0|this.words[0];e=r===t?0:rt.length)return 1;if(this.length=0;i--){var r=0|this.words[i],n=0|t.words[i];if(r!==n){rn&&(e=1);break}}return e},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new w(t)},r.prototype.toRed=function(t){return t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return this._forceRed(t)},r.prototype.redAdd=function(t){return this.red.add(this,t)},r.prototype.redIAdd=function(t){return this.red.iadd(this,t)},r.prototype.redSub=function(t){return this.red.sub(this,t)},r.prototype.redISub=function(t){return this.red.isub(this,t)},r.prototype.redShl=function(t){return this.red.shl(this,t)},r.prototype.redMul=function(t){return this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return this.red._verify1(this),this.red.pow(this,t)};var m={k256:null,p224:null,p192:null,p25519:null};function g(t,e){this.name=t,this.p=new r(e,16),this.n=this.p.bitLength(),this.k=new r(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){g.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function y(){g.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){g.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function M(){g.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function w(t){if("string"==typeof t){var e=r._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function _(t){w.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}g.prototype._tmp=function(){var t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},g.prototype.ireduce=function(t){var e,i=t;do{this.split(i,this.tmp),e=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(e>this.n);var r=e0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},g.prototype.split=function(t,e){t.iushrn(this.n,0,e)},g.prototype.imulK=function(t){return t.imul(this.k)},i(v,g),v.prototype.split=function(t,e){for(var i=Math.min(t.length,9),r=0;r>>22,n=s}n>>>=22,t.words[r-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,i=0;i>>=26,t.words[i]=n,e=r}return 0!==e&&(t.words[t.length++]=e),t},r._prime=function(t){if(m[t])return m[t];var e;if("k256"===t)e=new v;else if("p224"===t)e=new y;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new M}return m[t]=e,e},w.prototype._verify1=function(t){},w.prototype._verify2=function(t,e){},w.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},w.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},w.prototype.add=function(t,e){this._verify2(t,e);var i=t.add(e);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},w.prototype.iadd=function(t,e){this._verify2(t,e);var i=t.iadd(e);return i.cmp(this.m)>=0&&i.isub(this.m),i},w.prototype.sub=function(t,e){this._verify2(t,e);var i=t.sub(e);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},w.prototype.isub=function(t,e){this._verify2(t,e);var i=t.isub(e);return i.cmpn(0)<0&&i.iadd(this.m),i},w.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},w.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},w.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},w.prototype.isqr=function(t){return this.imul(t,t.clone())},w.prototype.sqr=function(t){return this.mul(t,t)},w.prototype.sqrt=function(t){if(t.isZero())return t.clone();if(3===this.m.andln(3)){var e=this.m.add(new r(1)).iushrn(2);return this.pow(t,e)}for(var i=this.m.subn(1),n=0;!i.isZero()&&0===i.andln(1);)n++,i.iushrn(1);var s=new r(1).toRed(this),o=s.redNeg(),h=this.m.subn(1).iushrn(1),a=this.m.bitLength();for(a=new r(2*a*a).toRed(this);0!==this.pow(a,h).cmp(o);)a.redIAdd(o);for(var u=this.pow(a,i),f=this.pow(t,i.addn(1).iushrn(1)),l=this.pow(t,i),c=n;0!==l.cmp(s);){for(var d=l,p=0;0!==d.cmp(s);p++)d=d.redSqr();var m=this.pow(u,new r(1).iushln(c-p-1));f=f.redMul(m),u=m.redSqr(),l=l.redMul(u),c=p}return f},w.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},w.prototype.pow=function(t,e){if(e.isZero())return new r(1).toRed(this);if(0===e.cmpn(1))return t.clone();var i=new Array(16);i[0]=new r(1).toRed(this),i[1]=t;for(var n=2;n=0;n--){for(var u=e.words[n],f=a-1;f>=0;f--){var l=u>>f&1;s!==i[0]&&(s=this.sqr(s)),0!==l||0!==o?(o<<=1,o|=l,(4==++h||0===n&&0===f)&&(s=this.mul(s,i[o]),h=0,o=0)):h=0}a=26}return s},w.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},w.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},r.mont=function(t){return new _(t)},i(_,w),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(e),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new r(0)._forceRed(this);var i=t.mul(e),n=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=i.isub(n).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(cn,this),cn=cn.exports;var dn,pn;function mn(t){this.rand=t}if((dn=function(t){return pn||(pn=new mn(null)),pn.generate(t)}).Rand=mn,mn.prototype.generate=function(t){return this._rand(t)},mn.prototype._rand=function(t){if(this.rand.getBytes)return this.rand.getBytes(t);for(var e=new Uint8Array(t),i=0;i=0);return r},yn.prototype._randrange=function(t,e){var i=e.sub(t);return t.add(this._randbelow(i))},yn.prototype.test=function(t,e,i){var r=t.bitLength(),n=cn.mont(t),s=new cn(1).toRed(n);e||(e=Math.max(1,r/48|0));for(var o=t.subn(1),h=0;!o.testn(h);h++);for(var a=t.shrn(h),u=o.toRed(n);e>0;e--){var f=this._randrange(new cn(2),o);i&&i(f);var l=f.toRed(n).redPow(a);if(0!==l.cmp(s)&&0!==l.cmp(u)){for(var c=1;c0;e--){var u=this._randrange(new cn(2),s),f=t.gcd(u);if(0!==f.cmpn(1))return f;var l=u.toRed(r).redPow(h);if(0!==l.cmp(n)&&0!==l.cmp(a)){for(var c=1;ct;)i.ishrn(1);if(i.isEven()&&i.iadd(_n),i.testn(1)||i.iadd(Sn),e.cmp(Sn)){if(!e.cmp(kn))for(;i.mod(An).cmp(En);)i.iadd(xn)}else for(;i.mod(Mn).cmp(Rn);)i.iadd(xn);if(Pn(r=i.shrn(1))&&Pn(i)&&Tn(r)&&Tn(i)&&wn.test(r)&&wn.test(i))return i}}(function(t){(function(){var e=new vn,i=new ln(24),r=new ln(11),n=new ln(10),s=new ln(3),o=new ln(7);function h(e,i){return i=i||"utf8",t.isBuffer(e)||(e=new t(e,i)),this._pub=new ln(e),this}function a(e,i){return i=i||"utf8",t.isBuffer(e)||(e=new t(e,i)),this._priv=new ln(e),this}f;var u={};function f(t,e,i){this.setGenerator(e),this.__prime=new ln(t),this._prime=ln.mont(this.__prime),this._primeLen=t.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,i?(this.setPublicKey=h,this.setPrivateKey=a):this._primeCode=8}function l(e,i){var r=new t(e.toArray());return i?r.toString(i):r}Object.defineProperty(f.prototype,"verifyError",{enumerable:!0,get:function(){return"number"!=typeof this._primeCode&&(this._primeCode=function(t,h){var a=h.toString("hex"),f=[a,t.toString(16)].join("_");if(f in u)return u[f];var l,c=0;if(t.isEven()||!bn.simpleSieve||!bn.fermatTest(t)||!e.test(t))return c+=1,c+="02"===a||"05"===a?8:4,u[f]=c,c;switch(e.test(t.shrn(1))||(c+=2),a){case"02":t.mod(i).cmp(r)&&(c+=8);break;case"05":(l=t.mod(n)).cmp(s)&&l.cmp(o)&&(c+=8);break;default:c+=4}return u[f]=c,c}(this.__prime,this.__gen)),this._primeCode}}),f.prototype.generateKeys=function(){return this._priv||(this._priv=new ln(U(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()},f.prototype.computeSecret=function(e){var i=(e=(e=new ln(e)).toRed(this._prime)).redPow(this._priv).fromRed(),r=new t(i.toArray()),n=this.getPrime();if(r.length=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:o}return r}function o(t,e,i,r){for(var n=0,s=Math.min(t.length,i),o=e;o=49?h-49+10:h>=17?h-17+10:h}return n}function h(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,e){return t.cmp(e)>0?t:e},r.min=function(t,e){return t.cmp(e)<0?t:e},r.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===e?this._parseHex(t,r):this._parseBase(t,e,r),"-"===t[0]&&(this.negative=1),this._strip(),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initArray=function(t,e,i){if(t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r=0;r-=3)s=t[r]|t[r-1]<<8|t[r-2]<<16,this.words[n]|=s<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===i)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this._strip()},r.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=6)n=s(t,i,i+6),this.words[r]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,r++);i+6!==e&&(n=s(t,e,i+6),this.words[r]|=n<>>26-o&4194303),this._strip()},r.prototype._parseBase=function(t,e,i){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=e)r++;r--,n=n/e|0;for(var s=t.length-i,h=s%r,a=Math.min(s,s-h)+i,u=0,f=i;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{r.prototype[Symbol.for("nodejs.util.inspect.custom")]=u}catch(hu){r.prototype.inspect=u}else r.prototype.inspect=u;function u(){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"],l=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],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(t,e,i){i.negative=e.negative^t.negative;var r=t.length+e.length|0;i.length=r,r=r-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,h=67108863&o,a=o/67108864|0;i.words[0]=h;for(var u=1;u>>26,l=67108863&a,c=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=c;d++){var p=u-d|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[d])+l)/67108864|0,l=67108863&o}i.words[u]=0|l,a=0|f}return 0!==a?i.words[u]=0|a:i.length--,i._strip()}r.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var r=0,n=0,s=0;s>>24-r&16777215)||s!==this.length-1?f[6-h.length]+h+i:h+i,(r+=2)>=26&&(r-=26,s--)}for(0!==n&&(i=n.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var a=l[t],u=c[t];i="";var d=this.clone();for(d.negative=0;!d.isZero();){var p=d.modrn(u).toString(t);i=(d=d.idivn(u)).isZero()?p+i:f[a-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length,0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16,2)},n&&(r.prototype.toBuffer=function(t,e){return this.toArrayLike(n,t,e)}),r.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},r.prototype.toArrayLike=function(t,e,i){this._strip();var r=this.byteLength(),n=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,i||Math.max(1,r));return this["_toArrayLike"+("le"===e?"LE":"BE")](n,r),n},r.prototype._toArrayLikeLE=function(t,e){for(var i=0,r=0,n=0,s=0;n>8&255),i>16&255),6===s?(i>24&255),r=0,s=0):(r=o>>>24,s+=2)}if(i=0&&(t[i--]=o>>8&255),i>=0&&(t[i--]=o>>16&255),6===s?(i>=0&&(t[i--]=o>>24&255),r=0,s=0):(r=o>>>24,s+=2)}if(i>=0)for(t[i--]=r;i>=0;)t[i--]=0},Math.clz32?r.prototype._countBits=function(t){return 32-Math.clz32(t)}:r.prototype._countBits=function(t){var e=t,i=0;return e>=4096&&(i+=13,e>>>=13),e>=64&&(i+=7,e>>>=7),e>=8&&(i+=4,e>>>=4),e>=2&&(i+=2,e>>>=2),i+e},r.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,i=0;return 0==(8191&e)&&(i+=13,e>>>=13),0==(127&e)&&(i+=7,e>>>=7),0==(15&e)&&(i+=4,e>>>=4),0==(3&e)&&(i+=2,e>>>=2),0==(1&e)&&i++,i},r.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var i=0;it.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var e,i;this.length>t.length?(e=this,i=t):(e=t,i=this);for(var r=0;rt.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-i),this._strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,e){var i=t/26|0,r=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(i=this,r=t):(i=t,r=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i,r,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(i=this,r=t):(i=t,r=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,d=0|o[1],p=8191&d,m=d>>>13,g=0|o[2],v=8191&g,y=g>>>13,b=0|o[3],M=8191&b,w=b>>>13,_=0|o[4],S=8191&_,k=_>>>13,A=0|o[5],E=8191&A,R=A>>>13,x=0|o[6],B=8191&x,I=x>>>13,P=0|o[7],T=8191&P,q=P>>>13,L=0|o[8],j=8191&L,O=L>>>13,N=0|o[9],C=8191&N,$=N>>>13,U=0|h[0],z=8191&U,D=U>>>13,K=0|h[1],W=8191&K,Z=K>>>13,F=0|h[2],V=8191&F,H=F>>>13,G=0|h[3],X=8191&G,Y=G>>>13,J=0|h[4],Q=8191&J,tt=J>>>13,et=0|h[5],it=8191&et,rt=et>>>13,nt=0|h[6],st=8191&nt,ot=nt>>>13,ht=0|h[7],at=8191&ht,ut=ht>>>13,ft=0|h[8],lt=8191&ft,ct=ft>>>13,dt=0|h[9],pt=8191&dt,mt=dt>>>13;i.negative=t.negative^e.negative,i.length=19;var gt=(u+(r=Math.imul(l,z))|0)+((8191&(n=(n=Math.imul(l,D))+Math.imul(c,z)|0))<<13)|0;u=((s=Math.imul(c,D))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(p,z),n=(n=Math.imul(p,D))+Math.imul(m,z)|0,s=Math.imul(m,D);var vt=(u+(r=r+Math.imul(l,W)|0)|0)+((8191&(n=(n=n+Math.imul(l,Z)|0)+Math.imul(c,W)|0))<<13)|0;u=((s=s+Math.imul(c,Z)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(v,z),n=(n=Math.imul(v,D))+Math.imul(y,z)|0,s=Math.imul(y,D),r=r+Math.imul(p,W)|0,n=(n=n+Math.imul(p,Z)|0)+Math.imul(m,W)|0,s=s+Math.imul(m,Z)|0;var yt=(u+(r=r+Math.imul(l,V)|0)|0)+((8191&(n=(n=n+Math.imul(l,H)|0)+Math.imul(c,V)|0))<<13)|0;u=((s=s+Math.imul(c,H)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(M,z),n=(n=Math.imul(M,D))+Math.imul(w,z)|0,s=Math.imul(w,D),r=r+Math.imul(v,W)|0,n=(n=n+Math.imul(v,Z)|0)+Math.imul(y,W)|0,s=s+Math.imul(y,Z)|0,r=r+Math.imul(p,V)|0,n=(n=n+Math.imul(p,H)|0)+Math.imul(m,V)|0,s=s+Math.imul(m,H)|0;var bt=(u+(r=r+Math.imul(l,X)|0)|0)+((8191&(n=(n=n+Math.imul(l,Y)|0)+Math.imul(c,X)|0))<<13)|0;u=((s=s+Math.imul(c,Y)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(S,z),n=(n=Math.imul(S,D))+Math.imul(k,z)|0,s=Math.imul(k,D),r=r+Math.imul(M,W)|0,n=(n=n+Math.imul(M,Z)|0)+Math.imul(w,W)|0,s=s+Math.imul(w,Z)|0,r=r+Math.imul(v,V)|0,n=(n=n+Math.imul(v,H)|0)+Math.imul(y,V)|0,s=s+Math.imul(y,H)|0,r=r+Math.imul(p,X)|0,n=(n=n+Math.imul(p,Y)|0)+Math.imul(m,X)|0,s=s+Math.imul(m,Y)|0;var Mt=(u+(r=r+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(c,Q)|0))<<13)|0;u=((s=s+Math.imul(c,tt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(E,z),n=(n=Math.imul(E,D))+Math.imul(R,z)|0,s=Math.imul(R,D),r=r+Math.imul(S,W)|0,n=(n=n+Math.imul(S,Z)|0)+Math.imul(k,W)|0,s=s+Math.imul(k,Z)|0,r=r+Math.imul(M,V)|0,n=(n=n+Math.imul(M,H)|0)+Math.imul(w,V)|0,s=s+Math.imul(w,H)|0,r=r+Math.imul(v,X)|0,n=(n=n+Math.imul(v,Y)|0)+Math.imul(y,X)|0,s=s+Math.imul(y,Y)|0,r=r+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var wt=(u+(r=r+Math.imul(l,it)|0)|0)+((8191&(n=(n=n+Math.imul(l,rt)|0)+Math.imul(c,it)|0))<<13)|0;u=((s=s+Math.imul(c,rt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(B,z),n=(n=Math.imul(B,D))+Math.imul(I,z)|0,s=Math.imul(I,D),r=r+Math.imul(E,W)|0,n=(n=n+Math.imul(E,Z)|0)+Math.imul(R,W)|0,s=s+Math.imul(R,Z)|0,r=r+Math.imul(S,V)|0,n=(n=n+Math.imul(S,H)|0)+Math.imul(k,V)|0,s=s+Math.imul(k,H)|0,r=r+Math.imul(M,X)|0,n=(n=n+Math.imul(M,Y)|0)+Math.imul(w,X)|0,s=s+Math.imul(w,Y)|0,r=r+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,tt)|0)+Math.imul(y,Q)|0,s=s+Math.imul(y,tt)|0,r=r+Math.imul(p,it)|0,n=(n=n+Math.imul(p,rt)|0)+Math.imul(m,it)|0,s=s+Math.imul(m,rt)|0;var _t=(u+(r=r+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(c,st)|0))<<13)|0;u=((s=s+Math.imul(c,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(T,z),n=(n=Math.imul(T,D))+Math.imul(q,z)|0,s=Math.imul(q,D),r=r+Math.imul(B,W)|0,n=(n=n+Math.imul(B,Z)|0)+Math.imul(I,W)|0,s=s+Math.imul(I,Z)|0,r=r+Math.imul(E,V)|0,n=(n=n+Math.imul(E,H)|0)+Math.imul(R,V)|0,s=s+Math.imul(R,H)|0,r=r+Math.imul(S,X)|0,n=(n=n+Math.imul(S,Y)|0)+Math.imul(k,X)|0,s=s+Math.imul(k,Y)|0,r=r+Math.imul(M,Q)|0,n=(n=n+Math.imul(M,tt)|0)+Math.imul(w,Q)|0,s=s+Math.imul(w,tt)|0,r=r+Math.imul(v,it)|0,n=(n=n+Math.imul(v,rt)|0)+Math.imul(y,it)|0,s=s+Math.imul(y,rt)|0,r=r+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(r=r+Math.imul(l,at)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(c,at)|0))<<13)|0;u=((s=s+Math.imul(c,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(j,z),n=(n=Math.imul(j,D))+Math.imul(O,z)|0,s=Math.imul(O,D),r=r+Math.imul(T,W)|0,n=(n=n+Math.imul(T,Z)|0)+Math.imul(q,W)|0,s=s+Math.imul(q,Z)|0,r=r+Math.imul(B,V)|0,n=(n=n+Math.imul(B,H)|0)+Math.imul(I,V)|0,s=s+Math.imul(I,H)|0,r=r+Math.imul(E,X)|0,n=(n=n+Math.imul(E,Y)|0)+Math.imul(R,X)|0,s=s+Math.imul(R,Y)|0,r=r+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(k,Q)|0,s=s+Math.imul(k,tt)|0,r=r+Math.imul(M,it)|0,n=(n=n+Math.imul(M,rt)|0)+Math.imul(w,it)|0,s=s+Math.imul(w,rt)|0,r=r+Math.imul(v,st)|0,n=(n=n+Math.imul(v,ot)|0)+Math.imul(y,st)|0,s=s+Math.imul(y,ot)|0,r=r+Math.imul(p,at)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,at)|0,s=s+Math.imul(m,ut)|0;var kt=(u+(r=r+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,ct)|0)+Math.imul(c,lt)|0))<<13)|0;u=((s=s+Math.imul(c,ct)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(C,z),n=(n=Math.imul(C,D))+Math.imul($,z)|0,s=Math.imul($,D),r=r+Math.imul(j,W)|0,n=(n=n+Math.imul(j,Z)|0)+Math.imul(O,W)|0,s=s+Math.imul(O,Z)|0,r=r+Math.imul(T,V)|0,n=(n=n+Math.imul(T,H)|0)+Math.imul(q,V)|0,s=s+Math.imul(q,H)|0,r=r+Math.imul(B,X)|0,n=(n=n+Math.imul(B,Y)|0)+Math.imul(I,X)|0,s=s+Math.imul(I,Y)|0,r=r+Math.imul(E,Q)|0,n=(n=n+Math.imul(E,tt)|0)+Math.imul(R,Q)|0,s=s+Math.imul(R,tt)|0,r=r+Math.imul(S,it)|0,n=(n=n+Math.imul(S,rt)|0)+Math.imul(k,it)|0,s=s+Math.imul(k,rt)|0,r=r+Math.imul(M,st)|0,n=(n=n+Math.imul(M,ot)|0)+Math.imul(w,st)|0,s=s+Math.imul(w,ot)|0,r=r+Math.imul(v,at)|0,n=(n=n+Math.imul(v,ut)|0)+Math.imul(y,at)|0,s=s+Math.imul(y,ut)|0,r=r+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,ct)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,ct)|0;var At=(u+(r=r+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(c,pt)|0))<<13)|0;u=((s=s+Math.imul(c,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(C,W),n=(n=Math.imul(C,Z))+Math.imul($,W)|0,s=Math.imul($,Z),r=r+Math.imul(j,V)|0,n=(n=n+Math.imul(j,H)|0)+Math.imul(O,V)|0,s=s+Math.imul(O,H)|0,r=r+Math.imul(T,X)|0,n=(n=n+Math.imul(T,Y)|0)+Math.imul(q,X)|0,s=s+Math.imul(q,Y)|0,r=r+Math.imul(B,Q)|0,n=(n=n+Math.imul(B,tt)|0)+Math.imul(I,Q)|0,s=s+Math.imul(I,tt)|0,r=r+Math.imul(E,it)|0,n=(n=n+Math.imul(E,rt)|0)+Math.imul(R,it)|0,s=s+Math.imul(R,rt)|0,r=r+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(k,st)|0,s=s+Math.imul(k,ot)|0,r=r+Math.imul(M,at)|0,n=(n=n+Math.imul(M,ut)|0)+Math.imul(w,at)|0,s=s+Math.imul(w,ut)|0,r=r+Math.imul(v,lt)|0,n=(n=n+Math.imul(v,ct)|0)+Math.imul(y,lt)|0,s=s+Math.imul(y,ct)|0;var Et=(u+(r=r+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(C,V),n=(n=Math.imul(C,H))+Math.imul($,V)|0,s=Math.imul($,H),r=r+Math.imul(j,X)|0,n=(n=n+Math.imul(j,Y)|0)+Math.imul(O,X)|0,s=s+Math.imul(O,Y)|0,r=r+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(q,Q)|0,s=s+Math.imul(q,tt)|0,r=r+Math.imul(B,it)|0,n=(n=n+Math.imul(B,rt)|0)+Math.imul(I,it)|0,s=s+Math.imul(I,rt)|0,r=r+Math.imul(E,st)|0,n=(n=n+Math.imul(E,ot)|0)+Math.imul(R,st)|0,s=s+Math.imul(R,ot)|0,r=r+Math.imul(S,at)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(k,at)|0,s=s+Math.imul(k,ut)|0,r=r+Math.imul(M,lt)|0,n=(n=n+Math.imul(M,ct)|0)+Math.imul(w,lt)|0,s=s+Math.imul(w,ct)|0;var Rt=(u+(r=r+Math.imul(v,pt)|0)|0)+((8191&(n=(n=n+Math.imul(v,mt)|0)+Math.imul(y,pt)|0))<<13)|0;u=((s=s+Math.imul(y,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(C,X),n=(n=Math.imul(C,Y))+Math.imul($,X)|0,s=Math.imul($,Y),r=r+Math.imul(j,Q)|0,n=(n=n+Math.imul(j,tt)|0)+Math.imul(O,Q)|0,s=s+Math.imul(O,tt)|0,r=r+Math.imul(T,it)|0,n=(n=n+Math.imul(T,rt)|0)+Math.imul(q,it)|0,s=s+Math.imul(q,rt)|0,r=r+Math.imul(B,st)|0,n=(n=n+Math.imul(B,ot)|0)+Math.imul(I,st)|0,s=s+Math.imul(I,ot)|0,r=r+Math.imul(E,at)|0,n=(n=n+Math.imul(E,ut)|0)+Math.imul(R,at)|0,s=s+Math.imul(R,ut)|0,r=r+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,ct)|0)+Math.imul(k,lt)|0,s=s+Math.imul(k,ct)|0;var xt=(u+(r=r+Math.imul(M,pt)|0)|0)+((8191&(n=(n=n+Math.imul(M,mt)|0)+Math.imul(w,pt)|0))<<13)|0;u=((s=s+Math.imul(w,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(C,Q),n=(n=Math.imul(C,tt))+Math.imul($,Q)|0,s=Math.imul($,tt),r=r+Math.imul(j,it)|0,n=(n=n+Math.imul(j,rt)|0)+Math.imul(O,it)|0,s=s+Math.imul(O,rt)|0,r=r+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(q,st)|0,s=s+Math.imul(q,ot)|0,r=r+Math.imul(B,at)|0,n=(n=n+Math.imul(B,ut)|0)+Math.imul(I,at)|0,s=s+Math.imul(I,ut)|0,r=r+Math.imul(E,lt)|0,n=(n=n+Math.imul(E,ct)|0)+Math.imul(R,lt)|0,s=s+Math.imul(R,ct)|0;var Bt=(u+(r=r+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(k,pt)|0))<<13)|0;u=((s=s+Math.imul(k,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(C,it),n=(n=Math.imul(C,rt))+Math.imul($,it)|0,s=Math.imul($,rt),r=r+Math.imul(j,st)|0,n=(n=n+Math.imul(j,ot)|0)+Math.imul(O,st)|0,s=s+Math.imul(O,ot)|0,r=r+Math.imul(T,at)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(q,at)|0,s=s+Math.imul(q,ut)|0,r=r+Math.imul(B,lt)|0,n=(n=n+Math.imul(B,ct)|0)+Math.imul(I,lt)|0,s=s+Math.imul(I,ct)|0;var It=(u+(r=r+Math.imul(E,pt)|0)|0)+((8191&(n=(n=n+Math.imul(E,mt)|0)+Math.imul(R,pt)|0))<<13)|0;u=((s=s+Math.imul(R,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(C,st),n=(n=Math.imul(C,ot))+Math.imul($,st)|0,s=Math.imul($,ot),r=r+Math.imul(j,at)|0,n=(n=n+Math.imul(j,ut)|0)+Math.imul(O,at)|0,s=s+Math.imul(O,ut)|0,r=r+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,ct)|0)+Math.imul(q,lt)|0,s=s+Math.imul(q,ct)|0;var Pt=(u+(r=r+Math.imul(B,pt)|0)|0)+((8191&(n=(n=n+Math.imul(B,mt)|0)+Math.imul(I,pt)|0))<<13)|0;u=((s=s+Math.imul(I,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(C,at),n=(n=Math.imul(C,ut))+Math.imul($,at)|0,s=Math.imul($,ut),r=r+Math.imul(j,lt)|0,n=(n=n+Math.imul(j,ct)|0)+Math.imul(O,lt)|0,s=s+Math.imul(O,ct)|0;var Tt=(u+(r=r+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(q,pt)|0))<<13)|0;u=((s=s+Math.imul(q,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(C,lt),n=(n=Math.imul(C,ct))+Math.imul($,lt)|0,s=Math.imul($,ct);var qt=(u+(r=r+Math.imul(j,pt)|0)|0)+((8191&(n=(n=n+Math.imul(j,mt)|0)+Math.imul(O,pt)|0))<<13)|0;u=((s=s+Math.imul(O,mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863;var Lt=(u+(r=Math.imul(C,pt))|0)+((8191&(n=(n=Math.imul(C,mt))+Math.imul($,pt)|0))<<13)|0;return u=((s=Math.imul($,mt))+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,a[0]=gt,a[1]=vt,a[2]=yt,a[3]=bt,a[4]=Mt,a[5]=wt,a[6]=_t,a[7]=St,a[8]=kt,a[9]=At,a[10]=Et,a[11]=Rt,a[12]=xt,a[13]=Bt,a[14]=It,a[15]=Pt,a[16]=Tt,a[17]=qt,a[18]=Lt,0!==u&&(a[19]=u,i.length++),i};function m(t,e,i){i.negative=e.negative^t.negative,i.length=t.length+e.length;for(var r=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}i.words[s]=h,r=o,o=n}return 0!==r?i.words[s]=r:i.length--,i._strip()}function g(t,e,i){return m(t,e,i)}function v(t,e){this.x=t,this.y=e}Math.imul||(p=d),r.prototype.mulTo=function(t,e){var i=this.length+t.length;return 10===this.length&&10===t.length?p(this,t,e):i<63?d(this,t,e):i<1024?m(this,t,e):g(this,t,e)},v.prototype.makeRBT=function(t){for(var e=new Array(t),i=r.prototype._countBits(t)-1,n=0;n>=1;return r},v.prototype.permute=function(t,e,i,r,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*s+1]=8191&n,n>>>=13;for(s=2*e;s>=26,i+=n/67108864|0,i+=s>>>26,this.words[r]=67108863&s}return 0!==i&&(this.words[r]=i,this.length++),e?this.ineg():this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),i=0;i>>n&1}return e}(t);if(0===e.length)return new r(1);for(var i=this,n=0;n>>26-i<<26-i;if(0!==i){var s=0;for(e=0;e>>26-i}s&&(this.words[e]=s,this.length++)}if(0!==r){for(e=this.length-1;e>=0;e--)this.words[e+r]=this.words[e];for(e=0;e>>n<s)for(this.length-=s,a=0;a=0&&(0!==u||a>=r);a--){var f=0|this.words[a];this.words[a]=u<<26-n|f>>>n,u=f&o}return h&&0!==u&&(h.words[h.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},r.prototype.ishrn=function(t,e,i){return this.iushrn(t,e,i)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){var e=t%26,i=(t-e)/26,r=1<>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},r.prototype.isubn=function(t){if(t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[r+i]=67108863&n}for(;r>26,this.words[r+i]=67108863&n;if(0===o)return this._strip();for(o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this._strip()},r.prototype._wordDiv=function(t,e){var i=(this.length,t.length),n=this.clone(),s=t,o=0|s.words[s.length-1];0!=(i=26-this._countBits(o))&&(s=s.ushln(i),n.iushln(i),o=0|s.words[s.length-1]);var h,a=n.length-s.length;if("mod"!==e){(h=new r(null)).length=a+1,h.words=new Array(h.length);for(var u=0;u=0;l--){var c=67108864*(0|n.words[s.length+l])+(0|n.words[s.length+l-1]);for(c=Math.min(c/o|0,67108863),n._ishlnsubmul(s,c,l);0!==n.negative;)c--,n.negative=0,n._ishlnsubmul(s,1,l),n.isZero()||(n.negative^=1);h&&(h.words[l]=c)}return h&&h._strip(),n._strip(),"div"!==e&&0!==i&&n.iushrn(i),{div:h||null,mod:n}},r.prototype.divmod=function(t,e,i){return this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),"mod"!==e&&(n=o.div.neg()),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),e),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new r(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modrn(t.words[0]))}:this._wordDiv(t,e);var n,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var i=0!==e.div.negative?e.mod.isub(t):e.mod,r=t.ushrn(1),n=t.andln(1),s=i.cmp(r);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},r.prototype.modrn=function(t){var e=t<0;e&&(t=-t);for(var i=(1<<26)%t,r=0,n=this.length-1;n>=0;n--)r=(i*r+(0|this.words[n]))%t;return e?-r:r},r.prototype.modn=function(t){return this.modrn(t)},r.prototype.idivn=function(t){var e=t<0;e&&(t=-t);for(var i=0,r=this.length-1;r>=0;r--){var n=(0|this.words[r])+67108864*i;this.words[r]=n/t|0,i=n%t}return this._strip(),e?this.ineg():this},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new r(1),s=new r(0),o=new r(0),h=new r(1),a=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++a;for(var u=i.clone(),f=e.clone();!e.isZero();){for(var l=0,c=1;0==(e.words[0]&c)&&l<26;++l,c<<=1);if(l>0)for(e.iushrn(l);l-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(u),s.isub(f)),n.iushrn(1),s.iushrn(1);for(var d=0,p=1;0==(i.words[0]&p)&&d<26;++d,p<<=1);if(d>0)for(i.iushrn(d);d-- >0;)(o.isOdd()||h.isOdd())&&(o.iadd(u),h.isub(f)),o.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),n.isub(o),s.isub(h)):(i.isub(e),o.isub(n),h.isub(s))}return{a:o,b:h,gcd:i.iushln(a)}},r.prototype._invmp=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new r(1),o=new r(0),h=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var a=0,u=1;0==(e.words[0]&u)&&a<26;++a,u<<=1);if(a>0)for(e.iushrn(a);a-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);for(var f=0,l=1;0==(i.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(i.iushrn(f);f-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o)):(i.isub(e),o.isub(s))}return(n=0===e.cmpn(1)?s:o).cmpn(0)<0&&n.iadd(t),n},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),i=t.clone();e.negative=0,i.negative=0;for(var r=0;e.isEven()&&i.isEven();r++)e.iushrn(1),i.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;i.isEven();)i.iushrn(1);var n=e.cmp(i);if(n<0){var s=e;e=i,i=s}else if(0===n||0===i.cmpn(1))break;e.isub(i)}return i.iushln(r)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){var e=t%26,i=(t-e)/26,r=1<>>26,o&=67108863,this.words[s]=o}return 0!==n&&(this.words[s]=n,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this._strip(),this.length>1)e=1;else{i&&(t=-t);var r=0|this.words[0];e=r===t?0:rt.length)return 1;if(this.length=0;i--){var r=0|this.words[i],n=0|t.words[i];if(r!==n){rn&&(e=1);break}}return e},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new k(t)},r.prototype.toRed=function(t){return t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return this._forceRed(t)},r.prototype.redAdd=function(t){return this.red.add(this,t)},r.prototype.redIAdd=function(t){return this.red.iadd(this,t)},r.prototype.redSub=function(t){return this.red.sub(this,t)},r.prototype.redISub=function(t){return this.red.isub(this,t)},r.prototype.redShl=function(t){return this.red.shl(this,t)},r.prototype.redMul=function(t){return this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return this.red._verify1(this),this.red.pow(this,t)};var y={k256:null,p224:null,p192:null,p25519:null};function b(t,e){this.name=t,this.p=new r(e,16),this.n=this.p.bitLength(),this.k=new r(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function M(){b.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function w(){b.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function _(){b.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function S(){b.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function k(t){if("string"==typeof t){var e=r._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function A(t){k.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(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)}b.prototype._tmp=function(){var t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},b.prototype.ireduce=function(t){var e,i=t;do{this.split(i,this.tmp),e=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(e>this.n);var r=e0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},b.prototype.split=function(t,e){t.iushrn(this.n,0,e)},b.prototype.imulK=function(t){return t.imul(this.k)},i(M,b),M.prototype.split=function(t,e){for(var i=Math.min(t.length,9),r=0;r>>22,n=s}n>>>=22,t.words[r-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},M.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,i=0;i>>=26,t.words[i]=n,e=r}return 0!==e&&(t.words[t.length++]=e),t},r._prime=function(t){if(y[t])return y[t];var e;if("k256"===t)e=new M;else if("p224"===t)e=new w;else if("p192"===t)e=new _;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new S}return y[t]=e,e},k.prototype._verify1=function(t){},k.prototype._verify2=function(t,e){},k.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(h(t,t.umod(this.m)._forceRed(this)),t)},k.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},k.prototype.add=function(t,e){this._verify2(t,e);var i=t.add(e);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},k.prototype.iadd=function(t,e){this._verify2(t,e);var i=t.iadd(e);return i.cmp(this.m)>=0&&i.isub(this.m),i},k.prototype.sub=function(t,e){this._verify2(t,e);var i=t.sub(e);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},k.prototype.isub=function(t,e){this._verify2(t,e);var i=t.isub(e);return i.cmpn(0)<0&&i.iadd(this.m),i},k.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},k.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},k.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},k.prototype.isqr=function(t){return this.imul(t,t.clone())},k.prototype.sqr=function(t){return this.mul(t,t)},k.prototype.sqrt=function(t){if(t.isZero())return t.clone();if(3===this.m.andln(3)){var e=this.m.add(new r(1)).iushrn(2);return this.pow(t,e)}for(var i=this.m.subn(1),n=0;!i.isZero()&&0===i.andln(1);)n++,i.iushrn(1);var s=new r(1).toRed(this),o=s.redNeg(),h=this.m.subn(1).iushrn(1),a=this.m.bitLength();for(a=new r(2*a*a).toRed(this);0!==this.pow(a,h).cmp(o);)a.redIAdd(o);for(var u=this.pow(a,i),f=this.pow(t,i.addn(1).iushrn(1)),l=this.pow(t,i),c=n;0!==l.cmp(s);){for(var d=l,p=0;0!==d.cmp(s);p++)d=d.redSqr();var m=this.pow(u,new r(1).iushln(c-p-1));f=f.redMul(m),u=m.redSqr(),l=l.redMul(u),c=p}return f},k.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},k.prototype.pow=function(t,e){if(e.isZero())return new r(1).toRed(this);if(0===e.cmpn(1))return t.clone();var i=new Array(16);i[0]=new r(1).toRed(this),i[1]=t;for(var n=2;n=0;n--){for(var u=e.words[n],f=a-1;f>=0;f--){var l=u>>f&1;s!==i[0]&&(s=this.sqr(s)),0!==l||0!==o?(o<<=1,o|=l,(4==++h||0===n&&0===f)&&(s=this.mul(s,i[o]),h=0,o=0)):h=0}a=26}return s},k.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},k.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},r.mont=function(t){return new A(t)},i(A,k),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(e),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new r(0)._forceRed(this);var i=t.mul(e),n=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=i.isub(n).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(Ln,this),Ln=Ln.exports;var jn={};(function(t){(function(){function e(t){var e,i=t.modulus.byteLength();do{e=new Ln(U(i))}while(e.cmp(t.modulus)>=0||!e.umod(t.prime1)||!e.umod(t.prime2));return e}function i(i,r){var n=function(t){var i=e(t);return{blinder:i.toRed(Ln.mont(t.modulus)).redPow(new Ln(t.publicExponent)).fromRed(),unblinder:i.invm(t.modulus)}}(r),s=r.modulus.byteLength(),o=new Ln(i).mul(n.blinder).umod(r.modulus),h=o.toRed(Ln.mont(r.prime1)),a=o.toRed(Ln.mont(r.prime2)),u=r.coefficient,f=r.prime1,l=r.prime2,c=h.redPow(r.exponent1).fromRed(),d=a.redPow(r.exponent2).fromRed(),p=c.isub(d).imul(u).umod(f).imul(l);return d.iadd(p).imul(n.unblinder).umod(r.modulus).toArrayLike(t,"be",s)}i.getr=e,jn=i}).call(this)}).call(this,u({}).Buffer);var On={exports:{}};!function(t,e){"use strict";function i(t,e){t.super_=e;var i=function(){};i.prototype=e.prototype,t.prototype=new i,t.prototype.constructor=t}function r(t,e,i){if(r.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(i=e,e=10),this._init(t||0,e||10,i||"be"))}var n;"object"==typeof t?t.exports=r:e.BN=r,r.BN=r,r.wordSize=26;try{n=a({}).Buffer}catch(hu){}function s(t,e,i){for(var r=0,n=Math.min(t.length,i),s=e;s=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return r}function o(t,e,i,r){for(var n=0,s=Math.min(t.length,i),o=e;o=49?h-49+10:h>=17?h-17+10:h}return n}r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,e){return t.cmp(e)>0?t:e},r.min=function(t,e){return t.cmp(e)<0?t:e},r.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===e?this._parseHex(t,r):this._parseBase(t,e,r),"-"===t[0]&&(this.negative=1),this.strip(),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initArray=function(t,e,i){if(t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r=0;r-=3)s=t[r]|t[r-1]<<8|t[r-2]<<16,this.words[n]|=s<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===i)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this.strip()},r.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=6)n=s(t,i,i+6),this.words[r]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,r++);i+6!==e&&(n=s(t,e,i+6),this.words[r]|=n<>>26-o&4194303),this.strip()},r.prototype._parseBase=function(t,e,i){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=e)r++;r--,n=n/e|0;for(var s=t.length-i,h=s%r,a=Math.min(s,s-h)+i,u=0,f=i;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},r.prototype.inspect=function(){return(this.red?""};var h=["","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],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function l(t,e,i){i.negative=e.negative^t.negative;var r=t.length+e.length|0;i.length=r,r=r-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,h=67108863&o,a=o/67108864|0;i.words[0]=h;for(var u=1;u>>26,l=67108863&a,c=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=c;d++){var p=u-d|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[d])+l)/67108864|0,l=67108863&o}i.words[u]=0|l,a=0|f}return 0!==a?i.words[u]=0|a:i.length--,i.strip()}r.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var r=0,n=0,s=0;s>>24-r&16777215)||s!==this.length-1?h[6-a.length]+a+i:a+i,(r+=2)>=26&&(r-=26,s--)}for(0!==n&&(i=n.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var l=u[t],c=f[t];i="";var d=this.clone();for(d.negative=0;!d.isZero();){var p=d.modn(c).toString(t);i=(d=d.idivn(c)).isZero()?p+i:h[l-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length,0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16)},r.prototype.toBuffer=function(t,e){return this.toArrayLike(n,t,e)},r.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},r.prototype.toArrayLike=function(t,e,i){var r=this.byteLength(),n=i||Math.max(1,r);this.strip();var s,o,h="le"===e,a=new t(n),u=this.clone();if(h){for(o=0;!u.isZero();o++)s=u.andln(255),u.iushrn(8),a[o]=s;for(;o=4096&&(i+=13,e>>>=13),e>=64&&(i+=7,e>>>=7),e>=8&&(i+=4,e>>>=4),e>=2&&(i+=2,e>>>=2),i+e},r.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,i=0;return 0==(8191&e)&&(i+=13,e>>>=13),0==(127&e)&&(i+=7,e>>>=7),0==(15&e)&&(i+=4,e>>>=4),0==(3&e)&&(i+=2,e>>>=2),0==(1&e)&&i++,i},r.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var i=0;it.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var e,i;this.length>t.length?(e=this,i=t):(e=t,i=this);for(var r=0;rt.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-i),this.strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,e){var i=t/26|0,r=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(i=this,r=t):(i=t,r=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i,r,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(i=this,r=t):(i=t,r=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,d=0|o[1],p=8191&d,m=d>>>13,g=0|o[2],v=8191&g,y=g>>>13,b=0|o[3],M=8191&b,w=b>>>13,_=0|o[4],S=8191&_,k=_>>>13,A=0|o[5],E=8191&A,R=A>>>13,x=0|o[6],B=8191&x,I=x>>>13,P=0|o[7],T=8191&P,q=P>>>13,L=0|o[8],j=8191&L,O=L>>>13,N=0|o[9],C=8191&N,$=N>>>13,U=0|h[0],z=8191&U,D=U>>>13,K=0|h[1],W=8191&K,Z=K>>>13,F=0|h[2],V=8191&F,H=F>>>13,G=0|h[3],X=8191&G,Y=G>>>13,J=0|h[4],Q=8191&J,tt=J>>>13,et=0|h[5],it=8191&et,rt=et>>>13,nt=0|h[6],st=8191&nt,ot=nt>>>13,ht=0|h[7],at=8191&ht,ut=ht>>>13,ft=0|h[8],lt=8191&ft,ct=ft>>>13,dt=0|h[9],pt=8191&dt,mt=dt>>>13;i.negative=t.negative^e.negative,i.length=19;var gt=(u+(r=Math.imul(l,z))|0)+((8191&(n=(n=Math.imul(l,D))+Math.imul(c,z)|0))<<13)|0;u=((s=Math.imul(c,D))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(p,z),n=(n=Math.imul(p,D))+Math.imul(m,z)|0,s=Math.imul(m,D);var vt=(u+(r=r+Math.imul(l,W)|0)|0)+((8191&(n=(n=n+Math.imul(l,Z)|0)+Math.imul(c,W)|0))<<13)|0;u=((s=s+Math.imul(c,Z)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(v,z),n=(n=Math.imul(v,D))+Math.imul(y,z)|0,s=Math.imul(y,D),r=r+Math.imul(p,W)|0,n=(n=n+Math.imul(p,Z)|0)+Math.imul(m,W)|0,s=s+Math.imul(m,Z)|0;var yt=(u+(r=r+Math.imul(l,V)|0)|0)+((8191&(n=(n=n+Math.imul(l,H)|0)+Math.imul(c,V)|0))<<13)|0;u=((s=s+Math.imul(c,H)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(M,z),n=(n=Math.imul(M,D))+Math.imul(w,z)|0,s=Math.imul(w,D),r=r+Math.imul(v,W)|0,n=(n=n+Math.imul(v,Z)|0)+Math.imul(y,W)|0,s=s+Math.imul(y,Z)|0,r=r+Math.imul(p,V)|0,n=(n=n+Math.imul(p,H)|0)+Math.imul(m,V)|0,s=s+Math.imul(m,H)|0;var bt=(u+(r=r+Math.imul(l,X)|0)|0)+((8191&(n=(n=n+Math.imul(l,Y)|0)+Math.imul(c,X)|0))<<13)|0;u=((s=s+Math.imul(c,Y)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(S,z),n=(n=Math.imul(S,D))+Math.imul(k,z)|0,s=Math.imul(k,D),r=r+Math.imul(M,W)|0,n=(n=n+Math.imul(M,Z)|0)+Math.imul(w,W)|0,s=s+Math.imul(w,Z)|0,r=r+Math.imul(v,V)|0,n=(n=n+Math.imul(v,H)|0)+Math.imul(y,V)|0,s=s+Math.imul(y,H)|0,r=r+Math.imul(p,X)|0,n=(n=n+Math.imul(p,Y)|0)+Math.imul(m,X)|0,s=s+Math.imul(m,Y)|0;var Mt=(u+(r=r+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(c,Q)|0))<<13)|0;u=((s=s+Math.imul(c,tt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(E,z),n=(n=Math.imul(E,D))+Math.imul(R,z)|0,s=Math.imul(R,D),r=r+Math.imul(S,W)|0,n=(n=n+Math.imul(S,Z)|0)+Math.imul(k,W)|0,s=s+Math.imul(k,Z)|0,r=r+Math.imul(M,V)|0,n=(n=n+Math.imul(M,H)|0)+Math.imul(w,V)|0,s=s+Math.imul(w,H)|0,r=r+Math.imul(v,X)|0,n=(n=n+Math.imul(v,Y)|0)+Math.imul(y,X)|0,s=s+Math.imul(y,Y)|0,r=r+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var wt=(u+(r=r+Math.imul(l,it)|0)|0)+((8191&(n=(n=n+Math.imul(l,rt)|0)+Math.imul(c,it)|0))<<13)|0;u=((s=s+Math.imul(c,rt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(B,z),n=(n=Math.imul(B,D))+Math.imul(I,z)|0,s=Math.imul(I,D),r=r+Math.imul(E,W)|0,n=(n=n+Math.imul(E,Z)|0)+Math.imul(R,W)|0,s=s+Math.imul(R,Z)|0,r=r+Math.imul(S,V)|0,n=(n=n+Math.imul(S,H)|0)+Math.imul(k,V)|0,s=s+Math.imul(k,H)|0,r=r+Math.imul(M,X)|0,n=(n=n+Math.imul(M,Y)|0)+Math.imul(w,X)|0,s=s+Math.imul(w,Y)|0,r=r+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,tt)|0)+Math.imul(y,Q)|0,s=s+Math.imul(y,tt)|0,r=r+Math.imul(p,it)|0,n=(n=n+Math.imul(p,rt)|0)+Math.imul(m,it)|0,s=s+Math.imul(m,rt)|0;var _t=(u+(r=r+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(c,st)|0))<<13)|0;u=((s=s+Math.imul(c,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(T,z),n=(n=Math.imul(T,D))+Math.imul(q,z)|0,s=Math.imul(q,D),r=r+Math.imul(B,W)|0,n=(n=n+Math.imul(B,Z)|0)+Math.imul(I,W)|0,s=s+Math.imul(I,Z)|0,r=r+Math.imul(E,V)|0,n=(n=n+Math.imul(E,H)|0)+Math.imul(R,V)|0,s=s+Math.imul(R,H)|0,r=r+Math.imul(S,X)|0,n=(n=n+Math.imul(S,Y)|0)+Math.imul(k,X)|0,s=s+Math.imul(k,Y)|0,r=r+Math.imul(M,Q)|0,n=(n=n+Math.imul(M,tt)|0)+Math.imul(w,Q)|0,s=s+Math.imul(w,tt)|0,r=r+Math.imul(v,it)|0,n=(n=n+Math.imul(v,rt)|0)+Math.imul(y,it)|0,s=s+Math.imul(y,rt)|0,r=r+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(r=r+Math.imul(l,at)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(c,at)|0))<<13)|0;u=((s=s+Math.imul(c,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(j,z),n=(n=Math.imul(j,D))+Math.imul(O,z)|0,s=Math.imul(O,D),r=r+Math.imul(T,W)|0,n=(n=n+Math.imul(T,Z)|0)+Math.imul(q,W)|0,s=s+Math.imul(q,Z)|0,r=r+Math.imul(B,V)|0,n=(n=n+Math.imul(B,H)|0)+Math.imul(I,V)|0,s=s+Math.imul(I,H)|0,r=r+Math.imul(E,X)|0,n=(n=n+Math.imul(E,Y)|0)+Math.imul(R,X)|0,s=s+Math.imul(R,Y)|0,r=r+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(k,Q)|0,s=s+Math.imul(k,tt)|0,r=r+Math.imul(M,it)|0,n=(n=n+Math.imul(M,rt)|0)+Math.imul(w,it)|0,s=s+Math.imul(w,rt)|0,r=r+Math.imul(v,st)|0,n=(n=n+Math.imul(v,ot)|0)+Math.imul(y,st)|0,s=s+Math.imul(y,ot)|0,r=r+Math.imul(p,at)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,at)|0,s=s+Math.imul(m,ut)|0;var kt=(u+(r=r+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,ct)|0)+Math.imul(c,lt)|0))<<13)|0;u=((s=s+Math.imul(c,ct)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(C,z),n=(n=Math.imul(C,D))+Math.imul($,z)|0,s=Math.imul($,D),r=r+Math.imul(j,W)|0,n=(n=n+Math.imul(j,Z)|0)+Math.imul(O,W)|0,s=s+Math.imul(O,Z)|0,r=r+Math.imul(T,V)|0,n=(n=n+Math.imul(T,H)|0)+Math.imul(q,V)|0,s=s+Math.imul(q,H)|0,r=r+Math.imul(B,X)|0,n=(n=n+Math.imul(B,Y)|0)+Math.imul(I,X)|0,s=s+Math.imul(I,Y)|0,r=r+Math.imul(E,Q)|0,n=(n=n+Math.imul(E,tt)|0)+Math.imul(R,Q)|0,s=s+Math.imul(R,tt)|0,r=r+Math.imul(S,it)|0,n=(n=n+Math.imul(S,rt)|0)+Math.imul(k,it)|0,s=s+Math.imul(k,rt)|0,r=r+Math.imul(M,st)|0,n=(n=n+Math.imul(M,ot)|0)+Math.imul(w,st)|0,s=s+Math.imul(w,ot)|0,r=r+Math.imul(v,at)|0,n=(n=n+Math.imul(v,ut)|0)+Math.imul(y,at)|0,s=s+Math.imul(y,ut)|0,r=r+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,ct)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,ct)|0;var At=(u+(r=r+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(c,pt)|0))<<13)|0;u=((s=s+Math.imul(c,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(C,W),n=(n=Math.imul(C,Z))+Math.imul($,W)|0,s=Math.imul($,Z),r=r+Math.imul(j,V)|0,n=(n=n+Math.imul(j,H)|0)+Math.imul(O,V)|0,s=s+Math.imul(O,H)|0,r=r+Math.imul(T,X)|0,n=(n=n+Math.imul(T,Y)|0)+Math.imul(q,X)|0,s=s+Math.imul(q,Y)|0,r=r+Math.imul(B,Q)|0,n=(n=n+Math.imul(B,tt)|0)+Math.imul(I,Q)|0,s=s+Math.imul(I,tt)|0,r=r+Math.imul(E,it)|0,n=(n=n+Math.imul(E,rt)|0)+Math.imul(R,it)|0,s=s+Math.imul(R,rt)|0,r=r+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(k,st)|0,s=s+Math.imul(k,ot)|0,r=r+Math.imul(M,at)|0,n=(n=n+Math.imul(M,ut)|0)+Math.imul(w,at)|0,s=s+Math.imul(w,ut)|0,r=r+Math.imul(v,lt)|0,n=(n=n+Math.imul(v,ct)|0)+Math.imul(y,lt)|0,s=s+Math.imul(y,ct)|0;var Et=(u+(r=r+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(C,V),n=(n=Math.imul(C,H))+Math.imul($,V)|0,s=Math.imul($,H),r=r+Math.imul(j,X)|0,n=(n=n+Math.imul(j,Y)|0)+Math.imul(O,X)|0,s=s+Math.imul(O,Y)|0,r=r+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(q,Q)|0,s=s+Math.imul(q,tt)|0,r=r+Math.imul(B,it)|0,n=(n=n+Math.imul(B,rt)|0)+Math.imul(I,it)|0,s=s+Math.imul(I,rt)|0,r=r+Math.imul(E,st)|0,n=(n=n+Math.imul(E,ot)|0)+Math.imul(R,st)|0,s=s+Math.imul(R,ot)|0,r=r+Math.imul(S,at)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(k,at)|0,s=s+Math.imul(k,ut)|0,r=r+Math.imul(M,lt)|0,n=(n=n+Math.imul(M,ct)|0)+Math.imul(w,lt)|0,s=s+Math.imul(w,ct)|0;var Rt=(u+(r=r+Math.imul(v,pt)|0)|0)+((8191&(n=(n=n+Math.imul(v,mt)|0)+Math.imul(y,pt)|0))<<13)|0;u=((s=s+Math.imul(y,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(C,X),n=(n=Math.imul(C,Y))+Math.imul($,X)|0,s=Math.imul($,Y),r=r+Math.imul(j,Q)|0,n=(n=n+Math.imul(j,tt)|0)+Math.imul(O,Q)|0,s=s+Math.imul(O,tt)|0,r=r+Math.imul(T,it)|0,n=(n=n+Math.imul(T,rt)|0)+Math.imul(q,it)|0,s=s+Math.imul(q,rt)|0,r=r+Math.imul(B,st)|0,n=(n=n+Math.imul(B,ot)|0)+Math.imul(I,st)|0,s=s+Math.imul(I,ot)|0,r=r+Math.imul(E,at)|0,n=(n=n+Math.imul(E,ut)|0)+Math.imul(R,at)|0,s=s+Math.imul(R,ut)|0,r=r+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,ct)|0)+Math.imul(k,lt)|0,s=s+Math.imul(k,ct)|0;var xt=(u+(r=r+Math.imul(M,pt)|0)|0)+((8191&(n=(n=n+Math.imul(M,mt)|0)+Math.imul(w,pt)|0))<<13)|0;u=((s=s+Math.imul(w,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(C,Q),n=(n=Math.imul(C,tt))+Math.imul($,Q)|0,s=Math.imul($,tt),r=r+Math.imul(j,it)|0,n=(n=n+Math.imul(j,rt)|0)+Math.imul(O,it)|0,s=s+Math.imul(O,rt)|0,r=r+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(q,st)|0,s=s+Math.imul(q,ot)|0,r=r+Math.imul(B,at)|0,n=(n=n+Math.imul(B,ut)|0)+Math.imul(I,at)|0,s=s+Math.imul(I,ut)|0,r=r+Math.imul(E,lt)|0,n=(n=n+Math.imul(E,ct)|0)+Math.imul(R,lt)|0,s=s+Math.imul(R,ct)|0;var Bt=(u+(r=r+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(k,pt)|0))<<13)|0;u=((s=s+Math.imul(k,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(C,it),n=(n=Math.imul(C,rt))+Math.imul($,it)|0,s=Math.imul($,rt),r=r+Math.imul(j,st)|0,n=(n=n+Math.imul(j,ot)|0)+Math.imul(O,st)|0,s=s+Math.imul(O,ot)|0,r=r+Math.imul(T,at)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(q,at)|0,s=s+Math.imul(q,ut)|0,r=r+Math.imul(B,lt)|0,n=(n=n+Math.imul(B,ct)|0)+Math.imul(I,lt)|0,s=s+Math.imul(I,ct)|0;var It=(u+(r=r+Math.imul(E,pt)|0)|0)+((8191&(n=(n=n+Math.imul(E,mt)|0)+Math.imul(R,pt)|0))<<13)|0;u=((s=s+Math.imul(R,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(C,st),n=(n=Math.imul(C,ot))+Math.imul($,st)|0,s=Math.imul($,ot),r=r+Math.imul(j,at)|0,n=(n=n+Math.imul(j,ut)|0)+Math.imul(O,at)|0,s=s+Math.imul(O,ut)|0,r=r+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,ct)|0)+Math.imul(q,lt)|0,s=s+Math.imul(q,ct)|0;var Pt=(u+(r=r+Math.imul(B,pt)|0)|0)+((8191&(n=(n=n+Math.imul(B,mt)|0)+Math.imul(I,pt)|0))<<13)|0;u=((s=s+Math.imul(I,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(C,at),n=(n=Math.imul(C,ut))+Math.imul($,at)|0,s=Math.imul($,ut),r=r+Math.imul(j,lt)|0,n=(n=n+Math.imul(j,ct)|0)+Math.imul(O,lt)|0,s=s+Math.imul(O,ct)|0;var Tt=(u+(r=r+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(q,pt)|0))<<13)|0;u=((s=s+Math.imul(q,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(C,lt),n=(n=Math.imul(C,ct))+Math.imul($,lt)|0,s=Math.imul($,ct);var qt=(u+(r=r+Math.imul(j,pt)|0)|0)+((8191&(n=(n=n+Math.imul(j,mt)|0)+Math.imul(O,pt)|0))<<13)|0;u=((s=s+Math.imul(O,mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863;var Lt=(u+(r=Math.imul(C,pt))|0)+((8191&(n=(n=Math.imul(C,mt))+Math.imul($,pt)|0))<<13)|0;return u=((s=Math.imul($,mt))+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,a[0]=gt,a[1]=vt,a[2]=yt,a[3]=bt,a[4]=Mt,a[5]=wt,a[6]=_t,a[7]=St,a[8]=kt,a[9]=At,a[10]=Et,a[11]=Rt,a[12]=xt,a[13]=Bt,a[14]=It,a[15]=Pt,a[16]=Tt,a[17]=qt,a[18]=Lt,0!==u&&(a[19]=u,i.length++),i};function d(t,e,i){return(new p).mulp(t,e,i)}function p(t,e){this.x=t,this.y=e}Math.imul||(c=l),r.prototype.mulTo=function(t,e){var i=this.length+t.length;return 10===this.length&&10===t.length?c(this,t,e):i<63?l(this,t,e):i<1024?function(t,e,i){i.negative=e.negative^t.negative,i.length=t.length+e.length;for(var r=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}i.words[s]=h,r=o,o=n}return 0!==r?i.words[s]=r:i.length--,i.strip()}(this,t,e):d(this,t,e)},p.prototype.makeRBT=function(t){for(var e=new Array(t),i=r.prototype._countBits(t)-1,n=0;n>=1;return r},p.prototype.permute=function(t,e,i,r,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*s+1]=8191&n,n>>>=13;for(s=2*e;s>=26,e+=r/67108864|0,e+=n>>>26,this.words[i]=67108863&n}return 0!==e&&(this.words[i]=e,this.length++),this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),i=0;i>>n}return e}(t);if(0===e.length)return new r(1);for(var i=this,n=0;n>>26-i<<26-i;if(0!==i){var s=0;for(e=0;e>>26-i}s&&(this.words[e]=s,this.length++)}if(0!==r){for(e=this.length-1;e>=0;e--)this.words[e+r]=this.words[e];for(e=0;e>>n<s)for(this.length-=s,a=0;a=0&&(0!==u||a>=r);a--){var f=0|this.words[a];this.words[a]=u<<26-n|f>>>n,u=f&o}return h&&0!==u&&(h.words[h.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},r.prototype.ishrn=function(t,e,i){return this.iushrn(t,e,i)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){var e=t%26,i=(t-e)/26,r=1<>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},r.prototype.isubn=function(t){if(t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[r+i]=67108863&n}for(;r>26,this.words[r+i]=67108863&n;if(0===o)return this.strip();for(o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},r.prototype._wordDiv=function(t,e){var i=(this.length,t.length),n=this.clone(),s=t,o=0|s.words[s.length-1];0!=(i=26-this._countBits(o))&&(s=s.ushln(i),n.iushln(i),o=0|s.words[s.length-1]);var h,a=n.length-s.length;if("mod"!==e){(h=new r(null)).length=a+1,h.words=new Array(h.length);for(var u=0;u=0;l--){var c=67108864*(0|n.words[s.length+l])+(0|n.words[s.length+l-1]);for(c=Math.min(c/o|0,67108863),n._ishlnsubmul(s,c,l);0!==n.negative;)c--,n.negative=0,n._ishlnsubmul(s,1,l),n.isZero()||(n.negative^=1);h&&(h.words[l]=c)}return h&&h.strip(),n.strip(),"div"!==e&&0!==i&&n.iushrn(i),{div:h||null,mod:n}},r.prototype.divmod=function(t,e,i){return this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),"mod"!==e&&(n=o.div.neg()),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),e),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new r(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var i=0!==e.div.negative?e.mod.isub(t):e.mod,r=t.ushrn(1),n=t.andln(1),s=i.cmp(r);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},r.prototype.modn=function(t){for(var e=(1<<26)%t,i=0,r=this.length-1;r>=0;r--)i=(e*i+(0|this.words[r]))%t;return i},r.prototype.idivn=function(t){for(var e=0,i=this.length-1;i>=0;i--){var r=(0|this.words[i])+67108864*e;this.words[i]=r/t|0,e=r%t}return this.strip()},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new r(1),s=new r(0),o=new r(0),h=new r(1),a=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++a;for(var u=i.clone(),f=e.clone();!e.isZero();){for(var l=0,c=1;0==(e.words[0]&c)&&l<26;++l,c<<=1);if(l>0)for(e.iushrn(l);l-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(u),s.isub(f)),n.iushrn(1),s.iushrn(1);for(var d=0,p=1;0==(i.words[0]&p)&&d<26;++d,p<<=1);if(d>0)for(i.iushrn(d);d-- >0;)(o.isOdd()||h.isOdd())&&(o.iadd(u),h.isub(f)),o.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),n.isub(o),s.isub(h)):(i.isub(e),o.isub(n),h.isub(s))}return{a:o,b:h,gcd:i.iushln(a)}},r.prototype._invmp=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new r(1),o=new r(0),h=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var a=0,u=1;0==(e.words[0]&u)&&a<26;++a,u<<=1);if(a>0)for(e.iushrn(a);a-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);for(var f=0,l=1;0==(i.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(i.iushrn(f);f-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o)):(i.isub(e),o.isub(s))}return(n=0===e.cmpn(1)?s:o).cmpn(0)<0&&n.iadd(t),n},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),i=t.clone();e.negative=0,i.negative=0;for(var r=0;e.isEven()&&i.isEven();r++)e.iushrn(1),i.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;i.isEven();)i.iushrn(1);var n=e.cmp(i);if(n<0){var s=e;e=i,i=s}else if(0===n||0===i.cmpn(1))break;e.isub(i)}return i.iushln(r)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){var e=t%26,i=(t-e)/26,r=1<>>26,o&=67108863,this.words[s]=o}return 0!==n&&(this.words[s]=n,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t);var r=0|this.words[0];e=r===t?0:rt.length)return 1;if(this.length=0;i--){var r=0|this.words[i],n=0|t.words[i];if(r!==n){rn&&(e=1);break}}return e},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new w(t)},r.prototype.toRed=function(t){return t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return this._forceRed(t)},r.prototype.redAdd=function(t){return this.red.add(this,t)},r.prototype.redIAdd=function(t){return this.red.iadd(this,t)},r.prototype.redSub=function(t){return this.red.sub(this,t)},r.prototype.redISub=function(t){return this.red.isub(this,t)},r.prototype.redShl=function(t){return this.red.shl(this,t)},r.prototype.redMul=function(t){return this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return this.red._verify1(this),this.red.pow(this,t)};var m={k256:null,p224:null,p192:null,p25519:null};function g(t,e){this.name=t,this.p=new r(e,16),this.n=this.p.bitLength(),this.k=new r(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){g.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function y(){g.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){g.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function M(){g.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function w(t){if("string"==typeof t){var e=r._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function _(t){w.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}g.prototype._tmp=function(){var t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},g.prototype.ireduce=function(t){var e,i=t;do{this.split(i,this.tmp),e=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(e>this.n);var r=e0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},g.prototype.split=function(t,e){t.iushrn(this.n,0,e)},g.prototype.imulK=function(t){return t.imul(this.k)},i(v,g),v.prototype.split=function(t,e){for(var i=Math.min(t.length,9),r=0;r>>22,n=s}n>>>=22,t.words[r-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,i=0;i>>=26,t.words[i]=n,e=r}return 0!==e&&(t.words[t.length++]=e),t},r._prime=function(t){if(m[t])return m[t];var e;if("k256"===t)e=new v;else if("p224"===t)e=new y;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new M}return m[t]=e,e},w.prototype._verify1=function(t){},w.prototype._verify2=function(t,e){},w.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},w.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},w.prototype.add=function(t,e){this._verify2(t,e);var i=t.add(e);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},w.prototype.iadd=function(t,e){this._verify2(t,e);var i=t.iadd(e);return i.cmp(this.m)>=0&&i.isub(this.m),i},w.prototype.sub=function(t,e){this._verify2(t,e);var i=t.sub(e);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},w.prototype.isub=function(t,e){this._verify2(t,e);var i=t.isub(e);return i.cmpn(0)<0&&i.iadd(this.m),i},w.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},w.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},w.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},w.prototype.isqr=function(t){return this.imul(t,t.clone())},w.prototype.sqr=function(t){return this.mul(t,t)},w.prototype.sqrt=function(t){if(t.isZero())return t.clone();if(3===this.m.andln(3)){var e=this.m.add(new r(1)).iushrn(2);return this.pow(t,e)}for(var i=this.m.subn(1),n=0;!i.isZero()&&0===i.andln(1);)n++,i.iushrn(1);var s=new r(1).toRed(this),o=s.redNeg(),h=this.m.subn(1).iushrn(1),a=this.m.bitLength();for(a=new r(2*a*a).toRed(this);0!==this.pow(a,h).cmp(o);)a.redIAdd(o);for(var u=this.pow(a,i),f=this.pow(t,i.addn(1).iushrn(1)),l=this.pow(t,i),c=n;0!==l.cmp(s);){for(var d=l,p=0;0!==d.cmp(s);p++)d=d.redSqr();var m=this.pow(u,new r(1).iushln(c-p-1));f=f.redMul(m),u=m.redSqr(),l=l.redMul(u),c=p}return f},w.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},w.prototype.pow=function(t,e){if(e.isZero())return new r(1).toRed(this);if(0===e.cmpn(1))return t.clone();var i=new Array(16);i[0]=new r(1).toRed(this),i[1]=t;for(var n=2;n=0;n--){for(var u=e.words[n],f=a-1;f>=0;f--){var l=u>>f&1;s!==i[0]&&(s=this.sqr(s)),0!==l||0!==o?(o<<=1,o|=l,(4==++h||0===n&&0===f)&&(s=this.mul(s,i[o]),h=0,o=0)):h=0}a=26}return s},w.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},w.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},r.mont=function(t){return new _(t)},i(_,w),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(e),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new r(0)._forceRed(this);var i=t.mul(e),n=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=i.isub(n).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(On,this),On=On.exports;var Nn={},Cn=Nn;function $n(t){return 1===t.length?"0"+t:t}function Un(t){for(var e="",i=0;i>8,o=255&n;s?i.push(s,o):i.push(o)}return i},Cn.zero2=$n,Cn.toHex=Un,Cn.encode=function(t,e){return"hex"===e?Un(t):t};var zn={},Dn=zn;Dn.assert=Gi,Dn.toArray=Nn.toArray,Dn.zero2=Nn.zero2,Dn.toHex=Nn.toHex,Dn.encode=Nn.encode,Dn.getNAF=function(t,e,i){var r=new Array(Math.max(t.bitLength(),i)+1);r.fill(0);for(var n=1<(n>>1)-1?(n>>1)-a:a,s.isubn(h)):h=0,r[o]=h,s.iushrn(1)}return r},Dn.getJSF=function(t,e){var i=[[],[]];t=t.clone(),e=e.clone();for(var r,n=0,s=0;t.cmpn(-n)>0||e.cmpn(-s)>0;){var o,h,a=t.andln(3)+n&3,u=e.andln(3)+s&3;3===a&&(a=-1),3===u&&(u=-1),o=0==(1&a)?0:3!=(r=t.andln(7)+n&7)&&5!==r||2!==u?a:-a,i[0].push(o),h=0==(1&u)?0:3!=(r=e.andln(7)+s&7)&&5!==r||2!==a?u:-u,i[1].push(h),2*n===o+1&&(n=1-n),2*s===h+1&&(s=1-s),t.iushrn(1),e.iushrn(1)}return i},Dn.cachedProperty=function(t,e,i){var r="_"+e;t.prototype[e]=function(){return void 0!==this[r]?this[r]:this[r]=i.call(this)}},Dn.parseBytes=function(t){return"string"==typeof t?Dn.toArray(t,"hex"):t},Dn.intFromLE=function(t){return new On(t,"hex","le")};var Kn={},Wn=zn.getNAF,Zn=zn.getJSF;function Fn(t,e){this.type=t,this.p=new On(e.p,16),this.red=e.prime?On.red(e.prime):On.mont(this.p),this.zero=new On(0).toRed(this.red),this.one=new On(1).toRed(this.red),this.two=new On(2).toRed(this.red),this.n=e.n&&new On(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var i=this.n&&this.p.div(this.n);!i||i.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function Vn(t,e){this.curve=t,this.type=e,this.precomputed=null}zn.assert,Kn=Fn,Fn.prototype.point=function(){throw new Error("Not implemented")},Fn.prototype.validate=function(){throw new Error("Not implemented")},Fn.prototype._fixedNafMul=function(t,e){var i=t._getDoubles(),r=Wn(e,1,this._bitLength),n=(1<=s;a--)o=(o<<1)+r[a];h.push(o)}for(var u=this.jpoint(null,null,null),f=this.jpoint(null,null,null),l=n;l>0;l--){for(s=0;s=0;h--){for(var a=0;h>=0&&0===s[h];h--)a++;if(h>=0&&a++,o=o.dblp(a),h<0)break;var u=s[h];o="affine"===t.type?u>0?o.mixedAdd(n[u-1>>1]):o.mixedAdd(n[-u-1>>1].neg()):u>0?o.add(n[u-1>>1]):o.add(n[-u-1>>1].neg())}return"affine"===t.type?o.toP():o},Fn.prototype._wnafMulAdd=function(t,e,i,r,n){var s,o,h,a=this._wnafT1,u=this._wnafT2,f=this._wnafT3,l=0;for(s=0;s=1;s-=2){var d=s-1,p=s;if(1===a[d]&&1===a[p]){var m=[e[d],null,null,e[p]];0===e[d].y.cmp(e[p].y)?(m[1]=e[d].add(e[p]),m[2]=e[d].toJ().mixedAdd(e[p].neg())):0===e[d].y.cmp(e[p].y.redNeg())?(m[1]=e[d].toJ().mixedAdd(e[p]),m[2]=e[d].add(e[p].neg())):(m[1]=e[d].toJ().mixedAdd(e[p]),m[2]=e[d].toJ().mixedAdd(e[p].neg()));var g=[-3,-1,-5,-7,0,7,5,1,3],v=Zn(i[d],i[p]);for(l=Math.max(v[0].length,l),f[d]=new Array(l),f[p]=new Array(l),o=0;o=0;s--){for(var _=0;s>=0;){var S=!0;for(o=0;o=0&&_++,M=M.dblp(_),s<0)break;for(o=0;o0?h=u[o][k-1>>1]:k<0&&(h=u[o][-k-1>>1].neg()),M="affine"===h.type?M.mixedAdd(h):M.add(h))}}for(s=0;s=Math.ceil((t.bitLength()+1)/e.step)},Vn.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],r=this,n=0;n=0&&(s=e,o=i),r.negative&&(r=r.neg(),n=n.neg()),s.negative&&(s=s.neg(),o=o.neg()),[{a:r,b:n},{a:s,b:o}]},Gn.prototype._endoSplit=function(t){var e=this.endo.basis,i=e[0],r=e[1],n=r.b.mul(t).divRound(this.n),s=i.b.neg().mul(t).divRound(this.n),o=n.mul(i.a),h=s.mul(r.a),a=n.mul(i.b),u=s.mul(r.b);return{k1:t.sub(o).sub(h),k2:a.add(u).neg()}},Gn.prototype.pointFromX=function(t,e){(t=new On(t,16)).red||(t=t.toRed(this.red));var i=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),r=i.redSqrt();if(0!==r.redSqr().redSub(i).cmp(this.zero))throw new Error("invalid point");var n=r.fromRed().isOdd();return(e&&!n||!e&&n)&&(r=r.redNeg()),this.point(t,r)},Gn.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,i=t.y,r=this.a.redMul(e),n=e.redSqr().redMul(e).redIAdd(r).redIAdd(this.b);return 0===i.redSqr().redISub(n).cmpn(0)},Gn.prototype._endoWnafMulAdd=function(t,e,i){for(var r=this._endoWnafT1,n=this._endoWnafT2,s=0;s":""},Xn.prototype.isInfinity=function(){return this.inf},Xn.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var i=e.redSqr().redISub(this.x).redISub(t.x),r=e.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,r)},Xn.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,i=this.x.redSqr(),r=t.redInvm(),n=i.redAdd(i).redIAdd(i).redIAdd(e).redMul(r),s=n.redSqr().redISub(this.x.redAdd(this.x)),o=n.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,o)},Xn.prototype.getX=function(){return this.x.fromRed()},Xn.prototype.getY=function(){return this.y.fromRed()},Xn.prototype.mul=function(t){return t=new On(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},Xn.prototype.mulAdd=function(t,e,i){var r=[this,e],n=[t,i];return this.curve.endo?this.curve._endoWnafMulAdd(r,n):this.curve._wnafMulAdd(1,r,n,2)},Xn.prototype.jmulAdd=function(t,e,i){var r=[this,e],n=[t,i];return this.curve.endo?this.curve._endoWnafMulAdd(r,n,!0):this.curve._wnafMulAdd(1,r,n,2,!0)},Xn.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},Xn.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var i=this.precomputed,r=function(t){return t.neg()};e.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(r)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(r)}}}return e},Xn.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},z(Yn,Kn.BasePoint),Gn.prototype.jpoint=function(t,e,i){return new Yn(this,t,e,i)},Yn.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),i=this.x.redMul(e),r=this.y.redMul(e).redMul(t);return this.curve.point(i,r)},Yn.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Yn.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),i=this.z.redSqr(),r=this.x.redMul(e),n=t.x.redMul(i),s=this.y.redMul(e.redMul(t.z)),o=t.y.redMul(i.redMul(this.z)),h=r.redSub(n),a=s.redSub(o);if(0===h.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=h.redSqr(),f=u.redMul(h),l=r.redMul(u),c=a.redSqr().redIAdd(f).redISub(l).redISub(l),d=a.redMul(l.redISub(c)).redISub(s.redMul(f)),p=this.z.redMul(t.z).redMul(h);return this.curve.jpoint(c,d,p)},Yn.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),i=this.x,r=t.x.redMul(e),n=this.y,s=t.y.redMul(e).redMul(this.z),o=i.redSub(r),h=n.redSub(s);if(0===o.cmpn(0))return 0!==h.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var a=o.redSqr(),u=a.redMul(o),f=i.redMul(a),l=h.redSqr().redIAdd(u).redISub(f).redISub(f),c=h.redMul(f.redISub(l)).redISub(n.redMul(u)),d=this.z.redMul(o);return this.curve.jpoint(l,c,d)},Yn.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var i=this;for(e=0;e=0)return!1;if(i.redIAdd(n),0===this.x.cmp(i))return!0}},Yn.prototype.inspect=function(){return this.isInfinity()?"":""},Yn.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var Jn;function Qn(t){Kn.call(this,"mont",t),this.a=new On(t.a,16).toRed(this.red),this.b=new On(t.b,16).toRed(this.red),this.i4=new On(4).toRed(this.red).redInvm(),this.two=new On(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function ts(t,e,i){Kn.BasePoint.call(this,t,"projective"),null===e&&null===i?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new On(e,16),this.z=new On(i,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}z(Qn,Kn),Jn=Qn,Qn.prototype.validate=function(t){var e=t.normalize().x,i=e.redSqr(),r=i.redMul(e).redAdd(i.redMul(this.a)).redAdd(e);return 0===r.redSqrt().redSqr().cmp(r)},z(ts,Kn.BasePoint),Qn.prototype.decodePoint=function(t,e){return this.point(zn.toArray(t,e),1)},Qn.prototype.point=function(t,e){return new ts(this,t,e)},Qn.prototype.pointFromJSON=function(t){return ts.fromJSON(this,t)},ts.prototype.precompute=function(){},ts.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},ts.fromJSON=function(t,e){return new ts(t,e[0],e[1]||t.one)},ts.prototype.inspect=function(){return this.isInfinity()?"":""},ts.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},ts.prototype.dbl=function(){var t=this.x.redAdd(this.z).redSqr(),e=this.x.redSub(this.z).redSqr(),i=t.redSub(e),r=t.redMul(e),n=i.redMul(e.redAdd(this.curve.a24.redMul(i)));return this.curve.point(r,n)},ts.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},ts.prototype.diffAdd=function(t,e){var i=this.x.redAdd(this.z),r=this.x.redSub(this.z),n=t.x.redAdd(t.z),s=t.x.redSub(t.z).redMul(i),o=n.redMul(r),h=e.z.redMul(s.redAdd(o).redSqr()),a=e.x.redMul(s.redISub(o).redSqr());return this.curve.point(h,a)},ts.prototype.mul=function(t){for(var e=t.clone(),i=this,r=this.curve.point(null,null),n=[];0!==e.cmpn(0);e.iushrn(1))n.push(e.andln(1));for(var s=n.length-1;s>=0;s--)0===n[s]?(i=i.diffAdd(r,this),r=r.dbl()):(r=i.diffAdd(r,this),i=i.dbl());return r},ts.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},ts.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},ts.prototype.eq=function(t){return 0===this.getX().cmp(t.getX())},ts.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},ts.prototype.getX=function(){return this.normalize(),this.x.fromRed()};var es;function is(t){this.twisted=1!=(0|t.a),this.mOneA=this.twisted&&-1==(0|t.a),this.extended=this.mOneA,Kn.call(this,"edwards",t),this.a=new On(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new On(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new On(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),this.oneC=1==(0|t.c)}function rs(t,e,i,r,n){Kn.BasePoint.call(this,t,"projective"),null===e&&null===i&&null===r?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new On(e,16),this.y=new On(i,16),this.z=r?new On(r,16):this.curve.one,this.t=n&&new On(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.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()))))}zn.assert,z(is,Kn),es=is,is.prototype._mulA=function(t){return this.mOneA?t.redNeg():this.a.redMul(t)},is.prototype._mulC=function(t){return this.oneC?t:this.c.redMul(t)},is.prototype.jpoint=function(t,e,i,r){return this.point(t,e,i,r)},is.prototype.pointFromX=function(t,e){(t=new On(t,16)).red||(t=t.toRed(this.red));var i=t.redSqr(),r=this.c2.redSub(this.a.redMul(i)),n=this.one.redSub(this.c2.redMul(this.d).redMul(i)),s=r.redMul(n.redInvm()),o=s.redSqrt();if(0!==o.redSqr().redSub(s).cmp(this.zero))throw new Error("invalid point");var h=o.fromRed().isOdd();return(e&&!h||!e&&h)&&(o=o.redNeg()),this.point(t,o)},is.prototype.pointFromY=function(t,e){(t=new On(t,16)).red||(t=t.toRed(this.red));var i=t.redSqr(),r=i.redSub(this.c2),n=i.redMul(this.d).redMul(this.c2).redSub(this.a),s=r.redMul(n.redInvm());if(0===s.cmp(this.zero)){if(e)throw new Error("invalid point");return this.point(this.zero,t)}var o=s.redSqrt();if(0!==o.redSqr().redSub(s).cmp(this.zero))throw new Error("invalid point");return o.fromRed().isOdd()!==e&&(o=o.redNeg()),this.point(o,t)},is.prototype.validate=function(t){if(t.isInfinity())return!0;t.normalize();var e=t.x.redSqr(),i=t.y.redSqr(),r=e.redMul(this.a).redAdd(i),n=this.c2.redMul(this.one.redAdd(this.d.redMul(e).redMul(i)));return 0===r.cmp(n)},z(rs,Kn.BasePoint),is.prototype.pointFromJSON=function(t){return rs.fromJSON(this,t)},is.prototype.point=function(t,e,i,r){return new rs(this,t,e,i,r)},rs.fromJSON=function(t,e){return new rs(t,e[0],e[1],e[2])},rs.prototype.inspect=function(){return this.isInfinity()?"":""},rs.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},rs.prototype._extDbl=function(){var t=this.x.redSqr(),e=this.y.redSqr(),i=this.z.redSqr();i=i.redIAdd(i);var r=this.curve._mulA(t),n=this.x.redAdd(this.y).redSqr().redISub(t).redISub(e),s=r.redAdd(e),o=s.redSub(i),h=r.redSub(e),a=n.redMul(o),u=s.redMul(h),f=n.redMul(h),l=o.redMul(s);return this.curve.point(a,u,l,f)},rs.prototype._projDbl=function(){var t,e,i,r,n,s,o=this.x.redAdd(this.y).redSqr(),h=this.x.redSqr(),a=this.y.redSqr();if(this.curve.twisted){var u=(r=this.curve._mulA(h)).redAdd(a);this.zOne?(t=o.redSub(h).redSub(a).redMul(u.redSub(this.curve.two)),e=u.redMul(r.redSub(a)),i=u.redSqr().redSub(u).redSub(u)):(n=this.z.redSqr(),s=u.redSub(n).redISub(n),t=o.redSub(h).redISub(a).redMul(s),e=u.redMul(r.redSub(a)),i=u.redMul(s))}else r=h.redAdd(a),n=this.curve._mulC(this.z).redSqr(),s=r.redSub(n).redSub(n),t=this.curve._mulC(o.redISub(r)).redMul(s),e=this.curve._mulC(r).redMul(h.redISub(a)),i=r.redMul(s);return this.curve.point(t,e,i)},rs.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},rs.prototype._extAdd=function(t){var e=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),i=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),r=this.t.redMul(this.curve.dd).redMul(t.t),n=this.z.redMul(t.z.redAdd(t.z)),s=i.redSub(e),o=n.redSub(r),h=n.redAdd(r),a=i.redAdd(e),u=s.redMul(o),f=h.redMul(a),l=s.redMul(a),c=o.redMul(h);return this.curve.point(u,f,c,l)},rs.prototype._projAdd=function(t){var e,i,r=this.z.redMul(t.z),n=r.redSqr(),s=this.x.redMul(t.x),o=this.y.redMul(t.y),h=this.curve.d.redMul(s).redMul(o),a=n.redSub(h),u=n.redAdd(h),f=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(s).redISub(o),l=r.redMul(a).redMul(f);return this.curve.twisted?(e=r.redMul(u).redMul(o.redSub(this.curve._mulA(s))),i=a.redMul(u)):(e=r.redMul(u).redMul(o.redSub(s)),i=this.curve._mulC(a).redMul(u)),this.curve.point(l,e,i)},rs.prototype.add=function(t){return this.isInfinity()?t:t.isInfinity()?this:this.curve.extended?this._extAdd(t):this._projAdd(t)},rs.prototype.mul=function(t){return this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve._wnafMul(this,t)},rs.prototype.mulAdd=function(t,e,i){return this.curve._wnafMulAdd(1,[this,e],[t,i],2,!1)},rs.prototype.jmulAdd=function(t,e,i){return this.curve._wnafMulAdd(1,[this,e],[t,i],2,!0)},rs.prototype.normalize=function(){if(this.zOne)return this;var t=this.z.redInvm();return this.x=this.x.redMul(t),this.y=this.y.redMul(t),this.t&&(this.t=this.t.redMul(t)),this.z=this.curve.one,this.zOne=!0,this},rs.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},rs.prototype.getX=function(){return this.normalize(),this.x.fromRed()},rs.prototype.getY=function(){return this.normalize(),this.y.fromRed()},rs.prototype.eq=function(t){return this===t||0===this.getX().cmp(t.getX())&&0===this.getY().cmp(t.getY())},rs.prototype.eqXToP=function(t){var e=t.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(e))return!0;for(var i=t.clone(),r=this.curve.redN.redMul(this.z);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(e.redIAdd(r),0===this.x.cmp(e))return!0}},rs.prototype.toP=rs.prototype.normalize,rs.prototype.mixedAdd=rs.prototype.add;var ns={},ss=ns;ss.base=Kn,ss.short=Hn,ss.mont=Jn,ss.edwards=es;var os={};function hs(t,e){return 55296==(64512&t.charCodeAt(e))&&!(e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1))}function as(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function us(t){return 1===t.length?"0"+t:t}function fs(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}os.inherits=z,os.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var i=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),n=0;n>6|192,i[r++]=63&s|128):hs(t,n)?(s=65536+((1023&s)<<10)+(1023&t.charCodeAt(++n)),i[r++]=s>>18|240,i[r++]=s>>12&63|128,i[r++]=s>>6&63|128,i[r++]=63&s|128):(i[r++]=s>>12|224,i[r++]=s>>6&63|128,i[r++]=63&s|128)}else for(n=0;n>>0}return n},os.split32=function(t,e){for(var i=new Array(4*t.length),r=0,n=0;r>>24,i[n+1]=s>>>16&255,i[n+2]=s>>>8&255,i[n+3]=255&s):(i[n+3]=s>>>24,i[n+2]=s>>>16&255,i[n+1]=s>>>8&255,i[n]=255&s)}return i},os.rotr32=function(t,e){return t>>>e|t<<32-e},os.rotl32=function(t,e){return t<>>32-e},os.sum32=function(t,e){return t+e>>>0},os.sum32_3=function(t,e,i){return t+e+i>>>0},os.sum32_4=function(t,e,i,r){return t+e+i+r>>>0},os.sum32_5=function(t,e,i,r,n){return t+e+i+r+n>>>0},os.sum64=function(t,e,i,r){var n=t[e],s=r+t[e+1]>>>0,o=(s>>0,t[e+1]=s},os.sum64_hi=function(t,e,i,r){return(e+r>>>0>>0},os.sum64_lo=function(t,e,i,r){return e+r>>>0},os.sum64_4_hi=function(t,e,i,r,n,s,o,h){var a=0,u=e;return a+=(u=u+r>>>0)>>0)>>0)>>0},os.sum64_4_lo=function(t,e,i,r,n,s,o,h){return e+r+s+h>>>0},os.sum64_5_hi=function(t,e,i,r,n,s,o,h,a,u){var f=0,l=e;return f+=(l=l+r>>>0)>>0)>>0)>>0)>>0},os.sum64_5_lo=function(t,e,i,r,n,s,o,h,a,u){return e+r+s+h+u>>>0},os.rotr64_hi=function(t,e,i){return(e<<32-i|t>>>i)>>>0},os.rotr64_lo=function(t,e,i){return(t<<32-i|e>>>i)>>>0},os.shr64_hi=function(t,e,i){return t>>>i},os.shr64_lo=function(t,e,i){return(t<<32-i|e>>>i)>>>0};var ls={};function cs(){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}ls.BlockHash=cs,cs.prototype.update=function(t,e){if(t=os.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var i=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-i,t.length),0===this.pending.length&&(this.pending=null),t=os.join32(t,0,t.length-i,this.endian);for(var r=0;r>>24&255,r[n++]=t>>>16&255,r[n++]=t>>>8&255,r[n++]=255&t}else for(r[n++]=255&t,r[n++]=t>>>8&255,r[n++]=t>>>16&255,r[n++]=t>>>24&255,r[n++]=0,r[n++]=0,r[n++]=0,r[n++]=0,s=8;s>>3},ds.g1_256=function(t){return ps(t,17)^ps(t,19)^t>>>10};var ys,bs=os.rotl32,Ms=os.sum32,ws=os.sum32_5,_s=ds.ft_1,Ss=ls.BlockHash,ks=[1518500249,1859775393,2400959708,3395469782];function As(){if(!(this instanceof As))return new As;Ss.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}os.inherits(As,Ss),ys=As,As.blockSize=512,As.outSize=160,As.hmacStrength=80,As.padLength=64,As.prototype._update=function(t,e){for(var i=this.W,r=0;r<16;r++)i[r]=t[e+r];for(;rthis.blockSize&&(t=(new this.Hash).update(t).digest());for(var e=t.length;ethis.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(r=i,i=e,e=null),i&&(i=Nn.toArray(i,r||"hex"),this._update(i));for(var n=[];n.length"};var Zo={};function Fo(t,e){if(t instanceof Fo)return t;this._importDER(t,e)||(this.r=new On(t.r,16),this.s=new On(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}function Vo(){this.place=0}function Ho(t,e){var i=t[e.place++];if(!(128&i))return i;var r=15&i;if(0===r||r>4)return!1;for(var n=0,s=0,o=e.place;s>>=0;return!(n<=127)&&(e.place=o,n)}function Go(t){for(var e=0,i=t.length-1;!t[e]&&!(128&t[e+1])&&e>>3);for(t.push(128|i);--i;)t.push(e>>>(i<<3)&255);t.push(e)}}zn.assert,Zo=Fo,Fo.prototype._importDER=function(t,e){t=zn.toArray(t,e);var i=new Vo;if(48!==t[i.place++])return!1;var r=Ho(t,i);if(!1===r)return!1;if(r+i.place!==t.length)return!1;if(2!==t[i.place++])return!1;var n=Ho(t,i);if(!1===n)return!1;var s=t.slice(i.place,n+i.place);if(i.place+=n,2!==t[i.place++])return!1;var o=Ho(t,i);if(!1===o)return!1;if(t.length!==o+i.place)return!1;var h=t.slice(i.place,o+i.place);if(0===s[0]){if(!(128&s[1]))return!1;s=s.slice(1)}if(0===h[0]){if(!(128&h[1]))return!1;h=h.slice(1)}return this.r=new On(s),this.s=new On(h),this.recoveryParam=null,!0},Fo.prototype.toDER=function(t){var e=this.r.toArray(),i=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&i[0]&&(i=[0].concat(i)),e=Go(e),i=Go(i);!(i[0]||128&i[1]);)i=i.slice(1);var r=[2];Xo(r,e.length),(r=r.concat(e)).push(2),Xo(r,i.length);var n=r.concat(i),s=[48];return Xo(s,n.length),s=s.concat(n),zn.encode(s,t)};var Yo,Jo=(zn.assert,Ko);function Qo(t){if(!(this instanceof Qo))return new Qo(t);"string"==typeof t&&(t=No[t]),t instanceof No.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}Yo=Qo,Qo.prototype.keyPair=function(t){return new Jo(this,t)},Qo.prototype.keyFromPrivate=function(t,e){return Jo.fromPrivate(this,t,e)},Qo.prototype.keyFromPublic=function(t,e){return Jo.fromPublic(this,t,e)},Qo.prototype.genKeyPair=function(t){t||(t={});for(var e=new zo({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||dn(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),r=this.n.sub(new On(2));;){var n=new On(e.generate(i));if(!(n.cmp(r)>0))return n.iaddn(1),this.keyFromPrivate(n)}},Qo.prototype._truncateToN=function(t,e){var i=8*t.byteLength()-this.n.bitLength();return i>0&&(t=t.ushrn(i)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},Qo.prototype.sign=function(t,e,i,r){"object"==typeof i&&(r=i,i=null),r||(r={}),e=this.keyFromPrivate(e,i),t=this._truncateToN(new On(t,16));for(var n=this.n.byteLength(),s=e.getPrivate().toArray("be",n),o=t.toArray("be",n),h=new zo({hash:this.hash,entropy:s,nonce:o,pers:r.pers,persEnc:r.persEnc||"utf8"}),a=this.n.sub(new On(1)),u=0;;u++){var f=r.k?r.k(u):new On(h.generate(this.n.byteLength()));if(!((f=this._truncateToN(f,!0)).cmpn(1)<=0||f.cmp(a)>=0)){var l=this.g.mul(f);if(!l.isInfinity()){var c=l.getX(),d=c.umod(this.n);if(0!==d.cmpn(0)){var p=f.invm(this.n).mul(d.mul(e.getPrivate()).iadd(t));if(0!==(p=p.umod(this.n)).cmpn(0)){var m=(l.getY().isOdd()?1:0)|(0!==c.cmp(d)?2:0);return r.canonical&&p.cmp(this.nh)>0&&(p=this.n.sub(p),m^=1),new Zo({r:d,s:p,recoveryParam:m})}}}}}},Qo.prototype.verify=function(t,e,i,r){t=this._truncateToN(new On(t,16)),i=this.keyFromPublic(i,r);var n=(e=new Zo(e,"hex")).r,s=e.s;if(n.cmpn(1)<0||n.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var o,h=s.invm(this.n),a=h.mul(t).umod(this.n),u=h.mul(n).umod(this.n);return this.curve._maxwellTrick?!(o=this.g.jmulAdd(a,i.getPublic(),u)).isInfinity()&&o.eqXToP(n):!(o=this.g.mulAdd(a,i.getPublic(),u)).isInfinity()&&0===o.getX().umod(this.n).cmp(n)},Qo.prototype.recoverPubKey=function(t,e,i,r){e=new Zo(e,r);var n=this.n,s=new On(t),o=e.r,h=e.s,a=1&i,u=i>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");o=u?this.curve.pointFromX(o.add(this.curve.n),a):this.curve.pointFromX(o,a);var f=e.r.invm(n),l=n.sub(s).mul(f).umod(n),c=h.mul(f).umod(n);return this.g.mulAdd(l,o,c)},Qo.prototype.getKeyRecoveryParam=function(t,e,i,r){if(null!==(e=new Zo(e,r)).recoveryParam)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(t,e,n)}catch(t){continue}if(s.eq(i))return n}throw new Error("Unable to find valid recovery factor")};var th={},eh=(zn.assert,zn.parseBytes),ih=zn.cachedProperty;function rh(t,e){this.eddsa=t,this._secret=eh(e.secret),t.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=eh(e.pub)}rh.fromPublic=function(t,e){return e instanceof rh?e:new rh(t,{pub:e})},rh.fromSecret=function(t,e){return e instanceof rh?e:new rh(t,{secret:e})},rh.prototype.secret=function(){return this._secret},ih(rh,"pubBytes",(function(){return this.eddsa.encodePoint(this.pub())})),ih(rh,"pub",(function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())})),ih(rh,"privBytes",(function(){var t=this.eddsa,e=this.hash(),i=t.encodingLength-1,r=e.slice(0,t.encodingLength);return r[0]&=248,r[i]&=127,r[i]|=64,r})),ih(rh,"priv",(function(){return this.eddsa.decodeInt(this.privBytes())})),ih(rh,"hash",(function(){return this.eddsa.hash().update(this.secret()).digest()})),ih(rh,"messagePrefix",(function(){return this.hash().slice(this.eddsa.encodingLength)})),rh.prototype.sign=function(t){return this.eddsa.sign(t,this)},rh.prototype.verify=function(t,e){return this.eddsa.verify(t,e,this)},rh.prototype.getSecret=function(t){return zn.encode(this.secret(),t)},rh.prototype.getPublic=function(t){return zn.encode(this.pubBytes(),t)},th=rh;var nh={},sh=(zn.assert,zn.cachedProperty),oh=zn.parseBytes;function hh(t,e){this.eddsa=t,"object"!=typeof e&&(e=oh(e)),Array.isArray(e)&&(e={R:e.slice(0,t.encodingLength),S:e.slice(t.encodingLength)}),t.isPoint(e.R)&&(this._R=e.R),e.S instanceof On&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}sh(hh,"S",(function(){return this.eddsa.decodeInt(this.Sencoded())})),sh(hh,"R",(function(){return this.eddsa.decodePoint(this.Rencoded())})),sh(hh,"Rencoded",(function(){return this.eddsa.encodePoint(this.R())})),sh(hh,"Sencoded",(function(){return this.eddsa.encodeInt(this.S())})),hh.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},hh.prototype.toHex=function(){return zn.encode(this.toBytes(),"hex").toUpperCase()},nh=hh;var ah,uh=(zn.assert,zn.parseBytes);function fh(t){if(!(this instanceof fh))return new fh(t);t=No[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=Lo.sha512}ah=fh,fh.prototype.sign=function(t,e){t=uh(t);var i=this.keyFromSecret(e),r=this.hashInt(i.messagePrefix(),t),n=this.g.mul(r),s=this.encodePoint(n),o=this.hashInt(s,i.pubBytes(),t).mul(i.priv()),h=r.add(o).umod(this.curve.n);return this.makeSignature({R:n,S:h,Rencoded:s})},fh.prototype.verify=function(t,e,i){t=uh(t),e=this.makeSignature(e);var r=this.keyFromPublic(i),n=this.hashInt(e.Rencoded(),r.pubBytes(),t),s=this.g.mul(e.S());return e.R().add(r.pub().mul(n)).eq(s)},fh.prototype.hashInt=function(){for(var t=this.hash(),e=0;e=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return r}function o(t,e,i,r){for(var n=0,s=Math.min(t.length,i),o=e;o=49?h-49+10:h>=17?h-17+10:h}return n}r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,e){return t.cmp(e)>0?t:e},r.min=function(t,e){return t.cmp(e)<0?t:e},r.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===e?this._parseHex(t,r):this._parseBase(t,e,r),"-"===t[0]&&(this.negative=1),this.strip(),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initArray=function(t,e,i){if(t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r=0;r-=3)s=t[r]|t[r-1]<<8|t[r-2]<<16,this.words[n]|=s<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===i)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this.strip()},r.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=6)n=s(t,i,i+6),this.words[r]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,r++);i+6!==e&&(n=s(t,e,i+6),this.words[r]|=n<>>26-o&4194303),this.strip()},r.prototype._parseBase=function(t,e,i){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=e)r++;r--,n=n/e|0;for(var s=t.length-i,h=s%r,a=Math.min(s,s-h)+i,u=0,f=i;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},r.prototype.inspect=function(){return(this.red?""};var h=["","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],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function l(t,e,i){i.negative=e.negative^t.negative;var r=t.length+e.length|0;i.length=r,r=r-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,h=67108863&o,a=o/67108864|0;i.words[0]=h;for(var u=1;u>>26,l=67108863&a,c=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=c;d++){var p=u-d|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[d])+l)/67108864|0,l=67108863&o}i.words[u]=0|l,a=0|f}return 0!==a?i.words[u]=0|a:i.length--,i.strip()}r.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var r=0,n=0,s=0;s>>24-r&16777215)||s!==this.length-1?h[6-a.length]+a+i:a+i,(r+=2)>=26&&(r-=26,s--)}for(0!==n&&(i=n.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var l=u[t],c=f[t];i="";var d=this.clone();for(d.negative=0;!d.isZero();){var p=d.modn(c).toString(t);i=(d=d.idivn(c)).isZero()?p+i:h[l-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length,0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16)},r.prototype.toBuffer=function(t,e){return this.toArrayLike(n,t,e)},r.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},r.prototype.toArrayLike=function(t,e,i){var r=this.byteLength(),n=i||Math.max(1,r);this.strip();var s,o,h="le"===e,a=new t(n),u=this.clone();if(h){for(o=0;!u.isZero();o++)s=u.andln(255),u.iushrn(8),a[o]=s;for(;o=4096&&(i+=13,e>>>=13),e>=64&&(i+=7,e>>>=7),e>=8&&(i+=4,e>>>=4),e>=2&&(i+=2,e>>>=2),i+e},r.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,i=0;return 0==(8191&e)&&(i+=13,e>>>=13),0==(127&e)&&(i+=7,e>>>=7),0==(15&e)&&(i+=4,e>>>=4),0==(3&e)&&(i+=2,e>>>=2),0==(1&e)&&i++,i},r.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var i=0;it.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var e,i;this.length>t.length?(e=this,i=t):(e=t,i=this);for(var r=0;rt.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-i),this.strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,e){var i=t/26|0,r=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(i=this,r=t):(i=t,r=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i,r,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(i=this,r=t):(i=t,r=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,d=0|o[1],p=8191&d,m=d>>>13,g=0|o[2],v=8191&g,y=g>>>13,b=0|o[3],M=8191&b,w=b>>>13,_=0|o[4],S=8191&_,k=_>>>13,A=0|o[5],E=8191&A,R=A>>>13,x=0|o[6],B=8191&x,I=x>>>13,P=0|o[7],T=8191&P,q=P>>>13,L=0|o[8],j=8191&L,O=L>>>13,N=0|o[9],C=8191&N,$=N>>>13,U=0|h[0],z=8191&U,D=U>>>13,K=0|h[1],W=8191&K,Z=K>>>13,F=0|h[2],V=8191&F,H=F>>>13,G=0|h[3],X=8191&G,Y=G>>>13,J=0|h[4],Q=8191&J,tt=J>>>13,et=0|h[5],it=8191&et,rt=et>>>13,nt=0|h[6],st=8191&nt,ot=nt>>>13,ht=0|h[7],at=8191&ht,ut=ht>>>13,ft=0|h[8],lt=8191&ft,ct=ft>>>13,dt=0|h[9],pt=8191&dt,mt=dt>>>13;i.negative=t.negative^e.negative,i.length=19;var gt=(u+(r=Math.imul(l,z))|0)+((8191&(n=(n=Math.imul(l,D))+Math.imul(c,z)|0))<<13)|0;u=((s=Math.imul(c,D))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(p,z),n=(n=Math.imul(p,D))+Math.imul(m,z)|0,s=Math.imul(m,D);var vt=(u+(r=r+Math.imul(l,W)|0)|0)+((8191&(n=(n=n+Math.imul(l,Z)|0)+Math.imul(c,W)|0))<<13)|0;u=((s=s+Math.imul(c,Z)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(v,z),n=(n=Math.imul(v,D))+Math.imul(y,z)|0,s=Math.imul(y,D),r=r+Math.imul(p,W)|0,n=(n=n+Math.imul(p,Z)|0)+Math.imul(m,W)|0,s=s+Math.imul(m,Z)|0;var yt=(u+(r=r+Math.imul(l,V)|0)|0)+((8191&(n=(n=n+Math.imul(l,H)|0)+Math.imul(c,V)|0))<<13)|0;u=((s=s+Math.imul(c,H)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(M,z),n=(n=Math.imul(M,D))+Math.imul(w,z)|0,s=Math.imul(w,D),r=r+Math.imul(v,W)|0,n=(n=n+Math.imul(v,Z)|0)+Math.imul(y,W)|0,s=s+Math.imul(y,Z)|0,r=r+Math.imul(p,V)|0,n=(n=n+Math.imul(p,H)|0)+Math.imul(m,V)|0,s=s+Math.imul(m,H)|0;var bt=(u+(r=r+Math.imul(l,X)|0)|0)+((8191&(n=(n=n+Math.imul(l,Y)|0)+Math.imul(c,X)|0))<<13)|0;u=((s=s+Math.imul(c,Y)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(S,z),n=(n=Math.imul(S,D))+Math.imul(k,z)|0,s=Math.imul(k,D),r=r+Math.imul(M,W)|0,n=(n=n+Math.imul(M,Z)|0)+Math.imul(w,W)|0,s=s+Math.imul(w,Z)|0,r=r+Math.imul(v,V)|0,n=(n=n+Math.imul(v,H)|0)+Math.imul(y,V)|0,s=s+Math.imul(y,H)|0,r=r+Math.imul(p,X)|0,n=(n=n+Math.imul(p,Y)|0)+Math.imul(m,X)|0,s=s+Math.imul(m,Y)|0;var Mt=(u+(r=r+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(c,Q)|0))<<13)|0;u=((s=s+Math.imul(c,tt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(E,z),n=(n=Math.imul(E,D))+Math.imul(R,z)|0,s=Math.imul(R,D),r=r+Math.imul(S,W)|0,n=(n=n+Math.imul(S,Z)|0)+Math.imul(k,W)|0,s=s+Math.imul(k,Z)|0,r=r+Math.imul(M,V)|0,n=(n=n+Math.imul(M,H)|0)+Math.imul(w,V)|0,s=s+Math.imul(w,H)|0,r=r+Math.imul(v,X)|0,n=(n=n+Math.imul(v,Y)|0)+Math.imul(y,X)|0,s=s+Math.imul(y,Y)|0,r=r+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var wt=(u+(r=r+Math.imul(l,it)|0)|0)+((8191&(n=(n=n+Math.imul(l,rt)|0)+Math.imul(c,it)|0))<<13)|0;u=((s=s+Math.imul(c,rt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(B,z),n=(n=Math.imul(B,D))+Math.imul(I,z)|0,s=Math.imul(I,D),r=r+Math.imul(E,W)|0,n=(n=n+Math.imul(E,Z)|0)+Math.imul(R,W)|0,s=s+Math.imul(R,Z)|0,r=r+Math.imul(S,V)|0,n=(n=n+Math.imul(S,H)|0)+Math.imul(k,V)|0,s=s+Math.imul(k,H)|0,r=r+Math.imul(M,X)|0,n=(n=n+Math.imul(M,Y)|0)+Math.imul(w,X)|0,s=s+Math.imul(w,Y)|0,r=r+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,tt)|0)+Math.imul(y,Q)|0,s=s+Math.imul(y,tt)|0,r=r+Math.imul(p,it)|0,n=(n=n+Math.imul(p,rt)|0)+Math.imul(m,it)|0,s=s+Math.imul(m,rt)|0;var _t=(u+(r=r+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(c,st)|0))<<13)|0;u=((s=s+Math.imul(c,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(T,z),n=(n=Math.imul(T,D))+Math.imul(q,z)|0,s=Math.imul(q,D),r=r+Math.imul(B,W)|0,n=(n=n+Math.imul(B,Z)|0)+Math.imul(I,W)|0,s=s+Math.imul(I,Z)|0,r=r+Math.imul(E,V)|0,n=(n=n+Math.imul(E,H)|0)+Math.imul(R,V)|0,s=s+Math.imul(R,H)|0,r=r+Math.imul(S,X)|0,n=(n=n+Math.imul(S,Y)|0)+Math.imul(k,X)|0,s=s+Math.imul(k,Y)|0,r=r+Math.imul(M,Q)|0,n=(n=n+Math.imul(M,tt)|0)+Math.imul(w,Q)|0,s=s+Math.imul(w,tt)|0,r=r+Math.imul(v,it)|0,n=(n=n+Math.imul(v,rt)|0)+Math.imul(y,it)|0,s=s+Math.imul(y,rt)|0,r=r+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(r=r+Math.imul(l,at)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(c,at)|0))<<13)|0;u=((s=s+Math.imul(c,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(j,z),n=(n=Math.imul(j,D))+Math.imul(O,z)|0,s=Math.imul(O,D),r=r+Math.imul(T,W)|0,n=(n=n+Math.imul(T,Z)|0)+Math.imul(q,W)|0,s=s+Math.imul(q,Z)|0,r=r+Math.imul(B,V)|0,n=(n=n+Math.imul(B,H)|0)+Math.imul(I,V)|0,s=s+Math.imul(I,H)|0,r=r+Math.imul(E,X)|0,n=(n=n+Math.imul(E,Y)|0)+Math.imul(R,X)|0,s=s+Math.imul(R,Y)|0,r=r+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(k,Q)|0,s=s+Math.imul(k,tt)|0,r=r+Math.imul(M,it)|0,n=(n=n+Math.imul(M,rt)|0)+Math.imul(w,it)|0,s=s+Math.imul(w,rt)|0,r=r+Math.imul(v,st)|0,n=(n=n+Math.imul(v,ot)|0)+Math.imul(y,st)|0,s=s+Math.imul(y,ot)|0,r=r+Math.imul(p,at)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,at)|0,s=s+Math.imul(m,ut)|0;var kt=(u+(r=r+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,ct)|0)+Math.imul(c,lt)|0))<<13)|0;u=((s=s+Math.imul(c,ct)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(C,z),n=(n=Math.imul(C,D))+Math.imul($,z)|0,s=Math.imul($,D),r=r+Math.imul(j,W)|0,n=(n=n+Math.imul(j,Z)|0)+Math.imul(O,W)|0,s=s+Math.imul(O,Z)|0,r=r+Math.imul(T,V)|0,n=(n=n+Math.imul(T,H)|0)+Math.imul(q,V)|0,s=s+Math.imul(q,H)|0,r=r+Math.imul(B,X)|0,n=(n=n+Math.imul(B,Y)|0)+Math.imul(I,X)|0,s=s+Math.imul(I,Y)|0,r=r+Math.imul(E,Q)|0,n=(n=n+Math.imul(E,tt)|0)+Math.imul(R,Q)|0,s=s+Math.imul(R,tt)|0,r=r+Math.imul(S,it)|0,n=(n=n+Math.imul(S,rt)|0)+Math.imul(k,it)|0,s=s+Math.imul(k,rt)|0,r=r+Math.imul(M,st)|0,n=(n=n+Math.imul(M,ot)|0)+Math.imul(w,st)|0,s=s+Math.imul(w,ot)|0,r=r+Math.imul(v,at)|0,n=(n=n+Math.imul(v,ut)|0)+Math.imul(y,at)|0,s=s+Math.imul(y,ut)|0,r=r+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,ct)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,ct)|0;var At=(u+(r=r+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(c,pt)|0))<<13)|0;u=((s=s+Math.imul(c,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(C,W),n=(n=Math.imul(C,Z))+Math.imul($,W)|0,s=Math.imul($,Z),r=r+Math.imul(j,V)|0,n=(n=n+Math.imul(j,H)|0)+Math.imul(O,V)|0,s=s+Math.imul(O,H)|0,r=r+Math.imul(T,X)|0,n=(n=n+Math.imul(T,Y)|0)+Math.imul(q,X)|0,s=s+Math.imul(q,Y)|0,r=r+Math.imul(B,Q)|0,n=(n=n+Math.imul(B,tt)|0)+Math.imul(I,Q)|0,s=s+Math.imul(I,tt)|0,r=r+Math.imul(E,it)|0,n=(n=n+Math.imul(E,rt)|0)+Math.imul(R,it)|0,s=s+Math.imul(R,rt)|0,r=r+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(k,st)|0,s=s+Math.imul(k,ot)|0,r=r+Math.imul(M,at)|0,n=(n=n+Math.imul(M,ut)|0)+Math.imul(w,at)|0,s=s+Math.imul(w,ut)|0,r=r+Math.imul(v,lt)|0,n=(n=n+Math.imul(v,ct)|0)+Math.imul(y,lt)|0,s=s+Math.imul(y,ct)|0;var Et=(u+(r=r+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(C,V),n=(n=Math.imul(C,H))+Math.imul($,V)|0,s=Math.imul($,H),r=r+Math.imul(j,X)|0,n=(n=n+Math.imul(j,Y)|0)+Math.imul(O,X)|0,s=s+Math.imul(O,Y)|0,r=r+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(q,Q)|0,s=s+Math.imul(q,tt)|0,r=r+Math.imul(B,it)|0,n=(n=n+Math.imul(B,rt)|0)+Math.imul(I,it)|0,s=s+Math.imul(I,rt)|0,r=r+Math.imul(E,st)|0,n=(n=n+Math.imul(E,ot)|0)+Math.imul(R,st)|0,s=s+Math.imul(R,ot)|0,r=r+Math.imul(S,at)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(k,at)|0,s=s+Math.imul(k,ut)|0,r=r+Math.imul(M,lt)|0,n=(n=n+Math.imul(M,ct)|0)+Math.imul(w,lt)|0,s=s+Math.imul(w,ct)|0;var Rt=(u+(r=r+Math.imul(v,pt)|0)|0)+((8191&(n=(n=n+Math.imul(v,mt)|0)+Math.imul(y,pt)|0))<<13)|0;u=((s=s+Math.imul(y,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(C,X),n=(n=Math.imul(C,Y))+Math.imul($,X)|0,s=Math.imul($,Y),r=r+Math.imul(j,Q)|0,n=(n=n+Math.imul(j,tt)|0)+Math.imul(O,Q)|0,s=s+Math.imul(O,tt)|0,r=r+Math.imul(T,it)|0,n=(n=n+Math.imul(T,rt)|0)+Math.imul(q,it)|0,s=s+Math.imul(q,rt)|0,r=r+Math.imul(B,st)|0,n=(n=n+Math.imul(B,ot)|0)+Math.imul(I,st)|0,s=s+Math.imul(I,ot)|0,r=r+Math.imul(E,at)|0,n=(n=n+Math.imul(E,ut)|0)+Math.imul(R,at)|0,s=s+Math.imul(R,ut)|0,r=r+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,ct)|0)+Math.imul(k,lt)|0,s=s+Math.imul(k,ct)|0;var xt=(u+(r=r+Math.imul(M,pt)|0)|0)+((8191&(n=(n=n+Math.imul(M,mt)|0)+Math.imul(w,pt)|0))<<13)|0;u=((s=s+Math.imul(w,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(C,Q),n=(n=Math.imul(C,tt))+Math.imul($,Q)|0,s=Math.imul($,tt),r=r+Math.imul(j,it)|0,n=(n=n+Math.imul(j,rt)|0)+Math.imul(O,it)|0,s=s+Math.imul(O,rt)|0,r=r+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(q,st)|0,s=s+Math.imul(q,ot)|0,r=r+Math.imul(B,at)|0,n=(n=n+Math.imul(B,ut)|0)+Math.imul(I,at)|0,s=s+Math.imul(I,ut)|0,r=r+Math.imul(E,lt)|0,n=(n=n+Math.imul(E,ct)|0)+Math.imul(R,lt)|0,s=s+Math.imul(R,ct)|0;var Bt=(u+(r=r+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(k,pt)|0))<<13)|0;u=((s=s+Math.imul(k,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(C,it),n=(n=Math.imul(C,rt))+Math.imul($,it)|0,s=Math.imul($,rt),r=r+Math.imul(j,st)|0,n=(n=n+Math.imul(j,ot)|0)+Math.imul(O,st)|0,s=s+Math.imul(O,ot)|0,r=r+Math.imul(T,at)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(q,at)|0,s=s+Math.imul(q,ut)|0,r=r+Math.imul(B,lt)|0,n=(n=n+Math.imul(B,ct)|0)+Math.imul(I,lt)|0,s=s+Math.imul(I,ct)|0;var It=(u+(r=r+Math.imul(E,pt)|0)|0)+((8191&(n=(n=n+Math.imul(E,mt)|0)+Math.imul(R,pt)|0))<<13)|0;u=((s=s+Math.imul(R,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(C,st),n=(n=Math.imul(C,ot))+Math.imul($,st)|0,s=Math.imul($,ot),r=r+Math.imul(j,at)|0,n=(n=n+Math.imul(j,ut)|0)+Math.imul(O,at)|0,s=s+Math.imul(O,ut)|0,r=r+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,ct)|0)+Math.imul(q,lt)|0,s=s+Math.imul(q,ct)|0;var Pt=(u+(r=r+Math.imul(B,pt)|0)|0)+((8191&(n=(n=n+Math.imul(B,mt)|0)+Math.imul(I,pt)|0))<<13)|0;u=((s=s+Math.imul(I,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(C,at),n=(n=Math.imul(C,ut))+Math.imul($,at)|0,s=Math.imul($,ut),r=r+Math.imul(j,lt)|0,n=(n=n+Math.imul(j,ct)|0)+Math.imul(O,lt)|0,s=s+Math.imul(O,ct)|0;var Tt=(u+(r=r+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(q,pt)|0))<<13)|0;u=((s=s+Math.imul(q,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(C,lt),n=(n=Math.imul(C,ct))+Math.imul($,lt)|0,s=Math.imul($,ct);var qt=(u+(r=r+Math.imul(j,pt)|0)|0)+((8191&(n=(n=n+Math.imul(j,mt)|0)+Math.imul(O,pt)|0))<<13)|0;u=((s=s+Math.imul(O,mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863;var Lt=(u+(r=Math.imul(C,pt))|0)+((8191&(n=(n=Math.imul(C,mt))+Math.imul($,pt)|0))<<13)|0;return u=((s=Math.imul($,mt))+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,a[0]=gt,a[1]=vt,a[2]=yt,a[3]=bt,a[4]=Mt,a[5]=wt,a[6]=_t,a[7]=St,a[8]=kt,a[9]=At,a[10]=Et,a[11]=Rt,a[12]=xt,a[13]=Bt,a[14]=It,a[15]=Pt,a[16]=Tt,a[17]=qt,a[18]=Lt,0!==u&&(a[19]=u,i.length++),i};function d(t,e,i){return(new p).mulp(t,e,i)}function p(t,e){this.x=t,this.y=e}Math.imul||(c=l),r.prototype.mulTo=function(t,e){var i=this.length+t.length;return 10===this.length&&10===t.length?c(this,t,e):i<63?l(this,t,e):i<1024?function(t,e,i){i.negative=e.negative^t.negative,i.length=t.length+e.length;for(var r=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}i.words[s]=h,r=o,o=n}return 0!==r?i.words[s]=r:i.length--,i.strip()}(this,t,e):d(this,t,e)},p.prototype.makeRBT=function(t){for(var e=new Array(t),i=r.prototype._countBits(t)-1,n=0;n>=1;return r},p.prototype.permute=function(t,e,i,r,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*s+1]=8191&n,n>>>=13;for(s=2*e;s>=26,e+=r/67108864|0,e+=n>>>26,this.words[i]=67108863&n}return 0!==e&&(this.words[i]=e,this.length++),this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),i=0;i>>n}return e}(t);if(0===e.length)return new r(1);for(var i=this,n=0;n>>26-i<<26-i;if(0!==i){var s=0;for(e=0;e>>26-i}s&&(this.words[e]=s,this.length++)}if(0!==r){for(e=this.length-1;e>=0;e--)this.words[e+r]=this.words[e];for(e=0;e>>n<s)for(this.length-=s,a=0;a=0&&(0!==u||a>=r);a--){var f=0|this.words[a];this.words[a]=u<<26-n|f>>>n,u=f&o}return h&&0!==u&&(h.words[h.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},r.prototype.ishrn=function(t,e,i){return this.iushrn(t,e,i)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){var e=t%26,i=(t-e)/26,r=1<>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},r.prototype.isubn=function(t){if(t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[r+i]=67108863&n}for(;r>26,this.words[r+i]=67108863&n;if(0===o)return this.strip();for(o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},r.prototype._wordDiv=function(t,e){var i=(this.length,t.length),n=this.clone(),s=t,o=0|s.words[s.length-1];0!=(i=26-this._countBits(o))&&(s=s.ushln(i),n.iushln(i),o=0|s.words[s.length-1]);var h,a=n.length-s.length;if("mod"!==e){(h=new r(null)).length=a+1,h.words=new Array(h.length);for(var u=0;u=0;l--){var c=67108864*(0|n.words[s.length+l])+(0|n.words[s.length+l-1]);for(c=Math.min(c/o|0,67108863),n._ishlnsubmul(s,c,l);0!==n.negative;)c--,n.negative=0,n._ishlnsubmul(s,1,l),n.isZero()||(n.negative^=1);h&&(h.words[l]=c)}return h&&h.strip(),n.strip(),"div"!==e&&0!==i&&n.iushrn(i),{div:h||null,mod:n}},r.prototype.divmod=function(t,e,i){return this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),"mod"!==e&&(n=o.div.neg()),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),e),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new r(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var i=0!==e.div.negative?e.mod.isub(t):e.mod,r=t.ushrn(1),n=t.andln(1),s=i.cmp(r);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},r.prototype.modn=function(t){for(var e=(1<<26)%t,i=0,r=this.length-1;r>=0;r--)i=(e*i+(0|this.words[r]))%t;return i},r.prototype.idivn=function(t){for(var e=0,i=this.length-1;i>=0;i--){var r=(0|this.words[i])+67108864*e;this.words[i]=r/t|0,e=r%t}return this.strip()},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new r(1),s=new r(0),o=new r(0),h=new r(1),a=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++a;for(var u=i.clone(),f=e.clone();!e.isZero();){for(var l=0,c=1;0==(e.words[0]&c)&&l<26;++l,c<<=1);if(l>0)for(e.iushrn(l);l-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(u),s.isub(f)),n.iushrn(1),s.iushrn(1);for(var d=0,p=1;0==(i.words[0]&p)&&d<26;++d,p<<=1);if(d>0)for(i.iushrn(d);d-- >0;)(o.isOdd()||h.isOdd())&&(o.iadd(u),h.isub(f)),o.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),n.isub(o),s.isub(h)):(i.isub(e),o.isub(n),h.isub(s))}return{a:o,b:h,gcd:i.iushln(a)}},r.prototype._invmp=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new r(1),o=new r(0),h=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var a=0,u=1;0==(e.words[0]&u)&&a<26;++a,u<<=1);if(a>0)for(e.iushrn(a);a-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);for(var f=0,l=1;0==(i.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(i.iushrn(f);f-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o)):(i.isub(e),o.isub(s))}return(n=0===e.cmpn(1)?s:o).cmpn(0)<0&&n.iadd(t),n},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),i=t.clone();e.negative=0,i.negative=0;for(var r=0;e.isEven()&&i.isEven();r++)e.iushrn(1),i.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;i.isEven();)i.iushrn(1);var n=e.cmp(i);if(n<0){var s=e;e=i,i=s}else if(0===n||0===i.cmpn(1))break;e.isub(i)}return i.iushln(r)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){var e=t%26,i=(t-e)/26,r=1<>>26,o&=67108863,this.words[s]=o}return 0!==n&&(this.words[s]=n,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t);var r=0|this.words[0];e=r===t?0:rt.length)return 1;if(this.length=0;i--){var r=0|this.words[i],n=0|t.words[i];if(r!==n){rn&&(e=1);break}}return e},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new w(t)},r.prototype.toRed=function(t){return t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return this._forceRed(t)},r.prototype.redAdd=function(t){return this.red.add(this,t)},r.prototype.redIAdd=function(t){return this.red.iadd(this,t)},r.prototype.redSub=function(t){return this.red.sub(this,t)},r.prototype.redISub=function(t){return this.red.isub(this,t)},r.prototype.redShl=function(t){return this.red.shl(this,t)},r.prototype.redMul=function(t){return this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return this.red._verify1(this),this.red.pow(this,t)};var m={k256:null,p224:null,p192:null,p25519:null};function g(t,e){this.name=t,this.p=new r(e,16),this.n=this.p.bitLength(),this.k=new r(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){g.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function y(){g.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){g.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function M(){g.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function w(t){if("string"==typeof t){var e=r._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function _(t){w.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}g.prototype._tmp=function(){var t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},g.prototype.ireduce=function(t){var e,i=t;do{this.split(i,this.tmp),e=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(e>this.n);var r=e0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},g.prototype.split=function(t,e){t.iushrn(this.n,0,e)},g.prototype.imulK=function(t){return t.imul(this.k)},i(v,g),v.prototype.split=function(t,e){for(var i=Math.min(t.length,9),r=0;r>>22,n=s}n>>>=22,t.words[r-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,i=0;i>>=26,t.words[i]=n,e=r}return 0!==e&&(t.words[t.length++]=e),t},r._prime=function(t){if(m[t])return m[t];var e;if("k256"===t)e=new v;else if("p224"===t)e=new y;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new M}return m[t]=e,e},w.prototype._verify1=function(t){},w.prototype._verify2=function(t,e){},w.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},w.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},w.prototype.add=function(t,e){this._verify2(t,e);var i=t.add(e);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},w.prototype.iadd=function(t,e){this._verify2(t,e);var i=t.iadd(e);return i.cmp(this.m)>=0&&i.isub(this.m),i},w.prototype.sub=function(t,e){this._verify2(t,e);var i=t.sub(e);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},w.prototype.isub=function(t,e){this._verify2(t,e);var i=t.isub(e);return i.cmpn(0)<0&&i.iadd(this.m),i},w.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},w.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},w.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},w.prototype.isqr=function(t){return this.imul(t,t.clone())},w.prototype.sqr=function(t){return this.mul(t,t)},w.prototype.sqrt=function(t){if(t.isZero())return t.clone();if(3===this.m.andln(3)){var e=this.m.add(new r(1)).iushrn(2);return this.pow(t,e)}for(var i=this.m.subn(1),n=0;!i.isZero()&&0===i.andln(1);)n++,i.iushrn(1);var s=new r(1).toRed(this),o=s.redNeg(),h=this.m.subn(1).iushrn(1),a=this.m.bitLength();for(a=new r(2*a*a).toRed(this);0!==this.pow(a,h).cmp(o);)a.redIAdd(o);for(var u=this.pow(a,i),f=this.pow(t,i.addn(1).iushrn(1)),l=this.pow(t,i),c=n;0!==l.cmp(s);){for(var d=l,p=0;0!==d.cmp(s);p++)d=d.redSqr();var m=this.pow(u,new r(1).iushln(c-p-1));f=f.redMul(m),u=m.redSqr(),l=l.redMul(u),c=p}return f},w.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},w.prototype.pow=function(t,e){if(e.isZero())return new r(1).toRed(this);if(0===e.cmpn(1))return t.clone();var i=new Array(16);i[0]=new r(1).toRed(this),i[1]=t;for(var n=2;n=0;n--){for(var u=e.words[n],f=a-1;f>=0;f--){var l=u>>f&1;s!==i[0]&&(s=this.sqr(s)),0!==l||0!==o?(o<<=1,o|=l,(4==++h||0===n&&0===f)&&(s=this.mul(s,i[o]),h=0,o=0)):h=0}a=26}return s},w.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},w.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},r.mont=function(t){return new _(t)},i(_,w),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(e),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new r(0)._forceRed(this);var i=t.mul(e),n=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=i.isub(n).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(dh,this),dh=dh.exports;var ph={};(function(t){(function(){"use strict";var e,i=u({}),r=i.Buffer,n={};for(e in i)i.hasOwnProperty(e)&&"SlowBuffer"!==e&&"Buffer"!==e&&(n[e]=i[e]);var s=n.Buffer={};for(e in r)r.hasOwnProperty(e)&&"allocUnsafe"!==e&&"allocUnsafeSlow"!==e&&(s[e]=r[e]);if(n.Buffer.prototype=r.prototype,s.from&&s.from!==Uint8Array.from||(s.from=function(t,e,i){if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof t);if(t&&void 0===t.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);return r(t,e,i)}),s.alloc||(s.alloc=function(t,e,i){if("number"!=typeof t)throw new TypeError('The "size" argument must be of type number. Received type '+typeof t);if(t<0||t>=2*(1<<30))throw new RangeError('The value "'+t+'" is invalid for option "size"');var n=r(t);return e&&0!==e.length?"string"==typeof i?n.fill(e,i):n.fill(e):n.fill(0),n}),!n.kStringMaxLength)try{n.kStringMaxLength=t.binding("buffer").kStringMaxLength}catch(hu){}n.constants||(n.constants={MAX_LENGTH:n.kMaxLength},n.kStringMaxLength&&(n.constants.MAX_STRING_LENGTH=n.kStringMaxLength)),ph=n}).call(this)}).call(this,R);var mh={};function gh(t){this._reporterState={obj:null,path:[],options:t||{},errors:[]}}function vh(t,e){this.path=t,this.rethrow(e)}mh.Reporter=gh,gh.prototype.isError=function(t){return t instanceof vh},gh.prototype.save=function(){const t=this._reporterState;return{obj:t.obj,pathLen:t.path.length}},gh.prototype.restore=function(t){const e=this._reporterState;e.obj=t.obj,e.path=e.path.slice(0,t.pathLen)},gh.prototype.enterKey=function(t){return this._reporterState.path.push(t)},gh.prototype.exitKey=function(t){const e=this._reporterState;e.path=e.path.slice(0,t-1)},gh.prototype.leaveKey=function(t,e,i){const r=this._reporterState;this.exitKey(t),null!==r.obj&&(r.obj[e]=i)},gh.prototype.path=function(){return this._reporterState.path.join("/")},gh.prototype.enterObject=function(){const t=this._reporterState,e=t.obj;return t.obj={},e},gh.prototype.leaveObject=function(t){const e=this._reporterState,i=e.obj;return e.obj=t,i},gh.prototype.error=function(t){let e;const i=this._reporterState,r=t instanceof vh;if(e=r?t:new vh(i.path.map((function(t){return"["+JSON.stringify(t)+"]"})).join(""),t.message||t,t.stack),!i.options.partial)throw e;return r||i.errors.push(e),e},gh.prototype.wrapResult=function(t){const e=this._reporterState;return e.options.partial?{result:this.isError(t)?null:t,errors:e.errors}:t},z(vh,Error),vh.prototype.rethrow=function(t){if(this.message=t+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,vh),!this.stack)try{throw new Error(this.message)}catch(hu){this.stack=hu.stack}return this};var yh={};const bh=mh.Reporter,Mh=ph.Buffer;function wh(t,e){bh.call(this,e),Mh.isBuffer(t)?(this.base=t,this.offset=0,this.length=t.length):this.error("Input not Buffer")}function _h(t,e){if(Array.isArray(t))this.length=0,this.value=t.map((function(t){return _h.isEncoderBuffer(t)||(t=new _h(t,e)),this.length+=t.length,t}),this);else if("number"==typeof t){if(!(0<=t&&t<=255))return e.error("non-byte EncoderBuffer value");this.value=t,this.length=1}else if("string"==typeof t)this.value=t,this.length=Mh.byteLength(t);else{if(!Mh.isBuffer(t))return e.error("Unsupported type: "+typeof t);this.value=t,this.length=t.length}}z(wh,bh),yh.DecoderBuffer=wh,wh.isDecoderBuffer=function(t){return t instanceof wh||"object"==typeof t&&Mh.isBuffer(t.base)&&"DecoderBuffer"===t.constructor.name&&"number"==typeof t.offset&&"number"==typeof t.length&&"function"==typeof t.save&&"function"==typeof t.restore&&"function"==typeof t.isEmpty&&"function"==typeof t.readUInt8&&"function"==typeof t.skip&&"function"==typeof t.raw},wh.prototype.save=function(){return{offset:this.offset,reporter:bh.prototype.save.call(this)}},wh.prototype.restore=function(t){const e=new wh(this.base);return e.offset=t.offset,e.length=this.offset,this.offset=t.offset,bh.prototype.restore.call(this,t.reporter),e},wh.prototype.isEmpty=function(){return this.offset===this.length},wh.prototype.readUInt8=function(t){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(t||"DecoderBuffer overrun")},wh.prototype.skip=function(t,e){if(!(this.offset+t<=this.length))return this.error(e||"DecoderBuffer overrun");const i=new wh(this.base);return i._reporterState=this._reporterState,i.offset=this.offset,i.length=this.offset+t,this.offset+=t,i},wh.prototype.raw=function(t){return this.base.slice(t?t.offset:this.offset,this.length)},yh.EncoderBuffer=_h,_h.isEncoderBuffer=function(t){return t instanceof _h||"object"==typeof t&&"EncoderBuffer"===t.constructor.name&&"number"==typeof t.length&&"function"==typeof t.join},_h.prototype.join=function(t,e){return t||(t=Mh.alloc(this.length)),e||(e=0),0===this.length||(Array.isArray(this.value)?this.value.forEach((function(i){i.join(t,e),e+=i.length})):("number"==typeof this.value?t[e]=this.value:"string"==typeof this.value?t.write(this.value,e):Mh.isBuffer(this.value)&&this.value.copy(t,e),e+=this.length)),t};const Sh=mh.Reporter,kh=yh.EncoderBuffer,Ah=yh.DecoderBuffer,Eh=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],Rh=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(Eh);function xh(t,e,i){const r={};this._baseState=r,r.name=i,r.enc=t,r.parent=e||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r.default=null,r.explicit=null,r.implicit=null,r.contains=null,r.parent||(r.children=[],this._wrap())}var Bh=xh;const Ih=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];xh.prototype.clone=function(){const t=this._baseState,e={};Ih.forEach((function(i){e[i]=t[i]}));const i=new this.constructor(e.parent);return i._baseState=e,i},xh.prototype._wrap=function(){const t=this._baseState;Rh.forEach((function(e){this[e]=function(){const i=new this.constructor(this);return t.children.push(i),i[e].apply(i,arguments)}}),this)},xh.prototype._init=function(t){const e=this._baseState;t.call(this),e.children=e.children.filter((function(t){return t._baseState.parent===this}),this)},xh.prototype._useArgs=function(t){const e=this._baseState,i=t.filter((function(t){return t instanceof this.constructor}),this);t=t.filter((function(t){return!(t instanceof this.constructor)}),this),0!==i.length&&(e.children=i,i.forEach((function(t){t._baseState.parent=this}),this)),0!==t.length&&(e.args=t,e.reverseArgs=t.map((function(t){if("object"!=typeof t||t.constructor!==Object)return t;const e={};return Object.keys(t).forEach((function(i){i==(0|i)&&(i|=0);const r=t[i];e[r]=i})),e})))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach((function(t){xh.prototype[t]=function(){const e=this._baseState;throw new Error(t+" not implemented for encoding: "+e.enc)}})),Eh.forEach((function(t){xh.prototype[t]=function(){const e=this._baseState,i=Array.prototype.slice.call(arguments);return e.tag=t,this._useArgs(i),this}})),xh.prototype.use=function(t){return this._baseState.use=t,this},xh.prototype.optional=function(){return this._baseState.optional=!0,this},xh.prototype.def=function(t){const e=this._baseState;return e.default=t,e.optional=!0,this},xh.prototype.explicit=function(t){return this._baseState.explicit=t,this},xh.prototype.implicit=function(t){return this._baseState.implicit=t,this},xh.prototype.obj=function(){const t=this._baseState,e=Array.prototype.slice.call(arguments);return t.obj=!0,0!==e.length&&this._useArgs(e),this},xh.prototype.key=function(t){return this._baseState.key=t,this},xh.prototype.any=function(){return this._baseState.any=!0,this},xh.prototype.choice=function(t){return this._baseState.choice=t,this._useArgs(Object.keys(t).map((function(e){return t[e]}))),this},xh.prototype.contains=function(t){return this._baseState.contains=t,this},xh.prototype._decode=function(t,e){const i=this._baseState;if(null===i.parent)return t.wrapResult(i.children[0]._decode(t,e));let r,n=i.default,s=!0,o=null;if(null!==i.key&&(o=t.enterKey(i.key)),i.optional){let r=null;if(null!==i.explicit?r=i.explicit:null!==i.implicit?r=i.implicit:null!==i.tag&&(r=i.tag),null!==r||i.any){if(s=this._peekTag(t,r,i.any),t.isError(s))return s}else{const r=t.save();try{null===i.choice?this._decodeGeneric(i.tag,t,e):this._decodeChoice(t,e),s=!0}catch(hu){s=!1}t.restore(r)}}if(i.obj&&s&&(r=t.enterObject()),s){if(null!==i.explicit){const e=this._decodeTag(t,i.explicit);if(t.isError(e))return e;t=e}const r=t.offset;if(null===i.use&&null===i.choice){let e;i.any&&(e=t.save());const r=this._decodeTag(t,null!==i.implicit?i.implicit:i.tag,i.any);if(t.isError(r))return r;i.any?n=t.raw(e):t=r}if(e&&e.track&&null!==i.tag&&e.track(t.path(),r,t.length,"tagged"),e&&e.track&&null!==i.tag&&e.track(t.path(),t.offset,t.length,"content"),i.any||(n=null===i.choice?this._decodeGeneric(i.tag,t,e):this._decodeChoice(t,e)),t.isError(n))return n;if(i.any||null!==i.choice||null===i.children||i.children.forEach((function(i){i._decode(t,e)})),i.contains&&("octstr"===i.tag||"bitstr"===i.tag)){const r=new Ah(n);n=this._getUse(i.contains,t._reporterState.obj)._decode(r,e)}}return i.obj&&s&&(n=t.leaveObject(r)),null===i.key||null===n&&!0!==s?null!==o&&t.exitKey(o):t.leaveKey(o,i.key,n),n},xh.prototype._decodeGeneric=function(t,e,i){const r=this._baseState;return"seq"===t||"set"===t?null:"seqof"===t||"setof"===t?this._decodeList(e,t,r.args[0],i):/str$/.test(t)?this._decodeStr(e,t,i):"objid"===t&&r.args?this._decodeObjid(e,r.args[0],r.args[1],i):"objid"===t?this._decodeObjid(e,null,null,i):"gentime"===t||"utctime"===t?this._decodeTime(e,t,i):"null_"===t?this._decodeNull(e,i):"bool"===t?this._decodeBool(e,i):"objDesc"===t?this._decodeStr(e,t,i):"int"===t||"enum"===t?this._decodeInt(e,r.args&&r.args[0],i):null!==r.use?this._getUse(r.use,e._reporterState.obj)._decode(e,i):e.error("unknown tag: "+t)},xh.prototype._getUse=function(t,e){const i=this._baseState;return i.useDecoder=this._use(t,e),i.useDecoder=i.useDecoder._baseState.children[0],i.implicit!==i.useDecoder._baseState.implicit&&(i.useDecoder=i.useDecoder.clone(),i.useDecoder._baseState.implicit=i.implicit),i.useDecoder},xh.prototype._decodeChoice=function(t,e){const i=this._baseState;let r=null,n=!1;return Object.keys(i.choice).some((function(s){const o=t.save(),h=i.choice[s];try{const i=h._decode(t,e);if(t.isError(i))return!1;r={type:s,value:i},n=!0}catch(hu){return t.restore(o),!1}return!0}),this),n?r:t.error("Choice not matched")},xh.prototype._createEncoderBuffer=function(t){return new kh(t,this.reporter)},xh.prototype._encode=function(t,e,i){const r=this._baseState;if(null!==r.default&&r.default===t)return;const n=this._encodeValue(t,e,i);return void 0===n||this._skipDefault(n,e,i)?void 0:n},xh.prototype._encodeValue=function(t,e,i){const r=this._baseState;if(null===r.parent)return r.children[0]._encode(t,e||new Sh);let n=null;if(this.reporter=e,r.optional&&void 0===t){if(null===r.default)return;t=r.default}let s=null,o=!1;if(r.any)n=this._createEncoderBuffer(t);else if(r.choice)n=this._encodeChoice(t,e);else if(r.contains)s=this._getUse(r.contains,i)._encode(t,e),o=!0;else if(r.children)s=r.children.map((function(i){if("null_"===i._baseState.tag)return i._encode(null,e,t);if(null===i._baseState.key)return e.error("Child should have a key");const r=e.enterKey(i._baseState.key);if("object"!=typeof t)return e.error("Child expected, but input is not object");const n=i._encode(t[i._baseState.key],e,t);return e.leaveKey(r),n}),this).filter((function(t){return t})),s=this._createEncoderBuffer(s);else if("seqof"===r.tag||"setof"===r.tag){if(!r.args||1!==r.args.length)return e.error("Too many args for : "+r.tag);if(!Array.isArray(t))return e.error("seqof/setof, but data is not Array");const i=this.clone();i._baseState.implicit=null,s=this._createEncoderBuffer(t.map((function(i){const r=this._baseState;return this._getUse(r.args[0],t)._encode(i,e)}),i))}else null!==r.use?n=this._getUse(r.use,i)._encode(t,e):(s=this._encodePrimitive(r.tag,t),o=!0);if(!r.any&&null===r.choice){const t=null!==r.implicit?r.implicit:r.tag,i=null===r.implicit?"universal":"context";null===t?null===r.use&&e.error("Tag could be omitted only for .use()"):null===r.use&&(n=this._encodeComposite(t,o,i,s))}return null!==r.explicit&&(n=this._encodeComposite(r.explicit,!1,"context",n)),n},xh.prototype._encodeChoice=function(t,e){return this._baseState.choice[t.type]._encode(t.value,e)},xh.prototype._encodePrimitive=function(t,e){const i=this._baseState;if(/str$/.test(t))return this._encodeStr(e,t);if("objid"===t&&i.args)return this._encodeObjid(e,i.reverseArgs[0],i.args[1]);if("objid"===t)return this._encodeObjid(e,null,null);if("gentime"===t||"utctime"===t)return this._encodeTime(e,t);if("null_"===t)return this._encodeNull();if("int"===t||"enum"===t)return this._encodeInt(e,i.args&&i.reverseArgs[0]);if("bool"===t)return this._encodeBool(e);if("objDesc"===t)return this._encodeStr(e,t);throw new Error("Unsupported tag: "+t)},xh.prototype._isNumstr=function(t){return/^[0-9 ]*$/.test(t)},xh.prototype._isPrintstr=function(t){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(t)};var Ph={};function Th(t){const e={};return Object.keys(t).forEach((function(i){(0|i)==i&&(i|=0);const r=t[i];e[r]=i})),e}Ph.tagClass={0:"universal",1:"application",2:"context",3:"private"},Ph.tagClassByName=Th(Ph.tagClass),Ph.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},Ph.tagByName=Th(Ph.tag);var qh={};const Lh=ph.Buffer;function jh(t){this.enc="der",this.name=t.name,this.entity=t,this.tree=new Oh,this.tree._init(t.body)}function Oh(t){Bh.call(this,"der",t)}function Nh(t){return t<10?"0"+t:t}qh=jh,jh.prototype.encode=function(t,e){return this.tree._encode(t,e).join()},z(Oh,Bh),Oh.prototype._encodeComposite=function(t,e,i,r){const n=function(t,e,i,r){let n;if("seqof"===t?t="seq":"setof"===t&&(t="set"),Ph.tagByName.hasOwnProperty(t))n=Ph.tagByName[t];else{if("number"!=typeof t||(0|t)!==t)return r.error("Unknown tag: "+t);n=t}return n>=31?r.error("Multi-octet tag encoding unsupported"):(e||(n|=32),n|Ph.tagClassByName[i||"universal"]<<6)}(t,e,i,this.reporter);if(r.length<128){const t=Lh.alloc(2);return t[0]=n,t[1]=r.length,this._createEncoderBuffer([t,r])}let s=1;for(let h=r.length;h>=256;h>>=8)s++;const o=Lh.alloc(2+s);o[0]=n,o[1]=128|s;for(let h=1+s,a=r.length;a>0;h--,a>>=8)o[h]=255&a;return this._createEncoderBuffer([o,r])},Oh.prototype._encodeStr=function(t,e){if("bitstr"===e)return this._createEncoderBuffer([0|t.unused,t.data]);if("bmpstr"===e){const e=Lh.alloc(2*t.length);for(let i=0;i=40)return this.reporter.error("Second objid identifier OOB");t.splice(0,2,40*t[0]+t[1])}let r=0;for(let o=0;o=128;e>>=7)r++}const n=Lh.alloc(r);let s=n.length-1;for(let o=t.length-1;o>=0;o--){let e=t[o];for(n[s--]=127&e;(e>>=7)>0;)n[s--]=128|127&e}return this._createEncoderBuffer(n)},Oh.prototype._encodeTime=function(t,e){let i;const r=new Date(t);return"gentime"===e?i=[Nh(r.getUTCFullYear()),Nh(r.getUTCMonth()+1),Nh(r.getUTCDate()),Nh(r.getUTCHours()),Nh(r.getUTCMinutes()),Nh(r.getUTCSeconds()),"Z"].join(""):"utctime"===e?i=[Nh(r.getUTCFullYear()%100),Nh(r.getUTCMonth()+1),Nh(r.getUTCDate()),Nh(r.getUTCHours()),Nh(r.getUTCMinutes()),Nh(r.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+e+" time is not supported yet"),this._encodeStr(i,"octstr")},Oh.prototype._encodeNull=function(){return this._createEncoderBuffer("")},Oh.prototype._encodeInt=function(t,e){if("string"==typeof t){if(!e)return this.reporter.error("String int or enum given, but no values map");if(!e.hasOwnProperty(t))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(t));t=e[t]}if("number"!=typeof t&&!Lh.isBuffer(t)){const e=t.toArray();!t.sign&&128&e[0]&&e.unshift(0),t=Lh.from(e)}if(Lh.isBuffer(t)){let e=t.length;0===t.length&&e++;const i=Lh.alloc(e);return t.copy(i),0===t.length&&(i[0]=0),this._createEncoderBuffer(i)}if(t<128)return this._createEncoderBuffer(t);if(t<256)return this._createEncoderBuffer([0,t]);let i=1;for(let n=t;n>=256;n>>=8)i++;const r=new Array(i);for(let n=r.length-1;n>=0;n--)r[n]=255&t,t>>=8;return 128&r[0]&&r.unshift(0),this._createEncoderBuffer(Lh.from(r))},Oh.prototype._encodeBool=function(t){return this._createEncoderBuffer(t?255:0)},Oh.prototype._use=function(t,e){return"function"==typeof t&&(t=t(e)),t._getEncoder("der").tree},Oh.prototype._skipDefault=function(t,e,i){const r=this._baseState;let n;if(null===r.default)return!1;const s=t.join();if(void 0===r.defaultBuffer&&(r.defaultBuffer=this._encodeValue(r.default,e,i).join()),s.length!==r.defaultBuffer.length)return!1;for(n=0;n>6],n=0==(32&i);if(31==(31&i)){let r=i;for(i=0;128==(128&r);){if(r=t.readUInt8(e),t.isError(r))return r;i<<=7,i|=127&r}}else i&=31;return{cls:r,primitive:n,tag:i,tagStr:Ph.tag[i]}}function Vh(t,e,i){let r=t.readUInt8(i);if(t.isError(r))return r;if(!e&&128===r)return null;if(0==(128&r))return r;const n=127&r;if(n>4)return t.error("length octect is too long");r=0;for(let s=0;s0&&i.ishrn(r),i}function Da(t,e,i){var r,n;do{for(r=Ca.alloc(0);8*r.length=e)throw new Error("invalid sig")}var Va=M.Buffer;function Ha(t){$t.Writable.call(this);var e=Ti[t];if(!e)throw new Error("Unknown message digest");this._hashType=e.hash,this._hash=wi(e.hash),this._tag=e.id,this._signType=e.sign}function Ga(t){$t.Writable.call(this);var e=Ti[t];if(!e)throw new Error("Unknown message digest");this._hash=wi(e.hash),this._tag=e.id,this._signType=e.sign}Object.keys(Ti).forEach((function(t){Ti[t].id=Va.from(Ti[t].id,"hex"),Ti[t.toLowerCase()]=Ti[t]})),z(Ha,$t.Writable),Ha.prototype._write=function(t,e,i){this._hash.update(t),i()},Ha.prototype.update=function(t,e){return"string"==typeof t&&(t=Va.from(t,e)),this._hash.update(t),this},Ha.prototype.sign=function(t,e){this.end();var i=this._hash.digest(),r=Oa(i,t,this._hashType,this._signType,this._tag);return e?r.toString(e):r},z(Ga,$t.Writable),Ga.prototype._write=function(t,e,i){this._hash.update(t),i()},Ga.prototype.update=function(t,e){return"string"==typeof t&&(t=Va.from(t,e)),this._hash.update(t),this},Ga.prototype.verify=function(t,e,i){return"string"==typeof e&&(e=Va.from(e,i)),this.end(),function(t,e,i,r,n){var s=qa(i);if("ec"===s.type){if("ecdsa"!==r&&"ecdsa/rsa"!==r)throw new Error("wrong public key type");return function(t,e,i){var r=Na[i.data.algorithm.curve.join(".")];if(!r)throw new Error("unknown curve "+i.data.algorithm.curve.join("."));var n=new Za(r),s=i.data.subjectPrivateKey.data;return n.verify(e,t,s)}(t,e,s)}if("dsa"===s.type){if("dsa"!==r)throw new Error("wrong public key type");return function(t,e,i){var r=i.data.p,n=i.data.q,s=i.data.g,o=i.data.pub_key,h=qa.signature.decode(t,"der"),a=h.s,u=h.r;Fa(a,n),Fa(u,n);var f=Ln.mont(r),l=a.invm(n);return 0===s.toRed(f).redPow(new Ln(e).mul(l).mod(n)).fromRed().mul(o.toRed(f).redPow(u.mul(l).mod(n)).fromRed()).mod(r).mod(n).cmp(u)}(t,e,s)}if("rsa"!==r&&"ecdsa/rsa"!==r)throw new Error("wrong public key type");e=Wa.concat([n,e]);for(var o=s.modulus.byteLength(),h=[1],a=0;e.length+h.length+2=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return r}function o(t,e,i,r){for(var n=0,s=Math.min(t.length,i),o=e;o=49?h-49+10:h>=17?h-17+10:h}return n}r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,e){return t.cmp(e)>0?t:e},r.min=function(t,e){return t.cmp(e)<0?t:e},r.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===e?this._parseHex(t,r):this._parseBase(t,e,r),"-"===t[0]&&(this.negative=1),this.strip(),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initArray=function(t,e,i){if(t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r=0;r-=3)s=t[r]|t[r-1]<<8|t[r-2]<<16,this.words[n]|=s<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===i)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this.strip()},r.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=6)n=s(t,i,i+6),this.words[r]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,r++);i+6!==e&&(n=s(t,e,i+6),this.words[r]|=n<>>26-o&4194303),this.strip()},r.prototype._parseBase=function(t,e,i){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=e)r++;r--,n=n/e|0;for(var s=t.length-i,h=s%r,a=Math.min(s,s-h)+i,u=0,f=i;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},r.prototype.inspect=function(){return(this.red?""};var h=["","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],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function l(t,e,i){i.negative=e.negative^t.negative;var r=t.length+e.length|0;i.length=r,r=r-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,h=67108863&o,a=o/67108864|0;i.words[0]=h;for(var u=1;u>>26,l=67108863&a,c=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=c;d++){var p=u-d|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[d])+l)/67108864|0,l=67108863&o}i.words[u]=0|l,a=0|f}return 0!==a?i.words[u]=0|a:i.length--,i.strip()}r.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var r=0,n=0,s=0;s>>24-r&16777215)||s!==this.length-1?h[6-a.length]+a+i:a+i,(r+=2)>=26&&(r-=26,s--)}for(0!==n&&(i=n.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var l=u[t],c=f[t];i="";var d=this.clone();for(d.negative=0;!d.isZero();){var p=d.modn(c).toString(t);i=(d=d.idivn(c)).isZero()?p+i:h[l-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length,0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16)},r.prototype.toBuffer=function(t,e){return this.toArrayLike(n,t,e)},r.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},r.prototype.toArrayLike=function(t,e,i){var r=this.byteLength(),n=i||Math.max(1,r);this.strip();var s,o,h="le"===e,a=new t(n),u=this.clone();if(h){for(o=0;!u.isZero();o++)s=u.andln(255),u.iushrn(8),a[o]=s;for(;o=4096&&(i+=13,e>>>=13),e>=64&&(i+=7,e>>>=7),e>=8&&(i+=4,e>>>=4),e>=2&&(i+=2,e>>>=2),i+e},r.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,i=0;return 0==(8191&e)&&(i+=13,e>>>=13),0==(127&e)&&(i+=7,e>>>=7),0==(15&e)&&(i+=4,e>>>=4),0==(3&e)&&(i+=2,e>>>=2),0==(1&e)&&i++,i},r.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var i=0;it.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var e,i;this.length>t.length?(e=this,i=t):(e=t,i=this);for(var r=0;rt.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-i),this.strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,e){var i=t/26|0,r=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(i=this,r=t):(i=t,r=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i,r,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(i=this,r=t):(i=t,r=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,d=0|o[1],p=8191&d,m=d>>>13,g=0|o[2],v=8191&g,y=g>>>13,b=0|o[3],M=8191&b,w=b>>>13,_=0|o[4],S=8191&_,k=_>>>13,A=0|o[5],E=8191&A,R=A>>>13,x=0|o[6],B=8191&x,I=x>>>13,P=0|o[7],T=8191&P,q=P>>>13,L=0|o[8],j=8191&L,O=L>>>13,N=0|o[9],C=8191&N,$=N>>>13,U=0|h[0],z=8191&U,D=U>>>13,K=0|h[1],W=8191&K,Z=K>>>13,F=0|h[2],V=8191&F,H=F>>>13,G=0|h[3],X=8191&G,Y=G>>>13,J=0|h[4],Q=8191&J,tt=J>>>13,et=0|h[5],it=8191&et,rt=et>>>13,nt=0|h[6],st=8191&nt,ot=nt>>>13,ht=0|h[7],at=8191&ht,ut=ht>>>13,ft=0|h[8],lt=8191&ft,ct=ft>>>13,dt=0|h[9],pt=8191&dt,mt=dt>>>13;i.negative=t.negative^e.negative,i.length=19;var gt=(u+(r=Math.imul(l,z))|0)+((8191&(n=(n=Math.imul(l,D))+Math.imul(c,z)|0))<<13)|0;u=((s=Math.imul(c,D))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(p,z),n=(n=Math.imul(p,D))+Math.imul(m,z)|0,s=Math.imul(m,D);var vt=(u+(r=r+Math.imul(l,W)|0)|0)+((8191&(n=(n=n+Math.imul(l,Z)|0)+Math.imul(c,W)|0))<<13)|0;u=((s=s+Math.imul(c,Z)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(v,z),n=(n=Math.imul(v,D))+Math.imul(y,z)|0,s=Math.imul(y,D),r=r+Math.imul(p,W)|0,n=(n=n+Math.imul(p,Z)|0)+Math.imul(m,W)|0,s=s+Math.imul(m,Z)|0;var yt=(u+(r=r+Math.imul(l,V)|0)|0)+((8191&(n=(n=n+Math.imul(l,H)|0)+Math.imul(c,V)|0))<<13)|0;u=((s=s+Math.imul(c,H)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(M,z),n=(n=Math.imul(M,D))+Math.imul(w,z)|0,s=Math.imul(w,D),r=r+Math.imul(v,W)|0,n=(n=n+Math.imul(v,Z)|0)+Math.imul(y,W)|0,s=s+Math.imul(y,Z)|0,r=r+Math.imul(p,V)|0,n=(n=n+Math.imul(p,H)|0)+Math.imul(m,V)|0,s=s+Math.imul(m,H)|0;var bt=(u+(r=r+Math.imul(l,X)|0)|0)+((8191&(n=(n=n+Math.imul(l,Y)|0)+Math.imul(c,X)|0))<<13)|0;u=((s=s+Math.imul(c,Y)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(S,z),n=(n=Math.imul(S,D))+Math.imul(k,z)|0,s=Math.imul(k,D),r=r+Math.imul(M,W)|0,n=(n=n+Math.imul(M,Z)|0)+Math.imul(w,W)|0,s=s+Math.imul(w,Z)|0,r=r+Math.imul(v,V)|0,n=(n=n+Math.imul(v,H)|0)+Math.imul(y,V)|0,s=s+Math.imul(y,H)|0,r=r+Math.imul(p,X)|0,n=(n=n+Math.imul(p,Y)|0)+Math.imul(m,X)|0,s=s+Math.imul(m,Y)|0;var Mt=(u+(r=r+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(c,Q)|0))<<13)|0;u=((s=s+Math.imul(c,tt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(E,z),n=(n=Math.imul(E,D))+Math.imul(R,z)|0,s=Math.imul(R,D),r=r+Math.imul(S,W)|0,n=(n=n+Math.imul(S,Z)|0)+Math.imul(k,W)|0,s=s+Math.imul(k,Z)|0,r=r+Math.imul(M,V)|0,n=(n=n+Math.imul(M,H)|0)+Math.imul(w,V)|0,s=s+Math.imul(w,H)|0,r=r+Math.imul(v,X)|0,n=(n=n+Math.imul(v,Y)|0)+Math.imul(y,X)|0,s=s+Math.imul(y,Y)|0,r=r+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var wt=(u+(r=r+Math.imul(l,it)|0)|0)+((8191&(n=(n=n+Math.imul(l,rt)|0)+Math.imul(c,it)|0))<<13)|0;u=((s=s+Math.imul(c,rt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(B,z),n=(n=Math.imul(B,D))+Math.imul(I,z)|0,s=Math.imul(I,D),r=r+Math.imul(E,W)|0,n=(n=n+Math.imul(E,Z)|0)+Math.imul(R,W)|0,s=s+Math.imul(R,Z)|0,r=r+Math.imul(S,V)|0,n=(n=n+Math.imul(S,H)|0)+Math.imul(k,V)|0,s=s+Math.imul(k,H)|0,r=r+Math.imul(M,X)|0,n=(n=n+Math.imul(M,Y)|0)+Math.imul(w,X)|0,s=s+Math.imul(w,Y)|0,r=r+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,tt)|0)+Math.imul(y,Q)|0,s=s+Math.imul(y,tt)|0,r=r+Math.imul(p,it)|0,n=(n=n+Math.imul(p,rt)|0)+Math.imul(m,it)|0,s=s+Math.imul(m,rt)|0;var _t=(u+(r=r+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(c,st)|0))<<13)|0;u=((s=s+Math.imul(c,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(T,z),n=(n=Math.imul(T,D))+Math.imul(q,z)|0,s=Math.imul(q,D),r=r+Math.imul(B,W)|0,n=(n=n+Math.imul(B,Z)|0)+Math.imul(I,W)|0,s=s+Math.imul(I,Z)|0,r=r+Math.imul(E,V)|0,n=(n=n+Math.imul(E,H)|0)+Math.imul(R,V)|0,s=s+Math.imul(R,H)|0,r=r+Math.imul(S,X)|0,n=(n=n+Math.imul(S,Y)|0)+Math.imul(k,X)|0,s=s+Math.imul(k,Y)|0,r=r+Math.imul(M,Q)|0,n=(n=n+Math.imul(M,tt)|0)+Math.imul(w,Q)|0,s=s+Math.imul(w,tt)|0,r=r+Math.imul(v,it)|0,n=(n=n+Math.imul(v,rt)|0)+Math.imul(y,it)|0,s=s+Math.imul(y,rt)|0,r=r+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(r=r+Math.imul(l,at)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(c,at)|0))<<13)|0;u=((s=s+Math.imul(c,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(j,z),n=(n=Math.imul(j,D))+Math.imul(O,z)|0,s=Math.imul(O,D),r=r+Math.imul(T,W)|0,n=(n=n+Math.imul(T,Z)|0)+Math.imul(q,W)|0,s=s+Math.imul(q,Z)|0,r=r+Math.imul(B,V)|0,n=(n=n+Math.imul(B,H)|0)+Math.imul(I,V)|0,s=s+Math.imul(I,H)|0,r=r+Math.imul(E,X)|0,n=(n=n+Math.imul(E,Y)|0)+Math.imul(R,X)|0,s=s+Math.imul(R,Y)|0,r=r+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(k,Q)|0,s=s+Math.imul(k,tt)|0,r=r+Math.imul(M,it)|0,n=(n=n+Math.imul(M,rt)|0)+Math.imul(w,it)|0,s=s+Math.imul(w,rt)|0,r=r+Math.imul(v,st)|0,n=(n=n+Math.imul(v,ot)|0)+Math.imul(y,st)|0,s=s+Math.imul(y,ot)|0,r=r+Math.imul(p,at)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,at)|0,s=s+Math.imul(m,ut)|0;var kt=(u+(r=r+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,ct)|0)+Math.imul(c,lt)|0))<<13)|0;u=((s=s+Math.imul(c,ct)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(C,z),n=(n=Math.imul(C,D))+Math.imul($,z)|0,s=Math.imul($,D),r=r+Math.imul(j,W)|0,n=(n=n+Math.imul(j,Z)|0)+Math.imul(O,W)|0,s=s+Math.imul(O,Z)|0,r=r+Math.imul(T,V)|0,n=(n=n+Math.imul(T,H)|0)+Math.imul(q,V)|0,s=s+Math.imul(q,H)|0,r=r+Math.imul(B,X)|0,n=(n=n+Math.imul(B,Y)|0)+Math.imul(I,X)|0,s=s+Math.imul(I,Y)|0,r=r+Math.imul(E,Q)|0,n=(n=n+Math.imul(E,tt)|0)+Math.imul(R,Q)|0,s=s+Math.imul(R,tt)|0,r=r+Math.imul(S,it)|0,n=(n=n+Math.imul(S,rt)|0)+Math.imul(k,it)|0,s=s+Math.imul(k,rt)|0,r=r+Math.imul(M,st)|0,n=(n=n+Math.imul(M,ot)|0)+Math.imul(w,st)|0,s=s+Math.imul(w,ot)|0,r=r+Math.imul(v,at)|0,n=(n=n+Math.imul(v,ut)|0)+Math.imul(y,at)|0,s=s+Math.imul(y,ut)|0,r=r+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,ct)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,ct)|0;var At=(u+(r=r+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(c,pt)|0))<<13)|0;u=((s=s+Math.imul(c,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(C,W),n=(n=Math.imul(C,Z))+Math.imul($,W)|0,s=Math.imul($,Z),r=r+Math.imul(j,V)|0,n=(n=n+Math.imul(j,H)|0)+Math.imul(O,V)|0,s=s+Math.imul(O,H)|0,r=r+Math.imul(T,X)|0,n=(n=n+Math.imul(T,Y)|0)+Math.imul(q,X)|0,s=s+Math.imul(q,Y)|0,r=r+Math.imul(B,Q)|0,n=(n=n+Math.imul(B,tt)|0)+Math.imul(I,Q)|0,s=s+Math.imul(I,tt)|0,r=r+Math.imul(E,it)|0,n=(n=n+Math.imul(E,rt)|0)+Math.imul(R,it)|0,s=s+Math.imul(R,rt)|0,r=r+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(k,st)|0,s=s+Math.imul(k,ot)|0,r=r+Math.imul(M,at)|0,n=(n=n+Math.imul(M,ut)|0)+Math.imul(w,at)|0,s=s+Math.imul(w,ut)|0,r=r+Math.imul(v,lt)|0,n=(n=n+Math.imul(v,ct)|0)+Math.imul(y,lt)|0,s=s+Math.imul(y,ct)|0;var Et=(u+(r=r+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(C,V),n=(n=Math.imul(C,H))+Math.imul($,V)|0,s=Math.imul($,H),r=r+Math.imul(j,X)|0,n=(n=n+Math.imul(j,Y)|0)+Math.imul(O,X)|0,s=s+Math.imul(O,Y)|0,r=r+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(q,Q)|0,s=s+Math.imul(q,tt)|0,r=r+Math.imul(B,it)|0,n=(n=n+Math.imul(B,rt)|0)+Math.imul(I,it)|0,s=s+Math.imul(I,rt)|0,r=r+Math.imul(E,st)|0,n=(n=n+Math.imul(E,ot)|0)+Math.imul(R,st)|0,s=s+Math.imul(R,ot)|0,r=r+Math.imul(S,at)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(k,at)|0,s=s+Math.imul(k,ut)|0,r=r+Math.imul(M,lt)|0,n=(n=n+Math.imul(M,ct)|0)+Math.imul(w,lt)|0,s=s+Math.imul(w,ct)|0;var Rt=(u+(r=r+Math.imul(v,pt)|0)|0)+((8191&(n=(n=n+Math.imul(v,mt)|0)+Math.imul(y,pt)|0))<<13)|0;u=((s=s+Math.imul(y,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(C,X),n=(n=Math.imul(C,Y))+Math.imul($,X)|0,s=Math.imul($,Y),r=r+Math.imul(j,Q)|0,n=(n=n+Math.imul(j,tt)|0)+Math.imul(O,Q)|0,s=s+Math.imul(O,tt)|0,r=r+Math.imul(T,it)|0,n=(n=n+Math.imul(T,rt)|0)+Math.imul(q,it)|0,s=s+Math.imul(q,rt)|0,r=r+Math.imul(B,st)|0,n=(n=n+Math.imul(B,ot)|0)+Math.imul(I,st)|0,s=s+Math.imul(I,ot)|0,r=r+Math.imul(E,at)|0,n=(n=n+Math.imul(E,ut)|0)+Math.imul(R,at)|0,s=s+Math.imul(R,ut)|0,r=r+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,ct)|0)+Math.imul(k,lt)|0,s=s+Math.imul(k,ct)|0;var xt=(u+(r=r+Math.imul(M,pt)|0)|0)+((8191&(n=(n=n+Math.imul(M,mt)|0)+Math.imul(w,pt)|0))<<13)|0;u=((s=s+Math.imul(w,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(C,Q),n=(n=Math.imul(C,tt))+Math.imul($,Q)|0,s=Math.imul($,tt),r=r+Math.imul(j,it)|0,n=(n=n+Math.imul(j,rt)|0)+Math.imul(O,it)|0,s=s+Math.imul(O,rt)|0,r=r+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(q,st)|0,s=s+Math.imul(q,ot)|0,r=r+Math.imul(B,at)|0,n=(n=n+Math.imul(B,ut)|0)+Math.imul(I,at)|0,s=s+Math.imul(I,ut)|0,r=r+Math.imul(E,lt)|0,n=(n=n+Math.imul(E,ct)|0)+Math.imul(R,lt)|0,s=s+Math.imul(R,ct)|0;var Bt=(u+(r=r+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(k,pt)|0))<<13)|0;u=((s=s+Math.imul(k,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(C,it),n=(n=Math.imul(C,rt))+Math.imul($,it)|0,s=Math.imul($,rt),r=r+Math.imul(j,st)|0,n=(n=n+Math.imul(j,ot)|0)+Math.imul(O,st)|0,s=s+Math.imul(O,ot)|0,r=r+Math.imul(T,at)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(q,at)|0,s=s+Math.imul(q,ut)|0,r=r+Math.imul(B,lt)|0,n=(n=n+Math.imul(B,ct)|0)+Math.imul(I,lt)|0,s=s+Math.imul(I,ct)|0;var It=(u+(r=r+Math.imul(E,pt)|0)|0)+((8191&(n=(n=n+Math.imul(E,mt)|0)+Math.imul(R,pt)|0))<<13)|0;u=((s=s+Math.imul(R,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(C,st),n=(n=Math.imul(C,ot))+Math.imul($,st)|0,s=Math.imul($,ot),r=r+Math.imul(j,at)|0,n=(n=n+Math.imul(j,ut)|0)+Math.imul(O,at)|0,s=s+Math.imul(O,ut)|0,r=r+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,ct)|0)+Math.imul(q,lt)|0,s=s+Math.imul(q,ct)|0;var Pt=(u+(r=r+Math.imul(B,pt)|0)|0)+((8191&(n=(n=n+Math.imul(B,mt)|0)+Math.imul(I,pt)|0))<<13)|0;u=((s=s+Math.imul(I,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(C,at),n=(n=Math.imul(C,ut))+Math.imul($,at)|0,s=Math.imul($,ut),r=r+Math.imul(j,lt)|0,n=(n=n+Math.imul(j,ct)|0)+Math.imul(O,lt)|0,s=s+Math.imul(O,ct)|0;var Tt=(u+(r=r+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(q,pt)|0))<<13)|0;u=((s=s+Math.imul(q,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(C,lt),n=(n=Math.imul(C,ct))+Math.imul($,lt)|0,s=Math.imul($,ct);var qt=(u+(r=r+Math.imul(j,pt)|0)|0)+((8191&(n=(n=n+Math.imul(j,mt)|0)+Math.imul(O,pt)|0))<<13)|0;u=((s=s+Math.imul(O,mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863;var Lt=(u+(r=Math.imul(C,pt))|0)+((8191&(n=(n=Math.imul(C,mt))+Math.imul($,pt)|0))<<13)|0;return u=((s=Math.imul($,mt))+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,a[0]=gt,a[1]=vt,a[2]=yt,a[3]=bt,a[4]=Mt,a[5]=wt,a[6]=_t,a[7]=St,a[8]=kt,a[9]=At,a[10]=Et,a[11]=Rt,a[12]=xt,a[13]=Bt,a[14]=It,a[15]=Pt,a[16]=Tt,a[17]=qt,a[18]=Lt,0!==u&&(a[19]=u,i.length++),i};function d(t,e,i){return(new p).mulp(t,e,i)}function p(t,e){this.x=t,this.y=e}Math.imul||(c=l),r.prototype.mulTo=function(t,e){var i=this.length+t.length;return 10===this.length&&10===t.length?c(this,t,e):i<63?l(this,t,e):i<1024?function(t,e,i){i.negative=e.negative^t.negative,i.length=t.length+e.length;for(var r=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}i.words[s]=h,r=o,o=n}return 0!==r?i.words[s]=r:i.length--,i.strip()}(this,t,e):d(this,t,e)},p.prototype.makeRBT=function(t){for(var e=new Array(t),i=r.prototype._countBits(t)-1,n=0;n>=1;return r},p.prototype.permute=function(t,e,i,r,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*s+1]=8191&n,n>>>=13;for(s=2*e;s>=26,e+=r/67108864|0,e+=n>>>26,this.words[i]=67108863&n}return 0!==e&&(this.words[i]=e,this.length++),this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),i=0;i>>n}return e}(t);if(0===e.length)return new r(1);for(var i=this,n=0;n>>26-i<<26-i;if(0!==i){var s=0;for(e=0;e>>26-i}s&&(this.words[e]=s,this.length++)}if(0!==r){for(e=this.length-1;e>=0;e--)this.words[e+r]=this.words[e];for(e=0;e>>n<s)for(this.length-=s,a=0;a=0&&(0!==u||a>=r);a--){var f=0|this.words[a];this.words[a]=u<<26-n|f>>>n,u=f&o}return h&&0!==u&&(h.words[h.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},r.prototype.ishrn=function(t,e,i){return this.iushrn(t,e,i)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){var e=t%26,i=(t-e)/26,r=1<>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},r.prototype.isubn=function(t){if(t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[r+i]=67108863&n}for(;r>26,this.words[r+i]=67108863&n;if(0===o)return this.strip();for(o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},r.prototype._wordDiv=function(t,e){var i=(this.length,t.length),n=this.clone(),s=t,o=0|s.words[s.length-1];0!=(i=26-this._countBits(o))&&(s=s.ushln(i),n.iushln(i),o=0|s.words[s.length-1]);var h,a=n.length-s.length;if("mod"!==e){(h=new r(null)).length=a+1,h.words=new Array(h.length);for(var u=0;u=0;l--){var c=67108864*(0|n.words[s.length+l])+(0|n.words[s.length+l-1]);for(c=Math.min(c/o|0,67108863),n._ishlnsubmul(s,c,l);0!==n.negative;)c--,n.negative=0,n._ishlnsubmul(s,1,l),n.isZero()||(n.negative^=1);h&&(h.words[l]=c)}return h&&h.strip(),n.strip(),"div"!==e&&0!==i&&n.iushrn(i),{div:h||null,mod:n}},r.prototype.divmod=function(t,e,i){return this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),"mod"!==e&&(n=o.div.neg()),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),e),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new r(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var i=0!==e.div.negative?e.mod.isub(t):e.mod,r=t.ushrn(1),n=t.andln(1),s=i.cmp(r);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},r.prototype.modn=function(t){for(var e=(1<<26)%t,i=0,r=this.length-1;r>=0;r--)i=(e*i+(0|this.words[r]))%t;return i},r.prototype.idivn=function(t){for(var e=0,i=this.length-1;i>=0;i--){var r=(0|this.words[i])+67108864*e;this.words[i]=r/t|0,e=r%t}return this.strip()},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new r(1),s=new r(0),o=new r(0),h=new r(1),a=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++a;for(var u=i.clone(),f=e.clone();!e.isZero();){for(var l=0,c=1;0==(e.words[0]&c)&&l<26;++l,c<<=1);if(l>0)for(e.iushrn(l);l-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(u),s.isub(f)),n.iushrn(1),s.iushrn(1);for(var d=0,p=1;0==(i.words[0]&p)&&d<26;++d,p<<=1);if(d>0)for(i.iushrn(d);d-- >0;)(o.isOdd()||h.isOdd())&&(o.iadd(u),h.isub(f)),o.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),n.isub(o),s.isub(h)):(i.isub(e),o.isub(n),h.isub(s))}return{a:o,b:h,gcd:i.iushln(a)}},r.prototype._invmp=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new r(1),o=new r(0),h=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var a=0,u=1;0==(e.words[0]&u)&&a<26;++a,u<<=1);if(a>0)for(e.iushrn(a);a-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);for(var f=0,l=1;0==(i.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(i.iushrn(f);f-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o)):(i.isub(e),o.isub(s))}return(n=0===e.cmpn(1)?s:o).cmpn(0)<0&&n.iadd(t),n},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),i=t.clone();e.negative=0,i.negative=0;for(var r=0;e.isEven()&&i.isEven();r++)e.iushrn(1),i.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;i.isEven();)i.iushrn(1);var n=e.cmp(i);if(n<0){var s=e;e=i,i=s}else if(0===n||0===i.cmpn(1))break;e.isub(i)}return i.iushln(r)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){var e=t%26,i=(t-e)/26,r=1<>>26,o&=67108863,this.words[s]=o}return 0!==n&&(this.words[s]=n,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t);var r=0|this.words[0];e=r===t?0:rt.length)return 1;if(this.length=0;i--){var r=0|this.words[i],n=0|t.words[i];if(r!==n){rn&&(e=1);break}}return e},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new w(t)},r.prototype.toRed=function(t){return t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return this._forceRed(t)},r.prototype.redAdd=function(t){return this.red.add(this,t)},r.prototype.redIAdd=function(t){return this.red.iadd(this,t)},r.prototype.redSub=function(t){return this.red.sub(this,t)},r.prototype.redISub=function(t){return this.red.isub(this,t)},r.prototype.redShl=function(t){return this.red.shl(this,t)},r.prototype.redMul=function(t){return this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return this.red._verify1(this),this.red.pow(this,t)};var m={k256:null,p224:null,p192:null,p25519:null};function g(t,e){this.name=t,this.p=new r(e,16),this.n=this.p.bitLength(),this.k=new r(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){g.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function y(){g.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){g.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function M(){g.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function w(t){if("string"==typeof t){var e=r._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function _(t){w.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}g.prototype._tmp=function(){var t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},g.prototype.ireduce=function(t){var e,i=t;do{this.split(i,this.tmp),e=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(e>this.n);var r=e0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},g.prototype.split=function(t,e){t.iushrn(this.n,0,e)},g.prototype.imulK=function(t){return t.imul(this.k)},i(v,g),v.prototype.split=function(t,e){for(var i=Math.min(t.length,9),r=0;r>>22,n=s}n>>>=22,t.words[r-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,i=0;i>>=26,t.words[i]=n,e=r}return 0!==e&&(t.words[t.length++]=e),t},r._prime=function(t){if(m[t])return m[t];var e;if("k256"===t)e=new v;else if("p224"===t)e=new y;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new M}return m[t]=e,e},w.prototype._verify1=function(t){},w.prototype._verify2=function(t,e){},w.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},w.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},w.prototype.add=function(t,e){this._verify2(t,e);var i=t.add(e);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},w.prototype.iadd=function(t,e){this._verify2(t,e);var i=t.iadd(e);return i.cmp(this.m)>=0&&i.isub(this.m),i},w.prototype.sub=function(t,e){this._verify2(t,e);var i=t.sub(e);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},w.prototype.isub=function(t,e){this._verify2(t,e);var i=t.isub(e);return i.cmpn(0)<0&&i.iadd(this.m),i},w.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},w.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},w.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},w.prototype.isqr=function(t){return this.imul(t,t.clone())},w.prototype.sqr=function(t){return this.mul(t,t)},w.prototype.sqrt=function(t){if(t.isZero())return t.clone();if(3===this.m.andln(3)){var e=this.m.add(new r(1)).iushrn(2);return this.pow(t,e)}for(var i=this.m.subn(1),n=0;!i.isZero()&&0===i.andln(1);)n++,i.iushrn(1);var s=new r(1).toRed(this),o=s.redNeg(),h=this.m.subn(1).iushrn(1),a=this.m.bitLength();for(a=new r(2*a*a).toRed(this);0!==this.pow(a,h).cmp(o);)a.redIAdd(o);for(var u=this.pow(a,i),f=this.pow(t,i.addn(1).iushrn(1)),l=this.pow(t,i),c=n;0!==l.cmp(s);){for(var d=l,p=0;0!==d.cmp(s);p++)d=d.redSqr();var m=this.pow(u,new r(1).iushln(c-p-1));f=f.redMul(m),u=m.redSqr(),l=l.redMul(u),c=p}return f},w.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},w.prototype.pow=function(t,e){if(e.isZero())return new r(1).toRed(this);if(0===e.cmpn(1))return t.clone();var i=new Array(16);i[0]=new r(1).toRed(this),i[1]=t;for(var n=2;n=0;n--){for(var u=e.words[n],f=a-1;f>=0;f--){var l=u>>f&1;s!==i[0]&&(s=this.sqr(s)),0!==l||0!==o?(o<<=1,o|=l,(4==++h||0===n&&0===f)&&(s=this.mul(s,i[o]),h=0,o=0)):h=0}a=26}return s},w.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},w.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},r.mont=function(t){return new _(t)},i(_,w),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(e),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new r(0)._forceRed(this);var i=t.mul(e),n=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=i.isub(n).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(Xa,this),Xa=Xa.exports;(function(t){(function(){(function(t){return new i(t)});var e={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};function i(t){this.curveType=e[t],this.curveType||(this.curveType={name:t}),this.curve=new lh.ec(this.curveType.name),this.keys=void 0}function r(e,i,r){Array.isArray(e)||(e=e.toArray());var n=new t(e);if(r&&n.length=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return r}function o(t,e,i,r){for(var n=0,s=Math.min(t.length,i),o=e;o=49?h-49+10:h>=17?h-17+10:h}return n}r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,e){return t.cmp(e)>0?t:e},r.min=function(t,e){return t.cmp(e)<0?t:e},r.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===e?this._parseHex(t,r):this._parseBase(t,e,r),"-"===t[0]&&(this.negative=1),this.strip(),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initArray=function(t,e,i){if(t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r=0;r-=3)s=t[r]|t[r-1]<<8|t[r-2]<<16,this.words[n]|=s<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===i)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this.strip()},r.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=6)n=s(t,i,i+6),this.words[r]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,r++);i+6!==e&&(n=s(t,e,i+6),this.words[r]|=n<>>26-o&4194303),this.strip()},r.prototype._parseBase=function(t,e,i){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=e)r++;r--,n=n/e|0;for(var s=t.length-i,h=s%r,a=Math.min(s,s-h)+i,u=0,f=i;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},r.prototype.inspect=function(){return(this.red?""};var h=["","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],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function l(t,e,i){i.negative=e.negative^t.negative;var r=t.length+e.length|0;i.length=r,r=r-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,h=67108863&o,a=o/67108864|0;i.words[0]=h;for(var u=1;u>>26,l=67108863&a,c=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=c;d++){var p=u-d|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[d])+l)/67108864|0,l=67108863&o}i.words[u]=0|l,a=0|f}return 0!==a?i.words[u]=0|a:i.length--,i.strip()}r.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var r=0,n=0,s=0;s>>24-r&16777215)||s!==this.length-1?h[6-a.length]+a+i:a+i,(r+=2)>=26&&(r-=26,s--)}for(0!==n&&(i=n.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var l=u[t],c=f[t];i="";var d=this.clone();for(d.negative=0;!d.isZero();){var p=d.modn(c).toString(t);i=(d=d.idivn(c)).isZero()?p+i:h[l-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length,0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16)},r.prototype.toBuffer=function(t,e){return this.toArrayLike(n,t,e)},r.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},r.prototype.toArrayLike=function(t,e,i){var r=this.byteLength(),n=i||Math.max(1,r);this.strip();var s,o,h="le"===e,a=new t(n),u=this.clone();if(h){for(o=0;!u.isZero();o++)s=u.andln(255),u.iushrn(8),a[o]=s;for(;o=4096&&(i+=13,e>>>=13),e>=64&&(i+=7,e>>>=7),e>=8&&(i+=4,e>>>=4),e>=2&&(i+=2,e>>>=2),i+e},r.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,i=0;return 0==(8191&e)&&(i+=13,e>>>=13),0==(127&e)&&(i+=7,e>>>=7),0==(15&e)&&(i+=4,e>>>=4),0==(3&e)&&(i+=2,e>>>=2),0==(1&e)&&i++,i},r.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var i=0;it.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var e,i;this.length>t.length?(e=this,i=t):(e=t,i=this);for(var r=0;rt.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-i),this.strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,e){var i=t/26|0,r=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(i=this,r=t):(i=t,r=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i,r,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(i=this,r=t):(i=t,r=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,d=0|o[1],p=8191&d,m=d>>>13,g=0|o[2],v=8191&g,y=g>>>13,b=0|o[3],M=8191&b,w=b>>>13,_=0|o[4],S=8191&_,k=_>>>13,A=0|o[5],E=8191&A,R=A>>>13,x=0|o[6],B=8191&x,I=x>>>13,P=0|o[7],T=8191&P,q=P>>>13,L=0|o[8],j=8191&L,O=L>>>13,N=0|o[9],C=8191&N,$=N>>>13,U=0|h[0],z=8191&U,D=U>>>13,K=0|h[1],W=8191&K,Z=K>>>13,F=0|h[2],V=8191&F,H=F>>>13,G=0|h[3],X=8191&G,Y=G>>>13,J=0|h[4],Q=8191&J,tt=J>>>13,et=0|h[5],it=8191&et,rt=et>>>13,nt=0|h[6],st=8191&nt,ot=nt>>>13,ht=0|h[7],at=8191&ht,ut=ht>>>13,ft=0|h[8],lt=8191&ft,ct=ft>>>13,dt=0|h[9],pt=8191&dt,mt=dt>>>13;i.negative=t.negative^e.negative,i.length=19;var gt=(u+(r=Math.imul(l,z))|0)+((8191&(n=(n=Math.imul(l,D))+Math.imul(c,z)|0))<<13)|0;u=((s=Math.imul(c,D))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(p,z),n=(n=Math.imul(p,D))+Math.imul(m,z)|0,s=Math.imul(m,D);var vt=(u+(r=r+Math.imul(l,W)|0)|0)+((8191&(n=(n=n+Math.imul(l,Z)|0)+Math.imul(c,W)|0))<<13)|0;u=((s=s+Math.imul(c,Z)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(v,z),n=(n=Math.imul(v,D))+Math.imul(y,z)|0,s=Math.imul(y,D),r=r+Math.imul(p,W)|0,n=(n=n+Math.imul(p,Z)|0)+Math.imul(m,W)|0,s=s+Math.imul(m,Z)|0;var yt=(u+(r=r+Math.imul(l,V)|0)|0)+((8191&(n=(n=n+Math.imul(l,H)|0)+Math.imul(c,V)|0))<<13)|0;u=((s=s+Math.imul(c,H)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(M,z),n=(n=Math.imul(M,D))+Math.imul(w,z)|0,s=Math.imul(w,D),r=r+Math.imul(v,W)|0,n=(n=n+Math.imul(v,Z)|0)+Math.imul(y,W)|0,s=s+Math.imul(y,Z)|0,r=r+Math.imul(p,V)|0,n=(n=n+Math.imul(p,H)|0)+Math.imul(m,V)|0,s=s+Math.imul(m,H)|0;var bt=(u+(r=r+Math.imul(l,X)|0)|0)+((8191&(n=(n=n+Math.imul(l,Y)|0)+Math.imul(c,X)|0))<<13)|0;u=((s=s+Math.imul(c,Y)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(S,z),n=(n=Math.imul(S,D))+Math.imul(k,z)|0,s=Math.imul(k,D),r=r+Math.imul(M,W)|0,n=(n=n+Math.imul(M,Z)|0)+Math.imul(w,W)|0,s=s+Math.imul(w,Z)|0,r=r+Math.imul(v,V)|0,n=(n=n+Math.imul(v,H)|0)+Math.imul(y,V)|0,s=s+Math.imul(y,H)|0,r=r+Math.imul(p,X)|0,n=(n=n+Math.imul(p,Y)|0)+Math.imul(m,X)|0,s=s+Math.imul(m,Y)|0;var Mt=(u+(r=r+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(c,Q)|0))<<13)|0;u=((s=s+Math.imul(c,tt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(E,z),n=(n=Math.imul(E,D))+Math.imul(R,z)|0,s=Math.imul(R,D),r=r+Math.imul(S,W)|0,n=(n=n+Math.imul(S,Z)|0)+Math.imul(k,W)|0,s=s+Math.imul(k,Z)|0,r=r+Math.imul(M,V)|0,n=(n=n+Math.imul(M,H)|0)+Math.imul(w,V)|0,s=s+Math.imul(w,H)|0,r=r+Math.imul(v,X)|0,n=(n=n+Math.imul(v,Y)|0)+Math.imul(y,X)|0,s=s+Math.imul(y,Y)|0,r=r+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var wt=(u+(r=r+Math.imul(l,it)|0)|0)+((8191&(n=(n=n+Math.imul(l,rt)|0)+Math.imul(c,it)|0))<<13)|0;u=((s=s+Math.imul(c,rt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(B,z),n=(n=Math.imul(B,D))+Math.imul(I,z)|0,s=Math.imul(I,D),r=r+Math.imul(E,W)|0,n=(n=n+Math.imul(E,Z)|0)+Math.imul(R,W)|0,s=s+Math.imul(R,Z)|0,r=r+Math.imul(S,V)|0,n=(n=n+Math.imul(S,H)|0)+Math.imul(k,V)|0,s=s+Math.imul(k,H)|0,r=r+Math.imul(M,X)|0,n=(n=n+Math.imul(M,Y)|0)+Math.imul(w,X)|0,s=s+Math.imul(w,Y)|0,r=r+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,tt)|0)+Math.imul(y,Q)|0,s=s+Math.imul(y,tt)|0,r=r+Math.imul(p,it)|0,n=(n=n+Math.imul(p,rt)|0)+Math.imul(m,it)|0,s=s+Math.imul(m,rt)|0;var _t=(u+(r=r+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(c,st)|0))<<13)|0;u=((s=s+Math.imul(c,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(T,z),n=(n=Math.imul(T,D))+Math.imul(q,z)|0,s=Math.imul(q,D),r=r+Math.imul(B,W)|0,n=(n=n+Math.imul(B,Z)|0)+Math.imul(I,W)|0,s=s+Math.imul(I,Z)|0,r=r+Math.imul(E,V)|0,n=(n=n+Math.imul(E,H)|0)+Math.imul(R,V)|0,s=s+Math.imul(R,H)|0,r=r+Math.imul(S,X)|0,n=(n=n+Math.imul(S,Y)|0)+Math.imul(k,X)|0,s=s+Math.imul(k,Y)|0,r=r+Math.imul(M,Q)|0,n=(n=n+Math.imul(M,tt)|0)+Math.imul(w,Q)|0,s=s+Math.imul(w,tt)|0,r=r+Math.imul(v,it)|0,n=(n=n+Math.imul(v,rt)|0)+Math.imul(y,it)|0,s=s+Math.imul(y,rt)|0,r=r+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(r=r+Math.imul(l,at)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(c,at)|0))<<13)|0;u=((s=s+Math.imul(c,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(j,z),n=(n=Math.imul(j,D))+Math.imul(O,z)|0,s=Math.imul(O,D),r=r+Math.imul(T,W)|0,n=(n=n+Math.imul(T,Z)|0)+Math.imul(q,W)|0,s=s+Math.imul(q,Z)|0,r=r+Math.imul(B,V)|0,n=(n=n+Math.imul(B,H)|0)+Math.imul(I,V)|0,s=s+Math.imul(I,H)|0,r=r+Math.imul(E,X)|0,n=(n=n+Math.imul(E,Y)|0)+Math.imul(R,X)|0,s=s+Math.imul(R,Y)|0,r=r+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(k,Q)|0,s=s+Math.imul(k,tt)|0,r=r+Math.imul(M,it)|0,n=(n=n+Math.imul(M,rt)|0)+Math.imul(w,it)|0,s=s+Math.imul(w,rt)|0,r=r+Math.imul(v,st)|0,n=(n=n+Math.imul(v,ot)|0)+Math.imul(y,st)|0,s=s+Math.imul(y,ot)|0,r=r+Math.imul(p,at)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,at)|0,s=s+Math.imul(m,ut)|0;var kt=(u+(r=r+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,ct)|0)+Math.imul(c,lt)|0))<<13)|0;u=((s=s+Math.imul(c,ct)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(C,z),n=(n=Math.imul(C,D))+Math.imul($,z)|0,s=Math.imul($,D),r=r+Math.imul(j,W)|0,n=(n=n+Math.imul(j,Z)|0)+Math.imul(O,W)|0,s=s+Math.imul(O,Z)|0,r=r+Math.imul(T,V)|0,n=(n=n+Math.imul(T,H)|0)+Math.imul(q,V)|0,s=s+Math.imul(q,H)|0,r=r+Math.imul(B,X)|0,n=(n=n+Math.imul(B,Y)|0)+Math.imul(I,X)|0,s=s+Math.imul(I,Y)|0,r=r+Math.imul(E,Q)|0,n=(n=n+Math.imul(E,tt)|0)+Math.imul(R,Q)|0,s=s+Math.imul(R,tt)|0,r=r+Math.imul(S,it)|0,n=(n=n+Math.imul(S,rt)|0)+Math.imul(k,it)|0,s=s+Math.imul(k,rt)|0,r=r+Math.imul(M,st)|0,n=(n=n+Math.imul(M,ot)|0)+Math.imul(w,st)|0,s=s+Math.imul(w,ot)|0,r=r+Math.imul(v,at)|0,n=(n=n+Math.imul(v,ut)|0)+Math.imul(y,at)|0,s=s+Math.imul(y,ut)|0,r=r+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,ct)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,ct)|0;var At=(u+(r=r+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(c,pt)|0))<<13)|0;u=((s=s+Math.imul(c,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(C,W),n=(n=Math.imul(C,Z))+Math.imul($,W)|0,s=Math.imul($,Z),r=r+Math.imul(j,V)|0,n=(n=n+Math.imul(j,H)|0)+Math.imul(O,V)|0,s=s+Math.imul(O,H)|0,r=r+Math.imul(T,X)|0,n=(n=n+Math.imul(T,Y)|0)+Math.imul(q,X)|0,s=s+Math.imul(q,Y)|0,r=r+Math.imul(B,Q)|0,n=(n=n+Math.imul(B,tt)|0)+Math.imul(I,Q)|0,s=s+Math.imul(I,tt)|0,r=r+Math.imul(E,it)|0,n=(n=n+Math.imul(E,rt)|0)+Math.imul(R,it)|0,s=s+Math.imul(R,rt)|0,r=r+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(k,st)|0,s=s+Math.imul(k,ot)|0,r=r+Math.imul(M,at)|0,n=(n=n+Math.imul(M,ut)|0)+Math.imul(w,at)|0,s=s+Math.imul(w,ut)|0,r=r+Math.imul(v,lt)|0,n=(n=n+Math.imul(v,ct)|0)+Math.imul(y,lt)|0,s=s+Math.imul(y,ct)|0;var Et=(u+(r=r+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(C,V),n=(n=Math.imul(C,H))+Math.imul($,V)|0,s=Math.imul($,H),r=r+Math.imul(j,X)|0,n=(n=n+Math.imul(j,Y)|0)+Math.imul(O,X)|0,s=s+Math.imul(O,Y)|0,r=r+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(q,Q)|0,s=s+Math.imul(q,tt)|0,r=r+Math.imul(B,it)|0,n=(n=n+Math.imul(B,rt)|0)+Math.imul(I,it)|0,s=s+Math.imul(I,rt)|0,r=r+Math.imul(E,st)|0,n=(n=n+Math.imul(E,ot)|0)+Math.imul(R,st)|0,s=s+Math.imul(R,ot)|0,r=r+Math.imul(S,at)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(k,at)|0,s=s+Math.imul(k,ut)|0,r=r+Math.imul(M,lt)|0,n=(n=n+Math.imul(M,ct)|0)+Math.imul(w,lt)|0,s=s+Math.imul(w,ct)|0;var Rt=(u+(r=r+Math.imul(v,pt)|0)|0)+((8191&(n=(n=n+Math.imul(v,mt)|0)+Math.imul(y,pt)|0))<<13)|0;u=((s=s+Math.imul(y,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(C,X),n=(n=Math.imul(C,Y))+Math.imul($,X)|0,s=Math.imul($,Y),r=r+Math.imul(j,Q)|0,n=(n=n+Math.imul(j,tt)|0)+Math.imul(O,Q)|0,s=s+Math.imul(O,tt)|0,r=r+Math.imul(T,it)|0,n=(n=n+Math.imul(T,rt)|0)+Math.imul(q,it)|0,s=s+Math.imul(q,rt)|0,r=r+Math.imul(B,st)|0,n=(n=n+Math.imul(B,ot)|0)+Math.imul(I,st)|0,s=s+Math.imul(I,ot)|0,r=r+Math.imul(E,at)|0,n=(n=n+Math.imul(E,ut)|0)+Math.imul(R,at)|0,s=s+Math.imul(R,ut)|0,r=r+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,ct)|0)+Math.imul(k,lt)|0,s=s+Math.imul(k,ct)|0;var xt=(u+(r=r+Math.imul(M,pt)|0)|0)+((8191&(n=(n=n+Math.imul(M,mt)|0)+Math.imul(w,pt)|0))<<13)|0;u=((s=s+Math.imul(w,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(C,Q),n=(n=Math.imul(C,tt))+Math.imul($,Q)|0,s=Math.imul($,tt),r=r+Math.imul(j,it)|0,n=(n=n+Math.imul(j,rt)|0)+Math.imul(O,it)|0,s=s+Math.imul(O,rt)|0,r=r+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(q,st)|0,s=s+Math.imul(q,ot)|0,r=r+Math.imul(B,at)|0,n=(n=n+Math.imul(B,ut)|0)+Math.imul(I,at)|0,s=s+Math.imul(I,ut)|0,r=r+Math.imul(E,lt)|0,n=(n=n+Math.imul(E,ct)|0)+Math.imul(R,lt)|0,s=s+Math.imul(R,ct)|0;var Bt=(u+(r=r+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(k,pt)|0))<<13)|0;u=((s=s+Math.imul(k,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(C,it),n=(n=Math.imul(C,rt))+Math.imul($,it)|0,s=Math.imul($,rt),r=r+Math.imul(j,st)|0,n=(n=n+Math.imul(j,ot)|0)+Math.imul(O,st)|0,s=s+Math.imul(O,ot)|0,r=r+Math.imul(T,at)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(q,at)|0,s=s+Math.imul(q,ut)|0,r=r+Math.imul(B,lt)|0,n=(n=n+Math.imul(B,ct)|0)+Math.imul(I,lt)|0,s=s+Math.imul(I,ct)|0;var It=(u+(r=r+Math.imul(E,pt)|0)|0)+((8191&(n=(n=n+Math.imul(E,mt)|0)+Math.imul(R,pt)|0))<<13)|0;u=((s=s+Math.imul(R,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(C,st),n=(n=Math.imul(C,ot))+Math.imul($,st)|0,s=Math.imul($,ot),r=r+Math.imul(j,at)|0,n=(n=n+Math.imul(j,ut)|0)+Math.imul(O,at)|0,s=s+Math.imul(O,ut)|0,r=r+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,ct)|0)+Math.imul(q,lt)|0,s=s+Math.imul(q,ct)|0;var Pt=(u+(r=r+Math.imul(B,pt)|0)|0)+((8191&(n=(n=n+Math.imul(B,mt)|0)+Math.imul(I,pt)|0))<<13)|0;u=((s=s+Math.imul(I,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(C,at),n=(n=Math.imul(C,ut))+Math.imul($,at)|0,s=Math.imul($,ut),r=r+Math.imul(j,lt)|0,n=(n=n+Math.imul(j,ct)|0)+Math.imul(O,lt)|0,s=s+Math.imul(O,ct)|0;var Tt=(u+(r=r+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(q,pt)|0))<<13)|0;u=((s=s+Math.imul(q,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(C,lt),n=(n=Math.imul(C,ct))+Math.imul($,lt)|0,s=Math.imul($,ct);var qt=(u+(r=r+Math.imul(j,pt)|0)|0)+((8191&(n=(n=n+Math.imul(j,mt)|0)+Math.imul(O,pt)|0))<<13)|0;u=((s=s+Math.imul(O,mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863;var Lt=(u+(r=Math.imul(C,pt))|0)+((8191&(n=(n=Math.imul(C,mt))+Math.imul($,pt)|0))<<13)|0;return u=((s=Math.imul($,mt))+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,a[0]=gt,a[1]=vt,a[2]=yt,a[3]=bt,a[4]=Mt,a[5]=wt,a[6]=_t,a[7]=St,a[8]=kt,a[9]=At,a[10]=Et,a[11]=Rt,a[12]=xt,a[13]=Bt,a[14]=It,a[15]=Pt,a[16]=Tt,a[17]=qt,a[18]=Lt,0!==u&&(a[19]=u,i.length++),i};function d(t,e,i){return(new p).mulp(t,e,i)}function p(t,e){this.x=t,this.y=e}Math.imul||(c=l),r.prototype.mulTo=function(t,e){var i=this.length+t.length;return 10===this.length&&10===t.length?c(this,t,e):i<63?l(this,t,e):i<1024?function(t,e,i){i.negative=e.negative^t.negative,i.length=t.length+e.length;for(var r=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}i.words[s]=h,r=o,o=n}return 0!==r?i.words[s]=r:i.length--,i.strip()}(this,t,e):d(this,t,e)},p.prototype.makeRBT=function(t){for(var e=new Array(t),i=r.prototype._countBits(t)-1,n=0;n>=1;return r},p.prototype.permute=function(t,e,i,r,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*s+1]=8191&n,n>>>=13;for(s=2*e;s>=26,e+=r/67108864|0,e+=n>>>26,this.words[i]=67108863&n}return 0!==e&&(this.words[i]=e,this.length++),this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),i=0;i>>n}return e}(t);if(0===e.length)return new r(1);for(var i=this,n=0;n>>26-i<<26-i;if(0!==i){var s=0;for(e=0;e>>26-i}s&&(this.words[e]=s,this.length++)}if(0!==r){for(e=this.length-1;e>=0;e--)this.words[e+r]=this.words[e];for(e=0;e>>n<s)for(this.length-=s,a=0;a=0&&(0!==u||a>=r);a--){var f=0|this.words[a];this.words[a]=u<<26-n|f>>>n,u=f&o}return h&&0!==u&&(h.words[h.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},r.prototype.ishrn=function(t,e,i){return this.iushrn(t,e,i)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){var e=t%26,i=(t-e)/26,r=1<>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},r.prototype.isubn=function(t){if(t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[r+i]=67108863&n}for(;r>26,this.words[r+i]=67108863&n;if(0===o)return this.strip();for(o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},r.prototype._wordDiv=function(t,e){var i=(this.length,t.length),n=this.clone(),s=t,o=0|s.words[s.length-1];0!=(i=26-this._countBits(o))&&(s=s.ushln(i),n.iushln(i),o=0|s.words[s.length-1]);var h,a=n.length-s.length;if("mod"!==e){(h=new r(null)).length=a+1,h.words=new Array(h.length);for(var u=0;u=0;l--){var c=67108864*(0|n.words[s.length+l])+(0|n.words[s.length+l-1]);for(c=Math.min(c/o|0,67108863),n._ishlnsubmul(s,c,l);0!==n.negative;)c--,n.negative=0,n._ishlnsubmul(s,1,l),n.isZero()||(n.negative^=1);h&&(h.words[l]=c)}return h&&h.strip(),n.strip(),"div"!==e&&0!==i&&n.iushrn(i),{div:h||null,mod:n}},r.prototype.divmod=function(t,e,i){return this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),"mod"!==e&&(n=o.div.neg()),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),e),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new r(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var i=0!==e.div.negative?e.mod.isub(t):e.mod,r=t.ushrn(1),n=t.andln(1),s=i.cmp(r);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},r.prototype.modn=function(t){for(var e=(1<<26)%t,i=0,r=this.length-1;r>=0;r--)i=(e*i+(0|this.words[r]))%t;return i},r.prototype.idivn=function(t){for(var e=0,i=this.length-1;i>=0;i--){var r=(0|this.words[i])+67108864*e;this.words[i]=r/t|0,e=r%t}return this.strip()},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new r(1),s=new r(0),o=new r(0),h=new r(1),a=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++a;for(var u=i.clone(),f=e.clone();!e.isZero();){for(var l=0,c=1;0==(e.words[0]&c)&&l<26;++l,c<<=1);if(l>0)for(e.iushrn(l);l-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(u),s.isub(f)),n.iushrn(1),s.iushrn(1);for(var d=0,p=1;0==(i.words[0]&p)&&d<26;++d,p<<=1);if(d>0)for(i.iushrn(d);d-- >0;)(o.isOdd()||h.isOdd())&&(o.iadd(u),h.isub(f)),o.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),n.isub(o),s.isub(h)):(i.isub(e),o.isub(n),h.isub(s))}return{a:o,b:h,gcd:i.iushln(a)}},r.prototype._invmp=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new r(1),o=new r(0),h=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var a=0,u=1;0==(e.words[0]&u)&&a<26;++a,u<<=1);if(a>0)for(e.iushrn(a);a-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);for(var f=0,l=1;0==(i.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(i.iushrn(f);f-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o)):(i.isub(e),o.isub(s))}return(n=0===e.cmpn(1)?s:o).cmpn(0)<0&&n.iadd(t),n},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),i=t.clone();e.negative=0,i.negative=0;for(var r=0;e.isEven()&&i.isEven();r++)e.iushrn(1),i.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;i.isEven();)i.iushrn(1);var n=e.cmp(i);if(n<0){var s=e;e=i,i=s}else if(0===n||0===i.cmpn(1))break;e.isub(i)}return i.iushln(r)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){var e=t%26,i=(t-e)/26,r=1<>>26,o&=67108863,this.words[s]=o}return 0!==n&&(this.words[s]=n,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t);var r=0|this.words[0];e=r===t?0:rt.length)return 1;if(this.length=0;i--){var r=0|this.words[i],n=0|t.words[i];if(r!==n){rn&&(e=1);break}}return e},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new w(t)},r.prototype.toRed=function(t){return t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return this._forceRed(t)},r.prototype.redAdd=function(t){return this.red.add(this,t)},r.prototype.redIAdd=function(t){return this.red.iadd(this,t)},r.prototype.redSub=function(t){return this.red.sub(this,t)},r.prototype.redISub=function(t){return this.red.isub(this,t)},r.prototype.redShl=function(t){return this.red.shl(this,t)},r.prototype.redMul=function(t){return this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return this.red._verify1(this),this.red.pow(this,t)};var m={k256:null,p224:null,p192:null,p25519:null};function g(t,e){this.name=t,this.p=new r(e,16),this.n=this.p.bitLength(),this.k=new r(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){g.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function y(){g.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){g.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function M(){g.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function w(t){if("string"==typeof t){var e=r._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function _(t){w.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}g.prototype._tmp=function(){var t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},g.prototype.ireduce=function(t){var e,i=t;do{this.split(i,this.tmp),e=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(e>this.n);var r=e0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},g.prototype.split=function(t,e){t.iushrn(this.n,0,e)},g.prototype.imulK=function(t){return t.imul(this.k)},i(v,g),v.prototype.split=function(t,e){for(var i=Math.min(t.length,9),r=0;r>>22,n=s}n>>>=22,t.words[r-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,i=0;i>>=26,t.words[i]=n,e=r}return 0!==e&&(t.words[t.length++]=e),t},r._prime=function(t){if(m[t])return m[t];var e;if("k256"===t)e=new v;else if("p224"===t)e=new y;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new M}return m[t]=e,e},w.prototype._verify1=function(t){},w.prototype._verify2=function(t,e){},w.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},w.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},w.prototype.add=function(t,e){this._verify2(t,e);var i=t.add(e);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},w.prototype.iadd=function(t,e){this._verify2(t,e);var i=t.iadd(e);return i.cmp(this.m)>=0&&i.isub(this.m),i},w.prototype.sub=function(t,e){this._verify2(t,e);var i=t.sub(e);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},w.prototype.isub=function(t,e){this._verify2(t,e);var i=t.isub(e);return i.cmpn(0)<0&&i.iadd(this.m),i},w.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},w.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},w.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},w.prototype.isqr=function(t){return this.imul(t,t.clone())},w.prototype.sqr=function(t){return this.mul(t,t)},w.prototype.sqrt=function(t){if(t.isZero())return t.clone();if(3===this.m.andln(3)){var e=this.m.add(new r(1)).iushrn(2);return this.pow(t,e)}for(var i=this.m.subn(1),n=0;!i.isZero()&&0===i.andln(1);)n++,i.iushrn(1);var s=new r(1).toRed(this),o=s.redNeg(),h=this.m.subn(1).iushrn(1),a=this.m.bitLength();for(a=new r(2*a*a).toRed(this);0!==this.pow(a,h).cmp(o);)a.redIAdd(o);for(var u=this.pow(a,i),f=this.pow(t,i.addn(1).iushrn(1)),l=this.pow(t,i),c=n;0!==l.cmp(s);){for(var d=l,p=0;0!==d.cmp(s);p++)d=d.redSqr();var m=this.pow(u,new r(1).iushln(c-p-1));f=f.redMul(m),u=m.redSqr(),l=l.redMul(u),c=p}return f},w.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},w.prototype.pow=function(t,e){if(e.isZero())return new r(1).toRed(this);if(0===e.cmpn(1))return t.clone();var i=new Array(16);i[0]=new r(1).toRed(this),i[1]=t;for(var n=2;n=0;n--){for(var u=e.words[n],f=a-1;f>=0;f--){var l=u>>f&1;s!==i[0]&&(s=this.sqr(s)),0!==l||0!==o?(o<<=1,o|=l,(4==++h||0===n&&0===f)&&(s=this.mul(s,i[o]),h=0,o=0)):h=0}a=26}return s},w.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},w.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},r.mont=function(t){return new _(t)},i(_,w),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(e),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new r(0)._forceRed(this);var i=t.mul(e),n=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=i.isub(n).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(Ya,this),Ya=Ya.exports;M.Buffer,M.Buffer,M.Buffer;var Ja={};(function(t,e){(function(){"use strict";M.Buffer,M.kMaxLength;var i=e.crypto||e.msCrypto;Math.pow(2,32);i&&i.getRandomValues||t.browser}).call(this)}).call(this,R,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});var Qa={};Qa.createHash=wi,Qa.createHmac=Ri;var tu=Object.keys(qi);["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(tu);Wi.pbkdf2,Wi.pbkdf2Sync,Ja.publicEncrypt,Ja.privateEncrypt,Ja.publicDecrypt,Ja.privateDecrypt;Array.isArray;var eu=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}},iu=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function ru(t,e){if(t.map)return t.map(e);for(var i=[],r=0;r{f=r.ERR_TIMEOUT,e.abort()},0===n?this.requestTimeout:n)}h=await fetch(t.uri,t),void 0!==u&&clearTimeout(u),f=r.ERR_RESPONSE;let s=h.headers.get("Content-Type");if(!1===e&&null===s?a=void 0===h.blob?await h.buffer():await h.blob():!1===e&&(s.startsWith("application/json")||s.startsWith("application/problem+json"))?(a=await h.json(),f=a.type,l=a.title):a=!1===e&&s.startsWith("text/")?await h.text():void 0===h.blob?await h.buffer():await h.blob(),f=r.ERR_SERVER,!h.ok)throw a}catch(g){if(s>0)return await new Promise(t=>setTimeout(t,2e3)),this._wrapWithPromise(t,e,i,n,s-1);let u;switch(u="object"==typeof g&&g.constructor===Object&&"title"in g?g.title:g,void 0===h&&(h={}),f){case r.ERR_REQUEST:f="https://api.backend.ai/probs/client-request-error",navigator.onLine?(l=u,o="sending request has failed: "+u,c=u):(l="Network disconnected.",o="sending request has failed: Network disconnected",c="Network disconnected");break;case r.ERR_RESPONSE:f="https://api.backend.ai/probs/client-response-error",l=u,o="reading response has failed: "+u,c=u;break;case r.ERR_SERVER:f="https://api.backend.ai/probs/server-error",l=`${h.status} ${h.statusText} - ${a.title}`,o="server responded failure: ",a.msg?(o+=`${h.status} ${h.statusText} - ${a.msg}`,c=a.msg):(o+=`${h.status} ${h.statusText} - ${a.title}`,c=a.title);break;case r.ERR_ABORT:f="https://api.backend.ai/probs/request-abort-error",l="Request aborted",c=o="Request aborted by user",h.status=408,h.statusText="Request aborted by user";break;case r.ERR_TIMEOUT:f="https://api.backend.ai/probs/request-timeout-error",l="Request timeout",c=o="No response returned during the timeout period",h.status=408,h.statusText="Timeout exceeded";break;default:void 0===h.status&&(h.status=500,h.statusText="Server error"),""===f&&(f=r.ERR_UNKNOWN),""===l&&(l=a.title),o=`server responded failure: ${h.status} ${h.statusText} - ${a.title}`,""!==a.title&&(c=a.title)}throw{isError:!0,timestamp:(new Date).toUTCString(),type:f,requestUrl:t.uri,requestMethod:t.method,requestParameters:t.body,statusCode:h.status,statusText:h.statusText,title:l,message:o,description:c}}let d=JSON.parse(localStorage.getItem("backendaiwebui.logs"));d&&d.length>3e3&&(d=d.slice(1,3e3));let p=Array();void 0===h&&(h={status:"No status",statusText:"No response given."});let m={isError:!1,timestamp:(new Date).toUTCString(),type:"",requestUrl:t.uri,requestMethod:t.method,requestParameters:t.body,statusCode:h.status,statusText:h.statusText,title:a.title,message:""};p.push(m),d&&(p=p.concat(d));try{localStorage.setItem("backendaiwebui.logs",JSON.stringify(p))}catch(hu){console.warn("Local storage is full. Clearing part of the logs.");let e=JSON.parse(localStorage.getItem("backendaiwebui.logs")||"[]");e=e.slice(0,Math.round(2*e.length/3)),localStorage.setItem("backendaiwebui.logs",JSON.stringify(e)),Object.entries(localStorage).map(t=>t[0]).filter(t=>t.startsWith("backendaiconsole")).map(t=>localStorage.removeItem(t))}return a}getServerVersion(t=null){let e=this.newPublicRequest("GET","/",null,"");return this._wrapWithPromise(e,!1,t)}get APIMajorVersion(){return this._apiVersionMajor}set APIMajorVersion(t){this._apiVersionMajor=t,this._config._apiVersionMajor=this._apiVersionMajor}async get_manager_version(t=null){if(null===this._managerVersion){let e=await this.getServerVersion(t);this._managerVersion=e.manager,this._apiVersion=e.version,this._config._apiVersion=this._apiVersion,this._apiVersionMajor=e.version.substr(1,2),this._config._apiVersionMajor=this._apiVersionMajor,this._apiVersionMajor>4&&(this.kernelPrefix="/session")}return this._managerVersion}supports(t){return 0===Object.keys(this._features).length&&this._updateSupportList(),t in this._features&&this._features[t]}_updateFieldCompatibilityByAPIVersion(t){const e={session_name:"sess_id"};return this._apiVersionMajor<5&&Object.keys(e).forEach(i=>{let r=t.indexOf(i);-1!==r&&(t[r]=e[i])}),t}_updateSupportList(){this.isAPIVersionCompatibleWith("v4.20190601")&&(this._features["scaling-group"]=!0,this._features.group=!0,this._features["group-folder"]=!0,this._features["system-images"]=!0,this._features["detailed-session-states"]=!0,this._features["change-user-name"]=!0),this.isAPIVersionCompatibleWith("v6.20200815")&&(this._features["multi-container"]=!0,this._features["multi-node"]=!0,this._features["storage-proxy"]=!0,this._features["hardware-metadata"]=!0)}isManagerVersionCompatibleWith(t){let e=this._managerVersion;return e=e.split(".").map(t=>t.padStart(10)).join("."),(t=t.split(".").map(t=>t.padStart(10)).join("."))<=e}isAPIVersionCompatibleWith(t){let e=this._apiVersion;return null!==e&&null!==t&&(e=e.split(".").map(t=>t.padStart(10)).join("."),t=t.split(".").map(t=>t.padStart(10)).join(".")),t<=e}async check_login(){let t,e=this.newSignedRequest("POST","/server/login-check",null);try{!0===(t=await this._wrapWithPromise(e)).authenticated&&(this._config._accessKey=t.data.access_key,this._config._session_id=t.session_id)}catch(i){return console.log(i),Promise.resolve(!1)}return t.authenticated}async login(){let t,e={username:this._config.userId,password:this._config.password},i=this.newSignedRequest("POST","/server/login",e);try{if(!0===(t=await this._wrapWithPromise(i)).authenticated)return await this.get_manager_version(),this.check_login();if(!1===t.authenticated)return t.data&&t.data.details?Promise.resolve({fail_reason:t.data.details}):Promise.resolve(!1)}catch(r){throw"statusCode"in r&&429===r.statusCode?{title:r.description,message:"Too many failed login attempts."}:{title:"No manager found at API Endpoint.",message:"Authentication failed. Check information and manager status."}}}logout(){let t=this.newSignedRequest("POST","/server/logout",{});return this._wrapWithPromise(t)}async signout(t,e){let i={username:t,password:e},r=this.newSignedRequest("POST","/auth/signout",i);return this._wrapWithPromise(r)}async update_password(t,e,i){let r={old_password:t,new_password:e,new_password2:i},n=this.newSignedRequest("POST","/auth/update-password",r);return this._wrapWithPromise(n)}async get_resource_slots(){let t;return t=this.isAPIVersionCompatibleWith("v4.20190601")?this.newPublicRequest("GET","/config/resource-slots",null,""):this.newPublicRequest("GET","/etcd/resource-slots",null,""),this._wrapWithPromise(t)}async createIfNotExists(t,e,i={},r=0){null==e&&(e=this.generateSessionId());let n,s={lang:t,clientSessionToken:e};if(i!={}){let t={};i.cpu&&(t.cpu=i.cpu),i.mem&&(t.mem=i.mem),i.gpu&&(t["cuda.device"]=parseInt(i.gpu)),i["cuda.device"]&&(t["cuda.device"]=parseInt(i["cuda.device"])),i.vgpu?t["cuda.shares"]=parseFloat(i.vgpu).toFixed(2):i.fgpu&&(t["cuda.shares"]=parseFloat(i.fgpu).toFixed(2)),i["cuda.shares"]&&(t["cuda.shares"]=parseFloat(i["cuda.shares"]).toFixed(2)),i.rocm&&(t["rocm.device"]=i.rocm),i.tpu&&(t["tpu.device"]=i.tpu),i.cluster_size&&(s.cluster_size=i.cluster_size),i.cluster_mode&&(s.cluster_mode=i.cluster_mode),i.group_name&&(s.group_name=i.group_name),i.domain&&(s.domain=i.domain),i.type&&(s.type=i.type),i.startsAt&&(s.starts_at=i.startsAt),i.enqueueOnly&&(s.enqueueOnly=i.enqueueOnly),i.maxWaitSeconds&&(s.maxWaitSeconds=i.maxWaitSeconds),i.reuseIfExists&&(s.reuseIfExists=i.reuseIfExists),i.startupCommand&&(s.startupCommand=i.startupCommand),i.bootstrapScript&&(s.bootstrapScript=i.bootstrapScript),i.bootstrap_script&&(s.bootstrap_script=i.bootstrap_script),i.owner_access_key&&(s.owner_access_key=i.owner_access_key),s.config={resources:t},i.mounts&&(s.config.mounts=i.mounts),i.scaling_group&&(s.config.scaling_group=i.scaling_group),i.shmem&&(s.config.resource_opts={},s.config.resource_opts.shmem=i.shmem),i.env&&(s.config.environ=i.env)}return n=this._apiVersionMajor<5?this.newSignedRequest("POST",this.kernelPrefix+"/create",s):this.newSignedRequest("POST",""+this.kernelPrefix,s),this._wrapWithPromise(n,!1,null,r)}async get_info(t,e=null){let i=`${this.kernelPrefix}/${t}`;null!=e&&(i=`${i}?owner_access_key=${e}`);let r=this.newSignedRequest("GET",i,null);return this._wrapWithPromise(r)}async get_logs(t,e=null,i=0){let r=`${this.kernelPrefix}/${t}/logs`;null!=e&&(r=`${r}?owner_access_key=${e}`);let n=this.newSignedRequest("GET",r,null);return this._wrapWithPromise(n,!1,null,i)}getTaskLogs(t){const e=`${this.kernelPrefix}/_/logs?session_name=${t}`;let i=this.newSignedRequest("GET",e,null);return this._wrapWithPromise(i)}async destroy(t,e=null,i=!1){let r=`${this.kernelPrefix}/${t}`;r=null!==e?`${r}?owner_access_key=${e}${i?"&forced=true":""}`:`${r}${i?"?forced=true":""}`;let n=this.newSignedRequest("DELETE",r,null);return this._wrapWithPromise(n,!1,null,15e3,2)}async restart(t,e=null){let i=`${this.kernelPrefix}/${t}`;null!=e&&(i=`${i}?owner_access_key=${e}`);let r=this.newSignedRequest("PATCH",i,null);return this._wrapWithPromise(r)}async execute(t,e,i,r,n){let s={mode:i,code:r,runId:e,options:n},o=this.newSignedRequest("POST",`${this.kernelPrefix}/${t}`,s);return this._wrapWithPromise(o)}createKernel(t,e,i={},r=0){return this.createIfNotExists(t,e,i,r)}destroyKernel(t,e=null){return this.destroy(t,e)}refreshKernel(t,e=null){return this.restart(t,e)}runCode(t,e,i,r){return this.execute(e,i,r,t,{})}async shutdown_service(t,e){let i={service_name:e};const r=su.stringify(i);let n=this.newSignedRequest("POST",`${this.kernelPrefix}/${t}/shutdown-service?${r}`,null);return this._wrapWithPromise(n,!0)}async upload(t,e,i){const r=new FormData;r.append("src",i,e);let n=this.newSignedRequest("POST",`${this.kernelPrefix}/${t}/upload`,r);return this._wrapWithPromise(n)}async download(t,e){let i={files:e};const r=su.stringify(i);let n=this.newSignedRequest("GET",`${this.kernelPrefix}/${t}/download?${r}`,null);return this._wrapWithPromise(n,!0)}async download_single(t,e){let i={file:e};const r=su.stringify(i);let n=this.newSignedRequest("GET",`${this.kernelPrefix}/${t}/download_single?${r}`,null);return this._wrapWithPromise(n,!0)}mangleUserAgentSignature(){return this.clientVersion+(this.agentSignature?"; "+this.agentSignature:"")}async query(t,e,i=null,r=0,n=0){let s={query:t,variables:e},o=this.newSignedRequest("POST","/admin/graphql",s);return this._wrapWithPromise(o,!1,i,r,n)}newSignedRequest(t,i,r){let n,s,o,h,a,u="application/json",f=new Date;if(null==r?s=n="":"function"==typeof r.getBoundary||r instanceof FormData?(n=r,s="",u="multipart/form-data"):s=n=JSON.stringify(r),a="","SESSION"===this._config.connectionMode)h=new Headers({"User-Agent":"Backend.AI Client for Javascript "+this.mangleUserAgentSignature(),"X-BackendAI-Version":this._config.apiVersion,"X-BackendAI-Date":f.toISOString()}),a=!0===i.startsWith("/server")?this._config.endpoint+i:this._config.endpoint+"/func"+i;else{o=this._config._apiVersion[1]<4?this.getAuthenticationString(t,i,f.toISOString(),s,u):this.getAuthenticationString(t,i,f.toISOString(),"",u);let e=this.getSignKey(this._config.secretKey,f),r=this.sign(e,"binary",o,"hex");h=new Headers({"User-Agent":"Backend.AI Client for Javascript "+this.mangleUserAgentSignature(),"X-BackendAI-Version":this._config.apiVersion,"X-BackendAI-Date":f.toISOString(),Authorization:`BackendAI signMethod=HMAC-SHA256, credential=${this._config.accessKey}:${r}`}),a=this._config.endpoint+i}return null!=r?("function"==typeof r.getBoundary&&h.set("Content-Type",r.getHeaders()["content-type"]),r instanceof FormData||(h.set("Content-Type",u),h.set("Content-Length",e.byteLength(s)))):h.set("Content-Type",u),{method:t,headers:h,cache:"default",body:n,uri:a}}newUnsignedRequest(t,e,i){return this.newPublicRequest(t,e,i,this._config.apiVersionMajor)}newPublicRequest(t,e,i,r){let n=new Date,s={method:t,headers:new Headers({"Content-Type":"application/json","User-Agent":"Backend.AI Client for Javascript "+this.mangleUserAgentSignature(),"X-BackendAI-Version":this._config.apiVersion,"X-BackendAI-Date":n.toISOString(),credentials:"include",mode:"cors"}),mode:"cors",cache:"default",uri:""};return"SESSION"===this._config.connectionMode&&!0===e.startsWith("/server")?s.uri=this._config.endpoint+e:"SESSION"===this._config.connectionMode&&!1===e.startsWith("/server")?s.uri=this._config.endpoint+"/func"+e:s.uri=this._config.endpoint+e,s}getAuthenticationString(t,e,i,r,n="application/json"){let s=Qa.createHash(this._config.hashType).update(r).digest("hex");return t+"\n"+e+"\n"+i+"\nhost:"+this._config.endpointHost+"\ncontent-type:"+n+"\nx-backendai-version:"+this._config.apiVersion+"\n"+s}getCurrentDate(t){return("0000"+t.getUTCFullYear()).slice(-4)+("0"+(t.getUTCMonth()+1)).slice(-2)+("0"+t.getUTCDate()).slice(-2)}sign(t,i,r,n){let s=new e(t,i),o=Qa.createHmac(this._config.hashType,s);return o.update(r,"utf8"),o.digest(n)}getSignKey(t,e){let i=this.sign(t,"utf8",this.getCurrentDate(e),"binary");return this.sign(i,"binary",this._config.endpointHost,"binary")}generateSessionId(t=8,e=!1){for(var i="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=0;n"aaaaeeeeiiiioooouuuuncsyoarsnpwgnmuxzh------".charAt(e.indexOf(t))).replace(/&/g,"-and-").replace(/[^\w\-]+/g,"").replace(/\-\-+/g,"-").replace(/^-+/,"").replace(/-+$/,"")}async fetchSSHKeypair(){let t=this.newSignedRequest("GET","/auth/ssh-keypair",null);return this._wrapWithPromise(t,!1)}async refreshSSHKeypair(){let t=this.newSignedRequest("PATCH","/auth/ssh-keypair",null);return this._wrapWithPromise(t,!1)}}class n{constructor(t){this.client=t,this.urlPrefix="/resource"}async list(t=null){let e=this.client.newSignedRequest("GET",this.urlPrefix+"/presets",t);return this.client._wrapWithPromise(e)}async check(t=null){let e=this.client.newSignedRequest("POST",this.urlPrefix+"/check-presets",t);return this.client._wrapWithPromise(e)}async add(t=null,e){if(!0===this.client.is_admin&&null!==t){let i="mutation($name: String!, $input: CreateResourcePresetInput!) { create_resource_preset(name: $name, props: $input) { ok msg }}",r={name:t,input:e};return this.client.query(i,r)}return Promise.resolve(!1)}async mutate(t=null,e){if(!0===this.client.is_admin&&null!==t){let i="mutation($name: String!, $input: ModifyResourcePresetInput!) { modify_resource_preset(name: $name, props: $input) { ok msg }}",r={name:t,input:e};return this.client.query(i,r)}return Promise.resolve(!1)}async delete(t=null){if(!0===this.client.is_admin&&null!==t){let e="mutation($name: String!) { delete_resource_preset(name: $name) { ok msg }}",i={name:t};return this.client.query(e,i)}return Promise.resolve(!1)}}class s{constructor(t,e=null){this.client=t,this.name=e,this.urlPrefix="/folders"}async list_allowed_types(){let t=this.client.newSignedRequest("GET",this.urlPrefix+"/_/allowed_types",null);return this.client._wrapWithPromise(t)}async create(t,e="",i="",r="general",n="rw",s=!1){let o;""!==e&&(o={name:t,host:e}),this.client.supports("group-folder")&&""!==i&&(o={name:t,host:e,group:i}),this.client.isAPIVersionCompatibleWith("v4.20191215")&&(r&&(o.usage_mode=r),n&&(o.permission=n)),this.client.supports("storage-proxy")&&(o.cloneable=s);let h=this.client.newSignedRequest("POST",""+this.urlPrefix,o);return this.client._wrapWithPromise(h)}async clone(t,e=null){let i=this.client.newSignedRequest("POST",`${this.urlPrefix}/${e}/clone`,t);return this.client._wrapWithPromise(i)}async update_folder(t,e=null){let i=this.client.newSignedRequest("POST",`${this.urlPrefix}/${e}/update-options`,t);return this.client._wrapWithPromise(i)}async list(t=null){let e=this.urlPrefix;if(t){const i={group_id:t};e+="?"+su.stringify(i)}let i=this.client.newSignedRequest("GET",e,null);return this.client._wrapWithPromise(i)}async list_hosts(){let t=this.client.newSignedRequest("GET",this.urlPrefix+"/_/hosts",null);return this.client._wrapWithPromise(t)}async info(t=null){null==t&&(t=this.name);let e=this.client.newSignedRequest("GET",`${this.urlPrefix}/${t}`,null);return this.client._wrapWithPromise(e)}async rename(t=null){const e={new_name:t};let i=this.client.newSignedRequest("POST",`${this.urlPrefix}/${this.name}/rename`,e);return this.client._wrapWithPromise(i)}async delete(t=null){null==t&&(t=this.name);let e=this.client.newSignedRequest("DELETE",`${this.urlPrefix}/${t}`,null);return this.client._wrapWithPromise(e)}async leave_invited(t=null){null==t&&(t=this.name);let e=this.client.newSignedRequest("POST",`${this.urlPrefix}/${t}/leave`,null);return this.client._wrapWithPromise(e)}async upload(t,e,i=null){null==i&&(i=this.name);let r=new FormData;r.append("src",e,t);let n=this.client.newSignedRequest("POST",`${this.urlPrefix}/${i}/upload`,r);return this.client._wrapWithPromise(n)}async uploadFormData(t,e=null){let i=this.client.newSignedRequest("POST",`${this.urlPrefix}/${e}/upload`,t);return this.client._wrapWithPromise(i)}async create_upload_session(t,e,i=null){null==i&&(i=this.name);let r,n={path:t,size:e.size};r=this.client._apiVersionMajor<6?`${this.urlPrefix}/${i}/create_upload_session`:`${this.urlPrefix}/${i}/request-upload`;const s=this.client.newSignedRequest("POST",r,n),o=await this.client._wrapWithPromise(s),h=o.token;let a;return this.client._apiVersionMajor<6?(a=this.client._config.endpoint,"SESSION"===this.client._config.connectionMode&&(a+="/func"),a+=`${this.urlPrefix}/_/tus/upload/${h}`):a=`${o.url}?token=${h}`,Promise.resolve(a)}async mkdir(t,e=null,i=null,r=null){null==e&&(e=this.name);const n={path:t};i&&(n.parents=i),r&&(n.exist_ok=r);const s=this.client.newSignedRequest("POST",`${this.urlPrefix}/${e}/mkdir`,n);return this.client._wrapWithPromise(s)}async rename_file(t,e,i=null,r=!1){let n;null==i&&(i=this.name),n=this.client.isAPIVersionCompatibleWith("v6.20200815")?{target_path:t,new_name:e,is_dir:r}:{target_path:t,new_name:e};let s=this.client.newSignedRequest("POST",`${this.urlPrefix}/${i}/rename_file`,n);return this.client._wrapWithPromise(s)}async delete_files(t,e=!1,i=null){null==i&&(i=this.name),null==e&&(e=!1);let r={files:t,recursive:e},n=this.client.newSignedRequest("DELETE",`${this.urlPrefix}/${i}/delete_files`,r);return this.client._wrapWithPromise(n)}async download(t,e=!1,i=!1,r=!1){const n={file:t,archive:i},s=su.stringify(n);if(this.client._apiVersionMajor<6){const t=this.client.newSignedRequest("GET",`${this.urlPrefix}/${e}/download_single?${s}`,null);return this.client._wrapWithPromise(t,!0)}{const n=await this.request_download_token(t,e),s=`${n.url}?token=${n.token}&archive=${i}&no_cache=${r}`;return fetch(s)}}async request_download_token(t,e=!1,i=!1){let r,n={file:t,archive:i};r=this.client._apiVersionMajor<6?`${this.urlPrefix}/${e}/request_download`:`${this.urlPrefix}/${e}/request-download`;const s=this.client.newSignedRequest("POST",r,n);return this.client._wrapWithPromise(s)}async download_with_token(t=""){let e={token:t},i=su.stringify(e),r=this.client.newSignedRequest("GET",`${this.urlPrefix}/_/download_with_token?${i}`,null);return this.client._wrapWithPromise(r,!0)}get_download_url_with_token(t=""){const e={token:t};let i=su.stringify(e);return"SESSION"===this.client._config.connectionMode?`${this.client._config.endpoint}/func${this.urlPrefix}/_/download_with_token?${i}`:`${this.client._config.endpoint}${this.urlPrefix}/_/download_with_token?${i}`}async list_files(t,e=null){null==e&&(e=this.name);let i={path:t},r=su.stringify(i),n=this.client.newSignedRequest("GET",`${this.urlPrefix}/${e}/files?${r}`,null);return this.client._wrapWithPromise(n)}async invite(t,e,i=null){null==i&&(i=this.name);let r={perm:t,user_ids:e},n=this.client.newSignedRequest("POST",`${this.urlPrefix}/${i}/invite`,r);return this.client._wrapWithPromise(n)}async invitations(){let t=this.client.newSignedRequest("GET",this.urlPrefix+"/invitations/list",null);return this.client._wrapWithPromise(t)}async accept_invitation(t){let e={inv_id:t},i=this.client.newSignedRequest("POST",this.urlPrefix+"/invitations/accept",e);return this.client._wrapWithPromise(i)}async delete_invitation(t){let e={inv_id:t},i=this.client.newSignedRequest("DELETE",this.urlPrefix+"/invitations/delete",e);return this.client._wrapWithPromise(i)}async list_invitees(t=null){let e="/folders/_/shared";null!==t&&(e=`${e}?vfolder_id=${t}`);let i=this.client.newSignedRequest("GET",e,null);return this.client._wrapWithPromise(i)}async modify_invitee_permission(t){let e=this.client.newSignedRequest("POST","/folders/_/shared",t);return this.client._wrapWithPromise(e)}async share(t,e,i=null){i||(i=this.name);const r={permission:t,emails:e},n=this.client.newSignedRequest("POST",`${this.urlPrefix}/${i}/share`,r);return this.client._wrapWithPromise(n)}async unshare(t,e=null){e||(e=this.name);const i={emails:t},r=this.client.newSignedRequest("DELETE",`${this.urlPrefix}/${e}/unshare`,i);return this.client._wrapWithPromise(r)}}class o{constructor(t){this.client=t}async list(t="ALIVE",e=["id","status","region","first_contact","cpu_cur_pct","mem_cur_bytes","available_slots","occupied_slots"],i=0){if(!1===["ALIVE","TERMINATED"].includes(t))return Promise.resolve(!1);let r="query($status: String) { agents(status: $status) { "+e.join(" ")+" }}",n={status:t};return this.client.query(r,n,null,i)}}class h{constructor(t){this.client=t}async list(t=["id","backend","capabilities"],e=20,i=0){let r=`query($offset:Int!, $limit:Int!) { storage_volume_list(limit:$limit, offset:$offset) { items { ${t.join(" ")} } total_count }}`,n={limit:e,offset:i};return this.client.query(r,n)}async detail(t="",e=["id","backend","path","fsprefix","capabilities"]){let i="query($vfolder_host: String!) { storage_volume(id: $vfolder_host) { "+e.join(" ")+" }}",r={vfolder_host:t};return this.client.query(i,r)}}class a{constructor(t,e=null){this.client=t,this.name=e}async info(t,e=["access_key","secret_key","is_active","is_admin","user_id","created_at","last_used","concurrency_limit","concurrency_used","rate_limit","num_queries","resource_policy"]){let i,r;return this.client.is_admin?(i="query($access_key: String!) { keypair(access_key: $access_key) { "+e.join(" ")+" }}",r={access_key:t}):(i="query { keypair { "+e.join(" ")+" }}",r={}),this.client.query(i,r)}async list(t=null,e=["access_key","is_active","is_admin","user_id","created_at","last_used","concurrency_used","rate_limit","num_queries","resource_policy"],i=!0){let r,n;if(this.client._apiVersionMajor<5)return r=this.client.is_admin&&null==t?`\n query($is_active: Boolean) {\n keypairs(is_active: $is_active) {\n ${e.join(" ")}\n }\n }\n `:`\n query($email: String!, $is_active: Boolean) {\n keypairs(email: $email, is_active: $is_active) {\n ${e.join(" ")}\n }\n }\n `,n={email:t||this.client.email,is_active:i},this.client.query(r,n);{const s=100,o=[];r=this.client.is_admin&&null==t?`\n query($offset:Int!, $limit:Int!, $is_active: Boolean) {\n keypair_list(offset:$offset, limit:$limit, is_active: $is_active) {\n items { ${e.join(" ")} }\n total_count\n }\n }\n `:`\n query($offset:Int!, $limit:Int!, $email: String!, $is_active: Boolean) {\n keypair_list(offset:$offset, limit:$limit, email: $email, is_active: $is_active) {\n items { ${e.join(" ")} }\n total_count\n }\n }\n `;for(let e=0;e<10*s;e+=s){n={offset:e,limit:s,email:t||this.client.email,is_active:i};const h=await this.client.query(r,n);if(o.push(...h.keypair_list.items),e>=h.keypair_list.total_count)break}const h={keypairs:o};return Promise.resolve(h)}}async add(t=null,e=!0,i=!1,r="default",n=1e3){let s=`mutation($user_id: String!, $input: KeyPairInput!) { create_keypair(user_id: $user_id, props: $input) { ok msg keypair { ${["is_active","is_admin","resource_policy","concurrency_limit","rate_limit"].join(" ")} } }}`,o={user_id:t,input:{is_active:e,is_admin:i,resource_policy:r,rate_limit:n}};return this.client.query(s,o)}async mutate(t,e){let i={access_key:t,input:e};return this.client.query("mutation($access_key: String!, $input: ModifyKeyPairInput!) { modify_keypair(access_key: $access_key, props: $input) { ok msg }}",i)}async delete(t){let e={access_key:t};return this.client.query("mutation($access_key: String!) { delete_keypair(access_key: $access_key) { ok msg }}",e)}}class u{constructor(t){this.client=t}async get(t=null,e=["name","created_at","default_for_unspecified","total_resource_slots","max_concurrent_sessions","max_containers_per_session","max_vfolder_count","max_vfolder_size","allowed_vfolder_hosts","idle_timeout"]){let i,r;return null===t?(i=`query { keypair_resource_policies { ${e.join(" ")} }}`,r={n:t}):(i=`query($n:String!) { keypair_resource_policy(name: $n) { ${e.join(" ")} }}`,r={n:t}),this.client.query(i,r)}async add(t=null,e){let i=["name","created_at","default_for_unspecified","total_resource_slots","max_concurrent_sessions","max_containers_per_session","max_vfolder_count","max_vfolder_size","allowed_vfolder_hosts","idle_timeout"];if(!0===this.client.is_admin&&null!==t){let r=`mutation($name: String!, $input: CreateKeyPairResourcePolicyInput!) { create_keypair_resource_policy(name: $name, props: $input) { ok msg resource_policy { ${i.join(" ")} } }}`,n={name:t,input:e};return this.client.query(r,n)}return Promise.resolve(!1)}async mutate(t=null,e){if(!0===this.client.is_admin&&null!==t){let i="mutation($name: String!, $input: ModifyKeyPairResourcePolicyInput!) { modify_keypair_resource_policy(name: $name, props: $input) { ok msg }}",r={name:t,input:e};return this.client.query(i,r)}return Promise.resolve(!1)}async delete(t=null){if(!0===this.client.is_superadmin&&null!==t){let e="mutation($name: String!) { delete_keypair_resource_policy(name: $name) { ok msg }}",i={name:t};return this.client.query(e,i)}return Promise.resolve(!1)}}class f{constructor(t){this.client=t}async list(t=["name","tag","registry","digest","installed","labels { key value }","resource_limits { key min max }"],e=!1,i=!1){let r,n;return this.client.supports("system-images")?!0===e?(r=`query($installed:Boolean) { images(is_installed:$installed) { ${t.join(" ")} }}`,n={installed:e,is_operation:i}):(r=`query { images { ${t.join(" ")} }}`,n={is_operation:i}):(r=`query { images { ${t.join(" ")} }}`,n={}),this.client.query(r,n)}async modifyResource(t,e,i,r){let n=[];return t=t.replace(":","%3A"),e=e.replace("/","%2F"),Object.keys(r).forEach(s=>{Object.keys(r[s]).forEach(o=>{const h=this.client.newSignedRequest("POST","/config/set",{key:`images/${t}/${e}/${i}/resource/${s}/${o}`,value:r[s][o]});n.push(this.client._wrapWithPromise(h))})}),Promise.all(n)}async modifyLabel(t,e,i,r,n){t=t.replace(":","%3A"),e=e.replace("/","%2F"),i=i.replace("/","%2F");const s=this.client.newSignedRequest("POST","/config/set",{key:`images/${t}/${e}/${i}/labels/${r}`,value:n});return this.client._wrapWithPromise(s)}async install(t,e={},i="index.docker.io"){"index.docker.io"!=i?i+="/":i="",i=i.replace(":","%3A");let r=this.client.generateSessionId();return 0===Object.keys(e).length&&(e={cpu:"1",mem:"512m"}),this.client.createIfNotExists(i+t,r,e,6e5).then(t=>this.client.destroy(r)).catch(t=>{throw t})}async uninstall(t,e="index.docker.io"){return Promise.resolve(!1)}async get(t,e,i){t=t.replace(":","%3A");const r=this.client.newSignedRequest("POST","/config/get",{key:`images/${t}/${e}/${i}/resource/`,prefix:!0});return this.client._wrapWithPromise(r)}}class l{constructor(t){this.client=t}async total_count(t="RUNNING",e="",i=1,r=0,n=""){let s,o;return s="query($limit:Int!, $offset:Int!, $ak:String, $group_id:String, $status:String) {\n compute_session_list(limit:$limit, offset:$offset, access_key:$ak, group_id:$group_id, status:$status) {\n total_count\n }\n }",o={limit:i,offset:r,status:t},""!=e&&(o.ak=e),""!=n&&(o.group_id=n),this.client.query("query($limit:Int!, $offset:Int!, $ak:String, $group_id:String, $status:String) {\n compute_session_list(limit:$limit, offset:$offset, access_key:$ak, group_id:$group_id, status:$status) {\n total_count\n }\n }",o)}async list(t=["id","name","image","created_at","terminated_at","status","status_info","occupied_slots","containers {live_stat last_stat}"],e="RUNNING",i="",r=30,n=0,s="",o=0){let h,a;return h=`query($limit:Int!, $offset:Int!, $ak:String, $group_id:String, $status:String) {\n compute_session_list(limit:$limit, offset:$offset, access_key:$ak, group_id:$group_id, status:$status) {\n items { ${(t=this.client._updateFieldCompatibilityByAPIVersion(t)).join(" ")}}\n total_count\n }\n }`,a={limit:r,offset:n,status:e},""!=i&&(a.ak=i),""!=s&&(a.group_id=s),this.client.query(h,a,null,o)}async listAll(t=["id","name","image","created_at","terminated_at","status","status_info","occupied_slots","containers {live_stat last_stat}"],e="RUNNING,RESTARTING,TERMINATING,PENDING,PREPARING,PULLING,TERMINATED,CANCELLED,ERROR",i="",r=100,n=0,s="",o=0){let h,a;const u=[];h=`query($limit:Int!, $offset:Int!, $ak:String, $group_id:String, $status:String) {\n compute_session_list(limit:$limit, offset:$offset, access_key:$ak, group_id:$group_id, status:$status) {\n items { ${(t=this.client._updateFieldCompatibilityByAPIVersion(t)).join(" ")}}\n total_count\n }\n }`;for(let f=0;f<10*r;f+=r){a={limit:r,offset:f,status:e},""!=i&&(a.access_key=i),""!=s&&(a.group_id=s);const t=await this.client.query(h,a,null,o);if(console.log(t.compute_session_list.total_count),u.push(...t.compute_session_list.items),f>=t.compute_session_list.total_count)break}return Promise.resolve(u)}async get(t=["id","session_name","lang","created_at","terminated_at","status","status_info","occupied_slots","cpu_used","io_read_bytes","io_write_bytes"],e=""){let i,r;return i=`query($session_uuid: UUID!) {\n compute_session(id:$session_uuid) {\n ${(t=this.client._updateFieldCompatibilityByAPIVersion(t)).join(" ")}\n }\n }`,r={session_uuid:e},this.client.query(i,r)}}class c{constructor(t){this.client=t,this.resources={},this._init_resource_values()}_init_resource_values(){this.resources.cpu={},this.resources.cpu.total=0,this.resources.cpu.used=0,this.resources.cpu.percent=0,this.resources.mem={},this.resources.mem.total=0,this.resources.mem.allocated=0,this.resources.mem.used=0,this.resources.gpu={},this.resources.gpu.total=0,this.resources.gpu.used=0,this.resources["cuda.device"]={},this.resources["cuda.device"].total=0,this.resources["cuda.device"].used=0,this.resources.fgpu={},this.resources.fgpu.total=0,this.resources.fgpu.used=0,this.resources["cuda.shares"]={},this.resources["cuda.shares"].total=0,this.resources["cuda.shares"].used=0,this.resources["rocm.device"]={},this.resources["rocm.device"].total=0,this.resources["rocm.device"].used=0,this.resources["tpu.device"]={},this.resources["tpu.device"].total=0,this.resources["tpu.device"].used=0,this.resources.agents={},this.resources.agents.total=0,this.resources.agents.using=0,this.agents=[]}async totalResourceInformation(t="ALIVE"){if(this.client.is_admin){let e=["id","addr","status","first_contact","cpu_cur_pct","mem_cur_bytes","occupied_slots","available_slots"];return this.client.agent.list(t,e).then(t=>(this._init_resource_values(),this.agents=t.agents,Object.keys(this.agents).map((t,e)=>{let i=this.agents[t],r=JSON.parse(i.occupied_slots),n=JSON.parse(i.available_slots);"cpu"in n&&(this.resources.cpu.total=this.resources.cpu.total+Math.floor(Number(n.cpu))),"cpu"in r&&(this.resources.cpu.used=this.resources.cpu.used+Math.floor(Number(r.cpu))),this.resources.cpu.percent=this.resources.cpu.percent+parseFloat(i.cpu_cur_pct),void 0===r.mem&&(r.mem=0),this.resources.mem.total=parseFloat(this.resources.mem.total)+parseInt(this.client.utils.changeBinaryUnit(n.mem,"b")),this.resources.mem.allocated=parseInt(this.resources.mem.allocated)+parseInt(this.client.utils.changeBinaryUnit(r.mem,"b")),this.resources.mem.used=parseInt(this.resources.mem.used)+parseInt(this.client.utils.changeBinaryUnit(i.mem_cur_bytes,"b")),"cuda.device"in n&&(this.resources["cuda.device"].total=parseInt(this.resources["cuda.device"].total)+Math.floor(Number(n["cuda.device"]))),"cuda.device"in r&&(this.resources["cuda.device"].used=parseInt(this.resources["cuda.device"].used)+Math.floor(Number(r["cuda.device"]))),"cuda.shares"in n&&(this.resources["cuda.shares"].total=parseFloat(this.resources["cuda.shares"].total)+parseFloat(n["cuda.shares"])),"cuda.shares"in r&&(this.resources["cuda.shares"].used=parseFloat(this.resources["cuda.shares"].used)+parseFloat(r["cuda.shares"])),"rocm.device"in n&&(this.resources["rocm.device"].total=parseInt(this.resources["rocm.device"].total)+Math.floor(Number(n["rocm.device"]))),"rocm.device"in r&&(this.resources["rocm.device"].used=parseInt(this.resources["rocm.device"].used)+Math.floor(Number(r["rocm.device"]))),"tpu.device"in n&&(this.resources["tpu.device"].total=parseInt(this.resources["tpu.device"].total)+Math.floor(Number(n["tpu.device"]))),"tpu.device"in r&&(this.resources["tpu.device"].used=parseInt(this.resources["tpu.device"].used)+Math.floor(Number(r["tpu.device"]))),isNaN(this.resources.cpu.used)&&(this.resources.cpu.used=0),isNaN(this.resources.mem.used)&&(this.resources.mem.used=0),isNaN(this.resources.gpu.used)&&(this.resources.gpu.used=0),isNaN(this.resources.fgpu.used)&&(this.resources.fgpu.used=0)}),this.resources.gpu.total=this.resources["cuda.device"].total,this.resources.gpu.used=this.resources["cuda.device"].used,this.resources.fgpu.used=this.resources["cuda.shares"].used.toFixed(2),this.resources.fgpu.total=this.resources["cuda.shares"].total.toFixed(2),this.resources.agents.total=Object.keys(this.agents).length,this.resources.agents.using=Object.keys(this.agents).length,Promise.resolve(this.resources))).catch(t=>{throw t})}return Promise.resolve(!1)}async user_stats(){const t=this.client.newSignedRequest("GET","/resource/stats/user/month",null);return this.client._wrapWithPromise(t)}}class d{constructor(t){this.client=t}async list(t=!0,e=!1,i=["id","name","description","is_active","created_at","modified_at","domain_name"]){let r,n;return!0===this.client.is_admin?(r=`query($is_active:Boolean) { groups(is_active:$is_active) { ${i.join(" ")} }}`,n={is_active:t},!1!==e&&(r=`query($domain_name: String, $is_active:Boolean) { groups(domain_name: $domain_name, is_active:$is_active) { ${i.join(" ")} }}`,n={is_active:t,domain_name:e})):(r=`query($is_active:Boolean) { groups(is_active:$is_active) { ${i.join(" ")} }}`,n={is_active:t}),this.client.query(r,n)}}class p{constructor(t){this.client=t}async get(t=!1,e=["name","description","is_active","created_at","modified_at","total_resource_slots","allowed_vfolder_hosts","allowed_docker_registries","integration_id","scaling_groups"]){let i,r;if(!1!==t)return i=`query($name: String) { domain(name: $name) { ${e.join(" ")} }}`,r={name:t},this.client.query(i,r)}async list(t=["name","description","is_active","created_at","total_resource_slots","allowed_vfolder_hosts","allowed_docker_registries","integration_id"]){let e=`query { domains { ${t.join(" ")} }}`;return this.client.query(e,{})}async update(t=!1,e){if(!0===this.client.is_superadmin){let i="mutation($name: String!, $input: ModifyDomainInput!) { modify_domain(name: $name, props: $input) { ok msg }}",r={name:t,input:e};return this.client.query(i,r)}return Promise.resolve(!1)}}class m{constructor(t){this.client=t,this.urlPrefix="/resource"}attach_background_task(t){var e="/events/background-task?task_id="+t;let i=this.client.newSignedRequest("GET",e,null);return new EventSource(i.uri,{withCredentials:!0})}async rescan_images(t=""){if(!0===this.client.is_admin){let e,i;return""!==t?(t=decodeURIComponent(t),e="mutation($registry: String) { rescan_images(registry: $registry) { ok msg task_id }}",i={registry:t}):(e="mutation { rescan_images { ok msg task_id }}",i={}),this.client.query(e,i,null,6e5)}return Promise.resolve(!1)}async recalculate_usage(){if(!0===this.client.is_superadmin){let t=this.client.newSignedRequest("POST",this.urlPrefix+"/recalculate-usage",null);return this.client._wrapWithPromise(t,null,null,6e4)}}}class g{constructor(t){this.client=t}async list(t=!0,e=["username","password","need_password_change","full_name","description","is_active","domain_name","role","groups {id name}"]){let i,r;if(this.client._apiVersionMajor<5)return i=this.client.is_admin?`\n query($is_active:Boolean) {\n users(is_active:$is_active) { ${e.join(" ")} }\n }\n `:`\n query {\n users { ${e.join(" ")} }\n }\n `,r=this.client.is_admin?{is_active:t}:{},this.client.query(i,r);{const n=100,s=[];i=this.client.is_admin?`\n query($offset:Int!, $limit:Int!, $is_active:Boolean) {\n user_list(offset:$offset, limit:$limit, is_active:$is_active) {\n items { ${e.join(" ")} }\n total_count\n }\n }\n `:`\n query($offset:Int!, $limit:Int!) {\n user_list(offset:$offset, limit:$limit) {\n items { ${e.join(" ")} }\n total_count\n }\n }\n `;for(let e=0;e<10*n;e+=n){r=this.client.is_admin?{offset:e,limit:n,is_active:t}:{offset:e,limit:n};const o=await this.client.query(i,r);if(s.push(...o.user_list.items),e>=o.user_list.total_count)break}const o={users:s};return Promise.resolve(o)}}async get(t,e=["email","username","password","need_password_change","full_name","description","is_active","domain_name","role","groups {id name}"]){let i,r;return!0===this.client.is_admin?(i=`query($email:String) { user (email:$email) { ${e.join(" ")} }}`,r={email:t}):(i=`query { user { ${e.join(" ")} }}`,r={}),this.client.query(i,r)}async create(t=null,e){let i=["username","password","need_password_change","full_name","description","is_active","domain_name","role","groups{id, name}"];if(!0===this.client.is_admin){let r=`mutation($email: String!, $input: UserInput!) { create_user(email: $email, props: $input) { ok msg user { ${i.join(" ")} } }}`,n={email:t,input:e};return this.client.query(r,n)}return Promise.resolve(!1)}async update(t=null,e){if(!0===this.client.is_superadmin){let i="mutation($email: String!, $input: ModifyUserInput!) { modify_user(email: $email, props: $input) { ok msg }}",r={email:t,input:e};return this.client.query(i,r)}return Promise.resolve(!1)}async delete(t){if(!0===this.client.is_superadmin){let e="mutation($email: String!) { delete_user(email: $email) { ok msg }}",i={email:t};return this.client.query(e,i)}return Promise.resolve(!1)}}class v{constructor(t){this.client=t}async list_available(){if(!0===this.client.is_superadmin){const t=`query { scaling_groups { ${["name","description","is_active","created_at","driver","driver_opts","scheduler","scheduler_opts"].join(" ")} }}`,e={};return this.client.query(t,e)}return Promise.resolve(!1)}async list(t="default"){const e="/scaling-groups?group="+t,i=this.client.newSignedRequest("GET",e,null);return this.client._wrapWithPromise(i)}async create(t,e=""){let i={name:t,input:{description:e,is_active:!0,driver:"static",scheduler:"fifo",driver_opts:"{}",scheduler_opts:"{}"}};return this.client.query("mutation($name: String!, $input: ScalingGroupInput!) { create_scaling_group(name: $name, props: $input) { ok msg }}",i)}async associate_domain(t,e){let i={domain:t,scaling_group:e};return this.client.query("mutation($domain: String!, $scaling_group: String!) { associate_scaling_group_with_domain(domain: $domain, scaling_group: $scaling_group) { ok msg }}",i)}async update(t,e){let i={name:t,input:e};return this.client.query("mutation($name: String!, $input: ModifyScalingGroupInput!) { modify_scaling_group(name: $name, props: $input) { ok msg }}",i)}async delete(t){let e={name:t};return this.client.query("mutation($name: String!) { delete_scaling_group(name: $name) { ok msg }}",e)}}class y{constructor(t){this.client=t}async list(){const t=this.client.newSignedRequest("POST","/config/get",{key:"config/docker/registry",prefix:!0});return this.client._wrapWithPromise(t)}async add(t,e){let i="config/docker/registry/"+(t=encodeURIComponent(t));const r=this.client.newSignedRequest("POST","/config/set",{key:i,value:e});return this.client._wrapWithPromise(r)}async delete(t){t=encodeURIComponent(t);const e=this.client.newSignedRequest("POST","/config/delete",{key:"config/docker/registry/"+t,prefix:!0});return this.client._wrapWithPromise(e)}}class b{constructor(t){this.client=t,this.config=null}async list(t=""){t="config/"+t;const e=this.client.newSignedRequest("POST","/config/get",{key:t,prefix:!0});return this.client._wrapWithPromise(e)}async get(t){t="config/"+t;const e=this.client.newSignedRequest("POST","/config/get",{key:t,prefix:!1});return this.client._wrapWithPromise(e)}async set(t,e){t="config/"+t;const i=this.client.newSignedRequest("POST","/config/set",{key:t,value:e});return this.client._wrapWithPromise(i)}async delete(t,e=!1){t="config/"+t;const i=this.client.newSignedRequest("POST","/config/delete",{key:""+t,prefix:e});return this.client._wrapWithPromise(i)}}class M{constructor(t){this.client=t,this.config=null}async get_announcement(){const t=this.client.newSignedRequest("GET","/manager/announcement",null);return this.client._wrapWithPromise(t)}async update_announcement(t=!0,e){const i=this.client.newSignedRequest("POST","/manager/announcement",{enabled:t,message:e});return this.client._wrapWithPromise(i)}}class w{constructor(t){this.client=t,this.config=null}async get_bootstrap_script(){if(!this.client._config.accessKey)throw"Your access key is not set";const t=this.client.newSignedRequest("GET","/user-config/bootstrap-script");return this.client._wrapWithPromise(t)}async update_bootstrap_script(t){const e=this.client.newSignedRequest("POST","/user-config/bootstrap-script",{script:t});return this.client._wrapWithPromise(e)}async create(t="",e){if(!this.client._config.accessKey)throw"Your access key is not set";let i={path:e,data:t,permission:"644"};const r=this.client.newSignedRequest("POST","/user-config/dotfiles",i);return this.client._wrapWithPromise(r)}async get(){if(!this.client._config.accessKey)throw"Your access key is not set";const t=this.client.newSignedRequest("GET","/user-config/dotfiles");return this.client._wrapWithPromise(t)}async update(t,e){let i={data:t,path:e,permission:"644"};const r=this.client.newSignedRequest("PATCH","/user-config/dotfiles",i);return this.client._wrapWithPromise(r)}async delete(t){let e={path:t};const i=this.client.newSignedRequest("DELETE","/user-config/dotfiles",e);return this.client._wrapWithPromise(i)}}class _{constructor(t){this.client=t,this.config=null}async getLicense(){if(!0!==this.client.is_superadmin)return Promise.resolve(!1);if(void 0===this.certificate){const t=this.client.newSignedRequest("GET","/license");let e=await this.client._wrapWithPromise(t);return this.certificate=e.certificate,"valid"===e.status?this.certificate.valid=!0:this.certificate.valid=!1,Promise.resolve(this.certificate)}}}class S{constructor(t){this.client=t,this.config=null}async ping(){const t=this.client.newSignedRequest("GET","/cloud/ping");return this.client._wrapWithPromise(t)}async verify_email(t){const e={verification_code:t},i=this.client.newSignedRequest("POST","/cloud/verify-email",e);return this.client._wrapWithPromise(i)}async send_verification_email(t){const e={email:t},i=this.client.newSignedRequest("POST","/cloud/send-verification-email",e);return this.client._wrapWithPromise(i)}async send_password_change_email(t){const e={email:t},i=this.client.newSignedRequest("POST","/cloud/send-password-change-email",e);return this.client._wrapWithPromise(i)}async change_password(t,e,i){const r={email:t,password:e,token:i},n=this.client.newSignedRequest("POST","/cloud/change-password",r);return this.client._wrapWithPromise(n)}}class k{constructor(t){this.client=t}changeBinaryUnit(t,e="g",i="b"){if(void 0===t)return t;let r;const n=["b","k","m","g","t","p","auto"],s=["B","KiB","MiB","GiB","TiB","PiB"];if(!n.includes(e))return!1;if((t=t.toString()).indexOf(" ")>=0){let e=t.split(/(\s+)/);t=s.includes(e[2])?e[0]+n[s.indexOf(e[2])]:e[0]}return n.includes(t.substr(-1))?(r=t.substr(-1),t=t.slice(0,-1)):r=i,t*Math.pow(1024,Math.floor(n.indexOf(r)-n.indexOf(e)))}elapsedTime(t,e){var i=new Date(t);if(null===e)var r=new Date;else r=new Date(e);var n=Math.floor((r.getTime()-i.getTime())/1e3),s=Math.floor(n/86400);n-=86400*s;var o=Math.floor(n/3600);n-=3600*o;var h=Math.floor(n/60),a=n-=60*h,u="";return void 0!==s&&s>0&&(u=u+String(s)+" Day "),void 0!==o&&(u=u+this._padding_zeros(o,2)+":"),void 0!==h&&(u=u+this._padding_zeros(h,2)+":"),u+this._padding_zeros(a,2)+""}_padding_zeros(t,e){return(t+="").length>=e?t:new Array(e-t.length+1).join("0")+t}gqlToObject(t,e){let i={};return t.forEach((function(t){i[t[e]]=t})),i}gqlToList(t,e){let i=[];return t.forEach((function(t){i.push(t[e])})),i}}Object.defineProperty(r,"ERR_SERVER",{value:0,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(r,"ERR_RESPONSE",{value:1,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(r,"ERR_REQUEST",{value:2,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(r,"ERR_ABORT",{value:3,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(r,"ERR_TIMEOUT",{value:4,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(r,"ERR_UNKNOWN",{value:99,writable:!1,enumerable:!0,configurable:!1});const A={Client:r,ClientConfig:i};ou.backend=A,ou.Client=r,ou.ClientConfig=i,ou.BackendAIClient=r,ou.BackendAIClientConfig=i}).call(this)}.call(this,R,u({}).Buffer),ou})); \ No newline at end of file +!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).ai=t()}}((function(){for(var t=function(t){var e;return function(i){return e||t(e={exports:{},parent:i},e.exports),e.exports}},e=t((function(t,e){(function(e,n){(function(){"use strict";var o;t.exports=A,A.ReadableState=R,et.EventEmitter;var a,h=function(t,e){return t.listeners(e).length},u=M({}).Buffer,f=n.Uint8Array||function(){},l=w({});a=l&&l.debuglog?l.debuglog("stream"):function(){};var d,c,p,m=Us.getHighWaterMark,g=Ls.codes,b=g.ERR_INVALID_ARG_TYPE,y=g.ERR_STREAM_PUSH_AFTER_EOF,_=g.ERR_METHOD_NOT_IMPLEMENTED,S=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;Q(A,Rs);var E=Os.errorOrDestroy,k=["error","close","destroy","pause","resume"];function R(t,e,i){o=o||s({}),t=t||{},"boolean"!=typeof i&&(i=e instanceof o),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=m(this,t,"readableHighWaterMark",i),this.buffer=new qs,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(d||(d=v({}).StringDecoder),this.decoder=new d(t.encoding),this.encoding=t.encoding)}function A(t){if(o=o||s({}),!(this instanceof A))return new A(t);var e=this instanceof o;this._readableState=new R(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),Rs.call(this)}function x(t,e,i,r,n){a("readableAddChunk",e);var s,o=t._readableState;if(null===e)o.reading=!1,function(t,e){if(a("onEofChunk"),!e.ended){if(e.decoder){var i=e.decoder.end();i&&i.length&&(e.buffer.push(i),e.length+=e.objectMode?1:i.length)}e.ended=!0,e.sync?B(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,I(t)))}}(t,o);else if(n||(s=function(t,e){var i,r;return r=e,u.isBuffer(r)||r instanceof f||"string"==typeof e||void 0===e||t.objectMode||(i=new b("chunk",["string","Buffer","Uint8Array"],e)),i}(o,e)),s)E(t,s);else if(o.objectMode||e&&e.length>0)if("string"==typeof e||o.objectMode||Object.getPrototypeOf(e)===u.prototype||(e=function(t){return u.from(t)}(e)),r)o.endEmitted?E(t,new S):T(t,o,e,!0);else if(o.ended)E(t,new y);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!i?(e=o.decoder.write(e),o.objectMode||0!==e.length?T(t,o,e,!1):q(t,o)):T(t,o,e,!1)}else r||(o.reading=!1,q(t,o));return!o.ended&&(o.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=1073741824?t=1073741824:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function B(t){var i=t._readableState;a("emitReadable",i.needReadable,i.emittedReadable),i.needReadable=!1,i.emittedReadable||(a("emitReadable",i.flowing),i.emittedReadable=!0,e.nextTick(I,t))}function I(t){var e=t._readableState;a("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,N(t)}function q(t,i){i.readingMore||(i.readingMore=!0,e.nextTick(O,t,i))}function O(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function j(t){a("readable nexttick read 0"),t.read(0)}function C(t,e){a("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),N(t),e.flowing&&!e.reading&&t.read(0)}function N(t){var e=t._readableState;for(a("flow",e.flowing);e.flowing&&null!==t.read(););}function D(t,e){return 0===e.length?null:(e.objectMode?i=e.buffer.shift():!t||t>=e.length?(i=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):i=e.buffer.consume(t,e.decoder),i);var i}function U(t){var i=t._readableState;a("endReadable",i.endEmitted),i.endEmitted||(i.ended=!0,e.nextTick($,i,t))}function $(t,e){if(a("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var i=e._writableState;(!i||i.autoDestroy&&i.finished)&&e.destroy()}}function z(t,e){for(var i=0,r=t.length;i=e.highWaterMark:e.length>0)||e.ended))return a("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?U(this):B(this),null;if(0===(t=P(t,e))&&e.ended)return 0===e.length&&U(this),null;var r,n=e.needReadable;return a("need readable",n),(0===e.length||e.length-t0?D(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),i!==t&&e.ended&&U(this)),null!==r&&this.emit("data",r),r},A.prototype._read=function(t){E(this,new _("_read()"))},A.prototype.pipe=function(t,i){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=t;break;case 1:n.pipes=[n.pipes,t];break;default:n.pipes.push(t)}n.pipesCount+=1,a("pipe count=%d opts=%j",n.pipesCount,i);var s=i&&!1===i.end||t===e.stdout||t===e.stderr?m:o;function o(){a("onend"),t.end()}n.endEmitted?e.nextTick(s):r.once("end",s),t.on("unpipe",(function e(i,s){a("onunpipe"),i===r&&s&&!1===s.hasUnpiped&&(s.hasUnpiped=!0,a("cleanup"),t.removeListener("close",c),t.removeListener("finish",p),t.removeListener("drain",u),t.removeListener("error",d),t.removeListener("unpipe",e),r.removeListener("end",o),r.removeListener("end",m),r.removeListener("data",l),f=!0,!n.awaitDrain||t._writableState&&!t._writableState.needDrain||u())}));var u=function(t){return function(){var e=t._readableState;a("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&h(t,"data")&&(e.flowing=!0,N(t))}}(r);t.on("drain",u);var f=!1;function l(e){a("ondata");var i=t.write(e);a("dest.write",i),!1===i&&((1===n.pipesCount&&n.pipes===t||n.pipesCount>1&&-1!==z(n.pipes,t))&&!f&&(a("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function d(e){a("onerror",e),m(),t.removeListener("error",d),0===h(t,"error")&&E(t,e)}function c(){t.removeListener("finish",p),m()}function p(){a("onfinish"),t.removeListener("close",c),m()}function m(){a("unpipe"),r.unpipe(t)}return r.on("data",l),function(t,e,i){if("function"==typeof t.prependListener)return t.prependListener("error",i);t._events&&t._events.error?Array.isArray(t._events.error)?t._events.error.unshift(i):t._events.error=[i,t._events.error]:t.on("error",i)}(t,0,d),t.once("close",c),t.once("finish",p),t.emit("pipe",r),n.flowing||(a("pipe resume"),r.resume()),t},A.prototype.unpipe=function(t){var e=this._readableState,i={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,i)),this;if(!t){var r=e.pipes,n=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var s=0;s0,!1!==n.flowing&&this.resume()):"readable"===t&&(n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,a("on readable",n.length,n.reading),n.length?B(this):n.reading||e.nextTick(j,this))),r},A.prototype.addListener=A.prototype.on,A.prototype.removeListener=function(t,i){var r=Rs.prototype.removeListener.call(this,t,i);return"readable"===t&&e.nextTick(L,this),r},A.prototype.removeAllListeners=function(t){var i=Rs.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||e.nextTick(L,this),i},A.prototype.resume=function(){var t=this._readableState;return t.flowing||(a("resume"),t.flowing=!t.readableListening,function(t,i){i.resumeScheduled||(i.resumeScheduled=!0,e.nextTick(C,t,i))}(this,t)),t.paused=!1,this},A.prototype.pause=function(){return a("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(a("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},A.prototype.wrap=function(t){var e=this,i=this._readableState,r=!1;for(var n in t.on("end",(function(){if(a("wrapped end"),i.decoder&&!i.ended){var t=i.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(n){a("wrapped data"),i.decoder&&(n=i.decoder.write(n)),i.objectMode&&null==n||(i.objectMode||n&&n.length)&&(e.push(n)||(r=!0,t.pause()))})),t)void 0===this[n]&&"function"==typeof t[n]&&(this[n]=function(e){return function(){return t[e].apply(t,arguments)}}(n));for(var s=0;s-1))throw new y(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(E.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(E.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),E.prototype._write=function(t,e,i){i(new c("_write()"))},E.prototype._writev=null,E.prototype.end=function(t,i,r){var n=this._writableState;return"function"==typeof t?(r=t,t=null,i=null):"function"==typeof i&&(r=i,i=null),null!=t&&this.write(t,i),n.corked&&(n.corked=1,this.uncork()),n.ending||function(t,i,r){i.ending=!0,P(t,i),r&&(i.finished?e.nextTick(r):t.once("finish",r)),i.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(E.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(E.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),E.prototype.destroy=Os.destroy,E.prototype._undestroy=Os.undestroy,E.prototype._destroy=function(t,e){e(t)}}).call(this)}).call(this,D,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})})),a=t((function(t,e){(function(e,i){(function(){"use strict";var r;t.exports=A,A.ReadableState=R,et.EventEmitter;var n,s=function(t,e){return t.listeners(e).length},o=M({}).Buffer,a=i.Uint8Array||function(){},f=w({});n=f&&f.debuglog?f.debuglog("stream"):function(){};var d,c,p,m=Ni.getHighWaterMark,g=qi.codes,b=g.ERR_INVALID_ARG_TYPE,y=g.ERR_STREAM_PUSH_AFTER_EOF,_=g.ERR_METHOD_NOT_IMPLEMENTED,S=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;Q(A,Ei);var E=Ii.errorOrDestroy,k=["error","close","destroy","pause","resume"];function R(t,e,i){r=r||l({}),t=t||{},"boolean"!=typeof i&&(i=e instanceof r),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=m(this,t,"readableHighWaterMark",i),this.buffer=new Bi,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(d||(d=v({}).StringDecoder),this.decoder=new d(t.encoding),this.encoding=t.encoding)}function A(t){if(r=r||l({}),!(this instanceof A))return new A(t);var e=this instanceof r;this._readableState=new R(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),Ei.call(this)}function x(t,e,i,r,s){n("readableAddChunk",e);var h,u=t._readableState;if(null===e)u.reading=!1,function(t,e){if(n("onEofChunk"),!e.ended){if(e.decoder){var i=e.decoder.end();i&&i.length&&(e.buffer.push(i),e.length+=e.objectMode?1:i.length)}e.ended=!0,e.sync?B(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,I(t)))}}(t,u);else if(s||(h=function(t,e){var i,r;return r=e,o.isBuffer(r)||r instanceof a||"string"==typeof e||void 0===e||t.objectMode||(i=new b("chunk",["string","Buffer","Uint8Array"],e)),i}(u,e)),h)E(t,h);else if(u.objectMode||e&&e.length>0)if("string"==typeof e||u.objectMode||Object.getPrototypeOf(e)===o.prototype||(e=function(t){return o.from(t)}(e)),r)u.endEmitted?E(t,new S):T(t,u,e,!0);else if(u.ended)E(t,new y);else{if(u.destroyed)return!1;u.reading=!1,u.decoder&&!i?(e=u.decoder.write(e),u.objectMode||0!==e.length?T(t,u,e,!1):q(t,u)):T(t,u,e,!1)}else r||(u.reading=!1,q(t,u));return!u.ended&&(u.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=1073741824?t=1073741824:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function B(t){var i=t._readableState;n("emitReadable",i.needReadable,i.emittedReadable),i.needReadable=!1,i.emittedReadable||(n("emitReadable",i.flowing),i.emittedReadable=!0,e.nextTick(I,t))}function I(t){var e=t._readableState;n("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,N(t)}function q(t,i){i.readingMore||(i.readingMore=!0,e.nextTick(O,t,i))}function O(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function j(t){n("readable nexttick read 0"),t.read(0)}function C(t,e){n("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),N(t),e.flowing&&!e.reading&&t.read(0)}function N(t){var e=t._readableState;for(n("flow",e.flowing);e.flowing&&null!==t.read(););}function D(t,e){return 0===e.length?null:(e.objectMode?i=e.buffer.shift():!t||t>=e.length?(i=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):i=e.buffer.consume(t,e.decoder),i);var i}function U(t){var i=t._readableState;n("endReadable",i.endEmitted),i.endEmitted||(i.ended=!0,e.nextTick($,i,t))}function $(t,e){if(n("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var i=e._writableState;(!i||i.autoDestroy&&i.finished)&&e.destroy()}}function z(t,e){for(var i=0,r=t.length;i=e.highWaterMark:e.length>0)||e.ended))return n("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?U(this):B(this),null;if(0===(t=P(t,e))&&e.ended)return 0===e.length&&U(this),null;var r,s=e.needReadable;return n("need readable",s),(0===e.length||e.length-t0?D(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),i!==t&&e.ended&&U(this)),null!==r&&this.emit("data",r),r},A.prototype._read=function(t){E(this,new _("_read()"))},A.prototype.pipe=function(t,i){var r=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=t;break;case 1:o.pipes=[o.pipes,t];break;default:o.pipes.push(t)}o.pipesCount+=1,n("pipe count=%d opts=%j",o.pipesCount,i);var a=i&&!1===i.end||t===e.stdout||t===e.stderr?m:h;function h(){n("onend"),t.end()}o.endEmitted?e.nextTick(a):r.once("end",a),t.on("unpipe",(function e(i,s){n("onunpipe"),i===r&&s&&!1===s.hasUnpiped&&(s.hasUnpiped=!0,n("cleanup"),t.removeListener("close",c),t.removeListener("finish",p),t.removeListener("drain",u),t.removeListener("error",d),t.removeListener("unpipe",e),r.removeListener("end",h),r.removeListener("end",m),r.removeListener("data",l),f=!0,!o.awaitDrain||t._writableState&&!t._writableState.needDrain||u())}));var u=function(t){return function(){var e=t._readableState;n("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&s(t,"data")&&(e.flowing=!0,N(t))}}(r);t.on("drain",u);var f=!1;function l(e){n("ondata");var i=t.write(e);n("dest.write",i),!1===i&&((1===o.pipesCount&&o.pipes===t||o.pipesCount>1&&-1!==z(o.pipes,t))&&!f&&(n("false write response, pause",o.awaitDrain),o.awaitDrain++),r.pause())}function d(e){n("onerror",e),m(),t.removeListener("error",d),0===s(t,"error")&&E(t,e)}function c(){t.removeListener("finish",p),m()}function p(){n("onfinish"),t.removeListener("close",c),m()}function m(){n("unpipe"),r.unpipe(t)}return r.on("data",l),function(t,e,i){if("function"==typeof t.prependListener)return t.prependListener("error",i);t._events&&t._events.error?Array.isArray(t._events.error)?t._events.error.unshift(i):t._events.error=[i,t._events.error]:t.on("error",i)}(t,0,d),t.once("close",c),t.once("finish",p),t.emit("pipe",r),o.flowing||(n("pipe resume"),r.resume()),t},A.prototype.unpipe=function(t){var e=this._readableState,i={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,i)),this;if(!t){var r=e.pipes,n=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var s=0;s0,!1!==s.flowing&&this.resume()):"readable"===t&&(s.endEmitted||s.readableListening||(s.readableListening=s.needReadable=!0,s.flowing=!1,s.emittedReadable=!1,n("on readable",s.length,s.reading),s.length?B(this):s.reading||e.nextTick(j,this))),r},A.prototype.addListener=A.prototype.on,A.prototype.removeListener=function(t,i){var r=Ei.prototype.removeListener.call(this,t,i);return"readable"===t&&e.nextTick(L,this),r},A.prototype.removeAllListeners=function(t){var i=Ei.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||e.nextTick(L,this),i},A.prototype.resume=function(){var t=this._readableState;return t.flowing||(n("resume"),t.flowing=!t.readableListening,function(t,i){i.resumeScheduled||(i.resumeScheduled=!0,e.nextTick(C,t,i))}(this,t)),t.paused=!1,this},A.prototype.pause=function(){return n("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(n("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},A.prototype.wrap=function(t){var e=this,i=this._readableState,r=!1;for(var s in t.on("end",(function(){if(n("wrapped end"),i.decoder&&!i.ended){var t=i.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(s){n("wrapped data"),i.decoder&&(s=i.decoder.write(s)),i.objectMode&&null==s||(i.objectMode||s&&s.length)&&(e.push(s)||(r=!0,t.pause()))})),t)void 0===this[s]&&"function"==typeof t[s]&&(this[s]=function(e){return function(){return t[e].apply(t,arguments)}}(s));for(var o=0;o-1))throw new y(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(E.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(E.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),E.prototype._write=function(t,e,i){i(new c("_write()"))},E.prototype._writev=null,E.prototype.end=function(t,i,r){var n=this._writableState;return"function"==typeof t?(r=t,t=null,i=null):"function"==typeof i&&(r=i,i=null),null!=t&&this.write(t,i),n.corked&&(n.corked=1,this.uncork()),n.ending||function(t,i,r){i.ending=!0,P(t,i),r&&(i.finished?e.nextTick(r):t.once("finish",r)),i.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(E.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(E.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),E.prototype.destroy=Ii.destroy,E.prototype._undestroy=Ii.undestroy,E.prototype._destroy=function(t,e){e(t)}}).call(this)}).call(this,D,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})})),c=t((function(t,e){(function(e,i){(function(){"use strict";var r;t.exports=A,A.ReadableState=R,et.EventEmitter;var n,s=function(t,e){return t.listeners(e).length},o=M({}).Buffer,a=i.Uint8Array||function(){},h=w({});n=h&&h.debuglog?h.debuglog("stream"):function(){};var u,f,l,d=xt.getHighWaterMark,c=St.codes,g=c.ERR_INVALID_ARG_TYPE,y=c.ERR_STREAM_PUSH_AFTER_EOF,_=c.ERR_METHOD_NOT_IMPLEMENTED,S=c.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;Q(A,pt);var E=_t.errorOrDestroy,k=["error","close","destroy","pause","resume"];function R(t,e,i){r=r||b({}),t=t||{},"boolean"!=typeof i&&(i=e instanceof r),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=d(this,t,"readableHighWaterMark",i),this.buffer=new Mt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(u||(u=v({}).StringDecoder),this.decoder=new u(t.encoding),this.encoding=t.encoding)}function A(t){if(r=r||b({}),!(this instanceof A))return new A(t);var e=this instanceof r;this._readableState=new R(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),pt.call(this)}function x(t,e,i,r,s){n("readableAddChunk",e);var h,u=t._readableState;if(null===e)u.reading=!1,function(t,e){if(n("onEofChunk"),!e.ended){if(e.decoder){var i=e.decoder.end();i&&i.length&&(e.buffer.push(i),e.length+=e.objectMode?1:i.length)}e.ended=!0,e.sync?B(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,I(t)))}}(t,u);else if(s||(h=function(t,e){var i,r;return r=e,o.isBuffer(r)||r instanceof a||"string"==typeof e||void 0===e||t.objectMode||(i=new g("chunk",["string","Buffer","Uint8Array"],e)),i}(u,e)),h)E(t,h);else if(u.objectMode||e&&e.length>0)if("string"==typeof e||u.objectMode||Object.getPrototypeOf(e)===o.prototype||(e=function(t){return o.from(t)}(e)),r)u.endEmitted?E(t,new S):T(t,u,e,!0);else if(u.ended)E(t,new y);else{if(u.destroyed)return!1;u.reading=!1,u.decoder&&!i?(e=u.decoder.write(e),u.objectMode||0!==e.length?T(t,u,e,!1):q(t,u)):T(t,u,e,!1)}else r||(u.reading=!1,q(t,u));return!u.ended&&(u.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=1073741824?t=1073741824:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function B(t){var i=t._readableState;n("emitReadable",i.needReadable,i.emittedReadable),i.needReadable=!1,i.emittedReadable||(n("emitReadable",i.flowing),i.emittedReadable=!0,e.nextTick(I,t))}function I(t){var e=t._readableState;n("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,N(t)}function q(t,i){i.readingMore||(i.readingMore=!0,e.nextTick(O,t,i))}function O(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function j(t){n("readable nexttick read 0"),t.read(0)}function C(t,e){n("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),N(t),e.flowing&&!e.reading&&t.read(0)}function N(t){var e=t._readableState;for(n("flow",e.flowing);e.flowing&&null!==t.read(););}function D(t,e){return 0===e.length?null:(e.objectMode?i=e.buffer.shift():!t||t>=e.length?(i=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):i=e.buffer.consume(t,e.decoder),i);var i}function U(t){var i=t._readableState;n("endReadable",i.endEmitted),i.endEmitted||(i.ended=!0,e.nextTick($,i,t))}function $(t,e){if(n("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var i=e._writableState;(!i||i.autoDestroy&&i.finished)&&e.destroy()}}function z(t,e){for(var i=0,r=t.length;i=e.highWaterMark:e.length>0)||e.ended))return n("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?U(this):B(this),null;if(0===(t=P(t,e))&&e.ended)return 0===e.length&&U(this),null;var r,s=e.needReadable;return n("need readable",s),(0===e.length||e.length-t0?D(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),i!==t&&e.ended&&U(this)),null!==r&&this.emit("data",r),r},A.prototype._read=function(t){E(this,new _("_read()"))},A.prototype.pipe=function(t,i){var r=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=t;break;case 1:o.pipes=[o.pipes,t];break;default:o.pipes.push(t)}o.pipesCount+=1,n("pipe count=%d opts=%j",o.pipesCount,i);var a=i&&!1===i.end||t===e.stdout||t===e.stderr?m:h;function h(){n("onend"),t.end()}o.endEmitted?e.nextTick(a):r.once("end",a),t.on("unpipe",(function e(i,s){n("onunpipe"),i===r&&s&&!1===s.hasUnpiped&&(s.hasUnpiped=!0,n("cleanup"),t.removeListener("close",c),t.removeListener("finish",p),t.removeListener("drain",u),t.removeListener("error",d),t.removeListener("unpipe",e),r.removeListener("end",h),r.removeListener("end",m),r.removeListener("data",l),f=!0,!o.awaitDrain||t._writableState&&!t._writableState.needDrain||u())}));var u=function(t){return function(){var e=t._readableState;n("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&s(t,"data")&&(e.flowing=!0,N(t))}}(r);t.on("drain",u);var f=!1;function l(e){n("ondata");var i=t.write(e);n("dest.write",i),!1===i&&((1===o.pipesCount&&o.pipes===t||o.pipesCount>1&&-1!==z(o.pipes,t))&&!f&&(n("false write response, pause",o.awaitDrain),o.awaitDrain++),r.pause())}function d(e){n("onerror",e),m(),t.removeListener("error",d),0===s(t,"error")&&E(t,e)}function c(){t.removeListener("finish",p),m()}function p(){n("onfinish"),t.removeListener("close",c),m()}function m(){n("unpipe"),r.unpipe(t)}return r.on("data",l),function(t,e,i){if("function"==typeof t.prependListener)return t.prependListener("error",i);t._events&&t._events.error?Array.isArray(t._events.error)?t._events.error.unshift(i):t._events.error=[i,t._events.error]:t.on("error",i)}(t,0,d),t.once("close",c),t.once("finish",p),t.emit("pipe",r),o.flowing||(n("pipe resume"),r.resume()),t},A.prototype.unpipe=function(t){var e=this._readableState,i={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,i)),this;if(!t){var r=e.pipes,n=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var s=0;s0,!1!==s.flowing&&this.resume()):"readable"===t&&(s.endEmitted||s.readableListening||(s.readableListening=s.needReadable=!0,s.flowing=!1,s.emittedReadable=!1,n("on readable",s.length,s.reading),s.length?B(this):s.reading||e.nextTick(j,this))),r},A.prototype.addListener=A.prototype.on,A.prototype.removeListener=function(t,i){var r=pt.prototype.removeListener.call(this,t,i);return"readable"===t&&e.nextTick(L,this),r},A.prototype.removeAllListeners=function(t){var i=pt.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||e.nextTick(L,this),i},A.prototype.resume=function(){var t=this._readableState;return t.flowing||(n("resume"),t.flowing=!t.readableListening,function(t,i){i.resumeScheduled||(i.resumeScheduled=!0,e.nextTick(C,t,i))}(this,t)),t.paused=!1,this},A.prototype.pause=function(){return n("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(n("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},A.prototype.wrap=function(t){var e=this,i=this._readableState,r=!1;for(var s in t.on("end",(function(){if(n("wrapped end"),i.decoder&&!i.ended){var t=i.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(s){n("wrapped data"),i.decoder&&(s=i.decoder.write(s)),i.objectMode&&null==s||(i.objectMode||s&&s.length)&&(e.push(s)||(r=!0,t.pause()))})),t)void 0===this[s]&&"function"==typeof t[s]&&(this[s]=function(e){return function(){return t[e].apply(t,arguments)}}(s));for(var o=0;o>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function o(t){var e=this.lastTotal-this.lastNeed,i=function(t,e,i){if(128!=(192&e[0]))return t.lastNeed=0,"\ufffd";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"\ufffd";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"\ufffd"}}(this,t);return void 0!==i?i:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function a(t,e){if((t.length-e)%2==0){var i=t.toString("utf16le",e);if(i){var r=i.charCodeAt(i.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],i.slice(0,-1)}return i}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function h(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var i=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,i)}return e}function u(t,e){var i=(t.length-e)%3;return 0===i?t.toString("base64",e):(this.lastNeed=3-i,this.lastTotal=3,1===i?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-i))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function l(t){return t.toString(this.encoding)}function d(t){return t&&t.length?this.write(t):""}e.StringDecoder=n,n.prototype.write=function(t){if(0===t.length)return"";var e,i;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";i=this.lastNeed,this.lastNeed=0}else i=0;return i=0?(n>0&&(t.lastNeed=n-1),n):--r=0?(n>0&&(t.lastNeed=n-2),n):--r=0?(n>0&&(2===n?n=0:t.lastNeed=n-3),n):0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=i;var r=t.length-(i-this.lastNeed);return t.copy(this.lastChar,0,r),t.toString("utf8",e,r)},n.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}})),b=t((function(t,e){(function(e){(function(){"use strict";var i=Object.keys||function(t){var e=[];for(var i in t)e.push(i);return e};t.exports=h;var r=c({}),n=y({});Q(h,r);for(var s=i(n.prototype),o=0;o-1))throw new y(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(E.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(E.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),E.prototype._write=function(t,e,i){i(new d("_write()"))},E.prototype._writev=null,E.prototype.end=function(t,i,r){var n=this._writableState;return"function"==typeof t?(r=t,t=null,i=null):"function"==typeof i&&(r=i,i=null),null!=t&&this.write(t,i),n.corked&&(n.corked=1,this.uncork()),n.ending||function(t,i,r){i.ending=!0,P(t,i),r&&(i.finished?e.nextTick(r):t.once("finish",r)),i.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(E.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(E.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),E.prototype.destroy=_t.destroy,E.prototype._undestroy=_t.undestroy,E.prototype._destroy=function(t,e){e(t)}}).call(this)}).call(this,D,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})})),w=t((function(t,e){})),M=t((function(t,e){(function(t){(function(){"use strict";e.Buffer=i,e.SlowBuffer=function(t){return+t!=t&&(t=0),i.alloc(+t)},e.INSPECT_MAX_BYTES=50;function t(t){if(t>2147483647)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=i.prototype,e}function i(t,e,i){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return s(t)}return r(t,e,i)}function r(e,r,n){if("string"==typeof e)return function(e,r){if("string"==typeof r&&""!==r||(r="utf8"),!i.isEncoding(r))throw new TypeError("Unknown encoding: "+r);var n=0|h(e,r),s=t(n),o=s.write(e,r);return o!==n&&(s=s.slice(0,o)),s}(e,r);if(ArrayBuffer.isView(e))return o(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(j(e,ArrayBuffer)||e&&j(e.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=2147483647)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+2147483647..toString(16)+" bytes");return 0|t}function h(t,e){if(i.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||j(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var s=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return O(t).length;default:if(s)return n?-1:q(t).length;e=(""+e).toLowerCase(),s=!0}}function u(t,e,i){var r=t[e];t[e]=t[i],t[i]=r}function f(t,e,r,n,s){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),C(r=+r)&&(r=s?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(s)return-1;r=t.length-1}else if(r<0){if(!s)return-1;r=0}if("string"==typeof e&&(e=i.from(e,n)),i.isBuffer(e))return 0===e.length?-1:l(t,e,r,n,s);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):l(t,[e],r,n,s);throw new TypeError("val must be string, number or Buffer")}function l(t,e,i,r,n){var s,o=1,a=t.length,h=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;o=2,a/=2,h/=2,i/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(n){var f=-1;for(s=i;sa&&(i=a-h),s=i;s>=0;s--){for(var l=!0,d=0;dn&&(r=n):r=n;var s=e.length;r>s/2&&(r=s/2);for(var o=0;o>8,n=i%256,s.push(n),s.push(r);return s}(e,t.length-i),t,i,r)}function b(t,e,i){return 0===e&&i===t.length?_.fromByteArray(t):_.fromByteArray(t.slice(e,i))}function y(t,e,i){i=Math.min(t.length,i);for(var r=[],n=e;n239?4:u>223?3:u>191?2:1;if(n+l<=i)switch(l){case 1:u<128&&(f=u);break;case 2:128==(192&(s=t[n+1]))&&(h=(31&u)<<6|63&s)>127&&(f=h);break;case 3:s=t[n+1],o=t[n+2],128==(192&s)&&128==(192&o)&&(h=(15&u)<<12|(63&s)<<6|63&o)>2047&&(h<55296||h>57343)&&(f=h);break;case 4:s=t[n+1],o=t[n+2],a=t[n+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(h=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&h<1114112&&(f=h)}null===f?(f=65533,l=1):f>65535&&(f-=65536,r.push(f>>>10&1023|55296),f=56320|1023&f),r.push(f),n+=l}return function(t){var e=t.length;if(e<=w)return String.fromCharCode.apply(String,t);for(var i="",r=0;rthis.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return E(this,e,i);case"utf8":case"utf-8":return y(this,e,i);case"ascii":return M(this,e,i);case"latin1":case"binary":return S(this,e,i);case"base64":return b(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,i);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}.apply(this,arguments)},i.prototype.toLocaleString=i.prototype.toString,i.prototype.equals=function(t){if(!i.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===i.compare(this,t)},i.prototype.inspect=function(){var t="",i=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,i).replace(/(.{2})/g,"$1 ").trim(),this.length>i&&(t+=" ... "),""},i.prototype.compare=function(t,e,r,n,s){if(j(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),!i.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===s&&(s=this.length),e<0||r>t.length||n<0||s>this.length)throw new RangeError("out of range index");if(n>=s&&e>=r)return 0;if(n>=s)return-1;if(e>=r)return 1;if(this===t)return 0;for(var o=(s>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),h=Math.min(o,a),u=this.slice(n,s),f=t.slice(e,r),l=0;l>>=0,isFinite(i)?(i>>>=0,void 0===r&&(r="utf8")):(r=i,i=void 0)}var n=this.length-e;if((void 0===i||i>n)&&(i=n),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var s=!1;;)switch(r){case"hex":return d(this,t,e,i);case"utf8":case"utf-8":return c(this,t,e,i);case"ascii":return p(this,t,e,i);case"latin1":case"binary":return m(this,t,e,i);case"base64":return g(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v(this,t,e,i);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var w=4096;function M(t,e,i){var r="";i=Math.min(t.length,i);for(var n=e;nn)&&(i=n);for(var s="",o=e;oi)throw new RangeError("Trying to access beyond buffer length")}function A(t,e,r,n,s,o){if(!i.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>s||et.length)throw new RangeError("Index out of range")}function x(t,e,i,r,n,s){if(i+r>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function T(t,e,i,r,n){return e=+e,i>>>=0,n||x(t,0,i,4),B.write(t,e,i,r,23,4),i+4}function P(t,e,i,r,n){return e=+e,i>>>=0,n||x(t,0,i,8),B.write(t,e,i,r,52,8),i+8}i.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,i||R(t,e,this.length);for(var r=this[t],n=1,s=0;++s>>=0,e>>>=0,i||R(t,e,this.length);for(var r=this[t+--e],n=1;e>0&&(n*=256);)r+=this[t+--e]*n;return r},i.prototype.readUInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),this[t]},i.prototype.readUInt16LE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]|this[t+1]<<8},i.prototype.readUInt16BE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]<<8|this[t+1]},i.prototype.readUInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},i.prototype.readUInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},i.prototype.readIntLE=function(t,e,i){t>>>=0,e>>>=0,i||R(t,e,this.length);for(var r=this[t],n=1,s=0;++s=(n*=128)&&(r-=Math.pow(2,8*e)),r},i.prototype.readIntBE=function(t,e,i){t>>>=0,e>>>=0,i||R(t,e,this.length);for(var r=e,n=1,s=this[t+--r];r>0&&(n*=256);)s+=this[t+--r]*n;return s>=(n*=128)&&(s-=Math.pow(2,8*e)),s},i.prototype.readInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},i.prototype.readInt16LE=function(t,e){t>>>=0,e||R(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},i.prototype.readInt16BE=function(t,e){t>>>=0,e||R(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},i.prototype.readInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},i.prototype.readInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},i.prototype.readFloatLE=function(t,e){return t>>>=0,e||R(t,4,this.length),B.read(this,t,!0,23,4)},i.prototype.readFloatBE=function(t,e){return t>>>=0,e||R(t,4,this.length),B.read(this,t,!1,23,4)},i.prototype.readDoubleLE=function(t,e){return t>>>=0,e||R(t,8,this.length),B.read(this,t,!0,52,8)},i.prototype.readDoubleBE=function(t,e){return t>>>=0,e||R(t,8,this.length),B.read(this,t,!1,52,8)},i.prototype.writeUIntLE=function(t,e,i,r){t=+t,e>>>=0,i>>>=0,r||A(this,t,e,i,Math.pow(2,8*i)-1,0);var n=1,s=0;for(this[e]=255&t;++s>>=0,i>>>=0,r||A(this,t,e,i,Math.pow(2,8*i)-1,0);var n=i-1,s=1;for(this[e+n]=255&t;--n>=0&&(s*=256);)this[e+n]=t/s&255;return e+i},i.prototype.writeUInt8=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,1,255,0),this[e]=255&t,e+1},i.prototype.writeUInt16LE=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeUInt16BE=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeUInt32LE=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},i.prototype.writeUInt32BE=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},i.prototype.writeIntLE=function(t,e,i,r){if(t=+t,e>>>=0,!r){var n=Math.pow(2,8*i-1);A(this,t,e,i,n-1,-n)}var s=0,o=1,a=0;for(this[e]=255&t;++s>0)-a&255;return e+i},i.prototype.writeIntBE=function(t,e,i,r){if(t=+t,e>>>=0,!r){var n=Math.pow(2,8*i-1);A(this,t,e,i,n-1,-n)}var s=i-1,o=1,a=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+i},i.prototype.writeInt8=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},i.prototype.writeInt16LE=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeInt16BE=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeInt32LE=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},i.prototype.writeInt32BE=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},i.prototype.writeFloatLE=function(t,e,i){return T(this,t,e,!0,i)},i.prototype.writeFloatBE=function(t,e,i){return T(this,t,e,!1,i)},i.prototype.writeDoubleLE=function(t,e,i){return P(this,t,e,!0,i)},i.prototype.writeDoubleBE=function(t,e,i){return P(this,t,e,!1,i)},i.prototype.copy=function(t,e,r,n){if(!i.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return s},i.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!i.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var s=t.charCodeAt(0);("utf8"===n&&s<128||"latin1"===n)&&(t=s)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&i<57344){if(!n){if(i>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===r){(e-=3)>-1&&s.push(239,191,189);continue}n=i;continue}if(i<56320){(e-=3)>-1&&s.push(239,191,189),n=i;continue}i=65536+(n-55296<<10|i-56320)}else n&&(e-=3)>-1&&s.push(239,191,189);if(n=null,i<128){if((e-=1)<0)break;s.push(i)}else if(i<2048){if((e-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function O(t){return _.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function L(t,e,i,r){for(var n=0;n=e.length||n>=t.length);++n)e[n+i]=t[n];return n}function j(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function C(t){return t!=t}}).call(this)}).call(this,M({}).Buffer)})),_={toByteArray:function(t){var e,i,r=T(t),n=r[0],s=r[1],o=new k(function(t,e,i){return 3*(e+i)/4-i}(0,n,s)),a=0,h=s>0?n-4:n;for(i=0;i>16&255,o[a++]=e>>8&255,o[a++]=255&e;return 2===s&&(e=E[t.charCodeAt(i)]<<2|E[t.charCodeAt(i+1)]>>4,o[a++]=255&e),1===s&&(e=E[t.charCodeAt(i)]<<10|E[t.charCodeAt(i+1)]<<4|E[t.charCodeAt(i+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e),o},fromByteArray:function(t){for(var e,i=t.length,r=i%3,n=[],s=0,o=i-r;so?o:s+16383));return 1===r?(e=t[i-1],n.push(S[e>>2]+S[e<<4&63]+"==")):2===r&&(e=(t[i-2]<<8)+t[i-1],n.push(S[e>>10]+S[e>>4&63]+S[e<<2&63]+"=")),n.join("")}},S=[],E=[],k="undefined"!=typeof Uint8Array?Uint8Array:Array,R="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",A=0,x=R.length;A0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");return-1===i&&(i=e),[i,i===e?0:4-i%4]}function P(t,e,i){for(var r,n,s=[],o=e;o>18&63]+S[n>>12&63]+S[n>>6&63]+S[63&n]);return s.join("")}E["-".charCodeAt(0)]=62,E["_".charCodeAt(0)]=63;var B={read:function(t,e,i,r,n){var s,o,a=8*n-r-1,h=(1<>1,f=-7,l=i?n-1:0,d=i?-1:1,c=t[e+l];for(l+=d,s=c&(1<<-f)-1,c>>=-f,f+=a;f>0;s=256*s+t[e+l],l+=d,f-=8);for(o=s&(1<<-f)-1,s>>=-f,f+=r;f>0;o=256*o+t[e+l],l+=d,f-=8);if(0===s)s=1-u;else{if(s===h)return o?NaN:1/0*(c?-1:1);o+=Math.pow(2,r),s-=u}return(c?-1:1)*o*Math.pow(2,s-r)},write:function(t,e,i,r,n,s){var o,a,h,u=8*s-n-1,f=(1<>1,d=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,c=r?0:s-1,p=r?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=f):(o=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-o))<1&&(o--,h*=2),(e+=o+l>=1?d/h:d*Math.pow(2,1-l))*h>=2&&(o++,h/=2),o+l>=f?(a=0,o=f):o+l>=1?(a=(e*h-1)*Math.pow(2,n),o+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,n),o=0));n>=8;t[i+c]=255&a,c+=p,a/=256,n-=8);for(o=o<0;t[i+c]=255&o,c+=p,o/=256,u-=8);t[i+c-p]|=128*m}},I={},q=M({}),O=q.Buffer;function L(t,e){for(var i in t)e[i]=t[i]}function j(t,e,i){return O(t,e,i)}O.from&&O.alloc&&O.allocUnsafe&&O.allocUnsafeSlow?I=q:(L(q,I),I.Buffer=j),j.prototype=Object.create(O.prototype),L(O,j),j.from=function(t,e,i){if("number"==typeof t)throw new TypeError("Argument must not be a number");return O(t,e,i)},j.alloc=function(t,e,i){if("number"!=typeof t)throw new TypeError("Argument must be a number");var r=O(t);return void 0!==e?"string"==typeof i?r.fill(e,i):r.fill(e):r.fill(0),r},j.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return O(t)},j.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return q.SlowBuffer(t)};var C,N,D={},U=D={};function $(){throw new Error("setTimeout has not been defined")}function z(){throw new Error("clearTimeout has not been defined")}function W(t){if(C===setTimeout)return setTimeout(t,0);if((C===$||!C)&&setTimeout)return C=setTimeout,setTimeout(t,0);try{return C(t,0)}catch(e){try{return C.call(null,t,0)}catch(e){return C.call(this,t,0)}}}!function(){try{C="function"==typeof setTimeout?setTimeout:$}catch(t){C=$}try{N="function"==typeof clearTimeout?clearTimeout:z}catch(t){N=z}}();var F,K=[],H=!1,Z=-1;function V(){H&&F&&(H=!1,F.length?K=F.concat(K):Z=-1,K.length&&G())}function G(){if(!H){var t=W(V);H=!0;for(var e=K.length;e;){for(F=K,K=[];++Z1)for(var i=1;i4294967295)throw new RangeError("requested too many random bytes");var s=i.allocUnsafe(e);if(e>0)if(e>65536)for(var o=0;o0&&o.length>n&&!o.warned){o.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=t,h.type=e,h.count=o.length,a=h,console&&console.warn&&console.warn(a)}return t}function ft(t,e,i){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},n=function(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}.bind(r);return n.listener=i,r.wrapFn=n,n}function lt(t,e,i){var r=t._events;if(void 0===r)return[];var n=r[e];return void 0===n?[]:"function"==typeof n?i?[n.listener||n]:[n]:i?function(t){for(var e=new Array(t.length),i=0;i0&&(s=e[0]),s instanceof Error)throw s;var o=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw o.context=s,o}var a=n[t];if(void 0===a)return!1;if("function"==typeof a)rt(a,this,e);else{var h=a.length,u=ct(a,h);for(i=0;i=0;s--)if(i[s]===e||i[s].listener===e){o=i[s].listener,n=s;break}if(n<0)return this;0===n?i.shift():function(t,e){for(;e+1=0;r--)this.removeListener(t,e[r]);return this},st.prototype.listeners=function(t){return lt(this,t,!0)},st.prototype.rawListeners=function(t){return lt(this,t,!1)},st.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):dt.call(t,e)},st.prototype.listenerCount=dt,st.prototype.eventNames=function(){return this._eventsCount>0?tt(this._events):[]};var pt=et.EventEmitter;function mt(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,r)}return i}function gt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function vt(t,e){for(var i=0;i0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,i=""+e.data;e=e.next;)i+=t+e.data;return i}},{key:"concat",value:function(t){if(0===this.length)return bt.alloc(0);for(var e,i,r,n=bt.allocUnsafe(t>>>0),s=this.head,o=0;s;)e=s.data,i=n,r=o,bt.prototype.copy.call(e,i,r),o+=s.data.length,s=s.next;return n}},{key:"consume",value:function(t,e){var i;return tn.length?n.length:t;if(s===n.length?r+=n:r+=n.slice(0,t),0==(t-=s)){s===n.length?(++i,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=n.slice(s));break}++i}return this.length-=i,r}},{key:"_getBuffer",value:function(t){var e=bt.allocUnsafe(t),i=this.head,r=1;for(i.data.copy(e),t-=i.data.length;i=i.next;){var n=i.data,s=t>n.length?n.length:t;if(n.copy(e,e.length-t,0,s),0==(t-=s)){s===n.length?(++r,i.next?this.head=i.next:this.head=this.tail=null):(this.head=i,i.data=n.slice(s));break}++r}return this.length-=r,e}},{key:wt,value:function(t,e){return yt(this,function(t){for(var e=1;e2?"one of ".concat(e," ").concat(t.slice(0,i-1).join(", "),", or ")+t[i-1]:2===i?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}kt("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),kt("ERR_INVALID_ARG_TYPE",(function(t,e,i){var r,n,s,o;if("string"==typeof e&&("not ","not "===e.substr(0,"not ".length))?(r="must not be",e=e.replace(/^not /,"")):r="must be",s=t,(void 0===o||o>s.length)&&(o=s.length)," argument"===s.substring(o-" argument".length,o))n="The ".concat(t," ").concat(r," ").concat(Rt(e,"type"));else{var a=function(t,e,i){return"number"!=typeof i&&(i=0),!(i+".".length>t.length)&&-1!==t.indexOf(".",i)}(t)?"property":"argument";n='The "'.concat(t,'" ').concat(a," ").concat(r," ").concat(Rt(e,"type"))}return n+". Received type ".concat(typeof i)}),TypeError),kt("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),kt("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),kt("ERR_STREAM_PREMATURE_CLOSE","Premature close"),kt("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),kt("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),kt("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),kt("ERR_STREAM_WRITE_AFTER_END","write after end"),kt("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),kt("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),kt("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),St.codes=Et;var At=St.codes.ERR_INVALID_OPT_VALUE,xt={getHighWaterMark:function(t,e,i,r){var n=function(t,e,i){return null!=t.highWaterMark?t.highWaterMark:e?t[i]:null}(e,r,i);if(null!=n){if(!isFinite(n)||Math.floor(n)!==n||n<0)throw new At(r?i:"highWaterMark",n);return Math.floor(n)}return t.objectMode?16:16384}},Tt={};(function(t){(function(){function e(e){try{if(!t.localStorage)return!1}catch(r){return!1}var i=t.localStorage[e];return null!=i&&"true"===String(i).toLowerCase()}Tt=function(t,i){if(e("noDeprecation"))return t;var r=!1;return function(){if(!r){if(e("throwDeprecation"))throw new Error(i);e("traceDeprecation")?console.trace(i):console.warn(i),r=!0}return t.apply(this,arguments)}}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});var Pt=Nt,Bt=St.codes,It=Bt.ERR_METHOD_NOT_IMPLEMENTED,qt=Bt.ERR_MULTIPLE_CALLBACK,Ot=Bt.ERR_TRANSFORM_ALREADY_TRANSFORMING,Lt=Bt.ERR_TRANSFORM_WITH_LENGTH_0,jt=b({});function Ct(t,e){var i=this._transformState;i.transforming=!1;var r=i.writecb;if(null===r)return this.emit("error",new qt);i.writechunk=null,i.writecb=null,null!=e&&this.push(e),r(t);var n=this._readableState;n.reading=!1,(n.needReadable||n.length0,(function(t){r||(r=t),t&&s.forEach(Vt),o||(s.forEach(Vt),n(r))}))}));return e.reduce(Gt)};var Xt={},Jt=I.Buffer,Qt=Yt.Transform;function te(t){Qt.call(this),this._block=Jt.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}Q(te,Qt),te.prototype._transform=function(t,e,i){var r=null;try{this.update(t,e)}catch(n){r=n}i(r)},te.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(i){e=i}t(e)},te.prototype.update=function(t,e){if(function(t,e){if(!Jt.isBuffer(t)&&"string"!=typeof t)throw new TypeError("Data must be a string or a buffer")}(t),this._finalized)throw new Error("Digest already called");Jt.isBuffer(t)||(t=Jt.from(t,e));for(var i=this._block,r=0;this._blockOffset+t.length-r>=this._blockSize;){for(var n=this._blockOffset;n0;++s)this._length[s]+=o,(o=this._length[s]/4294967296|0)>0&&(this._length[s]-=4294967296*o);return this},te.prototype._update=function(){throw new Error("_update is not implemented")},te.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var i=0;i<4;++i)this._length[i]=0;return e},te.prototype._digest=function(){throw new Error("_digest is not implemented")},Xt=te;var ee={},ie=I.Buffer,re=new Array(16);function ne(){Xt.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function se(t,e){return t<>>32-e}function oe(t,e,i,r,n,s,o){return se(t+(e&i|~e&r)+n+s|0,o)+e|0}function ae(t,e,i,r,n,s,o){return se(t+(e&r|i&~r)+n+s|0,o)+e|0}function he(t,e,i,r,n,s,o){return se(t+(e^i^r)+n+s|0,o)+e|0}function ue(t,e,i,r,n,s,o){return se(t+(i^(e|~r))+n+s|0,o)+e|0}Q(ne,Xt),ne.prototype._update=function(){for(var t=re,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);var i=this._a,r=this._b,n=this._c,s=this._d;i=oe(i,r,n,s,t[0],3614090360,7),s=oe(s,i,r,n,t[1],3905402710,12),n=oe(n,s,i,r,t[2],606105819,17),r=oe(r,n,s,i,t[3],3250441966,22),i=oe(i,r,n,s,t[4],4118548399,7),s=oe(s,i,r,n,t[5],1200080426,12),n=oe(n,s,i,r,t[6],2821735955,17),r=oe(r,n,s,i,t[7],4249261313,22),i=oe(i,r,n,s,t[8],1770035416,7),s=oe(s,i,r,n,t[9],2336552879,12),n=oe(n,s,i,r,t[10],4294925233,17),r=oe(r,n,s,i,t[11],2304563134,22),i=oe(i,r,n,s,t[12],1804603682,7),s=oe(s,i,r,n,t[13],4254626195,12),n=oe(n,s,i,r,t[14],2792965006,17),i=ae(i,r=oe(r,n,s,i,t[15],1236535329,22),n,s,t[1],4129170786,5),s=ae(s,i,r,n,t[6],3225465664,9),n=ae(n,s,i,r,t[11],643717713,14),r=ae(r,n,s,i,t[0],3921069994,20),i=ae(i,r,n,s,t[5],3593408605,5),s=ae(s,i,r,n,t[10],38016083,9),n=ae(n,s,i,r,t[15],3634488961,14),r=ae(r,n,s,i,t[4],3889429448,20),i=ae(i,r,n,s,t[9],568446438,5),s=ae(s,i,r,n,t[14],3275163606,9),n=ae(n,s,i,r,t[3],4107603335,14),r=ae(r,n,s,i,t[8],1163531501,20),i=ae(i,r,n,s,t[13],2850285829,5),s=ae(s,i,r,n,t[2],4243563512,9),n=ae(n,s,i,r,t[7],1735328473,14),i=he(i,r=ae(r,n,s,i,t[12],2368359562,20),n,s,t[5],4294588738,4),s=he(s,i,r,n,t[8],2272392833,11),n=he(n,s,i,r,t[11],1839030562,16),r=he(r,n,s,i,t[14],4259657740,23),i=he(i,r,n,s,t[1],2763975236,4),s=he(s,i,r,n,t[4],1272893353,11),n=he(n,s,i,r,t[7],4139469664,16),r=he(r,n,s,i,t[10],3200236656,23),i=he(i,r,n,s,t[13],681279174,4),s=he(s,i,r,n,t[0],3936430074,11),n=he(n,s,i,r,t[3],3572445317,16),r=he(r,n,s,i,t[6],76029189,23),i=he(i,r,n,s,t[9],3654602809,4),s=he(s,i,r,n,t[12],3873151461,11),n=he(n,s,i,r,t[15],530742520,16),i=ue(i,r=he(r,n,s,i,t[2],3299628645,23),n,s,t[0],4096336452,6),s=ue(s,i,r,n,t[7],1126891415,10),n=ue(n,s,i,r,t[14],2878612391,15),r=ue(r,n,s,i,t[5],4237533241,21),i=ue(i,r,n,s,t[12],1700485571,6),s=ue(s,i,r,n,t[3],2399980690,10),n=ue(n,s,i,r,t[10],4293915773,15),r=ue(r,n,s,i,t[1],2240044497,21),i=ue(i,r,n,s,t[8],1873313359,6),s=ue(s,i,r,n,t[15],4264355552,10),n=ue(n,s,i,r,t[6],2734768916,15),r=ue(r,n,s,i,t[13],1309151649,21),i=ue(i,r,n,s,t[4],4149444226,6),s=ue(s,i,r,n,t[11],3174756917,10),n=ue(n,s,i,r,t[2],718787259,15),r=ue(r,n,s,i,t[9],3951481745,21),this._a=this._a+i|0,this._b=this._b+r|0,this._c=this._c+n|0,this._d=this._d+s|0},ne.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 t=ie.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t},ee=ne;var fe={},le=M({}).Buffer,de=new Array(16),ce=[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],pe=[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],me=[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],ge=[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],ve=[0,1518500249,1859775393,2400959708,2840853838],be=[1352829926,1548603684,1836072691,2053994217,0];function ye(){Xt.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function we(t,e){return t<>>32-e}function Me(t,e,i,r,n,s,o,a){return we(t+(e^i^r)+s+o|0,a)+n|0}function _e(t,e,i,r,n,s,o,a){return we(t+(e&i|~e&r)+s+o|0,a)+n|0}function Se(t,e,i,r,n,s,o,a){return we(t+((e|~i)^r)+s+o|0,a)+n|0}function Ee(t,e,i,r,n,s,o,a){return we(t+(e&r|i&~r)+s+o|0,a)+n|0}function ke(t,e,i,r,n,s,o,a){return we(t+(e^(i|~r))+s+o|0,a)+n|0}Q(ye,Xt),ye.prototype._update=function(){for(var t=de,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);for(var i=0|this._a,r=0|this._b,n=0|this._c,s=0|this._d,o=0|this._e,a=0|this._a,h=0|this._b,u=0|this._c,f=0|this._d,l=0|this._e,d=0;d<80;d+=1){var c,p;d<16?(c=Me(i,r,n,s,o,t[ce[d]],ve[0],me[d]),p=ke(a,h,u,f,l,t[pe[d]],be[0],ge[d])):d<32?(c=_e(i,r,n,s,o,t[ce[d]],ve[1],me[d]),p=Ee(a,h,u,f,l,t[pe[d]],be[1],ge[d])):d<48?(c=Se(i,r,n,s,o,t[ce[d]],ve[2],me[d]),p=Se(a,h,u,f,l,t[pe[d]],be[2],ge[d])):d<64?(c=Ee(i,r,n,s,o,t[ce[d]],ve[3],me[d]),p=_e(a,h,u,f,l,t[pe[d]],be[3],ge[d])):(c=ke(i,r,n,s,o,t[ce[d]],ve[4],me[d]),p=Me(a,h,u,f,l,t[pe[d]],be[4],ge[d])),i=o,o=s,s=we(n,10),n=r,r=c,a=l,l=f,f=we(u,10),u=h,h=p}var m=this._b+n+f|0;this._b=this._c+s+l|0,this._c=this._d+o+a|0,this._d=this._e+i+h|0,this._e=this._a+r+u|0,this._a=m},ye.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 t=le.alloc?le.alloc(20):new le(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t},fe=ye;var Re={},Ae=I.Buffer;function xe(t,e){this._block=Ae.alloc(t),this._finalSize=e,this._blockSize=t,this._len=0}xe.prototype.update=function(t,e){"string"==typeof t&&(e=e||"utf8",t=Ae.from(t,e));for(var i=this._block,r=this._blockSize,n=t.length,s=this._len,o=0;o=this._finalSize&&(this._update(this._block),this._block.fill(0));var i=8*this._len;if(i<=4294967295)this._block.writeUInt32BE(i,this._blockSize-4);else{var r=(4294967295&i)>>>0,n=(i-r)/4294967296;this._block.writeUInt32BE(n,this._blockSize-8),this._block.writeUInt32BE(r,this._blockSize-4)}this._update(this._block);var s=this._hash();return t?s.toString(t):s},xe.prototype._update=function(){throw new Error("_update must be implemented by subclass")},Re=xe;var Te,Pe=I.Buffer,Be=[1518500249,1859775393,-1894007588,-899497514],Ie=new Array(80);function qe(){this.init(),this._w=Ie,Re.call(this,64,56)}function Oe(t){return t<<30|t>>>2}function Le(t,e,i,r){return 0===t?e&i|~e&r:2===t?e&i|e&r|i&r:e^i^r}Q(qe,Re),qe.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},qe.prototype._update=function(t){for(var e,i=this._w,r=0|this._a,n=0|this._b,s=0|this._c,o=0|this._d,a=0|this._e,h=0;h<16;++h)i[h]=t.readInt32BE(4*h);for(;h<80;++h)i[h]=i[h-3]^i[h-8]^i[h-14]^i[h-16];for(var u=0;u<80;++u){var f=~~(u/20),l=0|((e=r)<<5|e>>>27)+Le(f,n,s,o)+a+i[u]+Be[f];a=o,o=s,s=Oe(n),n=r,r=l}this._a=r+this._a|0,this._b=n+this._b|0,this._c=s+this._c|0,this._d=o+this._d|0,this._e=a+this._e|0},qe.prototype._hash=function(){var t=Pe.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},Te=qe;var je,Ce=I.Buffer,Ne=[1518500249,1859775393,-1894007588,-899497514],De=new Array(80);function Ue(){this.init(),this._w=De,Re.call(this,64,56)}function $e(t){return t<<5|t>>>27}function ze(t){return t<<30|t>>>2}function We(t,e,i,r){return 0===t?e&i|~e&r:2===t?e&i|e&r|i&r:e^i^r}Q(Ue,Re),Ue.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},Ue.prototype._update=function(t){for(var e,i=this._w,r=0|this._a,n=0|this._b,s=0|this._c,o=0|this._d,a=0|this._e,h=0;h<16;++h)i[h]=t.readInt32BE(4*h);for(;h<80;++h)i[h]=(e=i[h-3]^i[h-8]^i[h-14]^i[h-16])<<1|e>>>31;for(var u=0;u<80;++u){var f=~~(u/20),l=$e(r)+We(f,n,s,o)+a+i[u]+Ne[f]|0;a=o,o=s,s=ze(n),n=r,r=l}this._a=r+this._a|0,this._b=n+this._b|0,this._c=s+this._c|0,this._d=o+this._d|0,this._e=a+this._e|0},Ue.prototype._hash=function(){var t=Ce.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},je=Ue;var Fe,Ke=I.Buffer,He=[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],Ze=new Array(64);function Ve(){this.init(),this._w=Ze,Re.call(this,64,56)}function Ge(t,e,i){return i^t&(e^i)}function Ye(t,e,i){return t&e|i&(t|e)}function Xe(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function Je(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function Qe(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}Q(Ve,Re),Ve.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},Ve.prototype._update=function(t){for(var e,i=this._w,r=0|this._a,n=0|this._b,s=0|this._c,o=0|this._d,a=0|this._e,h=0|this._f,u=0|this._g,f=0|this._h,l=0;l<16;++l)i[l]=t.readInt32BE(4*l);for(;l<64;++l)i[l]=0|(((e=i[l-2])>>>17|e<<15)^(e>>>19|e<<13)^e>>>10)+i[l-7]+Qe(i[l-15])+i[l-16];for(var d=0;d<64;++d){var c=f+Je(a)+Ge(a,h,u)+He[d]+i[d]|0,p=Xe(r)+Ye(r,n,s)|0;f=u,u=h,h=a,a=o+c|0,o=s,s=n,n=r,r=c+p|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=s+this._c|0,this._d=o+this._d|0,this._e=a+this._e|0,this._f=h+this._f|0,this._g=u+this._g|0,this._h=f+this._h|0},Ve.prototype._hash=function(){var t=Ke.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},Fe=Ve;var ti,ei=I.Buffer,ii=new Array(64);function ri(){this.init(),this._w=ii,Re.call(this,64,56)}Q(ri,Fe),ri.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},ri.prototype._hash=function(){var t=ei.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},ti=ri;var ni,si=I.Buffer,oi=[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],ai=new Array(160);function hi(){this.init(),this._w=ai,Re.call(this,128,112)}function ui(t,e,i){return i^t&(e^i)}function fi(t,e,i){return t&e|i&(t|e)}function li(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function di(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function ci(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function pi(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function mi(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function gi(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function vi(t,e){return t>>>0>>0?1:0}Q(hi,Re),hi.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},hi.prototype._update=function(t){for(var e=this._w,i=0|this._ah,r=0|this._bh,n=0|this._ch,s=0|this._dh,o=0|this._eh,a=0|this._fh,h=0|this._gh,u=0|this._hh,f=0|this._al,l=0|this._bl,d=0|this._cl,c=0|this._dl,p=0|this._el,m=0|this._fl,g=0|this._gl,v=0|this._hl,b=0;b<32;b+=2)e[b]=t.readInt32BE(4*b),e[b+1]=t.readInt32BE(4*b+4);for(;b<160;b+=2){var y=e[b-30],w=e[b-30+1],M=ci(y,w),_=pi(w,y),S=mi(y=e[b-4],w=e[b-4+1]),E=gi(w,y),k=e[b-14],R=e[b-14+1],A=e[b-32],x=e[b-32+1],T=_+R|0,P=M+k+vi(T,_)|0;P=(P=P+S+vi(T=T+E|0,E)|0)+A+vi(T=T+x|0,x)|0,e[b]=P,e[b+1]=T}for(var B=0;B<160;B+=2){P=e[B],T=e[B+1];var I=fi(i,r,n),q=fi(f,l,d),O=li(i,f),L=li(f,i),j=di(o,p),C=di(p,o),N=oi[B],D=oi[B+1],U=ui(o,a,h),$=ui(p,m,g),z=v+C|0,W=u+j+vi(z,v)|0;W=(W=(W=W+U+vi(z=z+$|0,$)|0)+N+vi(z=z+D|0,D)|0)+P+vi(z=z+T|0,T)|0;var F=L+q|0,K=O+I+vi(F,L)|0;u=h,v=g,h=a,g=m,a=o,m=p,o=s+W+vi(p=c+z|0,c)|0,s=n,c=d,n=r,d=l,r=i,l=f,i=W+K+vi(f=z+F|0,z)|0}this._al=this._al+f|0,this._bl=this._bl+l|0,this._cl=this._cl+d|0,this._dl=this._dl+c|0,this._el=this._el+p|0,this._fl=this._fl+m|0,this._gl=this._gl+g|0,this._hl=this._hl+v|0,this._ah=this._ah+i+vi(this._al,f)|0,this._bh=this._bh+r+vi(this._bl,l)|0,this._ch=this._ch+n+vi(this._cl,d)|0,this._dh=this._dh+s+vi(this._dl,c)|0,this._eh=this._eh+o+vi(this._el,p)|0,this._fh=this._fh+a+vi(this._fl,m)|0,this._gh=this._gh+h+vi(this._gl,g)|0,this._hh=this._hh+u+vi(this._hl,v)|0},hi.prototype._hash=function(){var t=si.allocUnsafe(64);function e(e,i,r){t.writeInt32BE(e,r),t.writeInt32BE(i,r+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},ni=hi;var bi,yi=I.Buffer,wi=new Array(160);function Mi(){this.init(),this._w=wi,Re.call(this,128,112)}Q(Mi,ni),Mi.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},Mi.prototype._hash=function(){var t=yi.allocUnsafe(48);function e(e,i,r){t.writeInt32BE(e,r),t.writeInt32BE(i,r+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t},bi=Mi;var _i,Si;(Si=_i=function(t){t=t.toLowerCase();var e=Si[t];if(!e)throw new Error(t+" is not supported (we accept pull requests)");return new e}).sha=Te,Si.sha1=je,Si.sha224=ti,Si.sha256=Fe,Si.sha384=bi,Si.sha512=ni;var Ei=et.EventEmitter;function ki(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,r)}return i}function Ri(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function Ai(t,e){for(var i=0;i0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,i=""+e.data;e=e.next;)i+=t+e.data;return i}},{key:"concat",value:function(t){if(0===this.length)return xi.alloc(0);for(var e,i,r,n=xi.allocUnsafe(t>>>0),s=this.head,o=0;s;)e=s.data,i=n,r=o,xi.prototype.copy.call(e,i,r),o+=s.data.length,s=s.next;return n}},{key:"consume",value:function(t,e){var i;return tn.length?n.length:t;if(s===n.length?r+=n:r+=n.slice(0,t),0==(t-=s)){s===n.length?(++i,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=n.slice(s));break}++i}return this.length-=i,r}},{key:"_getBuffer",value:function(t){var e=xi.allocUnsafe(t),i=this.head,r=1;for(i.data.copy(e),t-=i.data.length;i=i.next;){var n=i.data,s=t>n.length?n.length:t;if(n.copy(e,e.length-t,0,s),0==(t-=s)){s===n.length?(++r,i.next?this.head=i.next:this.head=this.tail=null):(this.head=i,i.data=n.slice(s));break}++r}return this.length-=r,e}},{key:Pi,value:function(t,e){return Ti(this,function(t){for(var e=1;e2?"one of ".concat(e," ").concat(t.slice(0,i-1).join(", "),", or ")+t[i-1]:2===i?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}Li("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),Li("ERR_INVALID_ARG_TYPE",(function(t,e,i){var r,n,s,o;if("string"==typeof e&&("not ","not "===e.substr(0,"not ".length))?(r="must not be",e=e.replace(/^not /,"")):r="must be",s=t,(void 0===o||o>s.length)&&(o=s.length)," argument"===s.substring(o-" argument".length,o))n="The ".concat(t," ").concat(r," ").concat(ji(e,"type"));else{var a=function(t,e,i){return"number"!=typeof i&&(i=0),!(i+".".length>t.length)&&-1!==t.indexOf(".",i)}(t)?"property":"argument";n='The "'.concat(t,'" ').concat(a," ").concat(r," ").concat(ji(e,"type"))}return n+". Received type ".concat(typeof i)}),TypeError),Li("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),Li("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),Li("ERR_STREAM_PREMATURE_CLOSE","Premature close"),Li("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),Li("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),Li("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),Li("ERR_STREAM_WRITE_AFTER_END","write after end"),Li("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),Li("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),Li("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),qi.codes=Oi;var Ci=qi.codes.ERR_INVALID_OPT_VALUE,Ni={getHighWaterMark:function(t,e,i,r){var n=function(t,e,i){return null!=t.highWaterMark?t.highWaterMark:e?t[i]:null}(e,r,i);if(null!=n){if(!isFinite(n)||Math.floor(n)!==n||n<0)throw new Ci(r?i:"highWaterMark",n);return Math.floor(n)}return t.objectMode?16:16384}},Di=Zi,Ui=qi.codes,$i=Ui.ERR_METHOD_NOT_IMPLEMENTED,zi=Ui.ERR_MULTIPLE_CALLBACK,Wi=Ui.ERR_TRANSFORM_ALREADY_TRANSFORMING,Fi=Ui.ERR_TRANSFORM_WITH_LENGTH_0,Ki=l({});function Hi(t,e){var i=this._transformState;i.transforming=!1;var r=i.writecb;if(null===r)return this.emit("error",new zi);i.writechunk=null,i.writecb=null,null!=e&&this.push(e),r(t);var n=this._readableState;n.reading=!1,(n.needReadable||n.length0,(function(t){r||(r=t),t&&s.forEach(rr),o||(s.forEach(rr),n(r))}))}));return e.reduce(nr)},ar.Stream=ar,ar.prototype.pipe=function(t,e){var i=this;function r(e){t.writable&&!1===t.write(e)&&i.pause&&i.pause()}function n(){i.readable&&i.resume&&i.resume()}i.on("data",r),t.on("drain",n),t._isStdio||e&&!1===e.end||(i.on("end",o),i.on("close",a));var s=!1;function o(){s||(s=!0,t.end())}function a(){s||(s=!0,"function"==typeof t.destroy&&t.destroy())}function h(t){if(u(),0===or.listenerCount(this,"error"))throw t}function u(){i.removeListener("data",r),t.removeListener("drain",n),i.removeListener("end",o),i.removeListener("close",a),i.removeListener("error",h),t.removeListener("error",h),i.removeListener("end",u),i.removeListener("close",u),t.removeListener("close",u)}return i.on("error",h),t.on("error",h),i.on("end",u),i.on("close",u),t.on("close",u),t.emit("pipe",i),t};var hr={},ur=I.Buffer,fr=sr.Transform,lr=v({}).StringDecoder;function dr(t){fr.call(this),this.hashMode="string"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}Q(dr,fr),dr.prototype.update=function(t,e,i){"string"==typeof t&&(t=ur.from(t,e));var r=this._update(t);return this.hashMode?this:(i&&(r=this._toString(r,i)),r)},dr.prototype.setAutoPadding=function(){},dr.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},dr.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},dr.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},dr.prototype._transform=function(t,e,i){var r;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(n){r=n}finally{i(r)}},dr.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(i){e=i}t(e)},dr.prototype._finalOrDigest=function(t){var e=this.__final()||ur.alloc(0);return t&&(e=this._toString(e,t,!0)),e},dr.prototype._toString=function(t,e,i){if(this._decoder||(this._decoder=new lr(e),this._encoding=e),this._encoding!==e)throw new Error("can't switch encodings");var r=this._decoder.write(t);return i&&(r+=this._decoder.end()),r};var cr;function pr(t){hr.call(this,"digest"),this._hash=t}Q(pr,hr=dr),pr.prototype._update=function(t){this._hash.update(t)},pr.prototype._final=function(){return this._hash.digest()},cr=function(t){return"md5"===(t=t.toLowerCase())?new ee:"rmd160"===t||"ripemd160"===t?new fe:new pr(_i(t))};var mr={},gr=I.Buffer,vr=gr.alloc(128);function br(t,e){hr.call(this,"digest"),"string"==typeof e&&(e=gr.from(e)),this._alg=t,this._key=e,e.length>64?e=t(e):e.length<64&&(e=gr.concat([e,vr],64));for(var i=this._ipad=gr.allocUnsafe(64),r=this._opad=gr.allocUnsafe(64),n=0;n<64;n++)i[n]=54^e[n],r[n]=92^e[n];this._hash=[i]}Q(br,hr),br.prototype._update=function(t){this._hash.push(t)},br.prototype._final=function(){var t=this._alg(gr.concat(this._hash));return this._alg(gr.concat([this._opad,t]))},mr=br;var yr,wr=function(t){return(new ee).update(t).digest()},Mr=I.Buffer,_r=Mr.alloc(128);function Sr(t,e){hr.call(this,"digest"),"string"==typeof e&&(e=Mr.from(e));var i="sha512"===t||"sha384"===t?128:64;this._alg=t,this._key=e,e.length>i?e=("rmd160"===t?new fe:_i(t)).update(e).digest():e.lengthRr||e!=e)throw new TypeError("Bad key length")},xr={};(function(t){(function(){var e;e=t.browser?"utf-8":t.version?parseInt(t.version.split(".")[0].slice(1),10)>=6?"utf-8":"binary":"utf-8",xr=e}).call(this)}).call(this,D);var Tr,Pr=I.Buffer,Br=function(t,e,i){if(Pr.isBuffer(t))return t;if("string"==typeof t)return Pr.from(t,e);if(ArrayBuffer.isView(t))return Pr.from(t.buffer);throw new TypeError(i+" must be a string, a Buffer, a typed array or a DataView")},Ir=I.Buffer,qr=Ir.alloc(128),Or={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function Lr(t,e,i){var r=function(t){return"rmd160"===t||"ripemd160"===t?function(t){return(new fe).update(t).digest()}:"md5"===t?wr:function(e){return _i(t).update(e).digest()}}(t),n="sha512"===t||"sha384"===t?128:64;e.length>n?e=r(e):e.length>>0},writeUInt32BE:function(t,e,i){t[0+i]=e>>>24,t[1+i]=e>>>16&255,t[2+i]=e>>>8&255,t[3+i]=255&e},ip:function(t,e,i,r){for(var n=0,s=0,o=6;o>=0;o-=2){for(var a=0;a<=24;a+=8)n<<=1,n|=e>>>a+o&1;for(a=0;a<=24;a+=8)n<<=1,n|=t>>>a+o&1}for(o=6;o>=0;o-=2){for(a=1;a<=25;a+=8)s<<=1,s|=e>>>a+o&1;for(a=1;a<=25;a+=8)s<<=1,s|=t>>>a+o&1}i[r+0]=n>>>0,i[r+1]=s>>>0},rip:function(t,e,i,r){for(var n=0,s=0,o=0;o<4;o++)for(var a=24;a>=0;a-=8)n<<=1,n|=e>>>a+o&1,n<<=1,n|=t>>>a+o&1;for(o=4;o<8;o++)for(a=24;a>=0;a-=8)s<<=1,s|=e>>>a+o&1,s<<=1,s|=t>>>a+o&1;i[r+0]=n>>>0,i[r+1]=s>>>0},pc1:function(t,e,i,r){for(var n=0,s=0,o=7;o>=5;o--){for(var a=0;a<=24;a+=8)n<<=1,n|=e>>a+o&1;for(a=0;a<=24;a+=8)n<<=1,n|=t>>a+o&1}for(a=0;a<=24;a+=8)n<<=1,n|=e>>a+o&1;for(o=1;o<=3;o++){for(a=0;a<=24;a+=8)s<<=1,s|=e>>a+o&1;for(a=0;a<=24;a+=8)s<<=1,s|=t>>a+o&1}for(a=0;a<=24;a+=8)s<<=1,s|=t>>a+o&1;i[r+0]=n>>>0,i[r+1]=s>>>0},r28shl:function(t,e){return t<>>28-e}},Nr=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];Cr.pc2=function(t,e,i,r){for(var n=0,s=0,o=Nr.length>>>1,a=0;a>>Nr[a]&1;for(a=o;a>>Nr[a]&1;i[r+0]=n>>>0,i[r+1]=s>>>0},Cr.expand=function(t,e,i){var r=0,n=0;r=(1&t)<<5|t>>>27;for(var s=23;s>=15;s-=4)r<<=6,r|=t>>>s&63;for(s=11;s>=3;s-=4)n|=t>>>s&63,n<<=6;n|=(31&t)<<1|t>>>31,e[i+0]=r>>>0,e[i+1]=n>>>0};var Dr=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];Cr.substitute=function(t,e){for(var i=0,r=0;r<4;r++)i<<=4,i|=Dr[64*r+(t>>>18-6*r&63)];for(r=0;r<4;r++)i<<=4,i|=Dr[256+64*r+(e>>>18-6*r&63)];return i>>>0};var Ur=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];Cr.permute=function(t){for(var e=0,i=0;i>>Ur[i]&1;return e>>>0},Cr.padSplit=function(t,e,i){for(var r=t.toString(2);r.length0;r--)e+=this._buffer(t,e),i+=this._flushBuffer(n,i);return e+=this._buffer(t,e),n},Fr.prototype.final=function(t){var e,i;return t&&(e=this.update(t)),i="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),e?e.concat(i):i},Fr.prototype._pad=function(t,e){if(0===e)return!1;for(;e>>1];i=Cr.r28shl(i,s),r=Cr.r28shl(r,s),Cr.pc2(i,r,t.keys,n)}},Zr.prototype._update=function(t,e,i,r){var n=this._desState,s=Cr.readUInt32BE(t,e),o=Cr.readUInt32BE(t,e+4);Cr.ip(s,o,n.tmp,0),s=n.tmp[0],o=n.tmp[1],"encrypt"===this.type?this._encrypt(n,s,o,n.tmp,0):this._decrypt(n,s,o,n.tmp,0),s=n.tmp[0],o=n.tmp[1],Cr.writeUInt32BE(i,s,r),Cr.writeUInt32BE(i,o,r+4)},Zr.prototype._pad=function(t,e){for(var i=t.length-e,r=e;r>>0,s=l}Cr.rip(o,s,r,n)},Zr.prototype._decrypt=function(t,e,i,r,n){for(var s=i,o=e,a=t.keys.length-2;a>=0;a-=2){var h=t.keys[a],u=t.keys[a+1];Cr.expand(s,t.tmp,0),h^=t.tmp[0],u^=t.tmp[1];var f=Cr.substitute(h,u),l=s;s=(o^Cr.permute(f))>>>0,o=l}Cr.rip(s,o,r,n)};var Gr={},Yr={};function Xr(t){this.iv=new Array(8);for(var e=0;e>s%8,t._prev=bn(t._prev,i?r:n);return o}function bn(t,e){var i=t.length,r=-1,n=gn.allocUnsafe(t.length);for(t=gn.concat([t,gn.from([e])]);++r>7;return n}mn.encrypt=function(t,e,i){for(var r=e.length,n=gn.allocUnsafe(r),s=-1;++s>>24]^f[p>>>16&255]^l[m>>>8&255]^d[255&g]^e[v++],o=u[p>>>24]^f[m>>>16&255]^l[g>>>8&255]^d[255&c]^e[v++],a=u[m>>>24]^f[g>>>16&255]^l[c>>>8&255]^d[255&p]^e[v++],h=u[g>>>24]^f[c>>>16&255]^l[p>>>8&255]^d[255&m]^e[v++],c=s,p=o,m=a,g=h;return s=(r[c>>>24]<<24|r[p>>>16&255]<<16|r[m>>>8&255]<<8|r[255&g])^e[v++],o=(r[p>>>24]<<24|r[m>>>16&255]<<16|r[g>>>8&255]<<8|r[255&c])^e[v++],a=(r[m>>>24]<<24|r[g>>>16&255]<<16|r[c>>>8&255]<<8|r[255&p])^e[v++],h=(r[g>>>24]<<24|r[c>>>16&255]<<16|r[p>>>8&255]<<8|r[255&m])^e[v++],[s>>>=0,o>>>=0,a>>>=0,h>>>=0]}var In=[0,1,2,4,8,16,32,64,128,27,54],qn=function(){for(var t=new Array(256),e=0;e<256;e++)t[e]=e<128?e<<1:e<<1^283;for(var i=[],r=[],n=[[],[],[],[]],s=[[],[],[],[]],o=0,a=0,h=0;h<256;++h){var u=a^a<<1^a<<2^a<<3^a<<4;u=u>>>8^255&u^99,i[o]=u,r[u]=o;var f=t[o],l=t[f],d=t[l],c=257*t[u]^16843008*u;n[0][o]=c<<24|c>>>8,n[1][o]=c<<16|c>>>16,n[2][o]=c<<8|c>>>24,n[3][o]=c,c=16843009*d^65537*l^257*f^16843008*o,s[0][u]=c<<24|c>>>8,s[1][u]=c<<16|c>>>16,s[2][u]=c<<8|c>>>24,s[3][u]=c,0===o?o=a=1:(o=f^t[t[t[d^f]]],a^=t[t[a]])}return{SBOX:i,INV_SBOX:r,SUB_MIX:n,INV_SUB_MIX:s}}();function On(t){this._key=Tn(t),this._reset()}On.blockSize=16,On.keySize=32,On.prototype.blockSize=On.blockSize,On.prototype.keySize=On.keySize,On.prototype._reset=function(){for(var t=this._key,e=t.length,i=e+6,r=4*(i+1),n=[],s=0;s>>24,o=qn.SBOX[o>>>24]<<24|qn.SBOX[o>>>16&255]<<16|qn.SBOX[o>>>8&255]<<8|qn.SBOX[255&o],o^=In[s/e|0]<<24):e>6&&s%e==4&&(o=qn.SBOX[o>>>24]<<24|qn.SBOX[o>>>16&255]<<16|qn.SBOX[o>>>8&255]<<8|qn.SBOX[255&o]),n[s]=n[s-e]^o}for(var a=[],h=0;h>>24]]^qn.INV_SUB_MIX[1][qn.SBOX[f>>>16&255]]^qn.INV_SUB_MIX[2][qn.SBOX[f>>>8&255]]^qn.INV_SUB_MIX[3][qn.SBOX[255&f]]}this._nRounds=i,this._keySchedule=n,this._invKeySchedule=a},On.prototype.encryptBlockRaw=function(t){return Bn(t=Tn(t),this._keySchedule,qn.SUB_MIX,qn.SBOX,this._nRounds)},On.prototype.encryptBlock=function(t){var e=this.encryptBlockRaw(t),i=xn.allocUnsafe(16);return i.writeUInt32BE(e[0],0),i.writeUInt32BE(e[1],4),i.writeUInt32BE(e[2],8),i.writeUInt32BE(e[3],12),i},On.prototype.decryptBlock=function(t){var e=(t=Tn(t))[1];t[1]=t[3],t[3]=e;var i=Bn(t,this._invKeySchedule,qn.INV_SUB_MIX,qn.INV_SBOX,this._nRounds),r=xn.allocUnsafe(16);return r.writeUInt32BE(i[0],0),r.writeUInt32BE(i[3],4),r.writeUInt32BE(i[2],8),r.writeUInt32BE(i[1],12),r},On.prototype.scrub=function(){Pn(this._keySchedule),Pn(this._invKeySchedule),Pn(this._key)},An.AES=On;var Ln={},jn=I.Buffer,Cn=jn.alloc(16,0);function Nn(t){var e=jn.allocUnsafe(16);return e.writeUInt32BE(t[0]>>>0,0),e.writeUInt32BE(t[1]>>>0,4),e.writeUInt32BE(t[2]>>>0,8),e.writeUInt32BE(t[3]>>>0,12),e}function Dn(t){this.h=t,this.state=jn.alloc(16,0),this.cache=jn.allocUnsafe(0)}Dn.prototype.ghash=function(t){for(var e=-1;++e0;e--)r[e]=r[e]>>>1|(1&r[e-1])<<31;r[0]=r[0]>>>1,i&&(r[0]=r[0]^225<<24)}this.state=Nn(n)},Dn.prototype.update=function(t){var e;for(this.cache=jn.concat([this.cache,t]);this.cache.length>=16;)e=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(e)},Dn.prototype.final=function(t,e){return this.cache.length&&this.ghash(jn.concat([this.cache,Cn],16)),this.ghash(Nn([0,t,0,e])),this.state},Ln=Dn;var Un=I.Buffer;function $n(t,e,i,r){hr.call(this);var n=Un.alloc(4,0);this._cipher=new An.AES(e);var s=this._cipher.encryptBlock(n);this._ghash=new Ln(s),i=function(t,e,i){if(12===e.length)return t._finID=Un.concat([e,Un.from([0,0,0,1])]),Un.concat([e,Un.from([0,0,0,2])]);var r=new Ln(i),n=e.length,s=n%16;r.update(e),s&&(s=16-s,r.update(Un.alloc(s,0))),r.update(Un.alloc(8,0));var o=8*n,a=Un.alloc(8);a.writeUIntBE(o,0,8),r.update(a),t._finID=r.state;var h=Un.from(t._finID);return wn(h),h}(this,i,s),this._prev=Un.from(i),this._cache=Un.allocUnsafe(0),this._secCache=Un.allocUnsafe(0),this._decrypt=r,this._alen=0,this._len=0,this._mode=t,this._authTag=null,this._called=!1}Q($n,hr),$n.prototype._update=function(t){if(!this._called&&this._alen){var e=16-this._alen%16;e<16&&(e=Un.alloc(e,0),this._ghash.update(e))}this._called=!0;var i=this._mode.encrypt(this,t);return this._decrypt?this._ghash.update(t):this._ghash.update(i),this._len+=t.length,i},$n.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var t=an(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(t,e){var i=0;t.length!==e.length&&i++;for(var r=Math.min(t.length,e.length),n=0;n0||r>0;){var h=new ee;h.update(a),h.update(t),e&&h.update(e),a=h.digest();var u=0;if(n>0){var f=s.length-n;u=Math.min(n,a.length),a.copy(s,f,0,u),n-=u}if(u0){var l=o.length-r,d=Math.min(r,a.length-u);a.copy(o,l,u,u+d),r-=d}}return a.fill(0),{key:s,iv:o}},Hn={},Zn=I.Buffer;function Vn(t,e,i){hr.call(this),this._cache=new Yn,this._cipher=new An.AES(e),this._prev=Zn.from(i),this._mode=t,this._autopadding=!0}Q(Vn,hr),Vn.prototype._update=function(t){var e,i;this._cache.add(t);for(var r=[];e=this._cache.get();)i=this._mode.encrypt(this,e),r.push(i);return Zn.concat(r)};var Gn=Zn.alloc(16,16);function Yn(){this.cache=Zn.allocUnsafe(0)}Vn.prototype._final=function(){var t=this._cache.flush();if(this._autopadding)return t=this._mode.encrypt(this,t),this._cipher.scrub(),t;if(!t.equals(Gn))throw this._cipher.scrub(),new Error("data not multiple of block length")},Vn.prototype.setAutoPadding=function(t){return this._autopadding=!!t,this},Yn.prototype.add=function(t){this.cache=Zn.concat([this.cache,t])},Yn.prototype.get=function(){if(this.cache.length>15){var t=this.cache.slice(0,16);return this.cache=this.cache.slice(16),t}return null},Yn.prototype.flush=function(){for(var t=16-this.cache.length,e=Zn.allocUnsafe(t),i=-1;++i16)throw new Error("unable to decrypt data");for(var i=-1;++i16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e}else if(this.cache.length>=16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e;return null},ts.prototype.flush=function(){if(this.cache.length)return this.cache};var es={};es.createCipheriv=Hn.createCipheriv,es.createDecipheriv=Xn.createDecipheriv;var is={"des-ecb":{key:8,iv:0}};is["des-cbc"]=is.des={key:8,iv:8},is["des-ede3-cbc"]=is.des3={key:24,iv:8},is["des-ede3"]={key:24,iv:0},is["des-ede-cbc"]={key:16,iv:8},is["des-ede"]={key:16,iv:0};var rs={exports:{}};!function(t,e){"use strict";function i(t,e){t.super_=e;var i=function(){};i.prototype=e.prototype,t.prototype=new i,t.prototype.constructor=t}function r(t,e,i){if(r.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(i=e,e=10),this._init(t||0,e||10,i||"be"))}var n;"object"==typeof t?t.exports=r:e.BN=r,r.BN=r,r.wordSize=26;try{n=w({}).Buffer}catch(S){}function s(t,e,i){for(var r=0,n=Math.min(t.length,i),s=e;s=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return r}function o(t,e,i,r){for(var n=0,s=Math.min(t.length,i),o=e;o=49?a-49+10:a>=17?a-17+10:a}return n}r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,e){return t.cmp(e)>0?t:e},r.min=function(t,e){return t.cmp(e)<0?t:e},r.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===e?this._parseHex(t,r):this._parseBase(t,e,r),"-"===t[0]&&(this.negative=1),this.strip(),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initArray=function(t,e,i){if(t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r=0;r-=3)s=t[r]|t[r-1]<<8|t[r-2]<<16,this.words[n]|=s<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===i)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this.strip()},r.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=6)n=s(t,i,i+6),this.words[r]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,r++);i+6!==e&&(n=s(t,e,i+6),this.words[r]|=n<>>26-o&4194303),this.strip()},r.prototype._parseBase=function(t,e,i){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=e)r++;r--,n=n/e|0;for(var s=t.length-i,a=s%r,h=Math.min(s,s-a)+i,u=0,f=i;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},r.prototype.inspect=function(){return(this.red?""};var a=["","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"],h=[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],u=[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 f(t,e,i){i.negative=e.negative^t.negative;var r=t.length+e.length|0;i.length=r,r=r-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;i.words[0]=a;for(var u=1;u>>26,l=67108863&h,d=Math.min(u,e.length-1),c=Math.max(0,u-t.length+1);c<=d;c++){var p=u-c|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[c])+l)/67108864|0,l=67108863&o}i.words[u]=0|l,h=0|f}return 0!==h?i.words[u]=0|h:i.length--,i.strip()}r.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var r=0,n=0,s=0;s>>24-r&16777215)||s!==this.length-1?a[6-f.length]+f+i:f+i,(r+=2)>=26&&(r-=26,s--)}for(0!==n&&(i=n.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var l=h[t],d=u[t];i="";var c=this.clone();for(c.negative=0;!c.isZero();){var p=c.modn(d).toString(t);i=(c=c.idivn(d)).isZero()?p+i:a[l-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length,0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16)},r.prototype.toBuffer=function(t,e){return this.toArrayLike(n,t,e)},r.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},r.prototype.toArrayLike=function(t,e,i){var r=this.byteLength(),n=i||Math.max(1,r);this.strip();var s,o,a="le"===e,h=new t(n),u=this.clone();if(a){for(o=0;!u.isZero();o++)s=u.andln(255),u.iushrn(8),h[o]=s;for(;o=4096&&(i+=13,e>>>=13),e>=64&&(i+=7,e>>>=7),e>=8&&(i+=4,e>>>=4),e>=2&&(i+=2,e>>>=2),i+e},r.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,i=0;return 0==(8191&e)&&(i+=13,e>>>=13),0==(127&e)&&(i+=7,e>>>=7),0==(15&e)&&(i+=4,e>>>=4),0==(3&e)&&(i+=2,e>>>=2),0==(1&e)&&i++,i},r.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var i=0;it.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var e,i;this.length>t.length?(e=this,i=t):(e=t,i=this);for(var r=0;rt.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-i),this.strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,e){var i=t/26|0,r=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(i=this,r=t):(i=t,r=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i,r,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(i=this,r=t):(i=t,r=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,c=0|o[1],p=8191&c,m=c>>>13,g=0|o[2],v=8191&g,b=g>>>13,y=0|o[3],w=8191&y,M=y>>>13,_=0|o[4],S=8191&_,E=_>>>13,k=0|o[5],R=8191&k,A=k>>>13,x=0|o[6],T=8191&x,P=x>>>13,B=0|o[7],I=8191&B,q=B>>>13,O=0|o[8],L=8191&O,j=O>>>13,C=0|o[9],N=8191&C,D=C>>>13,U=0|a[0],$=8191&U,z=U>>>13,W=0|a[1],F=8191&W,K=W>>>13,H=0|a[2],Z=8191&H,V=H>>>13,G=0|a[3],Y=8191&G,X=G>>>13,J=0|a[4],Q=8191&J,tt=J>>>13,et=0|a[5],it=8191&et,rt=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,ft=0|a[8],lt=8191&ft,dt=ft>>>13,ct=0|a[9],pt=8191&ct,mt=ct>>>13;i.negative=t.negative^e.negative,i.length=19;var gt=(u+(r=Math.imul(l,$))|0)+((8191&(n=(n=Math.imul(l,z))+Math.imul(d,$)|0))<<13)|0;u=((s=Math.imul(d,z))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(p,$),n=(n=Math.imul(p,z))+Math.imul(m,$)|0,s=Math.imul(m,z);var vt=(u+(r=r+Math.imul(l,F)|0)|0)+((8191&(n=(n=n+Math.imul(l,K)|0)+Math.imul(d,F)|0))<<13)|0;u=((s=s+Math.imul(d,K)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(v,$),n=(n=Math.imul(v,z))+Math.imul(b,$)|0,s=Math.imul(b,z),r=r+Math.imul(p,F)|0,n=(n=n+Math.imul(p,K)|0)+Math.imul(m,F)|0,s=s+Math.imul(m,K)|0;var bt=(u+(r=r+Math.imul(l,Z)|0)|0)+((8191&(n=(n=n+Math.imul(l,V)|0)+Math.imul(d,Z)|0))<<13)|0;u=((s=s+Math.imul(d,V)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(w,$),n=(n=Math.imul(w,z))+Math.imul(M,$)|0,s=Math.imul(M,z),r=r+Math.imul(v,F)|0,n=(n=n+Math.imul(v,K)|0)+Math.imul(b,F)|0,s=s+Math.imul(b,K)|0,r=r+Math.imul(p,Z)|0,n=(n=n+Math.imul(p,V)|0)+Math.imul(m,Z)|0,s=s+Math.imul(m,V)|0;var yt=(u+(r=r+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,X)|0)+Math.imul(d,Y)|0))<<13)|0;u=((s=s+Math.imul(d,X)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(S,$),n=(n=Math.imul(S,z))+Math.imul(E,$)|0,s=Math.imul(E,z),r=r+Math.imul(w,F)|0,n=(n=n+Math.imul(w,K)|0)+Math.imul(M,F)|0,s=s+Math.imul(M,K)|0,r=r+Math.imul(v,Z)|0,n=(n=n+Math.imul(v,V)|0)+Math.imul(b,Z)|0,s=s+Math.imul(b,V)|0,r=r+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,X)|0;var wt=(u+(r=r+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(d,Q)|0))<<13)|0;u=((s=s+Math.imul(d,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(R,$),n=(n=Math.imul(R,z))+Math.imul(A,$)|0,s=Math.imul(A,z),r=r+Math.imul(S,F)|0,n=(n=n+Math.imul(S,K)|0)+Math.imul(E,F)|0,s=s+Math.imul(E,K)|0,r=r+Math.imul(w,Z)|0,n=(n=n+Math.imul(w,V)|0)+Math.imul(M,Z)|0,s=s+Math.imul(M,V)|0,r=r+Math.imul(v,Y)|0,n=(n=n+Math.imul(v,X)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,X)|0,r=r+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var Mt=(u+(r=r+Math.imul(l,it)|0)|0)+((8191&(n=(n=n+Math.imul(l,rt)|0)+Math.imul(d,it)|0))<<13)|0;u=((s=s+Math.imul(d,rt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(T,$),n=(n=Math.imul(T,z))+Math.imul(P,$)|0,s=Math.imul(P,z),r=r+Math.imul(R,F)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(A,F)|0,s=s+Math.imul(A,K)|0,r=r+Math.imul(S,Z)|0,n=(n=n+Math.imul(S,V)|0)+Math.imul(E,Z)|0,s=s+Math.imul(E,V)|0,r=r+Math.imul(w,Y)|0,n=(n=n+Math.imul(w,X)|0)+Math.imul(M,Y)|0,s=s+Math.imul(M,X)|0,r=r+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,tt)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,tt)|0,r=r+Math.imul(p,it)|0,n=(n=n+Math.imul(p,rt)|0)+Math.imul(m,it)|0,s=s+Math.imul(m,rt)|0;var _t=(u+(r=r+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(d,st)|0))<<13)|0;u=((s=s+Math.imul(d,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(I,$),n=(n=Math.imul(I,z))+Math.imul(q,$)|0,s=Math.imul(q,z),r=r+Math.imul(T,F)|0,n=(n=n+Math.imul(T,K)|0)+Math.imul(P,F)|0,s=s+Math.imul(P,K)|0,r=r+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,V)|0)+Math.imul(A,Z)|0,s=s+Math.imul(A,V)|0,r=r+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,X)|0,r=r+Math.imul(w,Q)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(M,Q)|0,s=s+Math.imul(M,tt)|0,r=r+Math.imul(v,it)|0,n=(n=n+Math.imul(v,rt)|0)+Math.imul(b,it)|0,s=s+Math.imul(b,rt)|0,r=r+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(r=r+Math.imul(l,ht)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((s=s+Math.imul(d,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(L,$),n=(n=Math.imul(L,z))+Math.imul(j,$)|0,s=Math.imul(j,z),r=r+Math.imul(I,F)|0,n=(n=n+Math.imul(I,K)|0)+Math.imul(q,F)|0,s=s+Math.imul(q,K)|0,r=r+Math.imul(T,Z)|0,n=(n=n+Math.imul(T,V)|0)+Math.imul(P,Z)|0,s=s+Math.imul(P,V)|0,r=r+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,X)|0,r=r+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(E,Q)|0,s=s+Math.imul(E,tt)|0,r=r+Math.imul(w,it)|0,n=(n=n+Math.imul(w,rt)|0)+Math.imul(M,it)|0,s=s+Math.imul(M,rt)|0,r=r+Math.imul(v,st)|0,n=(n=n+Math.imul(v,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,r=r+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,ut)|0;var Et=(u+(r=r+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,dt)|0)+Math.imul(d,lt)|0))<<13)|0;u=((s=s+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(N,$),n=(n=Math.imul(N,z))+Math.imul(D,$)|0,s=Math.imul(D,z),r=r+Math.imul(L,F)|0,n=(n=n+Math.imul(L,K)|0)+Math.imul(j,F)|0,s=s+Math.imul(j,K)|0,r=r+Math.imul(I,Z)|0,n=(n=n+Math.imul(I,V)|0)+Math.imul(q,Z)|0,s=s+Math.imul(q,V)|0,r=r+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,X)|0,r=r+Math.imul(R,Q)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(A,Q)|0,s=s+Math.imul(A,tt)|0,r=r+Math.imul(S,it)|0,n=(n=n+Math.imul(S,rt)|0)+Math.imul(E,it)|0,s=s+Math.imul(E,rt)|0,r=r+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(M,st)|0,s=s+Math.imul(M,ot)|0,r=r+Math.imul(v,ht)|0,n=(n=n+Math.imul(v,ut)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ut)|0,r=r+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,dt)|0;var kt=(u+(r=r+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(d,pt)|0))<<13)|0;u=((s=s+Math.imul(d,mt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(N,F),n=(n=Math.imul(N,K))+Math.imul(D,F)|0,s=Math.imul(D,K),r=r+Math.imul(L,Z)|0,n=(n=n+Math.imul(L,V)|0)+Math.imul(j,Z)|0,s=s+Math.imul(j,V)|0,r=r+Math.imul(I,Y)|0,n=(n=n+Math.imul(I,X)|0)+Math.imul(q,Y)|0,s=s+Math.imul(q,X)|0,r=r+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(P,Q)|0,s=s+Math.imul(P,tt)|0,r=r+Math.imul(R,it)|0,n=(n=n+Math.imul(R,rt)|0)+Math.imul(A,it)|0,s=s+Math.imul(A,rt)|0,r=r+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(E,st)|0,s=s+Math.imul(E,ot)|0,r=r+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(M,ht)|0,s=s+Math.imul(M,ut)|0,r=r+Math.imul(v,lt)|0,n=(n=n+Math.imul(v,dt)|0)+Math.imul(b,lt)|0,s=s+Math.imul(b,dt)|0;var Rt=(u+(r=r+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(N,Z),n=(n=Math.imul(N,V))+Math.imul(D,Z)|0,s=Math.imul(D,V),r=r+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(j,Y)|0,s=s+Math.imul(j,X)|0,r=r+Math.imul(I,Q)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(q,Q)|0,s=s+Math.imul(q,tt)|0,r=r+Math.imul(T,it)|0,n=(n=n+Math.imul(T,rt)|0)+Math.imul(P,it)|0,s=s+Math.imul(P,rt)|0,r=r+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(A,st)|0,s=s+Math.imul(A,ot)|0,r=r+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(E,ht)|0,s=s+Math.imul(E,ut)|0,r=r+Math.imul(w,lt)|0,n=(n=n+Math.imul(w,dt)|0)+Math.imul(M,lt)|0,s=s+Math.imul(M,dt)|0;var At=(u+(r=r+Math.imul(v,pt)|0)|0)+((8191&(n=(n=n+Math.imul(v,mt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((s=s+Math.imul(b,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(N,Y),n=(n=Math.imul(N,X))+Math.imul(D,Y)|0,s=Math.imul(D,X),r=r+Math.imul(L,Q)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(j,Q)|0,s=s+Math.imul(j,tt)|0,r=r+Math.imul(I,it)|0,n=(n=n+Math.imul(I,rt)|0)+Math.imul(q,it)|0,s=s+Math.imul(q,rt)|0,r=r+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,ot)|0,r=r+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(A,ht)|0,s=s+Math.imul(A,ut)|0,r=r+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,dt)|0)+Math.imul(E,lt)|0,s=s+Math.imul(E,dt)|0;var xt=(u+(r=r+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((s=s+Math.imul(M,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(N,Q),n=(n=Math.imul(N,tt))+Math.imul(D,Q)|0,s=Math.imul(D,tt),r=r+Math.imul(L,it)|0,n=(n=n+Math.imul(L,rt)|0)+Math.imul(j,it)|0,s=s+Math.imul(j,rt)|0,r=r+Math.imul(I,st)|0,n=(n=n+Math.imul(I,ot)|0)+Math.imul(q,st)|0,s=s+Math.imul(q,ot)|0,r=r+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,ut)|0,r=r+Math.imul(R,lt)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(A,lt)|0,s=s+Math.imul(A,dt)|0;var Tt=(u+(r=r+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(E,pt)|0))<<13)|0;u=((s=s+Math.imul(E,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(N,it),n=(n=Math.imul(N,rt))+Math.imul(D,it)|0,s=Math.imul(D,rt),r=r+Math.imul(L,st)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(j,st)|0,s=s+Math.imul(j,ot)|0,r=r+Math.imul(I,ht)|0,n=(n=n+Math.imul(I,ut)|0)+Math.imul(q,ht)|0,s=s+Math.imul(q,ut)|0,r=r+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,dt)|0)+Math.imul(P,lt)|0,s=s+Math.imul(P,dt)|0;var Pt=(u+(r=r+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((s=s+Math.imul(A,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(N,st),n=(n=Math.imul(N,ot))+Math.imul(D,st)|0,s=Math.imul(D,ot),r=r+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,ut)|0)+Math.imul(j,ht)|0,s=s+Math.imul(j,ut)|0,r=r+Math.imul(I,lt)|0,n=(n=n+Math.imul(I,dt)|0)+Math.imul(q,lt)|0,s=s+Math.imul(q,dt)|0;var Bt=(u+(r=r+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((s=s+Math.imul(P,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(N,ht),n=(n=Math.imul(N,ut))+Math.imul(D,ht)|0,s=Math.imul(D,ut),r=r+Math.imul(L,lt)|0,n=(n=n+Math.imul(L,dt)|0)+Math.imul(j,lt)|0,s=s+Math.imul(j,dt)|0;var It=(u+(r=r+Math.imul(I,pt)|0)|0)+((8191&(n=(n=n+Math.imul(I,mt)|0)+Math.imul(q,pt)|0))<<13)|0;u=((s=s+Math.imul(q,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(N,lt),n=(n=Math.imul(N,dt))+Math.imul(D,lt)|0,s=Math.imul(D,dt);var qt=(u+(r=r+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,mt)|0)+Math.imul(j,pt)|0))<<13)|0;u=((s=s+Math.imul(j,mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863;var Ot=(u+(r=Math.imul(N,pt))|0)+((8191&(n=(n=Math.imul(N,mt))+Math.imul(D,pt)|0))<<13)|0;return u=((s=Math.imul(D,mt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=vt,h[2]=bt,h[3]=yt,h[4]=wt,h[5]=Mt,h[6]=_t,h[7]=St,h[8]=Et,h[9]=kt,h[10]=Rt,h[11]=At,h[12]=xt,h[13]=Tt,h[14]=Pt,h[15]=Bt,h[16]=It,h[17]=qt,h[18]=Ot,0!==u&&(h[19]=u,i.length++),i};function d(t,e,i){return(new c).mulp(t,e,i)}function c(t,e){this.x=t,this.y=e}Math.imul||(l=f),r.prototype.mulTo=function(t,e){var i=this.length+t.length;return 10===this.length&&10===t.length?l(this,t,e):i<63?f(this,t,e):i<1024?function(t,e,i){i.negative=e.negative^t.negative,i.length=t.length+e.length;for(var r=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}i.words[s]=a,r=o,o=n}return 0!==r?i.words[s]=r:i.length--,i.strip()}(this,t,e):d(this,t,e)},c.prototype.makeRBT=function(t){for(var e=new Array(t),i=r.prototype._countBits(t)-1,n=0;n>=1;return r},c.prototype.permute=function(t,e,i,r,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*s+1]=8191&n,n>>>=13;for(s=2*e;s>=26,e+=r/67108864|0,e+=n>>>26,this.words[i]=67108863&n}return 0!==e&&(this.words[i]=e,this.length++),this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),i=0;i>>n}return e}(t);if(0===e.length)return new r(1);for(var i=this,n=0;n>>26-i<<26-i;if(0!==i){var s=0;for(e=0;e>>26-i}s&&(this.words[e]=s,this.length++)}if(0!==r){for(e=this.length-1;e>=0;e--)this.words[e+r]=this.words[e];for(e=0;e>>n<s)for(this.length-=s,h=0;h=0&&(0!==u||h>=r);h--){var f=0|this.words[h];this.words[h]=u<<26-n|f>>>n,u=f&o}return a&&0!==u&&(a.words[a.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},r.prototype.ishrn=function(t,e,i){return this.iushrn(t,e,i)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){var e=t%26,i=(t-e)/26,r=1<>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},r.prototype.isubn=function(t){if(t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(a/67108864|0),this.words[r+i]=67108863&n}for(;r>26,this.words[r+i]=67108863&n;if(0===o)return this.strip();for(o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},r.prototype._wordDiv=function(t,e){var i=(this.length,t.length),n=this.clone(),s=t,o=0|s.words[s.length-1];0!=(i=26-this._countBits(o))&&(s=s.ushln(i),n.iushln(i),o=0|s.words[s.length-1]);var a,h=n.length-s.length;if("mod"!==e){(a=new r(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u=0;l--){var d=67108864*(0|n.words[s.length+l])+(0|n.words[s.length+l-1]);for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(s,d,l);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(s,1,l),n.isZero()||(n.negative^=1);a&&(a.words[l]=d)}return a&&a.strip(),n.strip(),"div"!==e&&0!==i&&n.iushrn(i),{div:a||null,mod:n}},r.prototype.divmod=function(t,e,i){return this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),"mod"!==e&&(n=o.div.neg()),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),e),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new r(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var i=0!==e.div.negative?e.mod.isub(t):e.mod,r=t.ushrn(1),n=t.andln(1),s=i.cmp(r);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},r.prototype.modn=function(t){for(var e=(1<<26)%t,i=0,r=this.length-1;r>=0;r--)i=(e*i+(0|this.words[r]))%t;return i},r.prototype.idivn=function(t){for(var e=0,i=this.length-1;i>=0;i--){var r=(0|this.words[i])+67108864*e;this.words[i]=r/t|0,e=r%t}return this.strip()},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new r(1),s=new r(0),o=new r(0),a=new r(1),h=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++h;for(var u=i.clone(),f=e.clone();!e.isZero();){for(var l=0,d=1;0==(e.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(e.iushrn(l);l-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(u),s.isub(f)),n.iushrn(1),s.iushrn(1);for(var c=0,p=1;0==(i.words[0]&p)&&c<26;++c,p<<=1);if(c>0)for(i.iushrn(c);c-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(u),a.isub(f)),o.iushrn(1),a.iushrn(1);e.cmp(i)>=0?(e.isub(i),n.isub(o),s.isub(a)):(i.isub(e),o.isub(n),a.isub(s))}return{a:o,b:a,gcd:i.iushln(h)}},r.prototype._invmp=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new r(1),o=new r(0),a=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var h=0,u=1;0==(e.words[0]&u)&&h<26;++h,u<<=1);if(h>0)for(e.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(a),s.iushrn(1);for(var f=0,l=1;0==(i.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(i.iushrn(f);f-- >0;)o.isOdd()&&o.iadd(a),o.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o)):(i.isub(e),o.isub(s))}return(n=0===e.cmpn(1)?s:o).cmpn(0)<0&&n.iadd(t),n},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),i=t.clone();e.negative=0,i.negative=0;for(var r=0;e.isEven()&&i.isEven();r++)e.iushrn(1),i.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;i.isEven();)i.iushrn(1);var n=e.cmp(i);if(n<0){var s=e;e=i,i=s}else if(0===n||0===i.cmpn(1))break;e.isub(i)}return i.iushln(r)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){var e=t%26,i=(t-e)/26,r=1<>>26,o&=67108863,this.words[s]=o}return 0!==n&&(this.words[s]=n,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t);var r=0|this.words[0];e=r===t?0:rt.length)return 1;if(this.length=0;i--){var r=0|this.words[i],n=0|t.words[i];if(r!==n){rn&&(e=1);break}}return e},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new M(t)},r.prototype.toRed=function(t){return t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return this._forceRed(t)},r.prototype.redAdd=function(t){return this.red.add(this,t)},r.prototype.redIAdd=function(t){return this.red.iadd(this,t)},r.prototype.redSub=function(t){return this.red.sub(this,t)},r.prototype.redISub=function(t){return this.red.isub(this,t)},r.prototype.redShl=function(t){return this.red.shl(this,t)},r.prototype.redMul=function(t){return this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return this.red._verify1(this),this.red.pow(this,t)};var p={k256:null,p224:null,p192:null,p25519:null};function m(t,e){this.name=t,this.p=new r(e,16),this.n=this.p.bitLength(),this.k=new r(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 v(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function y(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(t){if("string"==typeof t){var e=r._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function _(t){M.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(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 t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},m.prototype.ireduce=function(t){var e,i=t;do{this.split(i,this.tmp),e=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(e>this.n);var r=e0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},m.prototype.split=function(t,e){t.iushrn(this.n,0,e)},m.prototype.imulK=function(t){return t.imul(this.k)},i(g,m),g.prototype.split=function(t,e){for(var i=Math.min(t.length,9),r=0;r>>22,n=s}n>>>=22,t.words[r-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},g.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,i=0;i>>=26,t.words[i]=n,e=r}return 0!==e&&(t.words[t.length++]=e),t},r._prime=function(t){if(p[t])return p[t];var e;if("k256"===t)e=new g;else if("p224"===t)e=new v;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new y}return p[t]=e,e},M.prototype._verify1=function(t){},M.prototype._verify2=function(t,e){},M.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},M.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},M.prototype.add=function(t,e){this._verify2(t,e);var i=t.add(e);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},M.prototype.iadd=function(t,e){this._verify2(t,e);var i=t.iadd(e);return i.cmp(this.m)>=0&&i.isub(this.m),i},M.prototype.sub=function(t,e){this._verify2(t,e);var i=t.sub(e);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},M.prototype.isub=function(t,e){this._verify2(t,e);var i=t.isub(e);return i.cmpn(0)<0&&i.iadd(this.m),i},M.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},M.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},M.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},M.prototype.isqr=function(t){return this.imul(t,t.clone())},M.prototype.sqr=function(t){return this.mul(t,t)},M.prototype.sqrt=function(t){if(t.isZero())return t.clone();if(3===this.m.andln(3)){var e=this.m.add(new r(1)).iushrn(2);return this.pow(t,e)}for(var i=this.m.subn(1),n=0;!i.isZero()&&0===i.andln(1);)n++,i.iushrn(1);var s=new r(1).toRed(this),o=s.redNeg(),a=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new r(2*h*h).toRed(this);0!==this.pow(h,a).cmp(o);)h.redIAdd(o);for(var u=this.pow(h,i),f=this.pow(t,i.addn(1).iushrn(1)),l=this.pow(t,i),d=n;0!==l.cmp(s);){for(var c=l,p=0;0!==c.cmp(s);p++)c=c.redSqr();var m=this.pow(u,new r(1).iushln(d-p-1));f=f.redMul(m),u=m.redSqr(),l=l.redMul(u),d=p}return f},M.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},M.prototype.pow=function(t,e){if(e.isZero())return new r(1).toRed(this);if(0===e.cmpn(1))return t.clone();var i=new Array(16);i[0]=new r(1).toRed(this),i[1]=t;for(var n=2;n=0;n--){for(var u=e.words[n],f=h-1;f>=0;f--){var l=u>>f&1;s!==i[0]&&(s=this.sqr(s)),0!==l||0!==o?(o<<=1,o|=l,(4==++a||0===n&&0===f)&&(s=this.mul(s,i[o]),a=0,o=0)):a=0}h=26}return s},M.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},M.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},r.mont=function(t){return new _(t)},i(_,M),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(e),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new r(0)._forceRed(this);var i=t.mul(e),n=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=i.isub(n).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(rs,this),rs=rs.exports;var ns={exports:{}};!function(t,e){"use strict";function i(t,e){t.super_=e;var i=function(){};i.prototype=e.prototype,t.prototype=new i,t.prototype.constructor=t}function r(t,e,i){if(r.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(i=e,e=10),this._init(t||0,e||10,i||"be"))}var n;"object"==typeof t?t.exports=r:e.BN=r,r.BN=r,r.wordSize=26;try{n=w({}).Buffer}catch(S){}function s(t,e,i){for(var r=0,n=Math.min(t.length,i),s=e;s=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return r}function o(t,e,i,r){for(var n=0,s=Math.min(t.length,i),o=e;o=49?a-49+10:a>=17?a-17+10:a}return n}r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,e){return t.cmp(e)>0?t:e},r.min=function(t,e){return t.cmp(e)<0?t:e},r.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===e?this._parseHex(t,r):this._parseBase(t,e,r),"-"===t[0]&&(this.negative=1),this.strip(),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initArray=function(t,e,i){if(t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r=0;r-=3)s=t[r]|t[r-1]<<8|t[r-2]<<16,this.words[n]|=s<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===i)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this.strip()},r.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=6)n=s(t,i,i+6),this.words[r]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,r++);i+6!==e&&(n=s(t,e,i+6),this.words[r]|=n<>>26-o&4194303),this.strip()},r.prototype._parseBase=function(t,e,i){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=e)r++;r--,n=n/e|0;for(var s=t.length-i,a=s%r,h=Math.min(s,s-a)+i,u=0,f=i;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},r.prototype.inspect=function(){return(this.red?""};var a=["","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"],h=[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],u=[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 f(t,e,i){i.negative=e.negative^t.negative;var r=t.length+e.length|0;i.length=r,r=r-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;i.words[0]=a;for(var u=1;u>>26,l=67108863&h,d=Math.min(u,e.length-1),c=Math.max(0,u-t.length+1);c<=d;c++){var p=u-c|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[c])+l)/67108864|0,l=67108863&o}i.words[u]=0|l,h=0|f}return 0!==h?i.words[u]=0|h:i.length--,i.strip()}r.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var r=0,n=0,s=0;s>>24-r&16777215)||s!==this.length-1?a[6-f.length]+f+i:f+i,(r+=2)>=26&&(r-=26,s--)}for(0!==n&&(i=n.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var l=h[t],d=u[t];i="";var c=this.clone();for(c.negative=0;!c.isZero();){var p=c.modn(d).toString(t);i=(c=c.idivn(d)).isZero()?p+i:a[l-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length,0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16)},r.prototype.toBuffer=function(t,e){return this.toArrayLike(n,t,e)},r.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},r.prototype.toArrayLike=function(t,e,i){var r=this.byteLength(),n=i||Math.max(1,r);this.strip();var s,o,a="le"===e,h=new t(n),u=this.clone();if(a){for(o=0;!u.isZero();o++)s=u.andln(255),u.iushrn(8),h[o]=s;for(;o=4096&&(i+=13,e>>>=13),e>=64&&(i+=7,e>>>=7),e>=8&&(i+=4,e>>>=4),e>=2&&(i+=2,e>>>=2),i+e},r.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,i=0;return 0==(8191&e)&&(i+=13,e>>>=13),0==(127&e)&&(i+=7,e>>>=7),0==(15&e)&&(i+=4,e>>>=4),0==(3&e)&&(i+=2,e>>>=2),0==(1&e)&&i++,i},r.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var i=0;it.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var e,i;this.length>t.length?(e=this,i=t):(e=t,i=this);for(var r=0;rt.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-i),this.strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,e){var i=t/26|0,r=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(i=this,r=t):(i=t,r=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i,r,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(i=this,r=t):(i=t,r=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,c=0|o[1],p=8191&c,m=c>>>13,g=0|o[2],v=8191&g,b=g>>>13,y=0|o[3],w=8191&y,M=y>>>13,_=0|o[4],S=8191&_,E=_>>>13,k=0|o[5],R=8191&k,A=k>>>13,x=0|o[6],T=8191&x,P=x>>>13,B=0|o[7],I=8191&B,q=B>>>13,O=0|o[8],L=8191&O,j=O>>>13,C=0|o[9],N=8191&C,D=C>>>13,U=0|a[0],$=8191&U,z=U>>>13,W=0|a[1],F=8191&W,K=W>>>13,H=0|a[2],Z=8191&H,V=H>>>13,G=0|a[3],Y=8191&G,X=G>>>13,J=0|a[4],Q=8191&J,tt=J>>>13,et=0|a[5],it=8191&et,rt=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,ft=0|a[8],lt=8191&ft,dt=ft>>>13,ct=0|a[9],pt=8191&ct,mt=ct>>>13;i.negative=t.negative^e.negative,i.length=19;var gt=(u+(r=Math.imul(l,$))|0)+((8191&(n=(n=Math.imul(l,z))+Math.imul(d,$)|0))<<13)|0;u=((s=Math.imul(d,z))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(p,$),n=(n=Math.imul(p,z))+Math.imul(m,$)|0,s=Math.imul(m,z);var vt=(u+(r=r+Math.imul(l,F)|0)|0)+((8191&(n=(n=n+Math.imul(l,K)|0)+Math.imul(d,F)|0))<<13)|0;u=((s=s+Math.imul(d,K)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(v,$),n=(n=Math.imul(v,z))+Math.imul(b,$)|0,s=Math.imul(b,z),r=r+Math.imul(p,F)|0,n=(n=n+Math.imul(p,K)|0)+Math.imul(m,F)|0,s=s+Math.imul(m,K)|0;var bt=(u+(r=r+Math.imul(l,Z)|0)|0)+((8191&(n=(n=n+Math.imul(l,V)|0)+Math.imul(d,Z)|0))<<13)|0;u=((s=s+Math.imul(d,V)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(w,$),n=(n=Math.imul(w,z))+Math.imul(M,$)|0,s=Math.imul(M,z),r=r+Math.imul(v,F)|0,n=(n=n+Math.imul(v,K)|0)+Math.imul(b,F)|0,s=s+Math.imul(b,K)|0,r=r+Math.imul(p,Z)|0,n=(n=n+Math.imul(p,V)|0)+Math.imul(m,Z)|0,s=s+Math.imul(m,V)|0;var yt=(u+(r=r+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,X)|0)+Math.imul(d,Y)|0))<<13)|0;u=((s=s+Math.imul(d,X)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(S,$),n=(n=Math.imul(S,z))+Math.imul(E,$)|0,s=Math.imul(E,z),r=r+Math.imul(w,F)|0,n=(n=n+Math.imul(w,K)|0)+Math.imul(M,F)|0,s=s+Math.imul(M,K)|0,r=r+Math.imul(v,Z)|0,n=(n=n+Math.imul(v,V)|0)+Math.imul(b,Z)|0,s=s+Math.imul(b,V)|0,r=r+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,X)|0;var wt=(u+(r=r+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(d,Q)|0))<<13)|0;u=((s=s+Math.imul(d,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(R,$),n=(n=Math.imul(R,z))+Math.imul(A,$)|0,s=Math.imul(A,z),r=r+Math.imul(S,F)|0,n=(n=n+Math.imul(S,K)|0)+Math.imul(E,F)|0,s=s+Math.imul(E,K)|0,r=r+Math.imul(w,Z)|0,n=(n=n+Math.imul(w,V)|0)+Math.imul(M,Z)|0,s=s+Math.imul(M,V)|0,r=r+Math.imul(v,Y)|0,n=(n=n+Math.imul(v,X)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,X)|0,r=r+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var Mt=(u+(r=r+Math.imul(l,it)|0)|0)+((8191&(n=(n=n+Math.imul(l,rt)|0)+Math.imul(d,it)|0))<<13)|0;u=((s=s+Math.imul(d,rt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(T,$),n=(n=Math.imul(T,z))+Math.imul(P,$)|0,s=Math.imul(P,z),r=r+Math.imul(R,F)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(A,F)|0,s=s+Math.imul(A,K)|0,r=r+Math.imul(S,Z)|0,n=(n=n+Math.imul(S,V)|0)+Math.imul(E,Z)|0,s=s+Math.imul(E,V)|0,r=r+Math.imul(w,Y)|0,n=(n=n+Math.imul(w,X)|0)+Math.imul(M,Y)|0,s=s+Math.imul(M,X)|0,r=r+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,tt)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,tt)|0,r=r+Math.imul(p,it)|0,n=(n=n+Math.imul(p,rt)|0)+Math.imul(m,it)|0,s=s+Math.imul(m,rt)|0;var _t=(u+(r=r+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(d,st)|0))<<13)|0;u=((s=s+Math.imul(d,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(I,$),n=(n=Math.imul(I,z))+Math.imul(q,$)|0,s=Math.imul(q,z),r=r+Math.imul(T,F)|0,n=(n=n+Math.imul(T,K)|0)+Math.imul(P,F)|0,s=s+Math.imul(P,K)|0,r=r+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,V)|0)+Math.imul(A,Z)|0,s=s+Math.imul(A,V)|0,r=r+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,X)|0,r=r+Math.imul(w,Q)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(M,Q)|0,s=s+Math.imul(M,tt)|0,r=r+Math.imul(v,it)|0,n=(n=n+Math.imul(v,rt)|0)+Math.imul(b,it)|0,s=s+Math.imul(b,rt)|0,r=r+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(r=r+Math.imul(l,ht)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((s=s+Math.imul(d,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(L,$),n=(n=Math.imul(L,z))+Math.imul(j,$)|0,s=Math.imul(j,z),r=r+Math.imul(I,F)|0,n=(n=n+Math.imul(I,K)|0)+Math.imul(q,F)|0,s=s+Math.imul(q,K)|0,r=r+Math.imul(T,Z)|0,n=(n=n+Math.imul(T,V)|0)+Math.imul(P,Z)|0,s=s+Math.imul(P,V)|0,r=r+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,X)|0,r=r+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(E,Q)|0,s=s+Math.imul(E,tt)|0,r=r+Math.imul(w,it)|0,n=(n=n+Math.imul(w,rt)|0)+Math.imul(M,it)|0,s=s+Math.imul(M,rt)|0,r=r+Math.imul(v,st)|0,n=(n=n+Math.imul(v,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,r=r+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,ut)|0;var Et=(u+(r=r+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,dt)|0)+Math.imul(d,lt)|0))<<13)|0;u=((s=s+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(N,$),n=(n=Math.imul(N,z))+Math.imul(D,$)|0,s=Math.imul(D,z),r=r+Math.imul(L,F)|0,n=(n=n+Math.imul(L,K)|0)+Math.imul(j,F)|0,s=s+Math.imul(j,K)|0,r=r+Math.imul(I,Z)|0,n=(n=n+Math.imul(I,V)|0)+Math.imul(q,Z)|0,s=s+Math.imul(q,V)|0,r=r+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,X)|0,r=r+Math.imul(R,Q)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(A,Q)|0,s=s+Math.imul(A,tt)|0,r=r+Math.imul(S,it)|0,n=(n=n+Math.imul(S,rt)|0)+Math.imul(E,it)|0,s=s+Math.imul(E,rt)|0,r=r+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(M,st)|0,s=s+Math.imul(M,ot)|0,r=r+Math.imul(v,ht)|0,n=(n=n+Math.imul(v,ut)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ut)|0,r=r+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,dt)|0;var kt=(u+(r=r+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(d,pt)|0))<<13)|0;u=((s=s+Math.imul(d,mt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(N,F),n=(n=Math.imul(N,K))+Math.imul(D,F)|0,s=Math.imul(D,K),r=r+Math.imul(L,Z)|0,n=(n=n+Math.imul(L,V)|0)+Math.imul(j,Z)|0,s=s+Math.imul(j,V)|0,r=r+Math.imul(I,Y)|0,n=(n=n+Math.imul(I,X)|0)+Math.imul(q,Y)|0,s=s+Math.imul(q,X)|0,r=r+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(P,Q)|0,s=s+Math.imul(P,tt)|0,r=r+Math.imul(R,it)|0,n=(n=n+Math.imul(R,rt)|0)+Math.imul(A,it)|0,s=s+Math.imul(A,rt)|0,r=r+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(E,st)|0,s=s+Math.imul(E,ot)|0,r=r+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(M,ht)|0,s=s+Math.imul(M,ut)|0,r=r+Math.imul(v,lt)|0,n=(n=n+Math.imul(v,dt)|0)+Math.imul(b,lt)|0,s=s+Math.imul(b,dt)|0;var Rt=(u+(r=r+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(N,Z),n=(n=Math.imul(N,V))+Math.imul(D,Z)|0,s=Math.imul(D,V),r=r+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(j,Y)|0,s=s+Math.imul(j,X)|0,r=r+Math.imul(I,Q)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(q,Q)|0,s=s+Math.imul(q,tt)|0,r=r+Math.imul(T,it)|0,n=(n=n+Math.imul(T,rt)|0)+Math.imul(P,it)|0,s=s+Math.imul(P,rt)|0,r=r+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(A,st)|0,s=s+Math.imul(A,ot)|0,r=r+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(E,ht)|0,s=s+Math.imul(E,ut)|0,r=r+Math.imul(w,lt)|0,n=(n=n+Math.imul(w,dt)|0)+Math.imul(M,lt)|0,s=s+Math.imul(M,dt)|0;var At=(u+(r=r+Math.imul(v,pt)|0)|0)+((8191&(n=(n=n+Math.imul(v,mt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((s=s+Math.imul(b,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(N,Y),n=(n=Math.imul(N,X))+Math.imul(D,Y)|0,s=Math.imul(D,X),r=r+Math.imul(L,Q)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(j,Q)|0,s=s+Math.imul(j,tt)|0,r=r+Math.imul(I,it)|0,n=(n=n+Math.imul(I,rt)|0)+Math.imul(q,it)|0,s=s+Math.imul(q,rt)|0,r=r+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,ot)|0,r=r+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(A,ht)|0,s=s+Math.imul(A,ut)|0,r=r+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,dt)|0)+Math.imul(E,lt)|0,s=s+Math.imul(E,dt)|0;var xt=(u+(r=r+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((s=s+Math.imul(M,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(N,Q),n=(n=Math.imul(N,tt))+Math.imul(D,Q)|0,s=Math.imul(D,tt),r=r+Math.imul(L,it)|0,n=(n=n+Math.imul(L,rt)|0)+Math.imul(j,it)|0,s=s+Math.imul(j,rt)|0,r=r+Math.imul(I,st)|0,n=(n=n+Math.imul(I,ot)|0)+Math.imul(q,st)|0,s=s+Math.imul(q,ot)|0,r=r+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,ut)|0,r=r+Math.imul(R,lt)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(A,lt)|0,s=s+Math.imul(A,dt)|0;var Tt=(u+(r=r+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(E,pt)|0))<<13)|0;u=((s=s+Math.imul(E,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(N,it),n=(n=Math.imul(N,rt))+Math.imul(D,it)|0,s=Math.imul(D,rt),r=r+Math.imul(L,st)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(j,st)|0,s=s+Math.imul(j,ot)|0,r=r+Math.imul(I,ht)|0,n=(n=n+Math.imul(I,ut)|0)+Math.imul(q,ht)|0,s=s+Math.imul(q,ut)|0,r=r+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,dt)|0)+Math.imul(P,lt)|0,s=s+Math.imul(P,dt)|0;var Pt=(u+(r=r+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((s=s+Math.imul(A,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(N,st),n=(n=Math.imul(N,ot))+Math.imul(D,st)|0,s=Math.imul(D,ot),r=r+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,ut)|0)+Math.imul(j,ht)|0,s=s+Math.imul(j,ut)|0,r=r+Math.imul(I,lt)|0,n=(n=n+Math.imul(I,dt)|0)+Math.imul(q,lt)|0,s=s+Math.imul(q,dt)|0;var Bt=(u+(r=r+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((s=s+Math.imul(P,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(N,ht),n=(n=Math.imul(N,ut))+Math.imul(D,ht)|0,s=Math.imul(D,ut),r=r+Math.imul(L,lt)|0,n=(n=n+Math.imul(L,dt)|0)+Math.imul(j,lt)|0,s=s+Math.imul(j,dt)|0;var It=(u+(r=r+Math.imul(I,pt)|0)|0)+((8191&(n=(n=n+Math.imul(I,mt)|0)+Math.imul(q,pt)|0))<<13)|0;u=((s=s+Math.imul(q,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(N,lt),n=(n=Math.imul(N,dt))+Math.imul(D,lt)|0,s=Math.imul(D,dt);var qt=(u+(r=r+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,mt)|0)+Math.imul(j,pt)|0))<<13)|0;u=((s=s+Math.imul(j,mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863;var Ot=(u+(r=Math.imul(N,pt))|0)+((8191&(n=(n=Math.imul(N,mt))+Math.imul(D,pt)|0))<<13)|0;return u=((s=Math.imul(D,mt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=vt,h[2]=bt,h[3]=yt,h[4]=wt,h[5]=Mt,h[6]=_t,h[7]=St,h[8]=Et,h[9]=kt,h[10]=Rt,h[11]=At,h[12]=xt,h[13]=Tt,h[14]=Pt,h[15]=Bt,h[16]=It,h[17]=qt,h[18]=Ot,0!==u&&(h[19]=u,i.length++),i};function d(t,e,i){return(new c).mulp(t,e,i)}function c(t,e){this.x=t,this.y=e}Math.imul||(l=f),r.prototype.mulTo=function(t,e){var i=this.length+t.length;return 10===this.length&&10===t.length?l(this,t,e):i<63?f(this,t,e):i<1024?function(t,e,i){i.negative=e.negative^t.negative,i.length=t.length+e.length;for(var r=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}i.words[s]=a,r=o,o=n}return 0!==r?i.words[s]=r:i.length--,i.strip()}(this,t,e):d(this,t,e)},c.prototype.makeRBT=function(t){for(var e=new Array(t),i=r.prototype._countBits(t)-1,n=0;n>=1;return r},c.prototype.permute=function(t,e,i,r,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*s+1]=8191&n,n>>>=13;for(s=2*e;s>=26,e+=r/67108864|0,e+=n>>>26,this.words[i]=67108863&n}return 0!==e&&(this.words[i]=e,this.length++),this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),i=0;i>>n}return e}(t);if(0===e.length)return new r(1);for(var i=this,n=0;n>>26-i<<26-i;if(0!==i){var s=0;for(e=0;e>>26-i}s&&(this.words[e]=s,this.length++)}if(0!==r){for(e=this.length-1;e>=0;e--)this.words[e+r]=this.words[e];for(e=0;e>>n<s)for(this.length-=s,h=0;h=0&&(0!==u||h>=r);h--){var f=0|this.words[h];this.words[h]=u<<26-n|f>>>n,u=f&o}return a&&0!==u&&(a.words[a.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},r.prototype.ishrn=function(t,e,i){return this.iushrn(t,e,i)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){var e=t%26,i=(t-e)/26,r=1<>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},r.prototype.isubn=function(t){if(t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(a/67108864|0),this.words[r+i]=67108863&n}for(;r>26,this.words[r+i]=67108863&n;if(0===o)return this.strip();for(o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},r.prototype._wordDiv=function(t,e){var i=(this.length,t.length),n=this.clone(),s=t,o=0|s.words[s.length-1];0!=(i=26-this._countBits(o))&&(s=s.ushln(i),n.iushln(i),o=0|s.words[s.length-1]);var a,h=n.length-s.length;if("mod"!==e){(a=new r(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u=0;l--){var d=67108864*(0|n.words[s.length+l])+(0|n.words[s.length+l-1]);for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(s,d,l);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(s,1,l),n.isZero()||(n.negative^=1);a&&(a.words[l]=d)}return a&&a.strip(),n.strip(),"div"!==e&&0!==i&&n.iushrn(i),{div:a||null,mod:n}},r.prototype.divmod=function(t,e,i){return this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),"mod"!==e&&(n=o.div.neg()),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),e),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new r(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var i=0!==e.div.negative?e.mod.isub(t):e.mod,r=t.ushrn(1),n=t.andln(1),s=i.cmp(r);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},r.prototype.modn=function(t){for(var e=(1<<26)%t,i=0,r=this.length-1;r>=0;r--)i=(e*i+(0|this.words[r]))%t;return i},r.prototype.idivn=function(t){for(var e=0,i=this.length-1;i>=0;i--){var r=(0|this.words[i])+67108864*e;this.words[i]=r/t|0,e=r%t}return this.strip()},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new r(1),s=new r(0),o=new r(0),a=new r(1),h=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++h;for(var u=i.clone(),f=e.clone();!e.isZero();){for(var l=0,d=1;0==(e.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(e.iushrn(l);l-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(u),s.isub(f)),n.iushrn(1),s.iushrn(1);for(var c=0,p=1;0==(i.words[0]&p)&&c<26;++c,p<<=1);if(c>0)for(i.iushrn(c);c-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(u),a.isub(f)),o.iushrn(1),a.iushrn(1);e.cmp(i)>=0?(e.isub(i),n.isub(o),s.isub(a)):(i.isub(e),o.isub(n),a.isub(s))}return{a:o,b:a,gcd:i.iushln(h)}},r.prototype._invmp=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new r(1),o=new r(0),a=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var h=0,u=1;0==(e.words[0]&u)&&h<26;++h,u<<=1);if(h>0)for(e.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(a),s.iushrn(1);for(var f=0,l=1;0==(i.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(i.iushrn(f);f-- >0;)o.isOdd()&&o.iadd(a),o.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o)):(i.isub(e),o.isub(s))}return(n=0===e.cmpn(1)?s:o).cmpn(0)<0&&n.iadd(t),n},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),i=t.clone();e.negative=0,i.negative=0;for(var r=0;e.isEven()&&i.isEven();r++)e.iushrn(1),i.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;i.isEven();)i.iushrn(1);var n=e.cmp(i);if(n<0){var s=e;e=i,i=s}else if(0===n||0===i.cmpn(1))break;e.isub(i)}return i.iushln(r)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){var e=t%26,i=(t-e)/26,r=1<>>26,o&=67108863,this.words[s]=o}return 0!==n&&(this.words[s]=n,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t);var r=0|this.words[0];e=r===t?0:rt.length)return 1;if(this.length=0;i--){var r=0|this.words[i],n=0|t.words[i];if(r!==n){rn&&(e=1);break}}return e},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new M(t)},r.prototype.toRed=function(t){return t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return this._forceRed(t)},r.prototype.redAdd=function(t){return this.red.add(this,t)},r.prototype.redIAdd=function(t){return this.red.iadd(this,t)},r.prototype.redSub=function(t){return this.red.sub(this,t)},r.prototype.redISub=function(t){return this.red.isub(this,t)},r.prototype.redShl=function(t){return this.red.shl(this,t)},r.prototype.redMul=function(t){return this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return this.red._verify1(this),this.red.pow(this,t)};var p={k256:null,p224:null,p192:null,p25519:null};function m(t,e){this.name=t,this.p=new r(e,16),this.n=this.p.bitLength(),this.k=new r(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 v(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function y(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(t){if("string"==typeof t){var e=r._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function _(t){M.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(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 t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},m.prototype.ireduce=function(t){var e,i=t;do{this.split(i,this.tmp),e=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(e>this.n);var r=e0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},m.prototype.split=function(t,e){t.iushrn(this.n,0,e)},m.prototype.imulK=function(t){return t.imul(this.k)},i(g,m),g.prototype.split=function(t,e){for(var i=Math.min(t.length,9),r=0;r>>22,n=s}n>>>=22,t.words[r-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},g.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,i=0;i>>=26,t.words[i]=n,e=r}return 0!==e&&(t.words[t.length++]=e),t},r._prime=function(t){if(p[t])return p[t];var e;if("k256"===t)e=new g;else if("p224"===t)e=new v;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new y}return p[t]=e,e},M.prototype._verify1=function(t){},M.prototype._verify2=function(t,e){},M.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},M.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},M.prototype.add=function(t,e){this._verify2(t,e);var i=t.add(e);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},M.prototype.iadd=function(t,e){this._verify2(t,e);var i=t.iadd(e);return i.cmp(this.m)>=0&&i.isub(this.m),i},M.prototype.sub=function(t,e){this._verify2(t,e);var i=t.sub(e);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},M.prototype.isub=function(t,e){this._verify2(t,e);var i=t.isub(e);return i.cmpn(0)<0&&i.iadd(this.m),i},M.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},M.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},M.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},M.prototype.isqr=function(t){return this.imul(t,t.clone())},M.prototype.sqr=function(t){return this.mul(t,t)},M.prototype.sqrt=function(t){if(t.isZero())return t.clone();if(3===this.m.andln(3)){var e=this.m.add(new r(1)).iushrn(2);return this.pow(t,e)}for(var i=this.m.subn(1),n=0;!i.isZero()&&0===i.andln(1);)n++,i.iushrn(1);var s=new r(1).toRed(this),o=s.redNeg(),a=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new r(2*h*h).toRed(this);0!==this.pow(h,a).cmp(o);)h.redIAdd(o);for(var u=this.pow(h,i),f=this.pow(t,i.addn(1).iushrn(1)),l=this.pow(t,i),d=n;0!==l.cmp(s);){for(var c=l,p=0;0!==c.cmp(s);p++)c=c.redSqr();var m=this.pow(u,new r(1).iushln(d-p-1));f=f.redMul(m),u=m.redSqr(),l=l.redMul(u),d=p}return f},M.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},M.prototype.pow=function(t,e){if(e.isZero())return new r(1).toRed(this);if(0===e.cmpn(1))return t.clone();var i=new Array(16);i[0]=new r(1).toRed(this),i[1]=t;for(var n=2;n=0;n--){for(var u=e.words[n],f=h-1;f>=0;f--){var l=u>>f&1;s!==i[0]&&(s=this.sqr(s)),0!==l||0!==o?(o<<=1,o|=l,(4==++a||0===n&&0===f)&&(s=this.mul(s,i[o]),a=0,o=0)):a=0}h=26}return s},M.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},M.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},r.mont=function(t){return new _(t)},i(_,M),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(e),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new r(0)._forceRed(this);var i=t.mul(e),n=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=i.isub(n).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(ns,this),ns=ns.exports;var ss,os;function as(t){this.rand=t}if((ss=function(t){return os||(os=new as(null)),os.generate(t)}).Rand=as,as.prototype.generate=function(t){return this._rand(t)},as.prototype._rand=function(t){if(this.rand.getBytes)return this.rand.getBytes(t);for(var e=new Uint8Array(t),i=0;i=0);return r},fs.prototype._randrange=function(t,e){var i=e.sub(t);return t.add(this._randbelow(i))},fs.prototype.test=function(t,e,i){var r=t.bitLength(),n=ns.mont(t),s=new ns(1).toRed(n);e||(e=Math.max(1,r/48|0));for(var o=t.subn(1),a=0;!o.testn(a);a++);for(var h=t.shrn(a),u=o.toRed(n);e>0;e--){var f=this._randrange(new ns(2),o);i&&i(f);var l=f.toRed(n).redPow(h);if(0!==l.cmp(s)&&0!==l.cmp(u)){for(var d=1;d0;e--){var u=this._randrange(new ns(2),s),f=t.gcd(u);if(0!==f.cmpn(1))return f;var l=u.toRed(r).redPow(a);if(0!==l.cmp(n)&&0!==l.cmp(h)){for(var d=1;dt;)i.ishrn(1);if(i.isEven()&&i.iadd(ps),i.testn(1)||i.iadd(ms),e.cmp(ms)){if(!e.cmp(gs))for(;i.mod(vs).cmp(bs);)i.iadd(ws)}else for(;i.mod(ds).cmp(ys);)i.iadd(ws);if(Ss(r=i.shrn(1))&&Ss(i)&&Es(r)&&Es(i)&&cs.test(r)&&cs.test(i))return i}}(function(t){(function(){var e=new us,i=new rs(24),r=new rs(11),n=new rs(10),s=new rs(3),o=new rs(7);function a(e,i){return i=i||"utf8",t.isBuffer(e)||(e=new t(e,i)),this._pub=new rs(e),this}function h(e,i){return i=i||"utf8",t.isBuffer(e)||(e=new t(e,i)),this._priv=new rs(e),this}f;var u={};function f(t,e,i){this.setGenerator(e),this.__prime=new rs(t),this._prime=rs.mont(this.__prime),this._primeLen=t.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,i?(this.setPublicKey=a,this.setPrivateKey=h):this._primeCode=8}function l(e,i){var r=new t(e.toArray());return i?r.toString(i):r}Object.defineProperty(f.prototype,"verifyError",{enumerable:!0,get:function(){return"number"!=typeof this._primeCode&&(this._primeCode=function(t,a){var h=a.toString("hex"),f=[h,t.toString(16)].join("_");if(f in u)return u[f];var l,d=0;if(t.isEven()||!ls.simpleSieve||!ls.fermatTest(t)||!e.test(t))return d+=1,d+="02"===h||"05"===h?8:4,u[f]=d,d;switch(e.test(t.shrn(1))||(d+=2),h){case"02":t.mod(i).cmp(r)&&(d+=8);break;case"05":(l=t.mod(n)).cmp(s)&&l.cmp(o)&&(d+=8);break;default:d+=4}return u[f]=d,d}(this.__prime,this.__gen)),this._primeCode}}),f.prototype.generateKeys=function(){return this._priv||(this._priv=new rs(J(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()},f.prototype.computeSecret=function(e){var i=(e=(e=new rs(e)).toRed(this._prime)).redPow(this._priv).fromRed(),r=new t(i.toArray()),n=this.getPrime();if(r.length0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,i=""+e.data;e=e.next;)i+=t+e.data;return i}},{key:"concat",value:function(t){if(0===this.length)return Ps.alloc(0);for(var e,i,r,n=Ps.allocUnsafe(t>>>0),s=this.head,o=0;s;)e=s.data,i=n,r=o,Ps.prototype.copy.call(e,i,r),o+=s.data.length,s=s.next;return n}},{key:"consume",value:function(t,e){var i;return tn.length?n.length:t;if(s===n.length?r+=n:r+=n.slice(0,t),0==(t-=s)){s===n.length?(++i,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=n.slice(s));break}++i}return this.length-=i,r}},{key:"_getBuffer",value:function(t){var e=Ps.allocUnsafe(t),i=this.head,r=1;for(i.data.copy(e),t-=i.data.length;i=i.next;){var n=i.data,s=t>n.length?n.length:t;if(n.copy(e,e.length-t,0,s),0==(t-=s)){s===n.length?(++r,i.next?this.head=i.next:this.head=this.tail=null):(this.head=i,i.data=n.slice(s));break}++r}return this.length-=r,e}},{key:Is,value:function(t,e){return Bs(this,function(t){for(var e=1;e2?"one of ".concat(e," ").concat(t.slice(0,i-1).join(", "),", or ")+t[i-1]:2===i?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}Cs("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),Cs("ERR_INVALID_ARG_TYPE",(function(t,e,i){var r,n,s,o;if("string"==typeof e&&("not ","not "===e.substr(0,"not ".length))?(r="must not be",e=e.replace(/^not /,"")):r="must be",s=t,(void 0===o||o>s.length)&&(o=s.length)," argument"===s.substring(o-" argument".length,o))n="The ".concat(t," ").concat(r," ").concat(Ns(e,"type"));else{var a=function(t,e,i){return"number"!=typeof i&&(i=0),!(i+".".length>t.length)&&-1!==t.indexOf(".",i)}(t)?"property":"argument";n='The "'.concat(t,'" ').concat(a," ").concat(r," ").concat(Ns(e,"type"))}return n+". Received type ".concat(typeof i)}),TypeError),Cs("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),Cs("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),Cs("ERR_STREAM_PREMATURE_CLOSE","Premature close"),Cs("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),Cs("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),Cs("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),Cs("ERR_STREAM_WRITE_AFTER_END","write after end"),Cs("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),Cs("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),Cs("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),Ls.codes=js;var Ds=Ls.codes.ERR_INVALID_OPT_VALUE,Us={getHighWaterMark:function(t,e,i,r){var n=function(t,e,i){return null!=t.highWaterMark?t.highWaterMark:e?t[i]:null}(e,r,i);if(null!=n){if(!isFinite(n)||Math.floor(n)!==n||n<0)throw new Ds(r?i:"highWaterMark",n);return Math.floor(n)}return t.objectMode?16:16384}},$s=Gs,zs=Ls.codes,Ws=zs.ERR_METHOD_NOT_IMPLEMENTED,Fs=zs.ERR_MULTIPLE_CALLBACK,Ks=zs.ERR_TRANSFORM_ALREADY_TRANSFORMING,Hs=zs.ERR_TRANSFORM_WITH_LENGTH_0,Zs=s({});function Vs(t,e){var i=this._transformState;i.transforming=!1;var r=i.writecb;if(null===r)return this.emit("error",new Fs);i.writechunk=null,i.writecb=null,null!=e&&this.push(e),r(t);var n=this._readableState;n.reading=!1,(n.needReadable||n.length0,(function(t){r||(r=t),t&&o.forEach(so),a||(o.forEach(so),s(r))}))}));return e.reduce(oo)};var ho={exports:{}};!function(t,e){"use strict";function i(t,e){t.super_=e;var i=function(){};i.prototype=e.prototype,t.prototype=new i,t.prototype.constructor=t}function r(t,e,i){if(r.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(i=e,e=10),this._init(t||0,e||10,i||"be"))}var n;"object"==typeof t?t.exports=r:e.BN=r,r.BN=r,r.wordSize=26;try{n=w({}).Buffer}catch(jf){}function s(t,e,i){for(var r=0,n=Math.min(t.length,i),s=e;s=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:o}return r}function o(t,e,i,r){for(var n=0,s=Math.min(t.length,i),o=e;o=49?a-49+10:a>=17?a-17+10:a}return n}function a(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,e){return t.cmp(e)>0?t:e},r.min=function(t,e){return t.cmp(e)<0?t:e},r.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===e?this._parseHex(t,r):this._parseBase(t,e,r),"-"===t[0]&&(this.negative=1),this._strip(),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initArray=function(t,e,i){if(t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r=0;r-=3)s=t[r]|t[r-1]<<8|t[r-2]<<16,this.words[n]|=s<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===i)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this._strip()},r.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=6)n=s(t,i,i+6),this.words[r]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,r++);i+6!==e&&(n=s(t,e,i+6),this.words[r]|=n<>>26-o&4194303),this._strip()},r.prototype._parseBase=function(t,e,i){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=e)r++;r--,n=n/e|0;for(var s=t.length-i,a=s%r,h=Math.min(s,s-a)+i,u=0,f=i;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{r.prototype[Symbol.for("nodejs.util.inspect.custom")]=h}catch(jf){r.prototype.inspect=h}else r.prototype.inspect=h;function h(){return(this.red?""}var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],l=[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(t,e,i){i.negative=e.negative^t.negative;var r=t.length+e.length|0;i.length=r,r=r-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;i.words[0]=a;for(var u=1;u>>26,l=67108863&h,d=Math.min(u,e.length-1),c=Math.max(0,u-t.length+1);c<=d;c++){var p=u-c|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[c])+l)/67108864|0,l=67108863&o}i.words[u]=0|l,h=0|f}return 0!==h?i.words[u]=0|h:i.length--,i._strip()}r.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var r=0,n=0,s=0;s>>24-r&16777215)||s!==this.length-1?u[6-a.length]+a+i:a+i,(r+=2)>=26&&(r-=26,s--)}for(0!==n&&(i=n.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var h=f[t],d=l[t];i="";var c=this.clone();for(c.negative=0;!c.isZero();){var p=c.modrn(d).toString(t);i=(c=c.idivn(d)).isZero()?p+i:u[h-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length,0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16,2)},n&&(r.prototype.toBuffer=function(t,e){return this.toArrayLike(n,t,e)}),r.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},r.prototype.toArrayLike=function(t,e,i){this._strip();var r=this.byteLength(),n=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,i||Math.max(1,r));return this["_toArrayLike"+("le"===e?"LE":"BE")](n,r),n},r.prototype._toArrayLikeLE=function(t,e){for(var i=0,r=0,n=0,s=0;n>8&255),i>16&255),6===s?(i>24&255),r=0,s=0):(r=o>>>24,s+=2)}if(i=0&&(t[i--]=o>>8&255),i>=0&&(t[i--]=o>>16&255),6===s?(i>=0&&(t[i--]=o>>24&255),r=0,s=0):(r=o>>>24,s+=2)}if(i>=0)for(t[i--]=r;i>=0;)t[i--]=0},Math.clz32?r.prototype._countBits=function(t){return 32-Math.clz32(t)}:r.prototype._countBits=function(t){var e=t,i=0;return e>=4096&&(i+=13,e>>>=13),e>=64&&(i+=7,e>>>=7),e>=8&&(i+=4,e>>>=4),e>=2&&(i+=2,e>>>=2),i+e},r.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,i=0;return 0==(8191&e)&&(i+=13,e>>>=13),0==(127&e)&&(i+=7,e>>>=7),0==(15&e)&&(i+=4,e>>>=4),0==(3&e)&&(i+=2,e>>>=2),0==(1&e)&&i++,i},r.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var i=0;it.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var e,i;this.length>t.length?(e=this,i=t):(e=t,i=this);for(var r=0;rt.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-i),this._strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,e){var i=t/26|0,r=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(i=this,r=t):(i=t,r=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i,r,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(i=this,r=t):(i=t,r=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,c=0|o[1],p=8191&c,m=c>>>13,g=0|o[2],v=8191&g,b=g>>>13,y=0|o[3],w=8191&y,M=y>>>13,_=0|o[4],S=8191&_,E=_>>>13,k=0|o[5],R=8191&k,A=k>>>13,x=0|o[6],T=8191&x,P=x>>>13,B=0|o[7],I=8191&B,q=B>>>13,O=0|o[8],L=8191&O,j=O>>>13,C=0|o[9],N=8191&C,D=C>>>13,U=0|a[0],$=8191&U,z=U>>>13,W=0|a[1],F=8191&W,K=W>>>13,H=0|a[2],Z=8191&H,V=H>>>13,G=0|a[3],Y=8191&G,X=G>>>13,J=0|a[4],Q=8191&J,tt=J>>>13,et=0|a[5],it=8191&et,rt=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,ft=0|a[8],lt=8191&ft,dt=ft>>>13,ct=0|a[9],pt=8191&ct,mt=ct>>>13;i.negative=t.negative^e.negative,i.length=19;var gt=(u+(r=Math.imul(l,$))|0)+((8191&(n=(n=Math.imul(l,z))+Math.imul(d,$)|0))<<13)|0;u=((s=Math.imul(d,z))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(p,$),n=(n=Math.imul(p,z))+Math.imul(m,$)|0,s=Math.imul(m,z);var vt=(u+(r=r+Math.imul(l,F)|0)|0)+((8191&(n=(n=n+Math.imul(l,K)|0)+Math.imul(d,F)|0))<<13)|0;u=((s=s+Math.imul(d,K)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(v,$),n=(n=Math.imul(v,z))+Math.imul(b,$)|0,s=Math.imul(b,z),r=r+Math.imul(p,F)|0,n=(n=n+Math.imul(p,K)|0)+Math.imul(m,F)|0,s=s+Math.imul(m,K)|0;var bt=(u+(r=r+Math.imul(l,Z)|0)|0)+((8191&(n=(n=n+Math.imul(l,V)|0)+Math.imul(d,Z)|0))<<13)|0;u=((s=s+Math.imul(d,V)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(w,$),n=(n=Math.imul(w,z))+Math.imul(M,$)|0,s=Math.imul(M,z),r=r+Math.imul(v,F)|0,n=(n=n+Math.imul(v,K)|0)+Math.imul(b,F)|0,s=s+Math.imul(b,K)|0,r=r+Math.imul(p,Z)|0,n=(n=n+Math.imul(p,V)|0)+Math.imul(m,Z)|0,s=s+Math.imul(m,V)|0;var yt=(u+(r=r+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,X)|0)+Math.imul(d,Y)|0))<<13)|0;u=((s=s+Math.imul(d,X)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(S,$),n=(n=Math.imul(S,z))+Math.imul(E,$)|0,s=Math.imul(E,z),r=r+Math.imul(w,F)|0,n=(n=n+Math.imul(w,K)|0)+Math.imul(M,F)|0,s=s+Math.imul(M,K)|0,r=r+Math.imul(v,Z)|0,n=(n=n+Math.imul(v,V)|0)+Math.imul(b,Z)|0,s=s+Math.imul(b,V)|0,r=r+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,X)|0;var wt=(u+(r=r+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(d,Q)|0))<<13)|0;u=((s=s+Math.imul(d,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(R,$),n=(n=Math.imul(R,z))+Math.imul(A,$)|0,s=Math.imul(A,z),r=r+Math.imul(S,F)|0,n=(n=n+Math.imul(S,K)|0)+Math.imul(E,F)|0,s=s+Math.imul(E,K)|0,r=r+Math.imul(w,Z)|0,n=(n=n+Math.imul(w,V)|0)+Math.imul(M,Z)|0,s=s+Math.imul(M,V)|0,r=r+Math.imul(v,Y)|0,n=(n=n+Math.imul(v,X)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,X)|0,r=r+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var Mt=(u+(r=r+Math.imul(l,it)|0)|0)+((8191&(n=(n=n+Math.imul(l,rt)|0)+Math.imul(d,it)|0))<<13)|0;u=((s=s+Math.imul(d,rt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(T,$),n=(n=Math.imul(T,z))+Math.imul(P,$)|0,s=Math.imul(P,z),r=r+Math.imul(R,F)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(A,F)|0,s=s+Math.imul(A,K)|0,r=r+Math.imul(S,Z)|0,n=(n=n+Math.imul(S,V)|0)+Math.imul(E,Z)|0,s=s+Math.imul(E,V)|0,r=r+Math.imul(w,Y)|0,n=(n=n+Math.imul(w,X)|0)+Math.imul(M,Y)|0,s=s+Math.imul(M,X)|0,r=r+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,tt)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,tt)|0,r=r+Math.imul(p,it)|0,n=(n=n+Math.imul(p,rt)|0)+Math.imul(m,it)|0,s=s+Math.imul(m,rt)|0;var _t=(u+(r=r+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(d,st)|0))<<13)|0;u=((s=s+Math.imul(d,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(I,$),n=(n=Math.imul(I,z))+Math.imul(q,$)|0,s=Math.imul(q,z),r=r+Math.imul(T,F)|0,n=(n=n+Math.imul(T,K)|0)+Math.imul(P,F)|0,s=s+Math.imul(P,K)|0,r=r+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,V)|0)+Math.imul(A,Z)|0,s=s+Math.imul(A,V)|0,r=r+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,X)|0,r=r+Math.imul(w,Q)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(M,Q)|0,s=s+Math.imul(M,tt)|0,r=r+Math.imul(v,it)|0,n=(n=n+Math.imul(v,rt)|0)+Math.imul(b,it)|0,s=s+Math.imul(b,rt)|0,r=r+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(r=r+Math.imul(l,ht)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((s=s+Math.imul(d,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(L,$),n=(n=Math.imul(L,z))+Math.imul(j,$)|0,s=Math.imul(j,z),r=r+Math.imul(I,F)|0,n=(n=n+Math.imul(I,K)|0)+Math.imul(q,F)|0,s=s+Math.imul(q,K)|0,r=r+Math.imul(T,Z)|0,n=(n=n+Math.imul(T,V)|0)+Math.imul(P,Z)|0,s=s+Math.imul(P,V)|0,r=r+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,X)|0,r=r+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(E,Q)|0,s=s+Math.imul(E,tt)|0,r=r+Math.imul(w,it)|0,n=(n=n+Math.imul(w,rt)|0)+Math.imul(M,it)|0,s=s+Math.imul(M,rt)|0,r=r+Math.imul(v,st)|0,n=(n=n+Math.imul(v,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,r=r+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,ut)|0;var Et=(u+(r=r+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,dt)|0)+Math.imul(d,lt)|0))<<13)|0;u=((s=s+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(N,$),n=(n=Math.imul(N,z))+Math.imul(D,$)|0,s=Math.imul(D,z),r=r+Math.imul(L,F)|0,n=(n=n+Math.imul(L,K)|0)+Math.imul(j,F)|0,s=s+Math.imul(j,K)|0,r=r+Math.imul(I,Z)|0,n=(n=n+Math.imul(I,V)|0)+Math.imul(q,Z)|0,s=s+Math.imul(q,V)|0,r=r+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,X)|0,r=r+Math.imul(R,Q)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(A,Q)|0,s=s+Math.imul(A,tt)|0,r=r+Math.imul(S,it)|0,n=(n=n+Math.imul(S,rt)|0)+Math.imul(E,it)|0,s=s+Math.imul(E,rt)|0,r=r+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(M,st)|0,s=s+Math.imul(M,ot)|0,r=r+Math.imul(v,ht)|0,n=(n=n+Math.imul(v,ut)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ut)|0,r=r+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,dt)|0;var kt=(u+(r=r+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(d,pt)|0))<<13)|0;u=((s=s+Math.imul(d,mt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(N,F),n=(n=Math.imul(N,K))+Math.imul(D,F)|0,s=Math.imul(D,K),r=r+Math.imul(L,Z)|0,n=(n=n+Math.imul(L,V)|0)+Math.imul(j,Z)|0,s=s+Math.imul(j,V)|0,r=r+Math.imul(I,Y)|0,n=(n=n+Math.imul(I,X)|0)+Math.imul(q,Y)|0,s=s+Math.imul(q,X)|0,r=r+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(P,Q)|0,s=s+Math.imul(P,tt)|0,r=r+Math.imul(R,it)|0,n=(n=n+Math.imul(R,rt)|0)+Math.imul(A,it)|0,s=s+Math.imul(A,rt)|0,r=r+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(E,st)|0,s=s+Math.imul(E,ot)|0,r=r+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(M,ht)|0,s=s+Math.imul(M,ut)|0,r=r+Math.imul(v,lt)|0,n=(n=n+Math.imul(v,dt)|0)+Math.imul(b,lt)|0,s=s+Math.imul(b,dt)|0;var Rt=(u+(r=r+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(N,Z),n=(n=Math.imul(N,V))+Math.imul(D,Z)|0,s=Math.imul(D,V),r=r+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(j,Y)|0,s=s+Math.imul(j,X)|0,r=r+Math.imul(I,Q)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(q,Q)|0,s=s+Math.imul(q,tt)|0,r=r+Math.imul(T,it)|0,n=(n=n+Math.imul(T,rt)|0)+Math.imul(P,it)|0,s=s+Math.imul(P,rt)|0,r=r+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(A,st)|0,s=s+Math.imul(A,ot)|0,r=r+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(E,ht)|0,s=s+Math.imul(E,ut)|0,r=r+Math.imul(w,lt)|0,n=(n=n+Math.imul(w,dt)|0)+Math.imul(M,lt)|0,s=s+Math.imul(M,dt)|0;var At=(u+(r=r+Math.imul(v,pt)|0)|0)+((8191&(n=(n=n+Math.imul(v,mt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((s=s+Math.imul(b,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(N,Y),n=(n=Math.imul(N,X))+Math.imul(D,Y)|0,s=Math.imul(D,X),r=r+Math.imul(L,Q)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(j,Q)|0,s=s+Math.imul(j,tt)|0,r=r+Math.imul(I,it)|0,n=(n=n+Math.imul(I,rt)|0)+Math.imul(q,it)|0,s=s+Math.imul(q,rt)|0,r=r+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,ot)|0,r=r+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(A,ht)|0,s=s+Math.imul(A,ut)|0,r=r+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,dt)|0)+Math.imul(E,lt)|0,s=s+Math.imul(E,dt)|0;var xt=(u+(r=r+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((s=s+Math.imul(M,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(N,Q),n=(n=Math.imul(N,tt))+Math.imul(D,Q)|0,s=Math.imul(D,tt),r=r+Math.imul(L,it)|0,n=(n=n+Math.imul(L,rt)|0)+Math.imul(j,it)|0,s=s+Math.imul(j,rt)|0,r=r+Math.imul(I,st)|0,n=(n=n+Math.imul(I,ot)|0)+Math.imul(q,st)|0,s=s+Math.imul(q,ot)|0,r=r+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,ut)|0,r=r+Math.imul(R,lt)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(A,lt)|0,s=s+Math.imul(A,dt)|0;var Tt=(u+(r=r+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(E,pt)|0))<<13)|0;u=((s=s+Math.imul(E,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(N,it),n=(n=Math.imul(N,rt))+Math.imul(D,it)|0,s=Math.imul(D,rt),r=r+Math.imul(L,st)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(j,st)|0,s=s+Math.imul(j,ot)|0,r=r+Math.imul(I,ht)|0,n=(n=n+Math.imul(I,ut)|0)+Math.imul(q,ht)|0,s=s+Math.imul(q,ut)|0,r=r+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,dt)|0)+Math.imul(P,lt)|0,s=s+Math.imul(P,dt)|0;var Pt=(u+(r=r+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((s=s+Math.imul(A,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(N,st),n=(n=Math.imul(N,ot))+Math.imul(D,st)|0,s=Math.imul(D,ot),r=r+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,ut)|0)+Math.imul(j,ht)|0,s=s+Math.imul(j,ut)|0,r=r+Math.imul(I,lt)|0,n=(n=n+Math.imul(I,dt)|0)+Math.imul(q,lt)|0,s=s+Math.imul(q,dt)|0;var Bt=(u+(r=r+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((s=s+Math.imul(P,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(N,ht),n=(n=Math.imul(N,ut))+Math.imul(D,ht)|0,s=Math.imul(D,ut),r=r+Math.imul(L,lt)|0,n=(n=n+Math.imul(L,dt)|0)+Math.imul(j,lt)|0,s=s+Math.imul(j,dt)|0;var It=(u+(r=r+Math.imul(I,pt)|0)|0)+((8191&(n=(n=n+Math.imul(I,mt)|0)+Math.imul(q,pt)|0))<<13)|0;u=((s=s+Math.imul(q,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(N,lt),n=(n=Math.imul(N,dt))+Math.imul(D,lt)|0,s=Math.imul(D,dt);var qt=(u+(r=r+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,mt)|0)+Math.imul(j,pt)|0))<<13)|0;u=((s=s+Math.imul(j,mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863;var Ot=(u+(r=Math.imul(N,pt))|0)+((8191&(n=(n=Math.imul(N,mt))+Math.imul(D,pt)|0))<<13)|0;return u=((s=Math.imul(D,mt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=vt,h[2]=bt,h[3]=yt,h[4]=wt,h[5]=Mt,h[6]=_t,h[7]=St,h[8]=Et,h[9]=kt,h[10]=Rt,h[11]=At,h[12]=xt,h[13]=Tt,h[14]=Pt,h[15]=Bt,h[16]=It,h[17]=qt,h[18]=Ot,0!==u&&(h[19]=u,i.length++),i};function p(t,e,i){i.negative=e.negative^t.negative,i.length=t.length+e.length;for(var r=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}i.words[s]=a,r=o,o=n}return 0!==r?i.words[s]=r:i.length--,i._strip()}function m(t,e,i){return p(t,e,i)}function g(t,e){this.x=t,this.y=e}Math.imul||(c=d),r.prototype.mulTo=function(t,e){var i=this.length+t.length;return 10===this.length&&10===t.length?c(this,t,e):i<63?d(this,t,e):i<1024?p(this,t,e):m(this,t,e)},g.prototype.makeRBT=function(t){for(var e=new Array(t),i=r.prototype._countBits(t)-1,n=0;n>=1;return r},g.prototype.permute=function(t,e,i,r,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*s+1]=8191&n,n>>>=13;for(s=2*e;s>=26,i+=n/67108864|0,i+=s>>>26,this.words[r]=67108863&s}return 0!==i&&(this.words[r]=i,this.length++),e?this.ineg():this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),i=0;i>>n&1}return e}(t);if(0===e.length)return new r(1);for(var i=this,n=0;n>>26-i<<26-i;if(0!==i){var s=0;for(e=0;e>>26-i}s&&(this.words[e]=s,this.length++)}if(0!==r){for(e=this.length-1;e>=0;e--)this.words[e+r]=this.words[e];for(e=0;e>>n<s)for(this.length-=s,h=0;h=0&&(0!==u||h>=r);h--){var f=0|this.words[h];this.words[h]=u<<26-n|f>>>n,u=f&o}return a&&0!==u&&(a.words[a.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},r.prototype.ishrn=function(t,e,i){return this.iushrn(t,e,i)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){var e=t%26,i=(t-e)/26,r=1<>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},r.prototype.isubn=function(t){if(t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(a/67108864|0),this.words[r+i]=67108863&n}for(;r>26,this.words[r+i]=67108863&n;if(0===o)return this._strip();for(o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this._strip()},r.prototype._wordDiv=function(t,e){var i=(this.length,t.length),n=this.clone(),s=t,o=0|s.words[s.length-1];0!=(i=26-this._countBits(o))&&(s=s.ushln(i),n.iushln(i),o=0|s.words[s.length-1]);var a,h=n.length-s.length;if("mod"!==e){(a=new r(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u=0;l--){var d=67108864*(0|n.words[s.length+l])+(0|n.words[s.length+l-1]);for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(s,d,l);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(s,1,l),n.isZero()||(n.negative^=1);a&&(a.words[l]=d)}return a&&a._strip(),n._strip(),"div"!==e&&0!==i&&n.iushrn(i),{div:a||null,mod:n}},r.prototype.divmod=function(t,e,i){return this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),"mod"!==e&&(n=o.div.neg()),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),e),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new r(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modrn(t.words[0]))}:this._wordDiv(t,e);var n,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var i=0!==e.div.negative?e.mod.isub(t):e.mod,r=t.ushrn(1),n=t.andln(1),s=i.cmp(r);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},r.prototype.modrn=function(t){var e=t<0;e&&(t=-t);for(var i=(1<<26)%t,r=0,n=this.length-1;n>=0;n--)r=(i*r+(0|this.words[n]))%t;return e?-r:r},r.prototype.modn=function(t){return this.modrn(t)},r.prototype.idivn=function(t){var e=t<0;e&&(t=-t);for(var i=0,r=this.length-1;r>=0;r--){var n=(0|this.words[r])+67108864*i;this.words[r]=n/t|0,i=n%t}return this._strip(),e?this.ineg():this},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new r(1),s=new r(0),o=new r(0),a=new r(1),h=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++h;for(var u=i.clone(),f=e.clone();!e.isZero();){for(var l=0,d=1;0==(e.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(e.iushrn(l);l-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(u),s.isub(f)),n.iushrn(1),s.iushrn(1);for(var c=0,p=1;0==(i.words[0]&p)&&c<26;++c,p<<=1);if(c>0)for(i.iushrn(c);c-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(u),a.isub(f)),o.iushrn(1),a.iushrn(1);e.cmp(i)>=0?(e.isub(i),n.isub(o),s.isub(a)):(i.isub(e),o.isub(n),a.isub(s))}return{a:o,b:a,gcd:i.iushln(h)}},r.prototype._invmp=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new r(1),o=new r(0),a=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var h=0,u=1;0==(e.words[0]&u)&&h<26;++h,u<<=1);if(h>0)for(e.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(a),s.iushrn(1);for(var f=0,l=1;0==(i.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(i.iushrn(f);f-- >0;)o.isOdd()&&o.iadd(a),o.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o)):(i.isub(e),o.isub(s))}return(n=0===e.cmpn(1)?s:o).cmpn(0)<0&&n.iadd(t),n},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),i=t.clone();e.negative=0,i.negative=0;for(var r=0;e.isEven()&&i.isEven();r++)e.iushrn(1),i.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;i.isEven();)i.iushrn(1);var n=e.cmp(i);if(n<0){var s=e;e=i,i=s}else if(0===n||0===i.cmpn(1))break;e.isub(i)}return i.iushln(r)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){var e=t%26,i=(t-e)/26,r=1<>>26,o&=67108863,this.words[s]=o}return 0!==n&&(this.words[s]=n,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this._strip(),this.length>1)e=1;else{i&&(t=-t);var r=0|this.words[0];e=r===t?0:rt.length)return 1;if(this.length=0;i--){var r=0|this.words[i],n=0|t.words[i];if(r!==n){rn&&(e=1);break}}return e},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new E(t)},r.prototype.toRed=function(t){return t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return this._forceRed(t)},r.prototype.redAdd=function(t){return this.red.add(this,t)},r.prototype.redIAdd=function(t){return this.red.iadd(this,t)},r.prototype.redSub=function(t){return this.red.sub(this,t)},r.prototype.redISub=function(t){return this.red.isub(this,t)},r.prototype.redShl=function(t){return this.red.shl(this,t)},r.prototype.redMul=function(t){return this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return this.red._verify1(this),this.red.pow(this,t)};var v={k256:null,p224:null,p192:null,p25519:null};function b(t,e){this.name=t,this.p=new r(e,16),this.n=this.p.bitLength(),this.k=new r(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function y(){b.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function M(){b.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function _(){b.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function S(){b.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=r._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function k(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(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)}b.prototype._tmp=function(){var t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},b.prototype.ireduce=function(t){var e,i=t;do{this.split(i,this.tmp),e=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(e>this.n);var r=e0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},b.prototype.split=function(t,e){t.iushrn(this.n,0,e)},b.prototype.imulK=function(t){return t.imul(this.k)},i(y,b),y.prototype.split=function(t,e){for(var i=Math.min(t.length,9),r=0;r>>22,n=s}n>>>=22,t.words[r-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},y.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,i=0;i>>=26,t.words[i]=n,e=r}return 0!==e&&(t.words[t.length++]=e),t},r._prime=function(t){if(v[t])return v[t];var e;if("k256"===t)e=new y;else if("p224"===t)e=new M;else if("p192"===t)e=new _;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new S}return v[t]=e,e},E.prototype._verify1=function(t){},E.prototype._verify2=function(t,e){},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(a(t,t.umod(this.m)._forceRed(this)),t)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var i=t.add(e);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var i=t.iadd(e);return i.cmp(this.m)>=0&&i.isub(this.m),i},E.prototype.sub=function(t,e){this._verify2(t,e);var i=t.sub(e);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var i=t.isub(e);return i.cmpn(0)<0&&i.iadd(this.m),i},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();if(3===this.m.andln(3)){var e=this.m.add(new r(1)).iushrn(2);return this.pow(t,e)}for(var i=this.m.subn(1),n=0;!i.isZero()&&0===i.andln(1);)n++,i.iushrn(1);var s=new r(1).toRed(this),o=s.redNeg(),a=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new r(2*h*h).toRed(this);0!==this.pow(h,a).cmp(o);)h.redIAdd(o);for(var u=this.pow(h,i),f=this.pow(t,i.addn(1).iushrn(1)),l=this.pow(t,i),d=n;0!==l.cmp(s);){for(var c=l,p=0;0!==c.cmp(s);p++)c=c.redSqr();var m=this.pow(u,new r(1).iushln(d-p-1));f=f.redMul(m),u=m.redSqr(),l=l.redMul(u),d=p}return f},E.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},E.prototype.pow=function(t,e){if(e.isZero())return new r(1).toRed(this);if(0===e.cmpn(1))return t.clone();var i=new Array(16);i[0]=new r(1).toRed(this),i[1]=t;for(var n=2;n=0;n--){for(var u=e.words[n],f=h-1;f>=0;f--){var l=u>>f&1;s!==i[0]&&(s=this.sqr(s)),0!==l||0!==o?(o<<=1,o|=l,(4==++a||0===n&&0===f)&&(s=this.mul(s,i[o]),a=0,o=0)):a=0}h=26}return s},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},r.mont=function(t){return new k(t)},i(k,E),k.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},k.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},k.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(e),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},k.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new r(0)._forceRed(this);var i=t.mul(e),n=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=i.isub(n).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},k.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(ho,this),ho=ho.exports;var uo={};(function(t){(function(){function e(t){var e,i=t.modulus.byteLength();do{e=new ho(J(i))}while(e.cmp(t.modulus)>=0||!e.umod(t.prime1)||!e.umod(t.prime2));return e}function i(i,r){var n=function(t){var i=e(t);return{blinder:i.toRed(ho.mont(t.modulus)).redPow(new ho(t.publicExponent)).fromRed(),unblinder:i.invm(t.modulus)}}(r),s=r.modulus.byteLength(),o=new ho(i).mul(n.blinder).umod(r.modulus),a=o.toRed(ho.mont(r.prime1)),h=o.toRed(ho.mont(r.prime2)),u=r.coefficient,f=r.prime1,l=r.prime2,d=a.redPow(r.exponent1).fromRed(),c=h.redPow(r.exponent2).fromRed(),p=d.isub(c).imul(u).umod(f).imul(l);return c.iadd(p).imul(n.unblinder).umod(r.modulus).toArrayLike(t,"be",s)}i.getr=e,uo=i}).call(this)}).call(this,M({}).Buffer);var fo={exports:{}};!function(t,e){"use strict";function i(t,e){t.super_=e;var i=function(){};i.prototype=e.prototype,t.prototype=new i,t.prototype.constructor=t}function r(t,e,i){if(r.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(i=e,e=10),this._init(t||0,e||10,i||"be"))}var n;"object"==typeof t?t.exports=r:e.BN=r,r.BN=r,r.wordSize=26;try{n=w({}).Buffer}catch(jf){}function s(t,e,i){for(var r=0,n=Math.min(t.length,i),s=e;s=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return r}function o(t,e,i,r){for(var n=0,s=Math.min(t.length,i),o=e;o=49?a-49+10:a>=17?a-17+10:a}return n}r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,e){return t.cmp(e)>0?t:e},r.min=function(t,e){return t.cmp(e)<0?t:e},r.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===e?this._parseHex(t,r):this._parseBase(t,e,r),"-"===t[0]&&(this.negative=1),this.strip(),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initArray=function(t,e,i){if(t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r=0;r-=3)s=t[r]|t[r-1]<<8|t[r-2]<<16,this.words[n]|=s<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===i)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this.strip()},r.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=6)n=s(t,i,i+6),this.words[r]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,r++);i+6!==e&&(n=s(t,e,i+6),this.words[r]|=n<>>26-o&4194303),this.strip()},r.prototype._parseBase=function(t,e,i){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=e)r++;r--,n=n/e|0;for(var s=t.length-i,a=s%r,h=Math.min(s,s-a)+i,u=0,f=i;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},r.prototype.inspect=function(){return(this.red?""};var a=["","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"],h=[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],u=[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 f(t,e,i){i.negative=e.negative^t.negative;var r=t.length+e.length|0;i.length=r,r=r-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;i.words[0]=a;for(var u=1;u>>26,l=67108863&h,d=Math.min(u,e.length-1),c=Math.max(0,u-t.length+1);c<=d;c++){var p=u-c|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[c])+l)/67108864|0,l=67108863&o}i.words[u]=0|l,h=0|f}return 0!==h?i.words[u]=0|h:i.length--,i.strip()}r.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var r=0,n=0,s=0;s>>24-r&16777215)||s!==this.length-1?a[6-f.length]+f+i:f+i,(r+=2)>=26&&(r-=26,s--)}for(0!==n&&(i=n.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var l=h[t],d=u[t];i="";var c=this.clone();for(c.negative=0;!c.isZero();){var p=c.modn(d).toString(t);i=(c=c.idivn(d)).isZero()?p+i:a[l-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length,0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16)},r.prototype.toBuffer=function(t,e){return this.toArrayLike(n,t,e)},r.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},r.prototype.toArrayLike=function(t,e,i){var r=this.byteLength(),n=i||Math.max(1,r);this.strip();var s,o,a="le"===e,h=new t(n),u=this.clone();if(a){for(o=0;!u.isZero();o++)s=u.andln(255),u.iushrn(8),h[o]=s;for(;o=4096&&(i+=13,e>>>=13),e>=64&&(i+=7,e>>>=7),e>=8&&(i+=4,e>>>=4),e>=2&&(i+=2,e>>>=2),i+e},r.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,i=0;return 0==(8191&e)&&(i+=13,e>>>=13),0==(127&e)&&(i+=7,e>>>=7),0==(15&e)&&(i+=4,e>>>=4),0==(3&e)&&(i+=2,e>>>=2),0==(1&e)&&i++,i},r.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var i=0;it.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var e,i;this.length>t.length?(e=this,i=t):(e=t,i=this);for(var r=0;rt.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-i),this.strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,e){var i=t/26|0,r=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(i=this,r=t):(i=t,r=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i,r,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(i=this,r=t):(i=t,r=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,c=0|o[1],p=8191&c,m=c>>>13,g=0|o[2],v=8191&g,b=g>>>13,y=0|o[3],w=8191&y,M=y>>>13,_=0|o[4],S=8191&_,E=_>>>13,k=0|o[5],R=8191&k,A=k>>>13,x=0|o[6],T=8191&x,P=x>>>13,B=0|o[7],I=8191&B,q=B>>>13,O=0|o[8],L=8191&O,j=O>>>13,C=0|o[9],N=8191&C,D=C>>>13,U=0|a[0],$=8191&U,z=U>>>13,W=0|a[1],F=8191&W,K=W>>>13,H=0|a[2],Z=8191&H,V=H>>>13,G=0|a[3],Y=8191&G,X=G>>>13,J=0|a[4],Q=8191&J,tt=J>>>13,et=0|a[5],it=8191&et,rt=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,ft=0|a[8],lt=8191&ft,dt=ft>>>13,ct=0|a[9],pt=8191&ct,mt=ct>>>13;i.negative=t.negative^e.negative,i.length=19;var gt=(u+(r=Math.imul(l,$))|0)+((8191&(n=(n=Math.imul(l,z))+Math.imul(d,$)|0))<<13)|0;u=((s=Math.imul(d,z))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(p,$),n=(n=Math.imul(p,z))+Math.imul(m,$)|0,s=Math.imul(m,z);var vt=(u+(r=r+Math.imul(l,F)|0)|0)+((8191&(n=(n=n+Math.imul(l,K)|0)+Math.imul(d,F)|0))<<13)|0;u=((s=s+Math.imul(d,K)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(v,$),n=(n=Math.imul(v,z))+Math.imul(b,$)|0,s=Math.imul(b,z),r=r+Math.imul(p,F)|0,n=(n=n+Math.imul(p,K)|0)+Math.imul(m,F)|0,s=s+Math.imul(m,K)|0;var bt=(u+(r=r+Math.imul(l,Z)|0)|0)+((8191&(n=(n=n+Math.imul(l,V)|0)+Math.imul(d,Z)|0))<<13)|0;u=((s=s+Math.imul(d,V)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(w,$),n=(n=Math.imul(w,z))+Math.imul(M,$)|0,s=Math.imul(M,z),r=r+Math.imul(v,F)|0,n=(n=n+Math.imul(v,K)|0)+Math.imul(b,F)|0,s=s+Math.imul(b,K)|0,r=r+Math.imul(p,Z)|0,n=(n=n+Math.imul(p,V)|0)+Math.imul(m,Z)|0,s=s+Math.imul(m,V)|0;var yt=(u+(r=r+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,X)|0)+Math.imul(d,Y)|0))<<13)|0;u=((s=s+Math.imul(d,X)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(S,$),n=(n=Math.imul(S,z))+Math.imul(E,$)|0,s=Math.imul(E,z),r=r+Math.imul(w,F)|0,n=(n=n+Math.imul(w,K)|0)+Math.imul(M,F)|0,s=s+Math.imul(M,K)|0,r=r+Math.imul(v,Z)|0,n=(n=n+Math.imul(v,V)|0)+Math.imul(b,Z)|0,s=s+Math.imul(b,V)|0,r=r+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,X)|0;var wt=(u+(r=r+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(d,Q)|0))<<13)|0;u=((s=s+Math.imul(d,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(R,$),n=(n=Math.imul(R,z))+Math.imul(A,$)|0,s=Math.imul(A,z),r=r+Math.imul(S,F)|0,n=(n=n+Math.imul(S,K)|0)+Math.imul(E,F)|0,s=s+Math.imul(E,K)|0,r=r+Math.imul(w,Z)|0,n=(n=n+Math.imul(w,V)|0)+Math.imul(M,Z)|0,s=s+Math.imul(M,V)|0,r=r+Math.imul(v,Y)|0,n=(n=n+Math.imul(v,X)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,X)|0,r=r+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var Mt=(u+(r=r+Math.imul(l,it)|0)|0)+((8191&(n=(n=n+Math.imul(l,rt)|0)+Math.imul(d,it)|0))<<13)|0;u=((s=s+Math.imul(d,rt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(T,$),n=(n=Math.imul(T,z))+Math.imul(P,$)|0,s=Math.imul(P,z),r=r+Math.imul(R,F)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(A,F)|0,s=s+Math.imul(A,K)|0,r=r+Math.imul(S,Z)|0,n=(n=n+Math.imul(S,V)|0)+Math.imul(E,Z)|0,s=s+Math.imul(E,V)|0,r=r+Math.imul(w,Y)|0,n=(n=n+Math.imul(w,X)|0)+Math.imul(M,Y)|0,s=s+Math.imul(M,X)|0,r=r+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,tt)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,tt)|0,r=r+Math.imul(p,it)|0,n=(n=n+Math.imul(p,rt)|0)+Math.imul(m,it)|0,s=s+Math.imul(m,rt)|0;var _t=(u+(r=r+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(d,st)|0))<<13)|0;u=((s=s+Math.imul(d,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(I,$),n=(n=Math.imul(I,z))+Math.imul(q,$)|0,s=Math.imul(q,z),r=r+Math.imul(T,F)|0,n=(n=n+Math.imul(T,K)|0)+Math.imul(P,F)|0,s=s+Math.imul(P,K)|0,r=r+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,V)|0)+Math.imul(A,Z)|0,s=s+Math.imul(A,V)|0,r=r+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,X)|0,r=r+Math.imul(w,Q)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(M,Q)|0,s=s+Math.imul(M,tt)|0,r=r+Math.imul(v,it)|0,n=(n=n+Math.imul(v,rt)|0)+Math.imul(b,it)|0,s=s+Math.imul(b,rt)|0,r=r+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(r=r+Math.imul(l,ht)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((s=s+Math.imul(d,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(L,$),n=(n=Math.imul(L,z))+Math.imul(j,$)|0,s=Math.imul(j,z),r=r+Math.imul(I,F)|0,n=(n=n+Math.imul(I,K)|0)+Math.imul(q,F)|0,s=s+Math.imul(q,K)|0,r=r+Math.imul(T,Z)|0,n=(n=n+Math.imul(T,V)|0)+Math.imul(P,Z)|0,s=s+Math.imul(P,V)|0,r=r+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,X)|0,r=r+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(E,Q)|0,s=s+Math.imul(E,tt)|0,r=r+Math.imul(w,it)|0,n=(n=n+Math.imul(w,rt)|0)+Math.imul(M,it)|0,s=s+Math.imul(M,rt)|0,r=r+Math.imul(v,st)|0,n=(n=n+Math.imul(v,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,r=r+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,ut)|0;var Et=(u+(r=r+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,dt)|0)+Math.imul(d,lt)|0))<<13)|0;u=((s=s+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(N,$),n=(n=Math.imul(N,z))+Math.imul(D,$)|0,s=Math.imul(D,z),r=r+Math.imul(L,F)|0,n=(n=n+Math.imul(L,K)|0)+Math.imul(j,F)|0,s=s+Math.imul(j,K)|0,r=r+Math.imul(I,Z)|0,n=(n=n+Math.imul(I,V)|0)+Math.imul(q,Z)|0,s=s+Math.imul(q,V)|0,r=r+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,X)|0,r=r+Math.imul(R,Q)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(A,Q)|0,s=s+Math.imul(A,tt)|0,r=r+Math.imul(S,it)|0,n=(n=n+Math.imul(S,rt)|0)+Math.imul(E,it)|0,s=s+Math.imul(E,rt)|0,r=r+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(M,st)|0,s=s+Math.imul(M,ot)|0,r=r+Math.imul(v,ht)|0,n=(n=n+Math.imul(v,ut)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ut)|0,r=r+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,dt)|0;var kt=(u+(r=r+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(d,pt)|0))<<13)|0;u=((s=s+Math.imul(d,mt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(N,F),n=(n=Math.imul(N,K))+Math.imul(D,F)|0,s=Math.imul(D,K),r=r+Math.imul(L,Z)|0,n=(n=n+Math.imul(L,V)|0)+Math.imul(j,Z)|0,s=s+Math.imul(j,V)|0,r=r+Math.imul(I,Y)|0,n=(n=n+Math.imul(I,X)|0)+Math.imul(q,Y)|0,s=s+Math.imul(q,X)|0,r=r+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(P,Q)|0,s=s+Math.imul(P,tt)|0,r=r+Math.imul(R,it)|0,n=(n=n+Math.imul(R,rt)|0)+Math.imul(A,it)|0,s=s+Math.imul(A,rt)|0,r=r+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(E,st)|0,s=s+Math.imul(E,ot)|0,r=r+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(M,ht)|0,s=s+Math.imul(M,ut)|0,r=r+Math.imul(v,lt)|0,n=(n=n+Math.imul(v,dt)|0)+Math.imul(b,lt)|0,s=s+Math.imul(b,dt)|0;var Rt=(u+(r=r+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(N,Z),n=(n=Math.imul(N,V))+Math.imul(D,Z)|0,s=Math.imul(D,V),r=r+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(j,Y)|0,s=s+Math.imul(j,X)|0,r=r+Math.imul(I,Q)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(q,Q)|0,s=s+Math.imul(q,tt)|0,r=r+Math.imul(T,it)|0,n=(n=n+Math.imul(T,rt)|0)+Math.imul(P,it)|0,s=s+Math.imul(P,rt)|0,r=r+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(A,st)|0,s=s+Math.imul(A,ot)|0,r=r+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(E,ht)|0,s=s+Math.imul(E,ut)|0,r=r+Math.imul(w,lt)|0,n=(n=n+Math.imul(w,dt)|0)+Math.imul(M,lt)|0,s=s+Math.imul(M,dt)|0;var At=(u+(r=r+Math.imul(v,pt)|0)|0)+((8191&(n=(n=n+Math.imul(v,mt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((s=s+Math.imul(b,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(N,Y),n=(n=Math.imul(N,X))+Math.imul(D,Y)|0,s=Math.imul(D,X),r=r+Math.imul(L,Q)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(j,Q)|0,s=s+Math.imul(j,tt)|0,r=r+Math.imul(I,it)|0,n=(n=n+Math.imul(I,rt)|0)+Math.imul(q,it)|0,s=s+Math.imul(q,rt)|0,r=r+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,ot)|0,r=r+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(A,ht)|0,s=s+Math.imul(A,ut)|0,r=r+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,dt)|0)+Math.imul(E,lt)|0,s=s+Math.imul(E,dt)|0;var xt=(u+(r=r+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((s=s+Math.imul(M,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(N,Q),n=(n=Math.imul(N,tt))+Math.imul(D,Q)|0,s=Math.imul(D,tt),r=r+Math.imul(L,it)|0,n=(n=n+Math.imul(L,rt)|0)+Math.imul(j,it)|0,s=s+Math.imul(j,rt)|0,r=r+Math.imul(I,st)|0,n=(n=n+Math.imul(I,ot)|0)+Math.imul(q,st)|0,s=s+Math.imul(q,ot)|0,r=r+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,ut)|0,r=r+Math.imul(R,lt)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(A,lt)|0,s=s+Math.imul(A,dt)|0;var Tt=(u+(r=r+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(E,pt)|0))<<13)|0;u=((s=s+Math.imul(E,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(N,it),n=(n=Math.imul(N,rt))+Math.imul(D,it)|0,s=Math.imul(D,rt),r=r+Math.imul(L,st)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(j,st)|0,s=s+Math.imul(j,ot)|0,r=r+Math.imul(I,ht)|0,n=(n=n+Math.imul(I,ut)|0)+Math.imul(q,ht)|0,s=s+Math.imul(q,ut)|0,r=r+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,dt)|0)+Math.imul(P,lt)|0,s=s+Math.imul(P,dt)|0;var Pt=(u+(r=r+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((s=s+Math.imul(A,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(N,st),n=(n=Math.imul(N,ot))+Math.imul(D,st)|0,s=Math.imul(D,ot),r=r+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,ut)|0)+Math.imul(j,ht)|0,s=s+Math.imul(j,ut)|0,r=r+Math.imul(I,lt)|0,n=(n=n+Math.imul(I,dt)|0)+Math.imul(q,lt)|0,s=s+Math.imul(q,dt)|0;var Bt=(u+(r=r+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((s=s+Math.imul(P,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(N,ht),n=(n=Math.imul(N,ut))+Math.imul(D,ht)|0,s=Math.imul(D,ut),r=r+Math.imul(L,lt)|0,n=(n=n+Math.imul(L,dt)|0)+Math.imul(j,lt)|0,s=s+Math.imul(j,dt)|0;var It=(u+(r=r+Math.imul(I,pt)|0)|0)+((8191&(n=(n=n+Math.imul(I,mt)|0)+Math.imul(q,pt)|0))<<13)|0;u=((s=s+Math.imul(q,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(N,lt),n=(n=Math.imul(N,dt))+Math.imul(D,lt)|0,s=Math.imul(D,dt);var qt=(u+(r=r+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,mt)|0)+Math.imul(j,pt)|0))<<13)|0;u=((s=s+Math.imul(j,mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863;var Ot=(u+(r=Math.imul(N,pt))|0)+((8191&(n=(n=Math.imul(N,mt))+Math.imul(D,pt)|0))<<13)|0;return u=((s=Math.imul(D,mt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=vt,h[2]=bt,h[3]=yt,h[4]=wt,h[5]=Mt,h[6]=_t,h[7]=St,h[8]=Et,h[9]=kt,h[10]=Rt,h[11]=At,h[12]=xt,h[13]=Tt,h[14]=Pt,h[15]=Bt,h[16]=It,h[17]=qt,h[18]=Ot,0!==u&&(h[19]=u,i.length++),i};function d(t,e,i){return(new c).mulp(t,e,i)}function c(t,e){this.x=t,this.y=e}Math.imul||(l=f),r.prototype.mulTo=function(t,e){var i=this.length+t.length;return 10===this.length&&10===t.length?l(this,t,e):i<63?f(this,t,e):i<1024?function(t,e,i){i.negative=e.negative^t.negative,i.length=t.length+e.length;for(var r=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}i.words[s]=a,r=o,o=n}return 0!==r?i.words[s]=r:i.length--,i.strip()}(this,t,e):d(this,t,e)},c.prototype.makeRBT=function(t){for(var e=new Array(t),i=r.prototype._countBits(t)-1,n=0;n>=1;return r},c.prototype.permute=function(t,e,i,r,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*s+1]=8191&n,n>>>=13;for(s=2*e;s>=26,e+=r/67108864|0,e+=n>>>26,this.words[i]=67108863&n}return 0!==e&&(this.words[i]=e,this.length++),this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),i=0;i>>n}return e}(t);if(0===e.length)return new r(1);for(var i=this,n=0;n>>26-i<<26-i;if(0!==i){var s=0;for(e=0;e>>26-i}s&&(this.words[e]=s,this.length++)}if(0!==r){for(e=this.length-1;e>=0;e--)this.words[e+r]=this.words[e];for(e=0;e>>n<s)for(this.length-=s,h=0;h=0&&(0!==u||h>=r);h--){var f=0|this.words[h];this.words[h]=u<<26-n|f>>>n,u=f&o}return a&&0!==u&&(a.words[a.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},r.prototype.ishrn=function(t,e,i){return this.iushrn(t,e,i)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){var e=t%26,i=(t-e)/26,r=1<>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},r.prototype.isubn=function(t){if(t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(a/67108864|0),this.words[r+i]=67108863&n}for(;r>26,this.words[r+i]=67108863&n;if(0===o)return this.strip();for(o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},r.prototype._wordDiv=function(t,e){var i=(this.length,t.length),n=this.clone(),s=t,o=0|s.words[s.length-1];0!=(i=26-this._countBits(o))&&(s=s.ushln(i),n.iushln(i),o=0|s.words[s.length-1]);var a,h=n.length-s.length;if("mod"!==e){(a=new r(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u=0;l--){var d=67108864*(0|n.words[s.length+l])+(0|n.words[s.length+l-1]);for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(s,d,l);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(s,1,l),n.isZero()||(n.negative^=1);a&&(a.words[l]=d)}return a&&a.strip(),n.strip(),"div"!==e&&0!==i&&n.iushrn(i),{div:a||null,mod:n}},r.prototype.divmod=function(t,e,i){return this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),"mod"!==e&&(n=o.div.neg()),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),e),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new r(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var i=0!==e.div.negative?e.mod.isub(t):e.mod,r=t.ushrn(1),n=t.andln(1),s=i.cmp(r);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},r.prototype.modn=function(t){for(var e=(1<<26)%t,i=0,r=this.length-1;r>=0;r--)i=(e*i+(0|this.words[r]))%t;return i},r.prototype.idivn=function(t){for(var e=0,i=this.length-1;i>=0;i--){var r=(0|this.words[i])+67108864*e;this.words[i]=r/t|0,e=r%t}return this.strip()},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new r(1),s=new r(0),o=new r(0),a=new r(1),h=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++h;for(var u=i.clone(),f=e.clone();!e.isZero();){for(var l=0,d=1;0==(e.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(e.iushrn(l);l-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(u),s.isub(f)),n.iushrn(1),s.iushrn(1);for(var c=0,p=1;0==(i.words[0]&p)&&c<26;++c,p<<=1);if(c>0)for(i.iushrn(c);c-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(u),a.isub(f)),o.iushrn(1),a.iushrn(1);e.cmp(i)>=0?(e.isub(i),n.isub(o),s.isub(a)):(i.isub(e),o.isub(n),a.isub(s))}return{a:o,b:a,gcd:i.iushln(h)}},r.prototype._invmp=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new r(1),o=new r(0),a=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var h=0,u=1;0==(e.words[0]&u)&&h<26;++h,u<<=1);if(h>0)for(e.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(a),s.iushrn(1);for(var f=0,l=1;0==(i.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(i.iushrn(f);f-- >0;)o.isOdd()&&o.iadd(a),o.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o)):(i.isub(e),o.isub(s))}return(n=0===e.cmpn(1)?s:o).cmpn(0)<0&&n.iadd(t),n},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),i=t.clone();e.negative=0,i.negative=0;for(var r=0;e.isEven()&&i.isEven();r++)e.iushrn(1),i.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;i.isEven();)i.iushrn(1);var n=e.cmp(i);if(n<0){var s=e;e=i,i=s}else if(0===n||0===i.cmpn(1))break;e.isub(i)}return i.iushln(r)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){var e=t%26,i=(t-e)/26,r=1<>>26,o&=67108863,this.words[s]=o}return 0!==n&&(this.words[s]=n,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t);var r=0|this.words[0];e=r===t?0:rt.length)return 1;if(this.length=0;i--){var r=0|this.words[i],n=0|t.words[i];if(r!==n){rn&&(e=1);break}}return e},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new M(t)},r.prototype.toRed=function(t){return t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return this._forceRed(t)},r.prototype.redAdd=function(t){return this.red.add(this,t)},r.prototype.redIAdd=function(t){return this.red.iadd(this,t)},r.prototype.redSub=function(t){return this.red.sub(this,t)},r.prototype.redISub=function(t){return this.red.isub(this,t)},r.prototype.redShl=function(t){return this.red.shl(this,t)},r.prototype.redMul=function(t){return this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return this.red._verify1(this),this.red.pow(this,t)};var p={k256:null,p224:null,p192:null,p25519:null};function m(t,e){this.name=t,this.p=new r(e,16),this.n=this.p.bitLength(),this.k=new r(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 v(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function y(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(t){if("string"==typeof t){var e=r._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function _(t){M.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(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 t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},m.prototype.ireduce=function(t){var e,i=t;do{this.split(i,this.tmp),e=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(e>this.n);var r=e0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},m.prototype.split=function(t,e){t.iushrn(this.n,0,e)},m.prototype.imulK=function(t){return t.imul(this.k)},i(g,m),g.prototype.split=function(t,e){for(var i=Math.min(t.length,9),r=0;r>>22,n=s}n>>>=22,t.words[r-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},g.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,i=0;i>>=26,t.words[i]=n,e=r}return 0!==e&&(t.words[t.length++]=e),t},r._prime=function(t){if(p[t])return p[t];var e;if("k256"===t)e=new g;else if("p224"===t)e=new v;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new y}return p[t]=e,e},M.prototype._verify1=function(t){},M.prototype._verify2=function(t,e){},M.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},M.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},M.prototype.add=function(t,e){this._verify2(t,e);var i=t.add(e);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},M.prototype.iadd=function(t,e){this._verify2(t,e);var i=t.iadd(e);return i.cmp(this.m)>=0&&i.isub(this.m),i},M.prototype.sub=function(t,e){this._verify2(t,e);var i=t.sub(e);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},M.prototype.isub=function(t,e){this._verify2(t,e);var i=t.isub(e);return i.cmpn(0)<0&&i.iadd(this.m),i},M.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},M.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},M.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},M.prototype.isqr=function(t){return this.imul(t,t.clone())},M.prototype.sqr=function(t){return this.mul(t,t)},M.prototype.sqrt=function(t){if(t.isZero())return t.clone();if(3===this.m.andln(3)){var e=this.m.add(new r(1)).iushrn(2);return this.pow(t,e)}for(var i=this.m.subn(1),n=0;!i.isZero()&&0===i.andln(1);)n++,i.iushrn(1);var s=new r(1).toRed(this),o=s.redNeg(),a=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new r(2*h*h).toRed(this);0!==this.pow(h,a).cmp(o);)h.redIAdd(o);for(var u=this.pow(h,i),f=this.pow(t,i.addn(1).iushrn(1)),l=this.pow(t,i),d=n;0!==l.cmp(s);){for(var c=l,p=0;0!==c.cmp(s);p++)c=c.redSqr();var m=this.pow(u,new r(1).iushln(d-p-1));f=f.redMul(m),u=m.redSqr(),l=l.redMul(u),d=p}return f},M.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},M.prototype.pow=function(t,e){if(e.isZero())return new r(1).toRed(this);if(0===e.cmpn(1))return t.clone();var i=new Array(16);i[0]=new r(1).toRed(this),i[1]=t;for(var n=2;n=0;n--){for(var u=e.words[n],f=h-1;f>=0;f--){var l=u>>f&1;s!==i[0]&&(s=this.sqr(s)),0!==l||0!==o?(o<<=1,o|=l,(4==++a||0===n&&0===f)&&(s=this.mul(s,i[o]),a=0,o=0)):a=0}h=26}return s},M.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},M.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},r.mont=function(t){return new _(t)},i(_,M),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(e),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new r(0)._forceRed(this);var i=t.mul(e),n=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=i.isub(n).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(fo,this),fo=fo.exports;var lo={},co=lo;function po(t){return 1===t.length?"0"+t:t}function mo(t){for(var e="",i=0;i>8,o=255&n;s?i.push(s,o):i.push(o)}return i},co.zero2=po,co.toHex=mo,co.encode=function(t,e){return"hex"===e?mo(t):t};var go={},vo=go;vo.assert=$r,vo.toArray=lo.toArray,vo.zero2=lo.zero2,vo.toHex=lo.toHex,vo.encode=lo.encode,vo.getNAF=function(t,e,i){var r=new Array(Math.max(t.bitLength(),i)+1);r.fill(0);for(var n=1<(n>>1)-1?(n>>1)-h:h,s.isubn(a)):a=0,r[o]=a,s.iushrn(1)}return r},vo.getJSF=function(t,e){var i=[[],[]];t=t.clone(),e=e.clone();for(var r,n=0,s=0;t.cmpn(-n)>0||e.cmpn(-s)>0;){var o,a,h=t.andln(3)+n&3,u=e.andln(3)+s&3;3===h&&(h=-1),3===u&&(u=-1),o=0==(1&h)?0:3!=(r=t.andln(7)+n&7)&&5!==r||2!==u?h:-h,i[0].push(o),a=0==(1&u)?0:3!=(r=e.andln(7)+s&7)&&5!==r||2!==h?u:-u,i[1].push(a),2*n===o+1&&(n=1-n),2*s===a+1&&(s=1-s),t.iushrn(1),e.iushrn(1)}return i},vo.cachedProperty=function(t,e,i){var r="_"+e;t.prototype[e]=function(){return void 0!==this[r]?this[r]:this[r]=i.call(this)}},vo.parseBytes=function(t){return"string"==typeof t?vo.toArray(t,"hex"):t},vo.intFromLE=function(t){return new fo(t,"hex","le")};var bo={},yo=go.getNAF,wo=go.getJSF;function Mo(t,e){this.type=t,this.p=new fo(e.p,16),this.red=e.prime?fo.red(e.prime):fo.mont(this.p),this.zero=new fo(0).toRed(this.red),this.one=new fo(1).toRed(this.red),this.two=new fo(2).toRed(this.red),this.n=e.n&&new fo(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var i=this.n&&this.p.div(this.n);!i||i.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function _o(t,e){this.curve=t,this.type=e,this.precomputed=null}go.assert,bo=Mo,Mo.prototype.point=function(){throw new Error("Not implemented")},Mo.prototype.validate=function(){throw new Error("Not implemented")},Mo.prototype._fixedNafMul=function(t,e){var i=t._getDoubles(),r=yo(e,1,this._bitLength),n=(1<=s;h--)o=(o<<1)+r[h];a.push(o)}for(var u=this.jpoint(null,null,null),f=this.jpoint(null,null,null),l=n;l>0;l--){for(s=0;s=0;a--){for(var h=0;a>=0&&0===s[a];a--)h++;if(a>=0&&h++,o=o.dblp(h),a<0)break;var u=s[a];o="affine"===t.type?u>0?o.mixedAdd(n[u-1>>1]):o.mixedAdd(n[-u-1>>1].neg()):u>0?o.add(n[u-1>>1]):o.add(n[-u-1>>1].neg())}return"affine"===t.type?o.toP():o},Mo.prototype._wnafMulAdd=function(t,e,i,r,n){var s,o,a,h=this._wnafT1,u=this._wnafT2,f=this._wnafT3,l=0;for(s=0;s=1;s-=2){var c=s-1,p=s;if(1===h[c]&&1===h[p]){var m=[e[c],null,null,e[p]];0===e[c].y.cmp(e[p].y)?(m[1]=e[c].add(e[p]),m[2]=e[c].toJ().mixedAdd(e[p].neg())):0===e[c].y.cmp(e[p].y.redNeg())?(m[1]=e[c].toJ().mixedAdd(e[p]),m[2]=e[c].add(e[p].neg())):(m[1]=e[c].toJ().mixedAdd(e[p]),m[2]=e[c].toJ().mixedAdd(e[p].neg()));var g=[-3,-1,-5,-7,0,7,5,1,3],v=wo(i[c],i[p]);for(l=Math.max(v[0].length,l),f[c]=new Array(l),f[p]=new Array(l),o=0;o=0;s--){for(var _=0;s>=0;){var S=!0;for(o=0;o=0&&_++,w=w.dblp(_),s<0)break;for(o=0;o0?a=u[o][E-1>>1]:E<0&&(a=u[o][-E-1>>1].neg()),w="affine"===a.type?w.mixedAdd(a):w.add(a))}}for(s=0;s=Math.ceil((t.bitLength()+1)/e.step)},_o.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],r=this,n=0;n=0&&(s=e,o=i),r.negative&&(r=r.neg(),n=n.neg()),s.negative&&(s=s.neg(),o=o.neg()),[{a:r,b:n},{a:s,b:o}]},Eo.prototype._endoSplit=function(t){var e=this.endo.basis,i=e[0],r=e[1],n=r.b.mul(t).divRound(this.n),s=i.b.neg().mul(t).divRound(this.n),o=n.mul(i.a),a=s.mul(r.a),h=n.mul(i.b),u=s.mul(r.b);return{k1:t.sub(o).sub(a),k2:h.add(u).neg()}},Eo.prototype.pointFromX=function(t,e){(t=new fo(t,16)).red||(t=t.toRed(this.red));var i=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),r=i.redSqrt();if(0!==r.redSqr().redSub(i).cmp(this.zero))throw new Error("invalid point");var n=r.fromRed().isOdd();return(e&&!n||!e&&n)&&(r=r.redNeg()),this.point(t,r)},Eo.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,i=t.y,r=this.a.redMul(e),n=e.redSqr().redMul(e).redIAdd(r).redIAdd(this.b);return 0===i.redSqr().redISub(n).cmpn(0)},Eo.prototype._endoWnafMulAdd=function(t,e,i){for(var r=this._endoWnafT1,n=this._endoWnafT2,s=0;s":""},ko.prototype.isInfinity=function(){return this.inf},ko.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var i=e.redSqr().redISub(this.x).redISub(t.x),r=e.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,r)},ko.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,i=this.x.redSqr(),r=t.redInvm(),n=i.redAdd(i).redIAdd(i).redIAdd(e).redMul(r),s=n.redSqr().redISub(this.x.redAdd(this.x)),o=n.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,o)},ko.prototype.getX=function(){return this.x.fromRed()},ko.prototype.getY=function(){return this.y.fromRed()},ko.prototype.mul=function(t){return t=new fo(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},ko.prototype.mulAdd=function(t,e,i){var r=[this,e],n=[t,i];return this.curve.endo?this.curve._endoWnafMulAdd(r,n):this.curve._wnafMulAdd(1,r,n,2)},ko.prototype.jmulAdd=function(t,e,i){var r=[this,e],n=[t,i];return this.curve.endo?this.curve._endoWnafMulAdd(r,n,!0):this.curve._wnafMulAdd(1,r,n,2,!0)},ko.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},ko.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var i=this.precomputed,r=function(t){return t.neg()};e.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(r)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(r)}}}return e},ko.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},Q(Ro,bo.BasePoint),Eo.prototype.jpoint=function(t,e,i){return new Ro(this,t,e,i)},Ro.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),i=this.x.redMul(e),r=this.y.redMul(e).redMul(t);return this.curve.point(i,r)},Ro.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Ro.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),i=this.z.redSqr(),r=this.x.redMul(e),n=t.x.redMul(i),s=this.y.redMul(e.redMul(t.z)),o=t.y.redMul(i.redMul(this.z)),a=r.redSub(n),h=s.redSub(o);if(0===a.cmpn(0))return 0!==h.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),f=u.redMul(a),l=r.redMul(u),d=h.redSqr().redIAdd(f).redISub(l).redISub(l),c=h.redMul(l.redISub(d)).redISub(s.redMul(f)),p=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(d,c,p)},Ro.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),i=this.x,r=t.x.redMul(e),n=this.y,s=t.y.redMul(e).redMul(this.z),o=i.redSub(r),a=n.redSub(s);if(0===o.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=o.redSqr(),u=h.redMul(o),f=i.redMul(h),l=a.redSqr().redIAdd(u).redISub(f).redISub(f),d=a.redMul(f.redISub(l)).redISub(n.redMul(u)),c=this.z.redMul(o);return this.curve.jpoint(l,d,c)},Ro.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var i=this;for(e=0;e=0)return!1;if(i.redIAdd(n),0===this.x.cmp(i))return!0}},Ro.prototype.inspect=function(){return this.isInfinity()?"":""},Ro.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var Ao;function xo(t){bo.call(this,"mont",t),this.a=new fo(t.a,16).toRed(this.red),this.b=new fo(t.b,16).toRed(this.red),this.i4=new fo(4).toRed(this.red).redInvm(),this.two=new fo(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function To(t,e,i){bo.BasePoint.call(this,t,"projective"),null===e&&null===i?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new fo(e,16),this.z=new fo(i,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}Q(xo,bo),Ao=xo,xo.prototype.validate=function(t){var e=t.normalize().x,i=e.redSqr(),r=i.redMul(e).redAdd(i.redMul(this.a)).redAdd(e);return 0===r.redSqrt().redSqr().cmp(r)},Q(To,bo.BasePoint),xo.prototype.decodePoint=function(t,e){return this.point(go.toArray(t,e),1)},xo.prototype.point=function(t,e){return new To(this,t,e)},xo.prototype.pointFromJSON=function(t){return To.fromJSON(this,t)},To.prototype.precompute=function(){},To.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},To.fromJSON=function(t,e){return new To(t,e[0],e[1]||t.one)},To.prototype.inspect=function(){return this.isInfinity()?"":""},To.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},To.prototype.dbl=function(){var t=this.x.redAdd(this.z).redSqr(),e=this.x.redSub(this.z).redSqr(),i=t.redSub(e),r=t.redMul(e),n=i.redMul(e.redAdd(this.curve.a24.redMul(i)));return this.curve.point(r,n)},To.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},To.prototype.diffAdd=function(t,e){var i=this.x.redAdd(this.z),r=this.x.redSub(this.z),n=t.x.redAdd(t.z),s=t.x.redSub(t.z).redMul(i),o=n.redMul(r),a=e.z.redMul(s.redAdd(o).redSqr()),h=e.x.redMul(s.redISub(o).redSqr());return this.curve.point(a,h)},To.prototype.mul=function(t){for(var e=t.clone(),i=this,r=this.curve.point(null,null),n=[];0!==e.cmpn(0);e.iushrn(1))n.push(e.andln(1));for(var s=n.length-1;s>=0;s--)0===n[s]?(i=i.diffAdd(r,this),r=r.dbl()):(r=i.diffAdd(r,this),i=i.dbl());return r},To.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},To.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},To.prototype.eq=function(t){return 0===this.getX().cmp(t.getX())},To.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},To.prototype.getX=function(){return this.normalize(),this.x.fromRed()};var Po;function Bo(t){this.twisted=1!=(0|t.a),this.mOneA=this.twisted&&-1==(0|t.a),this.extended=this.mOneA,bo.call(this,"edwards",t),this.a=new fo(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new fo(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new fo(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),this.oneC=1==(0|t.c)}function Io(t,e,i,r,n){bo.BasePoint.call(this,t,"projective"),null===e&&null===i&&null===r?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new fo(e,16),this.y=new fo(i,16),this.z=r?new fo(r,16):this.curve.one,this.t=n&&new fo(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.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()))))}go.assert,Q(Bo,bo),Po=Bo,Bo.prototype._mulA=function(t){return this.mOneA?t.redNeg():this.a.redMul(t)},Bo.prototype._mulC=function(t){return this.oneC?t:this.c.redMul(t)},Bo.prototype.jpoint=function(t,e,i,r){return this.point(t,e,i,r)},Bo.prototype.pointFromX=function(t,e){(t=new fo(t,16)).red||(t=t.toRed(this.red));var i=t.redSqr(),r=this.c2.redSub(this.a.redMul(i)),n=this.one.redSub(this.c2.redMul(this.d).redMul(i)),s=r.redMul(n.redInvm()),o=s.redSqrt();if(0!==o.redSqr().redSub(s).cmp(this.zero))throw new Error("invalid point");var a=o.fromRed().isOdd();return(e&&!a||!e&&a)&&(o=o.redNeg()),this.point(t,o)},Bo.prototype.pointFromY=function(t,e){(t=new fo(t,16)).red||(t=t.toRed(this.red));var i=t.redSqr(),r=i.redSub(this.c2),n=i.redMul(this.d).redMul(this.c2).redSub(this.a),s=r.redMul(n.redInvm());if(0===s.cmp(this.zero)){if(e)throw new Error("invalid point");return this.point(this.zero,t)}var o=s.redSqrt();if(0!==o.redSqr().redSub(s).cmp(this.zero))throw new Error("invalid point");return o.fromRed().isOdd()!==e&&(o=o.redNeg()),this.point(o,t)},Bo.prototype.validate=function(t){if(t.isInfinity())return!0;t.normalize();var e=t.x.redSqr(),i=t.y.redSqr(),r=e.redMul(this.a).redAdd(i),n=this.c2.redMul(this.one.redAdd(this.d.redMul(e).redMul(i)));return 0===r.cmp(n)},Q(Io,bo.BasePoint),Bo.prototype.pointFromJSON=function(t){return Io.fromJSON(this,t)},Bo.prototype.point=function(t,e,i,r){return new Io(this,t,e,i,r)},Io.fromJSON=function(t,e){return new Io(t,e[0],e[1],e[2])},Io.prototype.inspect=function(){return this.isInfinity()?"":""},Io.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},Io.prototype._extDbl=function(){var t=this.x.redSqr(),e=this.y.redSqr(),i=this.z.redSqr();i=i.redIAdd(i);var r=this.curve._mulA(t),n=this.x.redAdd(this.y).redSqr().redISub(t).redISub(e),s=r.redAdd(e),o=s.redSub(i),a=r.redSub(e),h=n.redMul(o),u=s.redMul(a),f=n.redMul(a),l=o.redMul(s);return this.curve.point(h,u,l,f)},Io.prototype._projDbl=function(){var t,e,i,r,n,s,o=this.x.redAdd(this.y).redSqr(),a=this.x.redSqr(),h=this.y.redSqr();if(this.curve.twisted){var u=(r=this.curve._mulA(a)).redAdd(h);this.zOne?(t=o.redSub(a).redSub(h).redMul(u.redSub(this.curve.two)),e=u.redMul(r.redSub(h)),i=u.redSqr().redSub(u).redSub(u)):(n=this.z.redSqr(),s=u.redSub(n).redISub(n),t=o.redSub(a).redISub(h).redMul(s),e=u.redMul(r.redSub(h)),i=u.redMul(s))}else r=a.redAdd(h),n=this.curve._mulC(this.z).redSqr(),s=r.redSub(n).redSub(n),t=this.curve._mulC(o.redISub(r)).redMul(s),e=this.curve._mulC(r).redMul(a.redISub(h)),i=r.redMul(s);return this.curve.point(t,e,i)},Io.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},Io.prototype._extAdd=function(t){var e=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),i=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),r=this.t.redMul(this.curve.dd).redMul(t.t),n=this.z.redMul(t.z.redAdd(t.z)),s=i.redSub(e),o=n.redSub(r),a=n.redAdd(r),h=i.redAdd(e),u=s.redMul(o),f=a.redMul(h),l=s.redMul(h),d=o.redMul(a);return this.curve.point(u,f,d,l)},Io.prototype._projAdd=function(t){var e,i,r=this.z.redMul(t.z),n=r.redSqr(),s=this.x.redMul(t.x),o=this.y.redMul(t.y),a=this.curve.d.redMul(s).redMul(o),h=n.redSub(a),u=n.redAdd(a),f=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(s).redISub(o),l=r.redMul(h).redMul(f);return this.curve.twisted?(e=r.redMul(u).redMul(o.redSub(this.curve._mulA(s))),i=h.redMul(u)):(e=r.redMul(u).redMul(o.redSub(s)),i=this.curve._mulC(h).redMul(u)),this.curve.point(l,e,i)},Io.prototype.add=function(t){return this.isInfinity()?t:t.isInfinity()?this:this.curve.extended?this._extAdd(t):this._projAdd(t)},Io.prototype.mul=function(t){return this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve._wnafMul(this,t)},Io.prototype.mulAdd=function(t,e,i){return this.curve._wnafMulAdd(1,[this,e],[t,i],2,!1)},Io.prototype.jmulAdd=function(t,e,i){return this.curve._wnafMulAdd(1,[this,e],[t,i],2,!0)},Io.prototype.normalize=function(){if(this.zOne)return this;var t=this.z.redInvm();return this.x=this.x.redMul(t),this.y=this.y.redMul(t),this.t&&(this.t=this.t.redMul(t)),this.z=this.curve.one,this.zOne=!0,this},Io.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},Io.prototype.getX=function(){return this.normalize(),this.x.fromRed()},Io.prototype.getY=function(){return this.normalize(),this.y.fromRed()},Io.prototype.eq=function(t){return this===t||0===this.getX().cmp(t.getX())&&0===this.getY().cmp(t.getY())},Io.prototype.eqXToP=function(t){var e=t.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(e))return!0;for(var i=t.clone(),r=this.curve.redN.redMul(this.z);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(e.redIAdd(r),0===this.x.cmp(e))return!0}},Io.prototype.toP=Io.prototype.normalize,Io.prototype.mixedAdd=Io.prototype.add;var qo={},Oo=qo;Oo.base=bo,Oo.short=So,Oo.mont=Ao,Oo.edwards=Po;var Lo={};function jo(t,e){return 55296==(64512&t.charCodeAt(e))&&!(e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1))}function Co(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function No(t){return 1===t.length?"0"+t:t}function Do(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}Lo.inherits=Q,Lo.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var i=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),n=0;n>6|192,i[r++]=63&s|128):jo(t,n)?(s=65536+((1023&s)<<10)+(1023&t.charCodeAt(++n)),i[r++]=s>>18|240,i[r++]=s>>12&63|128,i[r++]=s>>6&63|128,i[r++]=63&s|128):(i[r++]=s>>12|224,i[r++]=s>>6&63|128,i[r++]=63&s|128)}else for(n=0;n>>0}return n},Lo.split32=function(t,e){for(var i=new Array(4*t.length),r=0,n=0;r>>24,i[n+1]=s>>>16&255,i[n+2]=s>>>8&255,i[n+3]=255&s):(i[n+3]=s>>>24,i[n+2]=s>>>16&255,i[n+1]=s>>>8&255,i[n]=255&s)}return i},Lo.rotr32=function(t,e){return t>>>e|t<<32-e},Lo.rotl32=function(t,e){return t<>>32-e},Lo.sum32=function(t,e){return t+e>>>0},Lo.sum32_3=function(t,e,i){return t+e+i>>>0},Lo.sum32_4=function(t,e,i,r){return t+e+i+r>>>0},Lo.sum32_5=function(t,e,i,r,n){return t+e+i+r+n>>>0},Lo.sum64=function(t,e,i,r){var n=t[e],s=r+t[e+1]>>>0,o=(s>>0,t[e+1]=s},Lo.sum64_hi=function(t,e,i,r){return(e+r>>>0>>0},Lo.sum64_lo=function(t,e,i,r){return e+r>>>0},Lo.sum64_4_hi=function(t,e,i,r,n,s,o,a){var h=0,u=e;return h+=(u=u+r>>>0)>>0)>>0)>>0},Lo.sum64_4_lo=function(t,e,i,r,n,s,o,a){return e+r+s+a>>>0},Lo.sum64_5_hi=function(t,e,i,r,n,s,o,a,h,u){var f=0,l=e;return f+=(l=l+r>>>0)>>0)>>0)>>0)>>0},Lo.sum64_5_lo=function(t,e,i,r,n,s,o,a,h,u){return e+r+s+a+u>>>0},Lo.rotr64_hi=function(t,e,i){return(e<<32-i|t>>>i)>>>0},Lo.rotr64_lo=function(t,e,i){return(t<<32-i|e>>>i)>>>0},Lo.shr64_hi=function(t,e,i){return t>>>i},Lo.shr64_lo=function(t,e,i){return(t<<32-i|e>>>i)>>>0};var Uo={};function $o(){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}Uo.BlockHash=$o,$o.prototype.update=function(t,e){if(t=Lo.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var i=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-i,t.length),0===this.pending.length&&(this.pending=null),t=Lo.join32(t,0,t.length-i,this.endian);for(var r=0;r>>24&255,r[n++]=t>>>16&255,r[n++]=t>>>8&255,r[n++]=255&t}else for(r[n++]=255&t,r[n++]=t>>>8&255,r[n++]=t>>>16&255,r[n++]=t>>>24&255,r[n++]=0,r[n++]=0,r[n++]=0,r[n++]=0,s=8;s>>3},zo.g1_256=function(t){return Wo(t,17)^Wo(t,19)^t>>>10};var Zo,Vo=Lo.rotl32,Go=Lo.sum32,Yo=Lo.sum32_5,Xo=zo.ft_1,Jo=Uo.BlockHash,Qo=[1518500249,1859775393,2400959708,3395469782];function ta(){if(!(this instanceof ta))return new ta;Jo.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Lo.inherits(ta,Jo),Zo=ta,ta.blockSize=512,ta.outSize=160,ta.hmacStrength=80,ta.padLength=64,ta.prototype._update=function(t,e){for(var i=this.W,r=0;r<16;r++)i[r]=t[e+r];for(;rthis.blockSize&&(t=(new this.Hash).update(t).digest());for(var e=t.length;ethis.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(r=i,i=e,e=null),i&&(i=lo.toArray(i,r||"hex"),this._update(i));for(var n=[];n.length"};var yh={};function wh(t,e){if(t instanceof wh)return t;this._importDER(t,e)||(this.r=new fo(t.r,16),this.s=new fo(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}function Mh(){this.place=0}function _h(t,e){var i=t[e.place++];if(!(128&i))return i;var r=15&i;if(0===r||r>4)return!1;for(var n=0,s=0,o=e.place;s>>=0;return!(n<=127)&&(e.place=o,n)}function Sh(t){for(var e=0,i=t.length-1;!t[e]&&!(128&t[e+1])&&e>>3);for(t.push(128|i);--i;)t.push(e>>>(i<<3)&255);t.push(e)}}go.assert,yh=wh,wh.prototype._importDER=function(t,e){t=go.toArray(t,e);var i=new Mh;if(48!==t[i.place++])return!1;var r=_h(t,i);if(!1===r)return!1;if(r+i.place!==t.length)return!1;if(2!==t[i.place++])return!1;var n=_h(t,i);if(!1===n)return!1;var s=t.slice(i.place,n+i.place);if(i.place+=n,2!==t[i.place++])return!1;var o=_h(t,i);if(!1===o)return!1;if(t.length!==o+i.place)return!1;var a=t.slice(i.place,o+i.place);if(0===s[0]){if(!(128&s[1]))return!1;s=s.slice(1)}if(0===a[0]){if(!(128&a[1]))return!1;a=a.slice(1)}return this.r=new fo(s),this.s=new fo(a),this.recoveryParam=null,!0},wh.prototype.toDER=function(t){var e=this.r.toArray(),i=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&i[0]&&(i=[0].concat(i)),e=Sh(e),i=Sh(i);!(i[0]||128&i[1]);)i=i.slice(1);var r=[2];Eh(r,e.length),(r=r.concat(e)).push(2),Eh(r,i.length);var n=r.concat(i),s=[48];return Eh(s,n.length),s=s.concat(n),go.encode(s,t)};var kh,Rh=(go.assert,vh);function Ah(t){if(!(this instanceof Ah))return new Ah(t);"string"==typeof t&&(t=lh[t]),t instanceof lh.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}kh=Ah,Ah.prototype.keyPair=function(t){return new Rh(this,t)},Ah.prototype.keyFromPrivate=function(t,e){return Rh.fromPrivate(this,t,e)},Ah.prototype.keyFromPublic=function(t,e){return Rh.fromPublic(this,t,e)},Ah.prototype.genKeyPair=function(t){t||(t={});for(var e=new mh({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||ss(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),r=this.n.sub(new fo(2));;){var n=new fo(e.generate(i));if(!(n.cmp(r)>0))return n.iaddn(1),this.keyFromPrivate(n)}},Ah.prototype._truncateToN=function(t,e){var i=8*t.byteLength()-this.n.bitLength();return i>0&&(t=t.ushrn(i)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},Ah.prototype.sign=function(t,e,i,r){"object"==typeof i&&(r=i,i=null),r||(r={}),e=this.keyFromPrivate(e,i),t=this._truncateToN(new fo(t,16));for(var n=this.n.byteLength(),s=e.getPrivate().toArray("be",n),o=t.toArray("be",n),a=new mh({hash:this.hash,entropy:s,nonce:o,pers:r.pers,persEnc:r.persEnc||"utf8"}),h=this.n.sub(new fo(1)),u=0;;u++){var f=r.k?r.k(u):new fo(a.generate(this.n.byteLength()));if(!((f=this._truncateToN(f,!0)).cmpn(1)<=0||f.cmp(h)>=0)){var l=this.g.mul(f);if(!l.isInfinity()){var d=l.getX(),c=d.umod(this.n);if(0!==c.cmpn(0)){var p=f.invm(this.n).mul(c.mul(e.getPrivate()).iadd(t));if(0!==(p=p.umod(this.n)).cmpn(0)){var m=(l.getY().isOdd()?1:0)|(0!==d.cmp(c)?2:0);return r.canonical&&p.cmp(this.nh)>0&&(p=this.n.sub(p),m^=1),new yh({r:c,s:p,recoveryParam:m})}}}}}},Ah.prototype.verify=function(t,e,i,r){t=this._truncateToN(new fo(t,16)),i=this.keyFromPublic(i,r);var n=(e=new yh(e,"hex")).r,s=e.s;if(n.cmpn(1)<0||n.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var o,a=s.invm(this.n),h=a.mul(t).umod(this.n),u=a.mul(n).umod(this.n);return this.curve._maxwellTrick?!(o=this.g.jmulAdd(h,i.getPublic(),u)).isInfinity()&&o.eqXToP(n):!(o=this.g.mulAdd(h,i.getPublic(),u)).isInfinity()&&0===o.getX().umod(this.n).cmp(n)},Ah.prototype.recoverPubKey=function(t,e,i,r){e=new yh(e,r);var n=this.n,s=new fo(t),o=e.r,a=e.s,h=1&i,u=i>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");o=u?this.curve.pointFromX(o.add(this.curve.n),h):this.curve.pointFromX(o,h);var f=e.r.invm(n),l=n.sub(s).mul(f).umod(n),d=a.mul(f).umod(n);return this.g.mulAdd(l,o,d)},Ah.prototype.getKeyRecoveryParam=function(t,e,i,r){if(null!==(e=new yh(e,r)).recoveryParam)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(t,e,n)}catch(t){continue}if(s.eq(i))return n}throw new Error("Unable to find valid recovery factor")};var xh={},Th=(go.assert,go.parseBytes),Ph=go.cachedProperty;function Bh(t,e){this.eddsa=t,this._secret=Th(e.secret),t.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=Th(e.pub)}Bh.fromPublic=function(t,e){return e instanceof Bh?e:new Bh(t,{pub:e})},Bh.fromSecret=function(t,e){return e instanceof Bh?e:new Bh(t,{secret:e})},Bh.prototype.secret=function(){return this._secret},Ph(Bh,"pubBytes",(function(){return this.eddsa.encodePoint(this.pub())})),Ph(Bh,"pub",(function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())})),Ph(Bh,"privBytes",(function(){var t=this.eddsa,e=this.hash(),i=t.encodingLength-1,r=e.slice(0,t.encodingLength);return r[0]&=248,r[i]&=127,r[i]|=64,r})),Ph(Bh,"priv",(function(){return this.eddsa.decodeInt(this.privBytes())})),Ph(Bh,"hash",(function(){return this.eddsa.hash().update(this.secret()).digest()})),Ph(Bh,"messagePrefix",(function(){return this.hash().slice(this.eddsa.encodingLength)})),Bh.prototype.sign=function(t){return this.eddsa.sign(t,this)},Bh.prototype.verify=function(t,e){return this.eddsa.verify(t,e,this)},Bh.prototype.getSecret=function(t){return go.encode(this.secret(),t)},Bh.prototype.getPublic=function(t){return go.encode(this.pubBytes(),t)},xh=Bh;var Ih={},qh=(go.assert,go.cachedProperty),Oh=go.parseBytes;function Lh(t,e){this.eddsa=t,"object"!=typeof e&&(e=Oh(e)),Array.isArray(e)&&(e={R:e.slice(0,t.encodingLength),S:e.slice(t.encodingLength)}),t.isPoint(e.R)&&(this._R=e.R),e.S instanceof fo&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}qh(Lh,"S",(function(){return this.eddsa.decodeInt(this.Sencoded())})),qh(Lh,"R",(function(){return this.eddsa.decodePoint(this.Rencoded())})),qh(Lh,"Rencoded",(function(){return this.eddsa.encodePoint(this.R())})),qh(Lh,"Sencoded",(function(){return this.eddsa.encodeInt(this.S())})),Lh.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},Lh.prototype.toHex=function(){return go.encode(this.toBytes(),"hex").toUpperCase()},Ih=Lh;var jh,Ch=(go.assert,go.parseBytes);function Nh(t){if(!(this instanceof Nh))return new Nh(t);t=lh[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=hh.sha512}jh=Nh,Nh.prototype.sign=function(t,e){t=Ch(t);var i=this.keyFromSecret(e),r=this.hashInt(i.messagePrefix(),t),n=this.g.mul(r),s=this.encodePoint(n),o=this.hashInt(s,i.pubBytes(),t).mul(i.priv()),a=r.add(o).umod(this.curve.n);return this.makeSignature({R:n,S:a,Rencoded:s})},Nh.prototype.verify=function(t,e,i){t=Ch(t),e=this.makeSignature(e);var r=this.keyFromPublic(i),n=this.hashInt(e.Rencoded(),r.pubBytes(),t),s=this.g.mul(e.S());return e.R().add(r.pub().mul(n)).eq(s)},Nh.prototype.hashInt=function(){for(var t=this.hash(),e=0;e=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return r}function o(t,e,i,r){for(var n=0,s=Math.min(t.length,i),o=e;o=49?a-49+10:a>=17?a-17+10:a}return n}r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,e){return t.cmp(e)>0?t:e},r.min=function(t,e){return t.cmp(e)<0?t:e},r.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===e?this._parseHex(t,r):this._parseBase(t,e,r),"-"===t[0]&&(this.negative=1),this.strip(),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initArray=function(t,e,i){if(t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r=0;r-=3)s=t[r]|t[r-1]<<8|t[r-2]<<16,this.words[n]|=s<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===i)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this.strip()},r.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=6)n=s(t,i,i+6),this.words[r]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,r++);i+6!==e&&(n=s(t,e,i+6),this.words[r]|=n<>>26-o&4194303),this.strip()},r.prototype._parseBase=function(t,e,i){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=e)r++;r--,n=n/e|0;for(var s=t.length-i,a=s%r,h=Math.min(s,s-a)+i,u=0,f=i;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},r.prototype.inspect=function(){return(this.red?""};var a=["","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"],h=[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],u=[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 f(t,e,i){i.negative=e.negative^t.negative;var r=t.length+e.length|0;i.length=r,r=r-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;i.words[0]=a;for(var u=1;u>>26,l=67108863&h,d=Math.min(u,e.length-1),c=Math.max(0,u-t.length+1);c<=d;c++){var p=u-c|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[c])+l)/67108864|0,l=67108863&o}i.words[u]=0|l,h=0|f}return 0!==h?i.words[u]=0|h:i.length--,i.strip()}r.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var r=0,n=0,s=0;s>>24-r&16777215)||s!==this.length-1?a[6-f.length]+f+i:f+i,(r+=2)>=26&&(r-=26,s--)}for(0!==n&&(i=n.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var l=h[t],d=u[t];i="";var c=this.clone();for(c.negative=0;!c.isZero();){var p=c.modn(d).toString(t);i=(c=c.idivn(d)).isZero()?p+i:a[l-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length,0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16)},r.prototype.toBuffer=function(t,e){return this.toArrayLike(n,t,e)},r.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},r.prototype.toArrayLike=function(t,e,i){var r=this.byteLength(),n=i||Math.max(1,r);this.strip();var s,o,a="le"===e,h=new t(n),u=this.clone();if(a){for(o=0;!u.isZero();o++)s=u.andln(255),u.iushrn(8),h[o]=s;for(;o=4096&&(i+=13,e>>>=13),e>=64&&(i+=7,e>>>=7),e>=8&&(i+=4,e>>>=4),e>=2&&(i+=2,e>>>=2),i+e},r.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,i=0;return 0==(8191&e)&&(i+=13,e>>>=13),0==(127&e)&&(i+=7,e>>>=7),0==(15&e)&&(i+=4,e>>>=4),0==(3&e)&&(i+=2,e>>>=2),0==(1&e)&&i++,i},r.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var i=0;it.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var e,i;this.length>t.length?(e=this,i=t):(e=t,i=this);for(var r=0;rt.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-i),this.strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,e){var i=t/26|0,r=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(i=this,r=t):(i=t,r=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i,r,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(i=this,r=t):(i=t,r=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,c=0|o[1],p=8191&c,m=c>>>13,g=0|o[2],v=8191&g,b=g>>>13,y=0|o[3],w=8191&y,M=y>>>13,_=0|o[4],S=8191&_,E=_>>>13,k=0|o[5],R=8191&k,A=k>>>13,x=0|o[6],T=8191&x,P=x>>>13,B=0|o[7],I=8191&B,q=B>>>13,O=0|o[8],L=8191&O,j=O>>>13,C=0|o[9],N=8191&C,D=C>>>13,U=0|a[0],$=8191&U,z=U>>>13,W=0|a[1],F=8191&W,K=W>>>13,H=0|a[2],Z=8191&H,V=H>>>13,G=0|a[3],Y=8191&G,X=G>>>13,J=0|a[4],Q=8191&J,tt=J>>>13,et=0|a[5],it=8191&et,rt=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,ft=0|a[8],lt=8191&ft,dt=ft>>>13,ct=0|a[9],pt=8191&ct,mt=ct>>>13;i.negative=t.negative^e.negative,i.length=19;var gt=(u+(r=Math.imul(l,$))|0)+((8191&(n=(n=Math.imul(l,z))+Math.imul(d,$)|0))<<13)|0;u=((s=Math.imul(d,z))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(p,$),n=(n=Math.imul(p,z))+Math.imul(m,$)|0,s=Math.imul(m,z);var vt=(u+(r=r+Math.imul(l,F)|0)|0)+((8191&(n=(n=n+Math.imul(l,K)|0)+Math.imul(d,F)|0))<<13)|0;u=((s=s+Math.imul(d,K)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(v,$),n=(n=Math.imul(v,z))+Math.imul(b,$)|0,s=Math.imul(b,z),r=r+Math.imul(p,F)|0,n=(n=n+Math.imul(p,K)|0)+Math.imul(m,F)|0,s=s+Math.imul(m,K)|0;var bt=(u+(r=r+Math.imul(l,Z)|0)|0)+((8191&(n=(n=n+Math.imul(l,V)|0)+Math.imul(d,Z)|0))<<13)|0;u=((s=s+Math.imul(d,V)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(w,$),n=(n=Math.imul(w,z))+Math.imul(M,$)|0,s=Math.imul(M,z),r=r+Math.imul(v,F)|0,n=(n=n+Math.imul(v,K)|0)+Math.imul(b,F)|0,s=s+Math.imul(b,K)|0,r=r+Math.imul(p,Z)|0,n=(n=n+Math.imul(p,V)|0)+Math.imul(m,Z)|0,s=s+Math.imul(m,V)|0;var yt=(u+(r=r+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,X)|0)+Math.imul(d,Y)|0))<<13)|0;u=((s=s+Math.imul(d,X)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(S,$),n=(n=Math.imul(S,z))+Math.imul(E,$)|0,s=Math.imul(E,z),r=r+Math.imul(w,F)|0,n=(n=n+Math.imul(w,K)|0)+Math.imul(M,F)|0,s=s+Math.imul(M,K)|0,r=r+Math.imul(v,Z)|0,n=(n=n+Math.imul(v,V)|0)+Math.imul(b,Z)|0,s=s+Math.imul(b,V)|0,r=r+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,X)|0;var wt=(u+(r=r+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(d,Q)|0))<<13)|0;u=((s=s+Math.imul(d,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(R,$),n=(n=Math.imul(R,z))+Math.imul(A,$)|0,s=Math.imul(A,z),r=r+Math.imul(S,F)|0,n=(n=n+Math.imul(S,K)|0)+Math.imul(E,F)|0,s=s+Math.imul(E,K)|0,r=r+Math.imul(w,Z)|0,n=(n=n+Math.imul(w,V)|0)+Math.imul(M,Z)|0,s=s+Math.imul(M,V)|0,r=r+Math.imul(v,Y)|0,n=(n=n+Math.imul(v,X)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,X)|0,r=r+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var Mt=(u+(r=r+Math.imul(l,it)|0)|0)+((8191&(n=(n=n+Math.imul(l,rt)|0)+Math.imul(d,it)|0))<<13)|0;u=((s=s+Math.imul(d,rt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(T,$),n=(n=Math.imul(T,z))+Math.imul(P,$)|0,s=Math.imul(P,z),r=r+Math.imul(R,F)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(A,F)|0,s=s+Math.imul(A,K)|0,r=r+Math.imul(S,Z)|0,n=(n=n+Math.imul(S,V)|0)+Math.imul(E,Z)|0,s=s+Math.imul(E,V)|0,r=r+Math.imul(w,Y)|0,n=(n=n+Math.imul(w,X)|0)+Math.imul(M,Y)|0,s=s+Math.imul(M,X)|0,r=r+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,tt)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,tt)|0,r=r+Math.imul(p,it)|0,n=(n=n+Math.imul(p,rt)|0)+Math.imul(m,it)|0,s=s+Math.imul(m,rt)|0;var _t=(u+(r=r+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(d,st)|0))<<13)|0;u=((s=s+Math.imul(d,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(I,$),n=(n=Math.imul(I,z))+Math.imul(q,$)|0,s=Math.imul(q,z),r=r+Math.imul(T,F)|0,n=(n=n+Math.imul(T,K)|0)+Math.imul(P,F)|0,s=s+Math.imul(P,K)|0,r=r+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,V)|0)+Math.imul(A,Z)|0,s=s+Math.imul(A,V)|0,r=r+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,X)|0,r=r+Math.imul(w,Q)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(M,Q)|0,s=s+Math.imul(M,tt)|0,r=r+Math.imul(v,it)|0,n=(n=n+Math.imul(v,rt)|0)+Math.imul(b,it)|0,s=s+Math.imul(b,rt)|0,r=r+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(r=r+Math.imul(l,ht)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((s=s+Math.imul(d,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(L,$),n=(n=Math.imul(L,z))+Math.imul(j,$)|0,s=Math.imul(j,z),r=r+Math.imul(I,F)|0,n=(n=n+Math.imul(I,K)|0)+Math.imul(q,F)|0,s=s+Math.imul(q,K)|0,r=r+Math.imul(T,Z)|0,n=(n=n+Math.imul(T,V)|0)+Math.imul(P,Z)|0,s=s+Math.imul(P,V)|0,r=r+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,X)|0,r=r+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(E,Q)|0,s=s+Math.imul(E,tt)|0,r=r+Math.imul(w,it)|0,n=(n=n+Math.imul(w,rt)|0)+Math.imul(M,it)|0,s=s+Math.imul(M,rt)|0,r=r+Math.imul(v,st)|0,n=(n=n+Math.imul(v,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,r=r+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,ut)|0;var Et=(u+(r=r+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,dt)|0)+Math.imul(d,lt)|0))<<13)|0;u=((s=s+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(N,$),n=(n=Math.imul(N,z))+Math.imul(D,$)|0,s=Math.imul(D,z),r=r+Math.imul(L,F)|0,n=(n=n+Math.imul(L,K)|0)+Math.imul(j,F)|0,s=s+Math.imul(j,K)|0,r=r+Math.imul(I,Z)|0,n=(n=n+Math.imul(I,V)|0)+Math.imul(q,Z)|0,s=s+Math.imul(q,V)|0,r=r+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,X)|0,r=r+Math.imul(R,Q)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(A,Q)|0,s=s+Math.imul(A,tt)|0,r=r+Math.imul(S,it)|0,n=(n=n+Math.imul(S,rt)|0)+Math.imul(E,it)|0,s=s+Math.imul(E,rt)|0,r=r+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(M,st)|0,s=s+Math.imul(M,ot)|0,r=r+Math.imul(v,ht)|0,n=(n=n+Math.imul(v,ut)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ut)|0,r=r+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,dt)|0;var kt=(u+(r=r+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(d,pt)|0))<<13)|0;u=((s=s+Math.imul(d,mt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(N,F),n=(n=Math.imul(N,K))+Math.imul(D,F)|0,s=Math.imul(D,K),r=r+Math.imul(L,Z)|0,n=(n=n+Math.imul(L,V)|0)+Math.imul(j,Z)|0,s=s+Math.imul(j,V)|0,r=r+Math.imul(I,Y)|0,n=(n=n+Math.imul(I,X)|0)+Math.imul(q,Y)|0,s=s+Math.imul(q,X)|0,r=r+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(P,Q)|0,s=s+Math.imul(P,tt)|0,r=r+Math.imul(R,it)|0,n=(n=n+Math.imul(R,rt)|0)+Math.imul(A,it)|0,s=s+Math.imul(A,rt)|0,r=r+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(E,st)|0,s=s+Math.imul(E,ot)|0,r=r+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(M,ht)|0,s=s+Math.imul(M,ut)|0,r=r+Math.imul(v,lt)|0,n=(n=n+Math.imul(v,dt)|0)+Math.imul(b,lt)|0,s=s+Math.imul(b,dt)|0;var Rt=(u+(r=r+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(N,Z),n=(n=Math.imul(N,V))+Math.imul(D,Z)|0,s=Math.imul(D,V),r=r+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(j,Y)|0,s=s+Math.imul(j,X)|0,r=r+Math.imul(I,Q)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(q,Q)|0,s=s+Math.imul(q,tt)|0,r=r+Math.imul(T,it)|0,n=(n=n+Math.imul(T,rt)|0)+Math.imul(P,it)|0,s=s+Math.imul(P,rt)|0,r=r+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(A,st)|0,s=s+Math.imul(A,ot)|0,r=r+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(E,ht)|0,s=s+Math.imul(E,ut)|0,r=r+Math.imul(w,lt)|0,n=(n=n+Math.imul(w,dt)|0)+Math.imul(M,lt)|0,s=s+Math.imul(M,dt)|0;var At=(u+(r=r+Math.imul(v,pt)|0)|0)+((8191&(n=(n=n+Math.imul(v,mt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((s=s+Math.imul(b,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(N,Y),n=(n=Math.imul(N,X))+Math.imul(D,Y)|0,s=Math.imul(D,X),r=r+Math.imul(L,Q)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(j,Q)|0,s=s+Math.imul(j,tt)|0,r=r+Math.imul(I,it)|0,n=(n=n+Math.imul(I,rt)|0)+Math.imul(q,it)|0,s=s+Math.imul(q,rt)|0,r=r+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,ot)|0,r=r+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(A,ht)|0,s=s+Math.imul(A,ut)|0,r=r+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,dt)|0)+Math.imul(E,lt)|0,s=s+Math.imul(E,dt)|0;var xt=(u+(r=r+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((s=s+Math.imul(M,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(N,Q),n=(n=Math.imul(N,tt))+Math.imul(D,Q)|0,s=Math.imul(D,tt),r=r+Math.imul(L,it)|0,n=(n=n+Math.imul(L,rt)|0)+Math.imul(j,it)|0,s=s+Math.imul(j,rt)|0,r=r+Math.imul(I,st)|0,n=(n=n+Math.imul(I,ot)|0)+Math.imul(q,st)|0,s=s+Math.imul(q,ot)|0,r=r+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,ut)|0,r=r+Math.imul(R,lt)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(A,lt)|0,s=s+Math.imul(A,dt)|0;var Tt=(u+(r=r+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(E,pt)|0))<<13)|0;u=((s=s+Math.imul(E,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(N,it),n=(n=Math.imul(N,rt))+Math.imul(D,it)|0,s=Math.imul(D,rt),r=r+Math.imul(L,st)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(j,st)|0,s=s+Math.imul(j,ot)|0,r=r+Math.imul(I,ht)|0,n=(n=n+Math.imul(I,ut)|0)+Math.imul(q,ht)|0,s=s+Math.imul(q,ut)|0,r=r+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,dt)|0)+Math.imul(P,lt)|0,s=s+Math.imul(P,dt)|0;var Pt=(u+(r=r+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((s=s+Math.imul(A,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(N,st),n=(n=Math.imul(N,ot))+Math.imul(D,st)|0,s=Math.imul(D,ot),r=r+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,ut)|0)+Math.imul(j,ht)|0,s=s+Math.imul(j,ut)|0,r=r+Math.imul(I,lt)|0,n=(n=n+Math.imul(I,dt)|0)+Math.imul(q,lt)|0,s=s+Math.imul(q,dt)|0;var Bt=(u+(r=r+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((s=s+Math.imul(P,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(N,ht),n=(n=Math.imul(N,ut))+Math.imul(D,ht)|0,s=Math.imul(D,ut),r=r+Math.imul(L,lt)|0,n=(n=n+Math.imul(L,dt)|0)+Math.imul(j,lt)|0,s=s+Math.imul(j,dt)|0;var It=(u+(r=r+Math.imul(I,pt)|0)|0)+((8191&(n=(n=n+Math.imul(I,mt)|0)+Math.imul(q,pt)|0))<<13)|0;u=((s=s+Math.imul(q,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(N,lt),n=(n=Math.imul(N,dt))+Math.imul(D,lt)|0,s=Math.imul(D,dt);var qt=(u+(r=r+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,mt)|0)+Math.imul(j,pt)|0))<<13)|0;u=((s=s+Math.imul(j,mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863;var Ot=(u+(r=Math.imul(N,pt))|0)+((8191&(n=(n=Math.imul(N,mt))+Math.imul(D,pt)|0))<<13)|0;return u=((s=Math.imul(D,mt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=vt,h[2]=bt,h[3]=yt,h[4]=wt,h[5]=Mt,h[6]=_t,h[7]=St,h[8]=Et,h[9]=kt,h[10]=Rt,h[11]=At,h[12]=xt,h[13]=Tt,h[14]=Pt,h[15]=Bt,h[16]=It,h[17]=qt,h[18]=Ot,0!==u&&(h[19]=u,i.length++),i};function d(t,e,i){return(new c).mulp(t,e,i)}function c(t,e){this.x=t,this.y=e}Math.imul||(l=f),r.prototype.mulTo=function(t,e){var i=this.length+t.length;return 10===this.length&&10===t.length?l(this,t,e):i<63?f(this,t,e):i<1024?function(t,e,i){i.negative=e.negative^t.negative,i.length=t.length+e.length;for(var r=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}i.words[s]=a,r=o,o=n}return 0!==r?i.words[s]=r:i.length--,i.strip()}(this,t,e):d(this,t,e)},c.prototype.makeRBT=function(t){for(var e=new Array(t),i=r.prototype._countBits(t)-1,n=0;n>=1;return r},c.prototype.permute=function(t,e,i,r,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*s+1]=8191&n,n>>>=13;for(s=2*e;s>=26,e+=r/67108864|0,e+=n>>>26,this.words[i]=67108863&n}return 0!==e&&(this.words[i]=e,this.length++),this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),i=0;i>>n}return e}(t);if(0===e.length)return new r(1);for(var i=this,n=0;n>>26-i<<26-i;if(0!==i){var s=0;for(e=0;e>>26-i}s&&(this.words[e]=s,this.length++)}if(0!==r){for(e=this.length-1;e>=0;e--)this.words[e+r]=this.words[e];for(e=0;e>>n<s)for(this.length-=s,h=0;h=0&&(0!==u||h>=r);h--){var f=0|this.words[h];this.words[h]=u<<26-n|f>>>n,u=f&o}return a&&0!==u&&(a.words[a.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},r.prototype.ishrn=function(t,e,i){return this.iushrn(t,e,i)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){var e=t%26,i=(t-e)/26,r=1<>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},r.prototype.isubn=function(t){if(t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(a/67108864|0),this.words[r+i]=67108863&n}for(;r>26,this.words[r+i]=67108863&n;if(0===o)return this.strip();for(o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},r.prototype._wordDiv=function(t,e){var i=(this.length,t.length),n=this.clone(),s=t,o=0|s.words[s.length-1];0!=(i=26-this._countBits(o))&&(s=s.ushln(i),n.iushln(i),o=0|s.words[s.length-1]);var a,h=n.length-s.length;if("mod"!==e){(a=new r(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u=0;l--){var d=67108864*(0|n.words[s.length+l])+(0|n.words[s.length+l-1]);for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(s,d,l);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(s,1,l),n.isZero()||(n.negative^=1);a&&(a.words[l]=d)}return a&&a.strip(),n.strip(),"div"!==e&&0!==i&&n.iushrn(i),{div:a||null,mod:n}},r.prototype.divmod=function(t,e,i){return this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),"mod"!==e&&(n=o.div.neg()),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),e),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new r(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var i=0!==e.div.negative?e.mod.isub(t):e.mod,r=t.ushrn(1),n=t.andln(1),s=i.cmp(r);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},r.prototype.modn=function(t){for(var e=(1<<26)%t,i=0,r=this.length-1;r>=0;r--)i=(e*i+(0|this.words[r]))%t;return i},r.prototype.idivn=function(t){for(var e=0,i=this.length-1;i>=0;i--){var r=(0|this.words[i])+67108864*e;this.words[i]=r/t|0,e=r%t}return this.strip()},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new r(1),s=new r(0),o=new r(0),a=new r(1),h=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++h;for(var u=i.clone(),f=e.clone();!e.isZero();){for(var l=0,d=1;0==(e.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(e.iushrn(l);l-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(u),s.isub(f)),n.iushrn(1),s.iushrn(1);for(var c=0,p=1;0==(i.words[0]&p)&&c<26;++c,p<<=1);if(c>0)for(i.iushrn(c);c-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(u),a.isub(f)),o.iushrn(1),a.iushrn(1);e.cmp(i)>=0?(e.isub(i),n.isub(o),s.isub(a)):(i.isub(e),o.isub(n),a.isub(s))}return{a:o,b:a,gcd:i.iushln(h)}},r.prototype._invmp=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new r(1),o=new r(0),a=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var h=0,u=1;0==(e.words[0]&u)&&h<26;++h,u<<=1);if(h>0)for(e.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(a),s.iushrn(1);for(var f=0,l=1;0==(i.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(i.iushrn(f);f-- >0;)o.isOdd()&&o.iadd(a),o.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o)):(i.isub(e),o.isub(s))}return(n=0===e.cmpn(1)?s:o).cmpn(0)<0&&n.iadd(t),n},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),i=t.clone();e.negative=0,i.negative=0;for(var r=0;e.isEven()&&i.isEven();r++)e.iushrn(1),i.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;i.isEven();)i.iushrn(1);var n=e.cmp(i);if(n<0){var s=e;e=i,i=s}else if(0===n||0===i.cmpn(1))break;e.isub(i)}return i.iushln(r)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){var e=t%26,i=(t-e)/26,r=1<>>26,o&=67108863,this.words[s]=o}return 0!==n&&(this.words[s]=n,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t);var r=0|this.words[0];e=r===t?0:rt.length)return 1;if(this.length=0;i--){var r=0|this.words[i],n=0|t.words[i];if(r!==n){rn&&(e=1);break}}return e},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new M(t)},r.prototype.toRed=function(t){return t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return this._forceRed(t)},r.prototype.redAdd=function(t){return this.red.add(this,t)},r.prototype.redIAdd=function(t){return this.red.iadd(this,t)},r.prototype.redSub=function(t){return this.red.sub(this,t)},r.prototype.redISub=function(t){return this.red.isub(this,t)},r.prototype.redShl=function(t){return this.red.shl(this,t)},r.prototype.redMul=function(t){return this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return this.red._verify1(this),this.red.pow(this,t)};var p={k256:null,p224:null,p192:null,p25519:null};function m(t,e){this.name=t,this.p=new r(e,16),this.n=this.p.bitLength(),this.k=new r(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 v(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function y(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(t){if("string"==typeof t){var e=r._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function _(t){M.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(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 t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},m.prototype.ireduce=function(t){var e,i=t;do{this.split(i,this.tmp),e=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(e>this.n);var r=e0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},m.prototype.split=function(t,e){t.iushrn(this.n,0,e)},m.prototype.imulK=function(t){return t.imul(this.k)},i(g,m),g.prototype.split=function(t,e){for(var i=Math.min(t.length,9),r=0;r>>22,n=s}n>>>=22,t.words[r-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},g.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,i=0;i>>=26,t.words[i]=n,e=r}return 0!==e&&(t.words[t.length++]=e),t},r._prime=function(t){if(p[t])return p[t];var e;if("k256"===t)e=new g;else if("p224"===t)e=new v;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new y}return p[t]=e,e},M.prototype._verify1=function(t){},M.prototype._verify2=function(t,e){},M.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},M.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},M.prototype.add=function(t,e){this._verify2(t,e);var i=t.add(e);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},M.prototype.iadd=function(t,e){this._verify2(t,e);var i=t.iadd(e);return i.cmp(this.m)>=0&&i.isub(this.m),i},M.prototype.sub=function(t,e){this._verify2(t,e);var i=t.sub(e);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},M.prototype.isub=function(t,e){this._verify2(t,e);var i=t.isub(e);return i.cmpn(0)<0&&i.iadd(this.m),i},M.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},M.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},M.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},M.prototype.isqr=function(t){return this.imul(t,t.clone())},M.prototype.sqr=function(t){return this.mul(t,t)},M.prototype.sqrt=function(t){if(t.isZero())return t.clone();if(3===this.m.andln(3)){var e=this.m.add(new r(1)).iushrn(2);return this.pow(t,e)}for(var i=this.m.subn(1),n=0;!i.isZero()&&0===i.andln(1);)n++,i.iushrn(1);var s=new r(1).toRed(this),o=s.redNeg(),a=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new r(2*h*h).toRed(this);0!==this.pow(h,a).cmp(o);)h.redIAdd(o);for(var u=this.pow(h,i),f=this.pow(t,i.addn(1).iushrn(1)),l=this.pow(t,i),d=n;0!==l.cmp(s);){for(var c=l,p=0;0!==c.cmp(s);p++)c=c.redSqr();var m=this.pow(u,new r(1).iushln(d-p-1));f=f.redMul(m),u=m.redSqr(),l=l.redMul(u),d=p}return f},M.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},M.prototype.pow=function(t,e){if(e.isZero())return new r(1).toRed(this);if(0===e.cmpn(1))return t.clone();var i=new Array(16);i[0]=new r(1).toRed(this),i[1]=t;for(var n=2;n=0;n--){for(var u=e.words[n],f=h-1;f>=0;f--){var l=u>>f&1;s!==i[0]&&(s=this.sqr(s)),0!==l||0!==o?(o<<=1,o|=l,(4==++a||0===n&&0===f)&&(s=this.mul(s,i[o]),a=0,o=0)):a=0}h=26}return s},M.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},M.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},r.mont=function(t){return new _(t)},i(_,M),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(e),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new r(0)._forceRed(this);var i=t.mul(e),n=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=i.isub(n).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}($h,this),$h=$h.exports;var zh={};(function(t){(function(){"use strict";var e,i=M({}),r=i.Buffer,n={};for(e in i)i.hasOwnProperty(e)&&"SlowBuffer"!==e&&"Buffer"!==e&&(n[e]=i[e]);var s=n.Buffer={};for(e in r)r.hasOwnProperty(e)&&"allocUnsafe"!==e&&"allocUnsafeSlow"!==e&&(s[e]=r[e]);if(n.Buffer.prototype=r.prototype,s.from&&s.from!==Uint8Array.from||(s.from=function(t,e,i){if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof t);if(t&&void 0===t.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);return r(t,e,i)}),s.alloc||(s.alloc=function(t,e,i){if("number"!=typeof t)throw new TypeError('The "size" argument must be of type number. Received type '+typeof t);if(t<0||t>=2*(1<<30))throw new RangeError('The value "'+t+'" is invalid for option "size"');var n=r(t);return e&&0!==e.length?"string"==typeof i?n.fill(e,i):n.fill(e):n.fill(0),n}),!n.kStringMaxLength)try{n.kStringMaxLength=t.binding("buffer").kStringMaxLength}catch(jf){}n.constants||(n.constants={MAX_LENGTH:n.kMaxLength},n.kStringMaxLength&&(n.constants.MAX_STRING_LENGTH=n.kStringMaxLength)),zh=n}).call(this)}).call(this,D);var Wh={};function Fh(t){this._reporterState={obj:null,path:[],options:t||{},errors:[]}}function Kh(t,e){this.path=t,this.rethrow(e)}Wh.Reporter=Fh,Fh.prototype.isError=function(t){return t instanceof Kh},Fh.prototype.save=function(){const t=this._reporterState;return{obj:t.obj,pathLen:t.path.length}},Fh.prototype.restore=function(t){const e=this._reporterState;e.obj=t.obj,e.path=e.path.slice(0,t.pathLen)},Fh.prototype.enterKey=function(t){return this._reporterState.path.push(t)},Fh.prototype.exitKey=function(t){const e=this._reporterState;e.path=e.path.slice(0,t-1)},Fh.prototype.leaveKey=function(t,e,i){const r=this._reporterState;this.exitKey(t),null!==r.obj&&(r.obj[e]=i)},Fh.prototype.path=function(){return this._reporterState.path.join("/")},Fh.prototype.enterObject=function(){const t=this._reporterState,e=t.obj;return t.obj={},e},Fh.prototype.leaveObject=function(t){const e=this._reporterState,i=e.obj;return e.obj=t,i},Fh.prototype.error=function(t){let e;const i=this._reporterState,r=t instanceof Kh;if(e=r?t:new Kh(i.path.map((function(t){return"["+JSON.stringify(t)+"]"})).join(""),t.message||t,t.stack),!i.options.partial)throw e;return r||i.errors.push(e),e},Fh.prototype.wrapResult=function(t){const e=this._reporterState;return e.options.partial?{result:this.isError(t)?null:t,errors:e.errors}:t},Q(Kh,Error),Kh.prototype.rethrow=function(t){if(this.message=t+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,Kh),!this.stack)try{throw new Error(this.message)}catch(jf){this.stack=jf.stack}return this};var Hh={};const Zh=Wh.Reporter,Vh=zh.Buffer;function Gh(t,e){Zh.call(this,e),Vh.isBuffer(t)?(this.base=t,this.offset=0,this.length=t.length):this.error("Input not Buffer")}function Yh(t,e){if(Array.isArray(t))this.length=0,this.value=t.map((function(t){return Yh.isEncoderBuffer(t)||(t=new Yh(t,e)),this.length+=t.length,t}),this);else if("number"==typeof t){if(!(0<=t&&t<=255))return e.error("non-byte EncoderBuffer value");this.value=t,this.length=1}else if("string"==typeof t)this.value=t,this.length=Vh.byteLength(t);else{if(!Vh.isBuffer(t))return e.error("Unsupported type: "+typeof t);this.value=t,this.length=t.length}}Q(Gh,Zh),Hh.DecoderBuffer=Gh,Gh.isDecoderBuffer=function(t){return t instanceof Gh||"object"==typeof t&&Vh.isBuffer(t.base)&&"DecoderBuffer"===t.constructor.name&&"number"==typeof t.offset&&"number"==typeof t.length&&"function"==typeof t.save&&"function"==typeof t.restore&&"function"==typeof t.isEmpty&&"function"==typeof t.readUInt8&&"function"==typeof t.skip&&"function"==typeof t.raw},Gh.prototype.save=function(){return{offset:this.offset,reporter:Zh.prototype.save.call(this)}},Gh.prototype.restore=function(t){const e=new Gh(this.base);return e.offset=t.offset,e.length=this.offset,this.offset=t.offset,Zh.prototype.restore.call(this,t.reporter),e},Gh.prototype.isEmpty=function(){return this.offset===this.length},Gh.prototype.readUInt8=function(t){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(t||"DecoderBuffer overrun")},Gh.prototype.skip=function(t,e){if(!(this.offset+t<=this.length))return this.error(e||"DecoderBuffer overrun");const i=new Gh(this.base);return i._reporterState=this._reporterState,i.offset=this.offset,i.length=this.offset+t,this.offset+=t,i},Gh.prototype.raw=function(t){return this.base.slice(t?t.offset:this.offset,this.length)},Hh.EncoderBuffer=Yh,Yh.isEncoderBuffer=function(t){return t instanceof Yh||"object"==typeof t&&"EncoderBuffer"===t.constructor.name&&"number"==typeof t.length&&"function"==typeof t.join},Yh.prototype.join=function(t,e){return t||(t=Vh.alloc(this.length)),e||(e=0),0===this.length||(Array.isArray(this.value)?this.value.forEach((function(i){i.join(t,e),e+=i.length})):("number"==typeof this.value?t[e]=this.value:"string"==typeof this.value?t.write(this.value,e):Vh.isBuffer(this.value)&&this.value.copy(t,e),e+=this.length)),t};const Xh=Wh.Reporter,Jh=Hh.EncoderBuffer,Qh=Hh.DecoderBuffer,tu=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],eu=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(tu);function iu(t,e,i){const r={};this._baseState=r,r.name=i,r.enc=t,r.parent=e||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r.default=null,r.explicit=null,r.implicit=null,r.contains=null,r.parent||(r.children=[],this._wrap())}var ru=iu;const nu=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];iu.prototype.clone=function(){const t=this._baseState,e={};nu.forEach((function(i){e[i]=t[i]}));const i=new this.constructor(e.parent);return i._baseState=e,i},iu.prototype._wrap=function(){const t=this._baseState;eu.forEach((function(e){this[e]=function(){const i=new this.constructor(this);return t.children.push(i),i[e].apply(i,arguments)}}),this)},iu.prototype._init=function(t){const e=this._baseState;t.call(this),e.children=e.children.filter((function(t){return t._baseState.parent===this}),this)},iu.prototype._useArgs=function(t){const e=this._baseState,i=t.filter((function(t){return t instanceof this.constructor}),this);t=t.filter((function(t){return!(t instanceof this.constructor)}),this),0!==i.length&&(e.children=i,i.forEach((function(t){t._baseState.parent=this}),this)),0!==t.length&&(e.args=t,e.reverseArgs=t.map((function(t){if("object"!=typeof t||t.constructor!==Object)return t;const e={};return Object.keys(t).forEach((function(i){i==(0|i)&&(i|=0);const r=t[i];e[r]=i})),e})))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach((function(t){iu.prototype[t]=function(){const e=this._baseState;throw new Error(t+" not implemented for encoding: "+e.enc)}})),tu.forEach((function(t){iu.prototype[t]=function(){const e=this._baseState,i=Array.prototype.slice.call(arguments);return e.tag=t,this._useArgs(i),this}})),iu.prototype.use=function(t){return this._baseState.use=t,this},iu.prototype.optional=function(){return this._baseState.optional=!0,this},iu.prototype.def=function(t){const e=this._baseState;return e.default=t,e.optional=!0,this},iu.prototype.explicit=function(t){return this._baseState.explicit=t,this},iu.prototype.implicit=function(t){return this._baseState.implicit=t,this},iu.prototype.obj=function(){const t=this._baseState,e=Array.prototype.slice.call(arguments);return t.obj=!0,0!==e.length&&this._useArgs(e),this},iu.prototype.key=function(t){return this._baseState.key=t,this},iu.prototype.any=function(){return this._baseState.any=!0,this},iu.prototype.choice=function(t){return this._baseState.choice=t,this._useArgs(Object.keys(t).map((function(e){return t[e]}))),this},iu.prototype.contains=function(t){return this._baseState.contains=t,this},iu.prototype._decode=function(t,e){const i=this._baseState;if(null===i.parent)return t.wrapResult(i.children[0]._decode(t,e));let r,n=i.default,s=!0,o=null;if(null!==i.key&&(o=t.enterKey(i.key)),i.optional){let r=null;if(null!==i.explicit?r=i.explicit:null!==i.implicit?r=i.implicit:null!==i.tag&&(r=i.tag),null!==r||i.any){if(s=this._peekTag(t,r,i.any),t.isError(s))return s}else{const r=t.save();try{null===i.choice?this._decodeGeneric(i.tag,t,e):this._decodeChoice(t,e),s=!0}catch(jf){s=!1}t.restore(r)}}if(i.obj&&s&&(r=t.enterObject()),s){if(null!==i.explicit){const e=this._decodeTag(t,i.explicit);if(t.isError(e))return e;t=e}const r=t.offset;if(null===i.use&&null===i.choice){let e;i.any&&(e=t.save());const r=this._decodeTag(t,null!==i.implicit?i.implicit:i.tag,i.any);if(t.isError(r))return r;i.any?n=t.raw(e):t=r}if(e&&e.track&&null!==i.tag&&e.track(t.path(),r,t.length,"tagged"),e&&e.track&&null!==i.tag&&e.track(t.path(),t.offset,t.length,"content"),i.any||(n=null===i.choice?this._decodeGeneric(i.tag,t,e):this._decodeChoice(t,e)),t.isError(n))return n;if(i.any||null!==i.choice||null===i.children||i.children.forEach((function(i){i._decode(t,e)})),i.contains&&("octstr"===i.tag||"bitstr"===i.tag)){const r=new Qh(n);n=this._getUse(i.contains,t._reporterState.obj)._decode(r,e)}}return i.obj&&s&&(n=t.leaveObject(r)),null===i.key||null===n&&!0!==s?null!==o&&t.exitKey(o):t.leaveKey(o,i.key,n),n},iu.prototype._decodeGeneric=function(t,e,i){const r=this._baseState;return"seq"===t||"set"===t?null:"seqof"===t||"setof"===t?this._decodeList(e,t,r.args[0],i):/str$/.test(t)?this._decodeStr(e,t,i):"objid"===t&&r.args?this._decodeObjid(e,r.args[0],r.args[1],i):"objid"===t?this._decodeObjid(e,null,null,i):"gentime"===t||"utctime"===t?this._decodeTime(e,t,i):"null_"===t?this._decodeNull(e,i):"bool"===t?this._decodeBool(e,i):"objDesc"===t?this._decodeStr(e,t,i):"int"===t||"enum"===t?this._decodeInt(e,r.args&&r.args[0],i):null!==r.use?this._getUse(r.use,e._reporterState.obj)._decode(e,i):e.error("unknown tag: "+t)},iu.prototype._getUse=function(t,e){const i=this._baseState;return i.useDecoder=this._use(t,e),i.useDecoder=i.useDecoder._baseState.children[0],i.implicit!==i.useDecoder._baseState.implicit&&(i.useDecoder=i.useDecoder.clone(),i.useDecoder._baseState.implicit=i.implicit),i.useDecoder},iu.prototype._decodeChoice=function(t,e){const i=this._baseState;let r=null,n=!1;return Object.keys(i.choice).some((function(s){const o=t.save(),a=i.choice[s];try{const i=a._decode(t,e);if(t.isError(i))return!1;r={type:s,value:i},n=!0}catch(jf){return t.restore(o),!1}return!0}),this),n?r:t.error("Choice not matched")},iu.prototype._createEncoderBuffer=function(t){return new Jh(t,this.reporter)},iu.prototype._encode=function(t,e,i){const r=this._baseState;if(null!==r.default&&r.default===t)return;const n=this._encodeValue(t,e,i);return void 0===n||this._skipDefault(n,e,i)?void 0:n},iu.prototype._encodeValue=function(t,e,i){const r=this._baseState;if(null===r.parent)return r.children[0]._encode(t,e||new Xh);let n=null;if(this.reporter=e,r.optional&&void 0===t){if(null===r.default)return;t=r.default}let s=null,o=!1;if(r.any)n=this._createEncoderBuffer(t);else if(r.choice)n=this._encodeChoice(t,e);else if(r.contains)s=this._getUse(r.contains,i)._encode(t,e),o=!0;else if(r.children)s=r.children.map((function(i){if("null_"===i._baseState.tag)return i._encode(null,e,t);if(null===i._baseState.key)return e.error("Child should have a key");const r=e.enterKey(i._baseState.key);if("object"!=typeof t)return e.error("Child expected, but input is not object");const n=i._encode(t[i._baseState.key],e,t);return e.leaveKey(r),n}),this).filter((function(t){return t})),s=this._createEncoderBuffer(s);else if("seqof"===r.tag||"setof"===r.tag){if(!r.args||1!==r.args.length)return e.error("Too many args for : "+r.tag);if(!Array.isArray(t))return e.error("seqof/setof, but data is not Array");const i=this.clone();i._baseState.implicit=null,s=this._createEncoderBuffer(t.map((function(i){const r=this._baseState;return this._getUse(r.args[0],t)._encode(i,e)}),i))}else null!==r.use?n=this._getUse(r.use,i)._encode(t,e):(s=this._encodePrimitive(r.tag,t),o=!0);if(!r.any&&null===r.choice){const t=null!==r.implicit?r.implicit:r.tag,i=null===r.implicit?"universal":"context";null===t?null===r.use&&e.error("Tag could be omitted only for .use()"):null===r.use&&(n=this._encodeComposite(t,o,i,s))}return null!==r.explicit&&(n=this._encodeComposite(r.explicit,!1,"context",n)),n},iu.prototype._encodeChoice=function(t,e){return this._baseState.choice[t.type]._encode(t.value,e)},iu.prototype._encodePrimitive=function(t,e){const i=this._baseState;if(/str$/.test(t))return this._encodeStr(e,t);if("objid"===t&&i.args)return this._encodeObjid(e,i.reverseArgs[0],i.args[1]);if("objid"===t)return this._encodeObjid(e,null,null);if("gentime"===t||"utctime"===t)return this._encodeTime(e,t);if("null_"===t)return this._encodeNull();if("int"===t||"enum"===t)return this._encodeInt(e,i.args&&i.reverseArgs[0]);if("bool"===t)return this._encodeBool(e);if("objDesc"===t)return this._encodeStr(e,t);throw new Error("Unsupported tag: "+t)},iu.prototype._isNumstr=function(t){return/^[0-9 ]*$/.test(t)},iu.prototype._isPrintstr=function(t){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(t)};var su={};function ou(t){const e={};return Object.keys(t).forEach((function(i){(0|i)==i&&(i|=0);const r=t[i];e[r]=i})),e}su.tagClass={0:"universal",1:"application",2:"context",3:"private"},su.tagClassByName=ou(su.tagClass),su.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},su.tagByName=ou(su.tag);var au={};const hu=zh.Buffer;function uu(t){this.enc="der",this.name=t.name,this.entity=t,this.tree=new fu,this.tree._init(t.body)}function fu(t){ru.call(this,"der",t)}function lu(t){return t<10?"0"+t:t}au=uu,uu.prototype.encode=function(t,e){return this.tree._encode(t,e).join()},Q(fu,ru),fu.prototype._encodeComposite=function(t,e,i,r){const n=function(t,e,i,r){let n;if("seqof"===t?t="seq":"setof"===t&&(t="set"),su.tagByName.hasOwnProperty(t))n=su.tagByName[t];else{if("number"!=typeof t||(0|t)!==t)return r.error("Unknown tag: "+t);n=t}return n>=31?r.error("Multi-octet tag encoding unsupported"):(e||(n|=32),n|su.tagClassByName[i||"universal"]<<6)}(t,e,i,this.reporter);if(r.length<128){const t=hu.alloc(2);return t[0]=n,t[1]=r.length,this._createEncoderBuffer([t,r])}let s=1;for(let a=r.length;a>=256;a>>=8)s++;const o=hu.alloc(2+s);o[0]=n,o[1]=128|s;for(let a=1+s,h=r.length;h>0;a--,h>>=8)o[a]=255&h;return this._createEncoderBuffer([o,r])},fu.prototype._encodeStr=function(t,e){if("bitstr"===e)return this._createEncoderBuffer([0|t.unused,t.data]);if("bmpstr"===e){const e=hu.alloc(2*t.length);for(let i=0;i=40)return this.reporter.error("Second objid identifier OOB");t.splice(0,2,40*t[0]+t[1])}let r=0;for(let o=0;o=128;e>>=7)r++}const n=hu.alloc(r);let s=n.length-1;for(let o=t.length-1;o>=0;o--){let e=t[o];for(n[s--]=127&e;(e>>=7)>0;)n[s--]=128|127&e}return this._createEncoderBuffer(n)},fu.prototype._encodeTime=function(t,e){let i;const r=new Date(t);return"gentime"===e?i=[lu(r.getUTCFullYear()),lu(r.getUTCMonth()+1),lu(r.getUTCDate()),lu(r.getUTCHours()),lu(r.getUTCMinutes()),lu(r.getUTCSeconds()),"Z"].join(""):"utctime"===e?i=[lu(r.getUTCFullYear()%100),lu(r.getUTCMonth()+1),lu(r.getUTCDate()),lu(r.getUTCHours()),lu(r.getUTCMinutes()),lu(r.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+e+" time is not supported yet"),this._encodeStr(i,"octstr")},fu.prototype._encodeNull=function(){return this._createEncoderBuffer("")},fu.prototype._encodeInt=function(t,e){if("string"==typeof t){if(!e)return this.reporter.error("String int or enum given, but no values map");if(!e.hasOwnProperty(t))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(t));t=e[t]}if("number"!=typeof t&&!hu.isBuffer(t)){const e=t.toArray();!t.sign&&128&e[0]&&e.unshift(0),t=hu.from(e)}if(hu.isBuffer(t)){let e=t.length;0===t.length&&e++;const i=hu.alloc(e);return t.copy(i),0===t.length&&(i[0]=0),this._createEncoderBuffer(i)}if(t<128)return this._createEncoderBuffer(t);if(t<256)return this._createEncoderBuffer([0,t]);let i=1;for(let n=t;n>=256;n>>=8)i++;const r=new Array(i);for(let n=r.length-1;n>=0;n--)r[n]=255&t,t>>=8;return 128&r[0]&&r.unshift(0),this._createEncoderBuffer(hu.from(r))},fu.prototype._encodeBool=function(t){return this._createEncoderBuffer(t?255:0)},fu.prototype._use=function(t,e){return"function"==typeof t&&(t=t(e)),t._getEncoder("der").tree},fu.prototype._skipDefault=function(t,e,i){const r=this._baseState;let n;if(null===r.default)return!1;const s=t.join();if(void 0===r.defaultBuffer&&(r.defaultBuffer=this._encodeValue(r.default,e,i).join()),s.length!==r.defaultBuffer.length)return!1;for(n=0;n>6],n=0==(32&i);if(31==(31&i)){let r=i;for(i=0;128==(128&r);){if(r=t.readUInt8(e),t.isError(r))return r;i<<=7,i|=127&r}}else i&=31;return{cls:r,primitive:n,tag:i,tagStr:su.tag[i]}}function Mu(t,e,i){let r=t.readUInt8(i);if(t.isError(r))return r;if(!e&&128===r)return null;if(0==(128&r))return r;const n=127&r;if(n>4)return t.error("length octect is too long");r=0;for(let s=0;s0&&i.ishrn(r),i}function vf(t,e,i){var r,n;do{for(r=cf.alloc(0);8*r.length=e)throw new Error("invalid sig")}var _f=I.Buffer;function Sf(t){ao.Writable.call(this);var e=Er[t];if(!e)throw new Error("Unknown message digest");this._hashType=e.hash,this._hash=cr(e.hash),this._tag=e.id,this._signType=e.sign}function Ef(t){ao.Writable.call(this);var e=Er[t];if(!e)throw new Error("Unknown message digest");this._hash=cr(e.hash),this._tag=e.id,this._signType=e.sign}Object.keys(Er).forEach((function(t){Er[t].id=_f.from(Er[t].id,"hex"),Er[t.toLowerCase()]=Er[t]})),Q(Sf,ao.Writable),Sf.prototype._write=function(t,e,i){this._hash.update(t),i()},Sf.prototype.update=function(t,e){return"string"==typeof t&&(t=_f.from(t,e)),this._hash.update(t),this},Sf.prototype.sign=function(t,e){this.end();var i=this._hash.digest(),r=lf(i,t,this._hashType,this._signType,this._tag);return e?r.toString(e):r},Q(Ef,ao.Writable),Ef.prototype._write=function(t,e,i){this._hash.update(t),i()},Ef.prototype.update=function(t,e){return"string"==typeof t&&(t=_f.from(t,e)),this._hash.update(t),this},Ef.prototype.verify=function(t,e,i){return"string"==typeof e&&(e=_f.from(e,i)),this.end(),function(t,e,i,r,n){var s=hf(i);if("ec"===s.type){if("ecdsa"!==r&&"ecdsa/rsa"!==r)throw new Error("wrong public key type");return function(t,e,i){var r=df[i.data.algorithm.curve.join(".")];if(!r)throw new Error("unknown curve "+i.data.algorithm.curve.join("."));var n=new wf(r),s=i.data.subjectPrivateKey.data;return n.verify(e,t,s)}(t,e,s)}if("dsa"===s.type){if("dsa"!==r)throw new Error("wrong public key type");return function(t,e,i){var r=i.data.p,n=i.data.q,s=i.data.g,o=i.data.pub_key,a=hf.signature.decode(t,"der"),h=a.s,u=a.r;Mf(h,n),Mf(u,n);var f=ho.mont(r),l=h.invm(n);return 0===s.toRed(f).redPow(new ho(e).mul(l).mod(n)).fromRed().mul(o.toRed(f).redPow(u.mul(l).mod(n)).fromRed()).mod(r).mod(n).cmp(u)}(t,e,s)}if("rsa"!==r&&"ecdsa/rsa"!==r)throw new Error("wrong public key type");e=yf.concat([n,e]);for(var o=s.modulus.byteLength(),a=[1],h=0;e.length+a.length+2=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return r}function o(t,e,i,r){for(var n=0,s=Math.min(t.length,i),o=e;o=49?a-49+10:a>=17?a-17+10:a}return n}r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,e){return t.cmp(e)>0?t:e},r.min=function(t,e){return t.cmp(e)<0?t:e},r.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===e?this._parseHex(t,r):this._parseBase(t,e,r),"-"===t[0]&&(this.negative=1),this.strip(),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initArray=function(t,e,i){if(t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r=0;r-=3)s=t[r]|t[r-1]<<8|t[r-2]<<16,this.words[n]|=s<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===i)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this.strip()},r.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=6)n=s(t,i,i+6),this.words[r]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,r++);i+6!==e&&(n=s(t,e,i+6),this.words[r]|=n<>>26-o&4194303),this.strip()},r.prototype._parseBase=function(t,e,i){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=e)r++;r--,n=n/e|0;for(var s=t.length-i,a=s%r,h=Math.min(s,s-a)+i,u=0,f=i;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},r.prototype.inspect=function(){return(this.red?""};var a=["","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"],h=[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],u=[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 f(t,e,i){i.negative=e.negative^t.negative;var r=t.length+e.length|0;i.length=r,r=r-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;i.words[0]=a;for(var u=1;u>>26,l=67108863&h,d=Math.min(u,e.length-1),c=Math.max(0,u-t.length+1);c<=d;c++){var p=u-c|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[c])+l)/67108864|0,l=67108863&o}i.words[u]=0|l,h=0|f}return 0!==h?i.words[u]=0|h:i.length--,i.strip()}r.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var r=0,n=0,s=0;s>>24-r&16777215)||s!==this.length-1?a[6-f.length]+f+i:f+i,(r+=2)>=26&&(r-=26,s--)}for(0!==n&&(i=n.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var l=h[t],d=u[t];i="";var c=this.clone();for(c.negative=0;!c.isZero();){var p=c.modn(d).toString(t);i=(c=c.idivn(d)).isZero()?p+i:a[l-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length,0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16)},r.prototype.toBuffer=function(t,e){return this.toArrayLike(n,t,e)},r.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},r.prototype.toArrayLike=function(t,e,i){var r=this.byteLength(),n=i||Math.max(1,r);this.strip();var s,o,a="le"===e,h=new t(n),u=this.clone();if(a){for(o=0;!u.isZero();o++)s=u.andln(255),u.iushrn(8),h[o]=s;for(;o=4096&&(i+=13,e>>>=13),e>=64&&(i+=7,e>>>=7),e>=8&&(i+=4,e>>>=4),e>=2&&(i+=2,e>>>=2),i+e},r.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,i=0;return 0==(8191&e)&&(i+=13,e>>>=13),0==(127&e)&&(i+=7,e>>>=7),0==(15&e)&&(i+=4,e>>>=4),0==(3&e)&&(i+=2,e>>>=2),0==(1&e)&&i++,i},r.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var i=0;it.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var e,i;this.length>t.length?(e=this,i=t):(e=t,i=this);for(var r=0;rt.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-i),this.strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,e){var i=t/26|0,r=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(i=this,r=t):(i=t,r=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i,r,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(i=this,r=t):(i=t,r=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,c=0|o[1],p=8191&c,m=c>>>13,g=0|o[2],v=8191&g,b=g>>>13,y=0|o[3],w=8191&y,M=y>>>13,_=0|o[4],S=8191&_,E=_>>>13,k=0|o[5],R=8191&k,A=k>>>13,x=0|o[6],T=8191&x,P=x>>>13,B=0|o[7],I=8191&B,q=B>>>13,O=0|o[8],L=8191&O,j=O>>>13,C=0|o[9],N=8191&C,D=C>>>13,U=0|a[0],$=8191&U,z=U>>>13,W=0|a[1],F=8191&W,K=W>>>13,H=0|a[2],Z=8191&H,V=H>>>13,G=0|a[3],Y=8191&G,X=G>>>13,J=0|a[4],Q=8191&J,tt=J>>>13,et=0|a[5],it=8191&et,rt=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,ft=0|a[8],lt=8191&ft,dt=ft>>>13,ct=0|a[9],pt=8191&ct,mt=ct>>>13;i.negative=t.negative^e.negative,i.length=19;var gt=(u+(r=Math.imul(l,$))|0)+((8191&(n=(n=Math.imul(l,z))+Math.imul(d,$)|0))<<13)|0;u=((s=Math.imul(d,z))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(p,$),n=(n=Math.imul(p,z))+Math.imul(m,$)|0,s=Math.imul(m,z);var vt=(u+(r=r+Math.imul(l,F)|0)|0)+((8191&(n=(n=n+Math.imul(l,K)|0)+Math.imul(d,F)|0))<<13)|0;u=((s=s+Math.imul(d,K)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(v,$),n=(n=Math.imul(v,z))+Math.imul(b,$)|0,s=Math.imul(b,z),r=r+Math.imul(p,F)|0,n=(n=n+Math.imul(p,K)|0)+Math.imul(m,F)|0,s=s+Math.imul(m,K)|0;var bt=(u+(r=r+Math.imul(l,Z)|0)|0)+((8191&(n=(n=n+Math.imul(l,V)|0)+Math.imul(d,Z)|0))<<13)|0;u=((s=s+Math.imul(d,V)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(w,$),n=(n=Math.imul(w,z))+Math.imul(M,$)|0,s=Math.imul(M,z),r=r+Math.imul(v,F)|0,n=(n=n+Math.imul(v,K)|0)+Math.imul(b,F)|0,s=s+Math.imul(b,K)|0,r=r+Math.imul(p,Z)|0,n=(n=n+Math.imul(p,V)|0)+Math.imul(m,Z)|0,s=s+Math.imul(m,V)|0;var yt=(u+(r=r+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,X)|0)+Math.imul(d,Y)|0))<<13)|0;u=((s=s+Math.imul(d,X)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(S,$),n=(n=Math.imul(S,z))+Math.imul(E,$)|0,s=Math.imul(E,z),r=r+Math.imul(w,F)|0,n=(n=n+Math.imul(w,K)|0)+Math.imul(M,F)|0,s=s+Math.imul(M,K)|0,r=r+Math.imul(v,Z)|0,n=(n=n+Math.imul(v,V)|0)+Math.imul(b,Z)|0,s=s+Math.imul(b,V)|0,r=r+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,X)|0;var wt=(u+(r=r+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(d,Q)|0))<<13)|0;u=((s=s+Math.imul(d,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(R,$),n=(n=Math.imul(R,z))+Math.imul(A,$)|0,s=Math.imul(A,z),r=r+Math.imul(S,F)|0,n=(n=n+Math.imul(S,K)|0)+Math.imul(E,F)|0,s=s+Math.imul(E,K)|0,r=r+Math.imul(w,Z)|0,n=(n=n+Math.imul(w,V)|0)+Math.imul(M,Z)|0,s=s+Math.imul(M,V)|0,r=r+Math.imul(v,Y)|0,n=(n=n+Math.imul(v,X)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,X)|0,r=r+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var Mt=(u+(r=r+Math.imul(l,it)|0)|0)+((8191&(n=(n=n+Math.imul(l,rt)|0)+Math.imul(d,it)|0))<<13)|0;u=((s=s+Math.imul(d,rt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(T,$),n=(n=Math.imul(T,z))+Math.imul(P,$)|0,s=Math.imul(P,z),r=r+Math.imul(R,F)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(A,F)|0,s=s+Math.imul(A,K)|0,r=r+Math.imul(S,Z)|0,n=(n=n+Math.imul(S,V)|0)+Math.imul(E,Z)|0,s=s+Math.imul(E,V)|0,r=r+Math.imul(w,Y)|0,n=(n=n+Math.imul(w,X)|0)+Math.imul(M,Y)|0,s=s+Math.imul(M,X)|0,r=r+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,tt)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,tt)|0,r=r+Math.imul(p,it)|0,n=(n=n+Math.imul(p,rt)|0)+Math.imul(m,it)|0,s=s+Math.imul(m,rt)|0;var _t=(u+(r=r+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(d,st)|0))<<13)|0;u=((s=s+Math.imul(d,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(I,$),n=(n=Math.imul(I,z))+Math.imul(q,$)|0,s=Math.imul(q,z),r=r+Math.imul(T,F)|0,n=(n=n+Math.imul(T,K)|0)+Math.imul(P,F)|0,s=s+Math.imul(P,K)|0,r=r+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,V)|0)+Math.imul(A,Z)|0,s=s+Math.imul(A,V)|0,r=r+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,X)|0,r=r+Math.imul(w,Q)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(M,Q)|0,s=s+Math.imul(M,tt)|0,r=r+Math.imul(v,it)|0,n=(n=n+Math.imul(v,rt)|0)+Math.imul(b,it)|0,s=s+Math.imul(b,rt)|0,r=r+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(r=r+Math.imul(l,ht)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((s=s+Math.imul(d,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(L,$),n=(n=Math.imul(L,z))+Math.imul(j,$)|0,s=Math.imul(j,z),r=r+Math.imul(I,F)|0,n=(n=n+Math.imul(I,K)|0)+Math.imul(q,F)|0,s=s+Math.imul(q,K)|0,r=r+Math.imul(T,Z)|0,n=(n=n+Math.imul(T,V)|0)+Math.imul(P,Z)|0,s=s+Math.imul(P,V)|0,r=r+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,X)|0,r=r+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(E,Q)|0,s=s+Math.imul(E,tt)|0,r=r+Math.imul(w,it)|0,n=(n=n+Math.imul(w,rt)|0)+Math.imul(M,it)|0,s=s+Math.imul(M,rt)|0,r=r+Math.imul(v,st)|0,n=(n=n+Math.imul(v,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,r=r+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,ut)|0;var Et=(u+(r=r+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,dt)|0)+Math.imul(d,lt)|0))<<13)|0;u=((s=s+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(N,$),n=(n=Math.imul(N,z))+Math.imul(D,$)|0,s=Math.imul(D,z),r=r+Math.imul(L,F)|0,n=(n=n+Math.imul(L,K)|0)+Math.imul(j,F)|0,s=s+Math.imul(j,K)|0,r=r+Math.imul(I,Z)|0,n=(n=n+Math.imul(I,V)|0)+Math.imul(q,Z)|0,s=s+Math.imul(q,V)|0,r=r+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,X)|0,r=r+Math.imul(R,Q)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(A,Q)|0,s=s+Math.imul(A,tt)|0,r=r+Math.imul(S,it)|0,n=(n=n+Math.imul(S,rt)|0)+Math.imul(E,it)|0,s=s+Math.imul(E,rt)|0,r=r+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(M,st)|0,s=s+Math.imul(M,ot)|0,r=r+Math.imul(v,ht)|0,n=(n=n+Math.imul(v,ut)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ut)|0,r=r+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,dt)|0;var kt=(u+(r=r+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(d,pt)|0))<<13)|0;u=((s=s+Math.imul(d,mt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(N,F),n=(n=Math.imul(N,K))+Math.imul(D,F)|0,s=Math.imul(D,K),r=r+Math.imul(L,Z)|0,n=(n=n+Math.imul(L,V)|0)+Math.imul(j,Z)|0,s=s+Math.imul(j,V)|0,r=r+Math.imul(I,Y)|0,n=(n=n+Math.imul(I,X)|0)+Math.imul(q,Y)|0,s=s+Math.imul(q,X)|0,r=r+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(P,Q)|0,s=s+Math.imul(P,tt)|0,r=r+Math.imul(R,it)|0,n=(n=n+Math.imul(R,rt)|0)+Math.imul(A,it)|0,s=s+Math.imul(A,rt)|0,r=r+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(E,st)|0,s=s+Math.imul(E,ot)|0,r=r+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(M,ht)|0,s=s+Math.imul(M,ut)|0,r=r+Math.imul(v,lt)|0,n=(n=n+Math.imul(v,dt)|0)+Math.imul(b,lt)|0,s=s+Math.imul(b,dt)|0;var Rt=(u+(r=r+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(N,Z),n=(n=Math.imul(N,V))+Math.imul(D,Z)|0,s=Math.imul(D,V),r=r+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(j,Y)|0,s=s+Math.imul(j,X)|0,r=r+Math.imul(I,Q)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(q,Q)|0,s=s+Math.imul(q,tt)|0,r=r+Math.imul(T,it)|0,n=(n=n+Math.imul(T,rt)|0)+Math.imul(P,it)|0,s=s+Math.imul(P,rt)|0,r=r+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(A,st)|0,s=s+Math.imul(A,ot)|0,r=r+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(E,ht)|0,s=s+Math.imul(E,ut)|0,r=r+Math.imul(w,lt)|0,n=(n=n+Math.imul(w,dt)|0)+Math.imul(M,lt)|0,s=s+Math.imul(M,dt)|0;var At=(u+(r=r+Math.imul(v,pt)|0)|0)+((8191&(n=(n=n+Math.imul(v,mt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((s=s+Math.imul(b,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(N,Y),n=(n=Math.imul(N,X))+Math.imul(D,Y)|0,s=Math.imul(D,X),r=r+Math.imul(L,Q)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(j,Q)|0,s=s+Math.imul(j,tt)|0,r=r+Math.imul(I,it)|0,n=(n=n+Math.imul(I,rt)|0)+Math.imul(q,it)|0,s=s+Math.imul(q,rt)|0,r=r+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,ot)|0,r=r+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(A,ht)|0,s=s+Math.imul(A,ut)|0,r=r+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,dt)|0)+Math.imul(E,lt)|0,s=s+Math.imul(E,dt)|0;var xt=(u+(r=r+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((s=s+Math.imul(M,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(N,Q),n=(n=Math.imul(N,tt))+Math.imul(D,Q)|0,s=Math.imul(D,tt),r=r+Math.imul(L,it)|0,n=(n=n+Math.imul(L,rt)|0)+Math.imul(j,it)|0,s=s+Math.imul(j,rt)|0,r=r+Math.imul(I,st)|0,n=(n=n+Math.imul(I,ot)|0)+Math.imul(q,st)|0,s=s+Math.imul(q,ot)|0,r=r+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,ut)|0,r=r+Math.imul(R,lt)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(A,lt)|0,s=s+Math.imul(A,dt)|0;var Tt=(u+(r=r+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(E,pt)|0))<<13)|0;u=((s=s+Math.imul(E,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(N,it),n=(n=Math.imul(N,rt))+Math.imul(D,it)|0,s=Math.imul(D,rt),r=r+Math.imul(L,st)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(j,st)|0,s=s+Math.imul(j,ot)|0,r=r+Math.imul(I,ht)|0,n=(n=n+Math.imul(I,ut)|0)+Math.imul(q,ht)|0,s=s+Math.imul(q,ut)|0,r=r+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,dt)|0)+Math.imul(P,lt)|0,s=s+Math.imul(P,dt)|0;var Pt=(u+(r=r+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((s=s+Math.imul(A,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(N,st),n=(n=Math.imul(N,ot))+Math.imul(D,st)|0,s=Math.imul(D,ot),r=r+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,ut)|0)+Math.imul(j,ht)|0,s=s+Math.imul(j,ut)|0,r=r+Math.imul(I,lt)|0,n=(n=n+Math.imul(I,dt)|0)+Math.imul(q,lt)|0,s=s+Math.imul(q,dt)|0;var Bt=(u+(r=r+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((s=s+Math.imul(P,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(N,ht),n=(n=Math.imul(N,ut))+Math.imul(D,ht)|0,s=Math.imul(D,ut),r=r+Math.imul(L,lt)|0,n=(n=n+Math.imul(L,dt)|0)+Math.imul(j,lt)|0,s=s+Math.imul(j,dt)|0;var It=(u+(r=r+Math.imul(I,pt)|0)|0)+((8191&(n=(n=n+Math.imul(I,mt)|0)+Math.imul(q,pt)|0))<<13)|0;u=((s=s+Math.imul(q,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(N,lt),n=(n=Math.imul(N,dt))+Math.imul(D,lt)|0,s=Math.imul(D,dt);var qt=(u+(r=r+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,mt)|0)+Math.imul(j,pt)|0))<<13)|0;u=((s=s+Math.imul(j,mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863;var Ot=(u+(r=Math.imul(N,pt))|0)+((8191&(n=(n=Math.imul(N,mt))+Math.imul(D,pt)|0))<<13)|0;return u=((s=Math.imul(D,mt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=vt,h[2]=bt,h[3]=yt,h[4]=wt,h[5]=Mt,h[6]=_t,h[7]=St,h[8]=Et,h[9]=kt,h[10]=Rt,h[11]=At,h[12]=xt,h[13]=Tt,h[14]=Pt,h[15]=Bt,h[16]=It,h[17]=qt,h[18]=Ot,0!==u&&(h[19]=u,i.length++),i};function d(t,e,i){return(new c).mulp(t,e,i)}function c(t,e){this.x=t,this.y=e}Math.imul||(l=f),r.prototype.mulTo=function(t,e){var i=this.length+t.length;return 10===this.length&&10===t.length?l(this,t,e):i<63?f(this,t,e):i<1024?function(t,e,i){i.negative=e.negative^t.negative,i.length=t.length+e.length;for(var r=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}i.words[s]=a,r=o,o=n}return 0!==r?i.words[s]=r:i.length--,i.strip()}(this,t,e):d(this,t,e)},c.prototype.makeRBT=function(t){for(var e=new Array(t),i=r.prototype._countBits(t)-1,n=0;n>=1;return r},c.prototype.permute=function(t,e,i,r,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*s+1]=8191&n,n>>>=13;for(s=2*e;s>=26,e+=r/67108864|0,e+=n>>>26,this.words[i]=67108863&n}return 0!==e&&(this.words[i]=e,this.length++),this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),i=0;i>>n}return e}(t);if(0===e.length)return new r(1);for(var i=this,n=0;n>>26-i<<26-i;if(0!==i){var s=0;for(e=0;e>>26-i}s&&(this.words[e]=s,this.length++)}if(0!==r){for(e=this.length-1;e>=0;e--)this.words[e+r]=this.words[e];for(e=0;e>>n<s)for(this.length-=s,h=0;h=0&&(0!==u||h>=r);h--){var f=0|this.words[h];this.words[h]=u<<26-n|f>>>n,u=f&o}return a&&0!==u&&(a.words[a.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},r.prototype.ishrn=function(t,e,i){return this.iushrn(t,e,i)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){var e=t%26,i=(t-e)/26,r=1<>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},r.prototype.isubn=function(t){if(t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(a/67108864|0),this.words[r+i]=67108863&n}for(;r>26,this.words[r+i]=67108863&n;if(0===o)return this.strip();for(o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},r.prototype._wordDiv=function(t,e){var i=(this.length,t.length),n=this.clone(),s=t,o=0|s.words[s.length-1];0!=(i=26-this._countBits(o))&&(s=s.ushln(i),n.iushln(i),o=0|s.words[s.length-1]);var a,h=n.length-s.length;if("mod"!==e){(a=new r(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u=0;l--){var d=67108864*(0|n.words[s.length+l])+(0|n.words[s.length+l-1]);for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(s,d,l);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(s,1,l),n.isZero()||(n.negative^=1);a&&(a.words[l]=d)}return a&&a.strip(),n.strip(),"div"!==e&&0!==i&&n.iushrn(i),{div:a||null,mod:n}},r.prototype.divmod=function(t,e,i){return this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),"mod"!==e&&(n=o.div.neg()),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),e),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new r(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var i=0!==e.div.negative?e.mod.isub(t):e.mod,r=t.ushrn(1),n=t.andln(1),s=i.cmp(r);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},r.prototype.modn=function(t){for(var e=(1<<26)%t,i=0,r=this.length-1;r>=0;r--)i=(e*i+(0|this.words[r]))%t;return i},r.prototype.idivn=function(t){for(var e=0,i=this.length-1;i>=0;i--){var r=(0|this.words[i])+67108864*e;this.words[i]=r/t|0,e=r%t}return this.strip()},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new r(1),s=new r(0),o=new r(0),a=new r(1),h=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++h;for(var u=i.clone(),f=e.clone();!e.isZero();){for(var l=0,d=1;0==(e.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(e.iushrn(l);l-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(u),s.isub(f)),n.iushrn(1),s.iushrn(1);for(var c=0,p=1;0==(i.words[0]&p)&&c<26;++c,p<<=1);if(c>0)for(i.iushrn(c);c-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(u),a.isub(f)),o.iushrn(1),a.iushrn(1);e.cmp(i)>=0?(e.isub(i),n.isub(o),s.isub(a)):(i.isub(e),o.isub(n),a.isub(s))}return{a:o,b:a,gcd:i.iushln(h)}},r.prototype._invmp=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new r(1),o=new r(0),a=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var h=0,u=1;0==(e.words[0]&u)&&h<26;++h,u<<=1);if(h>0)for(e.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(a),s.iushrn(1);for(var f=0,l=1;0==(i.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(i.iushrn(f);f-- >0;)o.isOdd()&&o.iadd(a),o.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o)):(i.isub(e),o.isub(s))}return(n=0===e.cmpn(1)?s:o).cmpn(0)<0&&n.iadd(t),n},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),i=t.clone();e.negative=0,i.negative=0;for(var r=0;e.isEven()&&i.isEven();r++)e.iushrn(1),i.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;i.isEven();)i.iushrn(1);var n=e.cmp(i);if(n<0){var s=e;e=i,i=s}else if(0===n||0===i.cmpn(1))break;e.isub(i)}return i.iushln(r)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){var e=t%26,i=(t-e)/26,r=1<>>26,o&=67108863,this.words[s]=o}return 0!==n&&(this.words[s]=n,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t);var r=0|this.words[0];e=r===t?0:rt.length)return 1;if(this.length=0;i--){var r=0|this.words[i],n=0|t.words[i];if(r!==n){rn&&(e=1);break}}return e},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new M(t)},r.prototype.toRed=function(t){return t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return this._forceRed(t)},r.prototype.redAdd=function(t){return this.red.add(this,t)},r.prototype.redIAdd=function(t){return this.red.iadd(this,t)},r.prototype.redSub=function(t){return this.red.sub(this,t)},r.prototype.redISub=function(t){return this.red.isub(this,t)},r.prototype.redShl=function(t){return this.red.shl(this,t)},r.prototype.redMul=function(t){return this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return this.red._verify1(this),this.red.pow(this,t)};var p={k256:null,p224:null,p192:null,p25519:null};function m(t,e){this.name=t,this.p=new r(e,16),this.n=this.p.bitLength(),this.k=new r(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 v(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function y(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(t){if("string"==typeof t){var e=r._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function _(t){M.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(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 t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},m.prototype.ireduce=function(t){var e,i=t;do{this.split(i,this.tmp),e=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(e>this.n);var r=e0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},m.prototype.split=function(t,e){t.iushrn(this.n,0,e)},m.prototype.imulK=function(t){return t.imul(this.k)},i(g,m),g.prototype.split=function(t,e){for(var i=Math.min(t.length,9),r=0;r>>22,n=s}n>>>=22,t.words[r-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},g.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,i=0;i>>=26,t.words[i]=n,e=r}return 0!==e&&(t.words[t.length++]=e),t},r._prime=function(t){if(p[t])return p[t];var e;if("k256"===t)e=new g;else if("p224"===t)e=new v;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new y}return p[t]=e,e},M.prototype._verify1=function(t){},M.prototype._verify2=function(t,e){},M.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},M.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},M.prototype.add=function(t,e){this._verify2(t,e);var i=t.add(e);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},M.prototype.iadd=function(t,e){this._verify2(t,e);var i=t.iadd(e);return i.cmp(this.m)>=0&&i.isub(this.m),i},M.prototype.sub=function(t,e){this._verify2(t,e);var i=t.sub(e);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},M.prototype.isub=function(t,e){this._verify2(t,e);var i=t.isub(e);return i.cmpn(0)<0&&i.iadd(this.m),i},M.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},M.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},M.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},M.prototype.isqr=function(t){return this.imul(t,t.clone())},M.prototype.sqr=function(t){return this.mul(t,t)},M.prototype.sqrt=function(t){if(t.isZero())return t.clone();if(3===this.m.andln(3)){var e=this.m.add(new r(1)).iushrn(2);return this.pow(t,e)}for(var i=this.m.subn(1),n=0;!i.isZero()&&0===i.andln(1);)n++,i.iushrn(1);var s=new r(1).toRed(this),o=s.redNeg(),a=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new r(2*h*h).toRed(this);0!==this.pow(h,a).cmp(o);)h.redIAdd(o);for(var u=this.pow(h,i),f=this.pow(t,i.addn(1).iushrn(1)),l=this.pow(t,i),d=n;0!==l.cmp(s);){for(var c=l,p=0;0!==c.cmp(s);p++)c=c.redSqr();var m=this.pow(u,new r(1).iushln(d-p-1));f=f.redMul(m),u=m.redSqr(),l=l.redMul(u),d=p}return f},M.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},M.prototype.pow=function(t,e){if(e.isZero())return new r(1).toRed(this);if(0===e.cmpn(1))return t.clone();var i=new Array(16);i[0]=new r(1).toRed(this),i[1]=t;for(var n=2;n=0;n--){for(var u=e.words[n],f=h-1;f>=0;f--){var l=u>>f&1;s!==i[0]&&(s=this.sqr(s)),0!==l||0!==o?(o<<=1,o|=l,(4==++a||0===n&&0===f)&&(s=this.mul(s,i[o]),a=0,o=0)):a=0}h=26}return s},M.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},M.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},r.mont=function(t){return new _(t)},i(_,M),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(e),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new r(0)._forceRed(this);var i=t.mul(e),n=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=i.isub(n).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(kf,this),kf=kf.exports;(function(t){(function(){(function(t){return new i(t)});var e={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};function i(t){this.curveType=e[t],this.curveType||(this.curveType={name:t}),this.curve=new Dh.ec(this.curveType.name),this.keys=void 0}function r(e,i,r){Array.isArray(e)||(e=e.toArray());var n=new t(e);if(r&&n.length=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return r}function o(t,e,i,r){for(var n=0,s=Math.min(t.length,i),o=e;o=49?a-49+10:a>=17?a-17+10:a}return n}r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,e){return t.cmp(e)>0?t:e},r.min=function(t,e){return t.cmp(e)<0?t:e},r.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===e?this._parseHex(t,r):this._parseBase(t,e,r),"-"===t[0]&&(this.negative=1),this.strip(),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initArray=function(t,e,i){if(t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r=0;r-=3)s=t[r]|t[r-1]<<8|t[r-2]<<16,this.words[n]|=s<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===i)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this.strip()},r.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=6)n=s(t,i,i+6),this.words[r]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,r++);i+6!==e&&(n=s(t,e,i+6),this.words[r]|=n<>>26-o&4194303),this.strip()},r.prototype._parseBase=function(t,e,i){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=e)r++;r--,n=n/e|0;for(var s=t.length-i,a=s%r,h=Math.min(s,s-a)+i,u=0,f=i;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},r.prototype.inspect=function(){return(this.red?""};var a=["","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"],h=[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],u=[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 f(t,e,i){i.negative=e.negative^t.negative;var r=t.length+e.length|0;i.length=r,r=r-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;i.words[0]=a;for(var u=1;u>>26,l=67108863&h,d=Math.min(u,e.length-1),c=Math.max(0,u-t.length+1);c<=d;c++){var p=u-c|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[c])+l)/67108864|0,l=67108863&o}i.words[u]=0|l,h=0|f}return 0!==h?i.words[u]=0|h:i.length--,i.strip()}r.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var r=0,n=0,s=0;s>>24-r&16777215)||s!==this.length-1?a[6-f.length]+f+i:f+i,(r+=2)>=26&&(r-=26,s--)}for(0!==n&&(i=n.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var l=h[t],d=u[t];i="";var c=this.clone();for(c.negative=0;!c.isZero();){var p=c.modn(d).toString(t);i=(c=c.idivn(d)).isZero()?p+i:a[l-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length,0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16)},r.prototype.toBuffer=function(t,e){return this.toArrayLike(n,t,e)},r.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},r.prototype.toArrayLike=function(t,e,i){var r=this.byteLength(),n=i||Math.max(1,r);this.strip();var s,o,a="le"===e,h=new t(n),u=this.clone();if(a){for(o=0;!u.isZero();o++)s=u.andln(255),u.iushrn(8),h[o]=s;for(;o=4096&&(i+=13,e>>>=13),e>=64&&(i+=7,e>>>=7),e>=8&&(i+=4,e>>>=4),e>=2&&(i+=2,e>>>=2),i+e},r.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,i=0;return 0==(8191&e)&&(i+=13,e>>>=13),0==(127&e)&&(i+=7,e>>>=7),0==(15&e)&&(i+=4,e>>>=4),0==(3&e)&&(i+=2,e>>>=2),0==(1&e)&&i++,i},r.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var i=0;it.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var e,i;this.length>t.length?(e=this,i=t):(e=t,i=this);for(var r=0;rt.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-i),this.strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,e){var i=t/26|0,r=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(i=this,r=t):(i=t,r=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i,r,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(i=this,r=t):(i=t,r=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,c=0|o[1],p=8191&c,m=c>>>13,g=0|o[2],v=8191&g,b=g>>>13,y=0|o[3],w=8191&y,M=y>>>13,_=0|o[4],S=8191&_,E=_>>>13,k=0|o[5],R=8191&k,A=k>>>13,x=0|o[6],T=8191&x,P=x>>>13,B=0|o[7],I=8191&B,q=B>>>13,O=0|o[8],L=8191&O,j=O>>>13,C=0|o[9],N=8191&C,D=C>>>13,U=0|a[0],$=8191&U,z=U>>>13,W=0|a[1],F=8191&W,K=W>>>13,H=0|a[2],Z=8191&H,V=H>>>13,G=0|a[3],Y=8191&G,X=G>>>13,J=0|a[4],Q=8191&J,tt=J>>>13,et=0|a[5],it=8191&et,rt=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,ft=0|a[8],lt=8191&ft,dt=ft>>>13,ct=0|a[9],pt=8191&ct,mt=ct>>>13;i.negative=t.negative^e.negative,i.length=19;var gt=(u+(r=Math.imul(l,$))|0)+((8191&(n=(n=Math.imul(l,z))+Math.imul(d,$)|0))<<13)|0;u=((s=Math.imul(d,z))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(p,$),n=(n=Math.imul(p,z))+Math.imul(m,$)|0,s=Math.imul(m,z);var vt=(u+(r=r+Math.imul(l,F)|0)|0)+((8191&(n=(n=n+Math.imul(l,K)|0)+Math.imul(d,F)|0))<<13)|0;u=((s=s+Math.imul(d,K)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(v,$),n=(n=Math.imul(v,z))+Math.imul(b,$)|0,s=Math.imul(b,z),r=r+Math.imul(p,F)|0,n=(n=n+Math.imul(p,K)|0)+Math.imul(m,F)|0,s=s+Math.imul(m,K)|0;var bt=(u+(r=r+Math.imul(l,Z)|0)|0)+((8191&(n=(n=n+Math.imul(l,V)|0)+Math.imul(d,Z)|0))<<13)|0;u=((s=s+Math.imul(d,V)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(w,$),n=(n=Math.imul(w,z))+Math.imul(M,$)|0,s=Math.imul(M,z),r=r+Math.imul(v,F)|0,n=(n=n+Math.imul(v,K)|0)+Math.imul(b,F)|0,s=s+Math.imul(b,K)|0,r=r+Math.imul(p,Z)|0,n=(n=n+Math.imul(p,V)|0)+Math.imul(m,Z)|0,s=s+Math.imul(m,V)|0;var yt=(u+(r=r+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,X)|0)+Math.imul(d,Y)|0))<<13)|0;u=((s=s+Math.imul(d,X)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(S,$),n=(n=Math.imul(S,z))+Math.imul(E,$)|0,s=Math.imul(E,z),r=r+Math.imul(w,F)|0,n=(n=n+Math.imul(w,K)|0)+Math.imul(M,F)|0,s=s+Math.imul(M,K)|0,r=r+Math.imul(v,Z)|0,n=(n=n+Math.imul(v,V)|0)+Math.imul(b,Z)|0,s=s+Math.imul(b,V)|0,r=r+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,X)|0;var wt=(u+(r=r+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(d,Q)|0))<<13)|0;u=((s=s+Math.imul(d,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(R,$),n=(n=Math.imul(R,z))+Math.imul(A,$)|0,s=Math.imul(A,z),r=r+Math.imul(S,F)|0,n=(n=n+Math.imul(S,K)|0)+Math.imul(E,F)|0,s=s+Math.imul(E,K)|0,r=r+Math.imul(w,Z)|0,n=(n=n+Math.imul(w,V)|0)+Math.imul(M,Z)|0,s=s+Math.imul(M,V)|0,r=r+Math.imul(v,Y)|0,n=(n=n+Math.imul(v,X)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,X)|0,r=r+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var Mt=(u+(r=r+Math.imul(l,it)|0)|0)+((8191&(n=(n=n+Math.imul(l,rt)|0)+Math.imul(d,it)|0))<<13)|0;u=((s=s+Math.imul(d,rt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(T,$),n=(n=Math.imul(T,z))+Math.imul(P,$)|0,s=Math.imul(P,z),r=r+Math.imul(R,F)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(A,F)|0,s=s+Math.imul(A,K)|0,r=r+Math.imul(S,Z)|0,n=(n=n+Math.imul(S,V)|0)+Math.imul(E,Z)|0,s=s+Math.imul(E,V)|0,r=r+Math.imul(w,Y)|0,n=(n=n+Math.imul(w,X)|0)+Math.imul(M,Y)|0,s=s+Math.imul(M,X)|0,r=r+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,tt)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,tt)|0,r=r+Math.imul(p,it)|0,n=(n=n+Math.imul(p,rt)|0)+Math.imul(m,it)|0,s=s+Math.imul(m,rt)|0;var _t=(u+(r=r+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(d,st)|0))<<13)|0;u=((s=s+Math.imul(d,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(I,$),n=(n=Math.imul(I,z))+Math.imul(q,$)|0,s=Math.imul(q,z),r=r+Math.imul(T,F)|0,n=(n=n+Math.imul(T,K)|0)+Math.imul(P,F)|0,s=s+Math.imul(P,K)|0,r=r+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,V)|0)+Math.imul(A,Z)|0,s=s+Math.imul(A,V)|0,r=r+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,X)|0,r=r+Math.imul(w,Q)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(M,Q)|0,s=s+Math.imul(M,tt)|0,r=r+Math.imul(v,it)|0,n=(n=n+Math.imul(v,rt)|0)+Math.imul(b,it)|0,s=s+Math.imul(b,rt)|0,r=r+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(r=r+Math.imul(l,ht)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((s=s+Math.imul(d,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(L,$),n=(n=Math.imul(L,z))+Math.imul(j,$)|0,s=Math.imul(j,z),r=r+Math.imul(I,F)|0,n=(n=n+Math.imul(I,K)|0)+Math.imul(q,F)|0,s=s+Math.imul(q,K)|0,r=r+Math.imul(T,Z)|0,n=(n=n+Math.imul(T,V)|0)+Math.imul(P,Z)|0,s=s+Math.imul(P,V)|0,r=r+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,X)|0,r=r+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(E,Q)|0,s=s+Math.imul(E,tt)|0,r=r+Math.imul(w,it)|0,n=(n=n+Math.imul(w,rt)|0)+Math.imul(M,it)|0,s=s+Math.imul(M,rt)|0,r=r+Math.imul(v,st)|0,n=(n=n+Math.imul(v,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,r=r+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,ut)|0;var Et=(u+(r=r+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,dt)|0)+Math.imul(d,lt)|0))<<13)|0;u=((s=s+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(N,$),n=(n=Math.imul(N,z))+Math.imul(D,$)|0,s=Math.imul(D,z),r=r+Math.imul(L,F)|0,n=(n=n+Math.imul(L,K)|0)+Math.imul(j,F)|0,s=s+Math.imul(j,K)|0,r=r+Math.imul(I,Z)|0,n=(n=n+Math.imul(I,V)|0)+Math.imul(q,Z)|0,s=s+Math.imul(q,V)|0,r=r+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,X)|0,r=r+Math.imul(R,Q)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(A,Q)|0,s=s+Math.imul(A,tt)|0,r=r+Math.imul(S,it)|0,n=(n=n+Math.imul(S,rt)|0)+Math.imul(E,it)|0,s=s+Math.imul(E,rt)|0,r=r+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(M,st)|0,s=s+Math.imul(M,ot)|0,r=r+Math.imul(v,ht)|0,n=(n=n+Math.imul(v,ut)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ut)|0,r=r+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,dt)|0;var kt=(u+(r=r+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(d,pt)|0))<<13)|0;u=((s=s+Math.imul(d,mt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(N,F),n=(n=Math.imul(N,K))+Math.imul(D,F)|0,s=Math.imul(D,K),r=r+Math.imul(L,Z)|0,n=(n=n+Math.imul(L,V)|0)+Math.imul(j,Z)|0,s=s+Math.imul(j,V)|0,r=r+Math.imul(I,Y)|0,n=(n=n+Math.imul(I,X)|0)+Math.imul(q,Y)|0,s=s+Math.imul(q,X)|0,r=r+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(P,Q)|0,s=s+Math.imul(P,tt)|0,r=r+Math.imul(R,it)|0,n=(n=n+Math.imul(R,rt)|0)+Math.imul(A,it)|0,s=s+Math.imul(A,rt)|0,r=r+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(E,st)|0,s=s+Math.imul(E,ot)|0,r=r+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(M,ht)|0,s=s+Math.imul(M,ut)|0,r=r+Math.imul(v,lt)|0,n=(n=n+Math.imul(v,dt)|0)+Math.imul(b,lt)|0,s=s+Math.imul(b,dt)|0;var Rt=(u+(r=r+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(N,Z),n=(n=Math.imul(N,V))+Math.imul(D,Z)|0,s=Math.imul(D,V),r=r+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(j,Y)|0,s=s+Math.imul(j,X)|0,r=r+Math.imul(I,Q)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(q,Q)|0,s=s+Math.imul(q,tt)|0,r=r+Math.imul(T,it)|0,n=(n=n+Math.imul(T,rt)|0)+Math.imul(P,it)|0,s=s+Math.imul(P,rt)|0,r=r+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(A,st)|0,s=s+Math.imul(A,ot)|0,r=r+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(E,ht)|0,s=s+Math.imul(E,ut)|0,r=r+Math.imul(w,lt)|0,n=(n=n+Math.imul(w,dt)|0)+Math.imul(M,lt)|0,s=s+Math.imul(M,dt)|0;var At=(u+(r=r+Math.imul(v,pt)|0)|0)+((8191&(n=(n=n+Math.imul(v,mt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((s=s+Math.imul(b,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(N,Y),n=(n=Math.imul(N,X))+Math.imul(D,Y)|0,s=Math.imul(D,X),r=r+Math.imul(L,Q)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(j,Q)|0,s=s+Math.imul(j,tt)|0,r=r+Math.imul(I,it)|0,n=(n=n+Math.imul(I,rt)|0)+Math.imul(q,it)|0,s=s+Math.imul(q,rt)|0,r=r+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,ot)|0,r=r+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(A,ht)|0,s=s+Math.imul(A,ut)|0,r=r+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,dt)|0)+Math.imul(E,lt)|0,s=s+Math.imul(E,dt)|0;var xt=(u+(r=r+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((s=s+Math.imul(M,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(N,Q),n=(n=Math.imul(N,tt))+Math.imul(D,Q)|0,s=Math.imul(D,tt),r=r+Math.imul(L,it)|0,n=(n=n+Math.imul(L,rt)|0)+Math.imul(j,it)|0,s=s+Math.imul(j,rt)|0,r=r+Math.imul(I,st)|0,n=(n=n+Math.imul(I,ot)|0)+Math.imul(q,st)|0,s=s+Math.imul(q,ot)|0,r=r+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,ut)|0,r=r+Math.imul(R,lt)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(A,lt)|0,s=s+Math.imul(A,dt)|0;var Tt=(u+(r=r+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(E,pt)|0))<<13)|0;u=((s=s+Math.imul(E,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(N,it),n=(n=Math.imul(N,rt))+Math.imul(D,it)|0,s=Math.imul(D,rt),r=r+Math.imul(L,st)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(j,st)|0,s=s+Math.imul(j,ot)|0,r=r+Math.imul(I,ht)|0,n=(n=n+Math.imul(I,ut)|0)+Math.imul(q,ht)|0,s=s+Math.imul(q,ut)|0,r=r+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,dt)|0)+Math.imul(P,lt)|0,s=s+Math.imul(P,dt)|0;var Pt=(u+(r=r+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((s=s+Math.imul(A,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(N,st),n=(n=Math.imul(N,ot))+Math.imul(D,st)|0,s=Math.imul(D,ot),r=r+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,ut)|0)+Math.imul(j,ht)|0,s=s+Math.imul(j,ut)|0,r=r+Math.imul(I,lt)|0,n=(n=n+Math.imul(I,dt)|0)+Math.imul(q,lt)|0,s=s+Math.imul(q,dt)|0;var Bt=(u+(r=r+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((s=s+Math.imul(P,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(N,ht),n=(n=Math.imul(N,ut))+Math.imul(D,ht)|0,s=Math.imul(D,ut),r=r+Math.imul(L,lt)|0,n=(n=n+Math.imul(L,dt)|0)+Math.imul(j,lt)|0,s=s+Math.imul(j,dt)|0;var It=(u+(r=r+Math.imul(I,pt)|0)|0)+((8191&(n=(n=n+Math.imul(I,mt)|0)+Math.imul(q,pt)|0))<<13)|0;u=((s=s+Math.imul(q,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(N,lt),n=(n=Math.imul(N,dt))+Math.imul(D,lt)|0,s=Math.imul(D,dt);var qt=(u+(r=r+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,mt)|0)+Math.imul(j,pt)|0))<<13)|0;u=((s=s+Math.imul(j,mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863;var Ot=(u+(r=Math.imul(N,pt))|0)+((8191&(n=(n=Math.imul(N,mt))+Math.imul(D,pt)|0))<<13)|0;return u=((s=Math.imul(D,mt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=vt,h[2]=bt,h[3]=yt,h[4]=wt,h[5]=Mt,h[6]=_t,h[7]=St,h[8]=Et,h[9]=kt,h[10]=Rt,h[11]=At,h[12]=xt,h[13]=Tt,h[14]=Pt,h[15]=Bt,h[16]=It,h[17]=qt,h[18]=Ot,0!==u&&(h[19]=u,i.length++),i};function d(t,e,i){return(new c).mulp(t,e,i)}function c(t,e){this.x=t,this.y=e}Math.imul||(l=f),r.prototype.mulTo=function(t,e){var i=this.length+t.length;return 10===this.length&&10===t.length?l(this,t,e):i<63?f(this,t,e):i<1024?function(t,e,i){i.negative=e.negative^t.negative,i.length=t.length+e.length;for(var r=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}i.words[s]=a,r=o,o=n}return 0!==r?i.words[s]=r:i.length--,i.strip()}(this,t,e):d(this,t,e)},c.prototype.makeRBT=function(t){for(var e=new Array(t),i=r.prototype._countBits(t)-1,n=0;n>=1;return r},c.prototype.permute=function(t,e,i,r,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*s+1]=8191&n,n>>>=13;for(s=2*e;s>=26,e+=r/67108864|0,e+=n>>>26,this.words[i]=67108863&n}return 0!==e&&(this.words[i]=e,this.length++),this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),i=0;i>>n}return e}(t);if(0===e.length)return new r(1);for(var i=this,n=0;n>>26-i<<26-i;if(0!==i){var s=0;for(e=0;e>>26-i}s&&(this.words[e]=s,this.length++)}if(0!==r){for(e=this.length-1;e>=0;e--)this.words[e+r]=this.words[e];for(e=0;e>>n<s)for(this.length-=s,h=0;h=0&&(0!==u||h>=r);h--){var f=0|this.words[h];this.words[h]=u<<26-n|f>>>n,u=f&o}return a&&0!==u&&(a.words[a.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},r.prototype.ishrn=function(t,e,i){return this.iushrn(t,e,i)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){var e=t%26,i=(t-e)/26,r=1<>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},r.prototype.isubn=function(t){if(t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(a/67108864|0),this.words[r+i]=67108863&n}for(;r>26,this.words[r+i]=67108863&n;if(0===o)return this.strip();for(o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},r.prototype._wordDiv=function(t,e){var i=(this.length,t.length),n=this.clone(),s=t,o=0|s.words[s.length-1];0!=(i=26-this._countBits(o))&&(s=s.ushln(i),n.iushln(i),o=0|s.words[s.length-1]);var a,h=n.length-s.length;if("mod"!==e){(a=new r(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u=0;l--){var d=67108864*(0|n.words[s.length+l])+(0|n.words[s.length+l-1]);for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(s,d,l);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(s,1,l),n.isZero()||(n.negative^=1);a&&(a.words[l]=d)}return a&&a.strip(),n.strip(),"div"!==e&&0!==i&&n.iushrn(i),{div:a||null,mod:n}},r.prototype.divmod=function(t,e,i){return this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),"mod"!==e&&(n=o.div.neg()),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),e),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new r(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var i=0!==e.div.negative?e.mod.isub(t):e.mod,r=t.ushrn(1),n=t.andln(1),s=i.cmp(r);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},r.prototype.modn=function(t){for(var e=(1<<26)%t,i=0,r=this.length-1;r>=0;r--)i=(e*i+(0|this.words[r]))%t;return i},r.prototype.idivn=function(t){for(var e=0,i=this.length-1;i>=0;i--){var r=(0|this.words[i])+67108864*e;this.words[i]=r/t|0,e=r%t}return this.strip()},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new r(1),s=new r(0),o=new r(0),a=new r(1),h=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++h;for(var u=i.clone(),f=e.clone();!e.isZero();){for(var l=0,d=1;0==(e.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(e.iushrn(l);l-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(u),s.isub(f)),n.iushrn(1),s.iushrn(1);for(var c=0,p=1;0==(i.words[0]&p)&&c<26;++c,p<<=1);if(c>0)for(i.iushrn(c);c-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(u),a.isub(f)),o.iushrn(1),a.iushrn(1);e.cmp(i)>=0?(e.isub(i),n.isub(o),s.isub(a)):(i.isub(e),o.isub(n),a.isub(s))}return{a:o,b:a,gcd:i.iushln(h)}},r.prototype._invmp=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new r(1),o=new r(0),a=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var h=0,u=1;0==(e.words[0]&u)&&h<26;++h,u<<=1);if(h>0)for(e.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(a),s.iushrn(1);for(var f=0,l=1;0==(i.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(i.iushrn(f);f-- >0;)o.isOdd()&&o.iadd(a),o.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o)):(i.isub(e),o.isub(s))}return(n=0===e.cmpn(1)?s:o).cmpn(0)<0&&n.iadd(t),n},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),i=t.clone();e.negative=0,i.negative=0;for(var r=0;e.isEven()&&i.isEven();r++)e.iushrn(1),i.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;i.isEven();)i.iushrn(1);var n=e.cmp(i);if(n<0){var s=e;e=i,i=s}else if(0===n||0===i.cmpn(1))break;e.isub(i)}return i.iushln(r)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){var e=t%26,i=(t-e)/26,r=1<>>26,o&=67108863,this.words[s]=o}return 0!==n&&(this.words[s]=n,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t);var r=0|this.words[0];e=r===t?0:rt.length)return 1;if(this.length=0;i--){var r=0|this.words[i],n=0|t.words[i];if(r!==n){rn&&(e=1);break}}return e},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new M(t)},r.prototype.toRed=function(t){return t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return this._forceRed(t)},r.prototype.redAdd=function(t){return this.red.add(this,t)},r.prototype.redIAdd=function(t){return this.red.iadd(this,t)},r.prototype.redSub=function(t){return this.red.sub(this,t)},r.prototype.redISub=function(t){return this.red.isub(this,t)},r.prototype.redShl=function(t){return this.red.shl(this,t)},r.prototype.redMul=function(t){return this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return this.red._verify1(this),this.red.pow(this,t)};var p={k256:null,p224:null,p192:null,p25519:null};function m(t,e){this.name=t,this.p=new r(e,16),this.n=this.p.bitLength(),this.k=new r(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 v(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function y(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(t){if("string"==typeof t){var e=r._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function _(t){M.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(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 t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},m.prototype.ireduce=function(t){var e,i=t;do{this.split(i,this.tmp),e=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(e>this.n);var r=e0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},m.prototype.split=function(t,e){t.iushrn(this.n,0,e)},m.prototype.imulK=function(t){return t.imul(this.k)},i(g,m),g.prototype.split=function(t,e){for(var i=Math.min(t.length,9),r=0;r>>22,n=s}n>>>=22,t.words[r-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},g.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,i=0;i>>=26,t.words[i]=n,e=r}return 0!==e&&(t.words[t.length++]=e),t},r._prime=function(t){if(p[t])return p[t];var e;if("k256"===t)e=new g;else if("p224"===t)e=new v;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new y}return p[t]=e,e},M.prototype._verify1=function(t){},M.prototype._verify2=function(t,e){},M.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},M.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},M.prototype.add=function(t,e){this._verify2(t,e);var i=t.add(e);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},M.prototype.iadd=function(t,e){this._verify2(t,e);var i=t.iadd(e);return i.cmp(this.m)>=0&&i.isub(this.m),i},M.prototype.sub=function(t,e){this._verify2(t,e);var i=t.sub(e);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},M.prototype.isub=function(t,e){this._verify2(t,e);var i=t.isub(e);return i.cmpn(0)<0&&i.iadd(this.m),i},M.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},M.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},M.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},M.prototype.isqr=function(t){return this.imul(t,t.clone())},M.prototype.sqr=function(t){return this.mul(t,t)},M.prototype.sqrt=function(t){if(t.isZero())return t.clone();if(3===this.m.andln(3)){var e=this.m.add(new r(1)).iushrn(2);return this.pow(t,e)}for(var i=this.m.subn(1),n=0;!i.isZero()&&0===i.andln(1);)n++,i.iushrn(1);var s=new r(1).toRed(this),o=s.redNeg(),a=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new r(2*h*h).toRed(this);0!==this.pow(h,a).cmp(o);)h.redIAdd(o);for(var u=this.pow(h,i),f=this.pow(t,i.addn(1).iushrn(1)),l=this.pow(t,i),d=n;0!==l.cmp(s);){for(var c=l,p=0;0!==c.cmp(s);p++)c=c.redSqr();var m=this.pow(u,new r(1).iushln(d-p-1));f=f.redMul(m),u=m.redSqr(),l=l.redMul(u),d=p}return f},M.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},M.prototype.pow=function(t,e){if(e.isZero())return new r(1).toRed(this);if(0===e.cmpn(1))return t.clone();var i=new Array(16);i[0]=new r(1).toRed(this),i[1]=t;for(var n=2;n=0;n--){for(var u=e.words[n],f=h-1;f>=0;f--){var l=u>>f&1;s!==i[0]&&(s=this.sqr(s)),0!==l||0!==o?(o<<=1,o|=l,(4==++a||0===n&&0===f)&&(s=this.mul(s,i[o]),a=0,o=0)):a=0}h=26}return s},M.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},M.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},r.mont=function(t){return new _(t)},i(_,M),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(e),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new r(0)._forceRed(this);var i=t.mul(e),n=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=i.isub(n).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(Rf,this),Rf=Rf.exports;I.Buffer,I.Buffer,I.Buffer;var Af={};(function(t,e){(function(){"use strict";I.Buffer,I.kMaxLength;var i=e.crypto||e.msCrypto;Math.pow(2,32);i&&i.getRandomValues||t.browser}).call(this)}).call(this,D,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});var xf={};xf.createHash=cr,xf.createHmac=yr;var Tf=Object.keys(kr);["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(Tf);jr.pbkdf2,jr.pbkdf2Sync,Af.publicEncrypt,Af.privateEncrypt,Af.publicDecrypt,Af.privateDecrypt;Array.isArray;var Pf=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}},Bf=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function If(t,e){if(t.map)return t.map(e);for(var i=[],r=0;r{f=r.ERR_TIMEOUT,e.abort()},0===n?this.requestTimeout:n)}a=await fetch(t.uri,t),void 0!==u&&clearTimeout(u),f=r.ERR_RESPONSE;let s=a.headers.get("Content-Type");if(!1===e&&null===s?h=void 0===a.blob?await a.buffer():await a.blob():!1===e&&(s.startsWith("application/json")||s.startsWith("application/problem+json"))?(h=await a.json(),f=h.type,l=h.title):h=!1===e&&s.startsWith("text/")?await a.text():void 0===a.blob?await a.buffer():await a.blob(),f=r.ERR_SERVER,!a.ok)throw h}catch(g){if(s>0)return await new Promise(t=>setTimeout(t,2e3)),this._wrapWithPromise(t,e,i,n,s-1);let u;switch(u="object"==typeof g&&g.constructor===Object&&"title"in g?g.title:g,void 0===a&&(a={}),f){case r.ERR_REQUEST:f="https://api.backend.ai/probs/client-request-error",navigator.onLine?(l=u,o="sending request has failed: "+u,d=u):(l="Network disconnected.",o="sending request has failed: Network disconnected",d="Network disconnected");break;case r.ERR_RESPONSE:f="https://api.backend.ai/probs/client-response-error",l=u,o="reading response has failed: "+u,d=u;break;case r.ERR_SERVER:f="https://api.backend.ai/probs/server-error",l=`${a.status} ${a.statusText} - ${h.title}`,o="server responded failure: ",h.msg?(o+=`${a.status} ${a.statusText} - ${h.msg}`,d=h.msg):(o+=`${a.status} ${a.statusText} - ${h.title}`,d=h.title);break;case r.ERR_ABORT:f="https://api.backend.ai/probs/request-abort-error",l="Request aborted",d=o="Request aborted by user",a.status=408,a.statusText="Request aborted by user";break;case r.ERR_TIMEOUT:f="https://api.backend.ai/probs/request-timeout-error",l="Request timeout",d=o="No response returned during the timeout period",a.status=408,a.statusText="Timeout exceeded";break;default:void 0===a.status&&(a.status=500,a.statusText="Server error"),""===f&&(f=r.ERR_UNKNOWN),""===l&&(l=h.title),o=`server responded failure: ${a.status} ${a.statusText} - ${h.title}`,""!==h.title&&(d=h.title)}throw{isError:!0,timestamp:(new Date).toUTCString(),type:f,requestUrl:t.uri,requestMethod:t.method,requestParameters:t.body,statusCode:a.status,statusText:a.statusText,title:l,message:o,description:d}}let c=JSON.parse(localStorage.getItem("backendaiwebui.logs"));c&&c.length>3e3&&(c=c.slice(1,3e3));let p=Array();void 0===a&&(a={status:"No status",statusText:"No response given."});let m={isError:!1,timestamp:(new Date).toUTCString(),type:"",requestUrl:t.uri,requestMethod:t.method,requestParameters:t.body,statusCode:a.status,statusText:a.statusText,title:h.title,message:""};p.push(m),c&&(p=p.concat(c));try{localStorage.setItem("backendaiwebui.logs",JSON.stringify(p))}catch(jf){console.warn("Local storage is full. Clearing part of the logs.");let e=JSON.parse(localStorage.getItem("backendaiwebui.logs")||"[]");e=e.slice(0,Math.round(2*e.length/3)),localStorage.setItem("backendaiwebui.logs",JSON.stringify(e)),Object.entries(localStorage).map(t=>t[0]).filter(t=>t.startsWith("backendaiconsole")).map(t=>localStorage.removeItem(t))}return h}getServerVersion(t=null){let e=this.newPublicRequest("GET","/",null,"");return this._wrapWithPromise(e,!1,t)}get APIMajorVersion(){return this._apiVersionMajor}set APIMajorVersion(t){this._apiVersionMajor=t,this._config._apiVersionMajor=this._apiVersionMajor}async get_manager_version(t=null){if(null===this._managerVersion){let e=await this.getServerVersion(t);this._managerVersion=e.manager,this._apiVersion=e.version,this._config._apiVersion=this._apiVersion,this._apiVersionMajor=e.version.substr(1,2),this._config._apiVersionMajor=this._apiVersionMajor,this._apiVersionMajor>4&&(this.kernelPrefix="/session")}return this._managerVersion}supports(t){return 0===Object.keys(this._features).length&&this._updateSupportList(),t in this._features&&this._features[t]}_updateFieldCompatibilityByAPIVersion(t){const e={session_name:"sess_id"};return this._apiVersionMajor<5&&Object.keys(e).forEach(i=>{let r=t.indexOf(i);-1!==r&&(t[r]=e[i])}),t}_updateSupportList(){this.isAPIVersionCompatibleWith("v4.20190601")&&(this._features["scaling-group"]=!0,this._features.group=!0,this._features["group-folder"]=!0,this._features["system-images"]=!0,this._features["detailed-session-states"]=!0,this._features["change-user-name"]=!0),this.isAPIVersionCompatibleWith("v6.20200815")&&(this._features["multi-container"]=!0,this._features["multi-node"]=!0,this._features["storage-proxy"]=!0,this._features["hardware-metadata"]=!0)}isManagerVersionCompatibleWith(t){let e=this._managerVersion;return e=e.split(".").map(t=>t.padStart(10)).join("."),(t=t.split(".").map(t=>t.padStart(10)).join("."))<=e}isAPIVersionCompatibleWith(t){let e=this._apiVersion;return null!==e&&null!==t&&(e=e.split(".").map(t=>t.padStart(10)).join("."),t=t.split(".").map(t=>t.padStart(10)).join(".")),t<=e}async check_login(){let t,e=this.newSignedRequest("POST","/server/login-check",null);try{!0===(t=await this._wrapWithPromise(e)).authenticated&&(this._config._accessKey=t.data.access_key,this._config._session_id=t.session_id)}catch(i){return console.log(i),Promise.resolve(!1)}return t.authenticated}async login(){let t,e={username:this._config.userId,password:this._config.password},i=this.newSignedRequest("POST","/server/login",e);try{if(!0===(t=await this._wrapWithPromise(i)).authenticated)return await this.get_manager_version(),this.check_login();if(!1===t.authenticated)return t.data&&t.data.details?Promise.resolve({fail_reason:t.data.details}):Promise.resolve(!1)}catch(r){throw"statusCode"in r&&429===r.statusCode?{title:r.description,message:"Too many failed login attempts."}:{title:"No manager found at API Endpoint.",message:"Authentication failed. Check information and manager status."}}}logout(){let t=this.newSignedRequest("POST","/server/logout",{});return this._wrapWithPromise(t)}async signout(t,e){let i={username:t,password:e},r=this.newSignedRequest("POST","/auth/signout",i);return this._wrapWithPromise(r)}async update_password(t,e,i){let r={old_password:t,new_password:e,new_password2:i},n=this.newSignedRequest("POST","/auth/update-password",r);return this._wrapWithPromise(n)}async get_resource_slots(){let t;return t=this.isAPIVersionCompatibleWith("v4.20190601")?this.newPublicRequest("GET","/config/resource-slots",null,""):this.newPublicRequest("GET","/etcd/resource-slots",null,""),this._wrapWithPromise(t)}async createIfNotExists(t,e,i={},r=0){null==e&&(e=this.generateSessionId());let n,s={lang:t,clientSessionToken:e};if(i!={}){let t={};i.cpu&&(t.cpu=i.cpu),i.mem&&(t.mem=i.mem),i.gpu&&(t["cuda.device"]=parseInt(i.gpu)),i["cuda.device"]&&(t["cuda.device"]=parseInt(i["cuda.device"])),i.vgpu?t["cuda.shares"]=parseFloat(i.vgpu).toFixed(2):i.fgpu&&(t["cuda.shares"]=parseFloat(i.fgpu).toFixed(2)),i["cuda.shares"]&&(t["cuda.shares"]=parseFloat(i["cuda.shares"]).toFixed(2)),i.rocm&&(t["rocm.device"]=i.rocm),i.tpu&&(t["tpu.device"]=i.tpu),i.cluster_size&&(s.cluster_size=i.cluster_size),i.cluster_mode&&(s.cluster_mode=i.cluster_mode),i.group_name&&(s.group_name=i.group_name),i.domain&&(s.domain=i.domain),i.type&&(s.type=i.type),i.startsAt&&(s.starts_at=i.startsAt),i.enqueueOnly&&(s.enqueueOnly=i.enqueueOnly),i.maxWaitSeconds&&(s.maxWaitSeconds=i.maxWaitSeconds),i.reuseIfExists&&(s.reuseIfExists=i.reuseIfExists),i.startupCommand&&(s.startupCommand=i.startupCommand),i.bootstrapScript&&(s.bootstrapScript=i.bootstrapScript),i.bootstrap_script&&(s.bootstrap_script=i.bootstrap_script),i.owner_access_key&&(s.owner_access_key=i.owner_access_key),s.config={resources:t},i.mounts&&(s.config.mounts=i.mounts),i.scaling_group&&(s.config.scaling_group=i.scaling_group),i.shmem&&(s.config.resource_opts={},s.config.resource_opts.shmem=i.shmem),i.env&&(s.config.environ=i.env)}return n=this._apiVersionMajor<5?this.newSignedRequest("POST",this.kernelPrefix+"/create",s):this.newSignedRequest("POST",""+this.kernelPrefix,s),this._wrapWithPromise(n,!1,null,r)}async createSesisonFromTemplate(t,e,i={},r=0){}async get_info(t,e=null){let i=`${this.kernelPrefix}/${t}`;null!=e&&(i=`${i}?owner_access_key=${e}`);let r=this.newSignedRequest("GET",i,null);return this._wrapWithPromise(r)}async get_logs(t,e=null,i=0){let r=`${this.kernelPrefix}/${t}/logs`;null!=e&&(r=`${r}?owner_access_key=${e}`);let n=this.newSignedRequest("GET",r,null);return this._wrapWithPromise(n,!1,null,i)}getTaskLogs(t){const e=`${this.kernelPrefix}/_/logs?session_name=${t}`;let i=this.newSignedRequest("GET",e,null);return this._wrapWithPromise(i)}async destroy(t,e=null,i=!1){let r=`${this.kernelPrefix}/${t}`;r=null!==e?`${r}?owner_access_key=${e}${i?"&forced=true":""}`:`${r}${i?"?forced=true":""}`;let n=this.newSignedRequest("DELETE",r,null);return this._wrapWithPromise(n,!1,null,15e3,2)}async restart(t,e=null){let i=`${this.kernelPrefix}/${t}`;null!=e&&(i=`${i}?owner_access_key=${e}`);let r=this.newSignedRequest("PATCH",i,null);return this._wrapWithPromise(r)}async execute(t,e,i,r,n){let s={mode:i,code:r,runId:e,options:n},o=this.newSignedRequest("POST",`${this.kernelPrefix}/${t}`,s);return this._wrapWithPromise(o)}createKernel(t,e,i={},r=0){return this.createIfNotExists(t,e,i,r)}destroyKernel(t,e=null){return this.destroy(t,e)}refreshKernel(t,e=null){return this.restart(t,e)}runCode(t,e,i,r){return this.execute(e,i,r,t,{})}async shutdown_service(t,e){let i={service_name:e};const r=Of.stringify(i);let n=this.newSignedRequest("POST",`${this.kernelPrefix}/${t}/shutdown-service?${r}`,null);return this._wrapWithPromise(n,!0)}async upload(t,e,i){const r=new FormData;r.append("src",i,e);let n=this.newSignedRequest("POST",`${this.kernelPrefix}/${t}/upload`,r);return this._wrapWithPromise(n)}async download(t,e){let i={files:e};const r=Of.stringify(i);let n=this.newSignedRequest("GET",`${this.kernelPrefix}/${t}/download?${r}`,null);return this._wrapWithPromise(n,!0)}async download_single(t,e){let i={file:e};const r=Of.stringify(i);let n=this.newSignedRequest("GET",`${this.kernelPrefix}/${t}/download_single?${r}`,null);return this._wrapWithPromise(n,!0)}mangleUserAgentSignature(){return this.clientVersion+(this.agentSignature?"; "+this.agentSignature:"")}async query(t,e,i=null,r=0,n=0){let s={query:t,variables:e},o=this.newSignedRequest("POST","/admin/graphql",s);return this._wrapWithPromise(o,!1,i,r,n)}newSignedRequest(t,i,r){let n,s,o,a,h,u="application/json",f=new Date;if(null==r?s=n="":"function"==typeof r.getBoundary||r instanceof FormData?(n=r,s="",u="multipart/form-data"):s=n=JSON.stringify(r),h="","SESSION"===this._config.connectionMode)a=new Headers({"User-Agent":"Backend.AI Client for Javascript "+this.mangleUserAgentSignature(),"X-BackendAI-Version":this._config.apiVersion,"X-BackendAI-Date":f.toISOString()}),h=!0===i.startsWith("/server")?this._config.endpoint+i:this._config.endpoint+"/func"+i;else{o=this._config._apiVersion[1]<4?this.getAuthenticationString(t,i,f.toISOString(),s,u):this.getAuthenticationString(t,i,f.toISOString(),"",u);let e=this.getSignKey(this._config.secretKey,f),r=this.sign(e,"binary",o,"hex");a=new Headers({"User-Agent":"Backend.AI Client for Javascript "+this.mangleUserAgentSignature(),"X-BackendAI-Version":this._config.apiVersion,"X-BackendAI-Date":f.toISOString(),Authorization:`BackendAI signMethod=HMAC-SHA256, credential=${this._config.accessKey}:${r}`}),h=this._config.endpoint+i}return null!=r?("function"==typeof r.getBoundary&&a.set("Content-Type",r.getHeaders()["content-type"]),r instanceof FormData||(a.set("Content-Type",u),a.set("Content-Length",e.byteLength(s)))):a.set("Content-Type",u),{method:t,headers:a,cache:"default",body:n,uri:h}}newUnsignedRequest(t,e,i){return this.newPublicRequest(t,e,i,this._config.apiVersionMajor)}newPublicRequest(t,e,i,r){let n=new Date,s={method:t,headers:new Headers({"Content-Type":"application/json","User-Agent":"Backend.AI Client for Javascript "+this.mangleUserAgentSignature(),"X-BackendAI-Version":this._config.apiVersion,"X-BackendAI-Date":n.toISOString(),credentials:"include",mode:"cors"}),mode:"cors",cache:"default",uri:""};return"SESSION"===this._config.connectionMode&&!0===e.startsWith("/server")?s.uri=this._config.endpoint+e:"SESSION"===this._config.connectionMode&&!1===e.startsWith("/server")?s.uri=this._config.endpoint+"/func"+e:s.uri=this._config.endpoint+e,s}getAuthenticationString(t,e,i,r,n="application/json"){let s=xf.createHash(this._config.hashType).update(r).digest("hex");return t+"\n"+e+"\n"+i+"\nhost:"+this._config.endpointHost+"\ncontent-type:"+n+"\nx-backendai-version:"+this._config.apiVersion+"\n"+s}getCurrentDate(t){return("0000"+t.getUTCFullYear()).slice(-4)+("0"+(t.getUTCMonth()+1)).slice(-2)+("0"+t.getUTCDate()).slice(-2)}sign(t,i,r,n){let s=new e(t,i),o=xf.createHmac(this._config.hashType,s);return o.update(r,"utf8"),o.digest(n)}getSignKey(t,e){let i=this.sign(t,"utf8",this.getCurrentDate(e),"binary");return this.sign(i,"binary",this._config.endpointHost,"binary")}generateSessionId(t=8,e=!1){for(var i="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=0;n"aaaaeeeeiiiioooouuuuncsyoarsnpwgnmuxzh------".charAt(e.indexOf(t))).replace(/&/g,"-and-").replace(/[^\w\-]+/g,"").replace(/\-\-+/g,"-").replace(/^-+/,"").replace(/-+$/,"")}async fetchSSHKeypair(){let t=this.newSignedRequest("GET","/auth/ssh-keypair",null);return this._wrapWithPromise(t,!1)}async refreshSSHKeypair(){let t=this.newSignedRequest("PATCH","/auth/ssh-keypair",null);return this._wrapWithPromise(t,!1)}}class n{constructor(t){this.client=t,this.urlPrefix="/resource"}async list(t=null){let e=this.client.newSignedRequest("GET",this.urlPrefix+"/presets",t);return this.client._wrapWithPromise(e)}async check(t=null){let e=this.client.newSignedRequest("POST",this.urlPrefix+"/check-presets",t);return this.client._wrapWithPromise(e)}async add(t=null,e){if(!0===this.client.is_admin&&null!==t){let i="mutation($name: String!, $input: CreateResourcePresetInput!) { create_resource_preset(name: $name, props: $input) { ok msg }}",r={name:t,input:e};return this.client.query(i,r)}return Promise.resolve(!1)}async mutate(t=null,e){if(!0===this.client.is_admin&&null!==t){let i="mutation($name: String!, $input: ModifyResourcePresetInput!) { modify_resource_preset(name: $name, props: $input) { ok msg }}",r={name:t,input:e};return this.client.query(i,r)}return Promise.resolve(!1)}async delete(t=null){if(!0===this.client.is_admin&&null!==t){let e="mutation($name: String!) { delete_resource_preset(name: $name) { ok msg }}",i={name:t};return this.client.query(e,i)}return Promise.resolve(!1)}}class s{constructor(t,e=null){this.client=t,this.name=e,this.urlPrefix="/folders"}async list_allowed_types(){let t=this.client.newSignedRequest("GET",this.urlPrefix+"/_/allowed_types",null);return this.client._wrapWithPromise(t)}async create(t,e="",i="",r="general",n="rw",s=!1){let o;""!==e&&(o={name:t,host:e}),this.client.supports("group-folder")&&""!==i&&(o={name:t,host:e,group:i}),this.client.isAPIVersionCompatibleWith("v4.20191215")&&(r&&(o.usage_mode=r),n&&(o.permission=n)),this.client.supports("storage-proxy")&&(o.cloneable=s);let a=this.client.newSignedRequest("POST",""+this.urlPrefix,o);return this.client._wrapWithPromise(a)}async clone(t,e=null){let i=this.client.newSignedRequest("POST",`${this.urlPrefix}/${e}/clone`,t);return this.client._wrapWithPromise(i)}async update_folder(t,e=null){let i=this.client.newSignedRequest("POST",`${this.urlPrefix}/${e}/update-options`,t);return this.client._wrapWithPromise(i)}async list(t=null){let e=this.urlPrefix;if(t){const i={group_id:t};e+="?"+Of.stringify(i)}let i=this.client.newSignedRequest("GET",e,null);return this.client._wrapWithPromise(i)}async list_hosts(){let t=this.client.newSignedRequest("GET",this.urlPrefix+"/_/hosts",null);return this.client._wrapWithPromise(t)}async info(t=null){null==t&&(t=this.name);let e=this.client.newSignedRequest("GET",`${this.urlPrefix}/${t}`,null);return this.client._wrapWithPromise(e)}async rename(t=null){const e={new_name:t};let i=this.client.newSignedRequest("POST",`${this.urlPrefix}/${this.name}/rename`,e);return this.client._wrapWithPromise(i)}async delete(t=null){null==t&&(t=this.name);let e=this.client.newSignedRequest("DELETE",`${this.urlPrefix}/${t}`,null);return this.client._wrapWithPromise(e)}async leave_invited(t=null){null==t&&(t=this.name);let e=this.client.newSignedRequest("POST",`${this.urlPrefix}/${t}/leave`,null);return this.client._wrapWithPromise(e)}async upload(t,e,i=null){null==i&&(i=this.name);let r=new FormData;r.append("src",e,t);let n=this.client.newSignedRequest("POST",`${this.urlPrefix}/${i}/upload`,r);return this.client._wrapWithPromise(n)}async uploadFormData(t,e=null){let i=this.client.newSignedRequest("POST",`${this.urlPrefix}/${e}/upload`,t);return this.client._wrapWithPromise(i)}async create_upload_session(t,e,i=null){null==i&&(i=this.name);let r,n={path:t,size:e.size};r=this.client._apiVersionMajor<6?`${this.urlPrefix}/${i}/create_upload_session`:`${this.urlPrefix}/${i}/request-upload`;const s=this.client.newSignedRequest("POST",r,n),o=await this.client._wrapWithPromise(s),a=o.token;let h;return this.client._apiVersionMajor<6?(h=this.client._config.endpoint,"SESSION"===this.client._config.connectionMode&&(h+="/func"),h+=`${this.urlPrefix}/_/tus/upload/${a}`):h=`${o.url}?token=${a}`,Promise.resolve(h)}async mkdir(t,e=null,i=null,r=null){null==e&&(e=this.name);const n={path:t};i&&(n.parents=i),r&&(n.exist_ok=r);const s=this.client.newSignedRequest("POST",`${this.urlPrefix}/${e}/mkdir`,n);return this.client._wrapWithPromise(s)}async rename_file(t,e,i=null,r=!1){let n;null==i&&(i=this.name),n=this.client.isAPIVersionCompatibleWith("v6.20200815")?{target_path:t,new_name:e,is_dir:r}:{target_path:t,new_name:e};let s=this.client.newSignedRequest("POST",`${this.urlPrefix}/${i}/rename_file`,n);return this.client._wrapWithPromise(s)}async delete_files(t,e=!1,i=null){null==i&&(i=this.name),null==e&&(e=!1);let r={files:t,recursive:e},n=this.client.newSignedRequest("DELETE",`${this.urlPrefix}/${i}/delete_files`,r);return this.client._wrapWithPromise(n)}async download(t,e=!1,i=!1,r=!1){const n={file:t,archive:i},s=Of.stringify(n);if(this.client._apiVersionMajor<6){const t=this.client.newSignedRequest("GET",`${this.urlPrefix}/${e}/download_single?${s}`,null);return this.client._wrapWithPromise(t,!0)}{const n=await this.request_download_token(t,e),s=`${n.url}?token=${n.token}&archive=${i}&no_cache=${r}`;return fetch(s)}}async request_download_token(t,e=!1,i=!1){let r,n={file:t,archive:i};r=this.client._apiVersionMajor<6?`${this.urlPrefix}/${e}/request_download`:`${this.urlPrefix}/${e}/request-download`;const s=this.client.newSignedRequest("POST",r,n);return this.client._wrapWithPromise(s)}async download_with_token(t=""){let e={token:t},i=Of.stringify(e),r=this.client.newSignedRequest("GET",`${this.urlPrefix}/_/download_with_token?${i}`,null);return this.client._wrapWithPromise(r,!0)}get_download_url_with_token(t=""){const e={token:t};let i=Of.stringify(e);return"SESSION"===this.client._config.connectionMode?`${this.client._config.endpoint}/func${this.urlPrefix}/_/download_with_token?${i}`:`${this.client._config.endpoint}${this.urlPrefix}/_/download_with_token?${i}`}async list_files(t,e=null){null==e&&(e=this.name);let i={path:t},r=Of.stringify(i),n=this.client.newSignedRequest("GET",`${this.urlPrefix}/${e}/files?${r}`,null);return this.client._wrapWithPromise(n)}async invite(t,e,i=null){null==i&&(i=this.name);let r={perm:t,user_ids:e},n=this.client.newSignedRequest("POST",`${this.urlPrefix}/${i}/invite`,r);return this.client._wrapWithPromise(n)}async invitations(){let t=this.client.newSignedRequest("GET",this.urlPrefix+"/invitations/list",null);return this.client._wrapWithPromise(t)}async accept_invitation(t){let e={inv_id:t},i=this.client.newSignedRequest("POST",this.urlPrefix+"/invitations/accept",e);return this.client._wrapWithPromise(i)}async delete_invitation(t){let e={inv_id:t},i=this.client.newSignedRequest("DELETE",this.urlPrefix+"/invitations/delete",e);return this.client._wrapWithPromise(i)}async list_invitees(t=null){let e="/folders/_/shared";null!==t&&(e=`${e}?vfolder_id=${t}`);let i=this.client.newSignedRequest("GET",e,null);return this.client._wrapWithPromise(i)}async modify_invitee_permission(t){let e=this.client.newSignedRequest("POST","/folders/_/shared",t);return this.client._wrapWithPromise(e)}async share(t,e,i=null){i||(i=this.name);const r={permission:t,emails:e},n=this.client.newSignedRequest("POST",`${this.urlPrefix}/${i}/share`,r);return this.client._wrapWithPromise(n)}async unshare(t,e=null){e||(e=this.name);const i={emails:t},r=this.client.newSignedRequest("DELETE",`${this.urlPrefix}/${e}/unshare`,i);return this.client._wrapWithPromise(r)}}class o{constructor(t){this.client=t}async list(t="ALIVE",e=["id","status","region","first_contact","cpu_cur_pct","mem_cur_bytes","available_slots","occupied_slots"],i=0){if(!1===["ALIVE","TERMINATED"].includes(t))return Promise.resolve(!1);let r="query($status: String) { agents(status: $status) { "+e.join(" ")+" }}",n={status:t};return this.client.query(r,n,null,i)}}class a{constructor(t){this.client=t}async list(t=["id","backend","capabilities"],e=20,i=0){let r=`query($offset:Int!, $limit:Int!) { storage_volume_list(limit:$limit, offset:$offset) { items { ${t.join(" ")} } total_count }}`,n={limit:e,offset:i};return this.client.query(r,n)}async detail(t="",e=["id","backend","path","fsprefix","capabilities"]){let i="query($vfolder_host: String!) { storage_volume(id: $vfolder_host) { "+e.join(" ")+" }}",r={vfolder_host:t};return this.client.query(i,r)}}class h{constructor(t,e=null){this.client=t,this.name=e}async info(t,e=["access_key","secret_key","is_active","is_admin","user_id","created_at","last_used","concurrency_limit","concurrency_used","rate_limit","num_queries","resource_policy"]){let i,r;return this.client.is_admin?(i="query($access_key: String!) { keypair(access_key: $access_key) { "+e.join(" ")+" }}",r={access_key:t}):(i="query { keypair { "+e.join(" ")+" }}",r={}),this.client.query(i,r)}async list(t=null,e=["access_key","is_active","is_admin","user_id","created_at","last_used","concurrency_used","rate_limit","num_queries","resource_policy"],i=!0){let r,n;if(this.client._apiVersionMajor<5)return r=this.client.is_admin&&null==t?`\n query($is_active: Boolean) {\n keypairs(is_active: $is_active) {\n ${e.join(" ")}\n }\n }\n `:`\n query($email: String!, $is_active: Boolean) {\n keypairs(email: $email, is_active: $is_active) {\n ${e.join(" ")}\n }\n }\n `,n={email:t||this.client.email,is_active:i},this.client.query(r,n);{const s=100,o=[];r=this.client.is_admin&&null==t?`\n query($offset:Int!, $limit:Int!, $is_active: Boolean) {\n keypair_list(offset:$offset, limit:$limit, is_active: $is_active) {\n items { ${e.join(" ")} }\n total_count\n }\n }\n `:`\n query($offset:Int!, $limit:Int!, $email: String!, $is_active: Boolean) {\n keypair_list(offset:$offset, limit:$limit, email: $email, is_active: $is_active) {\n items { ${e.join(" ")} }\n total_count\n }\n }\n `;for(let e=0;e<10*s;e+=s){n={offset:e,limit:s,email:t||this.client.email,is_active:i};const a=await this.client.query(r,n);if(o.push(...a.keypair_list.items),e>=a.keypair_list.total_count)break}const a={keypairs:o};return Promise.resolve(a)}}async add(t=null,e=!0,i=!1,r="default",n=1e3){let s=`mutation($user_id: String!, $input: KeyPairInput!) { create_keypair(user_id: $user_id, props: $input) { ok msg keypair { ${["is_active","is_admin","resource_policy","concurrency_limit","rate_limit"].join(" ")} } }}`,o={user_id:t,input:{is_active:e,is_admin:i,resource_policy:r,rate_limit:n}};return this.client.query(s,o)}async mutate(t,e){let i={access_key:t,input:e};return this.client.query("mutation($access_key: String!, $input: ModifyKeyPairInput!) { modify_keypair(access_key: $access_key, props: $input) { ok msg }}",i)}async delete(t){let e={access_key:t};return this.client.query("mutation($access_key: String!) { delete_keypair(access_key: $access_key) { ok msg }}",e)}}class u{constructor(t){this.client=t}async get(t=null,e=["name","created_at","default_for_unspecified","total_resource_slots","max_concurrent_sessions","max_containers_per_session","max_vfolder_count","max_vfolder_size","allowed_vfolder_hosts","idle_timeout"]){let i,r;return null===t?(i=`query { keypair_resource_policies { ${e.join(" ")} }}`,r={n:t}):(i=`query($n:String!) { keypair_resource_policy(name: $n) { ${e.join(" ")} }}`,r={n:t}),this.client.query(i,r)}async add(t=null,e){let i=["name","created_at","default_for_unspecified","total_resource_slots","max_concurrent_sessions","max_containers_per_session","max_vfolder_count","max_vfolder_size","allowed_vfolder_hosts","idle_timeout"];if(!0===this.client.is_admin&&null!==t){let r=`mutation($name: String!, $input: CreateKeyPairResourcePolicyInput!) { create_keypair_resource_policy(name: $name, props: $input) { ok msg resource_policy { ${i.join(" ")} } }}`,n={name:t,input:e};return this.client.query(r,n)}return Promise.resolve(!1)}async mutate(t=null,e){if(!0===this.client.is_admin&&null!==t){let i="mutation($name: String!, $input: ModifyKeyPairResourcePolicyInput!) { modify_keypair_resource_policy(name: $name, props: $input) { ok msg }}",r={name:t,input:e};return this.client.query(i,r)}return Promise.resolve(!1)}async delete(t=null){if(!0===this.client.is_superadmin&&null!==t){let e="mutation($name: String!) { delete_keypair_resource_policy(name: $name) { ok msg }}",i={name:t};return this.client.query(e,i)}return Promise.resolve(!1)}}class f{constructor(t){this.client=t}async list(t=["name","tag","registry","digest","installed","labels { key value }","resource_limits { key min max }"],e=!1,i=!1){let r,n;return this.client.supports("system-images")?!0===e?(r=`query($installed:Boolean) { images(is_installed:$installed) { ${t.join(" ")} }}`,n={installed:e,is_operation:i}):(r=`query { images { ${t.join(" ")} }}`,n={is_operation:i}):(r=`query { images { ${t.join(" ")} }}`,n={}),this.client.query(r,n)}async modifyResource(t,e,i,r){let n=[];return t=t.replace(":","%3A"),e=e.replace("/","%2F"),Object.keys(r).forEach(s=>{Object.keys(r[s]).forEach(o=>{const a=this.client.newSignedRequest("POST","/config/set",{key:`images/${t}/${e}/${i}/resource/${s}/${o}`,value:r[s][o]});n.push(this.client._wrapWithPromise(a))})}),Promise.all(n)}async modifyLabel(t,e,i,r,n){t=t.replace(":","%3A"),e=e.replace("/","%2F"),i=i.replace("/","%2F");const s=this.client.newSignedRequest("POST","/config/set",{key:`images/${t}/${e}/${i}/labels/${r}`,value:n});return this.client._wrapWithPromise(s)}async install(t,e={},i="index.docker.io"){"index.docker.io"!=i?i+="/":i="",i=i.replace(":","%3A");let r=this.client.generateSessionId();return 0===Object.keys(e).length&&(e={cpu:"1",mem:"512m"}),this.client.createIfNotExists(i+t,r,e,6e5).then(t=>this.client.destroy(r)).catch(t=>{throw t})}async uninstall(t,e="index.docker.io"){return Promise.resolve(!1)}async get(t,e,i){t=t.replace(":","%3A");const r=this.client.newSignedRequest("POST","/config/get",{key:`images/${t}/${e}/${i}/resource/`,prefix:!0});return this.client._wrapWithPromise(r)}}class l{constructor(t){this.client=t}async total_count(t="RUNNING",e="",i=1,r=0,n=""){let s,o;return s="query($limit:Int!, $offset:Int!, $ak:String, $group_id:String, $status:String) {\n compute_session_list(limit:$limit, offset:$offset, access_key:$ak, group_id:$group_id, status:$status) {\n total_count\n }\n }",o={limit:i,offset:r,status:t},""!=e&&(o.ak=e),""!=n&&(o.group_id=n),this.client.query("query($limit:Int!, $offset:Int!, $ak:String, $group_id:String, $status:String) {\n compute_session_list(limit:$limit, offset:$offset, access_key:$ak, group_id:$group_id, status:$status) {\n total_count\n }\n }",o)}async list(t=["id","name","image","created_at","terminated_at","status","status_info","occupied_slots","containers {live_stat last_stat}"],e="RUNNING",i="",r=30,n=0,s="",o=0){let a,h;return a=`query($limit:Int!, $offset:Int!, $ak:String, $group_id:String, $status:String) {\n compute_session_list(limit:$limit, offset:$offset, access_key:$ak, group_id:$group_id, status:$status) {\n items { ${(t=this.client._updateFieldCompatibilityByAPIVersion(t)).join(" ")}}\n total_count\n }\n }`,h={limit:r,offset:n,status:e},""!=i&&(h.ak=i),""!=s&&(h.group_id=s),this.client.query(a,h,null,o)}async listAll(t=["id","name","image","created_at","terminated_at","status","status_info","occupied_slots","containers {live_stat last_stat}"],e="RUNNING,RESTARTING,TERMINATING,PENDING,PREPARING,PULLING,TERMINATED,CANCELLED,ERROR",i="",r=100,n=0,s="",o=0){let a,h;const u=[];a=`query($limit:Int!, $offset:Int!, $ak:String, $group_id:String, $status:String) {\n compute_session_list(limit:$limit, offset:$offset, access_key:$ak, group_id:$group_id, status:$status) {\n items { ${(t=this.client._updateFieldCompatibilityByAPIVersion(t)).join(" ")}}\n total_count\n }\n }`;for(let f=0;f<10*r;f+=r){h={limit:r,offset:f,status:e},""!=i&&(h.access_key=i),""!=s&&(h.group_id=s);const t=await this.client.query(a,h,null,o);if(console.log(t.compute_session_list.total_count),u.push(...t.compute_session_list.items),f>=t.compute_session_list.total_count)break}return Promise.resolve(u)}async get(t=["id","session_name","lang","created_at","terminated_at","status","status_info","occupied_slots","cpu_used","io_read_bytes","io_write_bytes"],e=""){let i,r;return i=`query($session_uuid: UUID!) {\n compute_session(id:$session_uuid) {\n ${(t=this.client._updateFieldCompatibilityByAPIVersion(t)).join(" ")}\n }\n }`,r={session_uuid:e},this.client.query(i,r)}}class d{constructor(t){this.client=t,this.urlPrefix="/template/session"}async list(t=!1,e=null){let i=this.urlPrefix;if(t){const e={all:t};i+="?"+Of.stringify(e)}if(e){const t={group_id:e};i+="?"+Of.stringify(t)}let r=this.client.newSignedRequest("GET",i,null);return this.client._wrapWithPromise(r)}}class c{constructor(t){this.client=t,this.resources={},this._init_resource_values()}_init_resource_values(){this.resources.cpu={},this.resources.cpu.total=0,this.resources.cpu.used=0,this.resources.cpu.percent=0,this.resources.mem={},this.resources.mem.total=0,this.resources.mem.allocated=0,this.resources.mem.used=0,this.resources.gpu={},this.resources.gpu.total=0,this.resources.gpu.used=0,this.resources["cuda.device"]={},this.resources["cuda.device"].total=0,this.resources["cuda.device"].used=0,this.resources.fgpu={},this.resources.fgpu.total=0,this.resources.fgpu.used=0,this.resources["cuda.shares"]={},this.resources["cuda.shares"].total=0,this.resources["cuda.shares"].used=0,this.resources["rocm.device"]={},this.resources["rocm.device"].total=0,this.resources["rocm.device"].used=0,this.resources["tpu.device"]={},this.resources["tpu.device"].total=0,this.resources["tpu.device"].used=0,this.resources.agents={},this.resources.agents.total=0,this.resources.agents.using=0,this.agents=[]}async totalResourceInformation(t="ALIVE"){if(this.client.is_admin){let e=["id","addr","status","first_contact","cpu_cur_pct","mem_cur_bytes","occupied_slots","available_slots"];return this.client.agent.list(t,e).then(t=>(this._init_resource_values(),this.agents=t.agents,Object.keys(this.agents).map((t,e)=>{let i=this.agents[t],r=JSON.parse(i.occupied_slots),n=JSON.parse(i.available_slots);"cpu"in n&&(this.resources.cpu.total=this.resources.cpu.total+Math.floor(Number(n.cpu))),"cpu"in r&&(this.resources.cpu.used=this.resources.cpu.used+Math.floor(Number(r.cpu))),this.resources.cpu.percent=this.resources.cpu.percent+parseFloat(i.cpu_cur_pct),void 0===r.mem&&(r.mem=0),this.resources.mem.total=parseFloat(this.resources.mem.total)+parseInt(this.client.utils.changeBinaryUnit(n.mem,"b")),this.resources.mem.allocated=parseInt(this.resources.mem.allocated)+parseInt(this.client.utils.changeBinaryUnit(r.mem,"b")),this.resources.mem.used=parseInt(this.resources.mem.used)+parseInt(this.client.utils.changeBinaryUnit(i.mem_cur_bytes,"b")),"cuda.device"in n&&(this.resources["cuda.device"].total=parseInt(this.resources["cuda.device"].total)+Math.floor(Number(n["cuda.device"]))),"cuda.device"in r&&(this.resources["cuda.device"].used=parseInt(this.resources["cuda.device"].used)+Math.floor(Number(r["cuda.device"]))),"cuda.shares"in n&&(this.resources["cuda.shares"].total=parseFloat(this.resources["cuda.shares"].total)+parseFloat(n["cuda.shares"])),"cuda.shares"in r&&(this.resources["cuda.shares"].used=parseFloat(this.resources["cuda.shares"].used)+parseFloat(r["cuda.shares"])),"rocm.device"in n&&(this.resources["rocm.device"].total=parseInt(this.resources["rocm.device"].total)+Math.floor(Number(n["rocm.device"]))),"rocm.device"in r&&(this.resources["rocm.device"].used=parseInt(this.resources["rocm.device"].used)+Math.floor(Number(r["rocm.device"]))),"tpu.device"in n&&(this.resources["tpu.device"].total=parseInt(this.resources["tpu.device"].total)+Math.floor(Number(n["tpu.device"]))),"tpu.device"in r&&(this.resources["tpu.device"].used=parseInt(this.resources["tpu.device"].used)+Math.floor(Number(r["tpu.device"]))),isNaN(this.resources.cpu.used)&&(this.resources.cpu.used=0),isNaN(this.resources.mem.used)&&(this.resources.mem.used=0),isNaN(this.resources.gpu.used)&&(this.resources.gpu.used=0),isNaN(this.resources.fgpu.used)&&(this.resources.fgpu.used=0)}),this.resources.gpu.total=this.resources["cuda.device"].total,this.resources.gpu.used=this.resources["cuda.device"].used,this.resources.fgpu.used=this.resources["cuda.shares"].used.toFixed(2),this.resources.fgpu.total=this.resources["cuda.shares"].total.toFixed(2),this.resources.agents.total=Object.keys(this.agents).length,this.resources.agents.using=Object.keys(this.agents).length,Promise.resolve(this.resources))).catch(t=>{throw t})}return Promise.resolve(!1)}async user_stats(){const t=this.client.newSignedRequest("GET","/resource/stats/user/month",null);return this.client._wrapWithPromise(t)}}class p{constructor(t){this.client=t}async list(t=!0,e=!1,i=["id","name","description","is_active","created_at","modified_at","domain_name"]){let r,n;return!0===this.client.is_admin?(r=`query($is_active:Boolean) { groups(is_active:$is_active) { ${i.join(" ")} }}`,n={is_active:t},!1!==e&&(r=`query($domain_name: String, $is_active:Boolean) { groups(domain_name: $domain_name, is_active:$is_active) { ${i.join(" ")} }}`,n={is_active:t,domain_name:e})):(r=`query($is_active:Boolean) { groups(is_active:$is_active) { ${i.join(" ")} }}`,n={is_active:t}),this.client.query(r,n)}}class m{constructor(t){this.client=t}async get(t=!1,e=["name","description","is_active","created_at","modified_at","total_resource_slots","allowed_vfolder_hosts","allowed_docker_registries","integration_id","scaling_groups"]){let i,r;if(!1!==t)return i=`query($name: String) { domain(name: $name) { ${e.join(" ")} }}`,r={name:t},this.client.query(i,r)}async list(t=["name","description","is_active","created_at","total_resource_slots","allowed_vfolder_hosts","allowed_docker_registries","integration_id"]){let e=`query { domains { ${t.join(" ")} }}`;return this.client.query(e,{})}async update(t=!1,e){if(!0===this.client.is_superadmin){let i="mutation($name: String!, $input: ModifyDomainInput!) { modify_domain(name: $name, props: $input) { ok msg }}",r={name:t,input:e};return this.client.query(i,r)}return Promise.resolve(!1)}}class g{constructor(t){this.client=t,this.urlPrefix="/resource"}attach_background_task(t){var e="/events/background-task?task_id="+t;let i=this.client.newSignedRequest("GET",e,null);return new EventSource(i.uri,{withCredentials:!0})}async rescan_images(t=""){if(!0===this.client.is_admin){let e,i;return""!==t?(t=decodeURIComponent(t),e="mutation($registry: String) { rescan_images(registry: $registry) { ok msg task_id }}",i={registry:t}):(e="mutation { rescan_images { ok msg task_id }}",i={}),this.client.query(e,i,null,6e5)}return Promise.resolve(!1)}async recalculate_usage(){if(!0===this.client.is_superadmin){let t=this.client.newSignedRequest("POST",this.urlPrefix+"/recalculate-usage",null);return this.client._wrapWithPromise(t,null,null,6e4)}}}class v{constructor(t){this.client=t}async list(t=!0,e=["username","password","need_password_change","full_name","description","is_active","domain_name","role","groups {id name}"]){let i,r;if(this.client._apiVersionMajor<5)return i=this.client.is_admin?`\n query($is_active:Boolean) {\n users(is_active:$is_active) { ${e.join(" ")} }\n }\n `:`\n query {\n users { ${e.join(" ")} }\n }\n `,r=this.client.is_admin?{is_active:t}:{},this.client.query(i,r);{const n=100,s=[];i=this.client.is_admin?`\n query($offset:Int!, $limit:Int!, $is_active:Boolean) {\n user_list(offset:$offset, limit:$limit, is_active:$is_active) {\n items { ${e.join(" ")} }\n total_count\n }\n }\n `:`\n query($offset:Int!, $limit:Int!) {\n user_list(offset:$offset, limit:$limit) {\n items { ${e.join(" ")} }\n total_count\n }\n }\n `;for(let e=0;e<10*n;e+=n){r=this.client.is_admin?{offset:e,limit:n,is_active:t}:{offset:e,limit:n};const o=await this.client.query(i,r);if(s.push(...o.user_list.items),e>=o.user_list.total_count)break}const o={users:s};return Promise.resolve(o)}}async get(t,e=["email","username","password","need_password_change","full_name","description","is_active","domain_name","role","groups {id name}"]){let i,r;return!0===this.client.is_admin?(i=`query($email:String) { user (email:$email) { ${e.join(" ")} }}`,r={email:t}):(i=`query { user { ${e.join(" ")} }}`,r={}),this.client.query(i,r)}async create(t=null,e){let i=["username","password","need_password_change","full_name","description","is_active","domain_name","role","groups{id, name}"];if(!0===this.client.is_admin){let r=`mutation($email: String!, $input: UserInput!) { create_user(email: $email, props: $input) { ok msg user { ${i.join(" ")} } }}`,n={email:t,input:e};return this.client.query(r,n)}return Promise.resolve(!1)}async update(t=null,e){if(!0===this.client.is_superadmin){let i="mutation($email: String!, $input: ModifyUserInput!) { modify_user(email: $email, props: $input) { ok msg }}",r={email:t,input:e};return this.client.query(i,r)}return Promise.resolve(!1)}async delete(t){if(!0===this.client.is_superadmin){let e="mutation($email: String!) { delete_user(email: $email) { ok msg }}",i={email:t};return this.client.query(e,i)}return Promise.resolve(!1)}}class b{constructor(t){this.client=t}async list_available(){if(!0===this.client.is_superadmin){const t=`query { scaling_groups { ${["name","description","is_active","created_at","driver","driver_opts","scheduler","scheduler_opts"].join(" ")} }}`,e={};return this.client.query(t,e)}return Promise.resolve(!1)}async list(t="default"){const e="/scaling-groups?group="+t,i=this.client.newSignedRequest("GET",e,null);return this.client._wrapWithPromise(i)}async create(t,e=""){let i={name:t,input:{description:e,is_active:!0,driver:"static",scheduler:"fifo",driver_opts:"{}",scheduler_opts:"{}"}};return this.client.query("mutation($name: String!, $input: ScalingGroupInput!) { create_scaling_group(name: $name, props: $input) { ok msg }}",i)}async associate_domain(t,e){let i={domain:t,scaling_group:e};return this.client.query("mutation($domain: String!, $scaling_group: String!) { associate_scaling_group_with_domain(domain: $domain, scaling_group: $scaling_group) { ok msg }}",i)}async update(t,e){let i={name:t,input:e};return this.client.query("mutation($name: String!, $input: ModifyScalingGroupInput!) { modify_scaling_group(name: $name, props: $input) { ok msg }}",i)}async delete(t){let e={name:t};return this.client.query("mutation($name: String!) { delete_scaling_group(name: $name) { ok msg }}",e)}}class y{constructor(t){this.client=t}async list(){const t=this.client.newSignedRequest("POST","/config/get",{key:"config/docker/registry",prefix:!0});return this.client._wrapWithPromise(t)}async add(t,e){let i="config/docker/registry/"+(t=encodeURIComponent(t));const r=this.client.newSignedRequest("POST","/config/set",{key:i,value:e});return this.client._wrapWithPromise(r)}async delete(t){t=encodeURIComponent(t);const e=this.client.newSignedRequest("POST","/config/delete",{key:"config/docker/registry/"+t,prefix:!0});return this.client._wrapWithPromise(e)}}class w{constructor(t){this.client=t,this.config=null}async list(t=""){t="config/"+t;const e=this.client.newSignedRequest("POST","/config/get",{key:t,prefix:!0});return this.client._wrapWithPromise(e)}async get(t){t="config/"+t;const e=this.client.newSignedRequest("POST","/config/get",{key:t,prefix:!1});return this.client._wrapWithPromise(e)}async set(t,e){t="config/"+t;const i=this.client.newSignedRequest("POST","/config/set",{key:t,value:e});return this.client._wrapWithPromise(i)}async delete(t,e=!1){t="config/"+t;const i=this.client.newSignedRequest("POST","/config/delete",{key:""+t,prefix:e});return this.client._wrapWithPromise(i)}}class M{constructor(t){this.client=t,this.config=null}async get_announcement(){const t=this.client.newSignedRequest("GET","/manager/announcement",null);return this.client._wrapWithPromise(t)}async update_announcement(t=!0,e){const i=this.client.newSignedRequest("POST","/manager/announcement",{enabled:t,message:e});return this.client._wrapWithPromise(i)}}class _{constructor(t){this.client=t,this.config=null}async get_bootstrap_script(){if(!this.client._config.accessKey)throw"Your access key is not set";const t=this.client.newSignedRequest("GET","/user-config/bootstrap-script");return this.client._wrapWithPromise(t)}async update_bootstrap_script(t){const e=this.client.newSignedRequest("POST","/user-config/bootstrap-script",{script:t});return this.client._wrapWithPromise(e)}async create(t="",e){if(!this.client._config.accessKey)throw"Your access key is not set";let i={path:e,data:t,permission:"644"};const r=this.client.newSignedRequest("POST","/user-config/dotfiles",i);return this.client._wrapWithPromise(r)}async get(){if(!this.client._config.accessKey)throw"Your access key is not set";const t=this.client.newSignedRequest("GET","/user-config/dotfiles");return this.client._wrapWithPromise(t)}async update(t,e){let i={data:t,path:e,permission:"644"};const r=this.client.newSignedRequest("PATCH","/user-config/dotfiles",i);return this.client._wrapWithPromise(r)}async delete(t){let e={path:t};const i=this.client.newSignedRequest("DELETE","/user-config/dotfiles",e);return this.client._wrapWithPromise(i)}}class S{constructor(t){this.client=t,this.config=null}async getLicense(){if(!0!==this.client.is_superadmin)return Promise.resolve(!1);if(void 0===this.certificate){const t=this.client.newSignedRequest("GET","/license");let e=await this.client._wrapWithPromise(t);return this.certificate=e.certificate,"valid"===e.status?this.certificate.valid=!0:this.certificate.valid=!1,Promise.resolve(this.certificate)}}}class E{constructor(t){this.client=t,this.config=null}async ping(){const t=this.client.newSignedRequest("GET","/cloud/ping");return this.client._wrapWithPromise(t)}async verify_email(t){const e={verification_code:t},i=this.client.newSignedRequest("POST","/cloud/verify-email",e);return this.client._wrapWithPromise(i)}async send_verification_email(t){const e={email:t},i=this.client.newSignedRequest("POST","/cloud/send-verification-email",e);return this.client._wrapWithPromise(i)}async send_password_change_email(t){const e={email:t},i=this.client.newSignedRequest("POST","/cloud/send-password-change-email",e);return this.client._wrapWithPromise(i)}async change_password(t,e,i){const r={email:t,password:e,token:i},n=this.client.newSignedRequest("POST","/cloud/change-password",r);return this.client._wrapWithPromise(n)}}class k{constructor(t){this.client=t}changeBinaryUnit(t,e="g",i="b"){if(void 0===t)return t;let r;const n=["b","k","m","g","t","p","auto"],s=["B","KiB","MiB","GiB","TiB","PiB"];if(!n.includes(e))return!1;if((t=t.toString()).indexOf(" ")>=0){let e=t.split(/(\s+)/);t=s.includes(e[2])?e[0]+n[s.indexOf(e[2])]:e[0]}return n.includes(t.substr(-1))?(r=t.substr(-1),t=t.slice(0,-1)):r=i,t*Math.pow(1024,Math.floor(n.indexOf(r)-n.indexOf(e)))}elapsedTime(t,e){var i=new Date(t);if(null===e)var r=new Date;else r=new Date(e);var n=Math.floor((r.getTime()-i.getTime())/1e3),s=Math.floor(n/86400);n-=86400*s;var o=Math.floor(n/3600);n-=3600*o;var a=Math.floor(n/60),h=n-=60*a,u="";return void 0!==s&&s>0&&(u=u+String(s)+" Day "),void 0!==o&&(u=u+this._padding_zeros(o,2)+":"),void 0!==a&&(u=u+this._padding_zeros(a,2)+":"),u+this._padding_zeros(h,2)+""}_padding_zeros(t,e){return(t+="").length>=e?t:new Array(e-t.length+1).join("0")+t}gqlToObject(t,e){let i={};return t.forEach((function(t){i[t[e]]=t})),i}gqlToList(t,e){let i=[];return t.forEach((function(t){i.push(t[e])})),i}}Object.defineProperty(r,"ERR_SERVER",{value:0,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(r,"ERR_RESPONSE",{value:1,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(r,"ERR_REQUEST",{value:2,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(r,"ERR_ABORT",{value:3,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(r,"ERR_TIMEOUT",{value:4,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(r,"ERR_UNKNOWN",{value:99,writable:!1,enumerable:!0,configurable:!1});const R={Client:r,ClientConfig:i};Lf.backend=R,Lf.Client=r,Lf.ClientConfig=i,Lf.BackendAIClient=r,Lf.BackendAIClientConfig=i}).call(this)}.call(this,D,M({}).Buffer),Lf})); \ No newline at end of file diff --git a/src/lib/backend.ai-client-node.js b/src/lib/backend.ai-client-node.js index 6cc734604b..7a8a719b2c 100644 --- a/src/lib/backend.ai-client-node.js +++ b/src/lib/backend.ai-client-node.js @@ -132,6 +132,7 @@ class Client { this.image = new ContainerImage(this); this.utils = new utils(this); this.computeSession = new ComputeSession(this); + this.sessionTemplate = new SessionTemplate(this); this.resourcePolicy = new ResourcePolicy(this); this.user = new User(this); this.group = new Group(this); @@ -708,6 +709,13 @@ class Client { //return this._wrapWithPromise(rqst); return this._wrapWithPromise(rqst, false, null, timeout); } + /** + * Create a session with a session template. + * + * @param {string} sessionId - the sessionId given when created + */ + async createSesisonFromTemplate(kernelType, sessionId, resources = {}, timeout = 0) { + } /** * Obtain the session information by given sessionId. * @@ -2299,6 +2307,43 @@ class ComputeSession { return this.client.query(q, v); } } +class SessionTemplate { + /** + * The Computate session template API wrapper. + * + * @param {Client} client - the Client API wrapper object to bind + */ + constructor(client) { + this.client = client; + this.urlPrefix = '/template/session'; + } + /** + * list session templates with specific conditions. + * + * @param {array} fields - fields to query. Default fields are: ["id", "name", "image", "created_at", "terminated_at", "status", "status_info", "occupied_slots", "cpu_used", "io_read_bytes", "io_write_bytes"]. + * @param {string or array} status - status to query. Default is 'RUNNING'. Available statuses are: `PREPARING`, `BUILDING`, `RUNNING`, `RESTARTING`, `RESIZING`, `SUSPENDED`, `TERMINATING`, `TERMINATED`, `ERROR`. + * @param {string} accessKey - access key that is used to start compute sessions. + * @param {number} limit - limit number of query items. + * @param {number} offset - offset for item query. Useful for pagination. + * @param {string} group - project group id to query. Default returns sessions from all groups. + * @param {number} timeout - timeout for the request. Default uses SDK default. (5 sec.) + */ + async list(listall = false, groupId = null) { + let reqUrl = this.urlPrefix; + if (listall) { + const params = { all: listall }; + const q = querystring.stringify(params); + reqUrl += `?${q}`; + } + if (groupId) { + const params = { group_id: groupId }; + const q = querystring.stringify(params); + reqUrl += `?${q}`; + } + let rqst = this.client.newSignedRequest('GET', reqUrl, null); + return this.client._wrapWithPromise(rqst); + } +} class Resources { constructor(client) { this.client = client; diff --git a/src/lib/backend.ai-client-node.ts b/src/lib/backend.ai-client-node.ts index 9f94deacb5..5d8ab6a4e4 100644 --- a/src/lib/backend.ai-client-node.ts +++ b/src/lib/backend.ai-client-node.ts @@ -155,6 +155,7 @@ class Client { public image: ContainerImage; public utils: utils; public computeSession: ComputeSession; + public sessionTemplate: SessionTemplate; public resourcePolicy: ResourcePolicy; public user: User; public group: Group; @@ -211,6 +212,7 @@ class Client { this.image = new ContainerImage(this); this.utils = new utils(this); this.computeSession = new ComputeSession(this); + this.sessionTemplate = new SessionTemplate(this); this.resourcePolicy = new ResourcePolicy(this); this.user = new User(this); this.group = new Group(this); @@ -793,6 +795,14 @@ class Client { return this._wrapWithPromise(rqst, false, null, timeout); } + /** + * Create a session with a session template. + * + * @param {string} sessionId - the sessionId given when created + */ + async createSesisonFromTemplate(kernelType, sessionId, resources = {}, timeout: number = 0) { + } + /** * Obtain the session information by given sessionId. * @@ -2484,6 +2494,48 @@ class ComputeSession { } } +class SessionTemplate { + public client: any; + public urlPrefix: string; + + /** + * The Computate session template API wrapper. + * + * @param {Client} client - the Client API wrapper object to bind + */ + constructor(client) { + this.client = client; + this.urlPrefix = '/template/session'; + } + + /** + * list session templates with specific conditions. + * + * @param {array} fields - fields to query. Default fields are: ["id", "name", "image", "created_at", "terminated_at", "status", "status_info", "occupied_slots", "cpu_used", "io_read_bytes", "io_write_bytes"]. + * @param {string or array} status - status to query. Default is 'RUNNING'. Available statuses are: `PREPARING`, `BUILDING`, `RUNNING`, `RESTARTING`, `RESIZING`, `SUSPENDED`, `TERMINATING`, `TERMINATED`, `ERROR`. + * @param {string} accessKey - access key that is used to start compute sessions. + * @param {number} limit - limit number of query items. + * @param {number} offset - offset for item query. Useful for pagination. + * @param {string} group - project group id to query. Default returns sessions from all groups. + * @param {number} timeout - timeout for the request. Default uses SDK default. (5 sec.) + */ + async list(listall=false, groupId=null) { + let reqUrl = this.urlPrefix; + if (listall) { + const params = {all: listall}; + const q = querystring.stringify(params); + reqUrl += `?${q}`; + } + if (groupId) { + const params = {group_id: groupId}; + const q = querystring.stringify(params); + reqUrl += `?${q}`; + } + let rqst = this.client.newSignedRequest('GET', reqUrl, null); + return this.client._wrapWithPromise(rqst); + } +} + class Resources { public client: any; public resources: any; From 81a7fc4c01b4b96d94df50df2f497e0352cdb6f4 Mon Sep 17 00:00:00 2001 From: Jonghyun Park Date: Tue, 27 Apr 2021 00:13:29 +0900 Subject: [PATCH 3/5] feat: accept app name to launch as a query param More concrete launch of the app in resuing case. --- src/components/backend-ai-edu-applauncher.ts | 71 ++++++++++++-------- 1 file changed, 43 insertions(+), 28 deletions(-) diff --git a/src/components/backend-ai-edu-applauncher.ts b/src/components/backend-ai-edu-applauncher.ts index 4bd9ce07d1..56d11638df 100644 --- a/src/components/backend-ai-edu-applauncher.ts +++ b/src/components/backend-ai-edu-applauncher.ts @@ -42,10 +42,6 @@ import './lablup-loading-spinner'; export default class BackendAiEduApplauncher extends BackendAIPage { @property({type: Object}) notification = Object(); - constructor() { - super(); - } - static get styles(): CSSResultOrNative | CSSResultArray { return [ BackendAiStyles, @@ -67,6 +63,7 @@ export default class BackendAiEduApplauncher extends BackendAIPage { } firstUpdated() { + this.notification = globalThis.lablupNotification; if (typeof globalThis.backendaiclient === 'undefined' || globalThis.backendaiclient === null) { document.addEventListener('backend-ai-connected', () => { this._createEduSession(); @@ -97,32 +94,58 @@ export default class BackendAiEduApplauncher extends BackendAIPage { } async _createEduSession() { - // Check if there is existing compute session + // Query current user's compute session in the current group. const fields = [ - 'session_id', 'name', 'status', 'status_info', 'service_ports', 'mounts', + 'session_id', 'name', 'access_key', 'status', 'status_info', 'service_ports', 'mounts', ]; const statuses = ['RUNNING', 'RESTARTING', 'TERMINATING', 'PENDING', 'PREPARING', 'PULLING'].join(','); - const accessKey = ''; - // const groupId = globalThis.backendaiclient.current_group_id(); + const accessKey = globalThis.backendaiclient._config.accessKey; + // NOTE: There is no way to change the default group. + // This API should be used when there is only one group, 'default'. + const groupId = globalThis.backendaiclient.current_group_id(); const sessions = await globalThis.backendaiclient.computeSession.list( - fields, statuses, accessKey, 10 * 1000 + fields, statuses, accessKey, 30, 0 , groupId ); + // URL Parameter parsing. + const queryString = window.location.search; + const urlParams = new URLSearchParams(queryString); + const requestedApp = urlParams.get('app') || 'jupyter'; + + // Create or select an existing compute session before lauching app. let sessionId; - let servicePorts; if (sessions.compute_session_list.total_count > 0) { - console.log('reusing an existing session...'); - // TODO: different response depending on existing session's status - // how to deal with if there are multiple sessions? + console.log('Reusing an existing session ...'); const sessionStatus = sessions.compute_session_list.items[0].status; if (sessionStatus !== 'RUNNING') { - this.notification.text = `Your session is in status ${sessionStatus}. Please retry after some time by reloading`; + this.notification.text = `Your session is ${sessionStatus}. Please reload after some time.`; + this.notification.show(true); + return; + } + let sess = null; + for (let i = 0; i < sessions.compute_session_list.items.length; i++) { + const _sess = sessions.compute_session_list.items[i]; + const servicePorts = JSON.parse(_sess.service_ports || '{}'); + const services = servicePorts.map((s) => s.name); + if (services.includes(requestedApp)) { + sess = _sess; + break; + } + } + if (!sess) { + this.notification.text = `No existing session can launch ${requestedApp}`; this.notification.show(true); + return; } - sessionId = sessions.compute_session_list.items[0].session_id; - servicePorts = JSON.parse(sessions.compute_session_list.items[0].service_ports || '{}'); + sessionId = sess.session_id; } else { // no existing compute session. create one. - console.log('creating a new session...'); + console.log('Creating a new session ...'); + let sessionTemplates = await globalThis.backendaiclient.sessionTemplate.list(false, groupId); + // Assume that session templates' name match requsetedApp name. + sessionTemplates = sessionTemplates.filter((t) => t.name === requestedApp); + const templateId = sessionTemplates[0].id; + return; + // TODO: hard-coded parameters -> replace session-template API call const imageName = 'cr.backend.ai/testing/ngc-tensorflow:20.11-tf2-py3'; const sessionName = this.generateSessionId(); @@ -130,7 +153,7 @@ export default class BackendAiEduApplauncher extends BackendAIPage { domain: 'default', group_name: 'default', scaling_group: 'default', - maxWaitSeconds: 30, + maxWaitSeconds: 0, // wait indefinitely cpu: 1, mem: '2g', // mounts: [], @@ -140,7 +163,6 @@ export default class BackendAiEduApplauncher extends BackendAIPage { imageName, sessionName, config, 30000 ); sessionId = response.sessionId; - servicePorts = response.servicePorts; } catch (err) { console.error(err); if (err && err.message) { @@ -163,15 +185,8 @@ export default class BackendAiEduApplauncher extends BackendAIPage { } // Launch app. - const availableServiceNames = servicePorts.map((s) => s.name); - if (availableServiceNames.includes('rstudio')) { - this._openServiceApp(sessionId, 'rstudio'); - } else if (availableServiceNames.includes('jupyter')) { - this._openServiceApp(sessionId, 'jupyter'); - } else { - // TODO: how to deal with else? - console.log('how to deal?'); - } + // TODO: launch 'jupyterlab' if the browser is not IE. + this._openServiceApp(sessionId, requestedApp); } async _openServiceApp(sessionId, appName) { From 3d4a70a994c41e02364bbdc5e4d6a69f10444b13 Mon Sep 17 00:00:00 2001 From: Jonghyun Park Date: Tue, 27 Apr 2021 11:23:31 +0900 Subject: [PATCH 4/5] feat: create a new session with session template --- src/components/backend-ai-edu-applauncher.ts | 38 ++++--- src/lib/backend.ai-client-es6.js | 2 +- src/lib/backend.ai-client-node.js | 102 +++++++++++++++++- src/lib/backend.ai-client-node.ts | 104 ++++++++++++++++++- 4 files changed, 219 insertions(+), 27 deletions(-) diff --git a/src/components/backend-ai-edu-applauncher.ts b/src/components/backend-ai-edu-applauncher.ts index 56d11638df..f65d96ef40 100644 --- a/src/components/backend-ai-edu-applauncher.ts +++ b/src/components/backend-ai-edu-applauncher.ts @@ -26,7 +26,11 @@ import './lablup-activity-panel'; import './lablup-loading-spinner'; /** - Backend.AI Education App Launcher + Backend.AI Education App Launcher. + + Available url parameters: + - app: str = 'jupyter' (app name to launch) + - scaling_group: str = 'default' (scaling group to create a new session) Example: @@ -111,6 +115,7 @@ export default class BackendAiEduApplauncher extends BackendAIPage { const queryString = window.location.search; const urlParams = new URLSearchParams(queryString); const requestedApp = urlParams.get('app') || 'jupyter'; + const scalingGroup = urlParams.get('scaling_group') || 'default'; // Create or select an existing compute session before lauching app. let sessionId; @@ -143,31 +148,24 @@ export default class BackendAiEduApplauncher extends BackendAIPage { let sessionTemplates = await globalThis.backendaiclient.sessionTemplate.list(false, groupId); // Assume that session templates' name match requsetedApp name. sessionTemplates = sessionTemplates.filter((t) => t.name === requestedApp); - const templateId = sessionTemplates[0].id; - return; - - // TODO: hard-coded parameters -> replace session-template API call - const imageName = 'cr.backend.ai/testing/ngc-tensorflow:20.11-tf2-py3'; - const sessionName = this.generateSessionId(); - const config = { - domain: 'default', - group_name: 'default', - scaling_group: 'default', - maxWaitSeconds: 0, // wait indefinitely - cpu: 1, - mem: '2g', - // mounts: [], - }; + if (sessionTemplates.length < 1) { + this.notification.text = 'No appropriate session templates'; + this.notification.show(true); + return; + } + const templateId = sessionTemplates[0].id; // NOTE: use the first template. will it be okay? try { - const response = await globalThis.backendaiclient.createIfNotExists( - imageName, sessionName, config, 30000 - ); + const resources = { + scaling_group: scalingGroup, + mounts: [], + } + const response = await globalThis.backendaiclient.createSessionFromTemplate(templateId, null, null, resources) sessionId = response.sessionId; } catch (err) { console.error(err); if (err && err.message) { if ('statusCode' in err && err.statusCode === 408) { - this.notification.text = _text('session.launcher.sessionStillPreparing'); + this.notification.text = 'Session is still in preparing. Reload after a while.'; } else { if (err.description) { this.notification.text = PainKiller.relieve(err.description); diff --git a/src/lib/backend.ai-client-es6.js b/src/lib/backend.ai-client-es6.js index c464c72bfb..bd29f3b2b8 100644 --- a/src/lib/backend.ai-client-es6.js +++ b/src/lib/backend.ai-client-es6.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).ai=t()}}((function(){for(var t=function(t){var e;return function(i){return e||t(e={exports:{},parent:i},e.exports),e.exports}},e=t((function(t,e){(function(e,n){(function(){"use strict";var o;t.exports=A,A.ReadableState=R,et.EventEmitter;var a,h=function(t,e){return t.listeners(e).length},u=M({}).Buffer,f=n.Uint8Array||function(){},l=w({});a=l&&l.debuglog?l.debuglog("stream"):function(){};var d,c,p,m=Us.getHighWaterMark,g=Ls.codes,b=g.ERR_INVALID_ARG_TYPE,y=g.ERR_STREAM_PUSH_AFTER_EOF,_=g.ERR_METHOD_NOT_IMPLEMENTED,S=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;Q(A,Rs);var E=Os.errorOrDestroy,k=["error","close","destroy","pause","resume"];function R(t,e,i){o=o||s({}),t=t||{},"boolean"!=typeof i&&(i=e instanceof o),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=m(this,t,"readableHighWaterMark",i),this.buffer=new qs,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(d||(d=v({}).StringDecoder),this.decoder=new d(t.encoding),this.encoding=t.encoding)}function A(t){if(o=o||s({}),!(this instanceof A))return new A(t);var e=this instanceof o;this._readableState=new R(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),Rs.call(this)}function x(t,e,i,r,n){a("readableAddChunk",e);var s,o=t._readableState;if(null===e)o.reading=!1,function(t,e){if(a("onEofChunk"),!e.ended){if(e.decoder){var i=e.decoder.end();i&&i.length&&(e.buffer.push(i),e.length+=e.objectMode?1:i.length)}e.ended=!0,e.sync?B(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,I(t)))}}(t,o);else if(n||(s=function(t,e){var i,r;return r=e,u.isBuffer(r)||r instanceof f||"string"==typeof e||void 0===e||t.objectMode||(i=new b("chunk",["string","Buffer","Uint8Array"],e)),i}(o,e)),s)E(t,s);else if(o.objectMode||e&&e.length>0)if("string"==typeof e||o.objectMode||Object.getPrototypeOf(e)===u.prototype||(e=function(t){return u.from(t)}(e)),r)o.endEmitted?E(t,new S):T(t,o,e,!0);else if(o.ended)E(t,new y);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!i?(e=o.decoder.write(e),o.objectMode||0!==e.length?T(t,o,e,!1):q(t,o)):T(t,o,e,!1)}else r||(o.reading=!1,q(t,o));return!o.ended&&(o.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=1073741824?t=1073741824:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function B(t){var i=t._readableState;a("emitReadable",i.needReadable,i.emittedReadable),i.needReadable=!1,i.emittedReadable||(a("emitReadable",i.flowing),i.emittedReadable=!0,e.nextTick(I,t))}function I(t){var e=t._readableState;a("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,N(t)}function q(t,i){i.readingMore||(i.readingMore=!0,e.nextTick(O,t,i))}function O(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function j(t){a("readable nexttick read 0"),t.read(0)}function C(t,e){a("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),N(t),e.flowing&&!e.reading&&t.read(0)}function N(t){var e=t._readableState;for(a("flow",e.flowing);e.flowing&&null!==t.read(););}function D(t,e){return 0===e.length?null:(e.objectMode?i=e.buffer.shift():!t||t>=e.length?(i=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):i=e.buffer.consume(t,e.decoder),i);var i}function U(t){var i=t._readableState;a("endReadable",i.endEmitted),i.endEmitted||(i.ended=!0,e.nextTick($,i,t))}function $(t,e){if(a("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var i=e._writableState;(!i||i.autoDestroy&&i.finished)&&e.destroy()}}function z(t,e){for(var i=0,r=t.length;i=e.highWaterMark:e.length>0)||e.ended))return a("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?U(this):B(this),null;if(0===(t=P(t,e))&&e.ended)return 0===e.length&&U(this),null;var r,n=e.needReadable;return a("need readable",n),(0===e.length||e.length-t0?D(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),i!==t&&e.ended&&U(this)),null!==r&&this.emit("data",r),r},A.prototype._read=function(t){E(this,new _("_read()"))},A.prototype.pipe=function(t,i){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=t;break;case 1:n.pipes=[n.pipes,t];break;default:n.pipes.push(t)}n.pipesCount+=1,a("pipe count=%d opts=%j",n.pipesCount,i);var s=i&&!1===i.end||t===e.stdout||t===e.stderr?m:o;function o(){a("onend"),t.end()}n.endEmitted?e.nextTick(s):r.once("end",s),t.on("unpipe",(function e(i,s){a("onunpipe"),i===r&&s&&!1===s.hasUnpiped&&(s.hasUnpiped=!0,a("cleanup"),t.removeListener("close",c),t.removeListener("finish",p),t.removeListener("drain",u),t.removeListener("error",d),t.removeListener("unpipe",e),r.removeListener("end",o),r.removeListener("end",m),r.removeListener("data",l),f=!0,!n.awaitDrain||t._writableState&&!t._writableState.needDrain||u())}));var u=function(t){return function(){var e=t._readableState;a("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&h(t,"data")&&(e.flowing=!0,N(t))}}(r);t.on("drain",u);var f=!1;function l(e){a("ondata");var i=t.write(e);a("dest.write",i),!1===i&&((1===n.pipesCount&&n.pipes===t||n.pipesCount>1&&-1!==z(n.pipes,t))&&!f&&(a("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function d(e){a("onerror",e),m(),t.removeListener("error",d),0===h(t,"error")&&E(t,e)}function c(){t.removeListener("finish",p),m()}function p(){a("onfinish"),t.removeListener("close",c),m()}function m(){a("unpipe"),r.unpipe(t)}return r.on("data",l),function(t,e,i){if("function"==typeof t.prependListener)return t.prependListener("error",i);t._events&&t._events.error?Array.isArray(t._events.error)?t._events.error.unshift(i):t._events.error=[i,t._events.error]:t.on("error",i)}(t,0,d),t.once("close",c),t.once("finish",p),t.emit("pipe",r),n.flowing||(a("pipe resume"),r.resume()),t},A.prototype.unpipe=function(t){var e=this._readableState,i={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,i)),this;if(!t){var r=e.pipes,n=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var s=0;s0,!1!==n.flowing&&this.resume()):"readable"===t&&(n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,a("on readable",n.length,n.reading),n.length?B(this):n.reading||e.nextTick(j,this))),r},A.prototype.addListener=A.prototype.on,A.prototype.removeListener=function(t,i){var r=Rs.prototype.removeListener.call(this,t,i);return"readable"===t&&e.nextTick(L,this),r},A.prototype.removeAllListeners=function(t){var i=Rs.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||e.nextTick(L,this),i},A.prototype.resume=function(){var t=this._readableState;return t.flowing||(a("resume"),t.flowing=!t.readableListening,function(t,i){i.resumeScheduled||(i.resumeScheduled=!0,e.nextTick(C,t,i))}(this,t)),t.paused=!1,this},A.prototype.pause=function(){return a("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(a("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},A.prototype.wrap=function(t){var e=this,i=this._readableState,r=!1;for(var n in t.on("end",(function(){if(a("wrapped end"),i.decoder&&!i.ended){var t=i.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(n){a("wrapped data"),i.decoder&&(n=i.decoder.write(n)),i.objectMode&&null==n||(i.objectMode||n&&n.length)&&(e.push(n)||(r=!0,t.pause()))})),t)void 0===this[n]&&"function"==typeof t[n]&&(this[n]=function(e){return function(){return t[e].apply(t,arguments)}}(n));for(var s=0;s-1))throw new y(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(E.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(E.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),E.prototype._write=function(t,e,i){i(new c("_write()"))},E.prototype._writev=null,E.prototype.end=function(t,i,r){var n=this._writableState;return"function"==typeof t?(r=t,t=null,i=null):"function"==typeof i&&(r=i,i=null),null!=t&&this.write(t,i),n.corked&&(n.corked=1,this.uncork()),n.ending||function(t,i,r){i.ending=!0,P(t,i),r&&(i.finished?e.nextTick(r):t.once("finish",r)),i.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(E.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(E.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),E.prototype.destroy=Os.destroy,E.prototype._undestroy=Os.undestroy,E.prototype._destroy=function(t,e){e(t)}}).call(this)}).call(this,D,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})})),a=t((function(t,e){(function(e,i){(function(){"use strict";var r;t.exports=A,A.ReadableState=R,et.EventEmitter;var n,s=function(t,e){return t.listeners(e).length},o=M({}).Buffer,a=i.Uint8Array||function(){},f=w({});n=f&&f.debuglog?f.debuglog("stream"):function(){};var d,c,p,m=Ni.getHighWaterMark,g=qi.codes,b=g.ERR_INVALID_ARG_TYPE,y=g.ERR_STREAM_PUSH_AFTER_EOF,_=g.ERR_METHOD_NOT_IMPLEMENTED,S=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;Q(A,Ei);var E=Ii.errorOrDestroy,k=["error","close","destroy","pause","resume"];function R(t,e,i){r=r||l({}),t=t||{},"boolean"!=typeof i&&(i=e instanceof r),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=m(this,t,"readableHighWaterMark",i),this.buffer=new Bi,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(d||(d=v({}).StringDecoder),this.decoder=new d(t.encoding),this.encoding=t.encoding)}function A(t){if(r=r||l({}),!(this instanceof A))return new A(t);var e=this instanceof r;this._readableState=new R(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),Ei.call(this)}function x(t,e,i,r,s){n("readableAddChunk",e);var h,u=t._readableState;if(null===e)u.reading=!1,function(t,e){if(n("onEofChunk"),!e.ended){if(e.decoder){var i=e.decoder.end();i&&i.length&&(e.buffer.push(i),e.length+=e.objectMode?1:i.length)}e.ended=!0,e.sync?B(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,I(t)))}}(t,u);else if(s||(h=function(t,e){var i,r;return r=e,o.isBuffer(r)||r instanceof a||"string"==typeof e||void 0===e||t.objectMode||(i=new b("chunk",["string","Buffer","Uint8Array"],e)),i}(u,e)),h)E(t,h);else if(u.objectMode||e&&e.length>0)if("string"==typeof e||u.objectMode||Object.getPrototypeOf(e)===o.prototype||(e=function(t){return o.from(t)}(e)),r)u.endEmitted?E(t,new S):T(t,u,e,!0);else if(u.ended)E(t,new y);else{if(u.destroyed)return!1;u.reading=!1,u.decoder&&!i?(e=u.decoder.write(e),u.objectMode||0!==e.length?T(t,u,e,!1):q(t,u)):T(t,u,e,!1)}else r||(u.reading=!1,q(t,u));return!u.ended&&(u.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=1073741824?t=1073741824:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function B(t){var i=t._readableState;n("emitReadable",i.needReadable,i.emittedReadable),i.needReadable=!1,i.emittedReadable||(n("emitReadable",i.flowing),i.emittedReadable=!0,e.nextTick(I,t))}function I(t){var e=t._readableState;n("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,N(t)}function q(t,i){i.readingMore||(i.readingMore=!0,e.nextTick(O,t,i))}function O(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function j(t){n("readable nexttick read 0"),t.read(0)}function C(t,e){n("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),N(t),e.flowing&&!e.reading&&t.read(0)}function N(t){var e=t._readableState;for(n("flow",e.flowing);e.flowing&&null!==t.read(););}function D(t,e){return 0===e.length?null:(e.objectMode?i=e.buffer.shift():!t||t>=e.length?(i=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):i=e.buffer.consume(t,e.decoder),i);var i}function U(t){var i=t._readableState;n("endReadable",i.endEmitted),i.endEmitted||(i.ended=!0,e.nextTick($,i,t))}function $(t,e){if(n("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var i=e._writableState;(!i||i.autoDestroy&&i.finished)&&e.destroy()}}function z(t,e){for(var i=0,r=t.length;i=e.highWaterMark:e.length>0)||e.ended))return n("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?U(this):B(this),null;if(0===(t=P(t,e))&&e.ended)return 0===e.length&&U(this),null;var r,s=e.needReadable;return n("need readable",s),(0===e.length||e.length-t0?D(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),i!==t&&e.ended&&U(this)),null!==r&&this.emit("data",r),r},A.prototype._read=function(t){E(this,new _("_read()"))},A.prototype.pipe=function(t,i){var r=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=t;break;case 1:o.pipes=[o.pipes,t];break;default:o.pipes.push(t)}o.pipesCount+=1,n("pipe count=%d opts=%j",o.pipesCount,i);var a=i&&!1===i.end||t===e.stdout||t===e.stderr?m:h;function h(){n("onend"),t.end()}o.endEmitted?e.nextTick(a):r.once("end",a),t.on("unpipe",(function e(i,s){n("onunpipe"),i===r&&s&&!1===s.hasUnpiped&&(s.hasUnpiped=!0,n("cleanup"),t.removeListener("close",c),t.removeListener("finish",p),t.removeListener("drain",u),t.removeListener("error",d),t.removeListener("unpipe",e),r.removeListener("end",h),r.removeListener("end",m),r.removeListener("data",l),f=!0,!o.awaitDrain||t._writableState&&!t._writableState.needDrain||u())}));var u=function(t){return function(){var e=t._readableState;n("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&s(t,"data")&&(e.flowing=!0,N(t))}}(r);t.on("drain",u);var f=!1;function l(e){n("ondata");var i=t.write(e);n("dest.write",i),!1===i&&((1===o.pipesCount&&o.pipes===t||o.pipesCount>1&&-1!==z(o.pipes,t))&&!f&&(n("false write response, pause",o.awaitDrain),o.awaitDrain++),r.pause())}function d(e){n("onerror",e),m(),t.removeListener("error",d),0===s(t,"error")&&E(t,e)}function c(){t.removeListener("finish",p),m()}function p(){n("onfinish"),t.removeListener("close",c),m()}function m(){n("unpipe"),r.unpipe(t)}return r.on("data",l),function(t,e,i){if("function"==typeof t.prependListener)return t.prependListener("error",i);t._events&&t._events.error?Array.isArray(t._events.error)?t._events.error.unshift(i):t._events.error=[i,t._events.error]:t.on("error",i)}(t,0,d),t.once("close",c),t.once("finish",p),t.emit("pipe",r),o.flowing||(n("pipe resume"),r.resume()),t},A.prototype.unpipe=function(t){var e=this._readableState,i={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,i)),this;if(!t){var r=e.pipes,n=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var s=0;s0,!1!==s.flowing&&this.resume()):"readable"===t&&(s.endEmitted||s.readableListening||(s.readableListening=s.needReadable=!0,s.flowing=!1,s.emittedReadable=!1,n("on readable",s.length,s.reading),s.length?B(this):s.reading||e.nextTick(j,this))),r},A.prototype.addListener=A.prototype.on,A.prototype.removeListener=function(t,i){var r=Ei.prototype.removeListener.call(this,t,i);return"readable"===t&&e.nextTick(L,this),r},A.prototype.removeAllListeners=function(t){var i=Ei.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||e.nextTick(L,this),i},A.prototype.resume=function(){var t=this._readableState;return t.flowing||(n("resume"),t.flowing=!t.readableListening,function(t,i){i.resumeScheduled||(i.resumeScheduled=!0,e.nextTick(C,t,i))}(this,t)),t.paused=!1,this},A.prototype.pause=function(){return n("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(n("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},A.prototype.wrap=function(t){var e=this,i=this._readableState,r=!1;for(var s in t.on("end",(function(){if(n("wrapped end"),i.decoder&&!i.ended){var t=i.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(s){n("wrapped data"),i.decoder&&(s=i.decoder.write(s)),i.objectMode&&null==s||(i.objectMode||s&&s.length)&&(e.push(s)||(r=!0,t.pause()))})),t)void 0===this[s]&&"function"==typeof t[s]&&(this[s]=function(e){return function(){return t[e].apply(t,arguments)}}(s));for(var o=0;o-1))throw new y(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(E.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(E.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),E.prototype._write=function(t,e,i){i(new c("_write()"))},E.prototype._writev=null,E.prototype.end=function(t,i,r){var n=this._writableState;return"function"==typeof t?(r=t,t=null,i=null):"function"==typeof i&&(r=i,i=null),null!=t&&this.write(t,i),n.corked&&(n.corked=1,this.uncork()),n.ending||function(t,i,r){i.ending=!0,P(t,i),r&&(i.finished?e.nextTick(r):t.once("finish",r)),i.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(E.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(E.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),E.prototype.destroy=Ii.destroy,E.prototype._undestroy=Ii.undestroy,E.prototype._destroy=function(t,e){e(t)}}).call(this)}).call(this,D,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})})),c=t((function(t,e){(function(e,i){(function(){"use strict";var r;t.exports=A,A.ReadableState=R,et.EventEmitter;var n,s=function(t,e){return t.listeners(e).length},o=M({}).Buffer,a=i.Uint8Array||function(){},h=w({});n=h&&h.debuglog?h.debuglog("stream"):function(){};var u,f,l,d=xt.getHighWaterMark,c=St.codes,g=c.ERR_INVALID_ARG_TYPE,y=c.ERR_STREAM_PUSH_AFTER_EOF,_=c.ERR_METHOD_NOT_IMPLEMENTED,S=c.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;Q(A,pt);var E=_t.errorOrDestroy,k=["error","close","destroy","pause","resume"];function R(t,e,i){r=r||b({}),t=t||{},"boolean"!=typeof i&&(i=e instanceof r),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=d(this,t,"readableHighWaterMark",i),this.buffer=new Mt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(u||(u=v({}).StringDecoder),this.decoder=new u(t.encoding),this.encoding=t.encoding)}function A(t){if(r=r||b({}),!(this instanceof A))return new A(t);var e=this instanceof r;this._readableState=new R(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),pt.call(this)}function x(t,e,i,r,s){n("readableAddChunk",e);var h,u=t._readableState;if(null===e)u.reading=!1,function(t,e){if(n("onEofChunk"),!e.ended){if(e.decoder){var i=e.decoder.end();i&&i.length&&(e.buffer.push(i),e.length+=e.objectMode?1:i.length)}e.ended=!0,e.sync?B(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,I(t)))}}(t,u);else if(s||(h=function(t,e){var i,r;return r=e,o.isBuffer(r)||r instanceof a||"string"==typeof e||void 0===e||t.objectMode||(i=new g("chunk",["string","Buffer","Uint8Array"],e)),i}(u,e)),h)E(t,h);else if(u.objectMode||e&&e.length>0)if("string"==typeof e||u.objectMode||Object.getPrototypeOf(e)===o.prototype||(e=function(t){return o.from(t)}(e)),r)u.endEmitted?E(t,new S):T(t,u,e,!0);else if(u.ended)E(t,new y);else{if(u.destroyed)return!1;u.reading=!1,u.decoder&&!i?(e=u.decoder.write(e),u.objectMode||0!==e.length?T(t,u,e,!1):q(t,u)):T(t,u,e,!1)}else r||(u.reading=!1,q(t,u));return!u.ended&&(u.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=1073741824?t=1073741824:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function B(t){var i=t._readableState;n("emitReadable",i.needReadable,i.emittedReadable),i.needReadable=!1,i.emittedReadable||(n("emitReadable",i.flowing),i.emittedReadable=!0,e.nextTick(I,t))}function I(t){var e=t._readableState;n("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,N(t)}function q(t,i){i.readingMore||(i.readingMore=!0,e.nextTick(O,t,i))}function O(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function j(t){n("readable nexttick read 0"),t.read(0)}function C(t,e){n("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),N(t),e.flowing&&!e.reading&&t.read(0)}function N(t){var e=t._readableState;for(n("flow",e.flowing);e.flowing&&null!==t.read(););}function D(t,e){return 0===e.length?null:(e.objectMode?i=e.buffer.shift():!t||t>=e.length?(i=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):i=e.buffer.consume(t,e.decoder),i);var i}function U(t){var i=t._readableState;n("endReadable",i.endEmitted),i.endEmitted||(i.ended=!0,e.nextTick($,i,t))}function $(t,e){if(n("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var i=e._writableState;(!i||i.autoDestroy&&i.finished)&&e.destroy()}}function z(t,e){for(var i=0,r=t.length;i=e.highWaterMark:e.length>0)||e.ended))return n("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?U(this):B(this),null;if(0===(t=P(t,e))&&e.ended)return 0===e.length&&U(this),null;var r,s=e.needReadable;return n("need readable",s),(0===e.length||e.length-t0?D(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),i!==t&&e.ended&&U(this)),null!==r&&this.emit("data",r),r},A.prototype._read=function(t){E(this,new _("_read()"))},A.prototype.pipe=function(t,i){var r=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=t;break;case 1:o.pipes=[o.pipes,t];break;default:o.pipes.push(t)}o.pipesCount+=1,n("pipe count=%d opts=%j",o.pipesCount,i);var a=i&&!1===i.end||t===e.stdout||t===e.stderr?m:h;function h(){n("onend"),t.end()}o.endEmitted?e.nextTick(a):r.once("end",a),t.on("unpipe",(function e(i,s){n("onunpipe"),i===r&&s&&!1===s.hasUnpiped&&(s.hasUnpiped=!0,n("cleanup"),t.removeListener("close",c),t.removeListener("finish",p),t.removeListener("drain",u),t.removeListener("error",d),t.removeListener("unpipe",e),r.removeListener("end",h),r.removeListener("end",m),r.removeListener("data",l),f=!0,!o.awaitDrain||t._writableState&&!t._writableState.needDrain||u())}));var u=function(t){return function(){var e=t._readableState;n("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&s(t,"data")&&(e.flowing=!0,N(t))}}(r);t.on("drain",u);var f=!1;function l(e){n("ondata");var i=t.write(e);n("dest.write",i),!1===i&&((1===o.pipesCount&&o.pipes===t||o.pipesCount>1&&-1!==z(o.pipes,t))&&!f&&(n("false write response, pause",o.awaitDrain),o.awaitDrain++),r.pause())}function d(e){n("onerror",e),m(),t.removeListener("error",d),0===s(t,"error")&&E(t,e)}function c(){t.removeListener("finish",p),m()}function p(){n("onfinish"),t.removeListener("close",c),m()}function m(){n("unpipe"),r.unpipe(t)}return r.on("data",l),function(t,e,i){if("function"==typeof t.prependListener)return t.prependListener("error",i);t._events&&t._events.error?Array.isArray(t._events.error)?t._events.error.unshift(i):t._events.error=[i,t._events.error]:t.on("error",i)}(t,0,d),t.once("close",c),t.once("finish",p),t.emit("pipe",r),o.flowing||(n("pipe resume"),r.resume()),t},A.prototype.unpipe=function(t){var e=this._readableState,i={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,i)),this;if(!t){var r=e.pipes,n=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var s=0;s0,!1!==s.flowing&&this.resume()):"readable"===t&&(s.endEmitted||s.readableListening||(s.readableListening=s.needReadable=!0,s.flowing=!1,s.emittedReadable=!1,n("on readable",s.length,s.reading),s.length?B(this):s.reading||e.nextTick(j,this))),r},A.prototype.addListener=A.prototype.on,A.prototype.removeListener=function(t,i){var r=pt.prototype.removeListener.call(this,t,i);return"readable"===t&&e.nextTick(L,this),r},A.prototype.removeAllListeners=function(t){var i=pt.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||e.nextTick(L,this),i},A.prototype.resume=function(){var t=this._readableState;return t.flowing||(n("resume"),t.flowing=!t.readableListening,function(t,i){i.resumeScheduled||(i.resumeScheduled=!0,e.nextTick(C,t,i))}(this,t)),t.paused=!1,this},A.prototype.pause=function(){return n("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(n("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},A.prototype.wrap=function(t){var e=this,i=this._readableState,r=!1;for(var s in t.on("end",(function(){if(n("wrapped end"),i.decoder&&!i.ended){var t=i.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(s){n("wrapped data"),i.decoder&&(s=i.decoder.write(s)),i.objectMode&&null==s||(i.objectMode||s&&s.length)&&(e.push(s)||(r=!0,t.pause()))})),t)void 0===this[s]&&"function"==typeof t[s]&&(this[s]=function(e){return function(){return t[e].apply(t,arguments)}}(s));for(var o=0;o>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function o(t){var e=this.lastTotal-this.lastNeed,i=function(t,e,i){if(128!=(192&e[0]))return t.lastNeed=0,"\ufffd";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"\ufffd";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"\ufffd"}}(this,t);return void 0!==i?i:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function a(t,e){if((t.length-e)%2==0){var i=t.toString("utf16le",e);if(i){var r=i.charCodeAt(i.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],i.slice(0,-1)}return i}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function h(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var i=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,i)}return e}function u(t,e){var i=(t.length-e)%3;return 0===i?t.toString("base64",e):(this.lastNeed=3-i,this.lastTotal=3,1===i?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-i))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function l(t){return t.toString(this.encoding)}function d(t){return t&&t.length?this.write(t):""}e.StringDecoder=n,n.prototype.write=function(t){if(0===t.length)return"";var e,i;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";i=this.lastNeed,this.lastNeed=0}else i=0;return i=0?(n>0&&(t.lastNeed=n-1),n):--r=0?(n>0&&(t.lastNeed=n-2),n):--r=0?(n>0&&(2===n?n=0:t.lastNeed=n-3),n):0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=i;var r=t.length-(i-this.lastNeed);return t.copy(this.lastChar,0,r),t.toString("utf8",e,r)},n.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}})),b=t((function(t,e){(function(e){(function(){"use strict";var i=Object.keys||function(t){var e=[];for(var i in t)e.push(i);return e};t.exports=h;var r=c({}),n=y({});Q(h,r);for(var s=i(n.prototype),o=0;o-1))throw new y(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(E.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(E.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),E.prototype._write=function(t,e,i){i(new d("_write()"))},E.prototype._writev=null,E.prototype.end=function(t,i,r){var n=this._writableState;return"function"==typeof t?(r=t,t=null,i=null):"function"==typeof i&&(r=i,i=null),null!=t&&this.write(t,i),n.corked&&(n.corked=1,this.uncork()),n.ending||function(t,i,r){i.ending=!0,P(t,i),r&&(i.finished?e.nextTick(r):t.once("finish",r)),i.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(E.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(E.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),E.prototype.destroy=_t.destroy,E.prototype._undestroy=_t.undestroy,E.prototype._destroy=function(t,e){e(t)}}).call(this)}).call(this,D,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})})),w=t((function(t,e){})),M=t((function(t,e){(function(t){(function(){"use strict";e.Buffer=i,e.SlowBuffer=function(t){return+t!=t&&(t=0),i.alloc(+t)},e.INSPECT_MAX_BYTES=50;function t(t){if(t>2147483647)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=i.prototype,e}function i(t,e,i){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return s(t)}return r(t,e,i)}function r(e,r,n){if("string"==typeof e)return function(e,r){if("string"==typeof r&&""!==r||(r="utf8"),!i.isEncoding(r))throw new TypeError("Unknown encoding: "+r);var n=0|h(e,r),s=t(n),o=s.write(e,r);return o!==n&&(s=s.slice(0,o)),s}(e,r);if(ArrayBuffer.isView(e))return o(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(j(e,ArrayBuffer)||e&&j(e.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=2147483647)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+2147483647..toString(16)+" bytes");return 0|t}function h(t,e){if(i.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||j(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var s=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return O(t).length;default:if(s)return n?-1:q(t).length;e=(""+e).toLowerCase(),s=!0}}function u(t,e,i){var r=t[e];t[e]=t[i],t[i]=r}function f(t,e,r,n,s){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),C(r=+r)&&(r=s?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(s)return-1;r=t.length-1}else if(r<0){if(!s)return-1;r=0}if("string"==typeof e&&(e=i.from(e,n)),i.isBuffer(e))return 0===e.length?-1:l(t,e,r,n,s);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):l(t,[e],r,n,s);throw new TypeError("val must be string, number or Buffer")}function l(t,e,i,r,n){var s,o=1,a=t.length,h=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;o=2,a/=2,h/=2,i/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(n){var f=-1;for(s=i;sa&&(i=a-h),s=i;s>=0;s--){for(var l=!0,d=0;dn&&(r=n):r=n;var s=e.length;r>s/2&&(r=s/2);for(var o=0;o>8,n=i%256,s.push(n),s.push(r);return s}(e,t.length-i),t,i,r)}function b(t,e,i){return 0===e&&i===t.length?_.fromByteArray(t):_.fromByteArray(t.slice(e,i))}function y(t,e,i){i=Math.min(t.length,i);for(var r=[],n=e;n239?4:u>223?3:u>191?2:1;if(n+l<=i)switch(l){case 1:u<128&&(f=u);break;case 2:128==(192&(s=t[n+1]))&&(h=(31&u)<<6|63&s)>127&&(f=h);break;case 3:s=t[n+1],o=t[n+2],128==(192&s)&&128==(192&o)&&(h=(15&u)<<12|(63&s)<<6|63&o)>2047&&(h<55296||h>57343)&&(f=h);break;case 4:s=t[n+1],o=t[n+2],a=t[n+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(h=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&h<1114112&&(f=h)}null===f?(f=65533,l=1):f>65535&&(f-=65536,r.push(f>>>10&1023|55296),f=56320|1023&f),r.push(f),n+=l}return function(t){var e=t.length;if(e<=w)return String.fromCharCode.apply(String,t);for(var i="",r=0;rthis.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return E(this,e,i);case"utf8":case"utf-8":return y(this,e,i);case"ascii":return M(this,e,i);case"latin1":case"binary":return S(this,e,i);case"base64":return b(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,i);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}.apply(this,arguments)},i.prototype.toLocaleString=i.prototype.toString,i.prototype.equals=function(t){if(!i.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===i.compare(this,t)},i.prototype.inspect=function(){var t="",i=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,i).replace(/(.{2})/g,"$1 ").trim(),this.length>i&&(t+=" ... "),""},i.prototype.compare=function(t,e,r,n,s){if(j(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),!i.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===s&&(s=this.length),e<0||r>t.length||n<0||s>this.length)throw new RangeError("out of range index");if(n>=s&&e>=r)return 0;if(n>=s)return-1;if(e>=r)return 1;if(this===t)return 0;for(var o=(s>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),h=Math.min(o,a),u=this.slice(n,s),f=t.slice(e,r),l=0;l>>=0,isFinite(i)?(i>>>=0,void 0===r&&(r="utf8")):(r=i,i=void 0)}var n=this.length-e;if((void 0===i||i>n)&&(i=n),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var s=!1;;)switch(r){case"hex":return d(this,t,e,i);case"utf8":case"utf-8":return c(this,t,e,i);case"ascii":return p(this,t,e,i);case"latin1":case"binary":return m(this,t,e,i);case"base64":return g(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v(this,t,e,i);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var w=4096;function M(t,e,i){var r="";i=Math.min(t.length,i);for(var n=e;nn)&&(i=n);for(var s="",o=e;oi)throw new RangeError("Trying to access beyond buffer length")}function A(t,e,r,n,s,o){if(!i.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>s||et.length)throw new RangeError("Index out of range")}function x(t,e,i,r,n,s){if(i+r>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function T(t,e,i,r,n){return e=+e,i>>>=0,n||x(t,0,i,4),B.write(t,e,i,r,23,4),i+4}function P(t,e,i,r,n){return e=+e,i>>>=0,n||x(t,0,i,8),B.write(t,e,i,r,52,8),i+8}i.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,i||R(t,e,this.length);for(var r=this[t],n=1,s=0;++s>>=0,e>>>=0,i||R(t,e,this.length);for(var r=this[t+--e],n=1;e>0&&(n*=256);)r+=this[t+--e]*n;return r},i.prototype.readUInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),this[t]},i.prototype.readUInt16LE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]|this[t+1]<<8},i.prototype.readUInt16BE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]<<8|this[t+1]},i.prototype.readUInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},i.prototype.readUInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},i.prototype.readIntLE=function(t,e,i){t>>>=0,e>>>=0,i||R(t,e,this.length);for(var r=this[t],n=1,s=0;++s=(n*=128)&&(r-=Math.pow(2,8*e)),r},i.prototype.readIntBE=function(t,e,i){t>>>=0,e>>>=0,i||R(t,e,this.length);for(var r=e,n=1,s=this[t+--r];r>0&&(n*=256);)s+=this[t+--r]*n;return s>=(n*=128)&&(s-=Math.pow(2,8*e)),s},i.prototype.readInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},i.prototype.readInt16LE=function(t,e){t>>>=0,e||R(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},i.prototype.readInt16BE=function(t,e){t>>>=0,e||R(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},i.prototype.readInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},i.prototype.readInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},i.prototype.readFloatLE=function(t,e){return t>>>=0,e||R(t,4,this.length),B.read(this,t,!0,23,4)},i.prototype.readFloatBE=function(t,e){return t>>>=0,e||R(t,4,this.length),B.read(this,t,!1,23,4)},i.prototype.readDoubleLE=function(t,e){return t>>>=0,e||R(t,8,this.length),B.read(this,t,!0,52,8)},i.prototype.readDoubleBE=function(t,e){return t>>>=0,e||R(t,8,this.length),B.read(this,t,!1,52,8)},i.prototype.writeUIntLE=function(t,e,i,r){t=+t,e>>>=0,i>>>=0,r||A(this,t,e,i,Math.pow(2,8*i)-1,0);var n=1,s=0;for(this[e]=255&t;++s>>=0,i>>>=0,r||A(this,t,e,i,Math.pow(2,8*i)-1,0);var n=i-1,s=1;for(this[e+n]=255&t;--n>=0&&(s*=256);)this[e+n]=t/s&255;return e+i},i.prototype.writeUInt8=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,1,255,0),this[e]=255&t,e+1},i.prototype.writeUInt16LE=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeUInt16BE=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeUInt32LE=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},i.prototype.writeUInt32BE=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},i.prototype.writeIntLE=function(t,e,i,r){if(t=+t,e>>>=0,!r){var n=Math.pow(2,8*i-1);A(this,t,e,i,n-1,-n)}var s=0,o=1,a=0;for(this[e]=255&t;++s>0)-a&255;return e+i},i.prototype.writeIntBE=function(t,e,i,r){if(t=+t,e>>>=0,!r){var n=Math.pow(2,8*i-1);A(this,t,e,i,n-1,-n)}var s=i-1,o=1,a=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+i},i.prototype.writeInt8=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},i.prototype.writeInt16LE=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeInt16BE=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeInt32LE=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},i.prototype.writeInt32BE=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},i.prototype.writeFloatLE=function(t,e,i){return T(this,t,e,!0,i)},i.prototype.writeFloatBE=function(t,e,i){return T(this,t,e,!1,i)},i.prototype.writeDoubleLE=function(t,e,i){return P(this,t,e,!0,i)},i.prototype.writeDoubleBE=function(t,e,i){return P(this,t,e,!1,i)},i.prototype.copy=function(t,e,r,n){if(!i.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return s},i.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!i.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var s=t.charCodeAt(0);("utf8"===n&&s<128||"latin1"===n)&&(t=s)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&i<57344){if(!n){if(i>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===r){(e-=3)>-1&&s.push(239,191,189);continue}n=i;continue}if(i<56320){(e-=3)>-1&&s.push(239,191,189),n=i;continue}i=65536+(n-55296<<10|i-56320)}else n&&(e-=3)>-1&&s.push(239,191,189);if(n=null,i<128){if((e-=1)<0)break;s.push(i)}else if(i<2048){if((e-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function O(t){return _.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function L(t,e,i,r){for(var n=0;n=e.length||n>=t.length);++n)e[n+i]=t[n];return n}function j(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function C(t){return t!=t}}).call(this)}).call(this,M({}).Buffer)})),_={toByteArray:function(t){var e,i,r=T(t),n=r[0],s=r[1],o=new k(function(t,e,i){return 3*(e+i)/4-i}(0,n,s)),a=0,h=s>0?n-4:n;for(i=0;i>16&255,o[a++]=e>>8&255,o[a++]=255&e;return 2===s&&(e=E[t.charCodeAt(i)]<<2|E[t.charCodeAt(i+1)]>>4,o[a++]=255&e),1===s&&(e=E[t.charCodeAt(i)]<<10|E[t.charCodeAt(i+1)]<<4|E[t.charCodeAt(i+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e),o},fromByteArray:function(t){for(var e,i=t.length,r=i%3,n=[],s=0,o=i-r;so?o:s+16383));return 1===r?(e=t[i-1],n.push(S[e>>2]+S[e<<4&63]+"==")):2===r&&(e=(t[i-2]<<8)+t[i-1],n.push(S[e>>10]+S[e>>4&63]+S[e<<2&63]+"=")),n.join("")}},S=[],E=[],k="undefined"!=typeof Uint8Array?Uint8Array:Array,R="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",A=0,x=R.length;A0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");return-1===i&&(i=e),[i,i===e?0:4-i%4]}function P(t,e,i){for(var r,n,s=[],o=e;o>18&63]+S[n>>12&63]+S[n>>6&63]+S[63&n]);return s.join("")}E["-".charCodeAt(0)]=62,E["_".charCodeAt(0)]=63;var B={read:function(t,e,i,r,n){var s,o,a=8*n-r-1,h=(1<>1,f=-7,l=i?n-1:0,d=i?-1:1,c=t[e+l];for(l+=d,s=c&(1<<-f)-1,c>>=-f,f+=a;f>0;s=256*s+t[e+l],l+=d,f-=8);for(o=s&(1<<-f)-1,s>>=-f,f+=r;f>0;o=256*o+t[e+l],l+=d,f-=8);if(0===s)s=1-u;else{if(s===h)return o?NaN:1/0*(c?-1:1);o+=Math.pow(2,r),s-=u}return(c?-1:1)*o*Math.pow(2,s-r)},write:function(t,e,i,r,n,s){var o,a,h,u=8*s-n-1,f=(1<>1,d=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,c=r?0:s-1,p=r?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=f):(o=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-o))<1&&(o--,h*=2),(e+=o+l>=1?d/h:d*Math.pow(2,1-l))*h>=2&&(o++,h/=2),o+l>=f?(a=0,o=f):o+l>=1?(a=(e*h-1)*Math.pow(2,n),o+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,n),o=0));n>=8;t[i+c]=255&a,c+=p,a/=256,n-=8);for(o=o<0;t[i+c]=255&o,c+=p,o/=256,u-=8);t[i+c-p]|=128*m}},I={},q=M({}),O=q.Buffer;function L(t,e){for(var i in t)e[i]=t[i]}function j(t,e,i){return O(t,e,i)}O.from&&O.alloc&&O.allocUnsafe&&O.allocUnsafeSlow?I=q:(L(q,I),I.Buffer=j),j.prototype=Object.create(O.prototype),L(O,j),j.from=function(t,e,i){if("number"==typeof t)throw new TypeError("Argument must not be a number");return O(t,e,i)},j.alloc=function(t,e,i){if("number"!=typeof t)throw new TypeError("Argument must be a number");var r=O(t);return void 0!==e?"string"==typeof i?r.fill(e,i):r.fill(e):r.fill(0),r},j.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return O(t)},j.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return q.SlowBuffer(t)};var C,N,D={},U=D={};function $(){throw new Error("setTimeout has not been defined")}function z(){throw new Error("clearTimeout has not been defined")}function W(t){if(C===setTimeout)return setTimeout(t,0);if((C===$||!C)&&setTimeout)return C=setTimeout,setTimeout(t,0);try{return C(t,0)}catch(e){try{return C.call(null,t,0)}catch(e){return C.call(this,t,0)}}}!function(){try{C="function"==typeof setTimeout?setTimeout:$}catch(t){C=$}try{N="function"==typeof clearTimeout?clearTimeout:z}catch(t){N=z}}();var F,K=[],H=!1,Z=-1;function V(){H&&F&&(H=!1,F.length?K=F.concat(K):Z=-1,K.length&&G())}function G(){if(!H){var t=W(V);H=!0;for(var e=K.length;e;){for(F=K,K=[];++Z1)for(var i=1;i4294967295)throw new RangeError("requested too many random bytes");var s=i.allocUnsafe(e);if(e>0)if(e>65536)for(var o=0;o0&&o.length>n&&!o.warned){o.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=t,h.type=e,h.count=o.length,a=h,console&&console.warn&&console.warn(a)}return t}function ft(t,e,i){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},n=function(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}.bind(r);return n.listener=i,r.wrapFn=n,n}function lt(t,e,i){var r=t._events;if(void 0===r)return[];var n=r[e];return void 0===n?[]:"function"==typeof n?i?[n.listener||n]:[n]:i?function(t){for(var e=new Array(t.length),i=0;i0&&(s=e[0]),s instanceof Error)throw s;var o=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw o.context=s,o}var a=n[t];if(void 0===a)return!1;if("function"==typeof a)rt(a,this,e);else{var h=a.length,u=ct(a,h);for(i=0;i=0;s--)if(i[s]===e||i[s].listener===e){o=i[s].listener,n=s;break}if(n<0)return this;0===n?i.shift():function(t,e){for(;e+1=0;r--)this.removeListener(t,e[r]);return this},st.prototype.listeners=function(t){return lt(this,t,!0)},st.prototype.rawListeners=function(t){return lt(this,t,!1)},st.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):dt.call(t,e)},st.prototype.listenerCount=dt,st.prototype.eventNames=function(){return this._eventsCount>0?tt(this._events):[]};var pt=et.EventEmitter;function mt(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,r)}return i}function gt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function vt(t,e){for(var i=0;i0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,i=""+e.data;e=e.next;)i+=t+e.data;return i}},{key:"concat",value:function(t){if(0===this.length)return bt.alloc(0);for(var e,i,r,n=bt.allocUnsafe(t>>>0),s=this.head,o=0;s;)e=s.data,i=n,r=o,bt.prototype.copy.call(e,i,r),o+=s.data.length,s=s.next;return n}},{key:"consume",value:function(t,e){var i;return tn.length?n.length:t;if(s===n.length?r+=n:r+=n.slice(0,t),0==(t-=s)){s===n.length?(++i,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=n.slice(s));break}++i}return this.length-=i,r}},{key:"_getBuffer",value:function(t){var e=bt.allocUnsafe(t),i=this.head,r=1;for(i.data.copy(e),t-=i.data.length;i=i.next;){var n=i.data,s=t>n.length?n.length:t;if(n.copy(e,e.length-t,0,s),0==(t-=s)){s===n.length?(++r,i.next?this.head=i.next:this.head=this.tail=null):(this.head=i,i.data=n.slice(s));break}++r}return this.length-=r,e}},{key:wt,value:function(t,e){return yt(this,function(t){for(var e=1;e2?"one of ".concat(e," ").concat(t.slice(0,i-1).join(", "),", or ")+t[i-1]:2===i?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}kt("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),kt("ERR_INVALID_ARG_TYPE",(function(t,e,i){var r,n,s,o;if("string"==typeof e&&("not ","not "===e.substr(0,"not ".length))?(r="must not be",e=e.replace(/^not /,"")):r="must be",s=t,(void 0===o||o>s.length)&&(o=s.length)," argument"===s.substring(o-" argument".length,o))n="The ".concat(t," ").concat(r," ").concat(Rt(e,"type"));else{var a=function(t,e,i){return"number"!=typeof i&&(i=0),!(i+".".length>t.length)&&-1!==t.indexOf(".",i)}(t)?"property":"argument";n='The "'.concat(t,'" ').concat(a," ").concat(r," ").concat(Rt(e,"type"))}return n+". Received type ".concat(typeof i)}),TypeError),kt("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),kt("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),kt("ERR_STREAM_PREMATURE_CLOSE","Premature close"),kt("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),kt("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),kt("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),kt("ERR_STREAM_WRITE_AFTER_END","write after end"),kt("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),kt("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),kt("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),St.codes=Et;var At=St.codes.ERR_INVALID_OPT_VALUE,xt={getHighWaterMark:function(t,e,i,r){var n=function(t,e,i){return null!=t.highWaterMark?t.highWaterMark:e?t[i]:null}(e,r,i);if(null!=n){if(!isFinite(n)||Math.floor(n)!==n||n<0)throw new At(r?i:"highWaterMark",n);return Math.floor(n)}return t.objectMode?16:16384}},Tt={};(function(t){(function(){function e(e){try{if(!t.localStorage)return!1}catch(r){return!1}var i=t.localStorage[e];return null!=i&&"true"===String(i).toLowerCase()}Tt=function(t,i){if(e("noDeprecation"))return t;var r=!1;return function(){if(!r){if(e("throwDeprecation"))throw new Error(i);e("traceDeprecation")?console.trace(i):console.warn(i),r=!0}return t.apply(this,arguments)}}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});var Pt=Nt,Bt=St.codes,It=Bt.ERR_METHOD_NOT_IMPLEMENTED,qt=Bt.ERR_MULTIPLE_CALLBACK,Ot=Bt.ERR_TRANSFORM_ALREADY_TRANSFORMING,Lt=Bt.ERR_TRANSFORM_WITH_LENGTH_0,jt=b({});function Ct(t,e){var i=this._transformState;i.transforming=!1;var r=i.writecb;if(null===r)return this.emit("error",new qt);i.writechunk=null,i.writecb=null,null!=e&&this.push(e),r(t);var n=this._readableState;n.reading=!1,(n.needReadable||n.length0,(function(t){r||(r=t),t&&s.forEach(Vt),o||(s.forEach(Vt),n(r))}))}));return e.reduce(Gt)};var Xt={},Jt=I.Buffer,Qt=Yt.Transform;function te(t){Qt.call(this),this._block=Jt.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}Q(te,Qt),te.prototype._transform=function(t,e,i){var r=null;try{this.update(t,e)}catch(n){r=n}i(r)},te.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(i){e=i}t(e)},te.prototype.update=function(t,e){if(function(t,e){if(!Jt.isBuffer(t)&&"string"!=typeof t)throw new TypeError("Data must be a string or a buffer")}(t),this._finalized)throw new Error("Digest already called");Jt.isBuffer(t)||(t=Jt.from(t,e));for(var i=this._block,r=0;this._blockOffset+t.length-r>=this._blockSize;){for(var n=this._blockOffset;n0;++s)this._length[s]+=o,(o=this._length[s]/4294967296|0)>0&&(this._length[s]-=4294967296*o);return this},te.prototype._update=function(){throw new Error("_update is not implemented")},te.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var i=0;i<4;++i)this._length[i]=0;return e},te.prototype._digest=function(){throw new Error("_digest is not implemented")},Xt=te;var ee={},ie=I.Buffer,re=new Array(16);function ne(){Xt.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function se(t,e){return t<>>32-e}function oe(t,e,i,r,n,s,o){return se(t+(e&i|~e&r)+n+s|0,o)+e|0}function ae(t,e,i,r,n,s,o){return se(t+(e&r|i&~r)+n+s|0,o)+e|0}function he(t,e,i,r,n,s,o){return se(t+(e^i^r)+n+s|0,o)+e|0}function ue(t,e,i,r,n,s,o){return se(t+(i^(e|~r))+n+s|0,o)+e|0}Q(ne,Xt),ne.prototype._update=function(){for(var t=re,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);var i=this._a,r=this._b,n=this._c,s=this._d;i=oe(i,r,n,s,t[0],3614090360,7),s=oe(s,i,r,n,t[1],3905402710,12),n=oe(n,s,i,r,t[2],606105819,17),r=oe(r,n,s,i,t[3],3250441966,22),i=oe(i,r,n,s,t[4],4118548399,7),s=oe(s,i,r,n,t[5],1200080426,12),n=oe(n,s,i,r,t[6],2821735955,17),r=oe(r,n,s,i,t[7],4249261313,22),i=oe(i,r,n,s,t[8],1770035416,7),s=oe(s,i,r,n,t[9],2336552879,12),n=oe(n,s,i,r,t[10],4294925233,17),r=oe(r,n,s,i,t[11],2304563134,22),i=oe(i,r,n,s,t[12],1804603682,7),s=oe(s,i,r,n,t[13],4254626195,12),n=oe(n,s,i,r,t[14],2792965006,17),i=ae(i,r=oe(r,n,s,i,t[15],1236535329,22),n,s,t[1],4129170786,5),s=ae(s,i,r,n,t[6],3225465664,9),n=ae(n,s,i,r,t[11],643717713,14),r=ae(r,n,s,i,t[0],3921069994,20),i=ae(i,r,n,s,t[5],3593408605,5),s=ae(s,i,r,n,t[10],38016083,9),n=ae(n,s,i,r,t[15],3634488961,14),r=ae(r,n,s,i,t[4],3889429448,20),i=ae(i,r,n,s,t[9],568446438,5),s=ae(s,i,r,n,t[14],3275163606,9),n=ae(n,s,i,r,t[3],4107603335,14),r=ae(r,n,s,i,t[8],1163531501,20),i=ae(i,r,n,s,t[13],2850285829,5),s=ae(s,i,r,n,t[2],4243563512,9),n=ae(n,s,i,r,t[7],1735328473,14),i=he(i,r=ae(r,n,s,i,t[12],2368359562,20),n,s,t[5],4294588738,4),s=he(s,i,r,n,t[8],2272392833,11),n=he(n,s,i,r,t[11],1839030562,16),r=he(r,n,s,i,t[14],4259657740,23),i=he(i,r,n,s,t[1],2763975236,4),s=he(s,i,r,n,t[4],1272893353,11),n=he(n,s,i,r,t[7],4139469664,16),r=he(r,n,s,i,t[10],3200236656,23),i=he(i,r,n,s,t[13],681279174,4),s=he(s,i,r,n,t[0],3936430074,11),n=he(n,s,i,r,t[3],3572445317,16),r=he(r,n,s,i,t[6],76029189,23),i=he(i,r,n,s,t[9],3654602809,4),s=he(s,i,r,n,t[12],3873151461,11),n=he(n,s,i,r,t[15],530742520,16),i=ue(i,r=he(r,n,s,i,t[2],3299628645,23),n,s,t[0],4096336452,6),s=ue(s,i,r,n,t[7],1126891415,10),n=ue(n,s,i,r,t[14],2878612391,15),r=ue(r,n,s,i,t[5],4237533241,21),i=ue(i,r,n,s,t[12],1700485571,6),s=ue(s,i,r,n,t[3],2399980690,10),n=ue(n,s,i,r,t[10],4293915773,15),r=ue(r,n,s,i,t[1],2240044497,21),i=ue(i,r,n,s,t[8],1873313359,6),s=ue(s,i,r,n,t[15],4264355552,10),n=ue(n,s,i,r,t[6],2734768916,15),r=ue(r,n,s,i,t[13],1309151649,21),i=ue(i,r,n,s,t[4],4149444226,6),s=ue(s,i,r,n,t[11],3174756917,10),n=ue(n,s,i,r,t[2],718787259,15),r=ue(r,n,s,i,t[9],3951481745,21),this._a=this._a+i|0,this._b=this._b+r|0,this._c=this._c+n|0,this._d=this._d+s|0},ne.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 t=ie.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t},ee=ne;var fe={},le=M({}).Buffer,de=new Array(16),ce=[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],pe=[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],me=[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],ge=[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],ve=[0,1518500249,1859775393,2400959708,2840853838],be=[1352829926,1548603684,1836072691,2053994217,0];function ye(){Xt.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function we(t,e){return t<>>32-e}function Me(t,e,i,r,n,s,o,a){return we(t+(e^i^r)+s+o|0,a)+n|0}function _e(t,e,i,r,n,s,o,a){return we(t+(e&i|~e&r)+s+o|0,a)+n|0}function Se(t,e,i,r,n,s,o,a){return we(t+((e|~i)^r)+s+o|0,a)+n|0}function Ee(t,e,i,r,n,s,o,a){return we(t+(e&r|i&~r)+s+o|0,a)+n|0}function ke(t,e,i,r,n,s,o,a){return we(t+(e^(i|~r))+s+o|0,a)+n|0}Q(ye,Xt),ye.prototype._update=function(){for(var t=de,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);for(var i=0|this._a,r=0|this._b,n=0|this._c,s=0|this._d,o=0|this._e,a=0|this._a,h=0|this._b,u=0|this._c,f=0|this._d,l=0|this._e,d=0;d<80;d+=1){var c,p;d<16?(c=Me(i,r,n,s,o,t[ce[d]],ve[0],me[d]),p=ke(a,h,u,f,l,t[pe[d]],be[0],ge[d])):d<32?(c=_e(i,r,n,s,o,t[ce[d]],ve[1],me[d]),p=Ee(a,h,u,f,l,t[pe[d]],be[1],ge[d])):d<48?(c=Se(i,r,n,s,o,t[ce[d]],ve[2],me[d]),p=Se(a,h,u,f,l,t[pe[d]],be[2],ge[d])):d<64?(c=Ee(i,r,n,s,o,t[ce[d]],ve[3],me[d]),p=_e(a,h,u,f,l,t[pe[d]],be[3],ge[d])):(c=ke(i,r,n,s,o,t[ce[d]],ve[4],me[d]),p=Me(a,h,u,f,l,t[pe[d]],be[4],ge[d])),i=o,o=s,s=we(n,10),n=r,r=c,a=l,l=f,f=we(u,10),u=h,h=p}var m=this._b+n+f|0;this._b=this._c+s+l|0,this._c=this._d+o+a|0,this._d=this._e+i+h|0,this._e=this._a+r+u|0,this._a=m},ye.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 t=le.alloc?le.alloc(20):new le(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t},fe=ye;var Re={},Ae=I.Buffer;function xe(t,e){this._block=Ae.alloc(t),this._finalSize=e,this._blockSize=t,this._len=0}xe.prototype.update=function(t,e){"string"==typeof t&&(e=e||"utf8",t=Ae.from(t,e));for(var i=this._block,r=this._blockSize,n=t.length,s=this._len,o=0;o=this._finalSize&&(this._update(this._block),this._block.fill(0));var i=8*this._len;if(i<=4294967295)this._block.writeUInt32BE(i,this._blockSize-4);else{var r=(4294967295&i)>>>0,n=(i-r)/4294967296;this._block.writeUInt32BE(n,this._blockSize-8),this._block.writeUInt32BE(r,this._blockSize-4)}this._update(this._block);var s=this._hash();return t?s.toString(t):s},xe.prototype._update=function(){throw new Error("_update must be implemented by subclass")},Re=xe;var Te,Pe=I.Buffer,Be=[1518500249,1859775393,-1894007588,-899497514],Ie=new Array(80);function qe(){this.init(),this._w=Ie,Re.call(this,64,56)}function Oe(t){return t<<30|t>>>2}function Le(t,e,i,r){return 0===t?e&i|~e&r:2===t?e&i|e&r|i&r:e^i^r}Q(qe,Re),qe.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},qe.prototype._update=function(t){for(var e,i=this._w,r=0|this._a,n=0|this._b,s=0|this._c,o=0|this._d,a=0|this._e,h=0;h<16;++h)i[h]=t.readInt32BE(4*h);for(;h<80;++h)i[h]=i[h-3]^i[h-8]^i[h-14]^i[h-16];for(var u=0;u<80;++u){var f=~~(u/20),l=0|((e=r)<<5|e>>>27)+Le(f,n,s,o)+a+i[u]+Be[f];a=o,o=s,s=Oe(n),n=r,r=l}this._a=r+this._a|0,this._b=n+this._b|0,this._c=s+this._c|0,this._d=o+this._d|0,this._e=a+this._e|0},qe.prototype._hash=function(){var t=Pe.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},Te=qe;var je,Ce=I.Buffer,Ne=[1518500249,1859775393,-1894007588,-899497514],De=new Array(80);function Ue(){this.init(),this._w=De,Re.call(this,64,56)}function $e(t){return t<<5|t>>>27}function ze(t){return t<<30|t>>>2}function We(t,e,i,r){return 0===t?e&i|~e&r:2===t?e&i|e&r|i&r:e^i^r}Q(Ue,Re),Ue.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},Ue.prototype._update=function(t){for(var e,i=this._w,r=0|this._a,n=0|this._b,s=0|this._c,o=0|this._d,a=0|this._e,h=0;h<16;++h)i[h]=t.readInt32BE(4*h);for(;h<80;++h)i[h]=(e=i[h-3]^i[h-8]^i[h-14]^i[h-16])<<1|e>>>31;for(var u=0;u<80;++u){var f=~~(u/20),l=$e(r)+We(f,n,s,o)+a+i[u]+Ne[f]|0;a=o,o=s,s=ze(n),n=r,r=l}this._a=r+this._a|0,this._b=n+this._b|0,this._c=s+this._c|0,this._d=o+this._d|0,this._e=a+this._e|0},Ue.prototype._hash=function(){var t=Ce.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},je=Ue;var Fe,Ke=I.Buffer,He=[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],Ze=new Array(64);function Ve(){this.init(),this._w=Ze,Re.call(this,64,56)}function Ge(t,e,i){return i^t&(e^i)}function Ye(t,e,i){return t&e|i&(t|e)}function Xe(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function Je(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function Qe(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}Q(Ve,Re),Ve.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},Ve.prototype._update=function(t){for(var e,i=this._w,r=0|this._a,n=0|this._b,s=0|this._c,o=0|this._d,a=0|this._e,h=0|this._f,u=0|this._g,f=0|this._h,l=0;l<16;++l)i[l]=t.readInt32BE(4*l);for(;l<64;++l)i[l]=0|(((e=i[l-2])>>>17|e<<15)^(e>>>19|e<<13)^e>>>10)+i[l-7]+Qe(i[l-15])+i[l-16];for(var d=0;d<64;++d){var c=f+Je(a)+Ge(a,h,u)+He[d]+i[d]|0,p=Xe(r)+Ye(r,n,s)|0;f=u,u=h,h=a,a=o+c|0,o=s,s=n,n=r,r=c+p|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=s+this._c|0,this._d=o+this._d|0,this._e=a+this._e|0,this._f=h+this._f|0,this._g=u+this._g|0,this._h=f+this._h|0},Ve.prototype._hash=function(){var t=Ke.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},Fe=Ve;var ti,ei=I.Buffer,ii=new Array(64);function ri(){this.init(),this._w=ii,Re.call(this,64,56)}Q(ri,Fe),ri.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},ri.prototype._hash=function(){var t=ei.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},ti=ri;var ni,si=I.Buffer,oi=[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],ai=new Array(160);function hi(){this.init(),this._w=ai,Re.call(this,128,112)}function ui(t,e,i){return i^t&(e^i)}function fi(t,e,i){return t&e|i&(t|e)}function li(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function di(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function ci(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function pi(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function mi(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function gi(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function vi(t,e){return t>>>0>>0?1:0}Q(hi,Re),hi.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},hi.prototype._update=function(t){for(var e=this._w,i=0|this._ah,r=0|this._bh,n=0|this._ch,s=0|this._dh,o=0|this._eh,a=0|this._fh,h=0|this._gh,u=0|this._hh,f=0|this._al,l=0|this._bl,d=0|this._cl,c=0|this._dl,p=0|this._el,m=0|this._fl,g=0|this._gl,v=0|this._hl,b=0;b<32;b+=2)e[b]=t.readInt32BE(4*b),e[b+1]=t.readInt32BE(4*b+4);for(;b<160;b+=2){var y=e[b-30],w=e[b-30+1],M=ci(y,w),_=pi(w,y),S=mi(y=e[b-4],w=e[b-4+1]),E=gi(w,y),k=e[b-14],R=e[b-14+1],A=e[b-32],x=e[b-32+1],T=_+R|0,P=M+k+vi(T,_)|0;P=(P=P+S+vi(T=T+E|0,E)|0)+A+vi(T=T+x|0,x)|0,e[b]=P,e[b+1]=T}for(var B=0;B<160;B+=2){P=e[B],T=e[B+1];var I=fi(i,r,n),q=fi(f,l,d),O=li(i,f),L=li(f,i),j=di(o,p),C=di(p,o),N=oi[B],D=oi[B+1],U=ui(o,a,h),$=ui(p,m,g),z=v+C|0,W=u+j+vi(z,v)|0;W=(W=(W=W+U+vi(z=z+$|0,$)|0)+N+vi(z=z+D|0,D)|0)+P+vi(z=z+T|0,T)|0;var F=L+q|0,K=O+I+vi(F,L)|0;u=h,v=g,h=a,g=m,a=o,m=p,o=s+W+vi(p=c+z|0,c)|0,s=n,c=d,n=r,d=l,r=i,l=f,i=W+K+vi(f=z+F|0,z)|0}this._al=this._al+f|0,this._bl=this._bl+l|0,this._cl=this._cl+d|0,this._dl=this._dl+c|0,this._el=this._el+p|0,this._fl=this._fl+m|0,this._gl=this._gl+g|0,this._hl=this._hl+v|0,this._ah=this._ah+i+vi(this._al,f)|0,this._bh=this._bh+r+vi(this._bl,l)|0,this._ch=this._ch+n+vi(this._cl,d)|0,this._dh=this._dh+s+vi(this._dl,c)|0,this._eh=this._eh+o+vi(this._el,p)|0,this._fh=this._fh+a+vi(this._fl,m)|0,this._gh=this._gh+h+vi(this._gl,g)|0,this._hh=this._hh+u+vi(this._hl,v)|0},hi.prototype._hash=function(){var t=si.allocUnsafe(64);function e(e,i,r){t.writeInt32BE(e,r),t.writeInt32BE(i,r+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},ni=hi;var bi,yi=I.Buffer,wi=new Array(160);function Mi(){this.init(),this._w=wi,Re.call(this,128,112)}Q(Mi,ni),Mi.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},Mi.prototype._hash=function(){var t=yi.allocUnsafe(48);function e(e,i,r){t.writeInt32BE(e,r),t.writeInt32BE(i,r+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t},bi=Mi;var _i,Si;(Si=_i=function(t){t=t.toLowerCase();var e=Si[t];if(!e)throw new Error(t+" is not supported (we accept pull requests)");return new e}).sha=Te,Si.sha1=je,Si.sha224=ti,Si.sha256=Fe,Si.sha384=bi,Si.sha512=ni;var Ei=et.EventEmitter;function ki(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,r)}return i}function Ri(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function Ai(t,e){for(var i=0;i0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,i=""+e.data;e=e.next;)i+=t+e.data;return i}},{key:"concat",value:function(t){if(0===this.length)return xi.alloc(0);for(var e,i,r,n=xi.allocUnsafe(t>>>0),s=this.head,o=0;s;)e=s.data,i=n,r=o,xi.prototype.copy.call(e,i,r),o+=s.data.length,s=s.next;return n}},{key:"consume",value:function(t,e){var i;return tn.length?n.length:t;if(s===n.length?r+=n:r+=n.slice(0,t),0==(t-=s)){s===n.length?(++i,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=n.slice(s));break}++i}return this.length-=i,r}},{key:"_getBuffer",value:function(t){var e=xi.allocUnsafe(t),i=this.head,r=1;for(i.data.copy(e),t-=i.data.length;i=i.next;){var n=i.data,s=t>n.length?n.length:t;if(n.copy(e,e.length-t,0,s),0==(t-=s)){s===n.length?(++r,i.next?this.head=i.next:this.head=this.tail=null):(this.head=i,i.data=n.slice(s));break}++r}return this.length-=r,e}},{key:Pi,value:function(t,e){return Ti(this,function(t){for(var e=1;e2?"one of ".concat(e," ").concat(t.slice(0,i-1).join(", "),", or ")+t[i-1]:2===i?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}Li("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),Li("ERR_INVALID_ARG_TYPE",(function(t,e,i){var r,n,s,o;if("string"==typeof e&&("not ","not "===e.substr(0,"not ".length))?(r="must not be",e=e.replace(/^not /,"")):r="must be",s=t,(void 0===o||o>s.length)&&(o=s.length)," argument"===s.substring(o-" argument".length,o))n="The ".concat(t," ").concat(r," ").concat(ji(e,"type"));else{var a=function(t,e,i){return"number"!=typeof i&&(i=0),!(i+".".length>t.length)&&-1!==t.indexOf(".",i)}(t)?"property":"argument";n='The "'.concat(t,'" ').concat(a," ").concat(r," ").concat(ji(e,"type"))}return n+". Received type ".concat(typeof i)}),TypeError),Li("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),Li("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),Li("ERR_STREAM_PREMATURE_CLOSE","Premature close"),Li("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),Li("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),Li("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),Li("ERR_STREAM_WRITE_AFTER_END","write after end"),Li("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),Li("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),Li("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),qi.codes=Oi;var Ci=qi.codes.ERR_INVALID_OPT_VALUE,Ni={getHighWaterMark:function(t,e,i,r){var n=function(t,e,i){return null!=t.highWaterMark?t.highWaterMark:e?t[i]:null}(e,r,i);if(null!=n){if(!isFinite(n)||Math.floor(n)!==n||n<0)throw new Ci(r?i:"highWaterMark",n);return Math.floor(n)}return t.objectMode?16:16384}},Di=Zi,Ui=qi.codes,$i=Ui.ERR_METHOD_NOT_IMPLEMENTED,zi=Ui.ERR_MULTIPLE_CALLBACK,Wi=Ui.ERR_TRANSFORM_ALREADY_TRANSFORMING,Fi=Ui.ERR_TRANSFORM_WITH_LENGTH_0,Ki=l({});function Hi(t,e){var i=this._transformState;i.transforming=!1;var r=i.writecb;if(null===r)return this.emit("error",new zi);i.writechunk=null,i.writecb=null,null!=e&&this.push(e),r(t);var n=this._readableState;n.reading=!1,(n.needReadable||n.length0,(function(t){r||(r=t),t&&s.forEach(rr),o||(s.forEach(rr),n(r))}))}));return e.reduce(nr)},ar.Stream=ar,ar.prototype.pipe=function(t,e){var i=this;function r(e){t.writable&&!1===t.write(e)&&i.pause&&i.pause()}function n(){i.readable&&i.resume&&i.resume()}i.on("data",r),t.on("drain",n),t._isStdio||e&&!1===e.end||(i.on("end",o),i.on("close",a));var s=!1;function o(){s||(s=!0,t.end())}function a(){s||(s=!0,"function"==typeof t.destroy&&t.destroy())}function h(t){if(u(),0===or.listenerCount(this,"error"))throw t}function u(){i.removeListener("data",r),t.removeListener("drain",n),i.removeListener("end",o),i.removeListener("close",a),i.removeListener("error",h),t.removeListener("error",h),i.removeListener("end",u),i.removeListener("close",u),t.removeListener("close",u)}return i.on("error",h),t.on("error",h),i.on("end",u),i.on("close",u),t.on("close",u),t.emit("pipe",i),t};var hr={},ur=I.Buffer,fr=sr.Transform,lr=v({}).StringDecoder;function dr(t){fr.call(this),this.hashMode="string"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}Q(dr,fr),dr.prototype.update=function(t,e,i){"string"==typeof t&&(t=ur.from(t,e));var r=this._update(t);return this.hashMode?this:(i&&(r=this._toString(r,i)),r)},dr.prototype.setAutoPadding=function(){},dr.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},dr.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},dr.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},dr.prototype._transform=function(t,e,i){var r;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(n){r=n}finally{i(r)}},dr.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(i){e=i}t(e)},dr.prototype._finalOrDigest=function(t){var e=this.__final()||ur.alloc(0);return t&&(e=this._toString(e,t,!0)),e},dr.prototype._toString=function(t,e,i){if(this._decoder||(this._decoder=new lr(e),this._encoding=e),this._encoding!==e)throw new Error("can't switch encodings");var r=this._decoder.write(t);return i&&(r+=this._decoder.end()),r};var cr;function pr(t){hr.call(this,"digest"),this._hash=t}Q(pr,hr=dr),pr.prototype._update=function(t){this._hash.update(t)},pr.prototype._final=function(){return this._hash.digest()},cr=function(t){return"md5"===(t=t.toLowerCase())?new ee:"rmd160"===t||"ripemd160"===t?new fe:new pr(_i(t))};var mr={},gr=I.Buffer,vr=gr.alloc(128);function br(t,e){hr.call(this,"digest"),"string"==typeof e&&(e=gr.from(e)),this._alg=t,this._key=e,e.length>64?e=t(e):e.length<64&&(e=gr.concat([e,vr],64));for(var i=this._ipad=gr.allocUnsafe(64),r=this._opad=gr.allocUnsafe(64),n=0;n<64;n++)i[n]=54^e[n],r[n]=92^e[n];this._hash=[i]}Q(br,hr),br.prototype._update=function(t){this._hash.push(t)},br.prototype._final=function(){var t=this._alg(gr.concat(this._hash));return this._alg(gr.concat([this._opad,t]))},mr=br;var yr,wr=function(t){return(new ee).update(t).digest()},Mr=I.Buffer,_r=Mr.alloc(128);function Sr(t,e){hr.call(this,"digest"),"string"==typeof e&&(e=Mr.from(e));var i="sha512"===t||"sha384"===t?128:64;this._alg=t,this._key=e,e.length>i?e=("rmd160"===t?new fe:_i(t)).update(e).digest():e.lengthRr||e!=e)throw new TypeError("Bad key length")},xr={};(function(t){(function(){var e;e=t.browser?"utf-8":t.version?parseInt(t.version.split(".")[0].slice(1),10)>=6?"utf-8":"binary":"utf-8",xr=e}).call(this)}).call(this,D);var Tr,Pr=I.Buffer,Br=function(t,e,i){if(Pr.isBuffer(t))return t;if("string"==typeof t)return Pr.from(t,e);if(ArrayBuffer.isView(t))return Pr.from(t.buffer);throw new TypeError(i+" must be a string, a Buffer, a typed array or a DataView")},Ir=I.Buffer,qr=Ir.alloc(128),Or={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function Lr(t,e,i){var r=function(t){return"rmd160"===t||"ripemd160"===t?function(t){return(new fe).update(t).digest()}:"md5"===t?wr:function(e){return _i(t).update(e).digest()}}(t),n="sha512"===t||"sha384"===t?128:64;e.length>n?e=r(e):e.length>>0},writeUInt32BE:function(t,e,i){t[0+i]=e>>>24,t[1+i]=e>>>16&255,t[2+i]=e>>>8&255,t[3+i]=255&e},ip:function(t,e,i,r){for(var n=0,s=0,o=6;o>=0;o-=2){for(var a=0;a<=24;a+=8)n<<=1,n|=e>>>a+o&1;for(a=0;a<=24;a+=8)n<<=1,n|=t>>>a+o&1}for(o=6;o>=0;o-=2){for(a=1;a<=25;a+=8)s<<=1,s|=e>>>a+o&1;for(a=1;a<=25;a+=8)s<<=1,s|=t>>>a+o&1}i[r+0]=n>>>0,i[r+1]=s>>>0},rip:function(t,e,i,r){for(var n=0,s=0,o=0;o<4;o++)for(var a=24;a>=0;a-=8)n<<=1,n|=e>>>a+o&1,n<<=1,n|=t>>>a+o&1;for(o=4;o<8;o++)for(a=24;a>=0;a-=8)s<<=1,s|=e>>>a+o&1,s<<=1,s|=t>>>a+o&1;i[r+0]=n>>>0,i[r+1]=s>>>0},pc1:function(t,e,i,r){for(var n=0,s=0,o=7;o>=5;o--){for(var a=0;a<=24;a+=8)n<<=1,n|=e>>a+o&1;for(a=0;a<=24;a+=8)n<<=1,n|=t>>a+o&1}for(a=0;a<=24;a+=8)n<<=1,n|=e>>a+o&1;for(o=1;o<=3;o++){for(a=0;a<=24;a+=8)s<<=1,s|=e>>a+o&1;for(a=0;a<=24;a+=8)s<<=1,s|=t>>a+o&1}for(a=0;a<=24;a+=8)s<<=1,s|=t>>a+o&1;i[r+0]=n>>>0,i[r+1]=s>>>0},r28shl:function(t,e){return t<>>28-e}},Nr=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];Cr.pc2=function(t,e,i,r){for(var n=0,s=0,o=Nr.length>>>1,a=0;a>>Nr[a]&1;for(a=o;a>>Nr[a]&1;i[r+0]=n>>>0,i[r+1]=s>>>0},Cr.expand=function(t,e,i){var r=0,n=0;r=(1&t)<<5|t>>>27;for(var s=23;s>=15;s-=4)r<<=6,r|=t>>>s&63;for(s=11;s>=3;s-=4)n|=t>>>s&63,n<<=6;n|=(31&t)<<1|t>>>31,e[i+0]=r>>>0,e[i+1]=n>>>0};var Dr=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];Cr.substitute=function(t,e){for(var i=0,r=0;r<4;r++)i<<=4,i|=Dr[64*r+(t>>>18-6*r&63)];for(r=0;r<4;r++)i<<=4,i|=Dr[256+64*r+(e>>>18-6*r&63)];return i>>>0};var Ur=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];Cr.permute=function(t){for(var e=0,i=0;i>>Ur[i]&1;return e>>>0},Cr.padSplit=function(t,e,i){for(var r=t.toString(2);r.length0;r--)e+=this._buffer(t,e),i+=this._flushBuffer(n,i);return e+=this._buffer(t,e),n},Fr.prototype.final=function(t){var e,i;return t&&(e=this.update(t)),i="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),e?e.concat(i):i},Fr.prototype._pad=function(t,e){if(0===e)return!1;for(;e>>1];i=Cr.r28shl(i,s),r=Cr.r28shl(r,s),Cr.pc2(i,r,t.keys,n)}},Zr.prototype._update=function(t,e,i,r){var n=this._desState,s=Cr.readUInt32BE(t,e),o=Cr.readUInt32BE(t,e+4);Cr.ip(s,o,n.tmp,0),s=n.tmp[0],o=n.tmp[1],"encrypt"===this.type?this._encrypt(n,s,o,n.tmp,0):this._decrypt(n,s,o,n.tmp,0),s=n.tmp[0],o=n.tmp[1],Cr.writeUInt32BE(i,s,r),Cr.writeUInt32BE(i,o,r+4)},Zr.prototype._pad=function(t,e){for(var i=t.length-e,r=e;r>>0,s=l}Cr.rip(o,s,r,n)},Zr.prototype._decrypt=function(t,e,i,r,n){for(var s=i,o=e,a=t.keys.length-2;a>=0;a-=2){var h=t.keys[a],u=t.keys[a+1];Cr.expand(s,t.tmp,0),h^=t.tmp[0],u^=t.tmp[1];var f=Cr.substitute(h,u),l=s;s=(o^Cr.permute(f))>>>0,o=l}Cr.rip(s,o,r,n)};var Gr={},Yr={};function Xr(t){this.iv=new Array(8);for(var e=0;e>s%8,t._prev=bn(t._prev,i?r:n);return o}function bn(t,e){var i=t.length,r=-1,n=gn.allocUnsafe(t.length);for(t=gn.concat([t,gn.from([e])]);++r>7;return n}mn.encrypt=function(t,e,i){for(var r=e.length,n=gn.allocUnsafe(r),s=-1;++s>>24]^f[p>>>16&255]^l[m>>>8&255]^d[255&g]^e[v++],o=u[p>>>24]^f[m>>>16&255]^l[g>>>8&255]^d[255&c]^e[v++],a=u[m>>>24]^f[g>>>16&255]^l[c>>>8&255]^d[255&p]^e[v++],h=u[g>>>24]^f[c>>>16&255]^l[p>>>8&255]^d[255&m]^e[v++],c=s,p=o,m=a,g=h;return s=(r[c>>>24]<<24|r[p>>>16&255]<<16|r[m>>>8&255]<<8|r[255&g])^e[v++],o=(r[p>>>24]<<24|r[m>>>16&255]<<16|r[g>>>8&255]<<8|r[255&c])^e[v++],a=(r[m>>>24]<<24|r[g>>>16&255]<<16|r[c>>>8&255]<<8|r[255&p])^e[v++],h=(r[g>>>24]<<24|r[c>>>16&255]<<16|r[p>>>8&255]<<8|r[255&m])^e[v++],[s>>>=0,o>>>=0,a>>>=0,h>>>=0]}var In=[0,1,2,4,8,16,32,64,128,27,54],qn=function(){for(var t=new Array(256),e=0;e<256;e++)t[e]=e<128?e<<1:e<<1^283;for(var i=[],r=[],n=[[],[],[],[]],s=[[],[],[],[]],o=0,a=0,h=0;h<256;++h){var u=a^a<<1^a<<2^a<<3^a<<4;u=u>>>8^255&u^99,i[o]=u,r[u]=o;var f=t[o],l=t[f],d=t[l],c=257*t[u]^16843008*u;n[0][o]=c<<24|c>>>8,n[1][o]=c<<16|c>>>16,n[2][o]=c<<8|c>>>24,n[3][o]=c,c=16843009*d^65537*l^257*f^16843008*o,s[0][u]=c<<24|c>>>8,s[1][u]=c<<16|c>>>16,s[2][u]=c<<8|c>>>24,s[3][u]=c,0===o?o=a=1:(o=f^t[t[t[d^f]]],a^=t[t[a]])}return{SBOX:i,INV_SBOX:r,SUB_MIX:n,INV_SUB_MIX:s}}();function On(t){this._key=Tn(t),this._reset()}On.blockSize=16,On.keySize=32,On.prototype.blockSize=On.blockSize,On.prototype.keySize=On.keySize,On.prototype._reset=function(){for(var t=this._key,e=t.length,i=e+6,r=4*(i+1),n=[],s=0;s>>24,o=qn.SBOX[o>>>24]<<24|qn.SBOX[o>>>16&255]<<16|qn.SBOX[o>>>8&255]<<8|qn.SBOX[255&o],o^=In[s/e|0]<<24):e>6&&s%e==4&&(o=qn.SBOX[o>>>24]<<24|qn.SBOX[o>>>16&255]<<16|qn.SBOX[o>>>8&255]<<8|qn.SBOX[255&o]),n[s]=n[s-e]^o}for(var a=[],h=0;h>>24]]^qn.INV_SUB_MIX[1][qn.SBOX[f>>>16&255]]^qn.INV_SUB_MIX[2][qn.SBOX[f>>>8&255]]^qn.INV_SUB_MIX[3][qn.SBOX[255&f]]}this._nRounds=i,this._keySchedule=n,this._invKeySchedule=a},On.prototype.encryptBlockRaw=function(t){return Bn(t=Tn(t),this._keySchedule,qn.SUB_MIX,qn.SBOX,this._nRounds)},On.prototype.encryptBlock=function(t){var e=this.encryptBlockRaw(t),i=xn.allocUnsafe(16);return i.writeUInt32BE(e[0],0),i.writeUInt32BE(e[1],4),i.writeUInt32BE(e[2],8),i.writeUInt32BE(e[3],12),i},On.prototype.decryptBlock=function(t){var e=(t=Tn(t))[1];t[1]=t[3],t[3]=e;var i=Bn(t,this._invKeySchedule,qn.INV_SUB_MIX,qn.INV_SBOX,this._nRounds),r=xn.allocUnsafe(16);return r.writeUInt32BE(i[0],0),r.writeUInt32BE(i[3],4),r.writeUInt32BE(i[2],8),r.writeUInt32BE(i[1],12),r},On.prototype.scrub=function(){Pn(this._keySchedule),Pn(this._invKeySchedule),Pn(this._key)},An.AES=On;var Ln={},jn=I.Buffer,Cn=jn.alloc(16,0);function Nn(t){var e=jn.allocUnsafe(16);return e.writeUInt32BE(t[0]>>>0,0),e.writeUInt32BE(t[1]>>>0,4),e.writeUInt32BE(t[2]>>>0,8),e.writeUInt32BE(t[3]>>>0,12),e}function Dn(t){this.h=t,this.state=jn.alloc(16,0),this.cache=jn.allocUnsafe(0)}Dn.prototype.ghash=function(t){for(var e=-1;++e0;e--)r[e]=r[e]>>>1|(1&r[e-1])<<31;r[0]=r[0]>>>1,i&&(r[0]=r[0]^225<<24)}this.state=Nn(n)},Dn.prototype.update=function(t){var e;for(this.cache=jn.concat([this.cache,t]);this.cache.length>=16;)e=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(e)},Dn.prototype.final=function(t,e){return this.cache.length&&this.ghash(jn.concat([this.cache,Cn],16)),this.ghash(Nn([0,t,0,e])),this.state},Ln=Dn;var Un=I.Buffer;function $n(t,e,i,r){hr.call(this);var n=Un.alloc(4,0);this._cipher=new An.AES(e);var s=this._cipher.encryptBlock(n);this._ghash=new Ln(s),i=function(t,e,i){if(12===e.length)return t._finID=Un.concat([e,Un.from([0,0,0,1])]),Un.concat([e,Un.from([0,0,0,2])]);var r=new Ln(i),n=e.length,s=n%16;r.update(e),s&&(s=16-s,r.update(Un.alloc(s,0))),r.update(Un.alloc(8,0));var o=8*n,a=Un.alloc(8);a.writeUIntBE(o,0,8),r.update(a),t._finID=r.state;var h=Un.from(t._finID);return wn(h),h}(this,i,s),this._prev=Un.from(i),this._cache=Un.allocUnsafe(0),this._secCache=Un.allocUnsafe(0),this._decrypt=r,this._alen=0,this._len=0,this._mode=t,this._authTag=null,this._called=!1}Q($n,hr),$n.prototype._update=function(t){if(!this._called&&this._alen){var e=16-this._alen%16;e<16&&(e=Un.alloc(e,0),this._ghash.update(e))}this._called=!0;var i=this._mode.encrypt(this,t);return this._decrypt?this._ghash.update(t):this._ghash.update(i),this._len+=t.length,i},$n.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var t=an(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(t,e){var i=0;t.length!==e.length&&i++;for(var r=Math.min(t.length,e.length),n=0;n0||r>0;){var h=new ee;h.update(a),h.update(t),e&&h.update(e),a=h.digest();var u=0;if(n>0){var f=s.length-n;u=Math.min(n,a.length),a.copy(s,f,0,u),n-=u}if(u0){var l=o.length-r,d=Math.min(r,a.length-u);a.copy(o,l,u,u+d),r-=d}}return a.fill(0),{key:s,iv:o}},Hn={},Zn=I.Buffer;function Vn(t,e,i){hr.call(this),this._cache=new Yn,this._cipher=new An.AES(e),this._prev=Zn.from(i),this._mode=t,this._autopadding=!0}Q(Vn,hr),Vn.prototype._update=function(t){var e,i;this._cache.add(t);for(var r=[];e=this._cache.get();)i=this._mode.encrypt(this,e),r.push(i);return Zn.concat(r)};var Gn=Zn.alloc(16,16);function Yn(){this.cache=Zn.allocUnsafe(0)}Vn.prototype._final=function(){var t=this._cache.flush();if(this._autopadding)return t=this._mode.encrypt(this,t),this._cipher.scrub(),t;if(!t.equals(Gn))throw this._cipher.scrub(),new Error("data not multiple of block length")},Vn.prototype.setAutoPadding=function(t){return this._autopadding=!!t,this},Yn.prototype.add=function(t){this.cache=Zn.concat([this.cache,t])},Yn.prototype.get=function(){if(this.cache.length>15){var t=this.cache.slice(0,16);return this.cache=this.cache.slice(16),t}return null},Yn.prototype.flush=function(){for(var t=16-this.cache.length,e=Zn.allocUnsafe(t),i=-1;++i16)throw new Error("unable to decrypt data");for(var i=-1;++i16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e}else if(this.cache.length>=16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e;return null},ts.prototype.flush=function(){if(this.cache.length)return this.cache};var es={};es.createCipheriv=Hn.createCipheriv,es.createDecipheriv=Xn.createDecipheriv;var is={"des-ecb":{key:8,iv:0}};is["des-cbc"]=is.des={key:8,iv:8},is["des-ede3-cbc"]=is.des3={key:24,iv:8},is["des-ede3"]={key:24,iv:0},is["des-ede-cbc"]={key:16,iv:8},is["des-ede"]={key:16,iv:0};var rs={exports:{}};!function(t,e){"use strict";function i(t,e){t.super_=e;var i=function(){};i.prototype=e.prototype,t.prototype=new i,t.prototype.constructor=t}function r(t,e,i){if(r.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(i=e,e=10),this._init(t||0,e||10,i||"be"))}var n;"object"==typeof t?t.exports=r:e.BN=r,r.BN=r,r.wordSize=26;try{n=w({}).Buffer}catch(S){}function s(t,e,i){for(var r=0,n=Math.min(t.length,i),s=e;s=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return r}function o(t,e,i,r){for(var n=0,s=Math.min(t.length,i),o=e;o=49?a-49+10:a>=17?a-17+10:a}return n}r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,e){return t.cmp(e)>0?t:e},r.min=function(t,e){return t.cmp(e)<0?t:e},r.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===e?this._parseHex(t,r):this._parseBase(t,e,r),"-"===t[0]&&(this.negative=1),this.strip(),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initArray=function(t,e,i){if(t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r=0;r-=3)s=t[r]|t[r-1]<<8|t[r-2]<<16,this.words[n]|=s<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===i)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this.strip()},r.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=6)n=s(t,i,i+6),this.words[r]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,r++);i+6!==e&&(n=s(t,e,i+6),this.words[r]|=n<>>26-o&4194303),this.strip()},r.prototype._parseBase=function(t,e,i){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=e)r++;r--,n=n/e|0;for(var s=t.length-i,a=s%r,h=Math.min(s,s-a)+i,u=0,f=i;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},r.prototype.inspect=function(){return(this.red?""};var a=["","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"],h=[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],u=[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 f(t,e,i){i.negative=e.negative^t.negative;var r=t.length+e.length|0;i.length=r,r=r-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;i.words[0]=a;for(var u=1;u>>26,l=67108863&h,d=Math.min(u,e.length-1),c=Math.max(0,u-t.length+1);c<=d;c++){var p=u-c|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[c])+l)/67108864|0,l=67108863&o}i.words[u]=0|l,h=0|f}return 0!==h?i.words[u]=0|h:i.length--,i.strip()}r.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var r=0,n=0,s=0;s>>24-r&16777215)||s!==this.length-1?a[6-f.length]+f+i:f+i,(r+=2)>=26&&(r-=26,s--)}for(0!==n&&(i=n.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var l=h[t],d=u[t];i="";var c=this.clone();for(c.negative=0;!c.isZero();){var p=c.modn(d).toString(t);i=(c=c.idivn(d)).isZero()?p+i:a[l-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length,0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16)},r.prototype.toBuffer=function(t,e){return this.toArrayLike(n,t,e)},r.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},r.prototype.toArrayLike=function(t,e,i){var r=this.byteLength(),n=i||Math.max(1,r);this.strip();var s,o,a="le"===e,h=new t(n),u=this.clone();if(a){for(o=0;!u.isZero();o++)s=u.andln(255),u.iushrn(8),h[o]=s;for(;o=4096&&(i+=13,e>>>=13),e>=64&&(i+=7,e>>>=7),e>=8&&(i+=4,e>>>=4),e>=2&&(i+=2,e>>>=2),i+e},r.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,i=0;return 0==(8191&e)&&(i+=13,e>>>=13),0==(127&e)&&(i+=7,e>>>=7),0==(15&e)&&(i+=4,e>>>=4),0==(3&e)&&(i+=2,e>>>=2),0==(1&e)&&i++,i},r.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var i=0;it.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var e,i;this.length>t.length?(e=this,i=t):(e=t,i=this);for(var r=0;rt.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-i),this.strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,e){var i=t/26|0,r=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(i=this,r=t):(i=t,r=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i,r,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(i=this,r=t):(i=t,r=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,c=0|o[1],p=8191&c,m=c>>>13,g=0|o[2],v=8191&g,b=g>>>13,y=0|o[3],w=8191&y,M=y>>>13,_=0|o[4],S=8191&_,E=_>>>13,k=0|o[5],R=8191&k,A=k>>>13,x=0|o[6],T=8191&x,P=x>>>13,B=0|o[7],I=8191&B,q=B>>>13,O=0|o[8],L=8191&O,j=O>>>13,C=0|o[9],N=8191&C,D=C>>>13,U=0|a[0],$=8191&U,z=U>>>13,W=0|a[1],F=8191&W,K=W>>>13,H=0|a[2],Z=8191&H,V=H>>>13,G=0|a[3],Y=8191&G,X=G>>>13,J=0|a[4],Q=8191&J,tt=J>>>13,et=0|a[5],it=8191&et,rt=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,ft=0|a[8],lt=8191&ft,dt=ft>>>13,ct=0|a[9],pt=8191&ct,mt=ct>>>13;i.negative=t.negative^e.negative,i.length=19;var gt=(u+(r=Math.imul(l,$))|0)+((8191&(n=(n=Math.imul(l,z))+Math.imul(d,$)|0))<<13)|0;u=((s=Math.imul(d,z))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(p,$),n=(n=Math.imul(p,z))+Math.imul(m,$)|0,s=Math.imul(m,z);var vt=(u+(r=r+Math.imul(l,F)|0)|0)+((8191&(n=(n=n+Math.imul(l,K)|0)+Math.imul(d,F)|0))<<13)|0;u=((s=s+Math.imul(d,K)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(v,$),n=(n=Math.imul(v,z))+Math.imul(b,$)|0,s=Math.imul(b,z),r=r+Math.imul(p,F)|0,n=(n=n+Math.imul(p,K)|0)+Math.imul(m,F)|0,s=s+Math.imul(m,K)|0;var bt=(u+(r=r+Math.imul(l,Z)|0)|0)+((8191&(n=(n=n+Math.imul(l,V)|0)+Math.imul(d,Z)|0))<<13)|0;u=((s=s+Math.imul(d,V)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(w,$),n=(n=Math.imul(w,z))+Math.imul(M,$)|0,s=Math.imul(M,z),r=r+Math.imul(v,F)|0,n=(n=n+Math.imul(v,K)|0)+Math.imul(b,F)|0,s=s+Math.imul(b,K)|0,r=r+Math.imul(p,Z)|0,n=(n=n+Math.imul(p,V)|0)+Math.imul(m,Z)|0,s=s+Math.imul(m,V)|0;var yt=(u+(r=r+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,X)|0)+Math.imul(d,Y)|0))<<13)|0;u=((s=s+Math.imul(d,X)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(S,$),n=(n=Math.imul(S,z))+Math.imul(E,$)|0,s=Math.imul(E,z),r=r+Math.imul(w,F)|0,n=(n=n+Math.imul(w,K)|0)+Math.imul(M,F)|0,s=s+Math.imul(M,K)|0,r=r+Math.imul(v,Z)|0,n=(n=n+Math.imul(v,V)|0)+Math.imul(b,Z)|0,s=s+Math.imul(b,V)|0,r=r+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,X)|0;var wt=(u+(r=r+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(d,Q)|0))<<13)|0;u=((s=s+Math.imul(d,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(R,$),n=(n=Math.imul(R,z))+Math.imul(A,$)|0,s=Math.imul(A,z),r=r+Math.imul(S,F)|0,n=(n=n+Math.imul(S,K)|0)+Math.imul(E,F)|0,s=s+Math.imul(E,K)|0,r=r+Math.imul(w,Z)|0,n=(n=n+Math.imul(w,V)|0)+Math.imul(M,Z)|0,s=s+Math.imul(M,V)|0,r=r+Math.imul(v,Y)|0,n=(n=n+Math.imul(v,X)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,X)|0,r=r+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var Mt=(u+(r=r+Math.imul(l,it)|0)|0)+((8191&(n=(n=n+Math.imul(l,rt)|0)+Math.imul(d,it)|0))<<13)|0;u=((s=s+Math.imul(d,rt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(T,$),n=(n=Math.imul(T,z))+Math.imul(P,$)|0,s=Math.imul(P,z),r=r+Math.imul(R,F)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(A,F)|0,s=s+Math.imul(A,K)|0,r=r+Math.imul(S,Z)|0,n=(n=n+Math.imul(S,V)|0)+Math.imul(E,Z)|0,s=s+Math.imul(E,V)|0,r=r+Math.imul(w,Y)|0,n=(n=n+Math.imul(w,X)|0)+Math.imul(M,Y)|0,s=s+Math.imul(M,X)|0,r=r+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,tt)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,tt)|0,r=r+Math.imul(p,it)|0,n=(n=n+Math.imul(p,rt)|0)+Math.imul(m,it)|0,s=s+Math.imul(m,rt)|0;var _t=(u+(r=r+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(d,st)|0))<<13)|0;u=((s=s+Math.imul(d,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(I,$),n=(n=Math.imul(I,z))+Math.imul(q,$)|0,s=Math.imul(q,z),r=r+Math.imul(T,F)|0,n=(n=n+Math.imul(T,K)|0)+Math.imul(P,F)|0,s=s+Math.imul(P,K)|0,r=r+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,V)|0)+Math.imul(A,Z)|0,s=s+Math.imul(A,V)|0,r=r+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,X)|0,r=r+Math.imul(w,Q)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(M,Q)|0,s=s+Math.imul(M,tt)|0,r=r+Math.imul(v,it)|0,n=(n=n+Math.imul(v,rt)|0)+Math.imul(b,it)|0,s=s+Math.imul(b,rt)|0,r=r+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(r=r+Math.imul(l,ht)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((s=s+Math.imul(d,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(L,$),n=(n=Math.imul(L,z))+Math.imul(j,$)|0,s=Math.imul(j,z),r=r+Math.imul(I,F)|0,n=(n=n+Math.imul(I,K)|0)+Math.imul(q,F)|0,s=s+Math.imul(q,K)|0,r=r+Math.imul(T,Z)|0,n=(n=n+Math.imul(T,V)|0)+Math.imul(P,Z)|0,s=s+Math.imul(P,V)|0,r=r+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,X)|0,r=r+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(E,Q)|0,s=s+Math.imul(E,tt)|0,r=r+Math.imul(w,it)|0,n=(n=n+Math.imul(w,rt)|0)+Math.imul(M,it)|0,s=s+Math.imul(M,rt)|0,r=r+Math.imul(v,st)|0,n=(n=n+Math.imul(v,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,r=r+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,ut)|0;var Et=(u+(r=r+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,dt)|0)+Math.imul(d,lt)|0))<<13)|0;u=((s=s+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(N,$),n=(n=Math.imul(N,z))+Math.imul(D,$)|0,s=Math.imul(D,z),r=r+Math.imul(L,F)|0,n=(n=n+Math.imul(L,K)|0)+Math.imul(j,F)|0,s=s+Math.imul(j,K)|0,r=r+Math.imul(I,Z)|0,n=(n=n+Math.imul(I,V)|0)+Math.imul(q,Z)|0,s=s+Math.imul(q,V)|0,r=r+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,X)|0,r=r+Math.imul(R,Q)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(A,Q)|0,s=s+Math.imul(A,tt)|0,r=r+Math.imul(S,it)|0,n=(n=n+Math.imul(S,rt)|0)+Math.imul(E,it)|0,s=s+Math.imul(E,rt)|0,r=r+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(M,st)|0,s=s+Math.imul(M,ot)|0,r=r+Math.imul(v,ht)|0,n=(n=n+Math.imul(v,ut)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ut)|0,r=r+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,dt)|0;var kt=(u+(r=r+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(d,pt)|0))<<13)|0;u=((s=s+Math.imul(d,mt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(N,F),n=(n=Math.imul(N,K))+Math.imul(D,F)|0,s=Math.imul(D,K),r=r+Math.imul(L,Z)|0,n=(n=n+Math.imul(L,V)|0)+Math.imul(j,Z)|0,s=s+Math.imul(j,V)|0,r=r+Math.imul(I,Y)|0,n=(n=n+Math.imul(I,X)|0)+Math.imul(q,Y)|0,s=s+Math.imul(q,X)|0,r=r+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(P,Q)|0,s=s+Math.imul(P,tt)|0,r=r+Math.imul(R,it)|0,n=(n=n+Math.imul(R,rt)|0)+Math.imul(A,it)|0,s=s+Math.imul(A,rt)|0,r=r+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(E,st)|0,s=s+Math.imul(E,ot)|0,r=r+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(M,ht)|0,s=s+Math.imul(M,ut)|0,r=r+Math.imul(v,lt)|0,n=(n=n+Math.imul(v,dt)|0)+Math.imul(b,lt)|0,s=s+Math.imul(b,dt)|0;var Rt=(u+(r=r+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(N,Z),n=(n=Math.imul(N,V))+Math.imul(D,Z)|0,s=Math.imul(D,V),r=r+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(j,Y)|0,s=s+Math.imul(j,X)|0,r=r+Math.imul(I,Q)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(q,Q)|0,s=s+Math.imul(q,tt)|0,r=r+Math.imul(T,it)|0,n=(n=n+Math.imul(T,rt)|0)+Math.imul(P,it)|0,s=s+Math.imul(P,rt)|0,r=r+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(A,st)|0,s=s+Math.imul(A,ot)|0,r=r+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(E,ht)|0,s=s+Math.imul(E,ut)|0,r=r+Math.imul(w,lt)|0,n=(n=n+Math.imul(w,dt)|0)+Math.imul(M,lt)|0,s=s+Math.imul(M,dt)|0;var At=(u+(r=r+Math.imul(v,pt)|0)|0)+((8191&(n=(n=n+Math.imul(v,mt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((s=s+Math.imul(b,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(N,Y),n=(n=Math.imul(N,X))+Math.imul(D,Y)|0,s=Math.imul(D,X),r=r+Math.imul(L,Q)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(j,Q)|0,s=s+Math.imul(j,tt)|0,r=r+Math.imul(I,it)|0,n=(n=n+Math.imul(I,rt)|0)+Math.imul(q,it)|0,s=s+Math.imul(q,rt)|0,r=r+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,ot)|0,r=r+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(A,ht)|0,s=s+Math.imul(A,ut)|0,r=r+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,dt)|0)+Math.imul(E,lt)|0,s=s+Math.imul(E,dt)|0;var xt=(u+(r=r+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((s=s+Math.imul(M,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(N,Q),n=(n=Math.imul(N,tt))+Math.imul(D,Q)|0,s=Math.imul(D,tt),r=r+Math.imul(L,it)|0,n=(n=n+Math.imul(L,rt)|0)+Math.imul(j,it)|0,s=s+Math.imul(j,rt)|0,r=r+Math.imul(I,st)|0,n=(n=n+Math.imul(I,ot)|0)+Math.imul(q,st)|0,s=s+Math.imul(q,ot)|0,r=r+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,ut)|0,r=r+Math.imul(R,lt)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(A,lt)|0,s=s+Math.imul(A,dt)|0;var Tt=(u+(r=r+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(E,pt)|0))<<13)|0;u=((s=s+Math.imul(E,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(N,it),n=(n=Math.imul(N,rt))+Math.imul(D,it)|0,s=Math.imul(D,rt),r=r+Math.imul(L,st)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(j,st)|0,s=s+Math.imul(j,ot)|0,r=r+Math.imul(I,ht)|0,n=(n=n+Math.imul(I,ut)|0)+Math.imul(q,ht)|0,s=s+Math.imul(q,ut)|0,r=r+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,dt)|0)+Math.imul(P,lt)|0,s=s+Math.imul(P,dt)|0;var Pt=(u+(r=r+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((s=s+Math.imul(A,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(N,st),n=(n=Math.imul(N,ot))+Math.imul(D,st)|0,s=Math.imul(D,ot),r=r+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,ut)|0)+Math.imul(j,ht)|0,s=s+Math.imul(j,ut)|0,r=r+Math.imul(I,lt)|0,n=(n=n+Math.imul(I,dt)|0)+Math.imul(q,lt)|0,s=s+Math.imul(q,dt)|0;var Bt=(u+(r=r+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((s=s+Math.imul(P,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(N,ht),n=(n=Math.imul(N,ut))+Math.imul(D,ht)|0,s=Math.imul(D,ut),r=r+Math.imul(L,lt)|0,n=(n=n+Math.imul(L,dt)|0)+Math.imul(j,lt)|0,s=s+Math.imul(j,dt)|0;var It=(u+(r=r+Math.imul(I,pt)|0)|0)+((8191&(n=(n=n+Math.imul(I,mt)|0)+Math.imul(q,pt)|0))<<13)|0;u=((s=s+Math.imul(q,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(N,lt),n=(n=Math.imul(N,dt))+Math.imul(D,lt)|0,s=Math.imul(D,dt);var qt=(u+(r=r+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,mt)|0)+Math.imul(j,pt)|0))<<13)|0;u=((s=s+Math.imul(j,mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863;var Ot=(u+(r=Math.imul(N,pt))|0)+((8191&(n=(n=Math.imul(N,mt))+Math.imul(D,pt)|0))<<13)|0;return u=((s=Math.imul(D,mt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=vt,h[2]=bt,h[3]=yt,h[4]=wt,h[5]=Mt,h[6]=_t,h[7]=St,h[8]=Et,h[9]=kt,h[10]=Rt,h[11]=At,h[12]=xt,h[13]=Tt,h[14]=Pt,h[15]=Bt,h[16]=It,h[17]=qt,h[18]=Ot,0!==u&&(h[19]=u,i.length++),i};function d(t,e,i){return(new c).mulp(t,e,i)}function c(t,e){this.x=t,this.y=e}Math.imul||(l=f),r.prototype.mulTo=function(t,e){var i=this.length+t.length;return 10===this.length&&10===t.length?l(this,t,e):i<63?f(this,t,e):i<1024?function(t,e,i){i.negative=e.negative^t.negative,i.length=t.length+e.length;for(var r=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}i.words[s]=a,r=o,o=n}return 0!==r?i.words[s]=r:i.length--,i.strip()}(this,t,e):d(this,t,e)},c.prototype.makeRBT=function(t){for(var e=new Array(t),i=r.prototype._countBits(t)-1,n=0;n>=1;return r},c.prototype.permute=function(t,e,i,r,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*s+1]=8191&n,n>>>=13;for(s=2*e;s>=26,e+=r/67108864|0,e+=n>>>26,this.words[i]=67108863&n}return 0!==e&&(this.words[i]=e,this.length++),this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),i=0;i>>n}return e}(t);if(0===e.length)return new r(1);for(var i=this,n=0;n>>26-i<<26-i;if(0!==i){var s=0;for(e=0;e>>26-i}s&&(this.words[e]=s,this.length++)}if(0!==r){for(e=this.length-1;e>=0;e--)this.words[e+r]=this.words[e];for(e=0;e>>n<s)for(this.length-=s,h=0;h=0&&(0!==u||h>=r);h--){var f=0|this.words[h];this.words[h]=u<<26-n|f>>>n,u=f&o}return a&&0!==u&&(a.words[a.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},r.prototype.ishrn=function(t,e,i){return this.iushrn(t,e,i)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){var e=t%26,i=(t-e)/26,r=1<>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},r.prototype.isubn=function(t){if(t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(a/67108864|0),this.words[r+i]=67108863&n}for(;r>26,this.words[r+i]=67108863&n;if(0===o)return this.strip();for(o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},r.prototype._wordDiv=function(t,e){var i=(this.length,t.length),n=this.clone(),s=t,o=0|s.words[s.length-1];0!=(i=26-this._countBits(o))&&(s=s.ushln(i),n.iushln(i),o=0|s.words[s.length-1]);var a,h=n.length-s.length;if("mod"!==e){(a=new r(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u=0;l--){var d=67108864*(0|n.words[s.length+l])+(0|n.words[s.length+l-1]);for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(s,d,l);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(s,1,l),n.isZero()||(n.negative^=1);a&&(a.words[l]=d)}return a&&a.strip(),n.strip(),"div"!==e&&0!==i&&n.iushrn(i),{div:a||null,mod:n}},r.prototype.divmod=function(t,e,i){return this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),"mod"!==e&&(n=o.div.neg()),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),e),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new r(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var i=0!==e.div.negative?e.mod.isub(t):e.mod,r=t.ushrn(1),n=t.andln(1),s=i.cmp(r);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},r.prototype.modn=function(t){for(var e=(1<<26)%t,i=0,r=this.length-1;r>=0;r--)i=(e*i+(0|this.words[r]))%t;return i},r.prototype.idivn=function(t){for(var e=0,i=this.length-1;i>=0;i--){var r=(0|this.words[i])+67108864*e;this.words[i]=r/t|0,e=r%t}return this.strip()},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new r(1),s=new r(0),o=new r(0),a=new r(1),h=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++h;for(var u=i.clone(),f=e.clone();!e.isZero();){for(var l=0,d=1;0==(e.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(e.iushrn(l);l-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(u),s.isub(f)),n.iushrn(1),s.iushrn(1);for(var c=0,p=1;0==(i.words[0]&p)&&c<26;++c,p<<=1);if(c>0)for(i.iushrn(c);c-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(u),a.isub(f)),o.iushrn(1),a.iushrn(1);e.cmp(i)>=0?(e.isub(i),n.isub(o),s.isub(a)):(i.isub(e),o.isub(n),a.isub(s))}return{a:o,b:a,gcd:i.iushln(h)}},r.prototype._invmp=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new r(1),o=new r(0),a=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var h=0,u=1;0==(e.words[0]&u)&&h<26;++h,u<<=1);if(h>0)for(e.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(a),s.iushrn(1);for(var f=0,l=1;0==(i.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(i.iushrn(f);f-- >0;)o.isOdd()&&o.iadd(a),o.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o)):(i.isub(e),o.isub(s))}return(n=0===e.cmpn(1)?s:o).cmpn(0)<0&&n.iadd(t),n},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),i=t.clone();e.negative=0,i.negative=0;for(var r=0;e.isEven()&&i.isEven();r++)e.iushrn(1),i.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;i.isEven();)i.iushrn(1);var n=e.cmp(i);if(n<0){var s=e;e=i,i=s}else if(0===n||0===i.cmpn(1))break;e.isub(i)}return i.iushln(r)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){var e=t%26,i=(t-e)/26,r=1<>>26,o&=67108863,this.words[s]=o}return 0!==n&&(this.words[s]=n,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t);var r=0|this.words[0];e=r===t?0:rt.length)return 1;if(this.length=0;i--){var r=0|this.words[i],n=0|t.words[i];if(r!==n){rn&&(e=1);break}}return e},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new M(t)},r.prototype.toRed=function(t){return t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return this._forceRed(t)},r.prototype.redAdd=function(t){return this.red.add(this,t)},r.prototype.redIAdd=function(t){return this.red.iadd(this,t)},r.prototype.redSub=function(t){return this.red.sub(this,t)},r.prototype.redISub=function(t){return this.red.isub(this,t)},r.prototype.redShl=function(t){return this.red.shl(this,t)},r.prototype.redMul=function(t){return this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return this.red._verify1(this),this.red.pow(this,t)};var p={k256:null,p224:null,p192:null,p25519:null};function m(t,e){this.name=t,this.p=new r(e,16),this.n=this.p.bitLength(),this.k=new r(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 v(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function y(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(t){if("string"==typeof t){var e=r._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function _(t){M.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(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 t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},m.prototype.ireduce=function(t){var e,i=t;do{this.split(i,this.tmp),e=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(e>this.n);var r=e0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},m.prototype.split=function(t,e){t.iushrn(this.n,0,e)},m.prototype.imulK=function(t){return t.imul(this.k)},i(g,m),g.prototype.split=function(t,e){for(var i=Math.min(t.length,9),r=0;r>>22,n=s}n>>>=22,t.words[r-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},g.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,i=0;i>>=26,t.words[i]=n,e=r}return 0!==e&&(t.words[t.length++]=e),t},r._prime=function(t){if(p[t])return p[t];var e;if("k256"===t)e=new g;else if("p224"===t)e=new v;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new y}return p[t]=e,e},M.prototype._verify1=function(t){},M.prototype._verify2=function(t,e){},M.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},M.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},M.prototype.add=function(t,e){this._verify2(t,e);var i=t.add(e);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},M.prototype.iadd=function(t,e){this._verify2(t,e);var i=t.iadd(e);return i.cmp(this.m)>=0&&i.isub(this.m),i},M.prototype.sub=function(t,e){this._verify2(t,e);var i=t.sub(e);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},M.prototype.isub=function(t,e){this._verify2(t,e);var i=t.isub(e);return i.cmpn(0)<0&&i.iadd(this.m),i},M.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},M.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},M.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},M.prototype.isqr=function(t){return this.imul(t,t.clone())},M.prototype.sqr=function(t){return this.mul(t,t)},M.prototype.sqrt=function(t){if(t.isZero())return t.clone();if(3===this.m.andln(3)){var e=this.m.add(new r(1)).iushrn(2);return this.pow(t,e)}for(var i=this.m.subn(1),n=0;!i.isZero()&&0===i.andln(1);)n++,i.iushrn(1);var s=new r(1).toRed(this),o=s.redNeg(),a=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new r(2*h*h).toRed(this);0!==this.pow(h,a).cmp(o);)h.redIAdd(o);for(var u=this.pow(h,i),f=this.pow(t,i.addn(1).iushrn(1)),l=this.pow(t,i),d=n;0!==l.cmp(s);){for(var c=l,p=0;0!==c.cmp(s);p++)c=c.redSqr();var m=this.pow(u,new r(1).iushln(d-p-1));f=f.redMul(m),u=m.redSqr(),l=l.redMul(u),d=p}return f},M.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},M.prototype.pow=function(t,e){if(e.isZero())return new r(1).toRed(this);if(0===e.cmpn(1))return t.clone();var i=new Array(16);i[0]=new r(1).toRed(this),i[1]=t;for(var n=2;n=0;n--){for(var u=e.words[n],f=h-1;f>=0;f--){var l=u>>f&1;s!==i[0]&&(s=this.sqr(s)),0!==l||0!==o?(o<<=1,o|=l,(4==++a||0===n&&0===f)&&(s=this.mul(s,i[o]),a=0,o=0)):a=0}h=26}return s},M.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},M.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},r.mont=function(t){return new _(t)},i(_,M),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(e),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new r(0)._forceRed(this);var i=t.mul(e),n=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=i.isub(n).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(rs,this),rs=rs.exports;var ns={exports:{}};!function(t,e){"use strict";function i(t,e){t.super_=e;var i=function(){};i.prototype=e.prototype,t.prototype=new i,t.prototype.constructor=t}function r(t,e,i){if(r.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(i=e,e=10),this._init(t||0,e||10,i||"be"))}var n;"object"==typeof t?t.exports=r:e.BN=r,r.BN=r,r.wordSize=26;try{n=w({}).Buffer}catch(S){}function s(t,e,i){for(var r=0,n=Math.min(t.length,i),s=e;s=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return r}function o(t,e,i,r){for(var n=0,s=Math.min(t.length,i),o=e;o=49?a-49+10:a>=17?a-17+10:a}return n}r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,e){return t.cmp(e)>0?t:e},r.min=function(t,e){return t.cmp(e)<0?t:e},r.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===e?this._parseHex(t,r):this._parseBase(t,e,r),"-"===t[0]&&(this.negative=1),this.strip(),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initArray=function(t,e,i){if(t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r=0;r-=3)s=t[r]|t[r-1]<<8|t[r-2]<<16,this.words[n]|=s<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===i)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this.strip()},r.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=6)n=s(t,i,i+6),this.words[r]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,r++);i+6!==e&&(n=s(t,e,i+6),this.words[r]|=n<>>26-o&4194303),this.strip()},r.prototype._parseBase=function(t,e,i){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=e)r++;r--,n=n/e|0;for(var s=t.length-i,a=s%r,h=Math.min(s,s-a)+i,u=0,f=i;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},r.prototype.inspect=function(){return(this.red?""};var a=["","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"],h=[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],u=[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 f(t,e,i){i.negative=e.negative^t.negative;var r=t.length+e.length|0;i.length=r,r=r-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;i.words[0]=a;for(var u=1;u>>26,l=67108863&h,d=Math.min(u,e.length-1),c=Math.max(0,u-t.length+1);c<=d;c++){var p=u-c|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[c])+l)/67108864|0,l=67108863&o}i.words[u]=0|l,h=0|f}return 0!==h?i.words[u]=0|h:i.length--,i.strip()}r.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var r=0,n=0,s=0;s>>24-r&16777215)||s!==this.length-1?a[6-f.length]+f+i:f+i,(r+=2)>=26&&(r-=26,s--)}for(0!==n&&(i=n.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var l=h[t],d=u[t];i="";var c=this.clone();for(c.negative=0;!c.isZero();){var p=c.modn(d).toString(t);i=(c=c.idivn(d)).isZero()?p+i:a[l-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length,0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16)},r.prototype.toBuffer=function(t,e){return this.toArrayLike(n,t,e)},r.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},r.prototype.toArrayLike=function(t,e,i){var r=this.byteLength(),n=i||Math.max(1,r);this.strip();var s,o,a="le"===e,h=new t(n),u=this.clone();if(a){for(o=0;!u.isZero();o++)s=u.andln(255),u.iushrn(8),h[o]=s;for(;o=4096&&(i+=13,e>>>=13),e>=64&&(i+=7,e>>>=7),e>=8&&(i+=4,e>>>=4),e>=2&&(i+=2,e>>>=2),i+e},r.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,i=0;return 0==(8191&e)&&(i+=13,e>>>=13),0==(127&e)&&(i+=7,e>>>=7),0==(15&e)&&(i+=4,e>>>=4),0==(3&e)&&(i+=2,e>>>=2),0==(1&e)&&i++,i},r.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var i=0;it.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var e,i;this.length>t.length?(e=this,i=t):(e=t,i=this);for(var r=0;rt.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-i),this.strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,e){var i=t/26|0,r=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(i=this,r=t):(i=t,r=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i,r,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(i=this,r=t):(i=t,r=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,c=0|o[1],p=8191&c,m=c>>>13,g=0|o[2],v=8191&g,b=g>>>13,y=0|o[3],w=8191&y,M=y>>>13,_=0|o[4],S=8191&_,E=_>>>13,k=0|o[5],R=8191&k,A=k>>>13,x=0|o[6],T=8191&x,P=x>>>13,B=0|o[7],I=8191&B,q=B>>>13,O=0|o[8],L=8191&O,j=O>>>13,C=0|o[9],N=8191&C,D=C>>>13,U=0|a[0],$=8191&U,z=U>>>13,W=0|a[1],F=8191&W,K=W>>>13,H=0|a[2],Z=8191&H,V=H>>>13,G=0|a[3],Y=8191&G,X=G>>>13,J=0|a[4],Q=8191&J,tt=J>>>13,et=0|a[5],it=8191&et,rt=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,ft=0|a[8],lt=8191&ft,dt=ft>>>13,ct=0|a[9],pt=8191&ct,mt=ct>>>13;i.negative=t.negative^e.negative,i.length=19;var gt=(u+(r=Math.imul(l,$))|0)+((8191&(n=(n=Math.imul(l,z))+Math.imul(d,$)|0))<<13)|0;u=((s=Math.imul(d,z))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(p,$),n=(n=Math.imul(p,z))+Math.imul(m,$)|0,s=Math.imul(m,z);var vt=(u+(r=r+Math.imul(l,F)|0)|0)+((8191&(n=(n=n+Math.imul(l,K)|0)+Math.imul(d,F)|0))<<13)|0;u=((s=s+Math.imul(d,K)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(v,$),n=(n=Math.imul(v,z))+Math.imul(b,$)|0,s=Math.imul(b,z),r=r+Math.imul(p,F)|0,n=(n=n+Math.imul(p,K)|0)+Math.imul(m,F)|0,s=s+Math.imul(m,K)|0;var bt=(u+(r=r+Math.imul(l,Z)|0)|0)+((8191&(n=(n=n+Math.imul(l,V)|0)+Math.imul(d,Z)|0))<<13)|0;u=((s=s+Math.imul(d,V)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(w,$),n=(n=Math.imul(w,z))+Math.imul(M,$)|0,s=Math.imul(M,z),r=r+Math.imul(v,F)|0,n=(n=n+Math.imul(v,K)|0)+Math.imul(b,F)|0,s=s+Math.imul(b,K)|0,r=r+Math.imul(p,Z)|0,n=(n=n+Math.imul(p,V)|0)+Math.imul(m,Z)|0,s=s+Math.imul(m,V)|0;var yt=(u+(r=r+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,X)|0)+Math.imul(d,Y)|0))<<13)|0;u=((s=s+Math.imul(d,X)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(S,$),n=(n=Math.imul(S,z))+Math.imul(E,$)|0,s=Math.imul(E,z),r=r+Math.imul(w,F)|0,n=(n=n+Math.imul(w,K)|0)+Math.imul(M,F)|0,s=s+Math.imul(M,K)|0,r=r+Math.imul(v,Z)|0,n=(n=n+Math.imul(v,V)|0)+Math.imul(b,Z)|0,s=s+Math.imul(b,V)|0,r=r+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,X)|0;var wt=(u+(r=r+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(d,Q)|0))<<13)|0;u=((s=s+Math.imul(d,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(R,$),n=(n=Math.imul(R,z))+Math.imul(A,$)|0,s=Math.imul(A,z),r=r+Math.imul(S,F)|0,n=(n=n+Math.imul(S,K)|0)+Math.imul(E,F)|0,s=s+Math.imul(E,K)|0,r=r+Math.imul(w,Z)|0,n=(n=n+Math.imul(w,V)|0)+Math.imul(M,Z)|0,s=s+Math.imul(M,V)|0,r=r+Math.imul(v,Y)|0,n=(n=n+Math.imul(v,X)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,X)|0,r=r+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var Mt=(u+(r=r+Math.imul(l,it)|0)|0)+((8191&(n=(n=n+Math.imul(l,rt)|0)+Math.imul(d,it)|0))<<13)|0;u=((s=s+Math.imul(d,rt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(T,$),n=(n=Math.imul(T,z))+Math.imul(P,$)|0,s=Math.imul(P,z),r=r+Math.imul(R,F)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(A,F)|0,s=s+Math.imul(A,K)|0,r=r+Math.imul(S,Z)|0,n=(n=n+Math.imul(S,V)|0)+Math.imul(E,Z)|0,s=s+Math.imul(E,V)|0,r=r+Math.imul(w,Y)|0,n=(n=n+Math.imul(w,X)|0)+Math.imul(M,Y)|0,s=s+Math.imul(M,X)|0,r=r+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,tt)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,tt)|0,r=r+Math.imul(p,it)|0,n=(n=n+Math.imul(p,rt)|0)+Math.imul(m,it)|0,s=s+Math.imul(m,rt)|0;var _t=(u+(r=r+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(d,st)|0))<<13)|0;u=((s=s+Math.imul(d,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(I,$),n=(n=Math.imul(I,z))+Math.imul(q,$)|0,s=Math.imul(q,z),r=r+Math.imul(T,F)|0,n=(n=n+Math.imul(T,K)|0)+Math.imul(P,F)|0,s=s+Math.imul(P,K)|0,r=r+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,V)|0)+Math.imul(A,Z)|0,s=s+Math.imul(A,V)|0,r=r+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,X)|0,r=r+Math.imul(w,Q)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(M,Q)|0,s=s+Math.imul(M,tt)|0,r=r+Math.imul(v,it)|0,n=(n=n+Math.imul(v,rt)|0)+Math.imul(b,it)|0,s=s+Math.imul(b,rt)|0,r=r+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(r=r+Math.imul(l,ht)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((s=s+Math.imul(d,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(L,$),n=(n=Math.imul(L,z))+Math.imul(j,$)|0,s=Math.imul(j,z),r=r+Math.imul(I,F)|0,n=(n=n+Math.imul(I,K)|0)+Math.imul(q,F)|0,s=s+Math.imul(q,K)|0,r=r+Math.imul(T,Z)|0,n=(n=n+Math.imul(T,V)|0)+Math.imul(P,Z)|0,s=s+Math.imul(P,V)|0,r=r+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,X)|0,r=r+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(E,Q)|0,s=s+Math.imul(E,tt)|0,r=r+Math.imul(w,it)|0,n=(n=n+Math.imul(w,rt)|0)+Math.imul(M,it)|0,s=s+Math.imul(M,rt)|0,r=r+Math.imul(v,st)|0,n=(n=n+Math.imul(v,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,r=r+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,ut)|0;var Et=(u+(r=r+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,dt)|0)+Math.imul(d,lt)|0))<<13)|0;u=((s=s+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(N,$),n=(n=Math.imul(N,z))+Math.imul(D,$)|0,s=Math.imul(D,z),r=r+Math.imul(L,F)|0,n=(n=n+Math.imul(L,K)|0)+Math.imul(j,F)|0,s=s+Math.imul(j,K)|0,r=r+Math.imul(I,Z)|0,n=(n=n+Math.imul(I,V)|0)+Math.imul(q,Z)|0,s=s+Math.imul(q,V)|0,r=r+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,X)|0,r=r+Math.imul(R,Q)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(A,Q)|0,s=s+Math.imul(A,tt)|0,r=r+Math.imul(S,it)|0,n=(n=n+Math.imul(S,rt)|0)+Math.imul(E,it)|0,s=s+Math.imul(E,rt)|0,r=r+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(M,st)|0,s=s+Math.imul(M,ot)|0,r=r+Math.imul(v,ht)|0,n=(n=n+Math.imul(v,ut)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ut)|0,r=r+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,dt)|0;var kt=(u+(r=r+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(d,pt)|0))<<13)|0;u=((s=s+Math.imul(d,mt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(N,F),n=(n=Math.imul(N,K))+Math.imul(D,F)|0,s=Math.imul(D,K),r=r+Math.imul(L,Z)|0,n=(n=n+Math.imul(L,V)|0)+Math.imul(j,Z)|0,s=s+Math.imul(j,V)|0,r=r+Math.imul(I,Y)|0,n=(n=n+Math.imul(I,X)|0)+Math.imul(q,Y)|0,s=s+Math.imul(q,X)|0,r=r+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(P,Q)|0,s=s+Math.imul(P,tt)|0,r=r+Math.imul(R,it)|0,n=(n=n+Math.imul(R,rt)|0)+Math.imul(A,it)|0,s=s+Math.imul(A,rt)|0,r=r+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(E,st)|0,s=s+Math.imul(E,ot)|0,r=r+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(M,ht)|0,s=s+Math.imul(M,ut)|0,r=r+Math.imul(v,lt)|0,n=(n=n+Math.imul(v,dt)|0)+Math.imul(b,lt)|0,s=s+Math.imul(b,dt)|0;var Rt=(u+(r=r+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(N,Z),n=(n=Math.imul(N,V))+Math.imul(D,Z)|0,s=Math.imul(D,V),r=r+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(j,Y)|0,s=s+Math.imul(j,X)|0,r=r+Math.imul(I,Q)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(q,Q)|0,s=s+Math.imul(q,tt)|0,r=r+Math.imul(T,it)|0,n=(n=n+Math.imul(T,rt)|0)+Math.imul(P,it)|0,s=s+Math.imul(P,rt)|0,r=r+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(A,st)|0,s=s+Math.imul(A,ot)|0,r=r+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(E,ht)|0,s=s+Math.imul(E,ut)|0,r=r+Math.imul(w,lt)|0,n=(n=n+Math.imul(w,dt)|0)+Math.imul(M,lt)|0,s=s+Math.imul(M,dt)|0;var At=(u+(r=r+Math.imul(v,pt)|0)|0)+((8191&(n=(n=n+Math.imul(v,mt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((s=s+Math.imul(b,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(N,Y),n=(n=Math.imul(N,X))+Math.imul(D,Y)|0,s=Math.imul(D,X),r=r+Math.imul(L,Q)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(j,Q)|0,s=s+Math.imul(j,tt)|0,r=r+Math.imul(I,it)|0,n=(n=n+Math.imul(I,rt)|0)+Math.imul(q,it)|0,s=s+Math.imul(q,rt)|0,r=r+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,ot)|0,r=r+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(A,ht)|0,s=s+Math.imul(A,ut)|0,r=r+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,dt)|0)+Math.imul(E,lt)|0,s=s+Math.imul(E,dt)|0;var xt=(u+(r=r+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((s=s+Math.imul(M,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(N,Q),n=(n=Math.imul(N,tt))+Math.imul(D,Q)|0,s=Math.imul(D,tt),r=r+Math.imul(L,it)|0,n=(n=n+Math.imul(L,rt)|0)+Math.imul(j,it)|0,s=s+Math.imul(j,rt)|0,r=r+Math.imul(I,st)|0,n=(n=n+Math.imul(I,ot)|0)+Math.imul(q,st)|0,s=s+Math.imul(q,ot)|0,r=r+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,ut)|0,r=r+Math.imul(R,lt)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(A,lt)|0,s=s+Math.imul(A,dt)|0;var Tt=(u+(r=r+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(E,pt)|0))<<13)|0;u=((s=s+Math.imul(E,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(N,it),n=(n=Math.imul(N,rt))+Math.imul(D,it)|0,s=Math.imul(D,rt),r=r+Math.imul(L,st)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(j,st)|0,s=s+Math.imul(j,ot)|0,r=r+Math.imul(I,ht)|0,n=(n=n+Math.imul(I,ut)|0)+Math.imul(q,ht)|0,s=s+Math.imul(q,ut)|0,r=r+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,dt)|0)+Math.imul(P,lt)|0,s=s+Math.imul(P,dt)|0;var Pt=(u+(r=r+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((s=s+Math.imul(A,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(N,st),n=(n=Math.imul(N,ot))+Math.imul(D,st)|0,s=Math.imul(D,ot),r=r+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,ut)|0)+Math.imul(j,ht)|0,s=s+Math.imul(j,ut)|0,r=r+Math.imul(I,lt)|0,n=(n=n+Math.imul(I,dt)|0)+Math.imul(q,lt)|0,s=s+Math.imul(q,dt)|0;var Bt=(u+(r=r+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((s=s+Math.imul(P,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(N,ht),n=(n=Math.imul(N,ut))+Math.imul(D,ht)|0,s=Math.imul(D,ut),r=r+Math.imul(L,lt)|0,n=(n=n+Math.imul(L,dt)|0)+Math.imul(j,lt)|0,s=s+Math.imul(j,dt)|0;var It=(u+(r=r+Math.imul(I,pt)|0)|0)+((8191&(n=(n=n+Math.imul(I,mt)|0)+Math.imul(q,pt)|0))<<13)|0;u=((s=s+Math.imul(q,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(N,lt),n=(n=Math.imul(N,dt))+Math.imul(D,lt)|0,s=Math.imul(D,dt);var qt=(u+(r=r+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,mt)|0)+Math.imul(j,pt)|0))<<13)|0;u=((s=s+Math.imul(j,mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863;var Ot=(u+(r=Math.imul(N,pt))|0)+((8191&(n=(n=Math.imul(N,mt))+Math.imul(D,pt)|0))<<13)|0;return u=((s=Math.imul(D,mt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=vt,h[2]=bt,h[3]=yt,h[4]=wt,h[5]=Mt,h[6]=_t,h[7]=St,h[8]=Et,h[9]=kt,h[10]=Rt,h[11]=At,h[12]=xt,h[13]=Tt,h[14]=Pt,h[15]=Bt,h[16]=It,h[17]=qt,h[18]=Ot,0!==u&&(h[19]=u,i.length++),i};function d(t,e,i){return(new c).mulp(t,e,i)}function c(t,e){this.x=t,this.y=e}Math.imul||(l=f),r.prototype.mulTo=function(t,e){var i=this.length+t.length;return 10===this.length&&10===t.length?l(this,t,e):i<63?f(this,t,e):i<1024?function(t,e,i){i.negative=e.negative^t.negative,i.length=t.length+e.length;for(var r=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}i.words[s]=a,r=o,o=n}return 0!==r?i.words[s]=r:i.length--,i.strip()}(this,t,e):d(this,t,e)},c.prototype.makeRBT=function(t){for(var e=new Array(t),i=r.prototype._countBits(t)-1,n=0;n>=1;return r},c.prototype.permute=function(t,e,i,r,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*s+1]=8191&n,n>>>=13;for(s=2*e;s>=26,e+=r/67108864|0,e+=n>>>26,this.words[i]=67108863&n}return 0!==e&&(this.words[i]=e,this.length++),this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),i=0;i>>n}return e}(t);if(0===e.length)return new r(1);for(var i=this,n=0;n>>26-i<<26-i;if(0!==i){var s=0;for(e=0;e>>26-i}s&&(this.words[e]=s,this.length++)}if(0!==r){for(e=this.length-1;e>=0;e--)this.words[e+r]=this.words[e];for(e=0;e>>n<s)for(this.length-=s,h=0;h=0&&(0!==u||h>=r);h--){var f=0|this.words[h];this.words[h]=u<<26-n|f>>>n,u=f&o}return a&&0!==u&&(a.words[a.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},r.prototype.ishrn=function(t,e,i){return this.iushrn(t,e,i)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){var e=t%26,i=(t-e)/26,r=1<>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},r.prototype.isubn=function(t){if(t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(a/67108864|0),this.words[r+i]=67108863&n}for(;r>26,this.words[r+i]=67108863&n;if(0===o)return this.strip();for(o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},r.prototype._wordDiv=function(t,e){var i=(this.length,t.length),n=this.clone(),s=t,o=0|s.words[s.length-1];0!=(i=26-this._countBits(o))&&(s=s.ushln(i),n.iushln(i),o=0|s.words[s.length-1]);var a,h=n.length-s.length;if("mod"!==e){(a=new r(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u=0;l--){var d=67108864*(0|n.words[s.length+l])+(0|n.words[s.length+l-1]);for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(s,d,l);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(s,1,l),n.isZero()||(n.negative^=1);a&&(a.words[l]=d)}return a&&a.strip(),n.strip(),"div"!==e&&0!==i&&n.iushrn(i),{div:a||null,mod:n}},r.prototype.divmod=function(t,e,i){return this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),"mod"!==e&&(n=o.div.neg()),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),e),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new r(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var i=0!==e.div.negative?e.mod.isub(t):e.mod,r=t.ushrn(1),n=t.andln(1),s=i.cmp(r);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},r.prototype.modn=function(t){for(var e=(1<<26)%t,i=0,r=this.length-1;r>=0;r--)i=(e*i+(0|this.words[r]))%t;return i},r.prototype.idivn=function(t){for(var e=0,i=this.length-1;i>=0;i--){var r=(0|this.words[i])+67108864*e;this.words[i]=r/t|0,e=r%t}return this.strip()},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new r(1),s=new r(0),o=new r(0),a=new r(1),h=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++h;for(var u=i.clone(),f=e.clone();!e.isZero();){for(var l=0,d=1;0==(e.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(e.iushrn(l);l-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(u),s.isub(f)),n.iushrn(1),s.iushrn(1);for(var c=0,p=1;0==(i.words[0]&p)&&c<26;++c,p<<=1);if(c>0)for(i.iushrn(c);c-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(u),a.isub(f)),o.iushrn(1),a.iushrn(1);e.cmp(i)>=0?(e.isub(i),n.isub(o),s.isub(a)):(i.isub(e),o.isub(n),a.isub(s))}return{a:o,b:a,gcd:i.iushln(h)}},r.prototype._invmp=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new r(1),o=new r(0),a=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var h=0,u=1;0==(e.words[0]&u)&&h<26;++h,u<<=1);if(h>0)for(e.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(a),s.iushrn(1);for(var f=0,l=1;0==(i.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(i.iushrn(f);f-- >0;)o.isOdd()&&o.iadd(a),o.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o)):(i.isub(e),o.isub(s))}return(n=0===e.cmpn(1)?s:o).cmpn(0)<0&&n.iadd(t),n},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),i=t.clone();e.negative=0,i.negative=0;for(var r=0;e.isEven()&&i.isEven();r++)e.iushrn(1),i.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;i.isEven();)i.iushrn(1);var n=e.cmp(i);if(n<0){var s=e;e=i,i=s}else if(0===n||0===i.cmpn(1))break;e.isub(i)}return i.iushln(r)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){var e=t%26,i=(t-e)/26,r=1<>>26,o&=67108863,this.words[s]=o}return 0!==n&&(this.words[s]=n,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t);var r=0|this.words[0];e=r===t?0:rt.length)return 1;if(this.length=0;i--){var r=0|this.words[i],n=0|t.words[i];if(r!==n){rn&&(e=1);break}}return e},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new M(t)},r.prototype.toRed=function(t){return t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return this._forceRed(t)},r.prototype.redAdd=function(t){return this.red.add(this,t)},r.prototype.redIAdd=function(t){return this.red.iadd(this,t)},r.prototype.redSub=function(t){return this.red.sub(this,t)},r.prototype.redISub=function(t){return this.red.isub(this,t)},r.prototype.redShl=function(t){return this.red.shl(this,t)},r.prototype.redMul=function(t){return this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return this.red._verify1(this),this.red.pow(this,t)};var p={k256:null,p224:null,p192:null,p25519:null};function m(t,e){this.name=t,this.p=new r(e,16),this.n=this.p.bitLength(),this.k=new r(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 v(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function y(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(t){if("string"==typeof t){var e=r._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function _(t){M.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(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 t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},m.prototype.ireduce=function(t){var e,i=t;do{this.split(i,this.tmp),e=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(e>this.n);var r=e0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},m.prototype.split=function(t,e){t.iushrn(this.n,0,e)},m.prototype.imulK=function(t){return t.imul(this.k)},i(g,m),g.prototype.split=function(t,e){for(var i=Math.min(t.length,9),r=0;r>>22,n=s}n>>>=22,t.words[r-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},g.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,i=0;i>>=26,t.words[i]=n,e=r}return 0!==e&&(t.words[t.length++]=e),t},r._prime=function(t){if(p[t])return p[t];var e;if("k256"===t)e=new g;else if("p224"===t)e=new v;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new y}return p[t]=e,e},M.prototype._verify1=function(t){},M.prototype._verify2=function(t,e){},M.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},M.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},M.prototype.add=function(t,e){this._verify2(t,e);var i=t.add(e);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},M.prototype.iadd=function(t,e){this._verify2(t,e);var i=t.iadd(e);return i.cmp(this.m)>=0&&i.isub(this.m),i},M.prototype.sub=function(t,e){this._verify2(t,e);var i=t.sub(e);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},M.prototype.isub=function(t,e){this._verify2(t,e);var i=t.isub(e);return i.cmpn(0)<0&&i.iadd(this.m),i},M.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},M.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},M.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},M.prototype.isqr=function(t){return this.imul(t,t.clone())},M.prototype.sqr=function(t){return this.mul(t,t)},M.prototype.sqrt=function(t){if(t.isZero())return t.clone();if(3===this.m.andln(3)){var e=this.m.add(new r(1)).iushrn(2);return this.pow(t,e)}for(var i=this.m.subn(1),n=0;!i.isZero()&&0===i.andln(1);)n++,i.iushrn(1);var s=new r(1).toRed(this),o=s.redNeg(),a=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new r(2*h*h).toRed(this);0!==this.pow(h,a).cmp(o);)h.redIAdd(o);for(var u=this.pow(h,i),f=this.pow(t,i.addn(1).iushrn(1)),l=this.pow(t,i),d=n;0!==l.cmp(s);){for(var c=l,p=0;0!==c.cmp(s);p++)c=c.redSqr();var m=this.pow(u,new r(1).iushln(d-p-1));f=f.redMul(m),u=m.redSqr(),l=l.redMul(u),d=p}return f},M.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},M.prototype.pow=function(t,e){if(e.isZero())return new r(1).toRed(this);if(0===e.cmpn(1))return t.clone();var i=new Array(16);i[0]=new r(1).toRed(this),i[1]=t;for(var n=2;n=0;n--){for(var u=e.words[n],f=h-1;f>=0;f--){var l=u>>f&1;s!==i[0]&&(s=this.sqr(s)),0!==l||0!==o?(o<<=1,o|=l,(4==++a||0===n&&0===f)&&(s=this.mul(s,i[o]),a=0,o=0)):a=0}h=26}return s},M.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},M.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},r.mont=function(t){return new _(t)},i(_,M),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(e),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new r(0)._forceRed(this);var i=t.mul(e),n=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=i.isub(n).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(ns,this),ns=ns.exports;var ss,os;function as(t){this.rand=t}if((ss=function(t){return os||(os=new as(null)),os.generate(t)}).Rand=as,as.prototype.generate=function(t){return this._rand(t)},as.prototype._rand=function(t){if(this.rand.getBytes)return this.rand.getBytes(t);for(var e=new Uint8Array(t),i=0;i=0);return r},fs.prototype._randrange=function(t,e){var i=e.sub(t);return t.add(this._randbelow(i))},fs.prototype.test=function(t,e,i){var r=t.bitLength(),n=ns.mont(t),s=new ns(1).toRed(n);e||(e=Math.max(1,r/48|0));for(var o=t.subn(1),a=0;!o.testn(a);a++);for(var h=t.shrn(a),u=o.toRed(n);e>0;e--){var f=this._randrange(new ns(2),o);i&&i(f);var l=f.toRed(n).redPow(h);if(0!==l.cmp(s)&&0!==l.cmp(u)){for(var d=1;d0;e--){var u=this._randrange(new ns(2),s),f=t.gcd(u);if(0!==f.cmpn(1))return f;var l=u.toRed(r).redPow(a);if(0!==l.cmp(n)&&0!==l.cmp(h)){for(var d=1;dt;)i.ishrn(1);if(i.isEven()&&i.iadd(ps),i.testn(1)||i.iadd(ms),e.cmp(ms)){if(!e.cmp(gs))for(;i.mod(vs).cmp(bs);)i.iadd(ws)}else for(;i.mod(ds).cmp(ys);)i.iadd(ws);if(Ss(r=i.shrn(1))&&Ss(i)&&Es(r)&&Es(i)&&cs.test(r)&&cs.test(i))return i}}(function(t){(function(){var e=new us,i=new rs(24),r=new rs(11),n=new rs(10),s=new rs(3),o=new rs(7);function a(e,i){return i=i||"utf8",t.isBuffer(e)||(e=new t(e,i)),this._pub=new rs(e),this}function h(e,i){return i=i||"utf8",t.isBuffer(e)||(e=new t(e,i)),this._priv=new rs(e),this}f;var u={};function f(t,e,i){this.setGenerator(e),this.__prime=new rs(t),this._prime=rs.mont(this.__prime),this._primeLen=t.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,i?(this.setPublicKey=a,this.setPrivateKey=h):this._primeCode=8}function l(e,i){var r=new t(e.toArray());return i?r.toString(i):r}Object.defineProperty(f.prototype,"verifyError",{enumerable:!0,get:function(){return"number"!=typeof this._primeCode&&(this._primeCode=function(t,a){var h=a.toString("hex"),f=[h,t.toString(16)].join("_");if(f in u)return u[f];var l,d=0;if(t.isEven()||!ls.simpleSieve||!ls.fermatTest(t)||!e.test(t))return d+=1,d+="02"===h||"05"===h?8:4,u[f]=d,d;switch(e.test(t.shrn(1))||(d+=2),h){case"02":t.mod(i).cmp(r)&&(d+=8);break;case"05":(l=t.mod(n)).cmp(s)&&l.cmp(o)&&(d+=8);break;default:d+=4}return u[f]=d,d}(this.__prime,this.__gen)),this._primeCode}}),f.prototype.generateKeys=function(){return this._priv||(this._priv=new rs(J(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()},f.prototype.computeSecret=function(e){var i=(e=(e=new rs(e)).toRed(this._prime)).redPow(this._priv).fromRed(),r=new t(i.toArray()),n=this.getPrime();if(r.length0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,i=""+e.data;e=e.next;)i+=t+e.data;return i}},{key:"concat",value:function(t){if(0===this.length)return Ps.alloc(0);for(var e,i,r,n=Ps.allocUnsafe(t>>>0),s=this.head,o=0;s;)e=s.data,i=n,r=o,Ps.prototype.copy.call(e,i,r),o+=s.data.length,s=s.next;return n}},{key:"consume",value:function(t,e){var i;return tn.length?n.length:t;if(s===n.length?r+=n:r+=n.slice(0,t),0==(t-=s)){s===n.length?(++i,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=n.slice(s));break}++i}return this.length-=i,r}},{key:"_getBuffer",value:function(t){var e=Ps.allocUnsafe(t),i=this.head,r=1;for(i.data.copy(e),t-=i.data.length;i=i.next;){var n=i.data,s=t>n.length?n.length:t;if(n.copy(e,e.length-t,0,s),0==(t-=s)){s===n.length?(++r,i.next?this.head=i.next:this.head=this.tail=null):(this.head=i,i.data=n.slice(s));break}++r}return this.length-=r,e}},{key:Is,value:function(t,e){return Bs(this,function(t){for(var e=1;e2?"one of ".concat(e," ").concat(t.slice(0,i-1).join(", "),", or ")+t[i-1]:2===i?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}Cs("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),Cs("ERR_INVALID_ARG_TYPE",(function(t,e,i){var r,n,s,o;if("string"==typeof e&&("not ","not "===e.substr(0,"not ".length))?(r="must not be",e=e.replace(/^not /,"")):r="must be",s=t,(void 0===o||o>s.length)&&(o=s.length)," argument"===s.substring(o-" argument".length,o))n="The ".concat(t," ").concat(r," ").concat(Ns(e,"type"));else{var a=function(t,e,i){return"number"!=typeof i&&(i=0),!(i+".".length>t.length)&&-1!==t.indexOf(".",i)}(t)?"property":"argument";n='The "'.concat(t,'" ').concat(a," ").concat(r," ").concat(Ns(e,"type"))}return n+". Received type ".concat(typeof i)}),TypeError),Cs("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),Cs("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),Cs("ERR_STREAM_PREMATURE_CLOSE","Premature close"),Cs("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),Cs("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),Cs("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),Cs("ERR_STREAM_WRITE_AFTER_END","write after end"),Cs("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),Cs("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),Cs("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),Ls.codes=js;var Ds=Ls.codes.ERR_INVALID_OPT_VALUE,Us={getHighWaterMark:function(t,e,i,r){var n=function(t,e,i){return null!=t.highWaterMark?t.highWaterMark:e?t[i]:null}(e,r,i);if(null!=n){if(!isFinite(n)||Math.floor(n)!==n||n<0)throw new Ds(r?i:"highWaterMark",n);return Math.floor(n)}return t.objectMode?16:16384}},$s=Gs,zs=Ls.codes,Ws=zs.ERR_METHOD_NOT_IMPLEMENTED,Fs=zs.ERR_MULTIPLE_CALLBACK,Ks=zs.ERR_TRANSFORM_ALREADY_TRANSFORMING,Hs=zs.ERR_TRANSFORM_WITH_LENGTH_0,Zs=s({});function Vs(t,e){var i=this._transformState;i.transforming=!1;var r=i.writecb;if(null===r)return this.emit("error",new Fs);i.writechunk=null,i.writecb=null,null!=e&&this.push(e),r(t);var n=this._readableState;n.reading=!1,(n.needReadable||n.length0,(function(t){r||(r=t),t&&o.forEach(so),a||(o.forEach(so),s(r))}))}));return e.reduce(oo)};var ho={exports:{}};!function(t,e){"use strict";function i(t,e){t.super_=e;var i=function(){};i.prototype=e.prototype,t.prototype=new i,t.prototype.constructor=t}function r(t,e,i){if(r.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(i=e,e=10),this._init(t||0,e||10,i||"be"))}var n;"object"==typeof t?t.exports=r:e.BN=r,r.BN=r,r.wordSize=26;try{n=w({}).Buffer}catch(jf){}function s(t,e,i){for(var r=0,n=Math.min(t.length,i),s=e;s=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:o}return r}function o(t,e,i,r){for(var n=0,s=Math.min(t.length,i),o=e;o=49?a-49+10:a>=17?a-17+10:a}return n}function a(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,e){return t.cmp(e)>0?t:e},r.min=function(t,e){return t.cmp(e)<0?t:e},r.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===e?this._parseHex(t,r):this._parseBase(t,e,r),"-"===t[0]&&(this.negative=1),this._strip(),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initArray=function(t,e,i){if(t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r=0;r-=3)s=t[r]|t[r-1]<<8|t[r-2]<<16,this.words[n]|=s<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===i)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this._strip()},r.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=6)n=s(t,i,i+6),this.words[r]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,r++);i+6!==e&&(n=s(t,e,i+6),this.words[r]|=n<>>26-o&4194303),this._strip()},r.prototype._parseBase=function(t,e,i){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=e)r++;r--,n=n/e|0;for(var s=t.length-i,a=s%r,h=Math.min(s,s-a)+i,u=0,f=i;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{r.prototype[Symbol.for("nodejs.util.inspect.custom")]=h}catch(jf){r.prototype.inspect=h}else r.prototype.inspect=h;function h(){return(this.red?""}var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],l=[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(t,e,i){i.negative=e.negative^t.negative;var r=t.length+e.length|0;i.length=r,r=r-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;i.words[0]=a;for(var u=1;u>>26,l=67108863&h,d=Math.min(u,e.length-1),c=Math.max(0,u-t.length+1);c<=d;c++){var p=u-c|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[c])+l)/67108864|0,l=67108863&o}i.words[u]=0|l,h=0|f}return 0!==h?i.words[u]=0|h:i.length--,i._strip()}r.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var r=0,n=0,s=0;s>>24-r&16777215)||s!==this.length-1?u[6-a.length]+a+i:a+i,(r+=2)>=26&&(r-=26,s--)}for(0!==n&&(i=n.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var h=f[t],d=l[t];i="";var c=this.clone();for(c.negative=0;!c.isZero();){var p=c.modrn(d).toString(t);i=(c=c.idivn(d)).isZero()?p+i:u[h-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length,0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16,2)},n&&(r.prototype.toBuffer=function(t,e){return this.toArrayLike(n,t,e)}),r.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},r.prototype.toArrayLike=function(t,e,i){this._strip();var r=this.byteLength(),n=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,i||Math.max(1,r));return this["_toArrayLike"+("le"===e?"LE":"BE")](n,r),n},r.prototype._toArrayLikeLE=function(t,e){for(var i=0,r=0,n=0,s=0;n>8&255),i>16&255),6===s?(i>24&255),r=0,s=0):(r=o>>>24,s+=2)}if(i=0&&(t[i--]=o>>8&255),i>=0&&(t[i--]=o>>16&255),6===s?(i>=0&&(t[i--]=o>>24&255),r=0,s=0):(r=o>>>24,s+=2)}if(i>=0)for(t[i--]=r;i>=0;)t[i--]=0},Math.clz32?r.prototype._countBits=function(t){return 32-Math.clz32(t)}:r.prototype._countBits=function(t){var e=t,i=0;return e>=4096&&(i+=13,e>>>=13),e>=64&&(i+=7,e>>>=7),e>=8&&(i+=4,e>>>=4),e>=2&&(i+=2,e>>>=2),i+e},r.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,i=0;return 0==(8191&e)&&(i+=13,e>>>=13),0==(127&e)&&(i+=7,e>>>=7),0==(15&e)&&(i+=4,e>>>=4),0==(3&e)&&(i+=2,e>>>=2),0==(1&e)&&i++,i},r.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var i=0;it.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var e,i;this.length>t.length?(e=this,i=t):(e=t,i=this);for(var r=0;rt.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-i),this._strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,e){var i=t/26|0,r=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(i=this,r=t):(i=t,r=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i,r,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(i=this,r=t):(i=t,r=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,c=0|o[1],p=8191&c,m=c>>>13,g=0|o[2],v=8191&g,b=g>>>13,y=0|o[3],w=8191&y,M=y>>>13,_=0|o[4],S=8191&_,E=_>>>13,k=0|o[5],R=8191&k,A=k>>>13,x=0|o[6],T=8191&x,P=x>>>13,B=0|o[7],I=8191&B,q=B>>>13,O=0|o[8],L=8191&O,j=O>>>13,C=0|o[9],N=8191&C,D=C>>>13,U=0|a[0],$=8191&U,z=U>>>13,W=0|a[1],F=8191&W,K=W>>>13,H=0|a[2],Z=8191&H,V=H>>>13,G=0|a[3],Y=8191&G,X=G>>>13,J=0|a[4],Q=8191&J,tt=J>>>13,et=0|a[5],it=8191&et,rt=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,ft=0|a[8],lt=8191&ft,dt=ft>>>13,ct=0|a[9],pt=8191&ct,mt=ct>>>13;i.negative=t.negative^e.negative,i.length=19;var gt=(u+(r=Math.imul(l,$))|0)+((8191&(n=(n=Math.imul(l,z))+Math.imul(d,$)|0))<<13)|0;u=((s=Math.imul(d,z))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(p,$),n=(n=Math.imul(p,z))+Math.imul(m,$)|0,s=Math.imul(m,z);var vt=(u+(r=r+Math.imul(l,F)|0)|0)+((8191&(n=(n=n+Math.imul(l,K)|0)+Math.imul(d,F)|0))<<13)|0;u=((s=s+Math.imul(d,K)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(v,$),n=(n=Math.imul(v,z))+Math.imul(b,$)|0,s=Math.imul(b,z),r=r+Math.imul(p,F)|0,n=(n=n+Math.imul(p,K)|0)+Math.imul(m,F)|0,s=s+Math.imul(m,K)|0;var bt=(u+(r=r+Math.imul(l,Z)|0)|0)+((8191&(n=(n=n+Math.imul(l,V)|0)+Math.imul(d,Z)|0))<<13)|0;u=((s=s+Math.imul(d,V)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(w,$),n=(n=Math.imul(w,z))+Math.imul(M,$)|0,s=Math.imul(M,z),r=r+Math.imul(v,F)|0,n=(n=n+Math.imul(v,K)|0)+Math.imul(b,F)|0,s=s+Math.imul(b,K)|0,r=r+Math.imul(p,Z)|0,n=(n=n+Math.imul(p,V)|0)+Math.imul(m,Z)|0,s=s+Math.imul(m,V)|0;var yt=(u+(r=r+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,X)|0)+Math.imul(d,Y)|0))<<13)|0;u=((s=s+Math.imul(d,X)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(S,$),n=(n=Math.imul(S,z))+Math.imul(E,$)|0,s=Math.imul(E,z),r=r+Math.imul(w,F)|0,n=(n=n+Math.imul(w,K)|0)+Math.imul(M,F)|0,s=s+Math.imul(M,K)|0,r=r+Math.imul(v,Z)|0,n=(n=n+Math.imul(v,V)|0)+Math.imul(b,Z)|0,s=s+Math.imul(b,V)|0,r=r+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,X)|0;var wt=(u+(r=r+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(d,Q)|0))<<13)|0;u=((s=s+Math.imul(d,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(R,$),n=(n=Math.imul(R,z))+Math.imul(A,$)|0,s=Math.imul(A,z),r=r+Math.imul(S,F)|0,n=(n=n+Math.imul(S,K)|0)+Math.imul(E,F)|0,s=s+Math.imul(E,K)|0,r=r+Math.imul(w,Z)|0,n=(n=n+Math.imul(w,V)|0)+Math.imul(M,Z)|0,s=s+Math.imul(M,V)|0,r=r+Math.imul(v,Y)|0,n=(n=n+Math.imul(v,X)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,X)|0,r=r+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var Mt=(u+(r=r+Math.imul(l,it)|0)|0)+((8191&(n=(n=n+Math.imul(l,rt)|0)+Math.imul(d,it)|0))<<13)|0;u=((s=s+Math.imul(d,rt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(T,$),n=(n=Math.imul(T,z))+Math.imul(P,$)|0,s=Math.imul(P,z),r=r+Math.imul(R,F)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(A,F)|0,s=s+Math.imul(A,K)|0,r=r+Math.imul(S,Z)|0,n=(n=n+Math.imul(S,V)|0)+Math.imul(E,Z)|0,s=s+Math.imul(E,V)|0,r=r+Math.imul(w,Y)|0,n=(n=n+Math.imul(w,X)|0)+Math.imul(M,Y)|0,s=s+Math.imul(M,X)|0,r=r+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,tt)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,tt)|0,r=r+Math.imul(p,it)|0,n=(n=n+Math.imul(p,rt)|0)+Math.imul(m,it)|0,s=s+Math.imul(m,rt)|0;var _t=(u+(r=r+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(d,st)|0))<<13)|0;u=((s=s+Math.imul(d,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(I,$),n=(n=Math.imul(I,z))+Math.imul(q,$)|0,s=Math.imul(q,z),r=r+Math.imul(T,F)|0,n=(n=n+Math.imul(T,K)|0)+Math.imul(P,F)|0,s=s+Math.imul(P,K)|0,r=r+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,V)|0)+Math.imul(A,Z)|0,s=s+Math.imul(A,V)|0,r=r+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,X)|0,r=r+Math.imul(w,Q)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(M,Q)|0,s=s+Math.imul(M,tt)|0,r=r+Math.imul(v,it)|0,n=(n=n+Math.imul(v,rt)|0)+Math.imul(b,it)|0,s=s+Math.imul(b,rt)|0,r=r+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(r=r+Math.imul(l,ht)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((s=s+Math.imul(d,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(L,$),n=(n=Math.imul(L,z))+Math.imul(j,$)|0,s=Math.imul(j,z),r=r+Math.imul(I,F)|0,n=(n=n+Math.imul(I,K)|0)+Math.imul(q,F)|0,s=s+Math.imul(q,K)|0,r=r+Math.imul(T,Z)|0,n=(n=n+Math.imul(T,V)|0)+Math.imul(P,Z)|0,s=s+Math.imul(P,V)|0,r=r+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,X)|0,r=r+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(E,Q)|0,s=s+Math.imul(E,tt)|0,r=r+Math.imul(w,it)|0,n=(n=n+Math.imul(w,rt)|0)+Math.imul(M,it)|0,s=s+Math.imul(M,rt)|0,r=r+Math.imul(v,st)|0,n=(n=n+Math.imul(v,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,r=r+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,ut)|0;var Et=(u+(r=r+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,dt)|0)+Math.imul(d,lt)|0))<<13)|0;u=((s=s+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(N,$),n=(n=Math.imul(N,z))+Math.imul(D,$)|0,s=Math.imul(D,z),r=r+Math.imul(L,F)|0,n=(n=n+Math.imul(L,K)|0)+Math.imul(j,F)|0,s=s+Math.imul(j,K)|0,r=r+Math.imul(I,Z)|0,n=(n=n+Math.imul(I,V)|0)+Math.imul(q,Z)|0,s=s+Math.imul(q,V)|0,r=r+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,X)|0,r=r+Math.imul(R,Q)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(A,Q)|0,s=s+Math.imul(A,tt)|0,r=r+Math.imul(S,it)|0,n=(n=n+Math.imul(S,rt)|0)+Math.imul(E,it)|0,s=s+Math.imul(E,rt)|0,r=r+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(M,st)|0,s=s+Math.imul(M,ot)|0,r=r+Math.imul(v,ht)|0,n=(n=n+Math.imul(v,ut)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ut)|0,r=r+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,dt)|0;var kt=(u+(r=r+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(d,pt)|0))<<13)|0;u=((s=s+Math.imul(d,mt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(N,F),n=(n=Math.imul(N,K))+Math.imul(D,F)|0,s=Math.imul(D,K),r=r+Math.imul(L,Z)|0,n=(n=n+Math.imul(L,V)|0)+Math.imul(j,Z)|0,s=s+Math.imul(j,V)|0,r=r+Math.imul(I,Y)|0,n=(n=n+Math.imul(I,X)|0)+Math.imul(q,Y)|0,s=s+Math.imul(q,X)|0,r=r+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(P,Q)|0,s=s+Math.imul(P,tt)|0,r=r+Math.imul(R,it)|0,n=(n=n+Math.imul(R,rt)|0)+Math.imul(A,it)|0,s=s+Math.imul(A,rt)|0,r=r+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(E,st)|0,s=s+Math.imul(E,ot)|0,r=r+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(M,ht)|0,s=s+Math.imul(M,ut)|0,r=r+Math.imul(v,lt)|0,n=(n=n+Math.imul(v,dt)|0)+Math.imul(b,lt)|0,s=s+Math.imul(b,dt)|0;var Rt=(u+(r=r+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(N,Z),n=(n=Math.imul(N,V))+Math.imul(D,Z)|0,s=Math.imul(D,V),r=r+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(j,Y)|0,s=s+Math.imul(j,X)|0,r=r+Math.imul(I,Q)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(q,Q)|0,s=s+Math.imul(q,tt)|0,r=r+Math.imul(T,it)|0,n=(n=n+Math.imul(T,rt)|0)+Math.imul(P,it)|0,s=s+Math.imul(P,rt)|0,r=r+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(A,st)|0,s=s+Math.imul(A,ot)|0,r=r+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(E,ht)|0,s=s+Math.imul(E,ut)|0,r=r+Math.imul(w,lt)|0,n=(n=n+Math.imul(w,dt)|0)+Math.imul(M,lt)|0,s=s+Math.imul(M,dt)|0;var At=(u+(r=r+Math.imul(v,pt)|0)|0)+((8191&(n=(n=n+Math.imul(v,mt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((s=s+Math.imul(b,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(N,Y),n=(n=Math.imul(N,X))+Math.imul(D,Y)|0,s=Math.imul(D,X),r=r+Math.imul(L,Q)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(j,Q)|0,s=s+Math.imul(j,tt)|0,r=r+Math.imul(I,it)|0,n=(n=n+Math.imul(I,rt)|0)+Math.imul(q,it)|0,s=s+Math.imul(q,rt)|0,r=r+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,ot)|0,r=r+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(A,ht)|0,s=s+Math.imul(A,ut)|0,r=r+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,dt)|0)+Math.imul(E,lt)|0,s=s+Math.imul(E,dt)|0;var xt=(u+(r=r+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((s=s+Math.imul(M,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(N,Q),n=(n=Math.imul(N,tt))+Math.imul(D,Q)|0,s=Math.imul(D,tt),r=r+Math.imul(L,it)|0,n=(n=n+Math.imul(L,rt)|0)+Math.imul(j,it)|0,s=s+Math.imul(j,rt)|0,r=r+Math.imul(I,st)|0,n=(n=n+Math.imul(I,ot)|0)+Math.imul(q,st)|0,s=s+Math.imul(q,ot)|0,r=r+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,ut)|0,r=r+Math.imul(R,lt)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(A,lt)|0,s=s+Math.imul(A,dt)|0;var Tt=(u+(r=r+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(E,pt)|0))<<13)|0;u=((s=s+Math.imul(E,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(N,it),n=(n=Math.imul(N,rt))+Math.imul(D,it)|0,s=Math.imul(D,rt),r=r+Math.imul(L,st)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(j,st)|0,s=s+Math.imul(j,ot)|0,r=r+Math.imul(I,ht)|0,n=(n=n+Math.imul(I,ut)|0)+Math.imul(q,ht)|0,s=s+Math.imul(q,ut)|0,r=r+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,dt)|0)+Math.imul(P,lt)|0,s=s+Math.imul(P,dt)|0;var Pt=(u+(r=r+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((s=s+Math.imul(A,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(N,st),n=(n=Math.imul(N,ot))+Math.imul(D,st)|0,s=Math.imul(D,ot),r=r+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,ut)|0)+Math.imul(j,ht)|0,s=s+Math.imul(j,ut)|0,r=r+Math.imul(I,lt)|0,n=(n=n+Math.imul(I,dt)|0)+Math.imul(q,lt)|0,s=s+Math.imul(q,dt)|0;var Bt=(u+(r=r+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((s=s+Math.imul(P,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(N,ht),n=(n=Math.imul(N,ut))+Math.imul(D,ht)|0,s=Math.imul(D,ut),r=r+Math.imul(L,lt)|0,n=(n=n+Math.imul(L,dt)|0)+Math.imul(j,lt)|0,s=s+Math.imul(j,dt)|0;var It=(u+(r=r+Math.imul(I,pt)|0)|0)+((8191&(n=(n=n+Math.imul(I,mt)|0)+Math.imul(q,pt)|0))<<13)|0;u=((s=s+Math.imul(q,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(N,lt),n=(n=Math.imul(N,dt))+Math.imul(D,lt)|0,s=Math.imul(D,dt);var qt=(u+(r=r+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,mt)|0)+Math.imul(j,pt)|0))<<13)|0;u=((s=s+Math.imul(j,mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863;var Ot=(u+(r=Math.imul(N,pt))|0)+((8191&(n=(n=Math.imul(N,mt))+Math.imul(D,pt)|0))<<13)|0;return u=((s=Math.imul(D,mt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=vt,h[2]=bt,h[3]=yt,h[4]=wt,h[5]=Mt,h[6]=_t,h[7]=St,h[8]=Et,h[9]=kt,h[10]=Rt,h[11]=At,h[12]=xt,h[13]=Tt,h[14]=Pt,h[15]=Bt,h[16]=It,h[17]=qt,h[18]=Ot,0!==u&&(h[19]=u,i.length++),i};function p(t,e,i){i.negative=e.negative^t.negative,i.length=t.length+e.length;for(var r=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}i.words[s]=a,r=o,o=n}return 0!==r?i.words[s]=r:i.length--,i._strip()}function m(t,e,i){return p(t,e,i)}function g(t,e){this.x=t,this.y=e}Math.imul||(c=d),r.prototype.mulTo=function(t,e){var i=this.length+t.length;return 10===this.length&&10===t.length?c(this,t,e):i<63?d(this,t,e):i<1024?p(this,t,e):m(this,t,e)},g.prototype.makeRBT=function(t){for(var e=new Array(t),i=r.prototype._countBits(t)-1,n=0;n>=1;return r},g.prototype.permute=function(t,e,i,r,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*s+1]=8191&n,n>>>=13;for(s=2*e;s>=26,i+=n/67108864|0,i+=s>>>26,this.words[r]=67108863&s}return 0!==i&&(this.words[r]=i,this.length++),e?this.ineg():this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),i=0;i>>n&1}return e}(t);if(0===e.length)return new r(1);for(var i=this,n=0;n>>26-i<<26-i;if(0!==i){var s=0;for(e=0;e>>26-i}s&&(this.words[e]=s,this.length++)}if(0!==r){for(e=this.length-1;e>=0;e--)this.words[e+r]=this.words[e];for(e=0;e>>n<s)for(this.length-=s,h=0;h=0&&(0!==u||h>=r);h--){var f=0|this.words[h];this.words[h]=u<<26-n|f>>>n,u=f&o}return a&&0!==u&&(a.words[a.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},r.prototype.ishrn=function(t,e,i){return this.iushrn(t,e,i)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){var e=t%26,i=(t-e)/26,r=1<>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},r.prototype.isubn=function(t){if(t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(a/67108864|0),this.words[r+i]=67108863&n}for(;r>26,this.words[r+i]=67108863&n;if(0===o)return this._strip();for(o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this._strip()},r.prototype._wordDiv=function(t,e){var i=(this.length,t.length),n=this.clone(),s=t,o=0|s.words[s.length-1];0!=(i=26-this._countBits(o))&&(s=s.ushln(i),n.iushln(i),o=0|s.words[s.length-1]);var a,h=n.length-s.length;if("mod"!==e){(a=new r(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u=0;l--){var d=67108864*(0|n.words[s.length+l])+(0|n.words[s.length+l-1]);for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(s,d,l);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(s,1,l),n.isZero()||(n.negative^=1);a&&(a.words[l]=d)}return a&&a._strip(),n._strip(),"div"!==e&&0!==i&&n.iushrn(i),{div:a||null,mod:n}},r.prototype.divmod=function(t,e,i){return this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),"mod"!==e&&(n=o.div.neg()),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),e),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new r(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modrn(t.words[0]))}:this._wordDiv(t,e);var n,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var i=0!==e.div.negative?e.mod.isub(t):e.mod,r=t.ushrn(1),n=t.andln(1),s=i.cmp(r);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},r.prototype.modrn=function(t){var e=t<0;e&&(t=-t);for(var i=(1<<26)%t,r=0,n=this.length-1;n>=0;n--)r=(i*r+(0|this.words[n]))%t;return e?-r:r},r.prototype.modn=function(t){return this.modrn(t)},r.prototype.idivn=function(t){var e=t<0;e&&(t=-t);for(var i=0,r=this.length-1;r>=0;r--){var n=(0|this.words[r])+67108864*i;this.words[r]=n/t|0,i=n%t}return this._strip(),e?this.ineg():this},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new r(1),s=new r(0),o=new r(0),a=new r(1),h=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++h;for(var u=i.clone(),f=e.clone();!e.isZero();){for(var l=0,d=1;0==(e.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(e.iushrn(l);l-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(u),s.isub(f)),n.iushrn(1),s.iushrn(1);for(var c=0,p=1;0==(i.words[0]&p)&&c<26;++c,p<<=1);if(c>0)for(i.iushrn(c);c-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(u),a.isub(f)),o.iushrn(1),a.iushrn(1);e.cmp(i)>=0?(e.isub(i),n.isub(o),s.isub(a)):(i.isub(e),o.isub(n),a.isub(s))}return{a:o,b:a,gcd:i.iushln(h)}},r.prototype._invmp=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new r(1),o=new r(0),a=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var h=0,u=1;0==(e.words[0]&u)&&h<26;++h,u<<=1);if(h>0)for(e.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(a),s.iushrn(1);for(var f=0,l=1;0==(i.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(i.iushrn(f);f-- >0;)o.isOdd()&&o.iadd(a),o.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o)):(i.isub(e),o.isub(s))}return(n=0===e.cmpn(1)?s:o).cmpn(0)<0&&n.iadd(t),n},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),i=t.clone();e.negative=0,i.negative=0;for(var r=0;e.isEven()&&i.isEven();r++)e.iushrn(1),i.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;i.isEven();)i.iushrn(1);var n=e.cmp(i);if(n<0){var s=e;e=i,i=s}else if(0===n||0===i.cmpn(1))break;e.isub(i)}return i.iushln(r)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){var e=t%26,i=(t-e)/26,r=1<>>26,o&=67108863,this.words[s]=o}return 0!==n&&(this.words[s]=n,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this._strip(),this.length>1)e=1;else{i&&(t=-t);var r=0|this.words[0];e=r===t?0:rt.length)return 1;if(this.length=0;i--){var r=0|this.words[i],n=0|t.words[i];if(r!==n){rn&&(e=1);break}}return e},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new E(t)},r.prototype.toRed=function(t){return t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return this._forceRed(t)},r.prototype.redAdd=function(t){return this.red.add(this,t)},r.prototype.redIAdd=function(t){return this.red.iadd(this,t)},r.prototype.redSub=function(t){return this.red.sub(this,t)},r.prototype.redISub=function(t){return this.red.isub(this,t)},r.prototype.redShl=function(t){return this.red.shl(this,t)},r.prototype.redMul=function(t){return this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return this.red._verify1(this),this.red.pow(this,t)};var v={k256:null,p224:null,p192:null,p25519:null};function b(t,e){this.name=t,this.p=new r(e,16),this.n=this.p.bitLength(),this.k=new r(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function y(){b.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function M(){b.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function _(){b.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function S(){b.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=r._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function k(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(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)}b.prototype._tmp=function(){var t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},b.prototype.ireduce=function(t){var e,i=t;do{this.split(i,this.tmp),e=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(e>this.n);var r=e0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},b.prototype.split=function(t,e){t.iushrn(this.n,0,e)},b.prototype.imulK=function(t){return t.imul(this.k)},i(y,b),y.prototype.split=function(t,e){for(var i=Math.min(t.length,9),r=0;r>>22,n=s}n>>>=22,t.words[r-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},y.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,i=0;i>>=26,t.words[i]=n,e=r}return 0!==e&&(t.words[t.length++]=e),t},r._prime=function(t){if(v[t])return v[t];var e;if("k256"===t)e=new y;else if("p224"===t)e=new M;else if("p192"===t)e=new _;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new S}return v[t]=e,e},E.prototype._verify1=function(t){},E.prototype._verify2=function(t,e){},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(a(t,t.umod(this.m)._forceRed(this)),t)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var i=t.add(e);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var i=t.iadd(e);return i.cmp(this.m)>=0&&i.isub(this.m),i},E.prototype.sub=function(t,e){this._verify2(t,e);var i=t.sub(e);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var i=t.isub(e);return i.cmpn(0)<0&&i.iadd(this.m),i},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();if(3===this.m.andln(3)){var e=this.m.add(new r(1)).iushrn(2);return this.pow(t,e)}for(var i=this.m.subn(1),n=0;!i.isZero()&&0===i.andln(1);)n++,i.iushrn(1);var s=new r(1).toRed(this),o=s.redNeg(),a=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new r(2*h*h).toRed(this);0!==this.pow(h,a).cmp(o);)h.redIAdd(o);for(var u=this.pow(h,i),f=this.pow(t,i.addn(1).iushrn(1)),l=this.pow(t,i),d=n;0!==l.cmp(s);){for(var c=l,p=0;0!==c.cmp(s);p++)c=c.redSqr();var m=this.pow(u,new r(1).iushln(d-p-1));f=f.redMul(m),u=m.redSqr(),l=l.redMul(u),d=p}return f},E.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},E.prototype.pow=function(t,e){if(e.isZero())return new r(1).toRed(this);if(0===e.cmpn(1))return t.clone();var i=new Array(16);i[0]=new r(1).toRed(this),i[1]=t;for(var n=2;n=0;n--){for(var u=e.words[n],f=h-1;f>=0;f--){var l=u>>f&1;s!==i[0]&&(s=this.sqr(s)),0!==l||0!==o?(o<<=1,o|=l,(4==++a||0===n&&0===f)&&(s=this.mul(s,i[o]),a=0,o=0)):a=0}h=26}return s},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},r.mont=function(t){return new k(t)},i(k,E),k.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},k.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},k.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(e),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},k.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new r(0)._forceRed(this);var i=t.mul(e),n=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=i.isub(n).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},k.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(ho,this),ho=ho.exports;var uo={};(function(t){(function(){function e(t){var e,i=t.modulus.byteLength();do{e=new ho(J(i))}while(e.cmp(t.modulus)>=0||!e.umod(t.prime1)||!e.umod(t.prime2));return e}function i(i,r){var n=function(t){var i=e(t);return{blinder:i.toRed(ho.mont(t.modulus)).redPow(new ho(t.publicExponent)).fromRed(),unblinder:i.invm(t.modulus)}}(r),s=r.modulus.byteLength(),o=new ho(i).mul(n.blinder).umod(r.modulus),a=o.toRed(ho.mont(r.prime1)),h=o.toRed(ho.mont(r.prime2)),u=r.coefficient,f=r.prime1,l=r.prime2,d=a.redPow(r.exponent1).fromRed(),c=h.redPow(r.exponent2).fromRed(),p=d.isub(c).imul(u).umod(f).imul(l);return c.iadd(p).imul(n.unblinder).umod(r.modulus).toArrayLike(t,"be",s)}i.getr=e,uo=i}).call(this)}).call(this,M({}).Buffer);var fo={exports:{}};!function(t,e){"use strict";function i(t,e){t.super_=e;var i=function(){};i.prototype=e.prototype,t.prototype=new i,t.prototype.constructor=t}function r(t,e,i){if(r.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(i=e,e=10),this._init(t||0,e||10,i||"be"))}var n;"object"==typeof t?t.exports=r:e.BN=r,r.BN=r,r.wordSize=26;try{n=w({}).Buffer}catch(jf){}function s(t,e,i){for(var r=0,n=Math.min(t.length,i),s=e;s=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return r}function o(t,e,i,r){for(var n=0,s=Math.min(t.length,i),o=e;o=49?a-49+10:a>=17?a-17+10:a}return n}r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,e){return t.cmp(e)>0?t:e},r.min=function(t,e){return t.cmp(e)<0?t:e},r.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===e?this._parseHex(t,r):this._parseBase(t,e,r),"-"===t[0]&&(this.negative=1),this.strip(),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initArray=function(t,e,i){if(t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r=0;r-=3)s=t[r]|t[r-1]<<8|t[r-2]<<16,this.words[n]|=s<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===i)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this.strip()},r.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=6)n=s(t,i,i+6),this.words[r]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,r++);i+6!==e&&(n=s(t,e,i+6),this.words[r]|=n<>>26-o&4194303),this.strip()},r.prototype._parseBase=function(t,e,i){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=e)r++;r--,n=n/e|0;for(var s=t.length-i,a=s%r,h=Math.min(s,s-a)+i,u=0,f=i;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},r.prototype.inspect=function(){return(this.red?""};var a=["","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"],h=[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],u=[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 f(t,e,i){i.negative=e.negative^t.negative;var r=t.length+e.length|0;i.length=r,r=r-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;i.words[0]=a;for(var u=1;u>>26,l=67108863&h,d=Math.min(u,e.length-1),c=Math.max(0,u-t.length+1);c<=d;c++){var p=u-c|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[c])+l)/67108864|0,l=67108863&o}i.words[u]=0|l,h=0|f}return 0!==h?i.words[u]=0|h:i.length--,i.strip()}r.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var r=0,n=0,s=0;s>>24-r&16777215)||s!==this.length-1?a[6-f.length]+f+i:f+i,(r+=2)>=26&&(r-=26,s--)}for(0!==n&&(i=n.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var l=h[t],d=u[t];i="";var c=this.clone();for(c.negative=0;!c.isZero();){var p=c.modn(d).toString(t);i=(c=c.idivn(d)).isZero()?p+i:a[l-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length,0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16)},r.prototype.toBuffer=function(t,e){return this.toArrayLike(n,t,e)},r.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},r.prototype.toArrayLike=function(t,e,i){var r=this.byteLength(),n=i||Math.max(1,r);this.strip();var s,o,a="le"===e,h=new t(n),u=this.clone();if(a){for(o=0;!u.isZero();o++)s=u.andln(255),u.iushrn(8),h[o]=s;for(;o=4096&&(i+=13,e>>>=13),e>=64&&(i+=7,e>>>=7),e>=8&&(i+=4,e>>>=4),e>=2&&(i+=2,e>>>=2),i+e},r.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,i=0;return 0==(8191&e)&&(i+=13,e>>>=13),0==(127&e)&&(i+=7,e>>>=7),0==(15&e)&&(i+=4,e>>>=4),0==(3&e)&&(i+=2,e>>>=2),0==(1&e)&&i++,i},r.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var i=0;it.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var e,i;this.length>t.length?(e=this,i=t):(e=t,i=this);for(var r=0;rt.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-i),this.strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,e){var i=t/26|0,r=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(i=this,r=t):(i=t,r=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i,r,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(i=this,r=t):(i=t,r=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,c=0|o[1],p=8191&c,m=c>>>13,g=0|o[2],v=8191&g,b=g>>>13,y=0|o[3],w=8191&y,M=y>>>13,_=0|o[4],S=8191&_,E=_>>>13,k=0|o[5],R=8191&k,A=k>>>13,x=0|o[6],T=8191&x,P=x>>>13,B=0|o[7],I=8191&B,q=B>>>13,O=0|o[8],L=8191&O,j=O>>>13,C=0|o[9],N=8191&C,D=C>>>13,U=0|a[0],$=8191&U,z=U>>>13,W=0|a[1],F=8191&W,K=W>>>13,H=0|a[2],Z=8191&H,V=H>>>13,G=0|a[3],Y=8191&G,X=G>>>13,J=0|a[4],Q=8191&J,tt=J>>>13,et=0|a[5],it=8191&et,rt=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,ft=0|a[8],lt=8191&ft,dt=ft>>>13,ct=0|a[9],pt=8191&ct,mt=ct>>>13;i.negative=t.negative^e.negative,i.length=19;var gt=(u+(r=Math.imul(l,$))|0)+((8191&(n=(n=Math.imul(l,z))+Math.imul(d,$)|0))<<13)|0;u=((s=Math.imul(d,z))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(p,$),n=(n=Math.imul(p,z))+Math.imul(m,$)|0,s=Math.imul(m,z);var vt=(u+(r=r+Math.imul(l,F)|0)|0)+((8191&(n=(n=n+Math.imul(l,K)|0)+Math.imul(d,F)|0))<<13)|0;u=((s=s+Math.imul(d,K)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(v,$),n=(n=Math.imul(v,z))+Math.imul(b,$)|0,s=Math.imul(b,z),r=r+Math.imul(p,F)|0,n=(n=n+Math.imul(p,K)|0)+Math.imul(m,F)|0,s=s+Math.imul(m,K)|0;var bt=(u+(r=r+Math.imul(l,Z)|0)|0)+((8191&(n=(n=n+Math.imul(l,V)|0)+Math.imul(d,Z)|0))<<13)|0;u=((s=s+Math.imul(d,V)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(w,$),n=(n=Math.imul(w,z))+Math.imul(M,$)|0,s=Math.imul(M,z),r=r+Math.imul(v,F)|0,n=(n=n+Math.imul(v,K)|0)+Math.imul(b,F)|0,s=s+Math.imul(b,K)|0,r=r+Math.imul(p,Z)|0,n=(n=n+Math.imul(p,V)|0)+Math.imul(m,Z)|0,s=s+Math.imul(m,V)|0;var yt=(u+(r=r+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,X)|0)+Math.imul(d,Y)|0))<<13)|0;u=((s=s+Math.imul(d,X)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(S,$),n=(n=Math.imul(S,z))+Math.imul(E,$)|0,s=Math.imul(E,z),r=r+Math.imul(w,F)|0,n=(n=n+Math.imul(w,K)|0)+Math.imul(M,F)|0,s=s+Math.imul(M,K)|0,r=r+Math.imul(v,Z)|0,n=(n=n+Math.imul(v,V)|0)+Math.imul(b,Z)|0,s=s+Math.imul(b,V)|0,r=r+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,X)|0;var wt=(u+(r=r+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(d,Q)|0))<<13)|0;u=((s=s+Math.imul(d,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(R,$),n=(n=Math.imul(R,z))+Math.imul(A,$)|0,s=Math.imul(A,z),r=r+Math.imul(S,F)|0,n=(n=n+Math.imul(S,K)|0)+Math.imul(E,F)|0,s=s+Math.imul(E,K)|0,r=r+Math.imul(w,Z)|0,n=(n=n+Math.imul(w,V)|0)+Math.imul(M,Z)|0,s=s+Math.imul(M,V)|0,r=r+Math.imul(v,Y)|0,n=(n=n+Math.imul(v,X)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,X)|0,r=r+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var Mt=(u+(r=r+Math.imul(l,it)|0)|0)+((8191&(n=(n=n+Math.imul(l,rt)|0)+Math.imul(d,it)|0))<<13)|0;u=((s=s+Math.imul(d,rt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(T,$),n=(n=Math.imul(T,z))+Math.imul(P,$)|0,s=Math.imul(P,z),r=r+Math.imul(R,F)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(A,F)|0,s=s+Math.imul(A,K)|0,r=r+Math.imul(S,Z)|0,n=(n=n+Math.imul(S,V)|0)+Math.imul(E,Z)|0,s=s+Math.imul(E,V)|0,r=r+Math.imul(w,Y)|0,n=(n=n+Math.imul(w,X)|0)+Math.imul(M,Y)|0,s=s+Math.imul(M,X)|0,r=r+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,tt)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,tt)|0,r=r+Math.imul(p,it)|0,n=(n=n+Math.imul(p,rt)|0)+Math.imul(m,it)|0,s=s+Math.imul(m,rt)|0;var _t=(u+(r=r+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(d,st)|0))<<13)|0;u=((s=s+Math.imul(d,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(I,$),n=(n=Math.imul(I,z))+Math.imul(q,$)|0,s=Math.imul(q,z),r=r+Math.imul(T,F)|0,n=(n=n+Math.imul(T,K)|0)+Math.imul(P,F)|0,s=s+Math.imul(P,K)|0,r=r+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,V)|0)+Math.imul(A,Z)|0,s=s+Math.imul(A,V)|0,r=r+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,X)|0,r=r+Math.imul(w,Q)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(M,Q)|0,s=s+Math.imul(M,tt)|0,r=r+Math.imul(v,it)|0,n=(n=n+Math.imul(v,rt)|0)+Math.imul(b,it)|0,s=s+Math.imul(b,rt)|0,r=r+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(r=r+Math.imul(l,ht)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((s=s+Math.imul(d,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(L,$),n=(n=Math.imul(L,z))+Math.imul(j,$)|0,s=Math.imul(j,z),r=r+Math.imul(I,F)|0,n=(n=n+Math.imul(I,K)|0)+Math.imul(q,F)|0,s=s+Math.imul(q,K)|0,r=r+Math.imul(T,Z)|0,n=(n=n+Math.imul(T,V)|0)+Math.imul(P,Z)|0,s=s+Math.imul(P,V)|0,r=r+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,X)|0,r=r+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(E,Q)|0,s=s+Math.imul(E,tt)|0,r=r+Math.imul(w,it)|0,n=(n=n+Math.imul(w,rt)|0)+Math.imul(M,it)|0,s=s+Math.imul(M,rt)|0,r=r+Math.imul(v,st)|0,n=(n=n+Math.imul(v,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,r=r+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,ut)|0;var Et=(u+(r=r+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,dt)|0)+Math.imul(d,lt)|0))<<13)|0;u=((s=s+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(N,$),n=(n=Math.imul(N,z))+Math.imul(D,$)|0,s=Math.imul(D,z),r=r+Math.imul(L,F)|0,n=(n=n+Math.imul(L,K)|0)+Math.imul(j,F)|0,s=s+Math.imul(j,K)|0,r=r+Math.imul(I,Z)|0,n=(n=n+Math.imul(I,V)|0)+Math.imul(q,Z)|0,s=s+Math.imul(q,V)|0,r=r+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,X)|0,r=r+Math.imul(R,Q)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(A,Q)|0,s=s+Math.imul(A,tt)|0,r=r+Math.imul(S,it)|0,n=(n=n+Math.imul(S,rt)|0)+Math.imul(E,it)|0,s=s+Math.imul(E,rt)|0,r=r+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(M,st)|0,s=s+Math.imul(M,ot)|0,r=r+Math.imul(v,ht)|0,n=(n=n+Math.imul(v,ut)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ut)|0,r=r+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,dt)|0;var kt=(u+(r=r+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(d,pt)|0))<<13)|0;u=((s=s+Math.imul(d,mt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(N,F),n=(n=Math.imul(N,K))+Math.imul(D,F)|0,s=Math.imul(D,K),r=r+Math.imul(L,Z)|0,n=(n=n+Math.imul(L,V)|0)+Math.imul(j,Z)|0,s=s+Math.imul(j,V)|0,r=r+Math.imul(I,Y)|0,n=(n=n+Math.imul(I,X)|0)+Math.imul(q,Y)|0,s=s+Math.imul(q,X)|0,r=r+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(P,Q)|0,s=s+Math.imul(P,tt)|0,r=r+Math.imul(R,it)|0,n=(n=n+Math.imul(R,rt)|0)+Math.imul(A,it)|0,s=s+Math.imul(A,rt)|0,r=r+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(E,st)|0,s=s+Math.imul(E,ot)|0,r=r+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(M,ht)|0,s=s+Math.imul(M,ut)|0,r=r+Math.imul(v,lt)|0,n=(n=n+Math.imul(v,dt)|0)+Math.imul(b,lt)|0,s=s+Math.imul(b,dt)|0;var Rt=(u+(r=r+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(N,Z),n=(n=Math.imul(N,V))+Math.imul(D,Z)|0,s=Math.imul(D,V),r=r+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(j,Y)|0,s=s+Math.imul(j,X)|0,r=r+Math.imul(I,Q)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(q,Q)|0,s=s+Math.imul(q,tt)|0,r=r+Math.imul(T,it)|0,n=(n=n+Math.imul(T,rt)|0)+Math.imul(P,it)|0,s=s+Math.imul(P,rt)|0,r=r+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(A,st)|0,s=s+Math.imul(A,ot)|0,r=r+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(E,ht)|0,s=s+Math.imul(E,ut)|0,r=r+Math.imul(w,lt)|0,n=(n=n+Math.imul(w,dt)|0)+Math.imul(M,lt)|0,s=s+Math.imul(M,dt)|0;var At=(u+(r=r+Math.imul(v,pt)|0)|0)+((8191&(n=(n=n+Math.imul(v,mt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((s=s+Math.imul(b,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(N,Y),n=(n=Math.imul(N,X))+Math.imul(D,Y)|0,s=Math.imul(D,X),r=r+Math.imul(L,Q)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(j,Q)|0,s=s+Math.imul(j,tt)|0,r=r+Math.imul(I,it)|0,n=(n=n+Math.imul(I,rt)|0)+Math.imul(q,it)|0,s=s+Math.imul(q,rt)|0,r=r+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,ot)|0,r=r+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(A,ht)|0,s=s+Math.imul(A,ut)|0,r=r+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,dt)|0)+Math.imul(E,lt)|0,s=s+Math.imul(E,dt)|0;var xt=(u+(r=r+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((s=s+Math.imul(M,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(N,Q),n=(n=Math.imul(N,tt))+Math.imul(D,Q)|0,s=Math.imul(D,tt),r=r+Math.imul(L,it)|0,n=(n=n+Math.imul(L,rt)|0)+Math.imul(j,it)|0,s=s+Math.imul(j,rt)|0,r=r+Math.imul(I,st)|0,n=(n=n+Math.imul(I,ot)|0)+Math.imul(q,st)|0,s=s+Math.imul(q,ot)|0,r=r+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,ut)|0,r=r+Math.imul(R,lt)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(A,lt)|0,s=s+Math.imul(A,dt)|0;var Tt=(u+(r=r+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(E,pt)|0))<<13)|0;u=((s=s+Math.imul(E,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(N,it),n=(n=Math.imul(N,rt))+Math.imul(D,it)|0,s=Math.imul(D,rt),r=r+Math.imul(L,st)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(j,st)|0,s=s+Math.imul(j,ot)|0,r=r+Math.imul(I,ht)|0,n=(n=n+Math.imul(I,ut)|0)+Math.imul(q,ht)|0,s=s+Math.imul(q,ut)|0,r=r+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,dt)|0)+Math.imul(P,lt)|0,s=s+Math.imul(P,dt)|0;var Pt=(u+(r=r+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((s=s+Math.imul(A,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(N,st),n=(n=Math.imul(N,ot))+Math.imul(D,st)|0,s=Math.imul(D,ot),r=r+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,ut)|0)+Math.imul(j,ht)|0,s=s+Math.imul(j,ut)|0,r=r+Math.imul(I,lt)|0,n=(n=n+Math.imul(I,dt)|0)+Math.imul(q,lt)|0,s=s+Math.imul(q,dt)|0;var Bt=(u+(r=r+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((s=s+Math.imul(P,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(N,ht),n=(n=Math.imul(N,ut))+Math.imul(D,ht)|0,s=Math.imul(D,ut),r=r+Math.imul(L,lt)|0,n=(n=n+Math.imul(L,dt)|0)+Math.imul(j,lt)|0,s=s+Math.imul(j,dt)|0;var It=(u+(r=r+Math.imul(I,pt)|0)|0)+((8191&(n=(n=n+Math.imul(I,mt)|0)+Math.imul(q,pt)|0))<<13)|0;u=((s=s+Math.imul(q,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(N,lt),n=(n=Math.imul(N,dt))+Math.imul(D,lt)|0,s=Math.imul(D,dt);var qt=(u+(r=r+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,mt)|0)+Math.imul(j,pt)|0))<<13)|0;u=((s=s+Math.imul(j,mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863;var Ot=(u+(r=Math.imul(N,pt))|0)+((8191&(n=(n=Math.imul(N,mt))+Math.imul(D,pt)|0))<<13)|0;return u=((s=Math.imul(D,mt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=vt,h[2]=bt,h[3]=yt,h[4]=wt,h[5]=Mt,h[6]=_t,h[7]=St,h[8]=Et,h[9]=kt,h[10]=Rt,h[11]=At,h[12]=xt,h[13]=Tt,h[14]=Pt,h[15]=Bt,h[16]=It,h[17]=qt,h[18]=Ot,0!==u&&(h[19]=u,i.length++),i};function d(t,e,i){return(new c).mulp(t,e,i)}function c(t,e){this.x=t,this.y=e}Math.imul||(l=f),r.prototype.mulTo=function(t,e){var i=this.length+t.length;return 10===this.length&&10===t.length?l(this,t,e):i<63?f(this,t,e):i<1024?function(t,e,i){i.negative=e.negative^t.negative,i.length=t.length+e.length;for(var r=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}i.words[s]=a,r=o,o=n}return 0!==r?i.words[s]=r:i.length--,i.strip()}(this,t,e):d(this,t,e)},c.prototype.makeRBT=function(t){for(var e=new Array(t),i=r.prototype._countBits(t)-1,n=0;n>=1;return r},c.prototype.permute=function(t,e,i,r,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*s+1]=8191&n,n>>>=13;for(s=2*e;s>=26,e+=r/67108864|0,e+=n>>>26,this.words[i]=67108863&n}return 0!==e&&(this.words[i]=e,this.length++),this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),i=0;i>>n}return e}(t);if(0===e.length)return new r(1);for(var i=this,n=0;n>>26-i<<26-i;if(0!==i){var s=0;for(e=0;e>>26-i}s&&(this.words[e]=s,this.length++)}if(0!==r){for(e=this.length-1;e>=0;e--)this.words[e+r]=this.words[e];for(e=0;e>>n<s)for(this.length-=s,h=0;h=0&&(0!==u||h>=r);h--){var f=0|this.words[h];this.words[h]=u<<26-n|f>>>n,u=f&o}return a&&0!==u&&(a.words[a.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},r.prototype.ishrn=function(t,e,i){return this.iushrn(t,e,i)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){var e=t%26,i=(t-e)/26,r=1<>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},r.prototype.isubn=function(t){if(t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(a/67108864|0),this.words[r+i]=67108863&n}for(;r>26,this.words[r+i]=67108863&n;if(0===o)return this.strip();for(o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},r.prototype._wordDiv=function(t,e){var i=(this.length,t.length),n=this.clone(),s=t,o=0|s.words[s.length-1];0!=(i=26-this._countBits(o))&&(s=s.ushln(i),n.iushln(i),o=0|s.words[s.length-1]);var a,h=n.length-s.length;if("mod"!==e){(a=new r(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u=0;l--){var d=67108864*(0|n.words[s.length+l])+(0|n.words[s.length+l-1]);for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(s,d,l);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(s,1,l),n.isZero()||(n.negative^=1);a&&(a.words[l]=d)}return a&&a.strip(),n.strip(),"div"!==e&&0!==i&&n.iushrn(i),{div:a||null,mod:n}},r.prototype.divmod=function(t,e,i){return this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),"mod"!==e&&(n=o.div.neg()),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),e),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new r(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var i=0!==e.div.negative?e.mod.isub(t):e.mod,r=t.ushrn(1),n=t.andln(1),s=i.cmp(r);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},r.prototype.modn=function(t){for(var e=(1<<26)%t,i=0,r=this.length-1;r>=0;r--)i=(e*i+(0|this.words[r]))%t;return i},r.prototype.idivn=function(t){for(var e=0,i=this.length-1;i>=0;i--){var r=(0|this.words[i])+67108864*e;this.words[i]=r/t|0,e=r%t}return this.strip()},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new r(1),s=new r(0),o=new r(0),a=new r(1),h=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++h;for(var u=i.clone(),f=e.clone();!e.isZero();){for(var l=0,d=1;0==(e.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(e.iushrn(l);l-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(u),s.isub(f)),n.iushrn(1),s.iushrn(1);for(var c=0,p=1;0==(i.words[0]&p)&&c<26;++c,p<<=1);if(c>0)for(i.iushrn(c);c-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(u),a.isub(f)),o.iushrn(1),a.iushrn(1);e.cmp(i)>=0?(e.isub(i),n.isub(o),s.isub(a)):(i.isub(e),o.isub(n),a.isub(s))}return{a:o,b:a,gcd:i.iushln(h)}},r.prototype._invmp=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new r(1),o=new r(0),a=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var h=0,u=1;0==(e.words[0]&u)&&h<26;++h,u<<=1);if(h>0)for(e.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(a),s.iushrn(1);for(var f=0,l=1;0==(i.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(i.iushrn(f);f-- >0;)o.isOdd()&&o.iadd(a),o.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o)):(i.isub(e),o.isub(s))}return(n=0===e.cmpn(1)?s:o).cmpn(0)<0&&n.iadd(t),n},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),i=t.clone();e.negative=0,i.negative=0;for(var r=0;e.isEven()&&i.isEven();r++)e.iushrn(1),i.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;i.isEven();)i.iushrn(1);var n=e.cmp(i);if(n<0){var s=e;e=i,i=s}else if(0===n||0===i.cmpn(1))break;e.isub(i)}return i.iushln(r)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){var e=t%26,i=(t-e)/26,r=1<>>26,o&=67108863,this.words[s]=o}return 0!==n&&(this.words[s]=n,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t);var r=0|this.words[0];e=r===t?0:rt.length)return 1;if(this.length=0;i--){var r=0|this.words[i],n=0|t.words[i];if(r!==n){rn&&(e=1);break}}return e},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new M(t)},r.prototype.toRed=function(t){return t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return this._forceRed(t)},r.prototype.redAdd=function(t){return this.red.add(this,t)},r.prototype.redIAdd=function(t){return this.red.iadd(this,t)},r.prototype.redSub=function(t){return this.red.sub(this,t)},r.prototype.redISub=function(t){return this.red.isub(this,t)},r.prototype.redShl=function(t){return this.red.shl(this,t)},r.prototype.redMul=function(t){return this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return this.red._verify1(this),this.red.pow(this,t)};var p={k256:null,p224:null,p192:null,p25519:null};function m(t,e){this.name=t,this.p=new r(e,16),this.n=this.p.bitLength(),this.k=new r(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 v(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function y(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(t){if("string"==typeof t){var e=r._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function _(t){M.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(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 t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},m.prototype.ireduce=function(t){var e,i=t;do{this.split(i,this.tmp),e=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(e>this.n);var r=e0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},m.prototype.split=function(t,e){t.iushrn(this.n,0,e)},m.prototype.imulK=function(t){return t.imul(this.k)},i(g,m),g.prototype.split=function(t,e){for(var i=Math.min(t.length,9),r=0;r>>22,n=s}n>>>=22,t.words[r-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},g.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,i=0;i>>=26,t.words[i]=n,e=r}return 0!==e&&(t.words[t.length++]=e),t},r._prime=function(t){if(p[t])return p[t];var e;if("k256"===t)e=new g;else if("p224"===t)e=new v;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new y}return p[t]=e,e},M.prototype._verify1=function(t){},M.prototype._verify2=function(t,e){},M.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},M.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},M.prototype.add=function(t,e){this._verify2(t,e);var i=t.add(e);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},M.prototype.iadd=function(t,e){this._verify2(t,e);var i=t.iadd(e);return i.cmp(this.m)>=0&&i.isub(this.m),i},M.prototype.sub=function(t,e){this._verify2(t,e);var i=t.sub(e);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},M.prototype.isub=function(t,e){this._verify2(t,e);var i=t.isub(e);return i.cmpn(0)<0&&i.iadd(this.m),i},M.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},M.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},M.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},M.prototype.isqr=function(t){return this.imul(t,t.clone())},M.prototype.sqr=function(t){return this.mul(t,t)},M.prototype.sqrt=function(t){if(t.isZero())return t.clone();if(3===this.m.andln(3)){var e=this.m.add(new r(1)).iushrn(2);return this.pow(t,e)}for(var i=this.m.subn(1),n=0;!i.isZero()&&0===i.andln(1);)n++,i.iushrn(1);var s=new r(1).toRed(this),o=s.redNeg(),a=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new r(2*h*h).toRed(this);0!==this.pow(h,a).cmp(o);)h.redIAdd(o);for(var u=this.pow(h,i),f=this.pow(t,i.addn(1).iushrn(1)),l=this.pow(t,i),d=n;0!==l.cmp(s);){for(var c=l,p=0;0!==c.cmp(s);p++)c=c.redSqr();var m=this.pow(u,new r(1).iushln(d-p-1));f=f.redMul(m),u=m.redSqr(),l=l.redMul(u),d=p}return f},M.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},M.prototype.pow=function(t,e){if(e.isZero())return new r(1).toRed(this);if(0===e.cmpn(1))return t.clone();var i=new Array(16);i[0]=new r(1).toRed(this),i[1]=t;for(var n=2;n=0;n--){for(var u=e.words[n],f=h-1;f>=0;f--){var l=u>>f&1;s!==i[0]&&(s=this.sqr(s)),0!==l||0!==o?(o<<=1,o|=l,(4==++a||0===n&&0===f)&&(s=this.mul(s,i[o]),a=0,o=0)):a=0}h=26}return s},M.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},M.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},r.mont=function(t){return new _(t)},i(_,M),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(e),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new r(0)._forceRed(this);var i=t.mul(e),n=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=i.isub(n).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(fo,this),fo=fo.exports;var lo={},co=lo;function po(t){return 1===t.length?"0"+t:t}function mo(t){for(var e="",i=0;i>8,o=255&n;s?i.push(s,o):i.push(o)}return i},co.zero2=po,co.toHex=mo,co.encode=function(t,e){return"hex"===e?mo(t):t};var go={},vo=go;vo.assert=$r,vo.toArray=lo.toArray,vo.zero2=lo.zero2,vo.toHex=lo.toHex,vo.encode=lo.encode,vo.getNAF=function(t,e,i){var r=new Array(Math.max(t.bitLength(),i)+1);r.fill(0);for(var n=1<(n>>1)-1?(n>>1)-h:h,s.isubn(a)):a=0,r[o]=a,s.iushrn(1)}return r},vo.getJSF=function(t,e){var i=[[],[]];t=t.clone(),e=e.clone();for(var r,n=0,s=0;t.cmpn(-n)>0||e.cmpn(-s)>0;){var o,a,h=t.andln(3)+n&3,u=e.andln(3)+s&3;3===h&&(h=-1),3===u&&(u=-1),o=0==(1&h)?0:3!=(r=t.andln(7)+n&7)&&5!==r||2!==u?h:-h,i[0].push(o),a=0==(1&u)?0:3!=(r=e.andln(7)+s&7)&&5!==r||2!==h?u:-u,i[1].push(a),2*n===o+1&&(n=1-n),2*s===a+1&&(s=1-s),t.iushrn(1),e.iushrn(1)}return i},vo.cachedProperty=function(t,e,i){var r="_"+e;t.prototype[e]=function(){return void 0!==this[r]?this[r]:this[r]=i.call(this)}},vo.parseBytes=function(t){return"string"==typeof t?vo.toArray(t,"hex"):t},vo.intFromLE=function(t){return new fo(t,"hex","le")};var bo={},yo=go.getNAF,wo=go.getJSF;function Mo(t,e){this.type=t,this.p=new fo(e.p,16),this.red=e.prime?fo.red(e.prime):fo.mont(this.p),this.zero=new fo(0).toRed(this.red),this.one=new fo(1).toRed(this.red),this.two=new fo(2).toRed(this.red),this.n=e.n&&new fo(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var i=this.n&&this.p.div(this.n);!i||i.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function _o(t,e){this.curve=t,this.type=e,this.precomputed=null}go.assert,bo=Mo,Mo.prototype.point=function(){throw new Error("Not implemented")},Mo.prototype.validate=function(){throw new Error("Not implemented")},Mo.prototype._fixedNafMul=function(t,e){var i=t._getDoubles(),r=yo(e,1,this._bitLength),n=(1<=s;h--)o=(o<<1)+r[h];a.push(o)}for(var u=this.jpoint(null,null,null),f=this.jpoint(null,null,null),l=n;l>0;l--){for(s=0;s=0;a--){for(var h=0;a>=0&&0===s[a];a--)h++;if(a>=0&&h++,o=o.dblp(h),a<0)break;var u=s[a];o="affine"===t.type?u>0?o.mixedAdd(n[u-1>>1]):o.mixedAdd(n[-u-1>>1].neg()):u>0?o.add(n[u-1>>1]):o.add(n[-u-1>>1].neg())}return"affine"===t.type?o.toP():o},Mo.prototype._wnafMulAdd=function(t,e,i,r,n){var s,o,a,h=this._wnafT1,u=this._wnafT2,f=this._wnafT3,l=0;for(s=0;s=1;s-=2){var c=s-1,p=s;if(1===h[c]&&1===h[p]){var m=[e[c],null,null,e[p]];0===e[c].y.cmp(e[p].y)?(m[1]=e[c].add(e[p]),m[2]=e[c].toJ().mixedAdd(e[p].neg())):0===e[c].y.cmp(e[p].y.redNeg())?(m[1]=e[c].toJ().mixedAdd(e[p]),m[2]=e[c].add(e[p].neg())):(m[1]=e[c].toJ().mixedAdd(e[p]),m[2]=e[c].toJ().mixedAdd(e[p].neg()));var g=[-3,-1,-5,-7,0,7,5,1,3],v=wo(i[c],i[p]);for(l=Math.max(v[0].length,l),f[c]=new Array(l),f[p]=new Array(l),o=0;o=0;s--){for(var _=0;s>=0;){var S=!0;for(o=0;o=0&&_++,w=w.dblp(_),s<0)break;for(o=0;o0?a=u[o][E-1>>1]:E<0&&(a=u[o][-E-1>>1].neg()),w="affine"===a.type?w.mixedAdd(a):w.add(a))}}for(s=0;s=Math.ceil((t.bitLength()+1)/e.step)},_o.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],r=this,n=0;n=0&&(s=e,o=i),r.negative&&(r=r.neg(),n=n.neg()),s.negative&&(s=s.neg(),o=o.neg()),[{a:r,b:n},{a:s,b:o}]},Eo.prototype._endoSplit=function(t){var e=this.endo.basis,i=e[0],r=e[1],n=r.b.mul(t).divRound(this.n),s=i.b.neg().mul(t).divRound(this.n),o=n.mul(i.a),a=s.mul(r.a),h=n.mul(i.b),u=s.mul(r.b);return{k1:t.sub(o).sub(a),k2:h.add(u).neg()}},Eo.prototype.pointFromX=function(t,e){(t=new fo(t,16)).red||(t=t.toRed(this.red));var i=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),r=i.redSqrt();if(0!==r.redSqr().redSub(i).cmp(this.zero))throw new Error("invalid point");var n=r.fromRed().isOdd();return(e&&!n||!e&&n)&&(r=r.redNeg()),this.point(t,r)},Eo.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,i=t.y,r=this.a.redMul(e),n=e.redSqr().redMul(e).redIAdd(r).redIAdd(this.b);return 0===i.redSqr().redISub(n).cmpn(0)},Eo.prototype._endoWnafMulAdd=function(t,e,i){for(var r=this._endoWnafT1,n=this._endoWnafT2,s=0;s":""},ko.prototype.isInfinity=function(){return this.inf},ko.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var i=e.redSqr().redISub(this.x).redISub(t.x),r=e.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,r)},ko.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,i=this.x.redSqr(),r=t.redInvm(),n=i.redAdd(i).redIAdd(i).redIAdd(e).redMul(r),s=n.redSqr().redISub(this.x.redAdd(this.x)),o=n.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,o)},ko.prototype.getX=function(){return this.x.fromRed()},ko.prototype.getY=function(){return this.y.fromRed()},ko.prototype.mul=function(t){return t=new fo(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},ko.prototype.mulAdd=function(t,e,i){var r=[this,e],n=[t,i];return this.curve.endo?this.curve._endoWnafMulAdd(r,n):this.curve._wnafMulAdd(1,r,n,2)},ko.prototype.jmulAdd=function(t,e,i){var r=[this,e],n=[t,i];return this.curve.endo?this.curve._endoWnafMulAdd(r,n,!0):this.curve._wnafMulAdd(1,r,n,2,!0)},ko.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},ko.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var i=this.precomputed,r=function(t){return t.neg()};e.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(r)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(r)}}}return e},ko.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},Q(Ro,bo.BasePoint),Eo.prototype.jpoint=function(t,e,i){return new Ro(this,t,e,i)},Ro.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),i=this.x.redMul(e),r=this.y.redMul(e).redMul(t);return this.curve.point(i,r)},Ro.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Ro.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),i=this.z.redSqr(),r=this.x.redMul(e),n=t.x.redMul(i),s=this.y.redMul(e.redMul(t.z)),o=t.y.redMul(i.redMul(this.z)),a=r.redSub(n),h=s.redSub(o);if(0===a.cmpn(0))return 0!==h.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),f=u.redMul(a),l=r.redMul(u),d=h.redSqr().redIAdd(f).redISub(l).redISub(l),c=h.redMul(l.redISub(d)).redISub(s.redMul(f)),p=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(d,c,p)},Ro.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),i=this.x,r=t.x.redMul(e),n=this.y,s=t.y.redMul(e).redMul(this.z),o=i.redSub(r),a=n.redSub(s);if(0===o.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=o.redSqr(),u=h.redMul(o),f=i.redMul(h),l=a.redSqr().redIAdd(u).redISub(f).redISub(f),d=a.redMul(f.redISub(l)).redISub(n.redMul(u)),c=this.z.redMul(o);return this.curve.jpoint(l,d,c)},Ro.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var i=this;for(e=0;e=0)return!1;if(i.redIAdd(n),0===this.x.cmp(i))return!0}},Ro.prototype.inspect=function(){return this.isInfinity()?"":""},Ro.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var Ao;function xo(t){bo.call(this,"mont",t),this.a=new fo(t.a,16).toRed(this.red),this.b=new fo(t.b,16).toRed(this.red),this.i4=new fo(4).toRed(this.red).redInvm(),this.two=new fo(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function To(t,e,i){bo.BasePoint.call(this,t,"projective"),null===e&&null===i?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new fo(e,16),this.z=new fo(i,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}Q(xo,bo),Ao=xo,xo.prototype.validate=function(t){var e=t.normalize().x,i=e.redSqr(),r=i.redMul(e).redAdd(i.redMul(this.a)).redAdd(e);return 0===r.redSqrt().redSqr().cmp(r)},Q(To,bo.BasePoint),xo.prototype.decodePoint=function(t,e){return this.point(go.toArray(t,e),1)},xo.prototype.point=function(t,e){return new To(this,t,e)},xo.prototype.pointFromJSON=function(t){return To.fromJSON(this,t)},To.prototype.precompute=function(){},To.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},To.fromJSON=function(t,e){return new To(t,e[0],e[1]||t.one)},To.prototype.inspect=function(){return this.isInfinity()?"":""},To.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},To.prototype.dbl=function(){var t=this.x.redAdd(this.z).redSqr(),e=this.x.redSub(this.z).redSqr(),i=t.redSub(e),r=t.redMul(e),n=i.redMul(e.redAdd(this.curve.a24.redMul(i)));return this.curve.point(r,n)},To.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},To.prototype.diffAdd=function(t,e){var i=this.x.redAdd(this.z),r=this.x.redSub(this.z),n=t.x.redAdd(t.z),s=t.x.redSub(t.z).redMul(i),o=n.redMul(r),a=e.z.redMul(s.redAdd(o).redSqr()),h=e.x.redMul(s.redISub(o).redSqr());return this.curve.point(a,h)},To.prototype.mul=function(t){for(var e=t.clone(),i=this,r=this.curve.point(null,null),n=[];0!==e.cmpn(0);e.iushrn(1))n.push(e.andln(1));for(var s=n.length-1;s>=0;s--)0===n[s]?(i=i.diffAdd(r,this),r=r.dbl()):(r=i.diffAdd(r,this),i=i.dbl());return r},To.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},To.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},To.prototype.eq=function(t){return 0===this.getX().cmp(t.getX())},To.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},To.prototype.getX=function(){return this.normalize(),this.x.fromRed()};var Po;function Bo(t){this.twisted=1!=(0|t.a),this.mOneA=this.twisted&&-1==(0|t.a),this.extended=this.mOneA,bo.call(this,"edwards",t),this.a=new fo(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new fo(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new fo(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),this.oneC=1==(0|t.c)}function Io(t,e,i,r,n){bo.BasePoint.call(this,t,"projective"),null===e&&null===i&&null===r?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new fo(e,16),this.y=new fo(i,16),this.z=r?new fo(r,16):this.curve.one,this.t=n&&new fo(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.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()))))}go.assert,Q(Bo,bo),Po=Bo,Bo.prototype._mulA=function(t){return this.mOneA?t.redNeg():this.a.redMul(t)},Bo.prototype._mulC=function(t){return this.oneC?t:this.c.redMul(t)},Bo.prototype.jpoint=function(t,e,i,r){return this.point(t,e,i,r)},Bo.prototype.pointFromX=function(t,e){(t=new fo(t,16)).red||(t=t.toRed(this.red));var i=t.redSqr(),r=this.c2.redSub(this.a.redMul(i)),n=this.one.redSub(this.c2.redMul(this.d).redMul(i)),s=r.redMul(n.redInvm()),o=s.redSqrt();if(0!==o.redSqr().redSub(s).cmp(this.zero))throw new Error("invalid point");var a=o.fromRed().isOdd();return(e&&!a||!e&&a)&&(o=o.redNeg()),this.point(t,o)},Bo.prototype.pointFromY=function(t,e){(t=new fo(t,16)).red||(t=t.toRed(this.red));var i=t.redSqr(),r=i.redSub(this.c2),n=i.redMul(this.d).redMul(this.c2).redSub(this.a),s=r.redMul(n.redInvm());if(0===s.cmp(this.zero)){if(e)throw new Error("invalid point");return this.point(this.zero,t)}var o=s.redSqrt();if(0!==o.redSqr().redSub(s).cmp(this.zero))throw new Error("invalid point");return o.fromRed().isOdd()!==e&&(o=o.redNeg()),this.point(o,t)},Bo.prototype.validate=function(t){if(t.isInfinity())return!0;t.normalize();var e=t.x.redSqr(),i=t.y.redSqr(),r=e.redMul(this.a).redAdd(i),n=this.c2.redMul(this.one.redAdd(this.d.redMul(e).redMul(i)));return 0===r.cmp(n)},Q(Io,bo.BasePoint),Bo.prototype.pointFromJSON=function(t){return Io.fromJSON(this,t)},Bo.prototype.point=function(t,e,i,r){return new Io(this,t,e,i,r)},Io.fromJSON=function(t,e){return new Io(t,e[0],e[1],e[2])},Io.prototype.inspect=function(){return this.isInfinity()?"":""},Io.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},Io.prototype._extDbl=function(){var t=this.x.redSqr(),e=this.y.redSqr(),i=this.z.redSqr();i=i.redIAdd(i);var r=this.curve._mulA(t),n=this.x.redAdd(this.y).redSqr().redISub(t).redISub(e),s=r.redAdd(e),o=s.redSub(i),a=r.redSub(e),h=n.redMul(o),u=s.redMul(a),f=n.redMul(a),l=o.redMul(s);return this.curve.point(h,u,l,f)},Io.prototype._projDbl=function(){var t,e,i,r,n,s,o=this.x.redAdd(this.y).redSqr(),a=this.x.redSqr(),h=this.y.redSqr();if(this.curve.twisted){var u=(r=this.curve._mulA(a)).redAdd(h);this.zOne?(t=o.redSub(a).redSub(h).redMul(u.redSub(this.curve.two)),e=u.redMul(r.redSub(h)),i=u.redSqr().redSub(u).redSub(u)):(n=this.z.redSqr(),s=u.redSub(n).redISub(n),t=o.redSub(a).redISub(h).redMul(s),e=u.redMul(r.redSub(h)),i=u.redMul(s))}else r=a.redAdd(h),n=this.curve._mulC(this.z).redSqr(),s=r.redSub(n).redSub(n),t=this.curve._mulC(o.redISub(r)).redMul(s),e=this.curve._mulC(r).redMul(a.redISub(h)),i=r.redMul(s);return this.curve.point(t,e,i)},Io.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},Io.prototype._extAdd=function(t){var e=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),i=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),r=this.t.redMul(this.curve.dd).redMul(t.t),n=this.z.redMul(t.z.redAdd(t.z)),s=i.redSub(e),o=n.redSub(r),a=n.redAdd(r),h=i.redAdd(e),u=s.redMul(o),f=a.redMul(h),l=s.redMul(h),d=o.redMul(a);return this.curve.point(u,f,d,l)},Io.prototype._projAdd=function(t){var e,i,r=this.z.redMul(t.z),n=r.redSqr(),s=this.x.redMul(t.x),o=this.y.redMul(t.y),a=this.curve.d.redMul(s).redMul(o),h=n.redSub(a),u=n.redAdd(a),f=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(s).redISub(o),l=r.redMul(h).redMul(f);return this.curve.twisted?(e=r.redMul(u).redMul(o.redSub(this.curve._mulA(s))),i=h.redMul(u)):(e=r.redMul(u).redMul(o.redSub(s)),i=this.curve._mulC(h).redMul(u)),this.curve.point(l,e,i)},Io.prototype.add=function(t){return this.isInfinity()?t:t.isInfinity()?this:this.curve.extended?this._extAdd(t):this._projAdd(t)},Io.prototype.mul=function(t){return this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve._wnafMul(this,t)},Io.prototype.mulAdd=function(t,e,i){return this.curve._wnafMulAdd(1,[this,e],[t,i],2,!1)},Io.prototype.jmulAdd=function(t,e,i){return this.curve._wnafMulAdd(1,[this,e],[t,i],2,!0)},Io.prototype.normalize=function(){if(this.zOne)return this;var t=this.z.redInvm();return this.x=this.x.redMul(t),this.y=this.y.redMul(t),this.t&&(this.t=this.t.redMul(t)),this.z=this.curve.one,this.zOne=!0,this},Io.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},Io.prototype.getX=function(){return this.normalize(),this.x.fromRed()},Io.prototype.getY=function(){return this.normalize(),this.y.fromRed()},Io.prototype.eq=function(t){return this===t||0===this.getX().cmp(t.getX())&&0===this.getY().cmp(t.getY())},Io.prototype.eqXToP=function(t){var e=t.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(e))return!0;for(var i=t.clone(),r=this.curve.redN.redMul(this.z);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(e.redIAdd(r),0===this.x.cmp(e))return!0}},Io.prototype.toP=Io.prototype.normalize,Io.prototype.mixedAdd=Io.prototype.add;var qo={},Oo=qo;Oo.base=bo,Oo.short=So,Oo.mont=Ao,Oo.edwards=Po;var Lo={};function jo(t,e){return 55296==(64512&t.charCodeAt(e))&&!(e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1))}function Co(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function No(t){return 1===t.length?"0"+t:t}function Do(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}Lo.inherits=Q,Lo.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var i=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),n=0;n>6|192,i[r++]=63&s|128):jo(t,n)?(s=65536+((1023&s)<<10)+(1023&t.charCodeAt(++n)),i[r++]=s>>18|240,i[r++]=s>>12&63|128,i[r++]=s>>6&63|128,i[r++]=63&s|128):(i[r++]=s>>12|224,i[r++]=s>>6&63|128,i[r++]=63&s|128)}else for(n=0;n>>0}return n},Lo.split32=function(t,e){for(var i=new Array(4*t.length),r=0,n=0;r>>24,i[n+1]=s>>>16&255,i[n+2]=s>>>8&255,i[n+3]=255&s):(i[n+3]=s>>>24,i[n+2]=s>>>16&255,i[n+1]=s>>>8&255,i[n]=255&s)}return i},Lo.rotr32=function(t,e){return t>>>e|t<<32-e},Lo.rotl32=function(t,e){return t<>>32-e},Lo.sum32=function(t,e){return t+e>>>0},Lo.sum32_3=function(t,e,i){return t+e+i>>>0},Lo.sum32_4=function(t,e,i,r){return t+e+i+r>>>0},Lo.sum32_5=function(t,e,i,r,n){return t+e+i+r+n>>>0},Lo.sum64=function(t,e,i,r){var n=t[e],s=r+t[e+1]>>>0,o=(s>>0,t[e+1]=s},Lo.sum64_hi=function(t,e,i,r){return(e+r>>>0>>0},Lo.sum64_lo=function(t,e,i,r){return e+r>>>0},Lo.sum64_4_hi=function(t,e,i,r,n,s,o,a){var h=0,u=e;return h+=(u=u+r>>>0)>>0)>>0)>>0},Lo.sum64_4_lo=function(t,e,i,r,n,s,o,a){return e+r+s+a>>>0},Lo.sum64_5_hi=function(t,e,i,r,n,s,o,a,h,u){var f=0,l=e;return f+=(l=l+r>>>0)>>0)>>0)>>0)>>0},Lo.sum64_5_lo=function(t,e,i,r,n,s,o,a,h,u){return e+r+s+a+u>>>0},Lo.rotr64_hi=function(t,e,i){return(e<<32-i|t>>>i)>>>0},Lo.rotr64_lo=function(t,e,i){return(t<<32-i|e>>>i)>>>0},Lo.shr64_hi=function(t,e,i){return t>>>i},Lo.shr64_lo=function(t,e,i){return(t<<32-i|e>>>i)>>>0};var Uo={};function $o(){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}Uo.BlockHash=$o,$o.prototype.update=function(t,e){if(t=Lo.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var i=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-i,t.length),0===this.pending.length&&(this.pending=null),t=Lo.join32(t,0,t.length-i,this.endian);for(var r=0;r>>24&255,r[n++]=t>>>16&255,r[n++]=t>>>8&255,r[n++]=255&t}else for(r[n++]=255&t,r[n++]=t>>>8&255,r[n++]=t>>>16&255,r[n++]=t>>>24&255,r[n++]=0,r[n++]=0,r[n++]=0,r[n++]=0,s=8;s>>3},zo.g1_256=function(t){return Wo(t,17)^Wo(t,19)^t>>>10};var Zo,Vo=Lo.rotl32,Go=Lo.sum32,Yo=Lo.sum32_5,Xo=zo.ft_1,Jo=Uo.BlockHash,Qo=[1518500249,1859775393,2400959708,3395469782];function ta(){if(!(this instanceof ta))return new ta;Jo.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Lo.inherits(ta,Jo),Zo=ta,ta.blockSize=512,ta.outSize=160,ta.hmacStrength=80,ta.padLength=64,ta.prototype._update=function(t,e){for(var i=this.W,r=0;r<16;r++)i[r]=t[e+r];for(;rthis.blockSize&&(t=(new this.Hash).update(t).digest());for(var e=t.length;ethis.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(r=i,i=e,e=null),i&&(i=lo.toArray(i,r||"hex"),this._update(i));for(var n=[];n.length"};var yh={};function wh(t,e){if(t instanceof wh)return t;this._importDER(t,e)||(this.r=new fo(t.r,16),this.s=new fo(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}function Mh(){this.place=0}function _h(t,e){var i=t[e.place++];if(!(128&i))return i;var r=15&i;if(0===r||r>4)return!1;for(var n=0,s=0,o=e.place;s>>=0;return!(n<=127)&&(e.place=o,n)}function Sh(t){for(var e=0,i=t.length-1;!t[e]&&!(128&t[e+1])&&e>>3);for(t.push(128|i);--i;)t.push(e>>>(i<<3)&255);t.push(e)}}go.assert,yh=wh,wh.prototype._importDER=function(t,e){t=go.toArray(t,e);var i=new Mh;if(48!==t[i.place++])return!1;var r=_h(t,i);if(!1===r)return!1;if(r+i.place!==t.length)return!1;if(2!==t[i.place++])return!1;var n=_h(t,i);if(!1===n)return!1;var s=t.slice(i.place,n+i.place);if(i.place+=n,2!==t[i.place++])return!1;var o=_h(t,i);if(!1===o)return!1;if(t.length!==o+i.place)return!1;var a=t.slice(i.place,o+i.place);if(0===s[0]){if(!(128&s[1]))return!1;s=s.slice(1)}if(0===a[0]){if(!(128&a[1]))return!1;a=a.slice(1)}return this.r=new fo(s),this.s=new fo(a),this.recoveryParam=null,!0},wh.prototype.toDER=function(t){var e=this.r.toArray(),i=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&i[0]&&(i=[0].concat(i)),e=Sh(e),i=Sh(i);!(i[0]||128&i[1]);)i=i.slice(1);var r=[2];Eh(r,e.length),(r=r.concat(e)).push(2),Eh(r,i.length);var n=r.concat(i),s=[48];return Eh(s,n.length),s=s.concat(n),go.encode(s,t)};var kh,Rh=(go.assert,vh);function Ah(t){if(!(this instanceof Ah))return new Ah(t);"string"==typeof t&&(t=lh[t]),t instanceof lh.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}kh=Ah,Ah.prototype.keyPair=function(t){return new Rh(this,t)},Ah.prototype.keyFromPrivate=function(t,e){return Rh.fromPrivate(this,t,e)},Ah.prototype.keyFromPublic=function(t,e){return Rh.fromPublic(this,t,e)},Ah.prototype.genKeyPair=function(t){t||(t={});for(var e=new mh({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||ss(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),r=this.n.sub(new fo(2));;){var n=new fo(e.generate(i));if(!(n.cmp(r)>0))return n.iaddn(1),this.keyFromPrivate(n)}},Ah.prototype._truncateToN=function(t,e){var i=8*t.byteLength()-this.n.bitLength();return i>0&&(t=t.ushrn(i)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},Ah.prototype.sign=function(t,e,i,r){"object"==typeof i&&(r=i,i=null),r||(r={}),e=this.keyFromPrivate(e,i),t=this._truncateToN(new fo(t,16));for(var n=this.n.byteLength(),s=e.getPrivate().toArray("be",n),o=t.toArray("be",n),a=new mh({hash:this.hash,entropy:s,nonce:o,pers:r.pers,persEnc:r.persEnc||"utf8"}),h=this.n.sub(new fo(1)),u=0;;u++){var f=r.k?r.k(u):new fo(a.generate(this.n.byteLength()));if(!((f=this._truncateToN(f,!0)).cmpn(1)<=0||f.cmp(h)>=0)){var l=this.g.mul(f);if(!l.isInfinity()){var d=l.getX(),c=d.umod(this.n);if(0!==c.cmpn(0)){var p=f.invm(this.n).mul(c.mul(e.getPrivate()).iadd(t));if(0!==(p=p.umod(this.n)).cmpn(0)){var m=(l.getY().isOdd()?1:0)|(0!==d.cmp(c)?2:0);return r.canonical&&p.cmp(this.nh)>0&&(p=this.n.sub(p),m^=1),new yh({r:c,s:p,recoveryParam:m})}}}}}},Ah.prototype.verify=function(t,e,i,r){t=this._truncateToN(new fo(t,16)),i=this.keyFromPublic(i,r);var n=(e=new yh(e,"hex")).r,s=e.s;if(n.cmpn(1)<0||n.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var o,a=s.invm(this.n),h=a.mul(t).umod(this.n),u=a.mul(n).umod(this.n);return this.curve._maxwellTrick?!(o=this.g.jmulAdd(h,i.getPublic(),u)).isInfinity()&&o.eqXToP(n):!(o=this.g.mulAdd(h,i.getPublic(),u)).isInfinity()&&0===o.getX().umod(this.n).cmp(n)},Ah.prototype.recoverPubKey=function(t,e,i,r){e=new yh(e,r);var n=this.n,s=new fo(t),o=e.r,a=e.s,h=1&i,u=i>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");o=u?this.curve.pointFromX(o.add(this.curve.n),h):this.curve.pointFromX(o,h);var f=e.r.invm(n),l=n.sub(s).mul(f).umod(n),d=a.mul(f).umod(n);return this.g.mulAdd(l,o,d)},Ah.prototype.getKeyRecoveryParam=function(t,e,i,r){if(null!==(e=new yh(e,r)).recoveryParam)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(t,e,n)}catch(t){continue}if(s.eq(i))return n}throw new Error("Unable to find valid recovery factor")};var xh={},Th=(go.assert,go.parseBytes),Ph=go.cachedProperty;function Bh(t,e){this.eddsa=t,this._secret=Th(e.secret),t.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=Th(e.pub)}Bh.fromPublic=function(t,e){return e instanceof Bh?e:new Bh(t,{pub:e})},Bh.fromSecret=function(t,e){return e instanceof Bh?e:new Bh(t,{secret:e})},Bh.prototype.secret=function(){return this._secret},Ph(Bh,"pubBytes",(function(){return this.eddsa.encodePoint(this.pub())})),Ph(Bh,"pub",(function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())})),Ph(Bh,"privBytes",(function(){var t=this.eddsa,e=this.hash(),i=t.encodingLength-1,r=e.slice(0,t.encodingLength);return r[0]&=248,r[i]&=127,r[i]|=64,r})),Ph(Bh,"priv",(function(){return this.eddsa.decodeInt(this.privBytes())})),Ph(Bh,"hash",(function(){return this.eddsa.hash().update(this.secret()).digest()})),Ph(Bh,"messagePrefix",(function(){return this.hash().slice(this.eddsa.encodingLength)})),Bh.prototype.sign=function(t){return this.eddsa.sign(t,this)},Bh.prototype.verify=function(t,e){return this.eddsa.verify(t,e,this)},Bh.prototype.getSecret=function(t){return go.encode(this.secret(),t)},Bh.prototype.getPublic=function(t){return go.encode(this.pubBytes(),t)},xh=Bh;var Ih={},qh=(go.assert,go.cachedProperty),Oh=go.parseBytes;function Lh(t,e){this.eddsa=t,"object"!=typeof e&&(e=Oh(e)),Array.isArray(e)&&(e={R:e.slice(0,t.encodingLength),S:e.slice(t.encodingLength)}),t.isPoint(e.R)&&(this._R=e.R),e.S instanceof fo&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}qh(Lh,"S",(function(){return this.eddsa.decodeInt(this.Sencoded())})),qh(Lh,"R",(function(){return this.eddsa.decodePoint(this.Rencoded())})),qh(Lh,"Rencoded",(function(){return this.eddsa.encodePoint(this.R())})),qh(Lh,"Sencoded",(function(){return this.eddsa.encodeInt(this.S())})),Lh.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},Lh.prototype.toHex=function(){return go.encode(this.toBytes(),"hex").toUpperCase()},Ih=Lh;var jh,Ch=(go.assert,go.parseBytes);function Nh(t){if(!(this instanceof Nh))return new Nh(t);t=lh[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=hh.sha512}jh=Nh,Nh.prototype.sign=function(t,e){t=Ch(t);var i=this.keyFromSecret(e),r=this.hashInt(i.messagePrefix(),t),n=this.g.mul(r),s=this.encodePoint(n),o=this.hashInt(s,i.pubBytes(),t).mul(i.priv()),a=r.add(o).umod(this.curve.n);return this.makeSignature({R:n,S:a,Rencoded:s})},Nh.prototype.verify=function(t,e,i){t=Ch(t),e=this.makeSignature(e);var r=this.keyFromPublic(i),n=this.hashInt(e.Rencoded(),r.pubBytes(),t),s=this.g.mul(e.S());return e.R().add(r.pub().mul(n)).eq(s)},Nh.prototype.hashInt=function(){for(var t=this.hash(),e=0;e=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return r}function o(t,e,i,r){for(var n=0,s=Math.min(t.length,i),o=e;o=49?a-49+10:a>=17?a-17+10:a}return n}r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,e){return t.cmp(e)>0?t:e},r.min=function(t,e){return t.cmp(e)<0?t:e},r.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===e?this._parseHex(t,r):this._parseBase(t,e,r),"-"===t[0]&&(this.negative=1),this.strip(),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initArray=function(t,e,i){if(t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r=0;r-=3)s=t[r]|t[r-1]<<8|t[r-2]<<16,this.words[n]|=s<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===i)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this.strip()},r.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=6)n=s(t,i,i+6),this.words[r]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,r++);i+6!==e&&(n=s(t,e,i+6),this.words[r]|=n<>>26-o&4194303),this.strip()},r.prototype._parseBase=function(t,e,i){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=e)r++;r--,n=n/e|0;for(var s=t.length-i,a=s%r,h=Math.min(s,s-a)+i,u=0,f=i;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},r.prototype.inspect=function(){return(this.red?""};var a=["","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"],h=[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],u=[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 f(t,e,i){i.negative=e.negative^t.negative;var r=t.length+e.length|0;i.length=r,r=r-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;i.words[0]=a;for(var u=1;u>>26,l=67108863&h,d=Math.min(u,e.length-1),c=Math.max(0,u-t.length+1);c<=d;c++){var p=u-c|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[c])+l)/67108864|0,l=67108863&o}i.words[u]=0|l,h=0|f}return 0!==h?i.words[u]=0|h:i.length--,i.strip()}r.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var r=0,n=0,s=0;s>>24-r&16777215)||s!==this.length-1?a[6-f.length]+f+i:f+i,(r+=2)>=26&&(r-=26,s--)}for(0!==n&&(i=n.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var l=h[t],d=u[t];i="";var c=this.clone();for(c.negative=0;!c.isZero();){var p=c.modn(d).toString(t);i=(c=c.idivn(d)).isZero()?p+i:a[l-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length,0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16)},r.prototype.toBuffer=function(t,e){return this.toArrayLike(n,t,e)},r.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},r.prototype.toArrayLike=function(t,e,i){var r=this.byteLength(),n=i||Math.max(1,r);this.strip();var s,o,a="le"===e,h=new t(n),u=this.clone();if(a){for(o=0;!u.isZero();o++)s=u.andln(255),u.iushrn(8),h[o]=s;for(;o=4096&&(i+=13,e>>>=13),e>=64&&(i+=7,e>>>=7),e>=8&&(i+=4,e>>>=4),e>=2&&(i+=2,e>>>=2),i+e},r.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,i=0;return 0==(8191&e)&&(i+=13,e>>>=13),0==(127&e)&&(i+=7,e>>>=7),0==(15&e)&&(i+=4,e>>>=4),0==(3&e)&&(i+=2,e>>>=2),0==(1&e)&&i++,i},r.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var i=0;it.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var e,i;this.length>t.length?(e=this,i=t):(e=t,i=this);for(var r=0;rt.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-i),this.strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,e){var i=t/26|0,r=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(i=this,r=t):(i=t,r=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i,r,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(i=this,r=t):(i=t,r=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,c=0|o[1],p=8191&c,m=c>>>13,g=0|o[2],v=8191&g,b=g>>>13,y=0|o[3],w=8191&y,M=y>>>13,_=0|o[4],S=8191&_,E=_>>>13,k=0|o[5],R=8191&k,A=k>>>13,x=0|o[6],T=8191&x,P=x>>>13,B=0|o[7],I=8191&B,q=B>>>13,O=0|o[8],L=8191&O,j=O>>>13,C=0|o[9],N=8191&C,D=C>>>13,U=0|a[0],$=8191&U,z=U>>>13,W=0|a[1],F=8191&W,K=W>>>13,H=0|a[2],Z=8191&H,V=H>>>13,G=0|a[3],Y=8191&G,X=G>>>13,J=0|a[4],Q=8191&J,tt=J>>>13,et=0|a[5],it=8191&et,rt=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,ft=0|a[8],lt=8191&ft,dt=ft>>>13,ct=0|a[9],pt=8191&ct,mt=ct>>>13;i.negative=t.negative^e.negative,i.length=19;var gt=(u+(r=Math.imul(l,$))|0)+((8191&(n=(n=Math.imul(l,z))+Math.imul(d,$)|0))<<13)|0;u=((s=Math.imul(d,z))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(p,$),n=(n=Math.imul(p,z))+Math.imul(m,$)|0,s=Math.imul(m,z);var vt=(u+(r=r+Math.imul(l,F)|0)|0)+((8191&(n=(n=n+Math.imul(l,K)|0)+Math.imul(d,F)|0))<<13)|0;u=((s=s+Math.imul(d,K)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(v,$),n=(n=Math.imul(v,z))+Math.imul(b,$)|0,s=Math.imul(b,z),r=r+Math.imul(p,F)|0,n=(n=n+Math.imul(p,K)|0)+Math.imul(m,F)|0,s=s+Math.imul(m,K)|0;var bt=(u+(r=r+Math.imul(l,Z)|0)|0)+((8191&(n=(n=n+Math.imul(l,V)|0)+Math.imul(d,Z)|0))<<13)|0;u=((s=s+Math.imul(d,V)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(w,$),n=(n=Math.imul(w,z))+Math.imul(M,$)|0,s=Math.imul(M,z),r=r+Math.imul(v,F)|0,n=(n=n+Math.imul(v,K)|0)+Math.imul(b,F)|0,s=s+Math.imul(b,K)|0,r=r+Math.imul(p,Z)|0,n=(n=n+Math.imul(p,V)|0)+Math.imul(m,Z)|0,s=s+Math.imul(m,V)|0;var yt=(u+(r=r+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,X)|0)+Math.imul(d,Y)|0))<<13)|0;u=((s=s+Math.imul(d,X)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(S,$),n=(n=Math.imul(S,z))+Math.imul(E,$)|0,s=Math.imul(E,z),r=r+Math.imul(w,F)|0,n=(n=n+Math.imul(w,K)|0)+Math.imul(M,F)|0,s=s+Math.imul(M,K)|0,r=r+Math.imul(v,Z)|0,n=(n=n+Math.imul(v,V)|0)+Math.imul(b,Z)|0,s=s+Math.imul(b,V)|0,r=r+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,X)|0;var wt=(u+(r=r+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(d,Q)|0))<<13)|0;u=((s=s+Math.imul(d,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(R,$),n=(n=Math.imul(R,z))+Math.imul(A,$)|0,s=Math.imul(A,z),r=r+Math.imul(S,F)|0,n=(n=n+Math.imul(S,K)|0)+Math.imul(E,F)|0,s=s+Math.imul(E,K)|0,r=r+Math.imul(w,Z)|0,n=(n=n+Math.imul(w,V)|0)+Math.imul(M,Z)|0,s=s+Math.imul(M,V)|0,r=r+Math.imul(v,Y)|0,n=(n=n+Math.imul(v,X)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,X)|0,r=r+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var Mt=(u+(r=r+Math.imul(l,it)|0)|0)+((8191&(n=(n=n+Math.imul(l,rt)|0)+Math.imul(d,it)|0))<<13)|0;u=((s=s+Math.imul(d,rt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(T,$),n=(n=Math.imul(T,z))+Math.imul(P,$)|0,s=Math.imul(P,z),r=r+Math.imul(R,F)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(A,F)|0,s=s+Math.imul(A,K)|0,r=r+Math.imul(S,Z)|0,n=(n=n+Math.imul(S,V)|0)+Math.imul(E,Z)|0,s=s+Math.imul(E,V)|0,r=r+Math.imul(w,Y)|0,n=(n=n+Math.imul(w,X)|0)+Math.imul(M,Y)|0,s=s+Math.imul(M,X)|0,r=r+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,tt)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,tt)|0,r=r+Math.imul(p,it)|0,n=(n=n+Math.imul(p,rt)|0)+Math.imul(m,it)|0,s=s+Math.imul(m,rt)|0;var _t=(u+(r=r+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(d,st)|0))<<13)|0;u=((s=s+Math.imul(d,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(I,$),n=(n=Math.imul(I,z))+Math.imul(q,$)|0,s=Math.imul(q,z),r=r+Math.imul(T,F)|0,n=(n=n+Math.imul(T,K)|0)+Math.imul(P,F)|0,s=s+Math.imul(P,K)|0,r=r+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,V)|0)+Math.imul(A,Z)|0,s=s+Math.imul(A,V)|0,r=r+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,X)|0,r=r+Math.imul(w,Q)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(M,Q)|0,s=s+Math.imul(M,tt)|0,r=r+Math.imul(v,it)|0,n=(n=n+Math.imul(v,rt)|0)+Math.imul(b,it)|0,s=s+Math.imul(b,rt)|0,r=r+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(r=r+Math.imul(l,ht)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((s=s+Math.imul(d,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(L,$),n=(n=Math.imul(L,z))+Math.imul(j,$)|0,s=Math.imul(j,z),r=r+Math.imul(I,F)|0,n=(n=n+Math.imul(I,K)|0)+Math.imul(q,F)|0,s=s+Math.imul(q,K)|0,r=r+Math.imul(T,Z)|0,n=(n=n+Math.imul(T,V)|0)+Math.imul(P,Z)|0,s=s+Math.imul(P,V)|0,r=r+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,X)|0,r=r+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(E,Q)|0,s=s+Math.imul(E,tt)|0,r=r+Math.imul(w,it)|0,n=(n=n+Math.imul(w,rt)|0)+Math.imul(M,it)|0,s=s+Math.imul(M,rt)|0,r=r+Math.imul(v,st)|0,n=(n=n+Math.imul(v,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,r=r+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,ut)|0;var Et=(u+(r=r+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,dt)|0)+Math.imul(d,lt)|0))<<13)|0;u=((s=s+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(N,$),n=(n=Math.imul(N,z))+Math.imul(D,$)|0,s=Math.imul(D,z),r=r+Math.imul(L,F)|0,n=(n=n+Math.imul(L,K)|0)+Math.imul(j,F)|0,s=s+Math.imul(j,K)|0,r=r+Math.imul(I,Z)|0,n=(n=n+Math.imul(I,V)|0)+Math.imul(q,Z)|0,s=s+Math.imul(q,V)|0,r=r+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,X)|0,r=r+Math.imul(R,Q)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(A,Q)|0,s=s+Math.imul(A,tt)|0,r=r+Math.imul(S,it)|0,n=(n=n+Math.imul(S,rt)|0)+Math.imul(E,it)|0,s=s+Math.imul(E,rt)|0,r=r+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(M,st)|0,s=s+Math.imul(M,ot)|0,r=r+Math.imul(v,ht)|0,n=(n=n+Math.imul(v,ut)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ut)|0,r=r+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,dt)|0;var kt=(u+(r=r+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(d,pt)|0))<<13)|0;u=((s=s+Math.imul(d,mt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(N,F),n=(n=Math.imul(N,K))+Math.imul(D,F)|0,s=Math.imul(D,K),r=r+Math.imul(L,Z)|0,n=(n=n+Math.imul(L,V)|0)+Math.imul(j,Z)|0,s=s+Math.imul(j,V)|0,r=r+Math.imul(I,Y)|0,n=(n=n+Math.imul(I,X)|0)+Math.imul(q,Y)|0,s=s+Math.imul(q,X)|0,r=r+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(P,Q)|0,s=s+Math.imul(P,tt)|0,r=r+Math.imul(R,it)|0,n=(n=n+Math.imul(R,rt)|0)+Math.imul(A,it)|0,s=s+Math.imul(A,rt)|0,r=r+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(E,st)|0,s=s+Math.imul(E,ot)|0,r=r+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(M,ht)|0,s=s+Math.imul(M,ut)|0,r=r+Math.imul(v,lt)|0,n=(n=n+Math.imul(v,dt)|0)+Math.imul(b,lt)|0,s=s+Math.imul(b,dt)|0;var Rt=(u+(r=r+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(N,Z),n=(n=Math.imul(N,V))+Math.imul(D,Z)|0,s=Math.imul(D,V),r=r+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(j,Y)|0,s=s+Math.imul(j,X)|0,r=r+Math.imul(I,Q)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(q,Q)|0,s=s+Math.imul(q,tt)|0,r=r+Math.imul(T,it)|0,n=(n=n+Math.imul(T,rt)|0)+Math.imul(P,it)|0,s=s+Math.imul(P,rt)|0,r=r+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(A,st)|0,s=s+Math.imul(A,ot)|0,r=r+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(E,ht)|0,s=s+Math.imul(E,ut)|0,r=r+Math.imul(w,lt)|0,n=(n=n+Math.imul(w,dt)|0)+Math.imul(M,lt)|0,s=s+Math.imul(M,dt)|0;var At=(u+(r=r+Math.imul(v,pt)|0)|0)+((8191&(n=(n=n+Math.imul(v,mt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((s=s+Math.imul(b,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(N,Y),n=(n=Math.imul(N,X))+Math.imul(D,Y)|0,s=Math.imul(D,X),r=r+Math.imul(L,Q)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(j,Q)|0,s=s+Math.imul(j,tt)|0,r=r+Math.imul(I,it)|0,n=(n=n+Math.imul(I,rt)|0)+Math.imul(q,it)|0,s=s+Math.imul(q,rt)|0,r=r+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,ot)|0,r=r+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(A,ht)|0,s=s+Math.imul(A,ut)|0,r=r+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,dt)|0)+Math.imul(E,lt)|0,s=s+Math.imul(E,dt)|0;var xt=(u+(r=r+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((s=s+Math.imul(M,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(N,Q),n=(n=Math.imul(N,tt))+Math.imul(D,Q)|0,s=Math.imul(D,tt),r=r+Math.imul(L,it)|0,n=(n=n+Math.imul(L,rt)|0)+Math.imul(j,it)|0,s=s+Math.imul(j,rt)|0,r=r+Math.imul(I,st)|0,n=(n=n+Math.imul(I,ot)|0)+Math.imul(q,st)|0,s=s+Math.imul(q,ot)|0,r=r+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,ut)|0,r=r+Math.imul(R,lt)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(A,lt)|0,s=s+Math.imul(A,dt)|0;var Tt=(u+(r=r+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(E,pt)|0))<<13)|0;u=((s=s+Math.imul(E,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(N,it),n=(n=Math.imul(N,rt))+Math.imul(D,it)|0,s=Math.imul(D,rt),r=r+Math.imul(L,st)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(j,st)|0,s=s+Math.imul(j,ot)|0,r=r+Math.imul(I,ht)|0,n=(n=n+Math.imul(I,ut)|0)+Math.imul(q,ht)|0,s=s+Math.imul(q,ut)|0,r=r+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,dt)|0)+Math.imul(P,lt)|0,s=s+Math.imul(P,dt)|0;var Pt=(u+(r=r+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((s=s+Math.imul(A,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(N,st),n=(n=Math.imul(N,ot))+Math.imul(D,st)|0,s=Math.imul(D,ot),r=r+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,ut)|0)+Math.imul(j,ht)|0,s=s+Math.imul(j,ut)|0,r=r+Math.imul(I,lt)|0,n=(n=n+Math.imul(I,dt)|0)+Math.imul(q,lt)|0,s=s+Math.imul(q,dt)|0;var Bt=(u+(r=r+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((s=s+Math.imul(P,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(N,ht),n=(n=Math.imul(N,ut))+Math.imul(D,ht)|0,s=Math.imul(D,ut),r=r+Math.imul(L,lt)|0,n=(n=n+Math.imul(L,dt)|0)+Math.imul(j,lt)|0,s=s+Math.imul(j,dt)|0;var It=(u+(r=r+Math.imul(I,pt)|0)|0)+((8191&(n=(n=n+Math.imul(I,mt)|0)+Math.imul(q,pt)|0))<<13)|0;u=((s=s+Math.imul(q,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(N,lt),n=(n=Math.imul(N,dt))+Math.imul(D,lt)|0,s=Math.imul(D,dt);var qt=(u+(r=r+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,mt)|0)+Math.imul(j,pt)|0))<<13)|0;u=((s=s+Math.imul(j,mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863;var Ot=(u+(r=Math.imul(N,pt))|0)+((8191&(n=(n=Math.imul(N,mt))+Math.imul(D,pt)|0))<<13)|0;return u=((s=Math.imul(D,mt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=vt,h[2]=bt,h[3]=yt,h[4]=wt,h[5]=Mt,h[6]=_t,h[7]=St,h[8]=Et,h[9]=kt,h[10]=Rt,h[11]=At,h[12]=xt,h[13]=Tt,h[14]=Pt,h[15]=Bt,h[16]=It,h[17]=qt,h[18]=Ot,0!==u&&(h[19]=u,i.length++),i};function d(t,e,i){return(new c).mulp(t,e,i)}function c(t,e){this.x=t,this.y=e}Math.imul||(l=f),r.prototype.mulTo=function(t,e){var i=this.length+t.length;return 10===this.length&&10===t.length?l(this,t,e):i<63?f(this,t,e):i<1024?function(t,e,i){i.negative=e.negative^t.negative,i.length=t.length+e.length;for(var r=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}i.words[s]=a,r=o,o=n}return 0!==r?i.words[s]=r:i.length--,i.strip()}(this,t,e):d(this,t,e)},c.prototype.makeRBT=function(t){for(var e=new Array(t),i=r.prototype._countBits(t)-1,n=0;n>=1;return r},c.prototype.permute=function(t,e,i,r,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*s+1]=8191&n,n>>>=13;for(s=2*e;s>=26,e+=r/67108864|0,e+=n>>>26,this.words[i]=67108863&n}return 0!==e&&(this.words[i]=e,this.length++),this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),i=0;i>>n}return e}(t);if(0===e.length)return new r(1);for(var i=this,n=0;n>>26-i<<26-i;if(0!==i){var s=0;for(e=0;e>>26-i}s&&(this.words[e]=s,this.length++)}if(0!==r){for(e=this.length-1;e>=0;e--)this.words[e+r]=this.words[e];for(e=0;e>>n<s)for(this.length-=s,h=0;h=0&&(0!==u||h>=r);h--){var f=0|this.words[h];this.words[h]=u<<26-n|f>>>n,u=f&o}return a&&0!==u&&(a.words[a.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},r.prototype.ishrn=function(t,e,i){return this.iushrn(t,e,i)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){var e=t%26,i=(t-e)/26,r=1<>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},r.prototype.isubn=function(t){if(t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(a/67108864|0),this.words[r+i]=67108863&n}for(;r>26,this.words[r+i]=67108863&n;if(0===o)return this.strip();for(o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},r.prototype._wordDiv=function(t,e){var i=(this.length,t.length),n=this.clone(),s=t,o=0|s.words[s.length-1];0!=(i=26-this._countBits(o))&&(s=s.ushln(i),n.iushln(i),o=0|s.words[s.length-1]);var a,h=n.length-s.length;if("mod"!==e){(a=new r(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u=0;l--){var d=67108864*(0|n.words[s.length+l])+(0|n.words[s.length+l-1]);for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(s,d,l);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(s,1,l),n.isZero()||(n.negative^=1);a&&(a.words[l]=d)}return a&&a.strip(),n.strip(),"div"!==e&&0!==i&&n.iushrn(i),{div:a||null,mod:n}},r.prototype.divmod=function(t,e,i){return this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),"mod"!==e&&(n=o.div.neg()),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),e),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new r(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var i=0!==e.div.negative?e.mod.isub(t):e.mod,r=t.ushrn(1),n=t.andln(1),s=i.cmp(r);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},r.prototype.modn=function(t){for(var e=(1<<26)%t,i=0,r=this.length-1;r>=0;r--)i=(e*i+(0|this.words[r]))%t;return i},r.prototype.idivn=function(t){for(var e=0,i=this.length-1;i>=0;i--){var r=(0|this.words[i])+67108864*e;this.words[i]=r/t|0,e=r%t}return this.strip()},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new r(1),s=new r(0),o=new r(0),a=new r(1),h=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++h;for(var u=i.clone(),f=e.clone();!e.isZero();){for(var l=0,d=1;0==(e.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(e.iushrn(l);l-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(u),s.isub(f)),n.iushrn(1),s.iushrn(1);for(var c=0,p=1;0==(i.words[0]&p)&&c<26;++c,p<<=1);if(c>0)for(i.iushrn(c);c-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(u),a.isub(f)),o.iushrn(1),a.iushrn(1);e.cmp(i)>=0?(e.isub(i),n.isub(o),s.isub(a)):(i.isub(e),o.isub(n),a.isub(s))}return{a:o,b:a,gcd:i.iushln(h)}},r.prototype._invmp=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new r(1),o=new r(0),a=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var h=0,u=1;0==(e.words[0]&u)&&h<26;++h,u<<=1);if(h>0)for(e.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(a),s.iushrn(1);for(var f=0,l=1;0==(i.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(i.iushrn(f);f-- >0;)o.isOdd()&&o.iadd(a),o.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o)):(i.isub(e),o.isub(s))}return(n=0===e.cmpn(1)?s:o).cmpn(0)<0&&n.iadd(t),n},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),i=t.clone();e.negative=0,i.negative=0;for(var r=0;e.isEven()&&i.isEven();r++)e.iushrn(1),i.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;i.isEven();)i.iushrn(1);var n=e.cmp(i);if(n<0){var s=e;e=i,i=s}else if(0===n||0===i.cmpn(1))break;e.isub(i)}return i.iushln(r)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){var e=t%26,i=(t-e)/26,r=1<>>26,o&=67108863,this.words[s]=o}return 0!==n&&(this.words[s]=n,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t);var r=0|this.words[0];e=r===t?0:rt.length)return 1;if(this.length=0;i--){var r=0|this.words[i],n=0|t.words[i];if(r!==n){rn&&(e=1);break}}return e},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new M(t)},r.prototype.toRed=function(t){return t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return this._forceRed(t)},r.prototype.redAdd=function(t){return this.red.add(this,t)},r.prototype.redIAdd=function(t){return this.red.iadd(this,t)},r.prototype.redSub=function(t){return this.red.sub(this,t)},r.prototype.redISub=function(t){return this.red.isub(this,t)},r.prototype.redShl=function(t){return this.red.shl(this,t)},r.prototype.redMul=function(t){return this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return this.red._verify1(this),this.red.pow(this,t)};var p={k256:null,p224:null,p192:null,p25519:null};function m(t,e){this.name=t,this.p=new r(e,16),this.n=this.p.bitLength(),this.k=new r(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 v(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function y(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(t){if("string"==typeof t){var e=r._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function _(t){M.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(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 t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},m.prototype.ireduce=function(t){var e,i=t;do{this.split(i,this.tmp),e=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(e>this.n);var r=e0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},m.prototype.split=function(t,e){t.iushrn(this.n,0,e)},m.prototype.imulK=function(t){return t.imul(this.k)},i(g,m),g.prototype.split=function(t,e){for(var i=Math.min(t.length,9),r=0;r>>22,n=s}n>>>=22,t.words[r-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},g.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,i=0;i>>=26,t.words[i]=n,e=r}return 0!==e&&(t.words[t.length++]=e),t},r._prime=function(t){if(p[t])return p[t];var e;if("k256"===t)e=new g;else if("p224"===t)e=new v;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new y}return p[t]=e,e},M.prototype._verify1=function(t){},M.prototype._verify2=function(t,e){},M.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},M.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},M.prototype.add=function(t,e){this._verify2(t,e);var i=t.add(e);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},M.prototype.iadd=function(t,e){this._verify2(t,e);var i=t.iadd(e);return i.cmp(this.m)>=0&&i.isub(this.m),i},M.prototype.sub=function(t,e){this._verify2(t,e);var i=t.sub(e);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},M.prototype.isub=function(t,e){this._verify2(t,e);var i=t.isub(e);return i.cmpn(0)<0&&i.iadd(this.m),i},M.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},M.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},M.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},M.prototype.isqr=function(t){return this.imul(t,t.clone())},M.prototype.sqr=function(t){return this.mul(t,t)},M.prototype.sqrt=function(t){if(t.isZero())return t.clone();if(3===this.m.andln(3)){var e=this.m.add(new r(1)).iushrn(2);return this.pow(t,e)}for(var i=this.m.subn(1),n=0;!i.isZero()&&0===i.andln(1);)n++,i.iushrn(1);var s=new r(1).toRed(this),o=s.redNeg(),a=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new r(2*h*h).toRed(this);0!==this.pow(h,a).cmp(o);)h.redIAdd(o);for(var u=this.pow(h,i),f=this.pow(t,i.addn(1).iushrn(1)),l=this.pow(t,i),d=n;0!==l.cmp(s);){for(var c=l,p=0;0!==c.cmp(s);p++)c=c.redSqr();var m=this.pow(u,new r(1).iushln(d-p-1));f=f.redMul(m),u=m.redSqr(),l=l.redMul(u),d=p}return f},M.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},M.prototype.pow=function(t,e){if(e.isZero())return new r(1).toRed(this);if(0===e.cmpn(1))return t.clone();var i=new Array(16);i[0]=new r(1).toRed(this),i[1]=t;for(var n=2;n=0;n--){for(var u=e.words[n],f=h-1;f>=0;f--){var l=u>>f&1;s!==i[0]&&(s=this.sqr(s)),0!==l||0!==o?(o<<=1,o|=l,(4==++a||0===n&&0===f)&&(s=this.mul(s,i[o]),a=0,o=0)):a=0}h=26}return s},M.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},M.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},r.mont=function(t){return new _(t)},i(_,M),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(e),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new r(0)._forceRed(this);var i=t.mul(e),n=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=i.isub(n).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}($h,this),$h=$h.exports;var zh={};(function(t){(function(){"use strict";var e,i=M({}),r=i.Buffer,n={};for(e in i)i.hasOwnProperty(e)&&"SlowBuffer"!==e&&"Buffer"!==e&&(n[e]=i[e]);var s=n.Buffer={};for(e in r)r.hasOwnProperty(e)&&"allocUnsafe"!==e&&"allocUnsafeSlow"!==e&&(s[e]=r[e]);if(n.Buffer.prototype=r.prototype,s.from&&s.from!==Uint8Array.from||(s.from=function(t,e,i){if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof t);if(t&&void 0===t.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);return r(t,e,i)}),s.alloc||(s.alloc=function(t,e,i){if("number"!=typeof t)throw new TypeError('The "size" argument must be of type number. Received type '+typeof t);if(t<0||t>=2*(1<<30))throw new RangeError('The value "'+t+'" is invalid for option "size"');var n=r(t);return e&&0!==e.length?"string"==typeof i?n.fill(e,i):n.fill(e):n.fill(0),n}),!n.kStringMaxLength)try{n.kStringMaxLength=t.binding("buffer").kStringMaxLength}catch(jf){}n.constants||(n.constants={MAX_LENGTH:n.kMaxLength},n.kStringMaxLength&&(n.constants.MAX_STRING_LENGTH=n.kStringMaxLength)),zh=n}).call(this)}).call(this,D);var Wh={};function Fh(t){this._reporterState={obj:null,path:[],options:t||{},errors:[]}}function Kh(t,e){this.path=t,this.rethrow(e)}Wh.Reporter=Fh,Fh.prototype.isError=function(t){return t instanceof Kh},Fh.prototype.save=function(){const t=this._reporterState;return{obj:t.obj,pathLen:t.path.length}},Fh.prototype.restore=function(t){const e=this._reporterState;e.obj=t.obj,e.path=e.path.slice(0,t.pathLen)},Fh.prototype.enterKey=function(t){return this._reporterState.path.push(t)},Fh.prototype.exitKey=function(t){const e=this._reporterState;e.path=e.path.slice(0,t-1)},Fh.prototype.leaveKey=function(t,e,i){const r=this._reporterState;this.exitKey(t),null!==r.obj&&(r.obj[e]=i)},Fh.prototype.path=function(){return this._reporterState.path.join("/")},Fh.prototype.enterObject=function(){const t=this._reporterState,e=t.obj;return t.obj={},e},Fh.prototype.leaveObject=function(t){const e=this._reporterState,i=e.obj;return e.obj=t,i},Fh.prototype.error=function(t){let e;const i=this._reporterState,r=t instanceof Kh;if(e=r?t:new Kh(i.path.map((function(t){return"["+JSON.stringify(t)+"]"})).join(""),t.message||t,t.stack),!i.options.partial)throw e;return r||i.errors.push(e),e},Fh.prototype.wrapResult=function(t){const e=this._reporterState;return e.options.partial?{result:this.isError(t)?null:t,errors:e.errors}:t},Q(Kh,Error),Kh.prototype.rethrow=function(t){if(this.message=t+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,Kh),!this.stack)try{throw new Error(this.message)}catch(jf){this.stack=jf.stack}return this};var Hh={};const Zh=Wh.Reporter,Vh=zh.Buffer;function Gh(t,e){Zh.call(this,e),Vh.isBuffer(t)?(this.base=t,this.offset=0,this.length=t.length):this.error("Input not Buffer")}function Yh(t,e){if(Array.isArray(t))this.length=0,this.value=t.map((function(t){return Yh.isEncoderBuffer(t)||(t=new Yh(t,e)),this.length+=t.length,t}),this);else if("number"==typeof t){if(!(0<=t&&t<=255))return e.error("non-byte EncoderBuffer value");this.value=t,this.length=1}else if("string"==typeof t)this.value=t,this.length=Vh.byteLength(t);else{if(!Vh.isBuffer(t))return e.error("Unsupported type: "+typeof t);this.value=t,this.length=t.length}}Q(Gh,Zh),Hh.DecoderBuffer=Gh,Gh.isDecoderBuffer=function(t){return t instanceof Gh||"object"==typeof t&&Vh.isBuffer(t.base)&&"DecoderBuffer"===t.constructor.name&&"number"==typeof t.offset&&"number"==typeof t.length&&"function"==typeof t.save&&"function"==typeof t.restore&&"function"==typeof t.isEmpty&&"function"==typeof t.readUInt8&&"function"==typeof t.skip&&"function"==typeof t.raw},Gh.prototype.save=function(){return{offset:this.offset,reporter:Zh.prototype.save.call(this)}},Gh.prototype.restore=function(t){const e=new Gh(this.base);return e.offset=t.offset,e.length=this.offset,this.offset=t.offset,Zh.prototype.restore.call(this,t.reporter),e},Gh.prototype.isEmpty=function(){return this.offset===this.length},Gh.prototype.readUInt8=function(t){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(t||"DecoderBuffer overrun")},Gh.prototype.skip=function(t,e){if(!(this.offset+t<=this.length))return this.error(e||"DecoderBuffer overrun");const i=new Gh(this.base);return i._reporterState=this._reporterState,i.offset=this.offset,i.length=this.offset+t,this.offset+=t,i},Gh.prototype.raw=function(t){return this.base.slice(t?t.offset:this.offset,this.length)},Hh.EncoderBuffer=Yh,Yh.isEncoderBuffer=function(t){return t instanceof Yh||"object"==typeof t&&"EncoderBuffer"===t.constructor.name&&"number"==typeof t.length&&"function"==typeof t.join},Yh.prototype.join=function(t,e){return t||(t=Vh.alloc(this.length)),e||(e=0),0===this.length||(Array.isArray(this.value)?this.value.forEach((function(i){i.join(t,e),e+=i.length})):("number"==typeof this.value?t[e]=this.value:"string"==typeof this.value?t.write(this.value,e):Vh.isBuffer(this.value)&&this.value.copy(t,e),e+=this.length)),t};const Xh=Wh.Reporter,Jh=Hh.EncoderBuffer,Qh=Hh.DecoderBuffer,tu=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],eu=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(tu);function iu(t,e,i){const r={};this._baseState=r,r.name=i,r.enc=t,r.parent=e||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r.default=null,r.explicit=null,r.implicit=null,r.contains=null,r.parent||(r.children=[],this._wrap())}var ru=iu;const nu=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];iu.prototype.clone=function(){const t=this._baseState,e={};nu.forEach((function(i){e[i]=t[i]}));const i=new this.constructor(e.parent);return i._baseState=e,i},iu.prototype._wrap=function(){const t=this._baseState;eu.forEach((function(e){this[e]=function(){const i=new this.constructor(this);return t.children.push(i),i[e].apply(i,arguments)}}),this)},iu.prototype._init=function(t){const e=this._baseState;t.call(this),e.children=e.children.filter((function(t){return t._baseState.parent===this}),this)},iu.prototype._useArgs=function(t){const e=this._baseState,i=t.filter((function(t){return t instanceof this.constructor}),this);t=t.filter((function(t){return!(t instanceof this.constructor)}),this),0!==i.length&&(e.children=i,i.forEach((function(t){t._baseState.parent=this}),this)),0!==t.length&&(e.args=t,e.reverseArgs=t.map((function(t){if("object"!=typeof t||t.constructor!==Object)return t;const e={};return Object.keys(t).forEach((function(i){i==(0|i)&&(i|=0);const r=t[i];e[r]=i})),e})))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach((function(t){iu.prototype[t]=function(){const e=this._baseState;throw new Error(t+" not implemented for encoding: "+e.enc)}})),tu.forEach((function(t){iu.prototype[t]=function(){const e=this._baseState,i=Array.prototype.slice.call(arguments);return e.tag=t,this._useArgs(i),this}})),iu.prototype.use=function(t){return this._baseState.use=t,this},iu.prototype.optional=function(){return this._baseState.optional=!0,this},iu.prototype.def=function(t){const e=this._baseState;return e.default=t,e.optional=!0,this},iu.prototype.explicit=function(t){return this._baseState.explicit=t,this},iu.prototype.implicit=function(t){return this._baseState.implicit=t,this},iu.prototype.obj=function(){const t=this._baseState,e=Array.prototype.slice.call(arguments);return t.obj=!0,0!==e.length&&this._useArgs(e),this},iu.prototype.key=function(t){return this._baseState.key=t,this},iu.prototype.any=function(){return this._baseState.any=!0,this},iu.prototype.choice=function(t){return this._baseState.choice=t,this._useArgs(Object.keys(t).map((function(e){return t[e]}))),this},iu.prototype.contains=function(t){return this._baseState.contains=t,this},iu.prototype._decode=function(t,e){const i=this._baseState;if(null===i.parent)return t.wrapResult(i.children[0]._decode(t,e));let r,n=i.default,s=!0,o=null;if(null!==i.key&&(o=t.enterKey(i.key)),i.optional){let r=null;if(null!==i.explicit?r=i.explicit:null!==i.implicit?r=i.implicit:null!==i.tag&&(r=i.tag),null!==r||i.any){if(s=this._peekTag(t,r,i.any),t.isError(s))return s}else{const r=t.save();try{null===i.choice?this._decodeGeneric(i.tag,t,e):this._decodeChoice(t,e),s=!0}catch(jf){s=!1}t.restore(r)}}if(i.obj&&s&&(r=t.enterObject()),s){if(null!==i.explicit){const e=this._decodeTag(t,i.explicit);if(t.isError(e))return e;t=e}const r=t.offset;if(null===i.use&&null===i.choice){let e;i.any&&(e=t.save());const r=this._decodeTag(t,null!==i.implicit?i.implicit:i.tag,i.any);if(t.isError(r))return r;i.any?n=t.raw(e):t=r}if(e&&e.track&&null!==i.tag&&e.track(t.path(),r,t.length,"tagged"),e&&e.track&&null!==i.tag&&e.track(t.path(),t.offset,t.length,"content"),i.any||(n=null===i.choice?this._decodeGeneric(i.tag,t,e):this._decodeChoice(t,e)),t.isError(n))return n;if(i.any||null!==i.choice||null===i.children||i.children.forEach((function(i){i._decode(t,e)})),i.contains&&("octstr"===i.tag||"bitstr"===i.tag)){const r=new Qh(n);n=this._getUse(i.contains,t._reporterState.obj)._decode(r,e)}}return i.obj&&s&&(n=t.leaveObject(r)),null===i.key||null===n&&!0!==s?null!==o&&t.exitKey(o):t.leaveKey(o,i.key,n),n},iu.prototype._decodeGeneric=function(t,e,i){const r=this._baseState;return"seq"===t||"set"===t?null:"seqof"===t||"setof"===t?this._decodeList(e,t,r.args[0],i):/str$/.test(t)?this._decodeStr(e,t,i):"objid"===t&&r.args?this._decodeObjid(e,r.args[0],r.args[1],i):"objid"===t?this._decodeObjid(e,null,null,i):"gentime"===t||"utctime"===t?this._decodeTime(e,t,i):"null_"===t?this._decodeNull(e,i):"bool"===t?this._decodeBool(e,i):"objDesc"===t?this._decodeStr(e,t,i):"int"===t||"enum"===t?this._decodeInt(e,r.args&&r.args[0],i):null!==r.use?this._getUse(r.use,e._reporterState.obj)._decode(e,i):e.error("unknown tag: "+t)},iu.prototype._getUse=function(t,e){const i=this._baseState;return i.useDecoder=this._use(t,e),i.useDecoder=i.useDecoder._baseState.children[0],i.implicit!==i.useDecoder._baseState.implicit&&(i.useDecoder=i.useDecoder.clone(),i.useDecoder._baseState.implicit=i.implicit),i.useDecoder},iu.prototype._decodeChoice=function(t,e){const i=this._baseState;let r=null,n=!1;return Object.keys(i.choice).some((function(s){const o=t.save(),a=i.choice[s];try{const i=a._decode(t,e);if(t.isError(i))return!1;r={type:s,value:i},n=!0}catch(jf){return t.restore(o),!1}return!0}),this),n?r:t.error("Choice not matched")},iu.prototype._createEncoderBuffer=function(t){return new Jh(t,this.reporter)},iu.prototype._encode=function(t,e,i){const r=this._baseState;if(null!==r.default&&r.default===t)return;const n=this._encodeValue(t,e,i);return void 0===n||this._skipDefault(n,e,i)?void 0:n},iu.prototype._encodeValue=function(t,e,i){const r=this._baseState;if(null===r.parent)return r.children[0]._encode(t,e||new Xh);let n=null;if(this.reporter=e,r.optional&&void 0===t){if(null===r.default)return;t=r.default}let s=null,o=!1;if(r.any)n=this._createEncoderBuffer(t);else if(r.choice)n=this._encodeChoice(t,e);else if(r.contains)s=this._getUse(r.contains,i)._encode(t,e),o=!0;else if(r.children)s=r.children.map((function(i){if("null_"===i._baseState.tag)return i._encode(null,e,t);if(null===i._baseState.key)return e.error("Child should have a key");const r=e.enterKey(i._baseState.key);if("object"!=typeof t)return e.error("Child expected, but input is not object");const n=i._encode(t[i._baseState.key],e,t);return e.leaveKey(r),n}),this).filter((function(t){return t})),s=this._createEncoderBuffer(s);else if("seqof"===r.tag||"setof"===r.tag){if(!r.args||1!==r.args.length)return e.error("Too many args for : "+r.tag);if(!Array.isArray(t))return e.error("seqof/setof, but data is not Array");const i=this.clone();i._baseState.implicit=null,s=this._createEncoderBuffer(t.map((function(i){const r=this._baseState;return this._getUse(r.args[0],t)._encode(i,e)}),i))}else null!==r.use?n=this._getUse(r.use,i)._encode(t,e):(s=this._encodePrimitive(r.tag,t),o=!0);if(!r.any&&null===r.choice){const t=null!==r.implicit?r.implicit:r.tag,i=null===r.implicit?"universal":"context";null===t?null===r.use&&e.error("Tag could be omitted only for .use()"):null===r.use&&(n=this._encodeComposite(t,o,i,s))}return null!==r.explicit&&(n=this._encodeComposite(r.explicit,!1,"context",n)),n},iu.prototype._encodeChoice=function(t,e){return this._baseState.choice[t.type]._encode(t.value,e)},iu.prototype._encodePrimitive=function(t,e){const i=this._baseState;if(/str$/.test(t))return this._encodeStr(e,t);if("objid"===t&&i.args)return this._encodeObjid(e,i.reverseArgs[0],i.args[1]);if("objid"===t)return this._encodeObjid(e,null,null);if("gentime"===t||"utctime"===t)return this._encodeTime(e,t);if("null_"===t)return this._encodeNull();if("int"===t||"enum"===t)return this._encodeInt(e,i.args&&i.reverseArgs[0]);if("bool"===t)return this._encodeBool(e);if("objDesc"===t)return this._encodeStr(e,t);throw new Error("Unsupported tag: "+t)},iu.prototype._isNumstr=function(t){return/^[0-9 ]*$/.test(t)},iu.prototype._isPrintstr=function(t){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(t)};var su={};function ou(t){const e={};return Object.keys(t).forEach((function(i){(0|i)==i&&(i|=0);const r=t[i];e[r]=i})),e}su.tagClass={0:"universal",1:"application",2:"context",3:"private"},su.tagClassByName=ou(su.tagClass),su.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},su.tagByName=ou(su.tag);var au={};const hu=zh.Buffer;function uu(t){this.enc="der",this.name=t.name,this.entity=t,this.tree=new fu,this.tree._init(t.body)}function fu(t){ru.call(this,"der",t)}function lu(t){return t<10?"0"+t:t}au=uu,uu.prototype.encode=function(t,e){return this.tree._encode(t,e).join()},Q(fu,ru),fu.prototype._encodeComposite=function(t,e,i,r){const n=function(t,e,i,r){let n;if("seqof"===t?t="seq":"setof"===t&&(t="set"),su.tagByName.hasOwnProperty(t))n=su.tagByName[t];else{if("number"!=typeof t||(0|t)!==t)return r.error("Unknown tag: "+t);n=t}return n>=31?r.error("Multi-octet tag encoding unsupported"):(e||(n|=32),n|su.tagClassByName[i||"universal"]<<6)}(t,e,i,this.reporter);if(r.length<128){const t=hu.alloc(2);return t[0]=n,t[1]=r.length,this._createEncoderBuffer([t,r])}let s=1;for(let a=r.length;a>=256;a>>=8)s++;const o=hu.alloc(2+s);o[0]=n,o[1]=128|s;for(let a=1+s,h=r.length;h>0;a--,h>>=8)o[a]=255&h;return this._createEncoderBuffer([o,r])},fu.prototype._encodeStr=function(t,e){if("bitstr"===e)return this._createEncoderBuffer([0|t.unused,t.data]);if("bmpstr"===e){const e=hu.alloc(2*t.length);for(let i=0;i=40)return this.reporter.error("Second objid identifier OOB");t.splice(0,2,40*t[0]+t[1])}let r=0;for(let o=0;o=128;e>>=7)r++}const n=hu.alloc(r);let s=n.length-1;for(let o=t.length-1;o>=0;o--){let e=t[o];for(n[s--]=127&e;(e>>=7)>0;)n[s--]=128|127&e}return this._createEncoderBuffer(n)},fu.prototype._encodeTime=function(t,e){let i;const r=new Date(t);return"gentime"===e?i=[lu(r.getUTCFullYear()),lu(r.getUTCMonth()+1),lu(r.getUTCDate()),lu(r.getUTCHours()),lu(r.getUTCMinutes()),lu(r.getUTCSeconds()),"Z"].join(""):"utctime"===e?i=[lu(r.getUTCFullYear()%100),lu(r.getUTCMonth()+1),lu(r.getUTCDate()),lu(r.getUTCHours()),lu(r.getUTCMinutes()),lu(r.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+e+" time is not supported yet"),this._encodeStr(i,"octstr")},fu.prototype._encodeNull=function(){return this._createEncoderBuffer("")},fu.prototype._encodeInt=function(t,e){if("string"==typeof t){if(!e)return this.reporter.error("String int or enum given, but no values map");if(!e.hasOwnProperty(t))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(t));t=e[t]}if("number"!=typeof t&&!hu.isBuffer(t)){const e=t.toArray();!t.sign&&128&e[0]&&e.unshift(0),t=hu.from(e)}if(hu.isBuffer(t)){let e=t.length;0===t.length&&e++;const i=hu.alloc(e);return t.copy(i),0===t.length&&(i[0]=0),this._createEncoderBuffer(i)}if(t<128)return this._createEncoderBuffer(t);if(t<256)return this._createEncoderBuffer([0,t]);let i=1;for(let n=t;n>=256;n>>=8)i++;const r=new Array(i);for(let n=r.length-1;n>=0;n--)r[n]=255&t,t>>=8;return 128&r[0]&&r.unshift(0),this._createEncoderBuffer(hu.from(r))},fu.prototype._encodeBool=function(t){return this._createEncoderBuffer(t?255:0)},fu.prototype._use=function(t,e){return"function"==typeof t&&(t=t(e)),t._getEncoder("der").tree},fu.prototype._skipDefault=function(t,e,i){const r=this._baseState;let n;if(null===r.default)return!1;const s=t.join();if(void 0===r.defaultBuffer&&(r.defaultBuffer=this._encodeValue(r.default,e,i).join()),s.length!==r.defaultBuffer.length)return!1;for(n=0;n>6],n=0==(32&i);if(31==(31&i)){let r=i;for(i=0;128==(128&r);){if(r=t.readUInt8(e),t.isError(r))return r;i<<=7,i|=127&r}}else i&=31;return{cls:r,primitive:n,tag:i,tagStr:su.tag[i]}}function Mu(t,e,i){let r=t.readUInt8(i);if(t.isError(r))return r;if(!e&&128===r)return null;if(0==(128&r))return r;const n=127&r;if(n>4)return t.error("length octect is too long");r=0;for(let s=0;s0&&i.ishrn(r),i}function vf(t,e,i){var r,n;do{for(r=cf.alloc(0);8*r.length=e)throw new Error("invalid sig")}var _f=I.Buffer;function Sf(t){ao.Writable.call(this);var e=Er[t];if(!e)throw new Error("Unknown message digest");this._hashType=e.hash,this._hash=cr(e.hash),this._tag=e.id,this._signType=e.sign}function Ef(t){ao.Writable.call(this);var e=Er[t];if(!e)throw new Error("Unknown message digest");this._hash=cr(e.hash),this._tag=e.id,this._signType=e.sign}Object.keys(Er).forEach((function(t){Er[t].id=_f.from(Er[t].id,"hex"),Er[t.toLowerCase()]=Er[t]})),Q(Sf,ao.Writable),Sf.prototype._write=function(t,e,i){this._hash.update(t),i()},Sf.prototype.update=function(t,e){return"string"==typeof t&&(t=_f.from(t,e)),this._hash.update(t),this},Sf.prototype.sign=function(t,e){this.end();var i=this._hash.digest(),r=lf(i,t,this._hashType,this._signType,this._tag);return e?r.toString(e):r},Q(Ef,ao.Writable),Ef.prototype._write=function(t,e,i){this._hash.update(t),i()},Ef.prototype.update=function(t,e){return"string"==typeof t&&(t=_f.from(t,e)),this._hash.update(t),this},Ef.prototype.verify=function(t,e,i){return"string"==typeof e&&(e=_f.from(e,i)),this.end(),function(t,e,i,r,n){var s=hf(i);if("ec"===s.type){if("ecdsa"!==r&&"ecdsa/rsa"!==r)throw new Error("wrong public key type");return function(t,e,i){var r=df[i.data.algorithm.curve.join(".")];if(!r)throw new Error("unknown curve "+i.data.algorithm.curve.join("."));var n=new wf(r),s=i.data.subjectPrivateKey.data;return n.verify(e,t,s)}(t,e,s)}if("dsa"===s.type){if("dsa"!==r)throw new Error("wrong public key type");return function(t,e,i){var r=i.data.p,n=i.data.q,s=i.data.g,o=i.data.pub_key,a=hf.signature.decode(t,"der"),h=a.s,u=a.r;Mf(h,n),Mf(u,n);var f=ho.mont(r),l=h.invm(n);return 0===s.toRed(f).redPow(new ho(e).mul(l).mod(n)).fromRed().mul(o.toRed(f).redPow(u.mul(l).mod(n)).fromRed()).mod(r).mod(n).cmp(u)}(t,e,s)}if("rsa"!==r&&"ecdsa/rsa"!==r)throw new Error("wrong public key type");e=yf.concat([n,e]);for(var o=s.modulus.byteLength(),a=[1],h=0;e.length+a.length+2=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return r}function o(t,e,i,r){for(var n=0,s=Math.min(t.length,i),o=e;o=49?a-49+10:a>=17?a-17+10:a}return n}r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,e){return t.cmp(e)>0?t:e},r.min=function(t,e){return t.cmp(e)<0?t:e},r.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===e?this._parseHex(t,r):this._parseBase(t,e,r),"-"===t[0]&&(this.negative=1),this.strip(),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initArray=function(t,e,i){if(t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r=0;r-=3)s=t[r]|t[r-1]<<8|t[r-2]<<16,this.words[n]|=s<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===i)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this.strip()},r.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=6)n=s(t,i,i+6),this.words[r]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,r++);i+6!==e&&(n=s(t,e,i+6),this.words[r]|=n<>>26-o&4194303),this.strip()},r.prototype._parseBase=function(t,e,i){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=e)r++;r--,n=n/e|0;for(var s=t.length-i,a=s%r,h=Math.min(s,s-a)+i,u=0,f=i;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},r.prototype.inspect=function(){return(this.red?""};var a=["","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"],h=[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],u=[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 f(t,e,i){i.negative=e.negative^t.negative;var r=t.length+e.length|0;i.length=r,r=r-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;i.words[0]=a;for(var u=1;u>>26,l=67108863&h,d=Math.min(u,e.length-1),c=Math.max(0,u-t.length+1);c<=d;c++){var p=u-c|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[c])+l)/67108864|0,l=67108863&o}i.words[u]=0|l,h=0|f}return 0!==h?i.words[u]=0|h:i.length--,i.strip()}r.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var r=0,n=0,s=0;s>>24-r&16777215)||s!==this.length-1?a[6-f.length]+f+i:f+i,(r+=2)>=26&&(r-=26,s--)}for(0!==n&&(i=n.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var l=h[t],d=u[t];i="";var c=this.clone();for(c.negative=0;!c.isZero();){var p=c.modn(d).toString(t);i=(c=c.idivn(d)).isZero()?p+i:a[l-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length,0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16)},r.prototype.toBuffer=function(t,e){return this.toArrayLike(n,t,e)},r.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},r.prototype.toArrayLike=function(t,e,i){var r=this.byteLength(),n=i||Math.max(1,r);this.strip();var s,o,a="le"===e,h=new t(n),u=this.clone();if(a){for(o=0;!u.isZero();o++)s=u.andln(255),u.iushrn(8),h[o]=s;for(;o=4096&&(i+=13,e>>>=13),e>=64&&(i+=7,e>>>=7),e>=8&&(i+=4,e>>>=4),e>=2&&(i+=2,e>>>=2),i+e},r.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,i=0;return 0==(8191&e)&&(i+=13,e>>>=13),0==(127&e)&&(i+=7,e>>>=7),0==(15&e)&&(i+=4,e>>>=4),0==(3&e)&&(i+=2,e>>>=2),0==(1&e)&&i++,i},r.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var i=0;it.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var e,i;this.length>t.length?(e=this,i=t):(e=t,i=this);for(var r=0;rt.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-i),this.strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,e){var i=t/26|0,r=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(i=this,r=t):(i=t,r=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i,r,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(i=this,r=t):(i=t,r=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,c=0|o[1],p=8191&c,m=c>>>13,g=0|o[2],v=8191&g,b=g>>>13,y=0|o[3],w=8191&y,M=y>>>13,_=0|o[4],S=8191&_,E=_>>>13,k=0|o[5],R=8191&k,A=k>>>13,x=0|o[6],T=8191&x,P=x>>>13,B=0|o[7],I=8191&B,q=B>>>13,O=0|o[8],L=8191&O,j=O>>>13,C=0|o[9],N=8191&C,D=C>>>13,U=0|a[0],$=8191&U,z=U>>>13,W=0|a[1],F=8191&W,K=W>>>13,H=0|a[2],Z=8191&H,V=H>>>13,G=0|a[3],Y=8191&G,X=G>>>13,J=0|a[4],Q=8191&J,tt=J>>>13,et=0|a[5],it=8191&et,rt=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,ft=0|a[8],lt=8191&ft,dt=ft>>>13,ct=0|a[9],pt=8191&ct,mt=ct>>>13;i.negative=t.negative^e.negative,i.length=19;var gt=(u+(r=Math.imul(l,$))|0)+((8191&(n=(n=Math.imul(l,z))+Math.imul(d,$)|0))<<13)|0;u=((s=Math.imul(d,z))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(p,$),n=(n=Math.imul(p,z))+Math.imul(m,$)|0,s=Math.imul(m,z);var vt=(u+(r=r+Math.imul(l,F)|0)|0)+((8191&(n=(n=n+Math.imul(l,K)|0)+Math.imul(d,F)|0))<<13)|0;u=((s=s+Math.imul(d,K)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(v,$),n=(n=Math.imul(v,z))+Math.imul(b,$)|0,s=Math.imul(b,z),r=r+Math.imul(p,F)|0,n=(n=n+Math.imul(p,K)|0)+Math.imul(m,F)|0,s=s+Math.imul(m,K)|0;var bt=(u+(r=r+Math.imul(l,Z)|0)|0)+((8191&(n=(n=n+Math.imul(l,V)|0)+Math.imul(d,Z)|0))<<13)|0;u=((s=s+Math.imul(d,V)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(w,$),n=(n=Math.imul(w,z))+Math.imul(M,$)|0,s=Math.imul(M,z),r=r+Math.imul(v,F)|0,n=(n=n+Math.imul(v,K)|0)+Math.imul(b,F)|0,s=s+Math.imul(b,K)|0,r=r+Math.imul(p,Z)|0,n=(n=n+Math.imul(p,V)|0)+Math.imul(m,Z)|0,s=s+Math.imul(m,V)|0;var yt=(u+(r=r+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,X)|0)+Math.imul(d,Y)|0))<<13)|0;u=((s=s+Math.imul(d,X)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(S,$),n=(n=Math.imul(S,z))+Math.imul(E,$)|0,s=Math.imul(E,z),r=r+Math.imul(w,F)|0,n=(n=n+Math.imul(w,K)|0)+Math.imul(M,F)|0,s=s+Math.imul(M,K)|0,r=r+Math.imul(v,Z)|0,n=(n=n+Math.imul(v,V)|0)+Math.imul(b,Z)|0,s=s+Math.imul(b,V)|0,r=r+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,X)|0;var wt=(u+(r=r+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(d,Q)|0))<<13)|0;u=((s=s+Math.imul(d,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(R,$),n=(n=Math.imul(R,z))+Math.imul(A,$)|0,s=Math.imul(A,z),r=r+Math.imul(S,F)|0,n=(n=n+Math.imul(S,K)|0)+Math.imul(E,F)|0,s=s+Math.imul(E,K)|0,r=r+Math.imul(w,Z)|0,n=(n=n+Math.imul(w,V)|0)+Math.imul(M,Z)|0,s=s+Math.imul(M,V)|0,r=r+Math.imul(v,Y)|0,n=(n=n+Math.imul(v,X)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,X)|0,r=r+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var Mt=(u+(r=r+Math.imul(l,it)|0)|0)+((8191&(n=(n=n+Math.imul(l,rt)|0)+Math.imul(d,it)|0))<<13)|0;u=((s=s+Math.imul(d,rt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(T,$),n=(n=Math.imul(T,z))+Math.imul(P,$)|0,s=Math.imul(P,z),r=r+Math.imul(R,F)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(A,F)|0,s=s+Math.imul(A,K)|0,r=r+Math.imul(S,Z)|0,n=(n=n+Math.imul(S,V)|0)+Math.imul(E,Z)|0,s=s+Math.imul(E,V)|0,r=r+Math.imul(w,Y)|0,n=(n=n+Math.imul(w,X)|0)+Math.imul(M,Y)|0,s=s+Math.imul(M,X)|0,r=r+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,tt)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,tt)|0,r=r+Math.imul(p,it)|0,n=(n=n+Math.imul(p,rt)|0)+Math.imul(m,it)|0,s=s+Math.imul(m,rt)|0;var _t=(u+(r=r+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(d,st)|0))<<13)|0;u=((s=s+Math.imul(d,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(I,$),n=(n=Math.imul(I,z))+Math.imul(q,$)|0,s=Math.imul(q,z),r=r+Math.imul(T,F)|0,n=(n=n+Math.imul(T,K)|0)+Math.imul(P,F)|0,s=s+Math.imul(P,K)|0,r=r+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,V)|0)+Math.imul(A,Z)|0,s=s+Math.imul(A,V)|0,r=r+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,X)|0,r=r+Math.imul(w,Q)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(M,Q)|0,s=s+Math.imul(M,tt)|0,r=r+Math.imul(v,it)|0,n=(n=n+Math.imul(v,rt)|0)+Math.imul(b,it)|0,s=s+Math.imul(b,rt)|0,r=r+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(r=r+Math.imul(l,ht)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((s=s+Math.imul(d,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(L,$),n=(n=Math.imul(L,z))+Math.imul(j,$)|0,s=Math.imul(j,z),r=r+Math.imul(I,F)|0,n=(n=n+Math.imul(I,K)|0)+Math.imul(q,F)|0,s=s+Math.imul(q,K)|0,r=r+Math.imul(T,Z)|0,n=(n=n+Math.imul(T,V)|0)+Math.imul(P,Z)|0,s=s+Math.imul(P,V)|0,r=r+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,X)|0,r=r+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(E,Q)|0,s=s+Math.imul(E,tt)|0,r=r+Math.imul(w,it)|0,n=(n=n+Math.imul(w,rt)|0)+Math.imul(M,it)|0,s=s+Math.imul(M,rt)|0,r=r+Math.imul(v,st)|0,n=(n=n+Math.imul(v,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,r=r+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,ut)|0;var Et=(u+(r=r+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,dt)|0)+Math.imul(d,lt)|0))<<13)|0;u=((s=s+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(N,$),n=(n=Math.imul(N,z))+Math.imul(D,$)|0,s=Math.imul(D,z),r=r+Math.imul(L,F)|0,n=(n=n+Math.imul(L,K)|0)+Math.imul(j,F)|0,s=s+Math.imul(j,K)|0,r=r+Math.imul(I,Z)|0,n=(n=n+Math.imul(I,V)|0)+Math.imul(q,Z)|0,s=s+Math.imul(q,V)|0,r=r+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,X)|0,r=r+Math.imul(R,Q)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(A,Q)|0,s=s+Math.imul(A,tt)|0,r=r+Math.imul(S,it)|0,n=(n=n+Math.imul(S,rt)|0)+Math.imul(E,it)|0,s=s+Math.imul(E,rt)|0,r=r+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(M,st)|0,s=s+Math.imul(M,ot)|0,r=r+Math.imul(v,ht)|0,n=(n=n+Math.imul(v,ut)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ut)|0,r=r+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,dt)|0;var kt=(u+(r=r+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(d,pt)|0))<<13)|0;u=((s=s+Math.imul(d,mt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(N,F),n=(n=Math.imul(N,K))+Math.imul(D,F)|0,s=Math.imul(D,K),r=r+Math.imul(L,Z)|0,n=(n=n+Math.imul(L,V)|0)+Math.imul(j,Z)|0,s=s+Math.imul(j,V)|0,r=r+Math.imul(I,Y)|0,n=(n=n+Math.imul(I,X)|0)+Math.imul(q,Y)|0,s=s+Math.imul(q,X)|0,r=r+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(P,Q)|0,s=s+Math.imul(P,tt)|0,r=r+Math.imul(R,it)|0,n=(n=n+Math.imul(R,rt)|0)+Math.imul(A,it)|0,s=s+Math.imul(A,rt)|0,r=r+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(E,st)|0,s=s+Math.imul(E,ot)|0,r=r+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(M,ht)|0,s=s+Math.imul(M,ut)|0,r=r+Math.imul(v,lt)|0,n=(n=n+Math.imul(v,dt)|0)+Math.imul(b,lt)|0,s=s+Math.imul(b,dt)|0;var Rt=(u+(r=r+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(N,Z),n=(n=Math.imul(N,V))+Math.imul(D,Z)|0,s=Math.imul(D,V),r=r+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(j,Y)|0,s=s+Math.imul(j,X)|0,r=r+Math.imul(I,Q)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(q,Q)|0,s=s+Math.imul(q,tt)|0,r=r+Math.imul(T,it)|0,n=(n=n+Math.imul(T,rt)|0)+Math.imul(P,it)|0,s=s+Math.imul(P,rt)|0,r=r+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(A,st)|0,s=s+Math.imul(A,ot)|0,r=r+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(E,ht)|0,s=s+Math.imul(E,ut)|0,r=r+Math.imul(w,lt)|0,n=(n=n+Math.imul(w,dt)|0)+Math.imul(M,lt)|0,s=s+Math.imul(M,dt)|0;var At=(u+(r=r+Math.imul(v,pt)|0)|0)+((8191&(n=(n=n+Math.imul(v,mt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((s=s+Math.imul(b,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(N,Y),n=(n=Math.imul(N,X))+Math.imul(D,Y)|0,s=Math.imul(D,X),r=r+Math.imul(L,Q)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(j,Q)|0,s=s+Math.imul(j,tt)|0,r=r+Math.imul(I,it)|0,n=(n=n+Math.imul(I,rt)|0)+Math.imul(q,it)|0,s=s+Math.imul(q,rt)|0,r=r+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,ot)|0,r=r+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(A,ht)|0,s=s+Math.imul(A,ut)|0,r=r+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,dt)|0)+Math.imul(E,lt)|0,s=s+Math.imul(E,dt)|0;var xt=(u+(r=r+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((s=s+Math.imul(M,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(N,Q),n=(n=Math.imul(N,tt))+Math.imul(D,Q)|0,s=Math.imul(D,tt),r=r+Math.imul(L,it)|0,n=(n=n+Math.imul(L,rt)|0)+Math.imul(j,it)|0,s=s+Math.imul(j,rt)|0,r=r+Math.imul(I,st)|0,n=(n=n+Math.imul(I,ot)|0)+Math.imul(q,st)|0,s=s+Math.imul(q,ot)|0,r=r+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,ut)|0,r=r+Math.imul(R,lt)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(A,lt)|0,s=s+Math.imul(A,dt)|0;var Tt=(u+(r=r+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(E,pt)|0))<<13)|0;u=((s=s+Math.imul(E,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(N,it),n=(n=Math.imul(N,rt))+Math.imul(D,it)|0,s=Math.imul(D,rt),r=r+Math.imul(L,st)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(j,st)|0,s=s+Math.imul(j,ot)|0,r=r+Math.imul(I,ht)|0,n=(n=n+Math.imul(I,ut)|0)+Math.imul(q,ht)|0,s=s+Math.imul(q,ut)|0,r=r+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,dt)|0)+Math.imul(P,lt)|0,s=s+Math.imul(P,dt)|0;var Pt=(u+(r=r+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((s=s+Math.imul(A,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(N,st),n=(n=Math.imul(N,ot))+Math.imul(D,st)|0,s=Math.imul(D,ot),r=r+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,ut)|0)+Math.imul(j,ht)|0,s=s+Math.imul(j,ut)|0,r=r+Math.imul(I,lt)|0,n=(n=n+Math.imul(I,dt)|0)+Math.imul(q,lt)|0,s=s+Math.imul(q,dt)|0;var Bt=(u+(r=r+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((s=s+Math.imul(P,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(N,ht),n=(n=Math.imul(N,ut))+Math.imul(D,ht)|0,s=Math.imul(D,ut),r=r+Math.imul(L,lt)|0,n=(n=n+Math.imul(L,dt)|0)+Math.imul(j,lt)|0,s=s+Math.imul(j,dt)|0;var It=(u+(r=r+Math.imul(I,pt)|0)|0)+((8191&(n=(n=n+Math.imul(I,mt)|0)+Math.imul(q,pt)|0))<<13)|0;u=((s=s+Math.imul(q,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(N,lt),n=(n=Math.imul(N,dt))+Math.imul(D,lt)|0,s=Math.imul(D,dt);var qt=(u+(r=r+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,mt)|0)+Math.imul(j,pt)|0))<<13)|0;u=((s=s+Math.imul(j,mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863;var Ot=(u+(r=Math.imul(N,pt))|0)+((8191&(n=(n=Math.imul(N,mt))+Math.imul(D,pt)|0))<<13)|0;return u=((s=Math.imul(D,mt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=vt,h[2]=bt,h[3]=yt,h[4]=wt,h[5]=Mt,h[6]=_t,h[7]=St,h[8]=Et,h[9]=kt,h[10]=Rt,h[11]=At,h[12]=xt,h[13]=Tt,h[14]=Pt,h[15]=Bt,h[16]=It,h[17]=qt,h[18]=Ot,0!==u&&(h[19]=u,i.length++),i};function d(t,e,i){return(new c).mulp(t,e,i)}function c(t,e){this.x=t,this.y=e}Math.imul||(l=f),r.prototype.mulTo=function(t,e){var i=this.length+t.length;return 10===this.length&&10===t.length?l(this,t,e):i<63?f(this,t,e):i<1024?function(t,e,i){i.negative=e.negative^t.negative,i.length=t.length+e.length;for(var r=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}i.words[s]=a,r=o,o=n}return 0!==r?i.words[s]=r:i.length--,i.strip()}(this,t,e):d(this,t,e)},c.prototype.makeRBT=function(t){for(var e=new Array(t),i=r.prototype._countBits(t)-1,n=0;n>=1;return r},c.prototype.permute=function(t,e,i,r,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*s+1]=8191&n,n>>>=13;for(s=2*e;s>=26,e+=r/67108864|0,e+=n>>>26,this.words[i]=67108863&n}return 0!==e&&(this.words[i]=e,this.length++),this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),i=0;i>>n}return e}(t);if(0===e.length)return new r(1);for(var i=this,n=0;n>>26-i<<26-i;if(0!==i){var s=0;for(e=0;e>>26-i}s&&(this.words[e]=s,this.length++)}if(0!==r){for(e=this.length-1;e>=0;e--)this.words[e+r]=this.words[e];for(e=0;e>>n<s)for(this.length-=s,h=0;h=0&&(0!==u||h>=r);h--){var f=0|this.words[h];this.words[h]=u<<26-n|f>>>n,u=f&o}return a&&0!==u&&(a.words[a.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},r.prototype.ishrn=function(t,e,i){return this.iushrn(t,e,i)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){var e=t%26,i=(t-e)/26,r=1<>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},r.prototype.isubn=function(t){if(t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(a/67108864|0),this.words[r+i]=67108863&n}for(;r>26,this.words[r+i]=67108863&n;if(0===o)return this.strip();for(o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},r.prototype._wordDiv=function(t,e){var i=(this.length,t.length),n=this.clone(),s=t,o=0|s.words[s.length-1];0!=(i=26-this._countBits(o))&&(s=s.ushln(i),n.iushln(i),o=0|s.words[s.length-1]);var a,h=n.length-s.length;if("mod"!==e){(a=new r(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u=0;l--){var d=67108864*(0|n.words[s.length+l])+(0|n.words[s.length+l-1]);for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(s,d,l);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(s,1,l),n.isZero()||(n.negative^=1);a&&(a.words[l]=d)}return a&&a.strip(),n.strip(),"div"!==e&&0!==i&&n.iushrn(i),{div:a||null,mod:n}},r.prototype.divmod=function(t,e,i){return this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),"mod"!==e&&(n=o.div.neg()),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),e),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new r(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var i=0!==e.div.negative?e.mod.isub(t):e.mod,r=t.ushrn(1),n=t.andln(1),s=i.cmp(r);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},r.prototype.modn=function(t){for(var e=(1<<26)%t,i=0,r=this.length-1;r>=0;r--)i=(e*i+(0|this.words[r]))%t;return i},r.prototype.idivn=function(t){for(var e=0,i=this.length-1;i>=0;i--){var r=(0|this.words[i])+67108864*e;this.words[i]=r/t|0,e=r%t}return this.strip()},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new r(1),s=new r(0),o=new r(0),a=new r(1),h=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++h;for(var u=i.clone(),f=e.clone();!e.isZero();){for(var l=0,d=1;0==(e.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(e.iushrn(l);l-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(u),s.isub(f)),n.iushrn(1),s.iushrn(1);for(var c=0,p=1;0==(i.words[0]&p)&&c<26;++c,p<<=1);if(c>0)for(i.iushrn(c);c-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(u),a.isub(f)),o.iushrn(1),a.iushrn(1);e.cmp(i)>=0?(e.isub(i),n.isub(o),s.isub(a)):(i.isub(e),o.isub(n),a.isub(s))}return{a:o,b:a,gcd:i.iushln(h)}},r.prototype._invmp=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new r(1),o=new r(0),a=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var h=0,u=1;0==(e.words[0]&u)&&h<26;++h,u<<=1);if(h>0)for(e.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(a),s.iushrn(1);for(var f=0,l=1;0==(i.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(i.iushrn(f);f-- >0;)o.isOdd()&&o.iadd(a),o.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o)):(i.isub(e),o.isub(s))}return(n=0===e.cmpn(1)?s:o).cmpn(0)<0&&n.iadd(t),n},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),i=t.clone();e.negative=0,i.negative=0;for(var r=0;e.isEven()&&i.isEven();r++)e.iushrn(1),i.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;i.isEven();)i.iushrn(1);var n=e.cmp(i);if(n<0){var s=e;e=i,i=s}else if(0===n||0===i.cmpn(1))break;e.isub(i)}return i.iushln(r)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){var e=t%26,i=(t-e)/26,r=1<>>26,o&=67108863,this.words[s]=o}return 0!==n&&(this.words[s]=n,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t);var r=0|this.words[0];e=r===t?0:rt.length)return 1;if(this.length=0;i--){var r=0|this.words[i],n=0|t.words[i];if(r!==n){rn&&(e=1);break}}return e},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new M(t)},r.prototype.toRed=function(t){return t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return this._forceRed(t)},r.prototype.redAdd=function(t){return this.red.add(this,t)},r.prototype.redIAdd=function(t){return this.red.iadd(this,t)},r.prototype.redSub=function(t){return this.red.sub(this,t)},r.prototype.redISub=function(t){return this.red.isub(this,t)},r.prototype.redShl=function(t){return this.red.shl(this,t)},r.prototype.redMul=function(t){return this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return this.red._verify1(this),this.red.pow(this,t)};var p={k256:null,p224:null,p192:null,p25519:null};function m(t,e){this.name=t,this.p=new r(e,16),this.n=this.p.bitLength(),this.k=new r(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 v(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function y(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(t){if("string"==typeof t){var e=r._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function _(t){M.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(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 t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},m.prototype.ireduce=function(t){var e,i=t;do{this.split(i,this.tmp),e=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(e>this.n);var r=e0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},m.prototype.split=function(t,e){t.iushrn(this.n,0,e)},m.prototype.imulK=function(t){return t.imul(this.k)},i(g,m),g.prototype.split=function(t,e){for(var i=Math.min(t.length,9),r=0;r>>22,n=s}n>>>=22,t.words[r-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},g.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,i=0;i>>=26,t.words[i]=n,e=r}return 0!==e&&(t.words[t.length++]=e),t},r._prime=function(t){if(p[t])return p[t];var e;if("k256"===t)e=new g;else if("p224"===t)e=new v;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new y}return p[t]=e,e},M.prototype._verify1=function(t){},M.prototype._verify2=function(t,e){},M.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},M.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},M.prototype.add=function(t,e){this._verify2(t,e);var i=t.add(e);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},M.prototype.iadd=function(t,e){this._verify2(t,e);var i=t.iadd(e);return i.cmp(this.m)>=0&&i.isub(this.m),i},M.prototype.sub=function(t,e){this._verify2(t,e);var i=t.sub(e);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},M.prototype.isub=function(t,e){this._verify2(t,e);var i=t.isub(e);return i.cmpn(0)<0&&i.iadd(this.m),i},M.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},M.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},M.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},M.prototype.isqr=function(t){return this.imul(t,t.clone())},M.prototype.sqr=function(t){return this.mul(t,t)},M.prototype.sqrt=function(t){if(t.isZero())return t.clone();if(3===this.m.andln(3)){var e=this.m.add(new r(1)).iushrn(2);return this.pow(t,e)}for(var i=this.m.subn(1),n=0;!i.isZero()&&0===i.andln(1);)n++,i.iushrn(1);var s=new r(1).toRed(this),o=s.redNeg(),a=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new r(2*h*h).toRed(this);0!==this.pow(h,a).cmp(o);)h.redIAdd(o);for(var u=this.pow(h,i),f=this.pow(t,i.addn(1).iushrn(1)),l=this.pow(t,i),d=n;0!==l.cmp(s);){for(var c=l,p=0;0!==c.cmp(s);p++)c=c.redSqr();var m=this.pow(u,new r(1).iushln(d-p-1));f=f.redMul(m),u=m.redSqr(),l=l.redMul(u),d=p}return f},M.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},M.prototype.pow=function(t,e){if(e.isZero())return new r(1).toRed(this);if(0===e.cmpn(1))return t.clone();var i=new Array(16);i[0]=new r(1).toRed(this),i[1]=t;for(var n=2;n=0;n--){for(var u=e.words[n],f=h-1;f>=0;f--){var l=u>>f&1;s!==i[0]&&(s=this.sqr(s)),0!==l||0!==o?(o<<=1,o|=l,(4==++a||0===n&&0===f)&&(s=this.mul(s,i[o]),a=0,o=0)):a=0}h=26}return s},M.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},M.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},r.mont=function(t){return new _(t)},i(_,M),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(e),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new r(0)._forceRed(this);var i=t.mul(e),n=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=i.isub(n).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(kf,this),kf=kf.exports;(function(t){(function(){(function(t){return new i(t)});var e={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};function i(t){this.curveType=e[t],this.curveType||(this.curveType={name:t}),this.curve=new Dh.ec(this.curveType.name),this.keys=void 0}function r(e,i,r){Array.isArray(e)||(e=e.toArray());var n=new t(e);if(r&&n.length=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return r}function o(t,e,i,r){for(var n=0,s=Math.min(t.length,i),o=e;o=49?a-49+10:a>=17?a-17+10:a}return n}r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,e){return t.cmp(e)>0?t:e},r.min=function(t,e){return t.cmp(e)<0?t:e},r.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===e?this._parseHex(t,r):this._parseBase(t,e,r),"-"===t[0]&&(this.negative=1),this.strip(),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initArray=function(t,e,i){if(t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r=0;r-=3)s=t[r]|t[r-1]<<8|t[r-2]<<16,this.words[n]|=s<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===i)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this.strip()},r.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=6)n=s(t,i,i+6),this.words[r]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,r++);i+6!==e&&(n=s(t,e,i+6),this.words[r]|=n<>>26-o&4194303),this.strip()},r.prototype._parseBase=function(t,e,i){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=e)r++;r--,n=n/e|0;for(var s=t.length-i,a=s%r,h=Math.min(s,s-a)+i,u=0,f=i;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},r.prototype.inspect=function(){return(this.red?""};var a=["","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"],h=[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],u=[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 f(t,e,i){i.negative=e.negative^t.negative;var r=t.length+e.length|0;i.length=r,r=r-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;i.words[0]=a;for(var u=1;u>>26,l=67108863&h,d=Math.min(u,e.length-1),c=Math.max(0,u-t.length+1);c<=d;c++){var p=u-c|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[c])+l)/67108864|0,l=67108863&o}i.words[u]=0|l,h=0|f}return 0!==h?i.words[u]=0|h:i.length--,i.strip()}r.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var r=0,n=0,s=0;s>>24-r&16777215)||s!==this.length-1?a[6-f.length]+f+i:f+i,(r+=2)>=26&&(r-=26,s--)}for(0!==n&&(i=n.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var l=h[t],d=u[t];i="";var c=this.clone();for(c.negative=0;!c.isZero();){var p=c.modn(d).toString(t);i=(c=c.idivn(d)).isZero()?p+i:a[l-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length,0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16)},r.prototype.toBuffer=function(t,e){return this.toArrayLike(n,t,e)},r.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},r.prototype.toArrayLike=function(t,e,i){var r=this.byteLength(),n=i||Math.max(1,r);this.strip();var s,o,a="le"===e,h=new t(n),u=this.clone();if(a){for(o=0;!u.isZero();o++)s=u.andln(255),u.iushrn(8),h[o]=s;for(;o=4096&&(i+=13,e>>>=13),e>=64&&(i+=7,e>>>=7),e>=8&&(i+=4,e>>>=4),e>=2&&(i+=2,e>>>=2),i+e},r.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,i=0;return 0==(8191&e)&&(i+=13,e>>>=13),0==(127&e)&&(i+=7,e>>>=7),0==(15&e)&&(i+=4,e>>>=4),0==(3&e)&&(i+=2,e>>>=2),0==(1&e)&&i++,i},r.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var i=0;it.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var e,i;this.length>t.length?(e=this,i=t):(e=t,i=this);for(var r=0;rt.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-i),this.strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,e){var i=t/26|0,r=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(i=this,r=t):(i=t,r=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i,r,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(i=this,r=t):(i=t,r=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,c=0|o[1],p=8191&c,m=c>>>13,g=0|o[2],v=8191&g,b=g>>>13,y=0|o[3],w=8191&y,M=y>>>13,_=0|o[4],S=8191&_,E=_>>>13,k=0|o[5],R=8191&k,A=k>>>13,x=0|o[6],T=8191&x,P=x>>>13,B=0|o[7],I=8191&B,q=B>>>13,O=0|o[8],L=8191&O,j=O>>>13,C=0|o[9],N=8191&C,D=C>>>13,U=0|a[0],$=8191&U,z=U>>>13,W=0|a[1],F=8191&W,K=W>>>13,H=0|a[2],Z=8191&H,V=H>>>13,G=0|a[3],Y=8191&G,X=G>>>13,J=0|a[4],Q=8191&J,tt=J>>>13,et=0|a[5],it=8191&et,rt=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,ft=0|a[8],lt=8191&ft,dt=ft>>>13,ct=0|a[9],pt=8191&ct,mt=ct>>>13;i.negative=t.negative^e.negative,i.length=19;var gt=(u+(r=Math.imul(l,$))|0)+((8191&(n=(n=Math.imul(l,z))+Math.imul(d,$)|0))<<13)|0;u=((s=Math.imul(d,z))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(p,$),n=(n=Math.imul(p,z))+Math.imul(m,$)|0,s=Math.imul(m,z);var vt=(u+(r=r+Math.imul(l,F)|0)|0)+((8191&(n=(n=n+Math.imul(l,K)|0)+Math.imul(d,F)|0))<<13)|0;u=((s=s+Math.imul(d,K)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(v,$),n=(n=Math.imul(v,z))+Math.imul(b,$)|0,s=Math.imul(b,z),r=r+Math.imul(p,F)|0,n=(n=n+Math.imul(p,K)|0)+Math.imul(m,F)|0,s=s+Math.imul(m,K)|0;var bt=(u+(r=r+Math.imul(l,Z)|0)|0)+((8191&(n=(n=n+Math.imul(l,V)|0)+Math.imul(d,Z)|0))<<13)|0;u=((s=s+Math.imul(d,V)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(w,$),n=(n=Math.imul(w,z))+Math.imul(M,$)|0,s=Math.imul(M,z),r=r+Math.imul(v,F)|0,n=(n=n+Math.imul(v,K)|0)+Math.imul(b,F)|0,s=s+Math.imul(b,K)|0,r=r+Math.imul(p,Z)|0,n=(n=n+Math.imul(p,V)|0)+Math.imul(m,Z)|0,s=s+Math.imul(m,V)|0;var yt=(u+(r=r+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,X)|0)+Math.imul(d,Y)|0))<<13)|0;u=((s=s+Math.imul(d,X)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(S,$),n=(n=Math.imul(S,z))+Math.imul(E,$)|0,s=Math.imul(E,z),r=r+Math.imul(w,F)|0,n=(n=n+Math.imul(w,K)|0)+Math.imul(M,F)|0,s=s+Math.imul(M,K)|0,r=r+Math.imul(v,Z)|0,n=(n=n+Math.imul(v,V)|0)+Math.imul(b,Z)|0,s=s+Math.imul(b,V)|0,r=r+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,X)|0;var wt=(u+(r=r+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(d,Q)|0))<<13)|0;u=((s=s+Math.imul(d,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(R,$),n=(n=Math.imul(R,z))+Math.imul(A,$)|0,s=Math.imul(A,z),r=r+Math.imul(S,F)|0,n=(n=n+Math.imul(S,K)|0)+Math.imul(E,F)|0,s=s+Math.imul(E,K)|0,r=r+Math.imul(w,Z)|0,n=(n=n+Math.imul(w,V)|0)+Math.imul(M,Z)|0,s=s+Math.imul(M,V)|0,r=r+Math.imul(v,Y)|0,n=(n=n+Math.imul(v,X)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,X)|0,r=r+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var Mt=(u+(r=r+Math.imul(l,it)|0)|0)+((8191&(n=(n=n+Math.imul(l,rt)|0)+Math.imul(d,it)|0))<<13)|0;u=((s=s+Math.imul(d,rt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(T,$),n=(n=Math.imul(T,z))+Math.imul(P,$)|0,s=Math.imul(P,z),r=r+Math.imul(R,F)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(A,F)|0,s=s+Math.imul(A,K)|0,r=r+Math.imul(S,Z)|0,n=(n=n+Math.imul(S,V)|0)+Math.imul(E,Z)|0,s=s+Math.imul(E,V)|0,r=r+Math.imul(w,Y)|0,n=(n=n+Math.imul(w,X)|0)+Math.imul(M,Y)|0,s=s+Math.imul(M,X)|0,r=r+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,tt)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,tt)|0,r=r+Math.imul(p,it)|0,n=(n=n+Math.imul(p,rt)|0)+Math.imul(m,it)|0,s=s+Math.imul(m,rt)|0;var _t=(u+(r=r+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(d,st)|0))<<13)|0;u=((s=s+Math.imul(d,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(I,$),n=(n=Math.imul(I,z))+Math.imul(q,$)|0,s=Math.imul(q,z),r=r+Math.imul(T,F)|0,n=(n=n+Math.imul(T,K)|0)+Math.imul(P,F)|0,s=s+Math.imul(P,K)|0,r=r+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,V)|0)+Math.imul(A,Z)|0,s=s+Math.imul(A,V)|0,r=r+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,X)|0,r=r+Math.imul(w,Q)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(M,Q)|0,s=s+Math.imul(M,tt)|0,r=r+Math.imul(v,it)|0,n=(n=n+Math.imul(v,rt)|0)+Math.imul(b,it)|0,s=s+Math.imul(b,rt)|0,r=r+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(r=r+Math.imul(l,ht)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((s=s+Math.imul(d,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(L,$),n=(n=Math.imul(L,z))+Math.imul(j,$)|0,s=Math.imul(j,z),r=r+Math.imul(I,F)|0,n=(n=n+Math.imul(I,K)|0)+Math.imul(q,F)|0,s=s+Math.imul(q,K)|0,r=r+Math.imul(T,Z)|0,n=(n=n+Math.imul(T,V)|0)+Math.imul(P,Z)|0,s=s+Math.imul(P,V)|0,r=r+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,X)|0,r=r+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(E,Q)|0,s=s+Math.imul(E,tt)|0,r=r+Math.imul(w,it)|0,n=(n=n+Math.imul(w,rt)|0)+Math.imul(M,it)|0,s=s+Math.imul(M,rt)|0,r=r+Math.imul(v,st)|0,n=(n=n+Math.imul(v,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,r=r+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,ut)|0;var Et=(u+(r=r+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,dt)|0)+Math.imul(d,lt)|0))<<13)|0;u=((s=s+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(N,$),n=(n=Math.imul(N,z))+Math.imul(D,$)|0,s=Math.imul(D,z),r=r+Math.imul(L,F)|0,n=(n=n+Math.imul(L,K)|0)+Math.imul(j,F)|0,s=s+Math.imul(j,K)|0,r=r+Math.imul(I,Z)|0,n=(n=n+Math.imul(I,V)|0)+Math.imul(q,Z)|0,s=s+Math.imul(q,V)|0,r=r+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,X)|0,r=r+Math.imul(R,Q)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(A,Q)|0,s=s+Math.imul(A,tt)|0,r=r+Math.imul(S,it)|0,n=(n=n+Math.imul(S,rt)|0)+Math.imul(E,it)|0,s=s+Math.imul(E,rt)|0,r=r+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(M,st)|0,s=s+Math.imul(M,ot)|0,r=r+Math.imul(v,ht)|0,n=(n=n+Math.imul(v,ut)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ut)|0,r=r+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,dt)|0;var kt=(u+(r=r+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(d,pt)|0))<<13)|0;u=((s=s+Math.imul(d,mt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(N,F),n=(n=Math.imul(N,K))+Math.imul(D,F)|0,s=Math.imul(D,K),r=r+Math.imul(L,Z)|0,n=(n=n+Math.imul(L,V)|0)+Math.imul(j,Z)|0,s=s+Math.imul(j,V)|0,r=r+Math.imul(I,Y)|0,n=(n=n+Math.imul(I,X)|0)+Math.imul(q,Y)|0,s=s+Math.imul(q,X)|0,r=r+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(P,Q)|0,s=s+Math.imul(P,tt)|0,r=r+Math.imul(R,it)|0,n=(n=n+Math.imul(R,rt)|0)+Math.imul(A,it)|0,s=s+Math.imul(A,rt)|0,r=r+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(E,st)|0,s=s+Math.imul(E,ot)|0,r=r+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(M,ht)|0,s=s+Math.imul(M,ut)|0,r=r+Math.imul(v,lt)|0,n=(n=n+Math.imul(v,dt)|0)+Math.imul(b,lt)|0,s=s+Math.imul(b,dt)|0;var Rt=(u+(r=r+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(N,Z),n=(n=Math.imul(N,V))+Math.imul(D,Z)|0,s=Math.imul(D,V),r=r+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(j,Y)|0,s=s+Math.imul(j,X)|0,r=r+Math.imul(I,Q)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(q,Q)|0,s=s+Math.imul(q,tt)|0,r=r+Math.imul(T,it)|0,n=(n=n+Math.imul(T,rt)|0)+Math.imul(P,it)|0,s=s+Math.imul(P,rt)|0,r=r+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(A,st)|0,s=s+Math.imul(A,ot)|0,r=r+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(E,ht)|0,s=s+Math.imul(E,ut)|0,r=r+Math.imul(w,lt)|0,n=(n=n+Math.imul(w,dt)|0)+Math.imul(M,lt)|0,s=s+Math.imul(M,dt)|0;var At=(u+(r=r+Math.imul(v,pt)|0)|0)+((8191&(n=(n=n+Math.imul(v,mt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((s=s+Math.imul(b,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(N,Y),n=(n=Math.imul(N,X))+Math.imul(D,Y)|0,s=Math.imul(D,X),r=r+Math.imul(L,Q)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(j,Q)|0,s=s+Math.imul(j,tt)|0,r=r+Math.imul(I,it)|0,n=(n=n+Math.imul(I,rt)|0)+Math.imul(q,it)|0,s=s+Math.imul(q,rt)|0,r=r+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,ot)|0,r=r+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(A,ht)|0,s=s+Math.imul(A,ut)|0,r=r+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,dt)|0)+Math.imul(E,lt)|0,s=s+Math.imul(E,dt)|0;var xt=(u+(r=r+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((s=s+Math.imul(M,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(N,Q),n=(n=Math.imul(N,tt))+Math.imul(D,Q)|0,s=Math.imul(D,tt),r=r+Math.imul(L,it)|0,n=(n=n+Math.imul(L,rt)|0)+Math.imul(j,it)|0,s=s+Math.imul(j,rt)|0,r=r+Math.imul(I,st)|0,n=(n=n+Math.imul(I,ot)|0)+Math.imul(q,st)|0,s=s+Math.imul(q,ot)|0,r=r+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,ut)|0,r=r+Math.imul(R,lt)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(A,lt)|0,s=s+Math.imul(A,dt)|0;var Tt=(u+(r=r+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(E,pt)|0))<<13)|0;u=((s=s+Math.imul(E,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(N,it),n=(n=Math.imul(N,rt))+Math.imul(D,it)|0,s=Math.imul(D,rt),r=r+Math.imul(L,st)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(j,st)|0,s=s+Math.imul(j,ot)|0,r=r+Math.imul(I,ht)|0,n=(n=n+Math.imul(I,ut)|0)+Math.imul(q,ht)|0,s=s+Math.imul(q,ut)|0,r=r+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,dt)|0)+Math.imul(P,lt)|0,s=s+Math.imul(P,dt)|0;var Pt=(u+(r=r+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((s=s+Math.imul(A,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(N,st),n=(n=Math.imul(N,ot))+Math.imul(D,st)|0,s=Math.imul(D,ot),r=r+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,ut)|0)+Math.imul(j,ht)|0,s=s+Math.imul(j,ut)|0,r=r+Math.imul(I,lt)|0,n=(n=n+Math.imul(I,dt)|0)+Math.imul(q,lt)|0,s=s+Math.imul(q,dt)|0;var Bt=(u+(r=r+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((s=s+Math.imul(P,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(N,ht),n=(n=Math.imul(N,ut))+Math.imul(D,ht)|0,s=Math.imul(D,ut),r=r+Math.imul(L,lt)|0,n=(n=n+Math.imul(L,dt)|0)+Math.imul(j,lt)|0,s=s+Math.imul(j,dt)|0;var It=(u+(r=r+Math.imul(I,pt)|0)|0)+((8191&(n=(n=n+Math.imul(I,mt)|0)+Math.imul(q,pt)|0))<<13)|0;u=((s=s+Math.imul(q,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(N,lt),n=(n=Math.imul(N,dt))+Math.imul(D,lt)|0,s=Math.imul(D,dt);var qt=(u+(r=r+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,mt)|0)+Math.imul(j,pt)|0))<<13)|0;u=((s=s+Math.imul(j,mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863;var Ot=(u+(r=Math.imul(N,pt))|0)+((8191&(n=(n=Math.imul(N,mt))+Math.imul(D,pt)|0))<<13)|0;return u=((s=Math.imul(D,mt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=vt,h[2]=bt,h[3]=yt,h[4]=wt,h[5]=Mt,h[6]=_t,h[7]=St,h[8]=Et,h[9]=kt,h[10]=Rt,h[11]=At,h[12]=xt,h[13]=Tt,h[14]=Pt,h[15]=Bt,h[16]=It,h[17]=qt,h[18]=Ot,0!==u&&(h[19]=u,i.length++),i};function d(t,e,i){return(new c).mulp(t,e,i)}function c(t,e){this.x=t,this.y=e}Math.imul||(l=f),r.prototype.mulTo=function(t,e){var i=this.length+t.length;return 10===this.length&&10===t.length?l(this,t,e):i<63?f(this,t,e):i<1024?function(t,e,i){i.negative=e.negative^t.negative,i.length=t.length+e.length;for(var r=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}i.words[s]=a,r=o,o=n}return 0!==r?i.words[s]=r:i.length--,i.strip()}(this,t,e):d(this,t,e)},c.prototype.makeRBT=function(t){for(var e=new Array(t),i=r.prototype._countBits(t)-1,n=0;n>=1;return r},c.prototype.permute=function(t,e,i,r,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*s+1]=8191&n,n>>>=13;for(s=2*e;s>=26,e+=r/67108864|0,e+=n>>>26,this.words[i]=67108863&n}return 0!==e&&(this.words[i]=e,this.length++),this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),i=0;i>>n}return e}(t);if(0===e.length)return new r(1);for(var i=this,n=0;n>>26-i<<26-i;if(0!==i){var s=0;for(e=0;e>>26-i}s&&(this.words[e]=s,this.length++)}if(0!==r){for(e=this.length-1;e>=0;e--)this.words[e+r]=this.words[e];for(e=0;e>>n<s)for(this.length-=s,h=0;h=0&&(0!==u||h>=r);h--){var f=0|this.words[h];this.words[h]=u<<26-n|f>>>n,u=f&o}return a&&0!==u&&(a.words[a.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},r.prototype.ishrn=function(t,e,i){return this.iushrn(t,e,i)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){var e=t%26,i=(t-e)/26,r=1<>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},r.prototype.isubn=function(t){if(t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(a/67108864|0),this.words[r+i]=67108863&n}for(;r>26,this.words[r+i]=67108863&n;if(0===o)return this.strip();for(o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},r.prototype._wordDiv=function(t,e){var i=(this.length,t.length),n=this.clone(),s=t,o=0|s.words[s.length-1];0!=(i=26-this._countBits(o))&&(s=s.ushln(i),n.iushln(i),o=0|s.words[s.length-1]);var a,h=n.length-s.length;if("mod"!==e){(a=new r(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u=0;l--){var d=67108864*(0|n.words[s.length+l])+(0|n.words[s.length+l-1]);for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(s,d,l);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(s,1,l),n.isZero()||(n.negative^=1);a&&(a.words[l]=d)}return a&&a.strip(),n.strip(),"div"!==e&&0!==i&&n.iushrn(i),{div:a||null,mod:n}},r.prototype.divmod=function(t,e,i){return this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),"mod"!==e&&(n=o.div.neg()),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),e),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new r(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var i=0!==e.div.negative?e.mod.isub(t):e.mod,r=t.ushrn(1),n=t.andln(1),s=i.cmp(r);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},r.prototype.modn=function(t){for(var e=(1<<26)%t,i=0,r=this.length-1;r>=0;r--)i=(e*i+(0|this.words[r]))%t;return i},r.prototype.idivn=function(t){for(var e=0,i=this.length-1;i>=0;i--){var r=(0|this.words[i])+67108864*e;this.words[i]=r/t|0,e=r%t}return this.strip()},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new r(1),s=new r(0),o=new r(0),a=new r(1),h=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++h;for(var u=i.clone(),f=e.clone();!e.isZero();){for(var l=0,d=1;0==(e.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(e.iushrn(l);l-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(u),s.isub(f)),n.iushrn(1),s.iushrn(1);for(var c=0,p=1;0==(i.words[0]&p)&&c<26;++c,p<<=1);if(c>0)for(i.iushrn(c);c-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(u),a.isub(f)),o.iushrn(1),a.iushrn(1);e.cmp(i)>=0?(e.isub(i),n.isub(o),s.isub(a)):(i.isub(e),o.isub(n),a.isub(s))}return{a:o,b:a,gcd:i.iushln(h)}},r.prototype._invmp=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new r(1),o=new r(0),a=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var h=0,u=1;0==(e.words[0]&u)&&h<26;++h,u<<=1);if(h>0)for(e.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(a),s.iushrn(1);for(var f=0,l=1;0==(i.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(i.iushrn(f);f-- >0;)o.isOdd()&&o.iadd(a),o.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o)):(i.isub(e),o.isub(s))}return(n=0===e.cmpn(1)?s:o).cmpn(0)<0&&n.iadd(t),n},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),i=t.clone();e.negative=0,i.negative=0;for(var r=0;e.isEven()&&i.isEven();r++)e.iushrn(1),i.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;i.isEven();)i.iushrn(1);var n=e.cmp(i);if(n<0){var s=e;e=i,i=s}else if(0===n||0===i.cmpn(1))break;e.isub(i)}return i.iushln(r)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){var e=t%26,i=(t-e)/26,r=1<>>26,o&=67108863,this.words[s]=o}return 0!==n&&(this.words[s]=n,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t);var r=0|this.words[0];e=r===t?0:rt.length)return 1;if(this.length=0;i--){var r=0|this.words[i],n=0|t.words[i];if(r!==n){rn&&(e=1);break}}return e},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new M(t)},r.prototype.toRed=function(t){return t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return this._forceRed(t)},r.prototype.redAdd=function(t){return this.red.add(this,t)},r.prototype.redIAdd=function(t){return this.red.iadd(this,t)},r.prototype.redSub=function(t){return this.red.sub(this,t)},r.prototype.redISub=function(t){return this.red.isub(this,t)},r.prototype.redShl=function(t){return this.red.shl(this,t)},r.prototype.redMul=function(t){return this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return this.red._verify1(this),this.red.pow(this,t)};var p={k256:null,p224:null,p192:null,p25519:null};function m(t,e){this.name=t,this.p=new r(e,16),this.n=this.p.bitLength(),this.k=new r(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 v(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function y(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(t){if("string"==typeof t){var e=r._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function _(t){M.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(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 t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},m.prototype.ireduce=function(t){var e,i=t;do{this.split(i,this.tmp),e=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(e>this.n);var r=e0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},m.prototype.split=function(t,e){t.iushrn(this.n,0,e)},m.prototype.imulK=function(t){return t.imul(this.k)},i(g,m),g.prototype.split=function(t,e){for(var i=Math.min(t.length,9),r=0;r>>22,n=s}n>>>=22,t.words[r-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},g.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,i=0;i>>=26,t.words[i]=n,e=r}return 0!==e&&(t.words[t.length++]=e),t},r._prime=function(t){if(p[t])return p[t];var e;if("k256"===t)e=new g;else if("p224"===t)e=new v;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new y}return p[t]=e,e},M.prototype._verify1=function(t){},M.prototype._verify2=function(t,e){},M.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},M.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},M.prototype.add=function(t,e){this._verify2(t,e);var i=t.add(e);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},M.prototype.iadd=function(t,e){this._verify2(t,e);var i=t.iadd(e);return i.cmp(this.m)>=0&&i.isub(this.m),i},M.prototype.sub=function(t,e){this._verify2(t,e);var i=t.sub(e);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},M.prototype.isub=function(t,e){this._verify2(t,e);var i=t.isub(e);return i.cmpn(0)<0&&i.iadd(this.m),i},M.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},M.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},M.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},M.prototype.isqr=function(t){return this.imul(t,t.clone())},M.prototype.sqr=function(t){return this.mul(t,t)},M.prototype.sqrt=function(t){if(t.isZero())return t.clone();if(3===this.m.andln(3)){var e=this.m.add(new r(1)).iushrn(2);return this.pow(t,e)}for(var i=this.m.subn(1),n=0;!i.isZero()&&0===i.andln(1);)n++,i.iushrn(1);var s=new r(1).toRed(this),o=s.redNeg(),a=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new r(2*h*h).toRed(this);0!==this.pow(h,a).cmp(o);)h.redIAdd(o);for(var u=this.pow(h,i),f=this.pow(t,i.addn(1).iushrn(1)),l=this.pow(t,i),d=n;0!==l.cmp(s);){for(var c=l,p=0;0!==c.cmp(s);p++)c=c.redSqr();var m=this.pow(u,new r(1).iushln(d-p-1));f=f.redMul(m),u=m.redSqr(),l=l.redMul(u),d=p}return f},M.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},M.prototype.pow=function(t,e){if(e.isZero())return new r(1).toRed(this);if(0===e.cmpn(1))return t.clone();var i=new Array(16);i[0]=new r(1).toRed(this),i[1]=t;for(var n=2;n=0;n--){for(var u=e.words[n],f=h-1;f>=0;f--){var l=u>>f&1;s!==i[0]&&(s=this.sqr(s)),0!==l||0!==o?(o<<=1,o|=l,(4==++a||0===n&&0===f)&&(s=this.mul(s,i[o]),a=0,o=0)):a=0}h=26}return s},M.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},M.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},r.mont=function(t){return new _(t)},i(_,M),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(e),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new r(0)._forceRed(this);var i=t.mul(e),n=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=i.isub(n).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(Rf,this),Rf=Rf.exports;I.Buffer,I.Buffer,I.Buffer;var Af={};(function(t,e){(function(){"use strict";I.Buffer,I.kMaxLength;var i=e.crypto||e.msCrypto;Math.pow(2,32);i&&i.getRandomValues||t.browser}).call(this)}).call(this,D,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});var xf={};xf.createHash=cr,xf.createHmac=yr;var Tf=Object.keys(kr);["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(Tf);jr.pbkdf2,jr.pbkdf2Sync,Af.publicEncrypt,Af.privateEncrypt,Af.publicDecrypt,Af.privateDecrypt;Array.isArray;var Pf=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}},Bf=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function If(t,e){if(t.map)return t.map(e);for(var i=[],r=0;r{f=r.ERR_TIMEOUT,e.abort()},0===n?this.requestTimeout:n)}a=await fetch(t.uri,t),void 0!==u&&clearTimeout(u),f=r.ERR_RESPONSE;let s=a.headers.get("Content-Type");if(!1===e&&null===s?h=void 0===a.blob?await a.buffer():await a.blob():!1===e&&(s.startsWith("application/json")||s.startsWith("application/problem+json"))?(h=await a.json(),f=h.type,l=h.title):h=!1===e&&s.startsWith("text/")?await a.text():void 0===a.blob?await a.buffer():await a.blob(),f=r.ERR_SERVER,!a.ok)throw h}catch(g){if(s>0)return await new Promise(t=>setTimeout(t,2e3)),this._wrapWithPromise(t,e,i,n,s-1);let u;switch(u="object"==typeof g&&g.constructor===Object&&"title"in g?g.title:g,void 0===a&&(a={}),f){case r.ERR_REQUEST:f="https://api.backend.ai/probs/client-request-error",navigator.onLine?(l=u,o="sending request has failed: "+u,d=u):(l="Network disconnected.",o="sending request has failed: Network disconnected",d="Network disconnected");break;case r.ERR_RESPONSE:f="https://api.backend.ai/probs/client-response-error",l=u,o="reading response has failed: "+u,d=u;break;case r.ERR_SERVER:f="https://api.backend.ai/probs/server-error",l=`${a.status} ${a.statusText} - ${h.title}`,o="server responded failure: ",h.msg?(o+=`${a.status} ${a.statusText} - ${h.msg}`,d=h.msg):(o+=`${a.status} ${a.statusText} - ${h.title}`,d=h.title);break;case r.ERR_ABORT:f="https://api.backend.ai/probs/request-abort-error",l="Request aborted",d=o="Request aborted by user",a.status=408,a.statusText="Request aborted by user";break;case r.ERR_TIMEOUT:f="https://api.backend.ai/probs/request-timeout-error",l="Request timeout",d=o="No response returned during the timeout period",a.status=408,a.statusText="Timeout exceeded";break;default:void 0===a.status&&(a.status=500,a.statusText="Server error"),""===f&&(f=r.ERR_UNKNOWN),""===l&&(l=h.title),o=`server responded failure: ${a.status} ${a.statusText} - ${h.title}`,""!==h.title&&(d=h.title)}throw{isError:!0,timestamp:(new Date).toUTCString(),type:f,requestUrl:t.uri,requestMethod:t.method,requestParameters:t.body,statusCode:a.status,statusText:a.statusText,title:l,message:o,description:d}}let c=JSON.parse(localStorage.getItem("backendaiwebui.logs"));c&&c.length>3e3&&(c=c.slice(1,3e3));let p=Array();void 0===a&&(a={status:"No status",statusText:"No response given."});let m={isError:!1,timestamp:(new Date).toUTCString(),type:"",requestUrl:t.uri,requestMethod:t.method,requestParameters:t.body,statusCode:a.status,statusText:a.statusText,title:h.title,message:""};p.push(m),c&&(p=p.concat(c));try{localStorage.setItem("backendaiwebui.logs",JSON.stringify(p))}catch(jf){console.warn("Local storage is full. Clearing part of the logs.");let e=JSON.parse(localStorage.getItem("backendaiwebui.logs")||"[]");e=e.slice(0,Math.round(2*e.length/3)),localStorage.setItem("backendaiwebui.logs",JSON.stringify(e)),Object.entries(localStorage).map(t=>t[0]).filter(t=>t.startsWith("backendaiconsole")).map(t=>localStorage.removeItem(t))}return h}getServerVersion(t=null){let e=this.newPublicRequest("GET","/",null,"");return this._wrapWithPromise(e,!1,t)}get APIMajorVersion(){return this._apiVersionMajor}set APIMajorVersion(t){this._apiVersionMajor=t,this._config._apiVersionMajor=this._apiVersionMajor}async get_manager_version(t=null){if(null===this._managerVersion){let e=await this.getServerVersion(t);this._managerVersion=e.manager,this._apiVersion=e.version,this._config._apiVersion=this._apiVersion,this._apiVersionMajor=e.version.substr(1,2),this._config._apiVersionMajor=this._apiVersionMajor,this._apiVersionMajor>4&&(this.kernelPrefix="/session")}return this._managerVersion}supports(t){return 0===Object.keys(this._features).length&&this._updateSupportList(),t in this._features&&this._features[t]}_updateFieldCompatibilityByAPIVersion(t){const e={session_name:"sess_id"};return this._apiVersionMajor<5&&Object.keys(e).forEach(i=>{let r=t.indexOf(i);-1!==r&&(t[r]=e[i])}),t}_updateSupportList(){this.isAPIVersionCompatibleWith("v4.20190601")&&(this._features["scaling-group"]=!0,this._features.group=!0,this._features["group-folder"]=!0,this._features["system-images"]=!0,this._features["detailed-session-states"]=!0,this._features["change-user-name"]=!0),this.isAPIVersionCompatibleWith("v6.20200815")&&(this._features["multi-container"]=!0,this._features["multi-node"]=!0,this._features["storage-proxy"]=!0,this._features["hardware-metadata"]=!0)}isManagerVersionCompatibleWith(t){let e=this._managerVersion;return e=e.split(".").map(t=>t.padStart(10)).join("."),(t=t.split(".").map(t=>t.padStart(10)).join("."))<=e}isAPIVersionCompatibleWith(t){let e=this._apiVersion;return null!==e&&null!==t&&(e=e.split(".").map(t=>t.padStart(10)).join("."),t=t.split(".").map(t=>t.padStart(10)).join(".")),t<=e}async check_login(){let t,e=this.newSignedRequest("POST","/server/login-check",null);try{!0===(t=await this._wrapWithPromise(e)).authenticated&&(this._config._accessKey=t.data.access_key,this._config._session_id=t.session_id)}catch(i){return console.log(i),Promise.resolve(!1)}return t.authenticated}async login(){let t,e={username:this._config.userId,password:this._config.password},i=this.newSignedRequest("POST","/server/login",e);try{if(!0===(t=await this._wrapWithPromise(i)).authenticated)return await this.get_manager_version(),this.check_login();if(!1===t.authenticated)return t.data&&t.data.details?Promise.resolve({fail_reason:t.data.details}):Promise.resolve(!1)}catch(r){throw"statusCode"in r&&429===r.statusCode?{title:r.description,message:"Too many failed login attempts."}:{title:"No manager found at API Endpoint.",message:"Authentication failed. Check information and manager status."}}}logout(){let t=this.newSignedRequest("POST","/server/logout",{});return this._wrapWithPromise(t)}async signout(t,e){let i={username:t,password:e},r=this.newSignedRequest("POST","/auth/signout",i);return this._wrapWithPromise(r)}async update_password(t,e,i){let r={old_password:t,new_password:e,new_password2:i},n=this.newSignedRequest("POST","/auth/update-password",r);return this._wrapWithPromise(n)}async get_resource_slots(){let t;return t=this.isAPIVersionCompatibleWith("v4.20190601")?this.newPublicRequest("GET","/config/resource-slots",null,""):this.newPublicRequest("GET","/etcd/resource-slots",null,""),this._wrapWithPromise(t)}async createIfNotExists(t,e,i={},r=0){null==e&&(e=this.generateSessionId());let n,s={lang:t,clientSessionToken:e};if(i!={}){let t={};i.cpu&&(t.cpu=i.cpu),i.mem&&(t.mem=i.mem),i.gpu&&(t["cuda.device"]=parseInt(i.gpu)),i["cuda.device"]&&(t["cuda.device"]=parseInt(i["cuda.device"])),i.vgpu?t["cuda.shares"]=parseFloat(i.vgpu).toFixed(2):i.fgpu&&(t["cuda.shares"]=parseFloat(i.fgpu).toFixed(2)),i["cuda.shares"]&&(t["cuda.shares"]=parseFloat(i["cuda.shares"]).toFixed(2)),i.rocm&&(t["rocm.device"]=i.rocm),i.tpu&&(t["tpu.device"]=i.tpu),i.cluster_size&&(s.cluster_size=i.cluster_size),i.cluster_mode&&(s.cluster_mode=i.cluster_mode),i.group_name&&(s.group_name=i.group_name),i.domain&&(s.domain=i.domain),i.type&&(s.type=i.type),i.startsAt&&(s.starts_at=i.startsAt),i.enqueueOnly&&(s.enqueueOnly=i.enqueueOnly),i.maxWaitSeconds&&(s.maxWaitSeconds=i.maxWaitSeconds),i.reuseIfExists&&(s.reuseIfExists=i.reuseIfExists),i.startupCommand&&(s.startupCommand=i.startupCommand),i.bootstrapScript&&(s.bootstrapScript=i.bootstrapScript),i.bootstrap_script&&(s.bootstrap_script=i.bootstrap_script),i.owner_access_key&&(s.owner_access_key=i.owner_access_key),s.config={resources:t},i.mounts&&(s.config.mounts=i.mounts),i.scaling_group&&(s.config.scaling_group=i.scaling_group),i.shmem&&(s.config.resource_opts={},s.config.resource_opts.shmem=i.shmem),i.env&&(s.config.environ=i.env)}return n=this._apiVersionMajor<5?this.newSignedRequest("POST",this.kernelPrefix+"/create",s):this.newSignedRequest("POST",""+this.kernelPrefix,s),this._wrapWithPromise(n,!1,null,r)}async createSesisonFromTemplate(t,e,i={},r=0){}async get_info(t,e=null){let i=`${this.kernelPrefix}/${t}`;null!=e&&(i=`${i}?owner_access_key=${e}`);let r=this.newSignedRequest("GET",i,null);return this._wrapWithPromise(r)}async get_logs(t,e=null,i=0){let r=`${this.kernelPrefix}/${t}/logs`;null!=e&&(r=`${r}?owner_access_key=${e}`);let n=this.newSignedRequest("GET",r,null);return this._wrapWithPromise(n,!1,null,i)}getTaskLogs(t){const e=`${this.kernelPrefix}/_/logs?session_name=${t}`;let i=this.newSignedRequest("GET",e,null);return this._wrapWithPromise(i)}async destroy(t,e=null,i=!1){let r=`${this.kernelPrefix}/${t}`;r=null!==e?`${r}?owner_access_key=${e}${i?"&forced=true":""}`:`${r}${i?"?forced=true":""}`;let n=this.newSignedRequest("DELETE",r,null);return this._wrapWithPromise(n,!1,null,15e3,2)}async restart(t,e=null){let i=`${this.kernelPrefix}/${t}`;null!=e&&(i=`${i}?owner_access_key=${e}`);let r=this.newSignedRequest("PATCH",i,null);return this._wrapWithPromise(r)}async execute(t,e,i,r,n){let s={mode:i,code:r,runId:e,options:n},o=this.newSignedRequest("POST",`${this.kernelPrefix}/${t}`,s);return this._wrapWithPromise(o)}createKernel(t,e,i={},r=0){return this.createIfNotExists(t,e,i,r)}destroyKernel(t,e=null){return this.destroy(t,e)}refreshKernel(t,e=null){return this.restart(t,e)}runCode(t,e,i,r){return this.execute(e,i,r,t,{})}async shutdown_service(t,e){let i={service_name:e};const r=Of.stringify(i);let n=this.newSignedRequest("POST",`${this.kernelPrefix}/${t}/shutdown-service?${r}`,null);return this._wrapWithPromise(n,!0)}async upload(t,e,i){const r=new FormData;r.append("src",i,e);let n=this.newSignedRequest("POST",`${this.kernelPrefix}/${t}/upload`,r);return this._wrapWithPromise(n)}async download(t,e){let i={files:e};const r=Of.stringify(i);let n=this.newSignedRequest("GET",`${this.kernelPrefix}/${t}/download?${r}`,null);return this._wrapWithPromise(n,!0)}async download_single(t,e){let i={file:e};const r=Of.stringify(i);let n=this.newSignedRequest("GET",`${this.kernelPrefix}/${t}/download_single?${r}`,null);return this._wrapWithPromise(n,!0)}mangleUserAgentSignature(){return this.clientVersion+(this.agentSignature?"; "+this.agentSignature:"")}async query(t,e,i=null,r=0,n=0){let s={query:t,variables:e},o=this.newSignedRequest("POST","/admin/graphql",s);return this._wrapWithPromise(o,!1,i,r,n)}newSignedRequest(t,i,r){let n,s,o,a,h,u="application/json",f=new Date;if(null==r?s=n="":"function"==typeof r.getBoundary||r instanceof FormData?(n=r,s="",u="multipart/form-data"):s=n=JSON.stringify(r),h="","SESSION"===this._config.connectionMode)a=new Headers({"User-Agent":"Backend.AI Client for Javascript "+this.mangleUserAgentSignature(),"X-BackendAI-Version":this._config.apiVersion,"X-BackendAI-Date":f.toISOString()}),h=!0===i.startsWith("/server")?this._config.endpoint+i:this._config.endpoint+"/func"+i;else{o=this._config._apiVersion[1]<4?this.getAuthenticationString(t,i,f.toISOString(),s,u):this.getAuthenticationString(t,i,f.toISOString(),"",u);let e=this.getSignKey(this._config.secretKey,f),r=this.sign(e,"binary",o,"hex");a=new Headers({"User-Agent":"Backend.AI Client for Javascript "+this.mangleUserAgentSignature(),"X-BackendAI-Version":this._config.apiVersion,"X-BackendAI-Date":f.toISOString(),Authorization:`BackendAI signMethod=HMAC-SHA256, credential=${this._config.accessKey}:${r}`}),h=this._config.endpoint+i}return null!=r?("function"==typeof r.getBoundary&&a.set("Content-Type",r.getHeaders()["content-type"]),r instanceof FormData||(a.set("Content-Type",u),a.set("Content-Length",e.byteLength(s)))):a.set("Content-Type",u),{method:t,headers:a,cache:"default",body:n,uri:h}}newUnsignedRequest(t,e,i){return this.newPublicRequest(t,e,i,this._config.apiVersionMajor)}newPublicRequest(t,e,i,r){let n=new Date,s={method:t,headers:new Headers({"Content-Type":"application/json","User-Agent":"Backend.AI Client for Javascript "+this.mangleUserAgentSignature(),"X-BackendAI-Version":this._config.apiVersion,"X-BackendAI-Date":n.toISOString(),credentials:"include",mode:"cors"}),mode:"cors",cache:"default",uri:""};return"SESSION"===this._config.connectionMode&&!0===e.startsWith("/server")?s.uri=this._config.endpoint+e:"SESSION"===this._config.connectionMode&&!1===e.startsWith("/server")?s.uri=this._config.endpoint+"/func"+e:s.uri=this._config.endpoint+e,s}getAuthenticationString(t,e,i,r,n="application/json"){let s=xf.createHash(this._config.hashType).update(r).digest("hex");return t+"\n"+e+"\n"+i+"\nhost:"+this._config.endpointHost+"\ncontent-type:"+n+"\nx-backendai-version:"+this._config.apiVersion+"\n"+s}getCurrentDate(t){return("0000"+t.getUTCFullYear()).slice(-4)+("0"+(t.getUTCMonth()+1)).slice(-2)+("0"+t.getUTCDate()).slice(-2)}sign(t,i,r,n){let s=new e(t,i),o=xf.createHmac(this._config.hashType,s);return o.update(r,"utf8"),o.digest(n)}getSignKey(t,e){let i=this.sign(t,"utf8",this.getCurrentDate(e),"binary");return this.sign(i,"binary",this._config.endpointHost,"binary")}generateSessionId(t=8,e=!1){for(var i="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=0;n"aaaaeeeeiiiioooouuuuncsyoarsnpwgnmuxzh------".charAt(e.indexOf(t))).replace(/&/g,"-and-").replace(/[^\w\-]+/g,"").replace(/\-\-+/g,"-").replace(/^-+/,"").replace(/-+$/,"")}async fetchSSHKeypair(){let t=this.newSignedRequest("GET","/auth/ssh-keypair",null);return this._wrapWithPromise(t,!1)}async refreshSSHKeypair(){let t=this.newSignedRequest("PATCH","/auth/ssh-keypair",null);return this._wrapWithPromise(t,!1)}}class n{constructor(t){this.client=t,this.urlPrefix="/resource"}async list(t=null){let e=this.client.newSignedRequest("GET",this.urlPrefix+"/presets",t);return this.client._wrapWithPromise(e)}async check(t=null){let e=this.client.newSignedRequest("POST",this.urlPrefix+"/check-presets",t);return this.client._wrapWithPromise(e)}async add(t=null,e){if(!0===this.client.is_admin&&null!==t){let i="mutation($name: String!, $input: CreateResourcePresetInput!) { create_resource_preset(name: $name, props: $input) { ok msg }}",r={name:t,input:e};return this.client.query(i,r)}return Promise.resolve(!1)}async mutate(t=null,e){if(!0===this.client.is_admin&&null!==t){let i="mutation($name: String!, $input: ModifyResourcePresetInput!) { modify_resource_preset(name: $name, props: $input) { ok msg }}",r={name:t,input:e};return this.client.query(i,r)}return Promise.resolve(!1)}async delete(t=null){if(!0===this.client.is_admin&&null!==t){let e="mutation($name: String!) { delete_resource_preset(name: $name) { ok msg }}",i={name:t};return this.client.query(e,i)}return Promise.resolve(!1)}}class s{constructor(t,e=null){this.client=t,this.name=e,this.urlPrefix="/folders"}async list_allowed_types(){let t=this.client.newSignedRequest("GET",this.urlPrefix+"/_/allowed_types",null);return this.client._wrapWithPromise(t)}async create(t,e="",i="",r="general",n="rw",s=!1){let o;""!==e&&(o={name:t,host:e}),this.client.supports("group-folder")&&""!==i&&(o={name:t,host:e,group:i}),this.client.isAPIVersionCompatibleWith("v4.20191215")&&(r&&(o.usage_mode=r),n&&(o.permission=n)),this.client.supports("storage-proxy")&&(o.cloneable=s);let a=this.client.newSignedRequest("POST",""+this.urlPrefix,o);return this.client._wrapWithPromise(a)}async clone(t,e=null){let i=this.client.newSignedRequest("POST",`${this.urlPrefix}/${e}/clone`,t);return this.client._wrapWithPromise(i)}async update_folder(t,e=null){let i=this.client.newSignedRequest("POST",`${this.urlPrefix}/${e}/update-options`,t);return this.client._wrapWithPromise(i)}async list(t=null){let e=this.urlPrefix;if(t){const i={group_id:t};e+="?"+Of.stringify(i)}let i=this.client.newSignedRequest("GET",e,null);return this.client._wrapWithPromise(i)}async list_hosts(){let t=this.client.newSignedRequest("GET",this.urlPrefix+"/_/hosts",null);return this.client._wrapWithPromise(t)}async info(t=null){null==t&&(t=this.name);let e=this.client.newSignedRequest("GET",`${this.urlPrefix}/${t}`,null);return this.client._wrapWithPromise(e)}async rename(t=null){const e={new_name:t};let i=this.client.newSignedRequest("POST",`${this.urlPrefix}/${this.name}/rename`,e);return this.client._wrapWithPromise(i)}async delete(t=null){null==t&&(t=this.name);let e=this.client.newSignedRequest("DELETE",`${this.urlPrefix}/${t}`,null);return this.client._wrapWithPromise(e)}async leave_invited(t=null){null==t&&(t=this.name);let e=this.client.newSignedRequest("POST",`${this.urlPrefix}/${t}/leave`,null);return this.client._wrapWithPromise(e)}async upload(t,e,i=null){null==i&&(i=this.name);let r=new FormData;r.append("src",e,t);let n=this.client.newSignedRequest("POST",`${this.urlPrefix}/${i}/upload`,r);return this.client._wrapWithPromise(n)}async uploadFormData(t,e=null){let i=this.client.newSignedRequest("POST",`${this.urlPrefix}/${e}/upload`,t);return this.client._wrapWithPromise(i)}async create_upload_session(t,e,i=null){null==i&&(i=this.name);let r,n={path:t,size:e.size};r=this.client._apiVersionMajor<6?`${this.urlPrefix}/${i}/create_upload_session`:`${this.urlPrefix}/${i}/request-upload`;const s=this.client.newSignedRequest("POST",r,n),o=await this.client._wrapWithPromise(s),a=o.token;let h;return this.client._apiVersionMajor<6?(h=this.client._config.endpoint,"SESSION"===this.client._config.connectionMode&&(h+="/func"),h+=`${this.urlPrefix}/_/tus/upload/${a}`):h=`${o.url}?token=${a}`,Promise.resolve(h)}async mkdir(t,e=null,i=null,r=null){null==e&&(e=this.name);const n={path:t};i&&(n.parents=i),r&&(n.exist_ok=r);const s=this.client.newSignedRequest("POST",`${this.urlPrefix}/${e}/mkdir`,n);return this.client._wrapWithPromise(s)}async rename_file(t,e,i=null,r=!1){let n;null==i&&(i=this.name),n=this.client.isAPIVersionCompatibleWith("v6.20200815")?{target_path:t,new_name:e,is_dir:r}:{target_path:t,new_name:e};let s=this.client.newSignedRequest("POST",`${this.urlPrefix}/${i}/rename_file`,n);return this.client._wrapWithPromise(s)}async delete_files(t,e=!1,i=null){null==i&&(i=this.name),null==e&&(e=!1);let r={files:t,recursive:e},n=this.client.newSignedRequest("DELETE",`${this.urlPrefix}/${i}/delete_files`,r);return this.client._wrapWithPromise(n)}async download(t,e=!1,i=!1,r=!1){const n={file:t,archive:i},s=Of.stringify(n);if(this.client._apiVersionMajor<6){const t=this.client.newSignedRequest("GET",`${this.urlPrefix}/${e}/download_single?${s}`,null);return this.client._wrapWithPromise(t,!0)}{const n=await this.request_download_token(t,e),s=`${n.url}?token=${n.token}&archive=${i}&no_cache=${r}`;return fetch(s)}}async request_download_token(t,e=!1,i=!1){let r,n={file:t,archive:i};r=this.client._apiVersionMajor<6?`${this.urlPrefix}/${e}/request_download`:`${this.urlPrefix}/${e}/request-download`;const s=this.client.newSignedRequest("POST",r,n);return this.client._wrapWithPromise(s)}async download_with_token(t=""){let e={token:t},i=Of.stringify(e),r=this.client.newSignedRequest("GET",`${this.urlPrefix}/_/download_with_token?${i}`,null);return this.client._wrapWithPromise(r,!0)}get_download_url_with_token(t=""){const e={token:t};let i=Of.stringify(e);return"SESSION"===this.client._config.connectionMode?`${this.client._config.endpoint}/func${this.urlPrefix}/_/download_with_token?${i}`:`${this.client._config.endpoint}${this.urlPrefix}/_/download_with_token?${i}`}async list_files(t,e=null){null==e&&(e=this.name);let i={path:t},r=Of.stringify(i),n=this.client.newSignedRequest("GET",`${this.urlPrefix}/${e}/files?${r}`,null);return this.client._wrapWithPromise(n)}async invite(t,e,i=null){null==i&&(i=this.name);let r={perm:t,user_ids:e},n=this.client.newSignedRequest("POST",`${this.urlPrefix}/${i}/invite`,r);return this.client._wrapWithPromise(n)}async invitations(){let t=this.client.newSignedRequest("GET",this.urlPrefix+"/invitations/list",null);return this.client._wrapWithPromise(t)}async accept_invitation(t){let e={inv_id:t},i=this.client.newSignedRequest("POST",this.urlPrefix+"/invitations/accept",e);return this.client._wrapWithPromise(i)}async delete_invitation(t){let e={inv_id:t},i=this.client.newSignedRequest("DELETE",this.urlPrefix+"/invitations/delete",e);return this.client._wrapWithPromise(i)}async list_invitees(t=null){let e="/folders/_/shared";null!==t&&(e=`${e}?vfolder_id=${t}`);let i=this.client.newSignedRequest("GET",e,null);return this.client._wrapWithPromise(i)}async modify_invitee_permission(t){let e=this.client.newSignedRequest("POST","/folders/_/shared",t);return this.client._wrapWithPromise(e)}async share(t,e,i=null){i||(i=this.name);const r={permission:t,emails:e},n=this.client.newSignedRequest("POST",`${this.urlPrefix}/${i}/share`,r);return this.client._wrapWithPromise(n)}async unshare(t,e=null){e||(e=this.name);const i={emails:t},r=this.client.newSignedRequest("DELETE",`${this.urlPrefix}/${e}/unshare`,i);return this.client._wrapWithPromise(r)}}class o{constructor(t){this.client=t}async list(t="ALIVE",e=["id","status","region","first_contact","cpu_cur_pct","mem_cur_bytes","available_slots","occupied_slots"],i=0){if(!1===["ALIVE","TERMINATED"].includes(t))return Promise.resolve(!1);let r="query($status: String) { agents(status: $status) { "+e.join(" ")+" }}",n={status:t};return this.client.query(r,n,null,i)}}class a{constructor(t){this.client=t}async list(t=["id","backend","capabilities"],e=20,i=0){let r=`query($offset:Int!, $limit:Int!) { storage_volume_list(limit:$limit, offset:$offset) { items { ${t.join(" ")} } total_count }}`,n={limit:e,offset:i};return this.client.query(r,n)}async detail(t="",e=["id","backend","path","fsprefix","capabilities"]){let i="query($vfolder_host: String!) { storage_volume(id: $vfolder_host) { "+e.join(" ")+" }}",r={vfolder_host:t};return this.client.query(i,r)}}class h{constructor(t,e=null){this.client=t,this.name=e}async info(t,e=["access_key","secret_key","is_active","is_admin","user_id","created_at","last_used","concurrency_limit","concurrency_used","rate_limit","num_queries","resource_policy"]){let i,r;return this.client.is_admin?(i="query($access_key: String!) { keypair(access_key: $access_key) { "+e.join(" ")+" }}",r={access_key:t}):(i="query { keypair { "+e.join(" ")+" }}",r={}),this.client.query(i,r)}async list(t=null,e=["access_key","is_active","is_admin","user_id","created_at","last_used","concurrency_used","rate_limit","num_queries","resource_policy"],i=!0){let r,n;if(this.client._apiVersionMajor<5)return r=this.client.is_admin&&null==t?`\n query($is_active: Boolean) {\n keypairs(is_active: $is_active) {\n ${e.join(" ")}\n }\n }\n `:`\n query($email: String!, $is_active: Boolean) {\n keypairs(email: $email, is_active: $is_active) {\n ${e.join(" ")}\n }\n }\n `,n={email:t||this.client.email,is_active:i},this.client.query(r,n);{const s=100,o=[];r=this.client.is_admin&&null==t?`\n query($offset:Int!, $limit:Int!, $is_active: Boolean) {\n keypair_list(offset:$offset, limit:$limit, is_active: $is_active) {\n items { ${e.join(" ")} }\n total_count\n }\n }\n `:`\n query($offset:Int!, $limit:Int!, $email: String!, $is_active: Boolean) {\n keypair_list(offset:$offset, limit:$limit, email: $email, is_active: $is_active) {\n items { ${e.join(" ")} }\n total_count\n }\n }\n `;for(let e=0;e<10*s;e+=s){n={offset:e,limit:s,email:t||this.client.email,is_active:i};const a=await this.client.query(r,n);if(o.push(...a.keypair_list.items),e>=a.keypair_list.total_count)break}const a={keypairs:o};return Promise.resolve(a)}}async add(t=null,e=!0,i=!1,r="default",n=1e3){let s=`mutation($user_id: String!, $input: KeyPairInput!) { create_keypair(user_id: $user_id, props: $input) { ok msg keypair { ${["is_active","is_admin","resource_policy","concurrency_limit","rate_limit"].join(" ")} } }}`,o={user_id:t,input:{is_active:e,is_admin:i,resource_policy:r,rate_limit:n}};return this.client.query(s,o)}async mutate(t,e){let i={access_key:t,input:e};return this.client.query("mutation($access_key: String!, $input: ModifyKeyPairInput!) { modify_keypair(access_key: $access_key, props: $input) { ok msg }}",i)}async delete(t){let e={access_key:t};return this.client.query("mutation($access_key: String!) { delete_keypair(access_key: $access_key) { ok msg }}",e)}}class u{constructor(t){this.client=t}async get(t=null,e=["name","created_at","default_for_unspecified","total_resource_slots","max_concurrent_sessions","max_containers_per_session","max_vfolder_count","max_vfolder_size","allowed_vfolder_hosts","idle_timeout"]){let i,r;return null===t?(i=`query { keypair_resource_policies { ${e.join(" ")} }}`,r={n:t}):(i=`query($n:String!) { keypair_resource_policy(name: $n) { ${e.join(" ")} }}`,r={n:t}),this.client.query(i,r)}async add(t=null,e){let i=["name","created_at","default_for_unspecified","total_resource_slots","max_concurrent_sessions","max_containers_per_session","max_vfolder_count","max_vfolder_size","allowed_vfolder_hosts","idle_timeout"];if(!0===this.client.is_admin&&null!==t){let r=`mutation($name: String!, $input: CreateKeyPairResourcePolicyInput!) { create_keypair_resource_policy(name: $name, props: $input) { ok msg resource_policy { ${i.join(" ")} } }}`,n={name:t,input:e};return this.client.query(r,n)}return Promise.resolve(!1)}async mutate(t=null,e){if(!0===this.client.is_admin&&null!==t){let i="mutation($name: String!, $input: ModifyKeyPairResourcePolicyInput!) { modify_keypair_resource_policy(name: $name, props: $input) { ok msg }}",r={name:t,input:e};return this.client.query(i,r)}return Promise.resolve(!1)}async delete(t=null){if(!0===this.client.is_superadmin&&null!==t){let e="mutation($name: String!) { delete_keypair_resource_policy(name: $name) { ok msg }}",i={name:t};return this.client.query(e,i)}return Promise.resolve(!1)}}class f{constructor(t){this.client=t}async list(t=["name","tag","registry","digest","installed","labels { key value }","resource_limits { key min max }"],e=!1,i=!1){let r,n;return this.client.supports("system-images")?!0===e?(r=`query($installed:Boolean) { images(is_installed:$installed) { ${t.join(" ")} }}`,n={installed:e,is_operation:i}):(r=`query { images { ${t.join(" ")} }}`,n={is_operation:i}):(r=`query { images { ${t.join(" ")} }}`,n={}),this.client.query(r,n)}async modifyResource(t,e,i,r){let n=[];return t=t.replace(":","%3A"),e=e.replace("/","%2F"),Object.keys(r).forEach(s=>{Object.keys(r[s]).forEach(o=>{const a=this.client.newSignedRequest("POST","/config/set",{key:`images/${t}/${e}/${i}/resource/${s}/${o}`,value:r[s][o]});n.push(this.client._wrapWithPromise(a))})}),Promise.all(n)}async modifyLabel(t,e,i,r,n){t=t.replace(":","%3A"),e=e.replace("/","%2F"),i=i.replace("/","%2F");const s=this.client.newSignedRequest("POST","/config/set",{key:`images/${t}/${e}/${i}/labels/${r}`,value:n});return this.client._wrapWithPromise(s)}async install(t,e={},i="index.docker.io"){"index.docker.io"!=i?i+="/":i="",i=i.replace(":","%3A");let r=this.client.generateSessionId();return 0===Object.keys(e).length&&(e={cpu:"1",mem:"512m"}),this.client.createIfNotExists(i+t,r,e,6e5).then(t=>this.client.destroy(r)).catch(t=>{throw t})}async uninstall(t,e="index.docker.io"){return Promise.resolve(!1)}async get(t,e,i){t=t.replace(":","%3A");const r=this.client.newSignedRequest("POST","/config/get",{key:`images/${t}/${e}/${i}/resource/`,prefix:!0});return this.client._wrapWithPromise(r)}}class l{constructor(t){this.client=t}async total_count(t="RUNNING",e="",i=1,r=0,n=""){let s,o;return s="query($limit:Int!, $offset:Int!, $ak:String, $group_id:String, $status:String) {\n compute_session_list(limit:$limit, offset:$offset, access_key:$ak, group_id:$group_id, status:$status) {\n total_count\n }\n }",o={limit:i,offset:r,status:t},""!=e&&(o.ak=e),""!=n&&(o.group_id=n),this.client.query("query($limit:Int!, $offset:Int!, $ak:String, $group_id:String, $status:String) {\n compute_session_list(limit:$limit, offset:$offset, access_key:$ak, group_id:$group_id, status:$status) {\n total_count\n }\n }",o)}async list(t=["id","name","image","created_at","terminated_at","status","status_info","occupied_slots","containers {live_stat last_stat}"],e="RUNNING",i="",r=30,n=0,s="",o=0){let a,h;return a=`query($limit:Int!, $offset:Int!, $ak:String, $group_id:String, $status:String) {\n compute_session_list(limit:$limit, offset:$offset, access_key:$ak, group_id:$group_id, status:$status) {\n items { ${(t=this.client._updateFieldCompatibilityByAPIVersion(t)).join(" ")}}\n total_count\n }\n }`,h={limit:r,offset:n,status:e},""!=i&&(h.ak=i),""!=s&&(h.group_id=s),this.client.query(a,h,null,o)}async listAll(t=["id","name","image","created_at","terminated_at","status","status_info","occupied_slots","containers {live_stat last_stat}"],e="RUNNING,RESTARTING,TERMINATING,PENDING,PREPARING,PULLING,TERMINATED,CANCELLED,ERROR",i="",r=100,n=0,s="",o=0){let a,h;const u=[];a=`query($limit:Int!, $offset:Int!, $ak:String, $group_id:String, $status:String) {\n compute_session_list(limit:$limit, offset:$offset, access_key:$ak, group_id:$group_id, status:$status) {\n items { ${(t=this.client._updateFieldCompatibilityByAPIVersion(t)).join(" ")}}\n total_count\n }\n }`;for(let f=0;f<10*r;f+=r){h={limit:r,offset:f,status:e},""!=i&&(h.access_key=i),""!=s&&(h.group_id=s);const t=await this.client.query(a,h,null,o);if(console.log(t.compute_session_list.total_count),u.push(...t.compute_session_list.items),f>=t.compute_session_list.total_count)break}return Promise.resolve(u)}async get(t=["id","session_name","lang","created_at","terminated_at","status","status_info","occupied_slots","cpu_used","io_read_bytes","io_write_bytes"],e=""){let i,r;return i=`query($session_uuid: UUID!) {\n compute_session(id:$session_uuid) {\n ${(t=this.client._updateFieldCompatibilityByAPIVersion(t)).join(" ")}\n }\n }`,r={session_uuid:e},this.client.query(i,r)}}class d{constructor(t){this.client=t,this.urlPrefix="/template/session"}async list(t=!1,e=null){let i=this.urlPrefix;if(t){const e={all:t};i+="?"+Of.stringify(e)}if(e){const t={group_id:e};i+="?"+Of.stringify(t)}let r=this.client.newSignedRequest("GET",i,null);return this.client._wrapWithPromise(r)}}class c{constructor(t){this.client=t,this.resources={},this._init_resource_values()}_init_resource_values(){this.resources.cpu={},this.resources.cpu.total=0,this.resources.cpu.used=0,this.resources.cpu.percent=0,this.resources.mem={},this.resources.mem.total=0,this.resources.mem.allocated=0,this.resources.mem.used=0,this.resources.gpu={},this.resources.gpu.total=0,this.resources.gpu.used=0,this.resources["cuda.device"]={},this.resources["cuda.device"].total=0,this.resources["cuda.device"].used=0,this.resources.fgpu={},this.resources.fgpu.total=0,this.resources.fgpu.used=0,this.resources["cuda.shares"]={},this.resources["cuda.shares"].total=0,this.resources["cuda.shares"].used=0,this.resources["rocm.device"]={},this.resources["rocm.device"].total=0,this.resources["rocm.device"].used=0,this.resources["tpu.device"]={},this.resources["tpu.device"].total=0,this.resources["tpu.device"].used=0,this.resources.agents={},this.resources.agents.total=0,this.resources.agents.using=0,this.agents=[]}async totalResourceInformation(t="ALIVE"){if(this.client.is_admin){let e=["id","addr","status","first_contact","cpu_cur_pct","mem_cur_bytes","occupied_slots","available_slots"];return this.client.agent.list(t,e).then(t=>(this._init_resource_values(),this.agents=t.agents,Object.keys(this.agents).map((t,e)=>{let i=this.agents[t],r=JSON.parse(i.occupied_slots),n=JSON.parse(i.available_slots);"cpu"in n&&(this.resources.cpu.total=this.resources.cpu.total+Math.floor(Number(n.cpu))),"cpu"in r&&(this.resources.cpu.used=this.resources.cpu.used+Math.floor(Number(r.cpu))),this.resources.cpu.percent=this.resources.cpu.percent+parseFloat(i.cpu_cur_pct),void 0===r.mem&&(r.mem=0),this.resources.mem.total=parseFloat(this.resources.mem.total)+parseInt(this.client.utils.changeBinaryUnit(n.mem,"b")),this.resources.mem.allocated=parseInt(this.resources.mem.allocated)+parseInt(this.client.utils.changeBinaryUnit(r.mem,"b")),this.resources.mem.used=parseInt(this.resources.mem.used)+parseInt(this.client.utils.changeBinaryUnit(i.mem_cur_bytes,"b")),"cuda.device"in n&&(this.resources["cuda.device"].total=parseInt(this.resources["cuda.device"].total)+Math.floor(Number(n["cuda.device"]))),"cuda.device"in r&&(this.resources["cuda.device"].used=parseInt(this.resources["cuda.device"].used)+Math.floor(Number(r["cuda.device"]))),"cuda.shares"in n&&(this.resources["cuda.shares"].total=parseFloat(this.resources["cuda.shares"].total)+parseFloat(n["cuda.shares"])),"cuda.shares"in r&&(this.resources["cuda.shares"].used=parseFloat(this.resources["cuda.shares"].used)+parseFloat(r["cuda.shares"])),"rocm.device"in n&&(this.resources["rocm.device"].total=parseInt(this.resources["rocm.device"].total)+Math.floor(Number(n["rocm.device"]))),"rocm.device"in r&&(this.resources["rocm.device"].used=parseInt(this.resources["rocm.device"].used)+Math.floor(Number(r["rocm.device"]))),"tpu.device"in n&&(this.resources["tpu.device"].total=parseInt(this.resources["tpu.device"].total)+Math.floor(Number(n["tpu.device"]))),"tpu.device"in r&&(this.resources["tpu.device"].used=parseInt(this.resources["tpu.device"].used)+Math.floor(Number(r["tpu.device"]))),isNaN(this.resources.cpu.used)&&(this.resources.cpu.used=0),isNaN(this.resources.mem.used)&&(this.resources.mem.used=0),isNaN(this.resources.gpu.used)&&(this.resources.gpu.used=0),isNaN(this.resources.fgpu.used)&&(this.resources.fgpu.used=0)}),this.resources.gpu.total=this.resources["cuda.device"].total,this.resources.gpu.used=this.resources["cuda.device"].used,this.resources.fgpu.used=this.resources["cuda.shares"].used.toFixed(2),this.resources.fgpu.total=this.resources["cuda.shares"].total.toFixed(2),this.resources.agents.total=Object.keys(this.agents).length,this.resources.agents.using=Object.keys(this.agents).length,Promise.resolve(this.resources))).catch(t=>{throw t})}return Promise.resolve(!1)}async user_stats(){const t=this.client.newSignedRequest("GET","/resource/stats/user/month",null);return this.client._wrapWithPromise(t)}}class p{constructor(t){this.client=t}async list(t=!0,e=!1,i=["id","name","description","is_active","created_at","modified_at","domain_name"]){let r,n;return!0===this.client.is_admin?(r=`query($is_active:Boolean) { groups(is_active:$is_active) { ${i.join(" ")} }}`,n={is_active:t},!1!==e&&(r=`query($domain_name: String, $is_active:Boolean) { groups(domain_name: $domain_name, is_active:$is_active) { ${i.join(" ")} }}`,n={is_active:t,domain_name:e})):(r=`query($is_active:Boolean) { groups(is_active:$is_active) { ${i.join(" ")} }}`,n={is_active:t}),this.client.query(r,n)}}class m{constructor(t){this.client=t}async get(t=!1,e=["name","description","is_active","created_at","modified_at","total_resource_slots","allowed_vfolder_hosts","allowed_docker_registries","integration_id","scaling_groups"]){let i,r;if(!1!==t)return i=`query($name: String) { domain(name: $name) { ${e.join(" ")} }}`,r={name:t},this.client.query(i,r)}async list(t=["name","description","is_active","created_at","total_resource_slots","allowed_vfolder_hosts","allowed_docker_registries","integration_id"]){let e=`query { domains { ${t.join(" ")} }}`;return this.client.query(e,{})}async update(t=!1,e){if(!0===this.client.is_superadmin){let i="mutation($name: String!, $input: ModifyDomainInput!) { modify_domain(name: $name, props: $input) { ok msg }}",r={name:t,input:e};return this.client.query(i,r)}return Promise.resolve(!1)}}class g{constructor(t){this.client=t,this.urlPrefix="/resource"}attach_background_task(t){var e="/events/background-task?task_id="+t;let i=this.client.newSignedRequest("GET",e,null);return new EventSource(i.uri,{withCredentials:!0})}async rescan_images(t=""){if(!0===this.client.is_admin){let e,i;return""!==t?(t=decodeURIComponent(t),e="mutation($registry: String) { rescan_images(registry: $registry) { ok msg task_id }}",i={registry:t}):(e="mutation { rescan_images { ok msg task_id }}",i={}),this.client.query(e,i,null,6e5)}return Promise.resolve(!1)}async recalculate_usage(){if(!0===this.client.is_superadmin){let t=this.client.newSignedRequest("POST",this.urlPrefix+"/recalculate-usage",null);return this.client._wrapWithPromise(t,null,null,6e4)}}}class v{constructor(t){this.client=t}async list(t=!0,e=["username","password","need_password_change","full_name","description","is_active","domain_name","role","groups {id name}"]){let i,r;if(this.client._apiVersionMajor<5)return i=this.client.is_admin?`\n query($is_active:Boolean) {\n users(is_active:$is_active) { ${e.join(" ")} }\n }\n `:`\n query {\n users { ${e.join(" ")} }\n }\n `,r=this.client.is_admin?{is_active:t}:{},this.client.query(i,r);{const n=100,s=[];i=this.client.is_admin?`\n query($offset:Int!, $limit:Int!, $is_active:Boolean) {\n user_list(offset:$offset, limit:$limit, is_active:$is_active) {\n items { ${e.join(" ")} }\n total_count\n }\n }\n `:`\n query($offset:Int!, $limit:Int!) {\n user_list(offset:$offset, limit:$limit) {\n items { ${e.join(" ")} }\n total_count\n }\n }\n `;for(let e=0;e<10*n;e+=n){r=this.client.is_admin?{offset:e,limit:n,is_active:t}:{offset:e,limit:n};const o=await this.client.query(i,r);if(s.push(...o.user_list.items),e>=o.user_list.total_count)break}const o={users:s};return Promise.resolve(o)}}async get(t,e=["email","username","password","need_password_change","full_name","description","is_active","domain_name","role","groups {id name}"]){let i,r;return!0===this.client.is_admin?(i=`query($email:String) { user (email:$email) { ${e.join(" ")} }}`,r={email:t}):(i=`query { user { ${e.join(" ")} }}`,r={}),this.client.query(i,r)}async create(t=null,e){let i=["username","password","need_password_change","full_name","description","is_active","domain_name","role","groups{id, name}"];if(!0===this.client.is_admin){let r=`mutation($email: String!, $input: UserInput!) { create_user(email: $email, props: $input) { ok msg user { ${i.join(" ")} } }}`,n={email:t,input:e};return this.client.query(r,n)}return Promise.resolve(!1)}async update(t=null,e){if(!0===this.client.is_superadmin){let i="mutation($email: String!, $input: ModifyUserInput!) { modify_user(email: $email, props: $input) { ok msg }}",r={email:t,input:e};return this.client.query(i,r)}return Promise.resolve(!1)}async delete(t){if(!0===this.client.is_superadmin){let e="mutation($email: String!) { delete_user(email: $email) { ok msg }}",i={email:t};return this.client.query(e,i)}return Promise.resolve(!1)}}class b{constructor(t){this.client=t}async list_available(){if(!0===this.client.is_superadmin){const t=`query { scaling_groups { ${["name","description","is_active","created_at","driver","driver_opts","scheduler","scheduler_opts"].join(" ")} }}`,e={};return this.client.query(t,e)}return Promise.resolve(!1)}async list(t="default"){const e="/scaling-groups?group="+t,i=this.client.newSignedRequest("GET",e,null);return this.client._wrapWithPromise(i)}async create(t,e=""){let i={name:t,input:{description:e,is_active:!0,driver:"static",scheduler:"fifo",driver_opts:"{}",scheduler_opts:"{}"}};return this.client.query("mutation($name: String!, $input: ScalingGroupInput!) { create_scaling_group(name: $name, props: $input) { ok msg }}",i)}async associate_domain(t,e){let i={domain:t,scaling_group:e};return this.client.query("mutation($domain: String!, $scaling_group: String!) { associate_scaling_group_with_domain(domain: $domain, scaling_group: $scaling_group) { ok msg }}",i)}async update(t,e){let i={name:t,input:e};return this.client.query("mutation($name: String!, $input: ModifyScalingGroupInput!) { modify_scaling_group(name: $name, props: $input) { ok msg }}",i)}async delete(t){let e={name:t};return this.client.query("mutation($name: String!) { delete_scaling_group(name: $name) { ok msg }}",e)}}class y{constructor(t){this.client=t}async list(){const t=this.client.newSignedRequest("POST","/config/get",{key:"config/docker/registry",prefix:!0});return this.client._wrapWithPromise(t)}async add(t,e){let i="config/docker/registry/"+(t=encodeURIComponent(t));const r=this.client.newSignedRequest("POST","/config/set",{key:i,value:e});return this.client._wrapWithPromise(r)}async delete(t){t=encodeURIComponent(t);const e=this.client.newSignedRequest("POST","/config/delete",{key:"config/docker/registry/"+t,prefix:!0});return this.client._wrapWithPromise(e)}}class w{constructor(t){this.client=t,this.config=null}async list(t=""){t="config/"+t;const e=this.client.newSignedRequest("POST","/config/get",{key:t,prefix:!0});return this.client._wrapWithPromise(e)}async get(t){t="config/"+t;const e=this.client.newSignedRequest("POST","/config/get",{key:t,prefix:!1});return this.client._wrapWithPromise(e)}async set(t,e){t="config/"+t;const i=this.client.newSignedRequest("POST","/config/set",{key:t,value:e});return this.client._wrapWithPromise(i)}async delete(t,e=!1){t="config/"+t;const i=this.client.newSignedRequest("POST","/config/delete",{key:""+t,prefix:e});return this.client._wrapWithPromise(i)}}class M{constructor(t){this.client=t,this.config=null}async get_announcement(){const t=this.client.newSignedRequest("GET","/manager/announcement",null);return this.client._wrapWithPromise(t)}async update_announcement(t=!0,e){const i=this.client.newSignedRequest("POST","/manager/announcement",{enabled:t,message:e});return this.client._wrapWithPromise(i)}}class _{constructor(t){this.client=t,this.config=null}async get_bootstrap_script(){if(!this.client._config.accessKey)throw"Your access key is not set";const t=this.client.newSignedRequest("GET","/user-config/bootstrap-script");return this.client._wrapWithPromise(t)}async update_bootstrap_script(t){const e=this.client.newSignedRequest("POST","/user-config/bootstrap-script",{script:t});return this.client._wrapWithPromise(e)}async create(t="",e){if(!this.client._config.accessKey)throw"Your access key is not set";let i={path:e,data:t,permission:"644"};const r=this.client.newSignedRequest("POST","/user-config/dotfiles",i);return this.client._wrapWithPromise(r)}async get(){if(!this.client._config.accessKey)throw"Your access key is not set";const t=this.client.newSignedRequest("GET","/user-config/dotfiles");return this.client._wrapWithPromise(t)}async update(t,e){let i={data:t,path:e,permission:"644"};const r=this.client.newSignedRequest("PATCH","/user-config/dotfiles",i);return this.client._wrapWithPromise(r)}async delete(t){let e={path:t};const i=this.client.newSignedRequest("DELETE","/user-config/dotfiles",e);return this.client._wrapWithPromise(i)}}class S{constructor(t){this.client=t,this.config=null}async getLicense(){if(!0!==this.client.is_superadmin)return Promise.resolve(!1);if(void 0===this.certificate){const t=this.client.newSignedRequest("GET","/license");let e=await this.client._wrapWithPromise(t);return this.certificate=e.certificate,"valid"===e.status?this.certificate.valid=!0:this.certificate.valid=!1,Promise.resolve(this.certificate)}}}class E{constructor(t){this.client=t,this.config=null}async ping(){const t=this.client.newSignedRequest("GET","/cloud/ping");return this.client._wrapWithPromise(t)}async verify_email(t){const e={verification_code:t},i=this.client.newSignedRequest("POST","/cloud/verify-email",e);return this.client._wrapWithPromise(i)}async send_verification_email(t){const e={email:t},i=this.client.newSignedRequest("POST","/cloud/send-verification-email",e);return this.client._wrapWithPromise(i)}async send_password_change_email(t){const e={email:t},i=this.client.newSignedRequest("POST","/cloud/send-password-change-email",e);return this.client._wrapWithPromise(i)}async change_password(t,e,i){const r={email:t,password:e,token:i},n=this.client.newSignedRequest("POST","/cloud/change-password",r);return this.client._wrapWithPromise(n)}}class k{constructor(t){this.client=t}changeBinaryUnit(t,e="g",i="b"){if(void 0===t)return t;let r;const n=["b","k","m","g","t","p","auto"],s=["B","KiB","MiB","GiB","TiB","PiB"];if(!n.includes(e))return!1;if((t=t.toString()).indexOf(" ")>=0){let e=t.split(/(\s+)/);t=s.includes(e[2])?e[0]+n[s.indexOf(e[2])]:e[0]}return n.includes(t.substr(-1))?(r=t.substr(-1),t=t.slice(0,-1)):r=i,t*Math.pow(1024,Math.floor(n.indexOf(r)-n.indexOf(e)))}elapsedTime(t,e){var i=new Date(t);if(null===e)var r=new Date;else r=new Date(e);var n=Math.floor((r.getTime()-i.getTime())/1e3),s=Math.floor(n/86400);n-=86400*s;var o=Math.floor(n/3600);n-=3600*o;var a=Math.floor(n/60),h=n-=60*a,u="";return void 0!==s&&s>0&&(u=u+String(s)+" Day "),void 0!==o&&(u=u+this._padding_zeros(o,2)+":"),void 0!==a&&(u=u+this._padding_zeros(a,2)+":"),u+this._padding_zeros(h,2)+""}_padding_zeros(t,e){return(t+="").length>=e?t:new Array(e-t.length+1).join("0")+t}gqlToObject(t,e){let i={};return t.forEach((function(t){i[t[e]]=t})),i}gqlToList(t,e){let i=[];return t.forEach((function(t){i.push(t[e])})),i}}Object.defineProperty(r,"ERR_SERVER",{value:0,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(r,"ERR_RESPONSE",{value:1,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(r,"ERR_REQUEST",{value:2,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(r,"ERR_ABORT",{value:3,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(r,"ERR_TIMEOUT",{value:4,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(r,"ERR_UNKNOWN",{value:99,writable:!1,enumerable:!0,configurable:!1});const R={Client:r,ClientConfig:i};Lf.backend=R,Lf.Client=r,Lf.ClientConfig=i,Lf.BackendAIClient=r,Lf.BackendAIClientConfig=i}).call(this)}.call(this,D,M({}).Buffer),Lf})); \ No newline at end of file +!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).ai=t()}}((function(){for(var t=function(t){var e;return function(i){return e||t(e={exports:{},parent:i},e.exports),e.exports}},e=t((function(t,e){(function(e,n){(function(){"use strict";var o;t.exports=A,A.ReadableState=R,et.EventEmitter;var a,h=function(t,e){return t.listeners(e).length},u=M({}).Buffer,f=n.Uint8Array||function(){},l=w({});a=l&&l.debuglog?l.debuglog("stream"):function(){};var d,c,p,m=Us.getHighWaterMark,g=Ls.codes,b=g.ERR_INVALID_ARG_TYPE,y=g.ERR_STREAM_PUSH_AFTER_EOF,_=g.ERR_METHOD_NOT_IMPLEMENTED,S=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;Q(A,Rs);var E=Os.errorOrDestroy,k=["error","close","destroy","pause","resume"];function R(t,e,i){o=o||s({}),t=t||{},"boolean"!=typeof i&&(i=e instanceof o),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=m(this,t,"readableHighWaterMark",i),this.buffer=new qs,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(d||(d=v({}).StringDecoder),this.decoder=new d(t.encoding),this.encoding=t.encoding)}function A(t){if(o=o||s({}),!(this instanceof A))return new A(t);var e=this instanceof o;this._readableState=new R(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),Rs.call(this)}function x(t,e,i,r,n){a("readableAddChunk",e);var s,o=t._readableState;if(null===e)o.reading=!1,function(t,e){if(a("onEofChunk"),!e.ended){if(e.decoder){var i=e.decoder.end();i&&i.length&&(e.buffer.push(i),e.length+=e.objectMode?1:i.length)}e.ended=!0,e.sync?B(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,I(t)))}}(t,o);else if(n||(s=function(t,e){var i,r;return r=e,u.isBuffer(r)||r instanceof f||"string"==typeof e||void 0===e||t.objectMode||(i=new b("chunk",["string","Buffer","Uint8Array"],e)),i}(o,e)),s)E(t,s);else if(o.objectMode||e&&e.length>0)if("string"==typeof e||o.objectMode||Object.getPrototypeOf(e)===u.prototype||(e=function(t){return u.from(t)}(e)),r)o.endEmitted?E(t,new S):T(t,o,e,!0);else if(o.ended)E(t,new y);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!i?(e=o.decoder.write(e),o.objectMode||0!==e.length?T(t,o,e,!1):q(t,o)):T(t,o,e,!1)}else r||(o.reading=!1,q(t,o));return!o.ended&&(o.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=1073741824?t=1073741824:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function B(t){var i=t._readableState;a("emitReadable",i.needReadable,i.emittedReadable),i.needReadable=!1,i.emittedReadable||(a("emitReadable",i.flowing),i.emittedReadable=!0,e.nextTick(I,t))}function I(t){var e=t._readableState;a("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,N(t)}function q(t,i){i.readingMore||(i.readingMore=!0,e.nextTick(O,t,i))}function O(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function j(t){a("readable nexttick read 0"),t.read(0)}function C(t,e){a("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),N(t),e.flowing&&!e.reading&&t.read(0)}function N(t){var e=t._readableState;for(a("flow",e.flowing);e.flowing&&null!==t.read(););}function D(t,e){return 0===e.length?null:(e.objectMode?i=e.buffer.shift():!t||t>=e.length?(i=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):i=e.buffer.consume(t,e.decoder),i);var i}function U(t){var i=t._readableState;a("endReadable",i.endEmitted),i.endEmitted||(i.ended=!0,e.nextTick($,i,t))}function $(t,e){if(a("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var i=e._writableState;(!i||i.autoDestroy&&i.finished)&&e.destroy()}}function z(t,e){for(var i=0,r=t.length;i=e.highWaterMark:e.length>0)||e.ended))return a("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?U(this):B(this),null;if(0===(t=P(t,e))&&e.ended)return 0===e.length&&U(this),null;var r,n=e.needReadable;return a("need readable",n),(0===e.length||e.length-t0?D(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),i!==t&&e.ended&&U(this)),null!==r&&this.emit("data",r),r},A.prototype._read=function(t){E(this,new _("_read()"))},A.prototype.pipe=function(t,i){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=t;break;case 1:n.pipes=[n.pipes,t];break;default:n.pipes.push(t)}n.pipesCount+=1,a("pipe count=%d opts=%j",n.pipesCount,i);var s=i&&!1===i.end||t===e.stdout||t===e.stderr?m:o;function o(){a("onend"),t.end()}n.endEmitted?e.nextTick(s):r.once("end",s),t.on("unpipe",(function e(i,s){a("onunpipe"),i===r&&s&&!1===s.hasUnpiped&&(s.hasUnpiped=!0,a("cleanup"),t.removeListener("close",c),t.removeListener("finish",p),t.removeListener("drain",u),t.removeListener("error",d),t.removeListener("unpipe",e),r.removeListener("end",o),r.removeListener("end",m),r.removeListener("data",l),f=!0,!n.awaitDrain||t._writableState&&!t._writableState.needDrain||u())}));var u=function(t){return function(){var e=t._readableState;a("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&h(t,"data")&&(e.flowing=!0,N(t))}}(r);t.on("drain",u);var f=!1;function l(e){a("ondata");var i=t.write(e);a("dest.write",i),!1===i&&((1===n.pipesCount&&n.pipes===t||n.pipesCount>1&&-1!==z(n.pipes,t))&&!f&&(a("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function d(e){a("onerror",e),m(),t.removeListener("error",d),0===h(t,"error")&&E(t,e)}function c(){t.removeListener("finish",p),m()}function p(){a("onfinish"),t.removeListener("close",c),m()}function m(){a("unpipe"),r.unpipe(t)}return r.on("data",l),function(t,e,i){if("function"==typeof t.prependListener)return t.prependListener("error",i);t._events&&t._events.error?Array.isArray(t._events.error)?t._events.error.unshift(i):t._events.error=[i,t._events.error]:t.on("error",i)}(t,0,d),t.once("close",c),t.once("finish",p),t.emit("pipe",r),n.flowing||(a("pipe resume"),r.resume()),t},A.prototype.unpipe=function(t){var e=this._readableState,i={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,i)),this;if(!t){var r=e.pipes,n=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var s=0;s0,!1!==n.flowing&&this.resume()):"readable"===t&&(n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,a("on readable",n.length,n.reading),n.length?B(this):n.reading||e.nextTick(j,this))),r},A.prototype.addListener=A.prototype.on,A.prototype.removeListener=function(t,i){var r=Rs.prototype.removeListener.call(this,t,i);return"readable"===t&&e.nextTick(L,this),r},A.prototype.removeAllListeners=function(t){var i=Rs.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||e.nextTick(L,this),i},A.prototype.resume=function(){var t=this._readableState;return t.flowing||(a("resume"),t.flowing=!t.readableListening,function(t,i){i.resumeScheduled||(i.resumeScheduled=!0,e.nextTick(C,t,i))}(this,t)),t.paused=!1,this},A.prototype.pause=function(){return a("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(a("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},A.prototype.wrap=function(t){var e=this,i=this._readableState,r=!1;for(var n in t.on("end",(function(){if(a("wrapped end"),i.decoder&&!i.ended){var t=i.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(n){a("wrapped data"),i.decoder&&(n=i.decoder.write(n)),i.objectMode&&null==n||(i.objectMode||n&&n.length)&&(e.push(n)||(r=!0,t.pause()))})),t)void 0===this[n]&&"function"==typeof t[n]&&(this[n]=function(e){return function(){return t[e].apply(t,arguments)}}(n));for(var s=0;s-1))throw new y(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(E.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(E.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),E.prototype._write=function(t,e,i){i(new c("_write()"))},E.prototype._writev=null,E.prototype.end=function(t,i,r){var n=this._writableState;return"function"==typeof t?(r=t,t=null,i=null):"function"==typeof i&&(r=i,i=null),null!=t&&this.write(t,i),n.corked&&(n.corked=1,this.uncork()),n.ending||function(t,i,r){i.ending=!0,P(t,i),r&&(i.finished?e.nextTick(r):t.once("finish",r)),i.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(E.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(E.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),E.prototype.destroy=Os.destroy,E.prototype._undestroy=Os.undestroy,E.prototype._destroy=function(t,e){e(t)}}).call(this)}).call(this,D,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})})),a=t((function(t,e){(function(e,i){(function(){"use strict";var r;t.exports=A,A.ReadableState=R,et.EventEmitter;var n,s=function(t,e){return t.listeners(e).length},o=M({}).Buffer,a=i.Uint8Array||function(){},f=w({});n=f&&f.debuglog?f.debuglog("stream"):function(){};var d,c,p,m=Ni.getHighWaterMark,g=qi.codes,b=g.ERR_INVALID_ARG_TYPE,y=g.ERR_STREAM_PUSH_AFTER_EOF,_=g.ERR_METHOD_NOT_IMPLEMENTED,S=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;Q(A,Ei);var E=Ii.errorOrDestroy,k=["error","close","destroy","pause","resume"];function R(t,e,i){r=r||l({}),t=t||{},"boolean"!=typeof i&&(i=e instanceof r),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=m(this,t,"readableHighWaterMark",i),this.buffer=new Bi,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(d||(d=v({}).StringDecoder),this.decoder=new d(t.encoding),this.encoding=t.encoding)}function A(t){if(r=r||l({}),!(this instanceof A))return new A(t);var e=this instanceof r;this._readableState=new R(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),Ei.call(this)}function x(t,e,i,r,s){n("readableAddChunk",e);var h,u=t._readableState;if(null===e)u.reading=!1,function(t,e){if(n("onEofChunk"),!e.ended){if(e.decoder){var i=e.decoder.end();i&&i.length&&(e.buffer.push(i),e.length+=e.objectMode?1:i.length)}e.ended=!0,e.sync?B(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,I(t)))}}(t,u);else if(s||(h=function(t,e){var i,r;return r=e,o.isBuffer(r)||r instanceof a||"string"==typeof e||void 0===e||t.objectMode||(i=new b("chunk",["string","Buffer","Uint8Array"],e)),i}(u,e)),h)E(t,h);else if(u.objectMode||e&&e.length>0)if("string"==typeof e||u.objectMode||Object.getPrototypeOf(e)===o.prototype||(e=function(t){return o.from(t)}(e)),r)u.endEmitted?E(t,new S):T(t,u,e,!0);else if(u.ended)E(t,new y);else{if(u.destroyed)return!1;u.reading=!1,u.decoder&&!i?(e=u.decoder.write(e),u.objectMode||0!==e.length?T(t,u,e,!1):q(t,u)):T(t,u,e,!1)}else r||(u.reading=!1,q(t,u));return!u.ended&&(u.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=1073741824?t=1073741824:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function B(t){var i=t._readableState;n("emitReadable",i.needReadable,i.emittedReadable),i.needReadable=!1,i.emittedReadable||(n("emitReadable",i.flowing),i.emittedReadable=!0,e.nextTick(I,t))}function I(t){var e=t._readableState;n("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,N(t)}function q(t,i){i.readingMore||(i.readingMore=!0,e.nextTick(O,t,i))}function O(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function j(t){n("readable nexttick read 0"),t.read(0)}function C(t,e){n("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),N(t),e.flowing&&!e.reading&&t.read(0)}function N(t){var e=t._readableState;for(n("flow",e.flowing);e.flowing&&null!==t.read(););}function D(t,e){return 0===e.length?null:(e.objectMode?i=e.buffer.shift():!t||t>=e.length?(i=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):i=e.buffer.consume(t,e.decoder),i);var i}function U(t){var i=t._readableState;n("endReadable",i.endEmitted),i.endEmitted||(i.ended=!0,e.nextTick($,i,t))}function $(t,e){if(n("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var i=e._writableState;(!i||i.autoDestroy&&i.finished)&&e.destroy()}}function z(t,e){for(var i=0,r=t.length;i=e.highWaterMark:e.length>0)||e.ended))return n("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?U(this):B(this),null;if(0===(t=P(t,e))&&e.ended)return 0===e.length&&U(this),null;var r,s=e.needReadable;return n("need readable",s),(0===e.length||e.length-t0?D(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),i!==t&&e.ended&&U(this)),null!==r&&this.emit("data",r),r},A.prototype._read=function(t){E(this,new _("_read()"))},A.prototype.pipe=function(t,i){var r=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=t;break;case 1:o.pipes=[o.pipes,t];break;default:o.pipes.push(t)}o.pipesCount+=1,n("pipe count=%d opts=%j",o.pipesCount,i);var a=i&&!1===i.end||t===e.stdout||t===e.stderr?m:h;function h(){n("onend"),t.end()}o.endEmitted?e.nextTick(a):r.once("end",a),t.on("unpipe",(function e(i,s){n("onunpipe"),i===r&&s&&!1===s.hasUnpiped&&(s.hasUnpiped=!0,n("cleanup"),t.removeListener("close",c),t.removeListener("finish",p),t.removeListener("drain",u),t.removeListener("error",d),t.removeListener("unpipe",e),r.removeListener("end",h),r.removeListener("end",m),r.removeListener("data",l),f=!0,!o.awaitDrain||t._writableState&&!t._writableState.needDrain||u())}));var u=function(t){return function(){var e=t._readableState;n("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&s(t,"data")&&(e.flowing=!0,N(t))}}(r);t.on("drain",u);var f=!1;function l(e){n("ondata");var i=t.write(e);n("dest.write",i),!1===i&&((1===o.pipesCount&&o.pipes===t||o.pipesCount>1&&-1!==z(o.pipes,t))&&!f&&(n("false write response, pause",o.awaitDrain),o.awaitDrain++),r.pause())}function d(e){n("onerror",e),m(),t.removeListener("error",d),0===s(t,"error")&&E(t,e)}function c(){t.removeListener("finish",p),m()}function p(){n("onfinish"),t.removeListener("close",c),m()}function m(){n("unpipe"),r.unpipe(t)}return r.on("data",l),function(t,e,i){if("function"==typeof t.prependListener)return t.prependListener("error",i);t._events&&t._events.error?Array.isArray(t._events.error)?t._events.error.unshift(i):t._events.error=[i,t._events.error]:t.on("error",i)}(t,0,d),t.once("close",c),t.once("finish",p),t.emit("pipe",r),o.flowing||(n("pipe resume"),r.resume()),t},A.prototype.unpipe=function(t){var e=this._readableState,i={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,i)),this;if(!t){var r=e.pipes,n=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var s=0;s0,!1!==s.flowing&&this.resume()):"readable"===t&&(s.endEmitted||s.readableListening||(s.readableListening=s.needReadable=!0,s.flowing=!1,s.emittedReadable=!1,n("on readable",s.length,s.reading),s.length?B(this):s.reading||e.nextTick(j,this))),r},A.prototype.addListener=A.prototype.on,A.prototype.removeListener=function(t,i){var r=Ei.prototype.removeListener.call(this,t,i);return"readable"===t&&e.nextTick(L,this),r},A.prototype.removeAllListeners=function(t){var i=Ei.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||e.nextTick(L,this),i},A.prototype.resume=function(){var t=this._readableState;return t.flowing||(n("resume"),t.flowing=!t.readableListening,function(t,i){i.resumeScheduled||(i.resumeScheduled=!0,e.nextTick(C,t,i))}(this,t)),t.paused=!1,this},A.prototype.pause=function(){return n("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(n("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},A.prototype.wrap=function(t){var e=this,i=this._readableState,r=!1;for(var s in t.on("end",(function(){if(n("wrapped end"),i.decoder&&!i.ended){var t=i.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(s){n("wrapped data"),i.decoder&&(s=i.decoder.write(s)),i.objectMode&&null==s||(i.objectMode||s&&s.length)&&(e.push(s)||(r=!0,t.pause()))})),t)void 0===this[s]&&"function"==typeof t[s]&&(this[s]=function(e){return function(){return t[e].apply(t,arguments)}}(s));for(var o=0;o-1))throw new y(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(E.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(E.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),E.prototype._write=function(t,e,i){i(new c("_write()"))},E.prototype._writev=null,E.prototype.end=function(t,i,r){var n=this._writableState;return"function"==typeof t?(r=t,t=null,i=null):"function"==typeof i&&(r=i,i=null),null!=t&&this.write(t,i),n.corked&&(n.corked=1,this.uncork()),n.ending||function(t,i,r){i.ending=!0,P(t,i),r&&(i.finished?e.nextTick(r):t.once("finish",r)),i.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(E.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(E.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),E.prototype.destroy=Ii.destroy,E.prototype._undestroy=Ii.undestroy,E.prototype._destroy=function(t,e){e(t)}}).call(this)}).call(this,D,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})})),c=t((function(t,e){(function(e,i){(function(){"use strict";var r;t.exports=A,A.ReadableState=R,et.EventEmitter;var n,s=function(t,e){return t.listeners(e).length},o=M({}).Buffer,a=i.Uint8Array||function(){},h=w({});n=h&&h.debuglog?h.debuglog("stream"):function(){};var u,f,l,d=xt.getHighWaterMark,c=St.codes,g=c.ERR_INVALID_ARG_TYPE,y=c.ERR_STREAM_PUSH_AFTER_EOF,_=c.ERR_METHOD_NOT_IMPLEMENTED,S=c.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;Q(A,pt);var E=_t.errorOrDestroy,k=["error","close","destroy","pause","resume"];function R(t,e,i){r=r||b({}),t=t||{},"boolean"!=typeof i&&(i=e instanceof r),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=d(this,t,"readableHighWaterMark",i),this.buffer=new Mt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(u||(u=v({}).StringDecoder),this.decoder=new u(t.encoding),this.encoding=t.encoding)}function A(t){if(r=r||b({}),!(this instanceof A))return new A(t);var e=this instanceof r;this._readableState=new R(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),pt.call(this)}function x(t,e,i,r,s){n("readableAddChunk",e);var h,u=t._readableState;if(null===e)u.reading=!1,function(t,e){if(n("onEofChunk"),!e.ended){if(e.decoder){var i=e.decoder.end();i&&i.length&&(e.buffer.push(i),e.length+=e.objectMode?1:i.length)}e.ended=!0,e.sync?B(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,I(t)))}}(t,u);else if(s||(h=function(t,e){var i,r;return r=e,o.isBuffer(r)||r instanceof a||"string"==typeof e||void 0===e||t.objectMode||(i=new g("chunk",["string","Buffer","Uint8Array"],e)),i}(u,e)),h)E(t,h);else if(u.objectMode||e&&e.length>0)if("string"==typeof e||u.objectMode||Object.getPrototypeOf(e)===o.prototype||(e=function(t){return o.from(t)}(e)),r)u.endEmitted?E(t,new S):T(t,u,e,!0);else if(u.ended)E(t,new y);else{if(u.destroyed)return!1;u.reading=!1,u.decoder&&!i?(e=u.decoder.write(e),u.objectMode||0!==e.length?T(t,u,e,!1):q(t,u)):T(t,u,e,!1)}else r||(u.reading=!1,q(t,u));return!u.ended&&(u.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=1073741824?t=1073741824:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function B(t){var i=t._readableState;n("emitReadable",i.needReadable,i.emittedReadable),i.needReadable=!1,i.emittedReadable||(n("emitReadable",i.flowing),i.emittedReadable=!0,e.nextTick(I,t))}function I(t){var e=t._readableState;n("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,N(t)}function q(t,i){i.readingMore||(i.readingMore=!0,e.nextTick(O,t,i))}function O(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function j(t){n("readable nexttick read 0"),t.read(0)}function C(t,e){n("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),N(t),e.flowing&&!e.reading&&t.read(0)}function N(t){var e=t._readableState;for(n("flow",e.flowing);e.flowing&&null!==t.read(););}function D(t,e){return 0===e.length?null:(e.objectMode?i=e.buffer.shift():!t||t>=e.length?(i=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):i=e.buffer.consume(t,e.decoder),i);var i}function U(t){var i=t._readableState;n("endReadable",i.endEmitted),i.endEmitted||(i.ended=!0,e.nextTick($,i,t))}function $(t,e){if(n("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var i=e._writableState;(!i||i.autoDestroy&&i.finished)&&e.destroy()}}function z(t,e){for(var i=0,r=t.length;i=e.highWaterMark:e.length>0)||e.ended))return n("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?U(this):B(this),null;if(0===(t=P(t,e))&&e.ended)return 0===e.length&&U(this),null;var r,s=e.needReadable;return n("need readable",s),(0===e.length||e.length-t0?D(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),i!==t&&e.ended&&U(this)),null!==r&&this.emit("data",r),r},A.prototype._read=function(t){E(this,new _("_read()"))},A.prototype.pipe=function(t,i){var r=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=t;break;case 1:o.pipes=[o.pipes,t];break;default:o.pipes.push(t)}o.pipesCount+=1,n("pipe count=%d opts=%j",o.pipesCount,i);var a=i&&!1===i.end||t===e.stdout||t===e.stderr?m:h;function h(){n("onend"),t.end()}o.endEmitted?e.nextTick(a):r.once("end",a),t.on("unpipe",(function e(i,s){n("onunpipe"),i===r&&s&&!1===s.hasUnpiped&&(s.hasUnpiped=!0,n("cleanup"),t.removeListener("close",c),t.removeListener("finish",p),t.removeListener("drain",u),t.removeListener("error",d),t.removeListener("unpipe",e),r.removeListener("end",h),r.removeListener("end",m),r.removeListener("data",l),f=!0,!o.awaitDrain||t._writableState&&!t._writableState.needDrain||u())}));var u=function(t){return function(){var e=t._readableState;n("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&s(t,"data")&&(e.flowing=!0,N(t))}}(r);t.on("drain",u);var f=!1;function l(e){n("ondata");var i=t.write(e);n("dest.write",i),!1===i&&((1===o.pipesCount&&o.pipes===t||o.pipesCount>1&&-1!==z(o.pipes,t))&&!f&&(n("false write response, pause",o.awaitDrain),o.awaitDrain++),r.pause())}function d(e){n("onerror",e),m(),t.removeListener("error",d),0===s(t,"error")&&E(t,e)}function c(){t.removeListener("finish",p),m()}function p(){n("onfinish"),t.removeListener("close",c),m()}function m(){n("unpipe"),r.unpipe(t)}return r.on("data",l),function(t,e,i){if("function"==typeof t.prependListener)return t.prependListener("error",i);t._events&&t._events.error?Array.isArray(t._events.error)?t._events.error.unshift(i):t._events.error=[i,t._events.error]:t.on("error",i)}(t,0,d),t.once("close",c),t.once("finish",p),t.emit("pipe",r),o.flowing||(n("pipe resume"),r.resume()),t},A.prototype.unpipe=function(t){var e=this._readableState,i={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,i)),this;if(!t){var r=e.pipes,n=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var s=0;s0,!1!==s.flowing&&this.resume()):"readable"===t&&(s.endEmitted||s.readableListening||(s.readableListening=s.needReadable=!0,s.flowing=!1,s.emittedReadable=!1,n("on readable",s.length,s.reading),s.length?B(this):s.reading||e.nextTick(j,this))),r},A.prototype.addListener=A.prototype.on,A.prototype.removeListener=function(t,i){var r=pt.prototype.removeListener.call(this,t,i);return"readable"===t&&e.nextTick(L,this),r},A.prototype.removeAllListeners=function(t){var i=pt.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||e.nextTick(L,this),i},A.prototype.resume=function(){var t=this._readableState;return t.flowing||(n("resume"),t.flowing=!t.readableListening,function(t,i){i.resumeScheduled||(i.resumeScheduled=!0,e.nextTick(C,t,i))}(this,t)),t.paused=!1,this},A.prototype.pause=function(){return n("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(n("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},A.prototype.wrap=function(t){var e=this,i=this._readableState,r=!1;for(var s in t.on("end",(function(){if(n("wrapped end"),i.decoder&&!i.ended){var t=i.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(s){n("wrapped data"),i.decoder&&(s=i.decoder.write(s)),i.objectMode&&null==s||(i.objectMode||s&&s.length)&&(e.push(s)||(r=!0,t.pause()))})),t)void 0===this[s]&&"function"==typeof t[s]&&(this[s]=function(e){return function(){return t[e].apply(t,arguments)}}(s));for(var o=0;o>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function o(t){var e=this.lastTotal-this.lastNeed,i=function(t,e,i){if(128!=(192&e[0]))return t.lastNeed=0,"\ufffd";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"\ufffd";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"\ufffd"}}(this,t);return void 0!==i?i:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function a(t,e){if((t.length-e)%2==0){var i=t.toString("utf16le",e);if(i){var r=i.charCodeAt(i.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],i.slice(0,-1)}return i}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function h(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var i=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,i)}return e}function u(t,e){var i=(t.length-e)%3;return 0===i?t.toString("base64",e):(this.lastNeed=3-i,this.lastTotal=3,1===i?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-i))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function l(t){return t.toString(this.encoding)}function d(t){return t&&t.length?this.write(t):""}e.StringDecoder=n,n.prototype.write=function(t){if(0===t.length)return"";var e,i;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";i=this.lastNeed,this.lastNeed=0}else i=0;return i=0?(n>0&&(t.lastNeed=n-1),n):--r=0?(n>0&&(t.lastNeed=n-2),n):--r=0?(n>0&&(2===n?n=0:t.lastNeed=n-3),n):0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=i;var r=t.length-(i-this.lastNeed);return t.copy(this.lastChar,0,r),t.toString("utf8",e,r)},n.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}})),b=t((function(t,e){(function(e){(function(){"use strict";var i=Object.keys||function(t){var e=[];for(var i in t)e.push(i);return e};t.exports=h;var r=c({}),n=y({});Q(h,r);for(var s=i(n.prototype),o=0;o-1))throw new y(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(E.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(E.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),E.prototype._write=function(t,e,i){i(new d("_write()"))},E.prototype._writev=null,E.prototype.end=function(t,i,r){var n=this._writableState;return"function"==typeof t?(r=t,t=null,i=null):"function"==typeof i&&(r=i,i=null),null!=t&&this.write(t,i),n.corked&&(n.corked=1,this.uncork()),n.ending||function(t,i,r){i.ending=!0,P(t,i),r&&(i.finished?e.nextTick(r):t.once("finish",r)),i.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(E.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(E.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),E.prototype.destroy=_t.destroy,E.prototype._undestroy=_t.undestroy,E.prototype._destroy=function(t,e){e(t)}}).call(this)}).call(this,D,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})})),w=t((function(t,e){})),M=t((function(t,e){(function(t){(function(){"use strict";e.Buffer=i,e.SlowBuffer=function(t){return+t!=t&&(t=0),i.alloc(+t)},e.INSPECT_MAX_BYTES=50;function t(t){if(t>2147483647)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=i.prototype,e}function i(t,e,i){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return s(t)}return r(t,e,i)}function r(e,r,n){if("string"==typeof e)return function(e,r){if("string"==typeof r&&""!==r||(r="utf8"),!i.isEncoding(r))throw new TypeError("Unknown encoding: "+r);var n=0|h(e,r),s=t(n),o=s.write(e,r);return o!==n&&(s=s.slice(0,o)),s}(e,r);if(ArrayBuffer.isView(e))return o(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(j(e,ArrayBuffer)||e&&j(e.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=2147483647)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+2147483647..toString(16)+" bytes");return 0|t}function h(t,e){if(i.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||j(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var s=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return O(t).length;default:if(s)return n?-1:q(t).length;e=(""+e).toLowerCase(),s=!0}}function u(t,e,i){var r=t[e];t[e]=t[i],t[i]=r}function f(t,e,r,n,s){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),C(r=+r)&&(r=s?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(s)return-1;r=t.length-1}else if(r<0){if(!s)return-1;r=0}if("string"==typeof e&&(e=i.from(e,n)),i.isBuffer(e))return 0===e.length?-1:l(t,e,r,n,s);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):l(t,[e],r,n,s);throw new TypeError("val must be string, number or Buffer")}function l(t,e,i,r,n){var s,o=1,a=t.length,h=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;o=2,a/=2,h/=2,i/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(n){var f=-1;for(s=i;sa&&(i=a-h),s=i;s>=0;s--){for(var l=!0,d=0;dn&&(r=n):r=n;var s=e.length;r>s/2&&(r=s/2);for(var o=0;o>8,n=i%256,s.push(n),s.push(r);return s}(e,t.length-i),t,i,r)}function b(t,e,i){return 0===e&&i===t.length?_.fromByteArray(t):_.fromByteArray(t.slice(e,i))}function y(t,e,i){i=Math.min(t.length,i);for(var r=[],n=e;n239?4:u>223?3:u>191?2:1;if(n+l<=i)switch(l){case 1:u<128&&(f=u);break;case 2:128==(192&(s=t[n+1]))&&(h=(31&u)<<6|63&s)>127&&(f=h);break;case 3:s=t[n+1],o=t[n+2],128==(192&s)&&128==(192&o)&&(h=(15&u)<<12|(63&s)<<6|63&o)>2047&&(h<55296||h>57343)&&(f=h);break;case 4:s=t[n+1],o=t[n+2],a=t[n+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(h=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&h<1114112&&(f=h)}null===f?(f=65533,l=1):f>65535&&(f-=65536,r.push(f>>>10&1023|55296),f=56320|1023&f),r.push(f),n+=l}return function(t){var e=t.length;if(e<=w)return String.fromCharCode.apply(String,t);for(var i="",r=0;rthis.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return E(this,e,i);case"utf8":case"utf-8":return y(this,e,i);case"ascii":return M(this,e,i);case"latin1":case"binary":return S(this,e,i);case"base64":return b(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,i);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}.apply(this,arguments)},i.prototype.toLocaleString=i.prototype.toString,i.prototype.equals=function(t){if(!i.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===i.compare(this,t)},i.prototype.inspect=function(){var t="",i=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,i).replace(/(.{2})/g,"$1 ").trim(),this.length>i&&(t+=" ... "),""},i.prototype.compare=function(t,e,r,n,s){if(j(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),!i.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===s&&(s=this.length),e<0||r>t.length||n<0||s>this.length)throw new RangeError("out of range index");if(n>=s&&e>=r)return 0;if(n>=s)return-1;if(e>=r)return 1;if(this===t)return 0;for(var o=(s>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),h=Math.min(o,a),u=this.slice(n,s),f=t.slice(e,r),l=0;l>>=0,isFinite(i)?(i>>>=0,void 0===r&&(r="utf8")):(r=i,i=void 0)}var n=this.length-e;if((void 0===i||i>n)&&(i=n),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var s=!1;;)switch(r){case"hex":return d(this,t,e,i);case"utf8":case"utf-8":return c(this,t,e,i);case"ascii":return p(this,t,e,i);case"latin1":case"binary":return m(this,t,e,i);case"base64":return g(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v(this,t,e,i);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var w=4096;function M(t,e,i){var r="";i=Math.min(t.length,i);for(var n=e;nn)&&(i=n);for(var s="",o=e;oi)throw new RangeError("Trying to access beyond buffer length")}function A(t,e,r,n,s,o){if(!i.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>s||et.length)throw new RangeError("Index out of range")}function x(t,e,i,r,n,s){if(i+r>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function T(t,e,i,r,n){return e=+e,i>>>=0,n||x(t,0,i,4),B.write(t,e,i,r,23,4),i+4}function P(t,e,i,r,n){return e=+e,i>>>=0,n||x(t,0,i,8),B.write(t,e,i,r,52,8),i+8}i.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,i||R(t,e,this.length);for(var r=this[t],n=1,s=0;++s>>=0,e>>>=0,i||R(t,e,this.length);for(var r=this[t+--e],n=1;e>0&&(n*=256);)r+=this[t+--e]*n;return r},i.prototype.readUInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),this[t]},i.prototype.readUInt16LE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]|this[t+1]<<8},i.prototype.readUInt16BE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]<<8|this[t+1]},i.prototype.readUInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},i.prototype.readUInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},i.prototype.readIntLE=function(t,e,i){t>>>=0,e>>>=0,i||R(t,e,this.length);for(var r=this[t],n=1,s=0;++s=(n*=128)&&(r-=Math.pow(2,8*e)),r},i.prototype.readIntBE=function(t,e,i){t>>>=0,e>>>=0,i||R(t,e,this.length);for(var r=e,n=1,s=this[t+--r];r>0&&(n*=256);)s+=this[t+--r]*n;return s>=(n*=128)&&(s-=Math.pow(2,8*e)),s},i.prototype.readInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},i.prototype.readInt16LE=function(t,e){t>>>=0,e||R(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},i.prototype.readInt16BE=function(t,e){t>>>=0,e||R(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},i.prototype.readInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},i.prototype.readInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},i.prototype.readFloatLE=function(t,e){return t>>>=0,e||R(t,4,this.length),B.read(this,t,!0,23,4)},i.prototype.readFloatBE=function(t,e){return t>>>=0,e||R(t,4,this.length),B.read(this,t,!1,23,4)},i.prototype.readDoubleLE=function(t,e){return t>>>=0,e||R(t,8,this.length),B.read(this,t,!0,52,8)},i.prototype.readDoubleBE=function(t,e){return t>>>=0,e||R(t,8,this.length),B.read(this,t,!1,52,8)},i.prototype.writeUIntLE=function(t,e,i,r){t=+t,e>>>=0,i>>>=0,r||A(this,t,e,i,Math.pow(2,8*i)-1,0);var n=1,s=0;for(this[e]=255&t;++s>>=0,i>>>=0,r||A(this,t,e,i,Math.pow(2,8*i)-1,0);var n=i-1,s=1;for(this[e+n]=255&t;--n>=0&&(s*=256);)this[e+n]=t/s&255;return e+i},i.prototype.writeUInt8=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,1,255,0),this[e]=255&t,e+1},i.prototype.writeUInt16LE=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeUInt16BE=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeUInt32LE=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},i.prototype.writeUInt32BE=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},i.prototype.writeIntLE=function(t,e,i,r){if(t=+t,e>>>=0,!r){var n=Math.pow(2,8*i-1);A(this,t,e,i,n-1,-n)}var s=0,o=1,a=0;for(this[e]=255&t;++s>0)-a&255;return e+i},i.prototype.writeIntBE=function(t,e,i,r){if(t=+t,e>>>=0,!r){var n=Math.pow(2,8*i-1);A(this,t,e,i,n-1,-n)}var s=i-1,o=1,a=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+i},i.prototype.writeInt8=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},i.prototype.writeInt16LE=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeInt16BE=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeInt32LE=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},i.prototype.writeInt32BE=function(t,e,i){return t=+t,e>>>=0,i||A(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},i.prototype.writeFloatLE=function(t,e,i){return T(this,t,e,!0,i)},i.prototype.writeFloatBE=function(t,e,i){return T(this,t,e,!1,i)},i.prototype.writeDoubleLE=function(t,e,i){return P(this,t,e,!0,i)},i.prototype.writeDoubleBE=function(t,e,i){return P(this,t,e,!1,i)},i.prototype.copy=function(t,e,r,n){if(!i.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return s},i.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!i.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var s=t.charCodeAt(0);("utf8"===n&&s<128||"latin1"===n)&&(t=s)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&i<57344){if(!n){if(i>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===r){(e-=3)>-1&&s.push(239,191,189);continue}n=i;continue}if(i<56320){(e-=3)>-1&&s.push(239,191,189),n=i;continue}i=65536+(n-55296<<10|i-56320)}else n&&(e-=3)>-1&&s.push(239,191,189);if(n=null,i<128){if((e-=1)<0)break;s.push(i)}else if(i<2048){if((e-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function O(t){return _.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function L(t,e,i,r){for(var n=0;n=e.length||n>=t.length);++n)e[n+i]=t[n];return n}function j(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function C(t){return t!=t}}).call(this)}).call(this,M({}).Buffer)})),_={toByteArray:function(t){var e,i,r=T(t),n=r[0],s=r[1],o=new k(function(t,e,i){return 3*(e+i)/4-i}(0,n,s)),a=0,h=s>0?n-4:n;for(i=0;i>16&255,o[a++]=e>>8&255,o[a++]=255&e;return 2===s&&(e=E[t.charCodeAt(i)]<<2|E[t.charCodeAt(i+1)]>>4,o[a++]=255&e),1===s&&(e=E[t.charCodeAt(i)]<<10|E[t.charCodeAt(i+1)]<<4|E[t.charCodeAt(i+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e),o},fromByteArray:function(t){for(var e,i=t.length,r=i%3,n=[],s=0,o=i-r;so?o:s+16383));return 1===r?(e=t[i-1],n.push(S[e>>2]+S[e<<4&63]+"==")):2===r&&(e=(t[i-2]<<8)+t[i-1],n.push(S[e>>10]+S[e>>4&63]+S[e<<2&63]+"=")),n.join("")}},S=[],E=[],k="undefined"!=typeof Uint8Array?Uint8Array:Array,R="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",A=0,x=R.length;A0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");return-1===i&&(i=e),[i,i===e?0:4-i%4]}function P(t,e,i){for(var r,n,s=[],o=e;o>18&63]+S[n>>12&63]+S[n>>6&63]+S[63&n]);return s.join("")}E["-".charCodeAt(0)]=62,E["_".charCodeAt(0)]=63;var B={read:function(t,e,i,r,n){var s,o,a=8*n-r-1,h=(1<>1,f=-7,l=i?n-1:0,d=i?-1:1,c=t[e+l];for(l+=d,s=c&(1<<-f)-1,c>>=-f,f+=a;f>0;s=256*s+t[e+l],l+=d,f-=8);for(o=s&(1<<-f)-1,s>>=-f,f+=r;f>0;o=256*o+t[e+l],l+=d,f-=8);if(0===s)s=1-u;else{if(s===h)return o?NaN:1/0*(c?-1:1);o+=Math.pow(2,r),s-=u}return(c?-1:1)*o*Math.pow(2,s-r)},write:function(t,e,i,r,n,s){var o,a,h,u=8*s-n-1,f=(1<>1,d=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,c=r?0:s-1,p=r?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=f):(o=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-o))<1&&(o--,h*=2),(e+=o+l>=1?d/h:d*Math.pow(2,1-l))*h>=2&&(o++,h/=2),o+l>=f?(a=0,o=f):o+l>=1?(a=(e*h-1)*Math.pow(2,n),o+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,n),o=0));n>=8;t[i+c]=255&a,c+=p,a/=256,n-=8);for(o=o<0;t[i+c]=255&o,c+=p,o/=256,u-=8);t[i+c-p]|=128*m}},I={},q=M({}),O=q.Buffer;function L(t,e){for(var i in t)e[i]=t[i]}function j(t,e,i){return O(t,e,i)}O.from&&O.alloc&&O.allocUnsafe&&O.allocUnsafeSlow?I=q:(L(q,I),I.Buffer=j),j.prototype=Object.create(O.prototype),L(O,j),j.from=function(t,e,i){if("number"==typeof t)throw new TypeError("Argument must not be a number");return O(t,e,i)},j.alloc=function(t,e,i){if("number"!=typeof t)throw new TypeError("Argument must be a number");var r=O(t);return void 0!==e?"string"==typeof i?r.fill(e,i):r.fill(e):r.fill(0),r},j.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return O(t)},j.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return q.SlowBuffer(t)};var C,N,D={},U=D={};function $(){throw new Error("setTimeout has not been defined")}function z(){throw new Error("clearTimeout has not been defined")}function W(t){if(C===setTimeout)return setTimeout(t,0);if((C===$||!C)&&setTimeout)return C=setTimeout,setTimeout(t,0);try{return C(t,0)}catch(e){try{return C.call(null,t,0)}catch(e){return C.call(this,t,0)}}}!function(){try{C="function"==typeof setTimeout?setTimeout:$}catch(t){C=$}try{N="function"==typeof clearTimeout?clearTimeout:z}catch(t){N=z}}();var F,K=[],H=!1,Z=-1;function V(){H&&F&&(H=!1,F.length?K=F.concat(K):Z=-1,K.length&&G())}function G(){if(!H){var t=W(V);H=!0;for(var e=K.length;e;){for(F=K,K=[];++Z1)for(var i=1;i4294967295)throw new RangeError("requested too many random bytes");var s=i.allocUnsafe(e);if(e>0)if(e>65536)for(var o=0;o0&&o.length>n&&!o.warned){o.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=t,h.type=e,h.count=o.length,a=h,console&&console.warn&&console.warn(a)}return t}function ft(t,e,i){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},n=function(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}.bind(r);return n.listener=i,r.wrapFn=n,n}function lt(t,e,i){var r=t._events;if(void 0===r)return[];var n=r[e];return void 0===n?[]:"function"==typeof n?i?[n.listener||n]:[n]:i?function(t){for(var e=new Array(t.length),i=0;i0&&(s=e[0]),s instanceof Error)throw s;var o=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw o.context=s,o}var a=n[t];if(void 0===a)return!1;if("function"==typeof a)rt(a,this,e);else{var h=a.length,u=ct(a,h);for(i=0;i=0;s--)if(i[s]===e||i[s].listener===e){o=i[s].listener,n=s;break}if(n<0)return this;0===n?i.shift():function(t,e){for(;e+1=0;r--)this.removeListener(t,e[r]);return this},st.prototype.listeners=function(t){return lt(this,t,!0)},st.prototype.rawListeners=function(t){return lt(this,t,!1)},st.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):dt.call(t,e)},st.prototype.listenerCount=dt,st.prototype.eventNames=function(){return this._eventsCount>0?tt(this._events):[]};var pt=et.EventEmitter;function mt(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,r)}return i}function gt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function vt(t,e){for(var i=0;i0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,i=""+e.data;e=e.next;)i+=t+e.data;return i}},{key:"concat",value:function(t){if(0===this.length)return bt.alloc(0);for(var e,i,r,n=bt.allocUnsafe(t>>>0),s=this.head,o=0;s;)e=s.data,i=n,r=o,bt.prototype.copy.call(e,i,r),o+=s.data.length,s=s.next;return n}},{key:"consume",value:function(t,e){var i;return tn.length?n.length:t;if(s===n.length?r+=n:r+=n.slice(0,t),0==(t-=s)){s===n.length?(++i,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=n.slice(s));break}++i}return this.length-=i,r}},{key:"_getBuffer",value:function(t){var e=bt.allocUnsafe(t),i=this.head,r=1;for(i.data.copy(e),t-=i.data.length;i=i.next;){var n=i.data,s=t>n.length?n.length:t;if(n.copy(e,e.length-t,0,s),0==(t-=s)){s===n.length?(++r,i.next?this.head=i.next:this.head=this.tail=null):(this.head=i,i.data=n.slice(s));break}++r}return this.length-=r,e}},{key:wt,value:function(t,e){return yt(this,function(t){for(var e=1;e2?"one of ".concat(e," ").concat(t.slice(0,i-1).join(", "),", or ")+t[i-1]:2===i?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}kt("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),kt("ERR_INVALID_ARG_TYPE",(function(t,e,i){var r,n,s,o;if("string"==typeof e&&("not ","not "===e.substr(0,"not ".length))?(r="must not be",e=e.replace(/^not /,"")):r="must be",s=t,(void 0===o||o>s.length)&&(o=s.length)," argument"===s.substring(o-" argument".length,o))n="The ".concat(t," ").concat(r," ").concat(Rt(e,"type"));else{var a=function(t,e,i){return"number"!=typeof i&&(i=0),!(i+".".length>t.length)&&-1!==t.indexOf(".",i)}(t)?"property":"argument";n='The "'.concat(t,'" ').concat(a," ").concat(r," ").concat(Rt(e,"type"))}return n+". Received type ".concat(typeof i)}),TypeError),kt("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),kt("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),kt("ERR_STREAM_PREMATURE_CLOSE","Premature close"),kt("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),kt("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),kt("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),kt("ERR_STREAM_WRITE_AFTER_END","write after end"),kt("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),kt("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),kt("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),St.codes=Et;var At=St.codes.ERR_INVALID_OPT_VALUE,xt={getHighWaterMark:function(t,e,i,r){var n=function(t,e,i){return null!=t.highWaterMark?t.highWaterMark:e?t[i]:null}(e,r,i);if(null!=n){if(!isFinite(n)||Math.floor(n)!==n||n<0)throw new At(r?i:"highWaterMark",n);return Math.floor(n)}return t.objectMode?16:16384}},Tt={};(function(t){(function(){function e(e){try{if(!t.localStorage)return!1}catch(r){return!1}var i=t.localStorage[e];return null!=i&&"true"===String(i).toLowerCase()}Tt=function(t,i){if(e("noDeprecation"))return t;var r=!1;return function(){if(!r){if(e("throwDeprecation"))throw new Error(i);e("traceDeprecation")?console.trace(i):console.warn(i),r=!0}return t.apply(this,arguments)}}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});var Pt=Nt,Bt=St.codes,It=Bt.ERR_METHOD_NOT_IMPLEMENTED,qt=Bt.ERR_MULTIPLE_CALLBACK,Ot=Bt.ERR_TRANSFORM_ALREADY_TRANSFORMING,Lt=Bt.ERR_TRANSFORM_WITH_LENGTH_0,jt=b({});function Ct(t,e){var i=this._transformState;i.transforming=!1;var r=i.writecb;if(null===r)return this.emit("error",new qt);i.writechunk=null,i.writecb=null,null!=e&&this.push(e),r(t);var n=this._readableState;n.reading=!1,(n.needReadable||n.length0,(function(t){r||(r=t),t&&s.forEach(Vt),o||(s.forEach(Vt),n(r))}))}));return e.reduce(Gt)};var Xt={},Jt=I.Buffer,Qt=Yt.Transform;function te(t){Qt.call(this),this._block=Jt.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}Q(te,Qt),te.prototype._transform=function(t,e,i){var r=null;try{this.update(t,e)}catch(n){r=n}i(r)},te.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(i){e=i}t(e)},te.prototype.update=function(t,e){if(function(t,e){if(!Jt.isBuffer(t)&&"string"!=typeof t)throw new TypeError("Data must be a string or a buffer")}(t),this._finalized)throw new Error("Digest already called");Jt.isBuffer(t)||(t=Jt.from(t,e));for(var i=this._block,r=0;this._blockOffset+t.length-r>=this._blockSize;){for(var n=this._blockOffset;n0;++s)this._length[s]+=o,(o=this._length[s]/4294967296|0)>0&&(this._length[s]-=4294967296*o);return this},te.prototype._update=function(){throw new Error("_update is not implemented")},te.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var i=0;i<4;++i)this._length[i]=0;return e},te.prototype._digest=function(){throw new Error("_digest is not implemented")},Xt=te;var ee={},ie=I.Buffer,re=new Array(16);function ne(){Xt.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function se(t,e){return t<>>32-e}function oe(t,e,i,r,n,s,o){return se(t+(e&i|~e&r)+n+s|0,o)+e|0}function ae(t,e,i,r,n,s,o){return se(t+(e&r|i&~r)+n+s|0,o)+e|0}function he(t,e,i,r,n,s,o){return se(t+(e^i^r)+n+s|0,o)+e|0}function ue(t,e,i,r,n,s,o){return se(t+(i^(e|~r))+n+s|0,o)+e|0}Q(ne,Xt),ne.prototype._update=function(){for(var t=re,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);var i=this._a,r=this._b,n=this._c,s=this._d;i=oe(i,r,n,s,t[0],3614090360,7),s=oe(s,i,r,n,t[1],3905402710,12),n=oe(n,s,i,r,t[2],606105819,17),r=oe(r,n,s,i,t[3],3250441966,22),i=oe(i,r,n,s,t[4],4118548399,7),s=oe(s,i,r,n,t[5],1200080426,12),n=oe(n,s,i,r,t[6],2821735955,17),r=oe(r,n,s,i,t[7],4249261313,22),i=oe(i,r,n,s,t[8],1770035416,7),s=oe(s,i,r,n,t[9],2336552879,12),n=oe(n,s,i,r,t[10],4294925233,17),r=oe(r,n,s,i,t[11],2304563134,22),i=oe(i,r,n,s,t[12],1804603682,7),s=oe(s,i,r,n,t[13],4254626195,12),n=oe(n,s,i,r,t[14],2792965006,17),i=ae(i,r=oe(r,n,s,i,t[15],1236535329,22),n,s,t[1],4129170786,5),s=ae(s,i,r,n,t[6],3225465664,9),n=ae(n,s,i,r,t[11],643717713,14),r=ae(r,n,s,i,t[0],3921069994,20),i=ae(i,r,n,s,t[5],3593408605,5),s=ae(s,i,r,n,t[10],38016083,9),n=ae(n,s,i,r,t[15],3634488961,14),r=ae(r,n,s,i,t[4],3889429448,20),i=ae(i,r,n,s,t[9],568446438,5),s=ae(s,i,r,n,t[14],3275163606,9),n=ae(n,s,i,r,t[3],4107603335,14),r=ae(r,n,s,i,t[8],1163531501,20),i=ae(i,r,n,s,t[13],2850285829,5),s=ae(s,i,r,n,t[2],4243563512,9),n=ae(n,s,i,r,t[7],1735328473,14),i=he(i,r=ae(r,n,s,i,t[12],2368359562,20),n,s,t[5],4294588738,4),s=he(s,i,r,n,t[8],2272392833,11),n=he(n,s,i,r,t[11],1839030562,16),r=he(r,n,s,i,t[14],4259657740,23),i=he(i,r,n,s,t[1],2763975236,4),s=he(s,i,r,n,t[4],1272893353,11),n=he(n,s,i,r,t[7],4139469664,16),r=he(r,n,s,i,t[10],3200236656,23),i=he(i,r,n,s,t[13],681279174,4),s=he(s,i,r,n,t[0],3936430074,11),n=he(n,s,i,r,t[3],3572445317,16),r=he(r,n,s,i,t[6],76029189,23),i=he(i,r,n,s,t[9],3654602809,4),s=he(s,i,r,n,t[12],3873151461,11),n=he(n,s,i,r,t[15],530742520,16),i=ue(i,r=he(r,n,s,i,t[2],3299628645,23),n,s,t[0],4096336452,6),s=ue(s,i,r,n,t[7],1126891415,10),n=ue(n,s,i,r,t[14],2878612391,15),r=ue(r,n,s,i,t[5],4237533241,21),i=ue(i,r,n,s,t[12],1700485571,6),s=ue(s,i,r,n,t[3],2399980690,10),n=ue(n,s,i,r,t[10],4293915773,15),r=ue(r,n,s,i,t[1],2240044497,21),i=ue(i,r,n,s,t[8],1873313359,6),s=ue(s,i,r,n,t[15],4264355552,10),n=ue(n,s,i,r,t[6],2734768916,15),r=ue(r,n,s,i,t[13],1309151649,21),i=ue(i,r,n,s,t[4],4149444226,6),s=ue(s,i,r,n,t[11],3174756917,10),n=ue(n,s,i,r,t[2],718787259,15),r=ue(r,n,s,i,t[9],3951481745,21),this._a=this._a+i|0,this._b=this._b+r|0,this._c=this._c+n|0,this._d=this._d+s|0},ne.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 t=ie.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t},ee=ne;var fe={},le=M({}).Buffer,de=new Array(16),ce=[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],pe=[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],me=[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],ge=[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],ve=[0,1518500249,1859775393,2400959708,2840853838],be=[1352829926,1548603684,1836072691,2053994217,0];function ye(){Xt.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function we(t,e){return t<>>32-e}function Me(t,e,i,r,n,s,o,a){return we(t+(e^i^r)+s+o|0,a)+n|0}function _e(t,e,i,r,n,s,o,a){return we(t+(e&i|~e&r)+s+o|0,a)+n|0}function Se(t,e,i,r,n,s,o,a){return we(t+((e|~i)^r)+s+o|0,a)+n|0}function Ee(t,e,i,r,n,s,o,a){return we(t+(e&r|i&~r)+s+o|0,a)+n|0}function ke(t,e,i,r,n,s,o,a){return we(t+(e^(i|~r))+s+o|0,a)+n|0}Q(ye,Xt),ye.prototype._update=function(){for(var t=de,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);for(var i=0|this._a,r=0|this._b,n=0|this._c,s=0|this._d,o=0|this._e,a=0|this._a,h=0|this._b,u=0|this._c,f=0|this._d,l=0|this._e,d=0;d<80;d+=1){var c,p;d<16?(c=Me(i,r,n,s,o,t[ce[d]],ve[0],me[d]),p=ke(a,h,u,f,l,t[pe[d]],be[0],ge[d])):d<32?(c=_e(i,r,n,s,o,t[ce[d]],ve[1],me[d]),p=Ee(a,h,u,f,l,t[pe[d]],be[1],ge[d])):d<48?(c=Se(i,r,n,s,o,t[ce[d]],ve[2],me[d]),p=Se(a,h,u,f,l,t[pe[d]],be[2],ge[d])):d<64?(c=Ee(i,r,n,s,o,t[ce[d]],ve[3],me[d]),p=_e(a,h,u,f,l,t[pe[d]],be[3],ge[d])):(c=ke(i,r,n,s,o,t[ce[d]],ve[4],me[d]),p=Me(a,h,u,f,l,t[pe[d]],be[4],ge[d])),i=o,o=s,s=we(n,10),n=r,r=c,a=l,l=f,f=we(u,10),u=h,h=p}var m=this._b+n+f|0;this._b=this._c+s+l|0,this._c=this._d+o+a|0,this._d=this._e+i+h|0,this._e=this._a+r+u|0,this._a=m},ye.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 t=le.alloc?le.alloc(20):new le(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t},fe=ye;var Re={},Ae=I.Buffer;function xe(t,e){this._block=Ae.alloc(t),this._finalSize=e,this._blockSize=t,this._len=0}xe.prototype.update=function(t,e){"string"==typeof t&&(e=e||"utf8",t=Ae.from(t,e));for(var i=this._block,r=this._blockSize,n=t.length,s=this._len,o=0;o=this._finalSize&&(this._update(this._block),this._block.fill(0));var i=8*this._len;if(i<=4294967295)this._block.writeUInt32BE(i,this._blockSize-4);else{var r=(4294967295&i)>>>0,n=(i-r)/4294967296;this._block.writeUInt32BE(n,this._blockSize-8),this._block.writeUInt32BE(r,this._blockSize-4)}this._update(this._block);var s=this._hash();return t?s.toString(t):s},xe.prototype._update=function(){throw new Error("_update must be implemented by subclass")},Re=xe;var Te,Pe=I.Buffer,Be=[1518500249,1859775393,-1894007588,-899497514],Ie=new Array(80);function qe(){this.init(),this._w=Ie,Re.call(this,64,56)}function Oe(t){return t<<30|t>>>2}function Le(t,e,i,r){return 0===t?e&i|~e&r:2===t?e&i|e&r|i&r:e^i^r}Q(qe,Re),qe.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},qe.prototype._update=function(t){for(var e,i=this._w,r=0|this._a,n=0|this._b,s=0|this._c,o=0|this._d,a=0|this._e,h=0;h<16;++h)i[h]=t.readInt32BE(4*h);for(;h<80;++h)i[h]=i[h-3]^i[h-8]^i[h-14]^i[h-16];for(var u=0;u<80;++u){var f=~~(u/20),l=0|((e=r)<<5|e>>>27)+Le(f,n,s,o)+a+i[u]+Be[f];a=o,o=s,s=Oe(n),n=r,r=l}this._a=r+this._a|0,this._b=n+this._b|0,this._c=s+this._c|0,this._d=o+this._d|0,this._e=a+this._e|0},qe.prototype._hash=function(){var t=Pe.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},Te=qe;var je,Ce=I.Buffer,Ne=[1518500249,1859775393,-1894007588,-899497514],De=new Array(80);function Ue(){this.init(),this._w=De,Re.call(this,64,56)}function $e(t){return t<<5|t>>>27}function ze(t){return t<<30|t>>>2}function We(t,e,i,r){return 0===t?e&i|~e&r:2===t?e&i|e&r|i&r:e^i^r}Q(Ue,Re),Ue.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},Ue.prototype._update=function(t){for(var e,i=this._w,r=0|this._a,n=0|this._b,s=0|this._c,o=0|this._d,a=0|this._e,h=0;h<16;++h)i[h]=t.readInt32BE(4*h);for(;h<80;++h)i[h]=(e=i[h-3]^i[h-8]^i[h-14]^i[h-16])<<1|e>>>31;for(var u=0;u<80;++u){var f=~~(u/20),l=$e(r)+We(f,n,s,o)+a+i[u]+Ne[f]|0;a=o,o=s,s=ze(n),n=r,r=l}this._a=r+this._a|0,this._b=n+this._b|0,this._c=s+this._c|0,this._d=o+this._d|0,this._e=a+this._e|0},Ue.prototype._hash=function(){var t=Ce.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},je=Ue;var Fe,Ke=I.Buffer,He=[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],Ze=new Array(64);function Ve(){this.init(),this._w=Ze,Re.call(this,64,56)}function Ge(t,e,i){return i^t&(e^i)}function Ye(t,e,i){return t&e|i&(t|e)}function Xe(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function Je(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function Qe(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}Q(Ve,Re),Ve.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},Ve.prototype._update=function(t){for(var e,i=this._w,r=0|this._a,n=0|this._b,s=0|this._c,o=0|this._d,a=0|this._e,h=0|this._f,u=0|this._g,f=0|this._h,l=0;l<16;++l)i[l]=t.readInt32BE(4*l);for(;l<64;++l)i[l]=0|(((e=i[l-2])>>>17|e<<15)^(e>>>19|e<<13)^e>>>10)+i[l-7]+Qe(i[l-15])+i[l-16];for(var d=0;d<64;++d){var c=f+Je(a)+Ge(a,h,u)+He[d]+i[d]|0,p=Xe(r)+Ye(r,n,s)|0;f=u,u=h,h=a,a=o+c|0,o=s,s=n,n=r,r=c+p|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=s+this._c|0,this._d=o+this._d|0,this._e=a+this._e|0,this._f=h+this._f|0,this._g=u+this._g|0,this._h=f+this._h|0},Ve.prototype._hash=function(){var t=Ke.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},Fe=Ve;var ti,ei=I.Buffer,ii=new Array(64);function ri(){this.init(),this._w=ii,Re.call(this,64,56)}Q(ri,Fe),ri.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},ri.prototype._hash=function(){var t=ei.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},ti=ri;var ni,si=I.Buffer,oi=[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],ai=new Array(160);function hi(){this.init(),this._w=ai,Re.call(this,128,112)}function ui(t,e,i){return i^t&(e^i)}function fi(t,e,i){return t&e|i&(t|e)}function li(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function di(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function ci(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function pi(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function mi(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function gi(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function vi(t,e){return t>>>0>>0?1:0}Q(hi,Re),hi.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},hi.prototype._update=function(t){for(var e=this._w,i=0|this._ah,r=0|this._bh,n=0|this._ch,s=0|this._dh,o=0|this._eh,a=0|this._fh,h=0|this._gh,u=0|this._hh,f=0|this._al,l=0|this._bl,d=0|this._cl,c=0|this._dl,p=0|this._el,m=0|this._fl,g=0|this._gl,v=0|this._hl,b=0;b<32;b+=2)e[b]=t.readInt32BE(4*b),e[b+1]=t.readInt32BE(4*b+4);for(;b<160;b+=2){var y=e[b-30],w=e[b-30+1],M=ci(y,w),_=pi(w,y),S=mi(y=e[b-4],w=e[b-4+1]),E=gi(w,y),k=e[b-14],R=e[b-14+1],A=e[b-32],x=e[b-32+1],T=_+R|0,P=M+k+vi(T,_)|0;P=(P=P+S+vi(T=T+E|0,E)|0)+A+vi(T=T+x|0,x)|0,e[b]=P,e[b+1]=T}for(var B=0;B<160;B+=2){P=e[B],T=e[B+1];var I=fi(i,r,n),q=fi(f,l,d),O=li(i,f),L=li(f,i),j=di(o,p),C=di(p,o),N=oi[B],D=oi[B+1],U=ui(o,a,h),$=ui(p,m,g),z=v+C|0,W=u+j+vi(z,v)|0;W=(W=(W=W+U+vi(z=z+$|0,$)|0)+N+vi(z=z+D|0,D)|0)+P+vi(z=z+T|0,T)|0;var F=L+q|0,K=O+I+vi(F,L)|0;u=h,v=g,h=a,g=m,a=o,m=p,o=s+W+vi(p=c+z|0,c)|0,s=n,c=d,n=r,d=l,r=i,l=f,i=W+K+vi(f=z+F|0,z)|0}this._al=this._al+f|0,this._bl=this._bl+l|0,this._cl=this._cl+d|0,this._dl=this._dl+c|0,this._el=this._el+p|0,this._fl=this._fl+m|0,this._gl=this._gl+g|0,this._hl=this._hl+v|0,this._ah=this._ah+i+vi(this._al,f)|0,this._bh=this._bh+r+vi(this._bl,l)|0,this._ch=this._ch+n+vi(this._cl,d)|0,this._dh=this._dh+s+vi(this._dl,c)|0,this._eh=this._eh+o+vi(this._el,p)|0,this._fh=this._fh+a+vi(this._fl,m)|0,this._gh=this._gh+h+vi(this._gl,g)|0,this._hh=this._hh+u+vi(this._hl,v)|0},hi.prototype._hash=function(){var t=si.allocUnsafe(64);function e(e,i,r){t.writeInt32BE(e,r),t.writeInt32BE(i,r+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},ni=hi;var bi,yi=I.Buffer,wi=new Array(160);function Mi(){this.init(),this._w=wi,Re.call(this,128,112)}Q(Mi,ni),Mi.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},Mi.prototype._hash=function(){var t=yi.allocUnsafe(48);function e(e,i,r){t.writeInt32BE(e,r),t.writeInt32BE(i,r+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t},bi=Mi;var _i,Si;(Si=_i=function(t){t=t.toLowerCase();var e=Si[t];if(!e)throw new Error(t+" is not supported (we accept pull requests)");return new e}).sha=Te,Si.sha1=je,Si.sha224=ti,Si.sha256=Fe,Si.sha384=bi,Si.sha512=ni;var Ei=et.EventEmitter;function ki(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,r)}return i}function Ri(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function Ai(t,e){for(var i=0;i0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,i=""+e.data;e=e.next;)i+=t+e.data;return i}},{key:"concat",value:function(t){if(0===this.length)return xi.alloc(0);for(var e,i,r,n=xi.allocUnsafe(t>>>0),s=this.head,o=0;s;)e=s.data,i=n,r=o,xi.prototype.copy.call(e,i,r),o+=s.data.length,s=s.next;return n}},{key:"consume",value:function(t,e){var i;return tn.length?n.length:t;if(s===n.length?r+=n:r+=n.slice(0,t),0==(t-=s)){s===n.length?(++i,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=n.slice(s));break}++i}return this.length-=i,r}},{key:"_getBuffer",value:function(t){var e=xi.allocUnsafe(t),i=this.head,r=1;for(i.data.copy(e),t-=i.data.length;i=i.next;){var n=i.data,s=t>n.length?n.length:t;if(n.copy(e,e.length-t,0,s),0==(t-=s)){s===n.length?(++r,i.next?this.head=i.next:this.head=this.tail=null):(this.head=i,i.data=n.slice(s));break}++r}return this.length-=r,e}},{key:Pi,value:function(t,e){return Ti(this,function(t){for(var e=1;e2?"one of ".concat(e," ").concat(t.slice(0,i-1).join(", "),", or ")+t[i-1]:2===i?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}Li("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),Li("ERR_INVALID_ARG_TYPE",(function(t,e,i){var r,n,s,o;if("string"==typeof e&&("not ","not "===e.substr(0,"not ".length))?(r="must not be",e=e.replace(/^not /,"")):r="must be",s=t,(void 0===o||o>s.length)&&(o=s.length)," argument"===s.substring(o-" argument".length,o))n="The ".concat(t," ").concat(r," ").concat(ji(e,"type"));else{var a=function(t,e,i){return"number"!=typeof i&&(i=0),!(i+".".length>t.length)&&-1!==t.indexOf(".",i)}(t)?"property":"argument";n='The "'.concat(t,'" ').concat(a," ").concat(r," ").concat(ji(e,"type"))}return n+". Received type ".concat(typeof i)}),TypeError),Li("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),Li("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),Li("ERR_STREAM_PREMATURE_CLOSE","Premature close"),Li("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),Li("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),Li("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),Li("ERR_STREAM_WRITE_AFTER_END","write after end"),Li("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),Li("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),Li("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),qi.codes=Oi;var Ci=qi.codes.ERR_INVALID_OPT_VALUE,Ni={getHighWaterMark:function(t,e,i,r){var n=function(t,e,i){return null!=t.highWaterMark?t.highWaterMark:e?t[i]:null}(e,r,i);if(null!=n){if(!isFinite(n)||Math.floor(n)!==n||n<0)throw new Ci(r?i:"highWaterMark",n);return Math.floor(n)}return t.objectMode?16:16384}},Di=Zi,Ui=qi.codes,$i=Ui.ERR_METHOD_NOT_IMPLEMENTED,zi=Ui.ERR_MULTIPLE_CALLBACK,Wi=Ui.ERR_TRANSFORM_ALREADY_TRANSFORMING,Fi=Ui.ERR_TRANSFORM_WITH_LENGTH_0,Ki=l({});function Hi(t,e){var i=this._transformState;i.transforming=!1;var r=i.writecb;if(null===r)return this.emit("error",new zi);i.writechunk=null,i.writecb=null,null!=e&&this.push(e),r(t);var n=this._readableState;n.reading=!1,(n.needReadable||n.length0,(function(t){r||(r=t),t&&s.forEach(rr),o||(s.forEach(rr),n(r))}))}));return e.reduce(nr)},ar.Stream=ar,ar.prototype.pipe=function(t,e){var i=this;function r(e){t.writable&&!1===t.write(e)&&i.pause&&i.pause()}function n(){i.readable&&i.resume&&i.resume()}i.on("data",r),t.on("drain",n),t._isStdio||e&&!1===e.end||(i.on("end",o),i.on("close",a));var s=!1;function o(){s||(s=!0,t.end())}function a(){s||(s=!0,"function"==typeof t.destroy&&t.destroy())}function h(t){if(u(),0===or.listenerCount(this,"error"))throw t}function u(){i.removeListener("data",r),t.removeListener("drain",n),i.removeListener("end",o),i.removeListener("close",a),i.removeListener("error",h),t.removeListener("error",h),i.removeListener("end",u),i.removeListener("close",u),t.removeListener("close",u)}return i.on("error",h),t.on("error",h),i.on("end",u),i.on("close",u),t.on("close",u),t.emit("pipe",i),t};var hr={},ur=I.Buffer,fr=sr.Transform,lr=v({}).StringDecoder;function dr(t){fr.call(this),this.hashMode="string"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}Q(dr,fr),dr.prototype.update=function(t,e,i){"string"==typeof t&&(t=ur.from(t,e));var r=this._update(t);return this.hashMode?this:(i&&(r=this._toString(r,i)),r)},dr.prototype.setAutoPadding=function(){},dr.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},dr.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},dr.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},dr.prototype._transform=function(t,e,i){var r;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(n){r=n}finally{i(r)}},dr.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(i){e=i}t(e)},dr.prototype._finalOrDigest=function(t){var e=this.__final()||ur.alloc(0);return t&&(e=this._toString(e,t,!0)),e},dr.prototype._toString=function(t,e,i){if(this._decoder||(this._decoder=new lr(e),this._encoding=e),this._encoding!==e)throw new Error("can't switch encodings");var r=this._decoder.write(t);return i&&(r+=this._decoder.end()),r};var cr;function pr(t){hr.call(this,"digest"),this._hash=t}Q(pr,hr=dr),pr.prototype._update=function(t){this._hash.update(t)},pr.prototype._final=function(){return this._hash.digest()},cr=function(t){return"md5"===(t=t.toLowerCase())?new ee:"rmd160"===t||"ripemd160"===t?new fe:new pr(_i(t))};var mr={},gr=I.Buffer,vr=gr.alloc(128);function br(t,e){hr.call(this,"digest"),"string"==typeof e&&(e=gr.from(e)),this._alg=t,this._key=e,e.length>64?e=t(e):e.length<64&&(e=gr.concat([e,vr],64));for(var i=this._ipad=gr.allocUnsafe(64),r=this._opad=gr.allocUnsafe(64),n=0;n<64;n++)i[n]=54^e[n],r[n]=92^e[n];this._hash=[i]}Q(br,hr),br.prototype._update=function(t){this._hash.push(t)},br.prototype._final=function(){var t=this._alg(gr.concat(this._hash));return this._alg(gr.concat([this._opad,t]))},mr=br;var yr,wr=function(t){return(new ee).update(t).digest()},Mr=I.Buffer,_r=Mr.alloc(128);function Sr(t,e){hr.call(this,"digest"),"string"==typeof e&&(e=Mr.from(e));var i="sha512"===t||"sha384"===t?128:64;this._alg=t,this._key=e,e.length>i?e=("rmd160"===t?new fe:_i(t)).update(e).digest():e.lengthRr||e!=e)throw new TypeError("Bad key length")},xr={};(function(t){(function(){var e;e=t.browser?"utf-8":t.version?parseInt(t.version.split(".")[0].slice(1),10)>=6?"utf-8":"binary":"utf-8",xr=e}).call(this)}).call(this,D);var Tr,Pr=I.Buffer,Br=function(t,e,i){if(Pr.isBuffer(t))return t;if("string"==typeof t)return Pr.from(t,e);if(ArrayBuffer.isView(t))return Pr.from(t.buffer);throw new TypeError(i+" must be a string, a Buffer, a typed array or a DataView")},Ir=I.Buffer,qr=Ir.alloc(128),Or={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function Lr(t,e,i){var r=function(t){return"rmd160"===t||"ripemd160"===t?function(t){return(new fe).update(t).digest()}:"md5"===t?wr:function(e){return _i(t).update(e).digest()}}(t),n="sha512"===t||"sha384"===t?128:64;e.length>n?e=r(e):e.length>>0},writeUInt32BE:function(t,e,i){t[0+i]=e>>>24,t[1+i]=e>>>16&255,t[2+i]=e>>>8&255,t[3+i]=255&e},ip:function(t,e,i,r){for(var n=0,s=0,o=6;o>=0;o-=2){for(var a=0;a<=24;a+=8)n<<=1,n|=e>>>a+o&1;for(a=0;a<=24;a+=8)n<<=1,n|=t>>>a+o&1}for(o=6;o>=0;o-=2){for(a=1;a<=25;a+=8)s<<=1,s|=e>>>a+o&1;for(a=1;a<=25;a+=8)s<<=1,s|=t>>>a+o&1}i[r+0]=n>>>0,i[r+1]=s>>>0},rip:function(t,e,i,r){for(var n=0,s=0,o=0;o<4;o++)for(var a=24;a>=0;a-=8)n<<=1,n|=e>>>a+o&1,n<<=1,n|=t>>>a+o&1;for(o=4;o<8;o++)for(a=24;a>=0;a-=8)s<<=1,s|=e>>>a+o&1,s<<=1,s|=t>>>a+o&1;i[r+0]=n>>>0,i[r+1]=s>>>0},pc1:function(t,e,i,r){for(var n=0,s=0,o=7;o>=5;o--){for(var a=0;a<=24;a+=8)n<<=1,n|=e>>a+o&1;for(a=0;a<=24;a+=8)n<<=1,n|=t>>a+o&1}for(a=0;a<=24;a+=8)n<<=1,n|=e>>a+o&1;for(o=1;o<=3;o++){for(a=0;a<=24;a+=8)s<<=1,s|=e>>a+o&1;for(a=0;a<=24;a+=8)s<<=1,s|=t>>a+o&1}for(a=0;a<=24;a+=8)s<<=1,s|=t>>a+o&1;i[r+0]=n>>>0,i[r+1]=s>>>0},r28shl:function(t,e){return t<>>28-e}},Nr=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];Cr.pc2=function(t,e,i,r){for(var n=0,s=0,o=Nr.length>>>1,a=0;a>>Nr[a]&1;for(a=o;a>>Nr[a]&1;i[r+0]=n>>>0,i[r+1]=s>>>0},Cr.expand=function(t,e,i){var r=0,n=0;r=(1&t)<<5|t>>>27;for(var s=23;s>=15;s-=4)r<<=6,r|=t>>>s&63;for(s=11;s>=3;s-=4)n|=t>>>s&63,n<<=6;n|=(31&t)<<1|t>>>31,e[i+0]=r>>>0,e[i+1]=n>>>0};var Dr=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];Cr.substitute=function(t,e){for(var i=0,r=0;r<4;r++)i<<=4,i|=Dr[64*r+(t>>>18-6*r&63)];for(r=0;r<4;r++)i<<=4,i|=Dr[256+64*r+(e>>>18-6*r&63)];return i>>>0};var Ur=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];Cr.permute=function(t){for(var e=0,i=0;i>>Ur[i]&1;return e>>>0},Cr.padSplit=function(t,e,i){for(var r=t.toString(2);r.length0;r--)e+=this._buffer(t,e),i+=this._flushBuffer(n,i);return e+=this._buffer(t,e),n},Fr.prototype.final=function(t){var e,i;return t&&(e=this.update(t)),i="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),e?e.concat(i):i},Fr.prototype._pad=function(t,e){if(0===e)return!1;for(;e>>1];i=Cr.r28shl(i,s),r=Cr.r28shl(r,s),Cr.pc2(i,r,t.keys,n)}},Zr.prototype._update=function(t,e,i,r){var n=this._desState,s=Cr.readUInt32BE(t,e),o=Cr.readUInt32BE(t,e+4);Cr.ip(s,o,n.tmp,0),s=n.tmp[0],o=n.tmp[1],"encrypt"===this.type?this._encrypt(n,s,o,n.tmp,0):this._decrypt(n,s,o,n.tmp,0),s=n.tmp[0],o=n.tmp[1],Cr.writeUInt32BE(i,s,r),Cr.writeUInt32BE(i,o,r+4)},Zr.prototype._pad=function(t,e){for(var i=t.length-e,r=e;r>>0,s=l}Cr.rip(o,s,r,n)},Zr.prototype._decrypt=function(t,e,i,r,n){for(var s=i,o=e,a=t.keys.length-2;a>=0;a-=2){var h=t.keys[a],u=t.keys[a+1];Cr.expand(s,t.tmp,0),h^=t.tmp[0],u^=t.tmp[1];var f=Cr.substitute(h,u),l=s;s=(o^Cr.permute(f))>>>0,o=l}Cr.rip(s,o,r,n)};var Gr={},Yr={};function Xr(t){this.iv=new Array(8);for(var e=0;e>s%8,t._prev=bn(t._prev,i?r:n);return o}function bn(t,e){var i=t.length,r=-1,n=gn.allocUnsafe(t.length);for(t=gn.concat([t,gn.from([e])]);++r>7;return n}mn.encrypt=function(t,e,i){for(var r=e.length,n=gn.allocUnsafe(r),s=-1;++s>>24]^f[p>>>16&255]^l[m>>>8&255]^d[255&g]^e[v++],o=u[p>>>24]^f[m>>>16&255]^l[g>>>8&255]^d[255&c]^e[v++],a=u[m>>>24]^f[g>>>16&255]^l[c>>>8&255]^d[255&p]^e[v++],h=u[g>>>24]^f[c>>>16&255]^l[p>>>8&255]^d[255&m]^e[v++],c=s,p=o,m=a,g=h;return s=(r[c>>>24]<<24|r[p>>>16&255]<<16|r[m>>>8&255]<<8|r[255&g])^e[v++],o=(r[p>>>24]<<24|r[m>>>16&255]<<16|r[g>>>8&255]<<8|r[255&c])^e[v++],a=(r[m>>>24]<<24|r[g>>>16&255]<<16|r[c>>>8&255]<<8|r[255&p])^e[v++],h=(r[g>>>24]<<24|r[c>>>16&255]<<16|r[p>>>8&255]<<8|r[255&m])^e[v++],[s>>>=0,o>>>=0,a>>>=0,h>>>=0]}var In=[0,1,2,4,8,16,32,64,128,27,54],qn=function(){for(var t=new Array(256),e=0;e<256;e++)t[e]=e<128?e<<1:e<<1^283;for(var i=[],r=[],n=[[],[],[],[]],s=[[],[],[],[]],o=0,a=0,h=0;h<256;++h){var u=a^a<<1^a<<2^a<<3^a<<4;u=u>>>8^255&u^99,i[o]=u,r[u]=o;var f=t[o],l=t[f],d=t[l],c=257*t[u]^16843008*u;n[0][o]=c<<24|c>>>8,n[1][o]=c<<16|c>>>16,n[2][o]=c<<8|c>>>24,n[3][o]=c,c=16843009*d^65537*l^257*f^16843008*o,s[0][u]=c<<24|c>>>8,s[1][u]=c<<16|c>>>16,s[2][u]=c<<8|c>>>24,s[3][u]=c,0===o?o=a=1:(o=f^t[t[t[d^f]]],a^=t[t[a]])}return{SBOX:i,INV_SBOX:r,SUB_MIX:n,INV_SUB_MIX:s}}();function On(t){this._key=Tn(t),this._reset()}On.blockSize=16,On.keySize=32,On.prototype.blockSize=On.blockSize,On.prototype.keySize=On.keySize,On.prototype._reset=function(){for(var t=this._key,e=t.length,i=e+6,r=4*(i+1),n=[],s=0;s>>24,o=qn.SBOX[o>>>24]<<24|qn.SBOX[o>>>16&255]<<16|qn.SBOX[o>>>8&255]<<8|qn.SBOX[255&o],o^=In[s/e|0]<<24):e>6&&s%e==4&&(o=qn.SBOX[o>>>24]<<24|qn.SBOX[o>>>16&255]<<16|qn.SBOX[o>>>8&255]<<8|qn.SBOX[255&o]),n[s]=n[s-e]^o}for(var a=[],h=0;h>>24]]^qn.INV_SUB_MIX[1][qn.SBOX[f>>>16&255]]^qn.INV_SUB_MIX[2][qn.SBOX[f>>>8&255]]^qn.INV_SUB_MIX[3][qn.SBOX[255&f]]}this._nRounds=i,this._keySchedule=n,this._invKeySchedule=a},On.prototype.encryptBlockRaw=function(t){return Bn(t=Tn(t),this._keySchedule,qn.SUB_MIX,qn.SBOX,this._nRounds)},On.prototype.encryptBlock=function(t){var e=this.encryptBlockRaw(t),i=xn.allocUnsafe(16);return i.writeUInt32BE(e[0],0),i.writeUInt32BE(e[1],4),i.writeUInt32BE(e[2],8),i.writeUInt32BE(e[3],12),i},On.prototype.decryptBlock=function(t){var e=(t=Tn(t))[1];t[1]=t[3],t[3]=e;var i=Bn(t,this._invKeySchedule,qn.INV_SUB_MIX,qn.INV_SBOX,this._nRounds),r=xn.allocUnsafe(16);return r.writeUInt32BE(i[0],0),r.writeUInt32BE(i[3],4),r.writeUInt32BE(i[2],8),r.writeUInt32BE(i[1],12),r},On.prototype.scrub=function(){Pn(this._keySchedule),Pn(this._invKeySchedule),Pn(this._key)},An.AES=On;var Ln={},jn=I.Buffer,Cn=jn.alloc(16,0);function Nn(t){var e=jn.allocUnsafe(16);return e.writeUInt32BE(t[0]>>>0,0),e.writeUInt32BE(t[1]>>>0,4),e.writeUInt32BE(t[2]>>>0,8),e.writeUInt32BE(t[3]>>>0,12),e}function Dn(t){this.h=t,this.state=jn.alloc(16,0),this.cache=jn.allocUnsafe(0)}Dn.prototype.ghash=function(t){for(var e=-1;++e0;e--)r[e]=r[e]>>>1|(1&r[e-1])<<31;r[0]=r[0]>>>1,i&&(r[0]=r[0]^225<<24)}this.state=Nn(n)},Dn.prototype.update=function(t){var e;for(this.cache=jn.concat([this.cache,t]);this.cache.length>=16;)e=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(e)},Dn.prototype.final=function(t,e){return this.cache.length&&this.ghash(jn.concat([this.cache,Cn],16)),this.ghash(Nn([0,t,0,e])),this.state},Ln=Dn;var Un=I.Buffer;function $n(t,e,i,r){hr.call(this);var n=Un.alloc(4,0);this._cipher=new An.AES(e);var s=this._cipher.encryptBlock(n);this._ghash=new Ln(s),i=function(t,e,i){if(12===e.length)return t._finID=Un.concat([e,Un.from([0,0,0,1])]),Un.concat([e,Un.from([0,0,0,2])]);var r=new Ln(i),n=e.length,s=n%16;r.update(e),s&&(s=16-s,r.update(Un.alloc(s,0))),r.update(Un.alloc(8,0));var o=8*n,a=Un.alloc(8);a.writeUIntBE(o,0,8),r.update(a),t._finID=r.state;var h=Un.from(t._finID);return wn(h),h}(this,i,s),this._prev=Un.from(i),this._cache=Un.allocUnsafe(0),this._secCache=Un.allocUnsafe(0),this._decrypt=r,this._alen=0,this._len=0,this._mode=t,this._authTag=null,this._called=!1}Q($n,hr),$n.prototype._update=function(t){if(!this._called&&this._alen){var e=16-this._alen%16;e<16&&(e=Un.alloc(e,0),this._ghash.update(e))}this._called=!0;var i=this._mode.encrypt(this,t);return this._decrypt?this._ghash.update(t):this._ghash.update(i),this._len+=t.length,i},$n.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var t=an(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(t,e){var i=0;t.length!==e.length&&i++;for(var r=Math.min(t.length,e.length),n=0;n0||r>0;){var h=new ee;h.update(a),h.update(t),e&&h.update(e),a=h.digest();var u=0;if(n>0){var f=s.length-n;u=Math.min(n,a.length),a.copy(s,f,0,u),n-=u}if(u0){var l=o.length-r,d=Math.min(r,a.length-u);a.copy(o,l,u,u+d),r-=d}}return a.fill(0),{key:s,iv:o}},Hn={},Zn=I.Buffer;function Vn(t,e,i){hr.call(this),this._cache=new Yn,this._cipher=new An.AES(e),this._prev=Zn.from(i),this._mode=t,this._autopadding=!0}Q(Vn,hr),Vn.prototype._update=function(t){var e,i;this._cache.add(t);for(var r=[];e=this._cache.get();)i=this._mode.encrypt(this,e),r.push(i);return Zn.concat(r)};var Gn=Zn.alloc(16,16);function Yn(){this.cache=Zn.allocUnsafe(0)}Vn.prototype._final=function(){var t=this._cache.flush();if(this._autopadding)return t=this._mode.encrypt(this,t),this._cipher.scrub(),t;if(!t.equals(Gn))throw this._cipher.scrub(),new Error("data not multiple of block length")},Vn.prototype.setAutoPadding=function(t){return this._autopadding=!!t,this},Yn.prototype.add=function(t){this.cache=Zn.concat([this.cache,t])},Yn.prototype.get=function(){if(this.cache.length>15){var t=this.cache.slice(0,16);return this.cache=this.cache.slice(16),t}return null},Yn.prototype.flush=function(){for(var t=16-this.cache.length,e=Zn.allocUnsafe(t),i=-1;++i16)throw new Error("unable to decrypt data");for(var i=-1;++i16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e}else if(this.cache.length>=16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e;return null},ts.prototype.flush=function(){if(this.cache.length)return this.cache};var es={};es.createCipheriv=Hn.createCipheriv,es.createDecipheriv=Xn.createDecipheriv;var is={"des-ecb":{key:8,iv:0}};is["des-cbc"]=is.des={key:8,iv:8},is["des-ede3-cbc"]=is.des3={key:24,iv:8},is["des-ede3"]={key:24,iv:0},is["des-ede-cbc"]={key:16,iv:8},is["des-ede"]={key:16,iv:0};var rs={exports:{}};!function(t,e){"use strict";function i(t,e){t.super_=e;var i=function(){};i.prototype=e.prototype,t.prototype=new i,t.prototype.constructor=t}function r(t,e,i){if(r.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(i=e,e=10),this._init(t||0,e||10,i||"be"))}var n;"object"==typeof t?t.exports=r:e.BN=r,r.BN=r,r.wordSize=26;try{n=w({}).Buffer}catch(S){}function s(t,e,i){for(var r=0,n=Math.min(t.length,i),s=e;s=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return r}function o(t,e,i,r){for(var n=0,s=Math.min(t.length,i),o=e;o=49?a-49+10:a>=17?a-17+10:a}return n}r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,e){return t.cmp(e)>0?t:e},r.min=function(t,e){return t.cmp(e)<0?t:e},r.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===e?this._parseHex(t,r):this._parseBase(t,e,r),"-"===t[0]&&(this.negative=1),this.strip(),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initArray=function(t,e,i){if(t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r=0;r-=3)s=t[r]|t[r-1]<<8|t[r-2]<<16,this.words[n]|=s<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===i)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this.strip()},r.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=6)n=s(t,i,i+6),this.words[r]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,r++);i+6!==e&&(n=s(t,e,i+6),this.words[r]|=n<>>26-o&4194303),this.strip()},r.prototype._parseBase=function(t,e,i){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=e)r++;r--,n=n/e|0;for(var s=t.length-i,a=s%r,h=Math.min(s,s-a)+i,u=0,f=i;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},r.prototype.inspect=function(){return(this.red?""};var a=["","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"],h=[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],u=[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 f(t,e,i){i.negative=e.negative^t.negative;var r=t.length+e.length|0;i.length=r,r=r-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;i.words[0]=a;for(var u=1;u>>26,l=67108863&h,d=Math.min(u,e.length-1),c=Math.max(0,u-t.length+1);c<=d;c++){var p=u-c|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[c])+l)/67108864|0,l=67108863&o}i.words[u]=0|l,h=0|f}return 0!==h?i.words[u]=0|h:i.length--,i.strip()}r.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var r=0,n=0,s=0;s>>24-r&16777215)||s!==this.length-1?a[6-f.length]+f+i:f+i,(r+=2)>=26&&(r-=26,s--)}for(0!==n&&(i=n.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var l=h[t],d=u[t];i="";var c=this.clone();for(c.negative=0;!c.isZero();){var p=c.modn(d).toString(t);i=(c=c.idivn(d)).isZero()?p+i:a[l-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length,0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16)},r.prototype.toBuffer=function(t,e){return this.toArrayLike(n,t,e)},r.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},r.prototype.toArrayLike=function(t,e,i){var r=this.byteLength(),n=i||Math.max(1,r);this.strip();var s,o,a="le"===e,h=new t(n),u=this.clone();if(a){for(o=0;!u.isZero();o++)s=u.andln(255),u.iushrn(8),h[o]=s;for(;o=4096&&(i+=13,e>>>=13),e>=64&&(i+=7,e>>>=7),e>=8&&(i+=4,e>>>=4),e>=2&&(i+=2,e>>>=2),i+e},r.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,i=0;return 0==(8191&e)&&(i+=13,e>>>=13),0==(127&e)&&(i+=7,e>>>=7),0==(15&e)&&(i+=4,e>>>=4),0==(3&e)&&(i+=2,e>>>=2),0==(1&e)&&i++,i},r.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var i=0;it.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var e,i;this.length>t.length?(e=this,i=t):(e=t,i=this);for(var r=0;rt.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-i),this.strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,e){var i=t/26|0,r=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(i=this,r=t):(i=t,r=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i,r,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(i=this,r=t):(i=t,r=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,c=0|o[1],p=8191&c,m=c>>>13,g=0|o[2],v=8191&g,b=g>>>13,y=0|o[3],w=8191&y,M=y>>>13,_=0|o[4],S=8191&_,E=_>>>13,k=0|o[5],R=8191&k,A=k>>>13,x=0|o[6],T=8191&x,P=x>>>13,B=0|o[7],I=8191&B,q=B>>>13,O=0|o[8],L=8191&O,j=O>>>13,C=0|o[9],N=8191&C,D=C>>>13,U=0|a[0],$=8191&U,z=U>>>13,W=0|a[1],F=8191&W,K=W>>>13,H=0|a[2],Z=8191&H,V=H>>>13,G=0|a[3],Y=8191&G,X=G>>>13,J=0|a[4],Q=8191&J,tt=J>>>13,et=0|a[5],it=8191&et,rt=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,ft=0|a[8],lt=8191&ft,dt=ft>>>13,ct=0|a[9],pt=8191&ct,mt=ct>>>13;i.negative=t.negative^e.negative,i.length=19;var gt=(u+(r=Math.imul(l,$))|0)+((8191&(n=(n=Math.imul(l,z))+Math.imul(d,$)|0))<<13)|0;u=((s=Math.imul(d,z))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(p,$),n=(n=Math.imul(p,z))+Math.imul(m,$)|0,s=Math.imul(m,z);var vt=(u+(r=r+Math.imul(l,F)|0)|0)+((8191&(n=(n=n+Math.imul(l,K)|0)+Math.imul(d,F)|0))<<13)|0;u=((s=s+Math.imul(d,K)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(v,$),n=(n=Math.imul(v,z))+Math.imul(b,$)|0,s=Math.imul(b,z),r=r+Math.imul(p,F)|0,n=(n=n+Math.imul(p,K)|0)+Math.imul(m,F)|0,s=s+Math.imul(m,K)|0;var bt=(u+(r=r+Math.imul(l,Z)|0)|0)+((8191&(n=(n=n+Math.imul(l,V)|0)+Math.imul(d,Z)|0))<<13)|0;u=((s=s+Math.imul(d,V)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(w,$),n=(n=Math.imul(w,z))+Math.imul(M,$)|0,s=Math.imul(M,z),r=r+Math.imul(v,F)|0,n=(n=n+Math.imul(v,K)|0)+Math.imul(b,F)|0,s=s+Math.imul(b,K)|0,r=r+Math.imul(p,Z)|0,n=(n=n+Math.imul(p,V)|0)+Math.imul(m,Z)|0,s=s+Math.imul(m,V)|0;var yt=(u+(r=r+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,X)|0)+Math.imul(d,Y)|0))<<13)|0;u=((s=s+Math.imul(d,X)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(S,$),n=(n=Math.imul(S,z))+Math.imul(E,$)|0,s=Math.imul(E,z),r=r+Math.imul(w,F)|0,n=(n=n+Math.imul(w,K)|0)+Math.imul(M,F)|0,s=s+Math.imul(M,K)|0,r=r+Math.imul(v,Z)|0,n=(n=n+Math.imul(v,V)|0)+Math.imul(b,Z)|0,s=s+Math.imul(b,V)|0,r=r+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,X)|0;var wt=(u+(r=r+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(d,Q)|0))<<13)|0;u=((s=s+Math.imul(d,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(R,$),n=(n=Math.imul(R,z))+Math.imul(A,$)|0,s=Math.imul(A,z),r=r+Math.imul(S,F)|0,n=(n=n+Math.imul(S,K)|0)+Math.imul(E,F)|0,s=s+Math.imul(E,K)|0,r=r+Math.imul(w,Z)|0,n=(n=n+Math.imul(w,V)|0)+Math.imul(M,Z)|0,s=s+Math.imul(M,V)|0,r=r+Math.imul(v,Y)|0,n=(n=n+Math.imul(v,X)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,X)|0,r=r+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var Mt=(u+(r=r+Math.imul(l,it)|0)|0)+((8191&(n=(n=n+Math.imul(l,rt)|0)+Math.imul(d,it)|0))<<13)|0;u=((s=s+Math.imul(d,rt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(T,$),n=(n=Math.imul(T,z))+Math.imul(P,$)|0,s=Math.imul(P,z),r=r+Math.imul(R,F)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(A,F)|0,s=s+Math.imul(A,K)|0,r=r+Math.imul(S,Z)|0,n=(n=n+Math.imul(S,V)|0)+Math.imul(E,Z)|0,s=s+Math.imul(E,V)|0,r=r+Math.imul(w,Y)|0,n=(n=n+Math.imul(w,X)|0)+Math.imul(M,Y)|0,s=s+Math.imul(M,X)|0,r=r+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,tt)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,tt)|0,r=r+Math.imul(p,it)|0,n=(n=n+Math.imul(p,rt)|0)+Math.imul(m,it)|0,s=s+Math.imul(m,rt)|0;var _t=(u+(r=r+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(d,st)|0))<<13)|0;u=((s=s+Math.imul(d,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(I,$),n=(n=Math.imul(I,z))+Math.imul(q,$)|0,s=Math.imul(q,z),r=r+Math.imul(T,F)|0,n=(n=n+Math.imul(T,K)|0)+Math.imul(P,F)|0,s=s+Math.imul(P,K)|0,r=r+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,V)|0)+Math.imul(A,Z)|0,s=s+Math.imul(A,V)|0,r=r+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,X)|0,r=r+Math.imul(w,Q)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(M,Q)|0,s=s+Math.imul(M,tt)|0,r=r+Math.imul(v,it)|0,n=(n=n+Math.imul(v,rt)|0)+Math.imul(b,it)|0,s=s+Math.imul(b,rt)|0,r=r+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(r=r+Math.imul(l,ht)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((s=s+Math.imul(d,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(L,$),n=(n=Math.imul(L,z))+Math.imul(j,$)|0,s=Math.imul(j,z),r=r+Math.imul(I,F)|0,n=(n=n+Math.imul(I,K)|0)+Math.imul(q,F)|0,s=s+Math.imul(q,K)|0,r=r+Math.imul(T,Z)|0,n=(n=n+Math.imul(T,V)|0)+Math.imul(P,Z)|0,s=s+Math.imul(P,V)|0,r=r+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,X)|0,r=r+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(E,Q)|0,s=s+Math.imul(E,tt)|0,r=r+Math.imul(w,it)|0,n=(n=n+Math.imul(w,rt)|0)+Math.imul(M,it)|0,s=s+Math.imul(M,rt)|0,r=r+Math.imul(v,st)|0,n=(n=n+Math.imul(v,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,r=r+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,ut)|0;var Et=(u+(r=r+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,dt)|0)+Math.imul(d,lt)|0))<<13)|0;u=((s=s+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(N,$),n=(n=Math.imul(N,z))+Math.imul(D,$)|0,s=Math.imul(D,z),r=r+Math.imul(L,F)|0,n=(n=n+Math.imul(L,K)|0)+Math.imul(j,F)|0,s=s+Math.imul(j,K)|0,r=r+Math.imul(I,Z)|0,n=(n=n+Math.imul(I,V)|0)+Math.imul(q,Z)|0,s=s+Math.imul(q,V)|0,r=r+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,X)|0,r=r+Math.imul(R,Q)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(A,Q)|0,s=s+Math.imul(A,tt)|0,r=r+Math.imul(S,it)|0,n=(n=n+Math.imul(S,rt)|0)+Math.imul(E,it)|0,s=s+Math.imul(E,rt)|0,r=r+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(M,st)|0,s=s+Math.imul(M,ot)|0,r=r+Math.imul(v,ht)|0,n=(n=n+Math.imul(v,ut)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ut)|0,r=r+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,dt)|0;var kt=(u+(r=r+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(d,pt)|0))<<13)|0;u=((s=s+Math.imul(d,mt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(N,F),n=(n=Math.imul(N,K))+Math.imul(D,F)|0,s=Math.imul(D,K),r=r+Math.imul(L,Z)|0,n=(n=n+Math.imul(L,V)|0)+Math.imul(j,Z)|0,s=s+Math.imul(j,V)|0,r=r+Math.imul(I,Y)|0,n=(n=n+Math.imul(I,X)|0)+Math.imul(q,Y)|0,s=s+Math.imul(q,X)|0,r=r+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(P,Q)|0,s=s+Math.imul(P,tt)|0,r=r+Math.imul(R,it)|0,n=(n=n+Math.imul(R,rt)|0)+Math.imul(A,it)|0,s=s+Math.imul(A,rt)|0,r=r+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(E,st)|0,s=s+Math.imul(E,ot)|0,r=r+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(M,ht)|0,s=s+Math.imul(M,ut)|0,r=r+Math.imul(v,lt)|0,n=(n=n+Math.imul(v,dt)|0)+Math.imul(b,lt)|0,s=s+Math.imul(b,dt)|0;var Rt=(u+(r=r+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(N,Z),n=(n=Math.imul(N,V))+Math.imul(D,Z)|0,s=Math.imul(D,V),r=r+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(j,Y)|0,s=s+Math.imul(j,X)|0,r=r+Math.imul(I,Q)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(q,Q)|0,s=s+Math.imul(q,tt)|0,r=r+Math.imul(T,it)|0,n=(n=n+Math.imul(T,rt)|0)+Math.imul(P,it)|0,s=s+Math.imul(P,rt)|0,r=r+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(A,st)|0,s=s+Math.imul(A,ot)|0,r=r+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(E,ht)|0,s=s+Math.imul(E,ut)|0,r=r+Math.imul(w,lt)|0,n=(n=n+Math.imul(w,dt)|0)+Math.imul(M,lt)|0,s=s+Math.imul(M,dt)|0;var At=(u+(r=r+Math.imul(v,pt)|0)|0)+((8191&(n=(n=n+Math.imul(v,mt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((s=s+Math.imul(b,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(N,Y),n=(n=Math.imul(N,X))+Math.imul(D,Y)|0,s=Math.imul(D,X),r=r+Math.imul(L,Q)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(j,Q)|0,s=s+Math.imul(j,tt)|0,r=r+Math.imul(I,it)|0,n=(n=n+Math.imul(I,rt)|0)+Math.imul(q,it)|0,s=s+Math.imul(q,rt)|0,r=r+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,ot)|0,r=r+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(A,ht)|0,s=s+Math.imul(A,ut)|0,r=r+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,dt)|0)+Math.imul(E,lt)|0,s=s+Math.imul(E,dt)|0;var xt=(u+(r=r+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((s=s+Math.imul(M,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(N,Q),n=(n=Math.imul(N,tt))+Math.imul(D,Q)|0,s=Math.imul(D,tt),r=r+Math.imul(L,it)|0,n=(n=n+Math.imul(L,rt)|0)+Math.imul(j,it)|0,s=s+Math.imul(j,rt)|0,r=r+Math.imul(I,st)|0,n=(n=n+Math.imul(I,ot)|0)+Math.imul(q,st)|0,s=s+Math.imul(q,ot)|0,r=r+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,ut)|0,r=r+Math.imul(R,lt)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(A,lt)|0,s=s+Math.imul(A,dt)|0;var Tt=(u+(r=r+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(E,pt)|0))<<13)|0;u=((s=s+Math.imul(E,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(N,it),n=(n=Math.imul(N,rt))+Math.imul(D,it)|0,s=Math.imul(D,rt),r=r+Math.imul(L,st)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(j,st)|0,s=s+Math.imul(j,ot)|0,r=r+Math.imul(I,ht)|0,n=(n=n+Math.imul(I,ut)|0)+Math.imul(q,ht)|0,s=s+Math.imul(q,ut)|0,r=r+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,dt)|0)+Math.imul(P,lt)|0,s=s+Math.imul(P,dt)|0;var Pt=(u+(r=r+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((s=s+Math.imul(A,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(N,st),n=(n=Math.imul(N,ot))+Math.imul(D,st)|0,s=Math.imul(D,ot),r=r+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,ut)|0)+Math.imul(j,ht)|0,s=s+Math.imul(j,ut)|0,r=r+Math.imul(I,lt)|0,n=(n=n+Math.imul(I,dt)|0)+Math.imul(q,lt)|0,s=s+Math.imul(q,dt)|0;var Bt=(u+(r=r+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((s=s+Math.imul(P,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(N,ht),n=(n=Math.imul(N,ut))+Math.imul(D,ht)|0,s=Math.imul(D,ut),r=r+Math.imul(L,lt)|0,n=(n=n+Math.imul(L,dt)|0)+Math.imul(j,lt)|0,s=s+Math.imul(j,dt)|0;var It=(u+(r=r+Math.imul(I,pt)|0)|0)+((8191&(n=(n=n+Math.imul(I,mt)|0)+Math.imul(q,pt)|0))<<13)|0;u=((s=s+Math.imul(q,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(N,lt),n=(n=Math.imul(N,dt))+Math.imul(D,lt)|0,s=Math.imul(D,dt);var qt=(u+(r=r+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,mt)|0)+Math.imul(j,pt)|0))<<13)|0;u=((s=s+Math.imul(j,mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863;var Ot=(u+(r=Math.imul(N,pt))|0)+((8191&(n=(n=Math.imul(N,mt))+Math.imul(D,pt)|0))<<13)|0;return u=((s=Math.imul(D,mt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=vt,h[2]=bt,h[3]=yt,h[4]=wt,h[5]=Mt,h[6]=_t,h[7]=St,h[8]=Et,h[9]=kt,h[10]=Rt,h[11]=At,h[12]=xt,h[13]=Tt,h[14]=Pt,h[15]=Bt,h[16]=It,h[17]=qt,h[18]=Ot,0!==u&&(h[19]=u,i.length++),i};function d(t,e,i){return(new c).mulp(t,e,i)}function c(t,e){this.x=t,this.y=e}Math.imul||(l=f),r.prototype.mulTo=function(t,e){var i=this.length+t.length;return 10===this.length&&10===t.length?l(this,t,e):i<63?f(this,t,e):i<1024?function(t,e,i){i.negative=e.negative^t.negative,i.length=t.length+e.length;for(var r=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}i.words[s]=a,r=o,o=n}return 0!==r?i.words[s]=r:i.length--,i.strip()}(this,t,e):d(this,t,e)},c.prototype.makeRBT=function(t){for(var e=new Array(t),i=r.prototype._countBits(t)-1,n=0;n>=1;return r},c.prototype.permute=function(t,e,i,r,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*s+1]=8191&n,n>>>=13;for(s=2*e;s>=26,e+=r/67108864|0,e+=n>>>26,this.words[i]=67108863&n}return 0!==e&&(this.words[i]=e,this.length++),this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),i=0;i>>n}return e}(t);if(0===e.length)return new r(1);for(var i=this,n=0;n>>26-i<<26-i;if(0!==i){var s=0;for(e=0;e>>26-i}s&&(this.words[e]=s,this.length++)}if(0!==r){for(e=this.length-1;e>=0;e--)this.words[e+r]=this.words[e];for(e=0;e>>n<s)for(this.length-=s,h=0;h=0&&(0!==u||h>=r);h--){var f=0|this.words[h];this.words[h]=u<<26-n|f>>>n,u=f&o}return a&&0!==u&&(a.words[a.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},r.prototype.ishrn=function(t,e,i){return this.iushrn(t,e,i)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){var e=t%26,i=(t-e)/26,r=1<>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},r.prototype.isubn=function(t){if(t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(a/67108864|0),this.words[r+i]=67108863&n}for(;r>26,this.words[r+i]=67108863&n;if(0===o)return this.strip();for(o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},r.prototype._wordDiv=function(t,e){var i=(this.length,t.length),n=this.clone(),s=t,o=0|s.words[s.length-1];0!=(i=26-this._countBits(o))&&(s=s.ushln(i),n.iushln(i),o=0|s.words[s.length-1]);var a,h=n.length-s.length;if("mod"!==e){(a=new r(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u=0;l--){var d=67108864*(0|n.words[s.length+l])+(0|n.words[s.length+l-1]);for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(s,d,l);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(s,1,l),n.isZero()||(n.negative^=1);a&&(a.words[l]=d)}return a&&a.strip(),n.strip(),"div"!==e&&0!==i&&n.iushrn(i),{div:a||null,mod:n}},r.prototype.divmod=function(t,e,i){return this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),"mod"!==e&&(n=o.div.neg()),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),e),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new r(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var i=0!==e.div.negative?e.mod.isub(t):e.mod,r=t.ushrn(1),n=t.andln(1),s=i.cmp(r);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},r.prototype.modn=function(t){for(var e=(1<<26)%t,i=0,r=this.length-1;r>=0;r--)i=(e*i+(0|this.words[r]))%t;return i},r.prototype.idivn=function(t){for(var e=0,i=this.length-1;i>=0;i--){var r=(0|this.words[i])+67108864*e;this.words[i]=r/t|0,e=r%t}return this.strip()},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new r(1),s=new r(0),o=new r(0),a=new r(1),h=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++h;for(var u=i.clone(),f=e.clone();!e.isZero();){for(var l=0,d=1;0==(e.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(e.iushrn(l);l-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(u),s.isub(f)),n.iushrn(1),s.iushrn(1);for(var c=0,p=1;0==(i.words[0]&p)&&c<26;++c,p<<=1);if(c>0)for(i.iushrn(c);c-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(u),a.isub(f)),o.iushrn(1),a.iushrn(1);e.cmp(i)>=0?(e.isub(i),n.isub(o),s.isub(a)):(i.isub(e),o.isub(n),a.isub(s))}return{a:o,b:a,gcd:i.iushln(h)}},r.prototype._invmp=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new r(1),o=new r(0),a=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var h=0,u=1;0==(e.words[0]&u)&&h<26;++h,u<<=1);if(h>0)for(e.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(a),s.iushrn(1);for(var f=0,l=1;0==(i.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(i.iushrn(f);f-- >0;)o.isOdd()&&o.iadd(a),o.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o)):(i.isub(e),o.isub(s))}return(n=0===e.cmpn(1)?s:o).cmpn(0)<0&&n.iadd(t),n},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),i=t.clone();e.negative=0,i.negative=0;for(var r=0;e.isEven()&&i.isEven();r++)e.iushrn(1),i.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;i.isEven();)i.iushrn(1);var n=e.cmp(i);if(n<0){var s=e;e=i,i=s}else if(0===n||0===i.cmpn(1))break;e.isub(i)}return i.iushln(r)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){var e=t%26,i=(t-e)/26,r=1<>>26,o&=67108863,this.words[s]=o}return 0!==n&&(this.words[s]=n,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t);var r=0|this.words[0];e=r===t?0:rt.length)return 1;if(this.length=0;i--){var r=0|this.words[i],n=0|t.words[i];if(r!==n){rn&&(e=1);break}}return e},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new M(t)},r.prototype.toRed=function(t){return t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return this._forceRed(t)},r.prototype.redAdd=function(t){return this.red.add(this,t)},r.prototype.redIAdd=function(t){return this.red.iadd(this,t)},r.prototype.redSub=function(t){return this.red.sub(this,t)},r.prototype.redISub=function(t){return this.red.isub(this,t)},r.prototype.redShl=function(t){return this.red.shl(this,t)},r.prototype.redMul=function(t){return this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return this.red._verify1(this),this.red.pow(this,t)};var p={k256:null,p224:null,p192:null,p25519:null};function m(t,e){this.name=t,this.p=new r(e,16),this.n=this.p.bitLength(),this.k=new r(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 v(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function y(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(t){if("string"==typeof t){var e=r._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function _(t){M.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(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 t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},m.prototype.ireduce=function(t){var e,i=t;do{this.split(i,this.tmp),e=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(e>this.n);var r=e0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},m.prototype.split=function(t,e){t.iushrn(this.n,0,e)},m.prototype.imulK=function(t){return t.imul(this.k)},i(g,m),g.prototype.split=function(t,e){for(var i=Math.min(t.length,9),r=0;r>>22,n=s}n>>>=22,t.words[r-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},g.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,i=0;i>>=26,t.words[i]=n,e=r}return 0!==e&&(t.words[t.length++]=e),t},r._prime=function(t){if(p[t])return p[t];var e;if("k256"===t)e=new g;else if("p224"===t)e=new v;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new y}return p[t]=e,e},M.prototype._verify1=function(t){},M.prototype._verify2=function(t,e){},M.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},M.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},M.prototype.add=function(t,e){this._verify2(t,e);var i=t.add(e);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},M.prototype.iadd=function(t,e){this._verify2(t,e);var i=t.iadd(e);return i.cmp(this.m)>=0&&i.isub(this.m),i},M.prototype.sub=function(t,e){this._verify2(t,e);var i=t.sub(e);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},M.prototype.isub=function(t,e){this._verify2(t,e);var i=t.isub(e);return i.cmpn(0)<0&&i.iadd(this.m),i},M.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},M.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},M.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},M.prototype.isqr=function(t){return this.imul(t,t.clone())},M.prototype.sqr=function(t){return this.mul(t,t)},M.prototype.sqrt=function(t){if(t.isZero())return t.clone();if(3===this.m.andln(3)){var e=this.m.add(new r(1)).iushrn(2);return this.pow(t,e)}for(var i=this.m.subn(1),n=0;!i.isZero()&&0===i.andln(1);)n++,i.iushrn(1);var s=new r(1).toRed(this),o=s.redNeg(),a=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new r(2*h*h).toRed(this);0!==this.pow(h,a).cmp(o);)h.redIAdd(o);for(var u=this.pow(h,i),f=this.pow(t,i.addn(1).iushrn(1)),l=this.pow(t,i),d=n;0!==l.cmp(s);){for(var c=l,p=0;0!==c.cmp(s);p++)c=c.redSqr();var m=this.pow(u,new r(1).iushln(d-p-1));f=f.redMul(m),u=m.redSqr(),l=l.redMul(u),d=p}return f},M.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},M.prototype.pow=function(t,e){if(e.isZero())return new r(1).toRed(this);if(0===e.cmpn(1))return t.clone();var i=new Array(16);i[0]=new r(1).toRed(this),i[1]=t;for(var n=2;n=0;n--){for(var u=e.words[n],f=h-1;f>=0;f--){var l=u>>f&1;s!==i[0]&&(s=this.sqr(s)),0!==l||0!==o?(o<<=1,o|=l,(4==++a||0===n&&0===f)&&(s=this.mul(s,i[o]),a=0,o=0)):a=0}h=26}return s},M.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},M.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},r.mont=function(t){return new _(t)},i(_,M),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(e),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new r(0)._forceRed(this);var i=t.mul(e),n=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=i.isub(n).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(rs,this),rs=rs.exports;var ns={exports:{}};!function(t,e){"use strict";function i(t,e){t.super_=e;var i=function(){};i.prototype=e.prototype,t.prototype=new i,t.prototype.constructor=t}function r(t,e,i){if(r.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(i=e,e=10),this._init(t||0,e||10,i||"be"))}var n;"object"==typeof t?t.exports=r:e.BN=r,r.BN=r,r.wordSize=26;try{n=w({}).Buffer}catch(S){}function s(t,e,i){for(var r=0,n=Math.min(t.length,i),s=e;s=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return r}function o(t,e,i,r){for(var n=0,s=Math.min(t.length,i),o=e;o=49?a-49+10:a>=17?a-17+10:a}return n}r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,e){return t.cmp(e)>0?t:e},r.min=function(t,e){return t.cmp(e)<0?t:e},r.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===e?this._parseHex(t,r):this._parseBase(t,e,r),"-"===t[0]&&(this.negative=1),this.strip(),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initArray=function(t,e,i){if(t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r=0;r-=3)s=t[r]|t[r-1]<<8|t[r-2]<<16,this.words[n]|=s<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===i)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this.strip()},r.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=6)n=s(t,i,i+6),this.words[r]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,r++);i+6!==e&&(n=s(t,e,i+6),this.words[r]|=n<>>26-o&4194303),this.strip()},r.prototype._parseBase=function(t,e,i){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=e)r++;r--,n=n/e|0;for(var s=t.length-i,a=s%r,h=Math.min(s,s-a)+i,u=0,f=i;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},r.prototype.inspect=function(){return(this.red?""};var a=["","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"],h=[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],u=[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 f(t,e,i){i.negative=e.negative^t.negative;var r=t.length+e.length|0;i.length=r,r=r-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;i.words[0]=a;for(var u=1;u>>26,l=67108863&h,d=Math.min(u,e.length-1),c=Math.max(0,u-t.length+1);c<=d;c++){var p=u-c|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[c])+l)/67108864|0,l=67108863&o}i.words[u]=0|l,h=0|f}return 0!==h?i.words[u]=0|h:i.length--,i.strip()}r.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var r=0,n=0,s=0;s>>24-r&16777215)||s!==this.length-1?a[6-f.length]+f+i:f+i,(r+=2)>=26&&(r-=26,s--)}for(0!==n&&(i=n.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var l=h[t],d=u[t];i="";var c=this.clone();for(c.negative=0;!c.isZero();){var p=c.modn(d).toString(t);i=(c=c.idivn(d)).isZero()?p+i:a[l-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length,0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16)},r.prototype.toBuffer=function(t,e){return this.toArrayLike(n,t,e)},r.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},r.prototype.toArrayLike=function(t,e,i){var r=this.byteLength(),n=i||Math.max(1,r);this.strip();var s,o,a="le"===e,h=new t(n),u=this.clone();if(a){for(o=0;!u.isZero();o++)s=u.andln(255),u.iushrn(8),h[o]=s;for(;o=4096&&(i+=13,e>>>=13),e>=64&&(i+=7,e>>>=7),e>=8&&(i+=4,e>>>=4),e>=2&&(i+=2,e>>>=2),i+e},r.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,i=0;return 0==(8191&e)&&(i+=13,e>>>=13),0==(127&e)&&(i+=7,e>>>=7),0==(15&e)&&(i+=4,e>>>=4),0==(3&e)&&(i+=2,e>>>=2),0==(1&e)&&i++,i},r.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var i=0;it.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var e,i;this.length>t.length?(e=this,i=t):(e=t,i=this);for(var r=0;rt.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-i),this.strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,e){var i=t/26|0,r=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(i=this,r=t):(i=t,r=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i,r,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(i=this,r=t):(i=t,r=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,c=0|o[1],p=8191&c,m=c>>>13,g=0|o[2],v=8191&g,b=g>>>13,y=0|o[3],w=8191&y,M=y>>>13,_=0|o[4],S=8191&_,E=_>>>13,k=0|o[5],R=8191&k,A=k>>>13,x=0|o[6],T=8191&x,P=x>>>13,B=0|o[7],I=8191&B,q=B>>>13,O=0|o[8],L=8191&O,j=O>>>13,C=0|o[9],N=8191&C,D=C>>>13,U=0|a[0],$=8191&U,z=U>>>13,W=0|a[1],F=8191&W,K=W>>>13,H=0|a[2],Z=8191&H,V=H>>>13,G=0|a[3],Y=8191&G,X=G>>>13,J=0|a[4],Q=8191&J,tt=J>>>13,et=0|a[5],it=8191&et,rt=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,ft=0|a[8],lt=8191&ft,dt=ft>>>13,ct=0|a[9],pt=8191&ct,mt=ct>>>13;i.negative=t.negative^e.negative,i.length=19;var gt=(u+(r=Math.imul(l,$))|0)+((8191&(n=(n=Math.imul(l,z))+Math.imul(d,$)|0))<<13)|0;u=((s=Math.imul(d,z))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(p,$),n=(n=Math.imul(p,z))+Math.imul(m,$)|0,s=Math.imul(m,z);var vt=(u+(r=r+Math.imul(l,F)|0)|0)+((8191&(n=(n=n+Math.imul(l,K)|0)+Math.imul(d,F)|0))<<13)|0;u=((s=s+Math.imul(d,K)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(v,$),n=(n=Math.imul(v,z))+Math.imul(b,$)|0,s=Math.imul(b,z),r=r+Math.imul(p,F)|0,n=(n=n+Math.imul(p,K)|0)+Math.imul(m,F)|0,s=s+Math.imul(m,K)|0;var bt=(u+(r=r+Math.imul(l,Z)|0)|0)+((8191&(n=(n=n+Math.imul(l,V)|0)+Math.imul(d,Z)|0))<<13)|0;u=((s=s+Math.imul(d,V)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(w,$),n=(n=Math.imul(w,z))+Math.imul(M,$)|0,s=Math.imul(M,z),r=r+Math.imul(v,F)|0,n=(n=n+Math.imul(v,K)|0)+Math.imul(b,F)|0,s=s+Math.imul(b,K)|0,r=r+Math.imul(p,Z)|0,n=(n=n+Math.imul(p,V)|0)+Math.imul(m,Z)|0,s=s+Math.imul(m,V)|0;var yt=(u+(r=r+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,X)|0)+Math.imul(d,Y)|0))<<13)|0;u=((s=s+Math.imul(d,X)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(S,$),n=(n=Math.imul(S,z))+Math.imul(E,$)|0,s=Math.imul(E,z),r=r+Math.imul(w,F)|0,n=(n=n+Math.imul(w,K)|0)+Math.imul(M,F)|0,s=s+Math.imul(M,K)|0,r=r+Math.imul(v,Z)|0,n=(n=n+Math.imul(v,V)|0)+Math.imul(b,Z)|0,s=s+Math.imul(b,V)|0,r=r+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,X)|0;var wt=(u+(r=r+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(d,Q)|0))<<13)|0;u=((s=s+Math.imul(d,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(R,$),n=(n=Math.imul(R,z))+Math.imul(A,$)|0,s=Math.imul(A,z),r=r+Math.imul(S,F)|0,n=(n=n+Math.imul(S,K)|0)+Math.imul(E,F)|0,s=s+Math.imul(E,K)|0,r=r+Math.imul(w,Z)|0,n=(n=n+Math.imul(w,V)|0)+Math.imul(M,Z)|0,s=s+Math.imul(M,V)|0,r=r+Math.imul(v,Y)|0,n=(n=n+Math.imul(v,X)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,X)|0,r=r+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var Mt=(u+(r=r+Math.imul(l,it)|0)|0)+((8191&(n=(n=n+Math.imul(l,rt)|0)+Math.imul(d,it)|0))<<13)|0;u=((s=s+Math.imul(d,rt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(T,$),n=(n=Math.imul(T,z))+Math.imul(P,$)|0,s=Math.imul(P,z),r=r+Math.imul(R,F)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(A,F)|0,s=s+Math.imul(A,K)|0,r=r+Math.imul(S,Z)|0,n=(n=n+Math.imul(S,V)|0)+Math.imul(E,Z)|0,s=s+Math.imul(E,V)|0,r=r+Math.imul(w,Y)|0,n=(n=n+Math.imul(w,X)|0)+Math.imul(M,Y)|0,s=s+Math.imul(M,X)|0,r=r+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,tt)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,tt)|0,r=r+Math.imul(p,it)|0,n=(n=n+Math.imul(p,rt)|0)+Math.imul(m,it)|0,s=s+Math.imul(m,rt)|0;var _t=(u+(r=r+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(d,st)|0))<<13)|0;u=((s=s+Math.imul(d,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(I,$),n=(n=Math.imul(I,z))+Math.imul(q,$)|0,s=Math.imul(q,z),r=r+Math.imul(T,F)|0,n=(n=n+Math.imul(T,K)|0)+Math.imul(P,F)|0,s=s+Math.imul(P,K)|0,r=r+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,V)|0)+Math.imul(A,Z)|0,s=s+Math.imul(A,V)|0,r=r+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,X)|0,r=r+Math.imul(w,Q)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(M,Q)|0,s=s+Math.imul(M,tt)|0,r=r+Math.imul(v,it)|0,n=(n=n+Math.imul(v,rt)|0)+Math.imul(b,it)|0,s=s+Math.imul(b,rt)|0,r=r+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(r=r+Math.imul(l,ht)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((s=s+Math.imul(d,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(L,$),n=(n=Math.imul(L,z))+Math.imul(j,$)|0,s=Math.imul(j,z),r=r+Math.imul(I,F)|0,n=(n=n+Math.imul(I,K)|0)+Math.imul(q,F)|0,s=s+Math.imul(q,K)|0,r=r+Math.imul(T,Z)|0,n=(n=n+Math.imul(T,V)|0)+Math.imul(P,Z)|0,s=s+Math.imul(P,V)|0,r=r+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,X)|0,r=r+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(E,Q)|0,s=s+Math.imul(E,tt)|0,r=r+Math.imul(w,it)|0,n=(n=n+Math.imul(w,rt)|0)+Math.imul(M,it)|0,s=s+Math.imul(M,rt)|0,r=r+Math.imul(v,st)|0,n=(n=n+Math.imul(v,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,r=r+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,ut)|0;var Et=(u+(r=r+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,dt)|0)+Math.imul(d,lt)|0))<<13)|0;u=((s=s+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(N,$),n=(n=Math.imul(N,z))+Math.imul(D,$)|0,s=Math.imul(D,z),r=r+Math.imul(L,F)|0,n=(n=n+Math.imul(L,K)|0)+Math.imul(j,F)|0,s=s+Math.imul(j,K)|0,r=r+Math.imul(I,Z)|0,n=(n=n+Math.imul(I,V)|0)+Math.imul(q,Z)|0,s=s+Math.imul(q,V)|0,r=r+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,X)|0,r=r+Math.imul(R,Q)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(A,Q)|0,s=s+Math.imul(A,tt)|0,r=r+Math.imul(S,it)|0,n=(n=n+Math.imul(S,rt)|0)+Math.imul(E,it)|0,s=s+Math.imul(E,rt)|0,r=r+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(M,st)|0,s=s+Math.imul(M,ot)|0,r=r+Math.imul(v,ht)|0,n=(n=n+Math.imul(v,ut)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ut)|0,r=r+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,dt)|0;var kt=(u+(r=r+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(d,pt)|0))<<13)|0;u=((s=s+Math.imul(d,mt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(N,F),n=(n=Math.imul(N,K))+Math.imul(D,F)|0,s=Math.imul(D,K),r=r+Math.imul(L,Z)|0,n=(n=n+Math.imul(L,V)|0)+Math.imul(j,Z)|0,s=s+Math.imul(j,V)|0,r=r+Math.imul(I,Y)|0,n=(n=n+Math.imul(I,X)|0)+Math.imul(q,Y)|0,s=s+Math.imul(q,X)|0,r=r+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(P,Q)|0,s=s+Math.imul(P,tt)|0,r=r+Math.imul(R,it)|0,n=(n=n+Math.imul(R,rt)|0)+Math.imul(A,it)|0,s=s+Math.imul(A,rt)|0,r=r+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(E,st)|0,s=s+Math.imul(E,ot)|0,r=r+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(M,ht)|0,s=s+Math.imul(M,ut)|0,r=r+Math.imul(v,lt)|0,n=(n=n+Math.imul(v,dt)|0)+Math.imul(b,lt)|0,s=s+Math.imul(b,dt)|0;var Rt=(u+(r=r+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(N,Z),n=(n=Math.imul(N,V))+Math.imul(D,Z)|0,s=Math.imul(D,V),r=r+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(j,Y)|0,s=s+Math.imul(j,X)|0,r=r+Math.imul(I,Q)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(q,Q)|0,s=s+Math.imul(q,tt)|0,r=r+Math.imul(T,it)|0,n=(n=n+Math.imul(T,rt)|0)+Math.imul(P,it)|0,s=s+Math.imul(P,rt)|0,r=r+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(A,st)|0,s=s+Math.imul(A,ot)|0,r=r+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(E,ht)|0,s=s+Math.imul(E,ut)|0,r=r+Math.imul(w,lt)|0,n=(n=n+Math.imul(w,dt)|0)+Math.imul(M,lt)|0,s=s+Math.imul(M,dt)|0;var At=(u+(r=r+Math.imul(v,pt)|0)|0)+((8191&(n=(n=n+Math.imul(v,mt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((s=s+Math.imul(b,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(N,Y),n=(n=Math.imul(N,X))+Math.imul(D,Y)|0,s=Math.imul(D,X),r=r+Math.imul(L,Q)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(j,Q)|0,s=s+Math.imul(j,tt)|0,r=r+Math.imul(I,it)|0,n=(n=n+Math.imul(I,rt)|0)+Math.imul(q,it)|0,s=s+Math.imul(q,rt)|0,r=r+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,ot)|0,r=r+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(A,ht)|0,s=s+Math.imul(A,ut)|0,r=r+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,dt)|0)+Math.imul(E,lt)|0,s=s+Math.imul(E,dt)|0;var xt=(u+(r=r+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((s=s+Math.imul(M,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(N,Q),n=(n=Math.imul(N,tt))+Math.imul(D,Q)|0,s=Math.imul(D,tt),r=r+Math.imul(L,it)|0,n=(n=n+Math.imul(L,rt)|0)+Math.imul(j,it)|0,s=s+Math.imul(j,rt)|0,r=r+Math.imul(I,st)|0,n=(n=n+Math.imul(I,ot)|0)+Math.imul(q,st)|0,s=s+Math.imul(q,ot)|0,r=r+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,ut)|0,r=r+Math.imul(R,lt)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(A,lt)|0,s=s+Math.imul(A,dt)|0;var Tt=(u+(r=r+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(E,pt)|0))<<13)|0;u=((s=s+Math.imul(E,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(N,it),n=(n=Math.imul(N,rt))+Math.imul(D,it)|0,s=Math.imul(D,rt),r=r+Math.imul(L,st)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(j,st)|0,s=s+Math.imul(j,ot)|0,r=r+Math.imul(I,ht)|0,n=(n=n+Math.imul(I,ut)|0)+Math.imul(q,ht)|0,s=s+Math.imul(q,ut)|0,r=r+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,dt)|0)+Math.imul(P,lt)|0,s=s+Math.imul(P,dt)|0;var Pt=(u+(r=r+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((s=s+Math.imul(A,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(N,st),n=(n=Math.imul(N,ot))+Math.imul(D,st)|0,s=Math.imul(D,ot),r=r+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,ut)|0)+Math.imul(j,ht)|0,s=s+Math.imul(j,ut)|0,r=r+Math.imul(I,lt)|0,n=(n=n+Math.imul(I,dt)|0)+Math.imul(q,lt)|0,s=s+Math.imul(q,dt)|0;var Bt=(u+(r=r+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((s=s+Math.imul(P,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(N,ht),n=(n=Math.imul(N,ut))+Math.imul(D,ht)|0,s=Math.imul(D,ut),r=r+Math.imul(L,lt)|0,n=(n=n+Math.imul(L,dt)|0)+Math.imul(j,lt)|0,s=s+Math.imul(j,dt)|0;var It=(u+(r=r+Math.imul(I,pt)|0)|0)+((8191&(n=(n=n+Math.imul(I,mt)|0)+Math.imul(q,pt)|0))<<13)|0;u=((s=s+Math.imul(q,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(N,lt),n=(n=Math.imul(N,dt))+Math.imul(D,lt)|0,s=Math.imul(D,dt);var qt=(u+(r=r+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,mt)|0)+Math.imul(j,pt)|0))<<13)|0;u=((s=s+Math.imul(j,mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863;var Ot=(u+(r=Math.imul(N,pt))|0)+((8191&(n=(n=Math.imul(N,mt))+Math.imul(D,pt)|0))<<13)|0;return u=((s=Math.imul(D,mt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=vt,h[2]=bt,h[3]=yt,h[4]=wt,h[5]=Mt,h[6]=_t,h[7]=St,h[8]=Et,h[9]=kt,h[10]=Rt,h[11]=At,h[12]=xt,h[13]=Tt,h[14]=Pt,h[15]=Bt,h[16]=It,h[17]=qt,h[18]=Ot,0!==u&&(h[19]=u,i.length++),i};function d(t,e,i){return(new c).mulp(t,e,i)}function c(t,e){this.x=t,this.y=e}Math.imul||(l=f),r.prototype.mulTo=function(t,e){var i=this.length+t.length;return 10===this.length&&10===t.length?l(this,t,e):i<63?f(this,t,e):i<1024?function(t,e,i){i.negative=e.negative^t.negative,i.length=t.length+e.length;for(var r=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}i.words[s]=a,r=o,o=n}return 0!==r?i.words[s]=r:i.length--,i.strip()}(this,t,e):d(this,t,e)},c.prototype.makeRBT=function(t){for(var e=new Array(t),i=r.prototype._countBits(t)-1,n=0;n>=1;return r},c.prototype.permute=function(t,e,i,r,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*s+1]=8191&n,n>>>=13;for(s=2*e;s>=26,e+=r/67108864|0,e+=n>>>26,this.words[i]=67108863&n}return 0!==e&&(this.words[i]=e,this.length++),this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),i=0;i>>n}return e}(t);if(0===e.length)return new r(1);for(var i=this,n=0;n>>26-i<<26-i;if(0!==i){var s=0;for(e=0;e>>26-i}s&&(this.words[e]=s,this.length++)}if(0!==r){for(e=this.length-1;e>=0;e--)this.words[e+r]=this.words[e];for(e=0;e>>n<s)for(this.length-=s,h=0;h=0&&(0!==u||h>=r);h--){var f=0|this.words[h];this.words[h]=u<<26-n|f>>>n,u=f&o}return a&&0!==u&&(a.words[a.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},r.prototype.ishrn=function(t,e,i){return this.iushrn(t,e,i)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){var e=t%26,i=(t-e)/26,r=1<>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},r.prototype.isubn=function(t){if(t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(a/67108864|0),this.words[r+i]=67108863&n}for(;r>26,this.words[r+i]=67108863&n;if(0===o)return this.strip();for(o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},r.prototype._wordDiv=function(t,e){var i=(this.length,t.length),n=this.clone(),s=t,o=0|s.words[s.length-1];0!=(i=26-this._countBits(o))&&(s=s.ushln(i),n.iushln(i),o=0|s.words[s.length-1]);var a,h=n.length-s.length;if("mod"!==e){(a=new r(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u=0;l--){var d=67108864*(0|n.words[s.length+l])+(0|n.words[s.length+l-1]);for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(s,d,l);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(s,1,l),n.isZero()||(n.negative^=1);a&&(a.words[l]=d)}return a&&a.strip(),n.strip(),"div"!==e&&0!==i&&n.iushrn(i),{div:a||null,mod:n}},r.prototype.divmod=function(t,e,i){return this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),"mod"!==e&&(n=o.div.neg()),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),e),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new r(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var i=0!==e.div.negative?e.mod.isub(t):e.mod,r=t.ushrn(1),n=t.andln(1),s=i.cmp(r);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},r.prototype.modn=function(t){for(var e=(1<<26)%t,i=0,r=this.length-1;r>=0;r--)i=(e*i+(0|this.words[r]))%t;return i},r.prototype.idivn=function(t){for(var e=0,i=this.length-1;i>=0;i--){var r=(0|this.words[i])+67108864*e;this.words[i]=r/t|0,e=r%t}return this.strip()},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new r(1),s=new r(0),o=new r(0),a=new r(1),h=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++h;for(var u=i.clone(),f=e.clone();!e.isZero();){for(var l=0,d=1;0==(e.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(e.iushrn(l);l-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(u),s.isub(f)),n.iushrn(1),s.iushrn(1);for(var c=0,p=1;0==(i.words[0]&p)&&c<26;++c,p<<=1);if(c>0)for(i.iushrn(c);c-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(u),a.isub(f)),o.iushrn(1),a.iushrn(1);e.cmp(i)>=0?(e.isub(i),n.isub(o),s.isub(a)):(i.isub(e),o.isub(n),a.isub(s))}return{a:o,b:a,gcd:i.iushln(h)}},r.prototype._invmp=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new r(1),o=new r(0),a=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var h=0,u=1;0==(e.words[0]&u)&&h<26;++h,u<<=1);if(h>0)for(e.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(a),s.iushrn(1);for(var f=0,l=1;0==(i.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(i.iushrn(f);f-- >0;)o.isOdd()&&o.iadd(a),o.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o)):(i.isub(e),o.isub(s))}return(n=0===e.cmpn(1)?s:o).cmpn(0)<0&&n.iadd(t),n},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),i=t.clone();e.negative=0,i.negative=0;for(var r=0;e.isEven()&&i.isEven();r++)e.iushrn(1),i.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;i.isEven();)i.iushrn(1);var n=e.cmp(i);if(n<0){var s=e;e=i,i=s}else if(0===n||0===i.cmpn(1))break;e.isub(i)}return i.iushln(r)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){var e=t%26,i=(t-e)/26,r=1<>>26,o&=67108863,this.words[s]=o}return 0!==n&&(this.words[s]=n,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t);var r=0|this.words[0];e=r===t?0:rt.length)return 1;if(this.length=0;i--){var r=0|this.words[i],n=0|t.words[i];if(r!==n){rn&&(e=1);break}}return e},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new M(t)},r.prototype.toRed=function(t){return t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return this._forceRed(t)},r.prototype.redAdd=function(t){return this.red.add(this,t)},r.prototype.redIAdd=function(t){return this.red.iadd(this,t)},r.prototype.redSub=function(t){return this.red.sub(this,t)},r.prototype.redISub=function(t){return this.red.isub(this,t)},r.prototype.redShl=function(t){return this.red.shl(this,t)},r.prototype.redMul=function(t){return this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return this.red._verify1(this),this.red.pow(this,t)};var p={k256:null,p224:null,p192:null,p25519:null};function m(t,e){this.name=t,this.p=new r(e,16),this.n=this.p.bitLength(),this.k=new r(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 v(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function y(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(t){if("string"==typeof t){var e=r._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function _(t){M.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(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 t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},m.prototype.ireduce=function(t){var e,i=t;do{this.split(i,this.tmp),e=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(e>this.n);var r=e0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},m.prototype.split=function(t,e){t.iushrn(this.n,0,e)},m.prototype.imulK=function(t){return t.imul(this.k)},i(g,m),g.prototype.split=function(t,e){for(var i=Math.min(t.length,9),r=0;r>>22,n=s}n>>>=22,t.words[r-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},g.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,i=0;i>>=26,t.words[i]=n,e=r}return 0!==e&&(t.words[t.length++]=e),t},r._prime=function(t){if(p[t])return p[t];var e;if("k256"===t)e=new g;else if("p224"===t)e=new v;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new y}return p[t]=e,e},M.prototype._verify1=function(t){},M.prototype._verify2=function(t,e){},M.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},M.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},M.prototype.add=function(t,e){this._verify2(t,e);var i=t.add(e);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},M.prototype.iadd=function(t,e){this._verify2(t,e);var i=t.iadd(e);return i.cmp(this.m)>=0&&i.isub(this.m),i},M.prototype.sub=function(t,e){this._verify2(t,e);var i=t.sub(e);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},M.prototype.isub=function(t,e){this._verify2(t,e);var i=t.isub(e);return i.cmpn(0)<0&&i.iadd(this.m),i},M.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},M.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},M.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},M.prototype.isqr=function(t){return this.imul(t,t.clone())},M.prototype.sqr=function(t){return this.mul(t,t)},M.prototype.sqrt=function(t){if(t.isZero())return t.clone();if(3===this.m.andln(3)){var e=this.m.add(new r(1)).iushrn(2);return this.pow(t,e)}for(var i=this.m.subn(1),n=0;!i.isZero()&&0===i.andln(1);)n++,i.iushrn(1);var s=new r(1).toRed(this),o=s.redNeg(),a=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new r(2*h*h).toRed(this);0!==this.pow(h,a).cmp(o);)h.redIAdd(o);for(var u=this.pow(h,i),f=this.pow(t,i.addn(1).iushrn(1)),l=this.pow(t,i),d=n;0!==l.cmp(s);){for(var c=l,p=0;0!==c.cmp(s);p++)c=c.redSqr();var m=this.pow(u,new r(1).iushln(d-p-1));f=f.redMul(m),u=m.redSqr(),l=l.redMul(u),d=p}return f},M.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},M.prototype.pow=function(t,e){if(e.isZero())return new r(1).toRed(this);if(0===e.cmpn(1))return t.clone();var i=new Array(16);i[0]=new r(1).toRed(this),i[1]=t;for(var n=2;n=0;n--){for(var u=e.words[n],f=h-1;f>=0;f--){var l=u>>f&1;s!==i[0]&&(s=this.sqr(s)),0!==l||0!==o?(o<<=1,o|=l,(4==++a||0===n&&0===f)&&(s=this.mul(s,i[o]),a=0,o=0)):a=0}h=26}return s},M.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},M.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},r.mont=function(t){return new _(t)},i(_,M),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(e),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new r(0)._forceRed(this);var i=t.mul(e),n=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=i.isub(n).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(ns,this),ns=ns.exports;var ss,os;function as(t){this.rand=t}if((ss=function(t){return os||(os=new as(null)),os.generate(t)}).Rand=as,as.prototype.generate=function(t){return this._rand(t)},as.prototype._rand=function(t){if(this.rand.getBytes)return this.rand.getBytes(t);for(var e=new Uint8Array(t),i=0;i=0);return r},fs.prototype._randrange=function(t,e){var i=e.sub(t);return t.add(this._randbelow(i))},fs.prototype.test=function(t,e,i){var r=t.bitLength(),n=ns.mont(t),s=new ns(1).toRed(n);e||(e=Math.max(1,r/48|0));for(var o=t.subn(1),a=0;!o.testn(a);a++);for(var h=t.shrn(a),u=o.toRed(n);e>0;e--){var f=this._randrange(new ns(2),o);i&&i(f);var l=f.toRed(n).redPow(h);if(0!==l.cmp(s)&&0!==l.cmp(u)){for(var d=1;d0;e--){var u=this._randrange(new ns(2),s),f=t.gcd(u);if(0!==f.cmpn(1))return f;var l=u.toRed(r).redPow(a);if(0!==l.cmp(n)&&0!==l.cmp(h)){for(var d=1;dt;)i.ishrn(1);if(i.isEven()&&i.iadd(ps),i.testn(1)||i.iadd(ms),e.cmp(ms)){if(!e.cmp(gs))for(;i.mod(vs).cmp(bs);)i.iadd(ws)}else for(;i.mod(ds).cmp(ys);)i.iadd(ws);if(Ss(r=i.shrn(1))&&Ss(i)&&Es(r)&&Es(i)&&cs.test(r)&&cs.test(i))return i}}(function(t){(function(){var e=new us,i=new rs(24),r=new rs(11),n=new rs(10),s=new rs(3),o=new rs(7);function a(e,i){return i=i||"utf8",t.isBuffer(e)||(e=new t(e,i)),this._pub=new rs(e),this}function h(e,i){return i=i||"utf8",t.isBuffer(e)||(e=new t(e,i)),this._priv=new rs(e),this}f;var u={};function f(t,e,i){this.setGenerator(e),this.__prime=new rs(t),this._prime=rs.mont(this.__prime),this._primeLen=t.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,i?(this.setPublicKey=a,this.setPrivateKey=h):this._primeCode=8}function l(e,i){var r=new t(e.toArray());return i?r.toString(i):r}Object.defineProperty(f.prototype,"verifyError",{enumerable:!0,get:function(){return"number"!=typeof this._primeCode&&(this._primeCode=function(t,a){var h=a.toString("hex"),f=[h,t.toString(16)].join("_");if(f in u)return u[f];var l,d=0;if(t.isEven()||!ls.simpleSieve||!ls.fermatTest(t)||!e.test(t))return d+=1,d+="02"===h||"05"===h?8:4,u[f]=d,d;switch(e.test(t.shrn(1))||(d+=2),h){case"02":t.mod(i).cmp(r)&&(d+=8);break;case"05":(l=t.mod(n)).cmp(s)&&l.cmp(o)&&(d+=8);break;default:d+=4}return u[f]=d,d}(this.__prime,this.__gen)),this._primeCode}}),f.prototype.generateKeys=function(){return this._priv||(this._priv=new rs(J(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()},f.prototype.computeSecret=function(e){var i=(e=(e=new rs(e)).toRed(this._prime)).redPow(this._priv).fromRed(),r=new t(i.toArray()),n=this.getPrime();if(r.length0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,i=""+e.data;e=e.next;)i+=t+e.data;return i}},{key:"concat",value:function(t){if(0===this.length)return Ps.alloc(0);for(var e,i,r,n=Ps.allocUnsafe(t>>>0),s=this.head,o=0;s;)e=s.data,i=n,r=o,Ps.prototype.copy.call(e,i,r),o+=s.data.length,s=s.next;return n}},{key:"consume",value:function(t,e){var i;return tn.length?n.length:t;if(s===n.length?r+=n:r+=n.slice(0,t),0==(t-=s)){s===n.length?(++i,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=n.slice(s));break}++i}return this.length-=i,r}},{key:"_getBuffer",value:function(t){var e=Ps.allocUnsafe(t),i=this.head,r=1;for(i.data.copy(e),t-=i.data.length;i=i.next;){var n=i.data,s=t>n.length?n.length:t;if(n.copy(e,e.length-t,0,s),0==(t-=s)){s===n.length?(++r,i.next?this.head=i.next:this.head=this.tail=null):(this.head=i,i.data=n.slice(s));break}++r}return this.length-=r,e}},{key:Is,value:function(t,e){return Bs(this,function(t){for(var e=1;e2?"one of ".concat(e," ").concat(t.slice(0,i-1).join(", "),", or ")+t[i-1]:2===i?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}Cs("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),Cs("ERR_INVALID_ARG_TYPE",(function(t,e,i){var r,n,s,o;if("string"==typeof e&&("not ","not "===e.substr(0,"not ".length))?(r="must not be",e=e.replace(/^not /,"")):r="must be",s=t,(void 0===o||o>s.length)&&(o=s.length)," argument"===s.substring(o-" argument".length,o))n="The ".concat(t," ").concat(r," ").concat(Ns(e,"type"));else{var a=function(t,e,i){return"number"!=typeof i&&(i=0),!(i+".".length>t.length)&&-1!==t.indexOf(".",i)}(t)?"property":"argument";n='The "'.concat(t,'" ').concat(a," ").concat(r," ").concat(Ns(e,"type"))}return n+". Received type ".concat(typeof i)}),TypeError),Cs("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),Cs("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),Cs("ERR_STREAM_PREMATURE_CLOSE","Premature close"),Cs("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),Cs("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),Cs("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),Cs("ERR_STREAM_WRITE_AFTER_END","write after end"),Cs("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),Cs("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),Cs("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),Ls.codes=js;var Ds=Ls.codes.ERR_INVALID_OPT_VALUE,Us={getHighWaterMark:function(t,e,i,r){var n=function(t,e,i){return null!=t.highWaterMark?t.highWaterMark:e?t[i]:null}(e,r,i);if(null!=n){if(!isFinite(n)||Math.floor(n)!==n||n<0)throw new Ds(r?i:"highWaterMark",n);return Math.floor(n)}return t.objectMode?16:16384}},$s=Gs,zs=Ls.codes,Ws=zs.ERR_METHOD_NOT_IMPLEMENTED,Fs=zs.ERR_MULTIPLE_CALLBACK,Ks=zs.ERR_TRANSFORM_ALREADY_TRANSFORMING,Hs=zs.ERR_TRANSFORM_WITH_LENGTH_0,Zs=s({});function Vs(t,e){var i=this._transformState;i.transforming=!1;var r=i.writecb;if(null===r)return this.emit("error",new Fs);i.writechunk=null,i.writecb=null,null!=e&&this.push(e),r(t);var n=this._readableState;n.reading=!1,(n.needReadable||n.length0,(function(t){r||(r=t),t&&o.forEach(so),a||(o.forEach(so),s(r))}))}));return e.reduce(oo)};var ho={exports:{}};!function(t,e){"use strict";function i(t,e){t.super_=e;var i=function(){};i.prototype=e.prototype,t.prototype=new i,t.prototype.constructor=t}function r(t,e,i){if(r.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(i=e,e=10),this._init(t||0,e||10,i||"be"))}var n;"object"==typeof t?t.exports=r:e.BN=r,r.BN=r,r.wordSize=26;try{n=w({}).Buffer}catch(jf){}function s(t,e,i){for(var r=0,n=Math.min(t.length,i),s=e;s=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:o}return r}function o(t,e,i,r){for(var n=0,s=Math.min(t.length,i),o=e;o=49?a-49+10:a>=17?a-17+10:a}return n}function a(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,e){return t.cmp(e)>0?t:e},r.min=function(t,e){return t.cmp(e)<0?t:e},r.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===e?this._parseHex(t,r):this._parseBase(t,e,r),"-"===t[0]&&(this.negative=1),this._strip(),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initArray=function(t,e,i){if(t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r=0;r-=3)s=t[r]|t[r-1]<<8|t[r-2]<<16,this.words[n]|=s<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===i)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this._strip()},r.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=6)n=s(t,i,i+6),this.words[r]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,r++);i+6!==e&&(n=s(t,e,i+6),this.words[r]|=n<>>26-o&4194303),this._strip()},r.prototype._parseBase=function(t,e,i){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=e)r++;r--,n=n/e|0;for(var s=t.length-i,a=s%r,h=Math.min(s,s-a)+i,u=0,f=i;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{r.prototype[Symbol.for("nodejs.util.inspect.custom")]=h}catch(jf){r.prototype.inspect=h}else r.prototype.inspect=h;function h(){return(this.red?""}var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],l=[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(t,e,i){i.negative=e.negative^t.negative;var r=t.length+e.length|0;i.length=r,r=r-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;i.words[0]=a;for(var u=1;u>>26,l=67108863&h,d=Math.min(u,e.length-1),c=Math.max(0,u-t.length+1);c<=d;c++){var p=u-c|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[c])+l)/67108864|0,l=67108863&o}i.words[u]=0|l,h=0|f}return 0!==h?i.words[u]=0|h:i.length--,i._strip()}r.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var r=0,n=0,s=0;s>>24-r&16777215)||s!==this.length-1?u[6-a.length]+a+i:a+i,(r+=2)>=26&&(r-=26,s--)}for(0!==n&&(i=n.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var h=f[t],d=l[t];i="";var c=this.clone();for(c.negative=0;!c.isZero();){var p=c.modrn(d).toString(t);i=(c=c.idivn(d)).isZero()?p+i:u[h-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length,0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16,2)},n&&(r.prototype.toBuffer=function(t,e){return this.toArrayLike(n,t,e)}),r.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},r.prototype.toArrayLike=function(t,e,i){this._strip();var r=this.byteLength(),n=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,i||Math.max(1,r));return this["_toArrayLike"+("le"===e?"LE":"BE")](n,r),n},r.prototype._toArrayLikeLE=function(t,e){for(var i=0,r=0,n=0,s=0;n>8&255),i>16&255),6===s?(i>24&255),r=0,s=0):(r=o>>>24,s+=2)}if(i=0&&(t[i--]=o>>8&255),i>=0&&(t[i--]=o>>16&255),6===s?(i>=0&&(t[i--]=o>>24&255),r=0,s=0):(r=o>>>24,s+=2)}if(i>=0)for(t[i--]=r;i>=0;)t[i--]=0},Math.clz32?r.prototype._countBits=function(t){return 32-Math.clz32(t)}:r.prototype._countBits=function(t){var e=t,i=0;return e>=4096&&(i+=13,e>>>=13),e>=64&&(i+=7,e>>>=7),e>=8&&(i+=4,e>>>=4),e>=2&&(i+=2,e>>>=2),i+e},r.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,i=0;return 0==(8191&e)&&(i+=13,e>>>=13),0==(127&e)&&(i+=7,e>>>=7),0==(15&e)&&(i+=4,e>>>=4),0==(3&e)&&(i+=2,e>>>=2),0==(1&e)&&i++,i},r.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var i=0;it.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var e,i;this.length>t.length?(e=this,i=t):(e=t,i=this);for(var r=0;rt.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-i),this._strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,e){var i=t/26|0,r=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(i=this,r=t):(i=t,r=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i,r,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(i=this,r=t):(i=t,r=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,c=0|o[1],p=8191&c,m=c>>>13,g=0|o[2],v=8191&g,b=g>>>13,y=0|o[3],w=8191&y,M=y>>>13,_=0|o[4],S=8191&_,E=_>>>13,k=0|o[5],R=8191&k,A=k>>>13,x=0|o[6],T=8191&x,P=x>>>13,B=0|o[7],I=8191&B,q=B>>>13,O=0|o[8],L=8191&O,j=O>>>13,C=0|o[9],N=8191&C,D=C>>>13,U=0|a[0],$=8191&U,z=U>>>13,W=0|a[1],F=8191&W,K=W>>>13,H=0|a[2],Z=8191&H,V=H>>>13,G=0|a[3],Y=8191&G,X=G>>>13,J=0|a[4],Q=8191&J,tt=J>>>13,et=0|a[5],it=8191&et,rt=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,ft=0|a[8],lt=8191&ft,dt=ft>>>13,ct=0|a[9],pt=8191&ct,mt=ct>>>13;i.negative=t.negative^e.negative,i.length=19;var gt=(u+(r=Math.imul(l,$))|0)+((8191&(n=(n=Math.imul(l,z))+Math.imul(d,$)|0))<<13)|0;u=((s=Math.imul(d,z))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(p,$),n=(n=Math.imul(p,z))+Math.imul(m,$)|0,s=Math.imul(m,z);var vt=(u+(r=r+Math.imul(l,F)|0)|0)+((8191&(n=(n=n+Math.imul(l,K)|0)+Math.imul(d,F)|0))<<13)|0;u=((s=s+Math.imul(d,K)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(v,$),n=(n=Math.imul(v,z))+Math.imul(b,$)|0,s=Math.imul(b,z),r=r+Math.imul(p,F)|0,n=(n=n+Math.imul(p,K)|0)+Math.imul(m,F)|0,s=s+Math.imul(m,K)|0;var bt=(u+(r=r+Math.imul(l,Z)|0)|0)+((8191&(n=(n=n+Math.imul(l,V)|0)+Math.imul(d,Z)|0))<<13)|0;u=((s=s+Math.imul(d,V)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(w,$),n=(n=Math.imul(w,z))+Math.imul(M,$)|0,s=Math.imul(M,z),r=r+Math.imul(v,F)|0,n=(n=n+Math.imul(v,K)|0)+Math.imul(b,F)|0,s=s+Math.imul(b,K)|0,r=r+Math.imul(p,Z)|0,n=(n=n+Math.imul(p,V)|0)+Math.imul(m,Z)|0,s=s+Math.imul(m,V)|0;var yt=(u+(r=r+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,X)|0)+Math.imul(d,Y)|0))<<13)|0;u=((s=s+Math.imul(d,X)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(S,$),n=(n=Math.imul(S,z))+Math.imul(E,$)|0,s=Math.imul(E,z),r=r+Math.imul(w,F)|0,n=(n=n+Math.imul(w,K)|0)+Math.imul(M,F)|0,s=s+Math.imul(M,K)|0,r=r+Math.imul(v,Z)|0,n=(n=n+Math.imul(v,V)|0)+Math.imul(b,Z)|0,s=s+Math.imul(b,V)|0,r=r+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,X)|0;var wt=(u+(r=r+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(d,Q)|0))<<13)|0;u=((s=s+Math.imul(d,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(R,$),n=(n=Math.imul(R,z))+Math.imul(A,$)|0,s=Math.imul(A,z),r=r+Math.imul(S,F)|0,n=(n=n+Math.imul(S,K)|0)+Math.imul(E,F)|0,s=s+Math.imul(E,K)|0,r=r+Math.imul(w,Z)|0,n=(n=n+Math.imul(w,V)|0)+Math.imul(M,Z)|0,s=s+Math.imul(M,V)|0,r=r+Math.imul(v,Y)|0,n=(n=n+Math.imul(v,X)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,X)|0,r=r+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var Mt=(u+(r=r+Math.imul(l,it)|0)|0)+((8191&(n=(n=n+Math.imul(l,rt)|0)+Math.imul(d,it)|0))<<13)|0;u=((s=s+Math.imul(d,rt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(T,$),n=(n=Math.imul(T,z))+Math.imul(P,$)|0,s=Math.imul(P,z),r=r+Math.imul(R,F)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(A,F)|0,s=s+Math.imul(A,K)|0,r=r+Math.imul(S,Z)|0,n=(n=n+Math.imul(S,V)|0)+Math.imul(E,Z)|0,s=s+Math.imul(E,V)|0,r=r+Math.imul(w,Y)|0,n=(n=n+Math.imul(w,X)|0)+Math.imul(M,Y)|0,s=s+Math.imul(M,X)|0,r=r+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,tt)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,tt)|0,r=r+Math.imul(p,it)|0,n=(n=n+Math.imul(p,rt)|0)+Math.imul(m,it)|0,s=s+Math.imul(m,rt)|0;var _t=(u+(r=r+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(d,st)|0))<<13)|0;u=((s=s+Math.imul(d,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(I,$),n=(n=Math.imul(I,z))+Math.imul(q,$)|0,s=Math.imul(q,z),r=r+Math.imul(T,F)|0,n=(n=n+Math.imul(T,K)|0)+Math.imul(P,F)|0,s=s+Math.imul(P,K)|0,r=r+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,V)|0)+Math.imul(A,Z)|0,s=s+Math.imul(A,V)|0,r=r+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,X)|0,r=r+Math.imul(w,Q)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(M,Q)|0,s=s+Math.imul(M,tt)|0,r=r+Math.imul(v,it)|0,n=(n=n+Math.imul(v,rt)|0)+Math.imul(b,it)|0,s=s+Math.imul(b,rt)|0,r=r+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(r=r+Math.imul(l,ht)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((s=s+Math.imul(d,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(L,$),n=(n=Math.imul(L,z))+Math.imul(j,$)|0,s=Math.imul(j,z),r=r+Math.imul(I,F)|0,n=(n=n+Math.imul(I,K)|0)+Math.imul(q,F)|0,s=s+Math.imul(q,K)|0,r=r+Math.imul(T,Z)|0,n=(n=n+Math.imul(T,V)|0)+Math.imul(P,Z)|0,s=s+Math.imul(P,V)|0,r=r+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,X)|0,r=r+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(E,Q)|0,s=s+Math.imul(E,tt)|0,r=r+Math.imul(w,it)|0,n=(n=n+Math.imul(w,rt)|0)+Math.imul(M,it)|0,s=s+Math.imul(M,rt)|0,r=r+Math.imul(v,st)|0,n=(n=n+Math.imul(v,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,r=r+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,ut)|0;var Et=(u+(r=r+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,dt)|0)+Math.imul(d,lt)|0))<<13)|0;u=((s=s+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(N,$),n=(n=Math.imul(N,z))+Math.imul(D,$)|0,s=Math.imul(D,z),r=r+Math.imul(L,F)|0,n=(n=n+Math.imul(L,K)|0)+Math.imul(j,F)|0,s=s+Math.imul(j,K)|0,r=r+Math.imul(I,Z)|0,n=(n=n+Math.imul(I,V)|0)+Math.imul(q,Z)|0,s=s+Math.imul(q,V)|0,r=r+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,X)|0,r=r+Math.imul(R,Q)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(A,Q)|0,s=s+Math.imul(A,tt)|0,r=r+Math.imul(S,it)|0,n=(n=n+Math.imul(S,rt)|0)+Math.imul(E,it)|0,s=s+Math.imul(E,rt)|0,r=r+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(M,st)|0,s=s+Math.imul(M,ot)|0,r=r+Math.imul(v,ht)|0,n=(n=n+Math.imul(v,ut)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ut)|0,r=r+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,dt)|0;var kt=(u+(r=r+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(d,pt)|0))<<13)|0;u=((s=s+Math.imul(d,mt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(N,F),n=(n=Math.imul(N,K))+Math.imul(D,F)|0,s=Math.imul(D,K),r=r+Math.imul(L,Z)|0,n=(n=n+Math.imul(L,V)|0)+Math.imul(j,Z)|0,s=s+Math.imul(j,V)|0,r=r+Math.imul(I,Y)|0,n=(n=n+Math.imul(I,X)|0)+Math.imul(q,Y)|0,s=s+Math.imul(q,X)|0,r=r+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(P,Q)|0,s=s+Math.imul(P,tt)|0,r=r+Math.imul(R,it)|0,n=(n=n+Math.imul(R,rt)|0)+Math.imul(A,it)|0,s=s+Math.imul(A,rt)|0,r=r+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(E,st)|0,s=s+Math.imul(E,ot)|0,r=r+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(M,ht)|0,s=s+Math.imul(M,ut)|0,r=r+Math.imul(v,lt)|0,n=(n=n+Math.imul(v,dt)|0)+Math.imul(b,lt)|0,s=s+Math.imul(b,dt)|0;var Rt=(u+(r=r+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(N,Z),n=(n=Math.imul(N,V))+Math.imul(D,Z)|0,s=Math.imul(D,V),r=r+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(j,Y)|0,s=s+Math.imul(j,X)|0,r=r+Math.imul(I,Q)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(q,Q)|0,s=s+Math.imul(q,tt)|0,r=r+Math.imul(T,it)|0,n=(n=n+Math.imul(T,rt)|0)+Math.imul(P,it)|0,s=s+Math.imul(P,rt)|0,r=r+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(A,st)|0,s=s+Math.imul(A,ot)|0,r=r+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(E,ht)|0,s=s+Math.imul(E,ut)|0,r=r+Math.imul(w,lt)|0,n=(n=n+Math.imul(w,dt)|0)+Math.imul(M,lt)|0,s=s+Math.imul(M,dt)|0;var At=(u+(r=r+Math.imul(v,pt)|0)|0)+((8191&(n=(n=n+Math.imul(v,mt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((s=s+Math.imul(b,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(N,Y),n=(n=Math.imul(N,X))+Math.imul(D,Y)|0,s=Math.imul(D,X),r=r+Math.imul(L,Q)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(j,Q)|0,s=s+Math.imul(j,tt)|0,r=r+Math.imul(I,it)|0,n=(n=n+Math.imul(I,rt)|0)+Math.imul(q,it)|0,s=s+Math.imul(q,rt)|0,r=r+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,ot)|0,r=r+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(A,ht)|0,s=s+Math.imul(A,ut)|0,r=r+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,dt)|0)+Math.imul(E,lt)|0,s=s+Math.imul(E,dt)|0;var xt=(u+(r=r+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((s=s+Math.imul(M,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(N,Q),n=(n=Math.imul(N,tt))+Math.imul(D,Q)|0,s=Math.imul(D,tt),r=r+Math.imul(L,it)|0,n=(n=n+Math.imul(L,rt)|0)+Math.imul(j,it)|0,s=s+Math.imul(j,rt)|0,r=r+Math.imul(I,st)|0,n=(n=n+Math.imul(I,ot)|0)+Math.imul(q,st)|0,s=s+Math.imul(q,ot)|0,r=r+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,ut)|0,r=r+Math.imul(R,lt)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(A,lt)|0,s=s+Math.imul(A,dt)|0;var Tt=(u+(r=r+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(E,pt)|0))<<13)|0;u=((s=s+Math.imul(E,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(N,it),n=(n=Math.imul(N,rt))+Math.imul(D,it)|0,s=Math.imul(D,rt),r=r+Math.imul(L,st)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(j,st)|0,s=s+Math.imul(j,ot)|0,r=r+Math.imul(I,ht)|0,n=(n=n+Math.imul(I,ut)|0)+Math.imul(q,ht)|0,s=s+Math.imul(q,ut)|0,r=r+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,dt)|0)+Math.imul(P,lt)|0,s=s+Math.imul(P,dt)|0;var Pt=(u+(r=r+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((s=s+Math.imul(A,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(N,st),n=(n=Math.imul(N,ot))+Math.imul(D,st)|0,s=Math.imul(D,ot),r=r+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,ut)|0)+Math.imul(j,ht)|0,s=s+Math.imul(j,ut)|0,r=r+Math.imul(I,lt)|0,n=(n=n+Math.imul(I,dt)|0)+Math.imul(q,lt)|0,s=s+Math.imul(q,dt)|0;var Bt=(u+(r=r+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((s=s+Math.imul(P,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(N,ht),n=(n=Math.imul(N,ut))+Math.imul(D,ht)|0,s=Math.imul(D,ut),r=r+Math.imul(L,lt)|0,n=(n=n+Math.imul(L,dt)|0)+Math.imul(j,lt)|0,s=s+Math.imul(j,dt)|0;var It=(u+(r=r+Math.imul(I,pt)|0)|0)+((8191&(n=(n=n+Math.imul(I,mt)|0)+Math.imul(q,pt)|0))<<13)|0;u=((s=s+Math.imul(q,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(N,lt),n=(n=Math.imul(N,dt))+Math.imul(D,lt)|0,s=Math.imul(D,dt);var qt=(u+(r=r+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,mt)|0)+Math.imul(j,pt)|0))<<13)|0;u=((s=s+Math.imul(j,mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863;var Ot=(u+(r=Math.imul(N,pt))|0)+((8191&(n=(n=Math.imul(N,mt))+Math.imul(D,pt)|0))<<13)|0;return u=((s=Math.imul(D,mt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=vt,h[2]=bt,h[3]=yt,h[4]=wt,h[5]=Mt,h[6]=_t,h[7]=St,h[8]=Et,h[9]=kt,h[10]=Rt,h[11]=At,h[12]=xt,h[13]=Tt,h[14]=Pt,h[15]=Bt,h[16]=It,h[17]=qt,h[18]=Ot,0!==u&&(h[19]=u,i.length++),i};function p(t,e,i){i.negative=e.negative^t.negative,i.length=t.length+e.length;for(var r=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}i.words[s]=a,r=o,o=n}return 0!==r?i.words[s]=r:i.length--,i._strip()}function m(t,e,i){return p(t,e,i)}function g(t,e){this.x=t,this.y=e}Math.imul||(c=d),r.prototype.mulTo=function(t,e){var i=this.length+t.length;return 10===this.length&&10===t.length?c(this,t,e):i<63?d(this,t,e):i<1024?p(this,t,e):m(this,t,e)},g.prototype.makeRBT=function(t){for(var e=new Array(t),i=r.prototype._countBits(t)-1,n=0;n>=1;return r},g.prototype.permute=function(t,e,i,r,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*s+1]=8191&n,n>>>=13;for(s=2*e;s>=26,i+=n/67108864|0,i+=s>>>26,this.words[r]=67108863&s}return 0!==i&&(this.words[r]=i,this.length++),e?this.ineg():this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),i=0;i>>n&1}return e}(t);if(0===e.length)return new r(1);for(var i=this,n=0;n>>26-i<<26-i;if(0!==i){var s=0;for(e=0;e>>26-i}s&&(this.words[e]=s,this.length++)}if(0!==r){for(e=this.length-1;e>=0;e--)this.words[e+r]=this.words[e];for(e=0;e>>n<s)for(this.length-=s,h=0;h=0&&(0!==u||h>=r);h--){var f=0|this.words[h];this.words[h]=u<<26-n|f>>>n,u=f&o}return a&&0!==u&&(a.words[a.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},r.prototype.ishrn=function(t,e,i){return this.iushrn(t,e,i)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){var e=t%26,i=(t-e)/26,r=1<>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},r.prototype.isubn=function(t){if(t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(a/67108864|0),this.words[r+i]=67108863&n}for(;r>26,this.words[r+i]=67108863&n;if(0===o)return this._strip();for(o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this._strip()},r.prototype._wordDiv=function(t,e){var i=(this.length,t.length),n=this.clone(),s=t,o=0|s.words[s.length-1];0!=(i=26-this._countBits(o))&&(s=s.ushln(i),n.iushln(i),o=0|s.words[s.length-1]);var a,h=n.length-s.length;if("mod"!==e){(a=new r(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u=0;l--){var d=67108864*(0|n.words[s.length+l])+(0|n.words[s.length+l-1]);for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(s,d,l);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(s,1,l),n.isZero()||(n.negative^=1);a&&(a.words[l]=d)}return a&&a._strip(),n._strip(),"div"!==e&&0!==i&&n.iushrn(i),{div:a||null,mod:n}},r.prototype.divmod=function(t,e,i){return this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),"mod"!==e&&(n=o.div.neg()),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),e),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new r(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modrn(t.words[0]))}:this._wordDiv(t,e);var n,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var i=0!==e.div.negative?e.mod.isub(t):e.mod,r=t.ushrn(1),n=t.andln(1),s=i.cmp(r);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},r.prototype.modrn=function(t){var e=t<0;e&&(t=-t);for(var i=(1<<26)%t,r=0,n=this.length-1;n>=0;n--)r=(i*r+(0|this.words[n]))%t;return e?-r:r},r.prototype.modn=function(t){return this.modrn(t)},r.prototype.idivn=function(t){var e=t<0;e&&(t=-t);for(var i=0,r=this.length-1;r>=0;r--){var n=(0|this.words[r])+67108864*i;this.words[r]=n/t|0,i=n%t}return this._strip(),e?this.ineg():this},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new r(1),s=new r(0),o=new r(0),a=new r(1),h=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++h;for(var u=i.clone(),f=e.clone();!e.isZero();){for(var l=0,d=1;0==(e.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(e.iushrn(l);l-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(u),s.isub(f)),n.iushrn(1),s.iushrn(1);for(var c=0,p=1;0==(i.words[0]&p)&&c<26;++c,p<<=1);if(c>0)for(i.iushrn(c);c-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(u),a.isub(f)),o.iushrn(1),a.iushrn(1);e.cmp(i)>=0?(e.isub(i),n.isub(o),s.isub(a)):(i.isub(e),o.isub(n),a.isub(s))}return{a:o,b:a,gcd:i.iushln(h)}},r.prototype._invmp=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new r(1),o=new r(0),a=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var h=0,u=1;0==(e.words[0]&u)&&h<26;++h,u<<=1);if(h>0)for(e.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(a),s.iushrn(1);for(var f=0,l=1;0==(i.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(i.iushrn(f);f-- >0;)o.isOdd()&&o.iadd(a),o.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o)):(i.isub(e),o.isub(s))}return(n=0===e.cmpn(1)?s:o).cmpn(0)<0&&n.iadd(t),n},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),i=t.clone();e.negative=0,i.negative=0;for(var r=0;e.isEven()&&i.isEven();r++)e.iushrn(1),i.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;i.isEven();)i.iushrn(1);var n=e.cmp(i);if(n<0){var s=e;e=i,i=s}else if(0===n||0===i.cmpn(1))break;e.isub(i)}return i.iushln(r)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){var e=t%26,i=(t-e)/26,r=1<>>26,o&=67108863,this.words[s]=o}return 0!==n&&(this.words[s]=n,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this._strip(),this.length>1)e=1;else{i&&(t=-t);var r=0|this.words[0];e=r===t?0:rt.length)return 1;if(this.length=0;i--){var r=0|this.words[i],n=0|t.words[i];if(r!==n){rn&&(e=1);break}}return e},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new E(t)},r.prototype.toRed=function(t){return t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return this._forceRed(t)},r.prototype.redAdd=function(t){return this.red.add(this,t)},r.prototype.redIAdd=function(t){return this.red.iadd(this,t)},r.prototype.redSub=function(t){return this.red.sub(this,t)},r.prototype.redISub=function(t){return this.red.isub(this,t)},r.prototype.redShl=function(t){return this.red.shl(this,t)},r.prototype.redMul=function(t){return this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return this.red._verify1(this),this.red.pow(this,t)};var v={k256:null,p224:null,p192:null,p25519:null};function b(t,e){this.name=t,this.p=new r(e,16),this.n=this.p.bitLength(),this.k=new r(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function y(){b.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function M(){b.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function _(){b.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function S(){b.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=r._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function k(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(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)}b.prototype._tmp=function(){var t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},b.prototype.ireduce=function(t){var e,i=t;do{this.split(i,this.tmp),e=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(e>this.n);var r=e0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},b.prototype.split=function(t,e){t.iushrn(this.n,0,e)},b.prototype.imulK=function(t){return t.imul(this.k)},i(y,b),y.prototype.split=function(t,e){for(var i=Math.min(t.length,9),r=0;r>>22,n=s}n>>>=22,t.words[r-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},y.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,i=0;i>>=26,t.words[i]=n,e=r}return 0!==e&&(t.words[t.length++]=e),t},r._prime=function(t){if(v[t])return v[t];var e;if("k256"===t)e=new y;else if("p224"===t)e=new M;else if("p192"===t)e=new _;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new S}return v[t]=e,e},E.prototype._verify1=function(t){},E.prototype._verify2=function(t,e){},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(a(t,t.umod(this.m)._forceRed(this)),t)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var i=t.add(e);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var i=t.iadd(e);return i.cmp(this.m)>=0&&i.isub(this.m),i},E.prototype.sub=function(t,e){this._verify2(t,e);var i=t.sub(e);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var i=t.isub(e);return i.cmpn(0)<0&&i.iadd(this.m),i},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();if(3===this.m.andln(3)){var e=this.m.add(new r(1)).iushrn(2);return this.pow(t,e)}for(var i=this.m.subn(1),n=0;!i.isZero()&&0===i.andln(1);)n++,i.iushrn(1);var s=new r(1).toRed(this),o=s.redNeg(),a=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new r(2*h*h).toRed(this);0!==this.pow(h,a).cmp(o);)h.redIAdd(o);for(var u=this.pow(h,i),f=this.pow(t,i.addn(1).iushrn(1)),l=this.pow(t,i),d=n;0!==l.cmp(s);){for(var c=l,p=0;0!==c.cmp(s);p++)c=c.redSqr();var m=this.pow(u,new r(1).iushln(d-p-1));f=f.redMul(m),u=m.redSqr(),l=l.redMul(u),d=p}return f},E.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},E.prototype.pow=function(t,e){if(e.isZero())return new r(1).toRed(this);if(0===e.cmpn(1))return t.clone();var i=new Array(16);i[0]=new r(1).toRed(this),i[1]=t;for(var n=2;n=0;n--){for(var u=e.words[n],f=h-1;f>=0;f--){var l=u>>f&1;s!==i[0]&&(s=this.sqr(s)),0!==l||0!==o?(o<<=1,o|=l,(4==++a||0===n&&0===f)&&(s=this.mul(s,i[o]),a=0,o=0)):a=0}h=26}return s},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},r.mont=function(t){return new k(t)},i(k,E),k.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},k.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},k.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(e),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},k.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new r(0)._forceRed(this);var i=t.mul(e),n=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=i.isub(n).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},k.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(ho,this),ho=ho.exports;var uo={};(function(t){(function(){function e(t){var e,i=t.modulus.byteLength();do{e=new ho(J(i))}while(e.cmp(t.modulus)>=0||!e.umod(t.prime1)||!e.umod(t.prime2));return e}function i(i,r){var n=function(t){var i=e(t);return{blinder:i.toRed(ho.mont(t.modulus)).redPow(new ho(t.publicExponent)).fromRed(),unblinder:i.invm(t.modulus)}}(r),s=r.modulus.byteLength(),o=new ho(i).mul(n.blinder).umod(r.modulus),a=o.toRed(ho.mont(r.prime1)),h=o.toRed(ho.mont(r.prime2)),u=r.coefficient,f=r.prime1,l=r.prime2,d=a.redPow(r.exponent1).fromRed(),c=h.redPow(r.exponent2).fromRed(),p=d.isub(c).imul(u).umod(f).imul(l);return c.iadd(p).imul(n.unblinder).umod(r.modulus).toArrayLike(t,"be",s)}i.getr=e,uo=i}).call(this)}).call(this,M({}).Buffer);var fo={exports:{}};!function(t,e){"use strict";function i(t,e){t.super_=e;var i=function(){};i.prototype=e.prototype,t.prototype=new i,t.prototype.constructor=t}function r(t,e,i){if(r.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(i=e,e=10),this._init(t||0,e||10,i||"be"))}var n;"object"==typeof t?t.exports=r:e.BN=r,r.BN=r,r.wordSize=26;try{n=w({}).Buffer}catch(jf){}function s(t,e,i){for(var r=0,n=Math.min(t.length,i),s=e;s=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return r}function o(t,e,i,r){for(var n=0,s=Math.min(t.length,i),o=e;o=49?a-49+10:a>=17?a-17+10:a}return n}r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,e){return t.cmp(e)>0?t:e},r.min=function(t,e){return t.cmp(e)<0?t:e},r.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===e?this._parseHex(t,r):this._parseBase(t,e,r),"-"===t[0]&&(this.negative=1),this.strip(),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initArray=function(t,e,i){if(t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r=0;r-=3)s=t[r]|t[r-1]<<8|t[r-2]<<16,this.words[n]|=s<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===i)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this.strip()},r.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=6)n=s(t,i,i+6),this.words[r]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,r++);i+6!==e&&(n=s(t,e,i+6),this.words[r]|=n<>>26-o&4194303),this.strip()},r.prototype._parseBase=function(t,e,i){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=e)r++;r--,n=n/e|0;for(var s=t.length-i,a=s%r,h=Math.min(s,s-a)+i,u=0,f=i;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},r.prototype.inspect=function(){return(this.red?""};var a=["","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"],h=[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],u=[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 f(t,e,i){i.negative=e.negative^t.negative;var r=t.length+e.length|0;i.length=r,r=r-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;i.words[0]=a;for(var u=1;u>>26,l=67108863&h,d=Math.min(u,e.length-1),c=Math.max(0,u-t.length+1);c<=d;c++){var p=u-c|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[c])+l)/67108864|0,l=67108863&o}i.words[u]=0|l,h=0|f}return 0!==h?i.words[u]=0|h:i.length--,i.strip()}r.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var r=0,n=0,s=0;s>>24-r&16777215)||s!==this.length-1?a[6-f.length]+f+i:f+i,(r+=2)>=26&&(r-=26,s--)}for(0!==n&&(i=n.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var l=h[t],d=u[t];i="";var c=this.clone();for(c.negative=0;!c.isZero();){var p=c.modn(d).toString(t);i=(c=c.idivn(d)).isZero()?p+i:a[l-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length,0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16)},r.prototype.toBuffer=function(t,e){return this.toArrayLike(n,t,e)},r.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},r.prototype.toArrayLike=function(t,e,i){var r=this.byteLength(),n=i||Math.max(1,r);this.strip();var s,o,a="le"===e,h=new t(n),u=this.clone();if(a){for(o=0;!u.isZero();o++)s=u.andln(255),u.iushrn(8),h[o]=s;for(;o=4096&&(i+=13,e>>>=13),e>=64&&(i+=7,e>>>=7),e>=8&&(i+=4,e>>>=4),e>=2&&(i+=2,e>>>=2),i+e},r.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,i=0;return 0==(8191&e)&&(i+=13,e>>>=13),0==(127&e)&&(i+=7,e>>>=7),0==(15&e)&&(i+=4,e>>>=4),0==(3&e)&&(i+=2,e>>>=2),0==(1&e)&&i++,i},r.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var i=0;it.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var e,i;this.length>t.length?(e=this,i=t):(e=t,i=this);for(var r=0;rt.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-i),this.strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,e){var i=t/26|0,r=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(i=this,r=t):(i=t,r=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i,r,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(i=this,r=t):(i=t,r=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,c=0|o[1],p=8191&c,m=c>>>13,g=0|o[2],v=8191&g,b=g>>>13,y=0|o[3],w=8191&y,M=y>>>13,_=0|o[4],S=8191&_,E=_>>>13,k=0|o[5],R=8191&k,A=k>>>13,x=0|o[6],T=8191&x,P=x>>>13,B=0|o[7],I=8191&B,q=B>>>13,O=0|o[8],L=8191&O,j=O>>>13,C=0|o[9],N=8191&C,D=C>>>13,U=0|a[0],$=8191&U,z=U>>>13,W=0|a[1],F=8191&W,K=W>>>13,H=0|a[2],Z=8191&H,V=H>>>13,G=0|a[3],Y=8191&G,X=G>>>13,J=0|a[4],Q=8191&J,tt=J>>>13,et=0|a[5],it=8191&et,rt=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,ft=0|a[8],lt=8191&ft,dt=ft>>>13,ct=0|a[9],pt=8191&ct,mt=ct>>>13;i.negative=t.negative^e.negative,i.length=19;var gt=(u+(r=Math.imul(l,$))|0)+((8191&(n=(n=Math.imul(l,z))+Math.imul(d,$)|0))<<13)|0;u=((s=Math.imul(d,z))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(p,$),n=(n=Math.imul(p,z))+Math.imul(m,$)|0,s=Math.imul(m,z);var vt=(u+(r=r+Math.imul(l,F)|0)|0)+((8191&(n=(n=n+Math.imul(l,K)|0)+Math.imul(d,F)|0))<<13)|0;u=((s=s+Math.imul(d,K)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(v,$),n=(n=Math.imul(v,z))+Math.imul(b,$)|0,s=Math.imul(b,z),r=r+Math.imul(p,F)|0,n=(n=n+Math.imul(p,K)|0)+Math.imul(m,F)|0,s=s+Math.imul(m,K)|0;var bt=(u+(r=r+Math.imul(l,Z)|0)|0)+((8191&(n=(n=n+Math.imul(l,V)|0)+Math.imul(d,Z)|0))<<13)|0;u=((s=s+Math.imul(d,V)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(w,$),n=(n=Math.imul(w,z))+Math.imul(M,$)|0,s=Math.imul(M,z),r=r+Math.imul(v,F)|0,n=(n=n+Math.imul(v,K)|0)+Math.imul(b,F)|0,s=s+Math.imul(b,K)|0,r=r+Math.imul(p,Z)|0,n=(n=n+Math.imul(p,V)|0)+Math.imul(m,Z)|0,s=s+Math.imul(m,V)|0;var yt=(u+(r=r+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,X)|0)+Math.imul(d,Y)|0))<<13)|0;u=((s=s+Math.imul(d,X)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(S,$),n=(n=Math.imul(S,z))+Math.imul(E,$)|0,s=Math.imul(E,z),r=r+Math.imul(w,F)|0,n=(n=n+Math.imul(w,K)|0)+Math.imul(M,F)|0,s=s+Math.imul(M,K)|0,r=r+Math.imul(v,Z)|0,n=(n=n+Math.imul(v,V)|0)+Math.imul(b,Z)|0,s=s+Math.imul(b,V)|0,r=r+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,X)|0;var wt=(u+(r=r+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(d,Q)|0))<<13)|0;u=((s=s+Math.imul(d,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(R,$),n=(n=Math.imul(R,z))+Math.imul(A,$)|0,s=Math.imul(A,z),r=r+Math.imul(S,F)|0,n=(n=n+Math.imul(S,K)|0)+Math.imul(E,F)|0,s=s+Math.imul(E,K)|0,r=r+Math.imul(w,Z)|0,n=(n=n+Math.imul(w,V)|0)+Math.imul(M,Z)|0,s=s+Math.imul(M,V)|0,r=r+Math.imul(v,Y)|0,n=(n=n+Math.imul(v,X)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,X)|0,r=r+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var Mt=(u+(r=r+Math.imul(l,it)|0)|0)+((8191&(n=(n=n+Math.imul(l,rt)|0)+Math.imul(d,it)|0))<<13)|0;u=((s=s+Math.imul(d,rt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(T,$),n=(n=Math.imul(T,z))+Math.imul(P,$)|0,s=Math.imul(P,z),r=r+Math.imul(R,F)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(A,F)|0,s=s+Math.imul(A,K)|0,r=r+Math.imul(S,Z)|0,n=(n=n+Math.imul(S,V)|0)+Math.imul(E,Z)|0,s=s+Math.imul(E,V)|0,r=r+Math.imul(w,Y)|0,n=(n=n+Math.imul(w,X)|0)+Math.imul(M,Y)|0,s=s+Math.imul(M,X)|0,r=r+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,tt)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,tt)|0,r=r+Math.imul(p,it)|0,n=(n=n+Math.imul(p,rt)|0)+Math.imul(m,it)|0,s=s+Math.imul(m,rt)|0;var _t=(u+(r=r+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(d,st)|0))<<13)|0;u=((s=s+Math.imul(d,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(I,$),n=(n=Math.imul(I,z))+Math.imul(q,$)|0,s=Math.imul(q,z),r=r+Math.imul(T,F)|0,n=(n=n+Math.imul(T,K)|0)+Math.imul(P,F)|0,s=s+Math.imul(P,K)|0,r=r+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,V)|0)+Math.imul(A,Z)|0,s=s+Math.imul(A,V)|0,r=r+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,X)|0,r=r+Math.imul(w,Q)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(M,Q)|0,s=s+Math.imul(M,tt)|0,r=r+Math.imul(v,it)|0,n=(n=n+Math.imul(v,rt)|0)+Math.imul(b,it)|0,s=s+Math.imul(b,rt)|0,r=r+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(r=r+Math.imul(l,ht)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((s=s+Math.imul(d,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(L,$),n=(n=Math.imul(L,z))+Math.imul(j,$)|0,s=Math.imul(j,z),r=r+Math.imul(I,F)|0,n=(n=n+Math.imul(I,K)|0)+Math.imul(q,F)|0,s=s+Math.imul(q,K)|0,r=r+Math.imul(T,Z)|0,n=(n=n+Math.imul(T,V)|0)+Math.imul(P,Z)|0,s=s+Math.imul(P,V)|0,r=r+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,X)|0,r=r+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(E,Q)|0,s=s+Math.imul(E,tt)|0,r=r+Math.imul(w,it)|0,n=(n=n+Math.imul(w,rt)|0)+Math.imul(M,it)|0,s=s+Math.imul(M,rt)|0,r=r+Math.imul(v,st)|0,n=(n=n+Math.imul(v,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,r=r+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,ut)|0;var Et=(u+(r=r+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,dt)|0)+Math.imul(d,lt)|0))<<13)|0;u=((s=s+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(N,$),n=(n=Math.imul(N,z))+Math.imul(D,$)|0,s=Math.imul(D,z),r=r+Math.imul(L,F)|0,n=(n=n+Math.imul(L,K)|0)+Math.imul(j,F)|0,s=s+Math.imul(j,K)|0,r=r+Math.imul(I,Z)|0,n=(n=n+Math.imul(I,V)|0)+Math.imul(q,Z)|0,s=s+Math.imul(q,V)|0,r=r+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,X)|0,r=r+Math.imul(R,Q)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(A,Q)|0,s=s+Math.imul(A,tt)|0,r=r+Math.imul(S,it)|0,n=(n=n+Math.imul(S,rt)|0)+Math.imul(E,it)|0,s=s+Math.imul(E,rt)|0,r=r+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(M,st)|0,s=s+Math.imul(M,ot)|0,r=r+Math.imul(v,ht)|0,n=(n=n+Math.imul(v,ut)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ut)|0,r=r+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,dt)|0;var kt=(u+(r=r+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(d,pt)|0))<<13)|0;u=((s=s+Math.imul(d,mt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(N,F),n=(n=Math.imul(N,K))+Math.imul(D,F)|0,s=Math.imul(D,K),r=r+Math.imul(L,Z)|0,n=(n=n+Math.imul(L,V)|0)+Math.imul(j,Z)|0,s=s+Math.imul(j,V)|0,r=r+Math.imul(I,Y)|0,n=(n=n+Math.imul(I,X)|0)+Math.imul(q,Y)|0,s=s+Math.imul(q,X)|0,r=r+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(P,Q)|0,s=s+Math.imul(P,tt)|0,r=r+Math.imul(R,it)|0,n=(n=n+Math.imul(R,rt)|0)+Math.imul(A,it)|0,s=s+Math.imul(A,rt)|0,r=r+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(E,st)|0,s=s+Math.imul(E,ot)|0,r=r+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(M,ht)|0,s=s+Math.imul(M,ut)|0,r=r+Math.imul(v,lt)|0,n=(n=n+Math.imul(v,dt)|0)+Math.imul(b,lt)|0,s=s+Math.imul(b,dt)|0;var Rt=(u+(r=r+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(N,Z),n=(n=Math.imul(N,V))+Math.imul(D,Z)|0,s=Math.imul(D,V),r=r+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(j,Y)|0,s=s+Math.imul(j,X)|0,r=r+Math.imul(I,Q)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(q,Q)|0,s=s+Math.imul(q,tt)|0,r=r+Math.imul(T,it)|0,n=(n=n+Math.imul(T,rt)|0)+Math.imul(P,it)|0,s=s+Math.imul(P,rt)|0,r=r+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(A,st)|0,s=s+Math.imul(A,ot)|0,r=r+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(E,ht)|0,s=s+Math.imul(E,ut)|0,r=r+Math.imul(w,lt)|0,n=(n=n+Math.imul(w,dt)|0)+Math.imul(M,lt)|0,s=s+Math.imul(M,dt)|0;var At=(u+(r=r+Math.imul(v,pt)|0)|0)+((8191&(n=(n=n+Math.imul(v,mt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((s=s+Math.imul(b,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(N,Y),n=(n=Math.imul(N,X))+Math.imul(D,Y)|0,s=Math.imul(D,X),r=r+Math.imul(L,Q)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(j,Q)|0,s=s+Math.imul(j,tt)|0,r=r+Math.imul(I,it)|0,n=(n=n+Math.imul(I,rt)|0)+Math.imul(q,it)|0,s=s+Math.imul(q,rt)|0,r=r+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,ot)|0,r=r+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(A,ht)|0,s=s+Math.imul(A,ut)|0,r=r+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,dt)|0)+Math.imul(E,lt)|0,s=s+Math.imul(E,dt)|0;var xt=(u+(r=r+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((s=s+Math.imul(M,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(N,Q),n=(n=Math.imul(N,tt))+Math.imul(D,Q)|0,s=Math.imul(D,tt),r=r+Math.imul(L,it)|0,n=(n=n+Math.imul(L,rt)|0)+Math.imul(j,it)|0,s=s+Math.imul(j,rt)|0,r=r+Math.imul(I,st)|0,n=(n=n+Math.imul(I,ot)|0)+Math.imul(q,st)|0,s=s+Math.imul(q,ot)|0,r=r+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,ut)|0,r=r+Math.imul(R,lt)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(A,lt)|0,s=s+Math.imul(A,dt)|0;var Tt=(u+(r=r+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(E,pt)|0))<<13)|0;u=((s=s+Math.imul(E,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(N,it),n=(n=Math.imul(N,rt))+Math.imul(D,it)|0,s=Math.imul(D,rt),r=r+Math.imul(L,st)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(j,st)|0,s=s+Math.imul(j,ot)|0,r=r+Math.imul(I,ht)|0,n=(n=n+Math.imul(I,ut)|0)+Math.imul(q,ht)|0,s=s+Math.imul(q,ut)|0,r=r+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,dt)|0)+Math.imul(P,lt)|0,s=s+Math.imul(P,dt)|0;var Pt=(u+(r=r+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((s=s+Math.imul(A,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(N,st),n=(n=Math.imul(N,ot))+Math.imul(D,st)|0,s=Math.imul(D,ot),r=r+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,ut)|0)+Math.imul(j,ht)|0,s=s+Math.imul(j,ut)|0,r=r+Math.imul(I,lt)|0,n=(n=n+Math.imul(I,dt)|0)+Math.imul(q,lt)|0,s=s+Math.imul(q,dt)|0;var Bt=(u+(r=r+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((s=s+Math.imul(P,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(N,ht),n=(n=Math.imul(N,ut))+Math.imul(D,ht)|0,s=Math.imul(D,ut),r=r+Math.imul(L,lt)|0,n=(n=n+Math.imul(L,dt)|0)+Math.imul(j,lt)|0,s=s+Math.imul(j,dt)|0;var It=(u+(r=r+Math.imul(I,pt)|0)|0)+((8191&(n=(n=n+Math.imul(I,mt)|0)+Math.imul(q,pt)|0))<<13)|0;u=((s=s+Math.imul(q,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(N,lt),n=(n=Math.imul(N,dt))+Math.imul(D,lt)|0,s=Math.imul(D,dt);var qt=(u+(r=r+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,mt)|0)+Math.imul(j,pt)|0))<<13)|0;u=((s=s+Math.imul(j,mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863;var Ot=(u+(r=Math.imul(N,pt))|0)+((8191&(n=(n=Math.imul(N,mt))+Math.imul(D,pt)|0))<<13)|0;return u=((s=Math.imul(D,mt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=vt,h[2]=bt,h[3]=yt,h[4]=wt,h[5]=Mt,h[6]=_t,h[7]=St,h[8]=Et,h[9]=kt,h[10]=Rt,h[11]=At,h[12]=xt,h[13]=Tt,h[14]=Pt,h[15]=Bt,h[16]=It,h[17]=qt,h[18]=Ot,0!==u&&(h[19]=u,i.length++),i};function d(t,e,i){return(new c).mulp(t,e,i)}function c(t,e){this.x=t,this.y=e}Math.imul||(l=f),r.prototype.mulTo=function(t,e){var i=this.length+t.length;return 10===this.length&&10===t.length?l(this,t,e):i<63?f(this,t,e):i<1024?function(t,e,i){i.negative=e.negative^t.negative,i.length=t.length+e.length;for(var r=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}i.words[s]=a,r=o,o=n}return 0!==r?i.words[s]=r:i.length--,i.strip()}(this,t,e):d(this,t,e)},c.prototype.makeRBT=function(t){for(var e=new Array(t),i=r.prototype._countBits(t)-1,n=0;n>=1;return r},c.prototype.permute=function(t,e,i,r,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*s+1]=8191&n,n>>>=13;for(s=2*e;s>=26,e+=r/67108864|0,e+=n>>>26,this.words[i]=67108863&n}return 0!==e&&(this.words[i]=e,this.length++),this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),i=0;i>>n}return e}(t);if(0===e.length)return new r(1);for(var i=this,n=0;n>>26-i<<26-i;if(0!==i){var s=0;for(e=0;e>>26-i}s&&(this.words[e]=s,this.length++)}if(0!==r){for(e=this.length-1;e>=0;e--)this.words[e+r]=this.words[e];for(e=0;e>>n<s)for(this.length-=s,h=0;h=0&&(0!==u||h>=r);h--){var f=0|this.words[h];this.words[h]=u<<26-n|f>>>n,u=f&o}return a&&0!==u&&(a.words[a.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},r.prototype.ishrn=function(t,e,i){return this.iushrn(t,e,i)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){var e=t%26,i=(t-e)/26,r=1<>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},r.prototype.isubn=function(t){if(t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(a/67108864|0),this.words[r+i]=67108863&n}for(;r>26,this.words[r+i]=67108863&n;if(0===o)return this.strip();for(o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},r.prototype._wordDiv=function(t,e){var i=(this.length,t.length),n=this.clone(),s=t,o=0|s.words[s.length-1];0!=(i=26-this._countBits(o))&&(s=s.ushln(i),n.iushln(i),o=0|s.words[s.length-1]);var a,h=n.length-s.length;if("mod"!==e){(a=new r(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u=0;l--){var d=67108864*(0|n.words[s.length+l])+(0|n.words[s.length+l-1]);for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(s,d,l);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(s,1,l),n.isZero()||(n.negative^=1);a&&(a.words[l]=d)}return a&&a.strip(),n.strip(),"div"!==e&&0!==i&&n.iushrn(i),{div:a||null,mod:n}},r.prototype.divmod=function(t,e,i){return this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),"mod"!==e&&(n=o.div.neg()),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),e),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new r(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var i=0!==e.div.negative?e.mod.isub(t):e.mod,r=t.ushrn(1),n=t.andln(1),s=i.cmp(r);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},r.prototype.modn=function(t){for(var e=(1<<26)%t,i=0,r=this.length-1;r>=0;r--)i=(e*i+(0|this.words[r]))%t;return i},r.prototype.idivn=function(t){for(var e=0,i=this.length-1;i>=0;i--){var r=(0|this.words[i])+67108864*e;this.words[i]=r/t|0,e=r%t}return this.strip()},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new r(1),s=new r(0),o=new r(0),a=new r(1),h=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++h;for(var u=i.clone(),f=e.clone();!e.isZero();){for(var l=0,d=1;0==(e.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(e.iushrn(l);l-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(u),s.isub(f)),n.iushrn(1),s.iushrn(1);for(var c=0,p=1;0==(i.words[0]&p)&&c<26;++c,p<<=1);if(c>0)for(i.iushrn(c);c-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(u),a.isub(f)),o.iushrn(1),a.iushrn(1);e.cmp(i)>=0?(e.isub(i),n.isub(o),s.isub(a)):(i.isub(e),o.isub(n),a.isub(s))}return{a:o,b:a,gcd:i.iushln(h)}},r.prototype._invmp=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new r(1),o=new r(0),a=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var h=0,u=1;0==(e.words[0]&u)&&h<26;++h,u<<=1);if(h>0)for(e.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(a),s.iushrn(1);for(var f=0,l=1;0==(i.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(i.iushrn(f);f-- >0;)o.isOdd()&&o.iadd(a),o.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o)):(i.isub(e),o.isub(s))}return(n=0===e.cmpn(1)?s:o).cmpn(0)<0&&n.iadd(t),n},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),i=t.clone();e.negative=0,i.negative=0;for(var r=0;e.isEven()&&i.isEven();r++)e.iushrn(1),i.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;i.isEven();)i.iushrn(1);var n=e.cmp(i);if(n<0){var s=e;e=i,i=s}else if(0===n||0===i.cmpn(1))break;e.isub(i)}return i.iushln(r)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){var e=t%26,i=(t-e)/26,r=1<>>26,o&=67108863,this.words[s]=o}return 0!==n&&(this.words[s]=n,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t);var r=0|this.words[0];e=r===t?0:rt.length)return 1;if(this.length=0;i--){var r=0|this.words[i],n=0|t.words[i];if(r!==n){rn&&(e=1);break}}return e},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new M(t)},r.prototype.toRed=function(t){return t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return this._forceRed(t)},r.prototype.redAdd=function(t){return this.red.add(this,t)},r.prototype.redIAdd=function(t){return this.red.iadd(this,t)},r.prototype.redSub=function(t){return this.red.sub(this,t)},r.prototype.redISub=function(t){return this.red.isub(this,t)},r.prototype.redShl=function(t){return this.red.shl(this,t)},r.prototype.redMul=function(t){return this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return this.red._verify1(this),this.red.pow(this,t)};var p={k256:null,p224:null,p192:null,p25519:null};function m(t,e){this.name=t,this.p=new r(e,16),this.n=this.p.bitLength(),this.k=new r(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 v(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function y(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(t){if("string"==typeof t){var e=r._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function _(t){M.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(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 t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},m.prototype.ireduce=function(t){var e,i=t;do{this.split(i,this.tmp),e=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(e>this.n);var r=e0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},m.prototype.split=function(t,e){t.iushrn(this.n,0,e)},m.prototype.imulK=function(t){return t.imul(this.k)},i(g,m),g.prototype.split=function(t,e){for(var i=Math.min(t.length,9),r=0;r>>22,n=s}n>>>=22,t.words[r-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},g.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,i=0;i>>=26,t.words[i]=n,e=r}return 0!==e&&(t.words[t.length++]=e),t},r._prime=function(t){if(p[t])return p[t];var e;if("k256"===t)e=new g;else if("p224"===t)e=new v;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new y}return p[t]=e,e},M.prototype._verify1=function(t){},M.prototype._verify2=function(t,e){},M.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},M.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},M.prototype.add=function(t,e){this._verify2(t,e);var i=t.add(e);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},M.prototype.iadd=function(t,e){this._verify2(t,e);var i=t.iadd(e);return i.cmp(this.m)>=0&&i.isub(this.m),i},M.prototype.sub=function(t,e){this._verify2(t,e);var i=t.sub(e);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},M.prototype.isub=function(t,e){this._verify2(t,e);var i=t.isub(e);return i.cmpn(0)<0&&i.iadd(this.m),i},M.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},M.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},M.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},M.prototype.isqr=function(t){return this.imul(t,t.clone())},M.prototype.sqr=function(t){return this.mul(t,t)},M.prototype.sqrt=function(t){if(t.isZero())return t.clone();if(3===this.m.andln(3)){var e=this.m.add(new r(1)).iushrn(2);return this.pow(t,e)}for(var i=this.m.subn(1),n=0;!i.isZero()&&0===i.andln(1);)n++,i.iushrn(1);var s=new r(1).toRed(this),o=s.redNeg(),a=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new r(2*h*h).toRed(this);0!==this.pow(h,a).cmp(o);)h.redIAdd(o);for(var u=this.pow(h,i),f=this.pow(t,i.addn(1).iushrn(1)),l=this.pow(t,i),d=n;0!==l.cmp(s);){for(var c=l,p=0;0!==c.cmp(s);p++)c=c.redSqr();var m=this.pow(u,new r(1).iushln(d-p-1));f=f.redMul(m),u=m.redSqr(),l=l.redMul(u),d=p}return f},M.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},M.prototype.pow=function(t,e){if(e.isZero())return new r(1).toRed(this);if(0===e.cmpn(1))return t.clone();var i=new Array(16);i[0]=new r(1).toRed(this),i[1]=t;for(var n=2;n=0;n--){for(var u=e.words[n],f=h-1;f>=0;f--){var l=u>>f&1;s!==i[0]&&(s=this.sqr(s)),0!==l||0!==o?(o<<=1,o|=l,(4==++a||0===n&&0===f)&&(s=this.mul(s,i[o]),a=0,o=0)):a=0}h=26}return s},M.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},M.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},r.mont=function(t){return new _(t)},i(_,M),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(e),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new r(0)._forceRed(this);var i=t.mul(e),n=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=i.isub(n).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(fo,this),fo=fo.exports;var lo={},co=lo;function po(t){return 1===t.length?"0"+t:t}function mo(t){for(var e="",i=0;i>8,o=255&n;s?i.push(s,o):i.push(o)}return i},co.zero2=po,co.toHex=mo,co.encode=function(t,e){return"hex"===e?mo(t):t};var go={},vo=go;vo.assert=$r,vo.toArray=lo.toArray,vo.zero2=lo.zero2,vo.toHex=lo.toHex,vo.encode=lo.encode,vo.getNAF=function(t,e,i){var r=new Array(Math.max(t.bitLength(),i)+1);r.fill(0);for(var n=1<(n>>1)-1?(n>>1)-h:h,s.isubn(a)):a=0,r[o]=a,s.iushrn(1)}return r},vo.getJSF=function(t,e){var i=[[],[]];t=t.clone(),e=e.clone();for(var r,n=0,s=0;t.cmpn(-n)>0||e.cmpn(-s)>0;){var o,a,h=t.andln(3)+n&3,u=e.andln(3)+s&3;3===h&&(h=-1),3===u&&(u=-1),o=0==(1&h)?0:3!=(r=t.andln(7)+n&7)&&5!==r||2!==u?h:-h,i[0].push(o),a=0==(1&u)?0:3!=(r=e.andln(7)+s&7)&&5!==r||2!==h?u:-u,i[1].push(a),2*n===o+1&&(n=1-n),2*s===a+1&&(s=1-s),t.iushrn(1),e.iushrn(1)}return i},vo.cachedProperty=function(t,e,i){var r="_"+e;t.prototype[e]=function(){return void 0!==this[r]?this[r]:this[r]=i.call(this)}},vo.parseBytes=function(t){return"string"==typeof t?vo.toArray(t,"hex"):t},vo.intFromLE=function(t){return new fo(t,"hex","le")};var bo={},yo=go.getNAF,wo=go.getJSF;function Mo(t,e){this.type=t,this.p=new fo(e.p,16),this.red=e.prime?fo.red(e.prime):fo.mont(this.p),this.zero=new fo(0).toRed(this.red),this.one=new fo(1).toRed(this.red),this.two=new fo(2).toRed(this.red),this.n=e.n&&new fo(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var i=this.n&&this.p.div(this.n);!i||i.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function _o(t,e){this.curve=t,this.type=e,this.precomputed=null}go.assert,bo=Mo,Mo.prototype.point=function(){throw new Error("Not implemented")},Mo.prototype.validate=function(){throw new Error("Not implemented")},Mo.prototype._fixedNafMul=function(t,e){var i=t._getDoubles(),r=yo(e,1,this._bitLength),n=(1<=s;h--)o=(o<<1)+r[h];a.push(o)}for(var u=this.jpoint(null,null,null),f=this.jpoint(null,null,null),l=n;l>0;l--){for(s=0;s=0;a--){for(var h=0;a>=0&&0===s[a];a--)h++;if(a>=0&&h++,o=o.dblp(h),a<0)break;var u=s[a];o="affine"===t.type?u>0?o.mixedAdd(n[u-1>>1]):o.mixedAdd(n[-u-1>>1].neg()):u>0?o.add(n[u-1>>1]):o.add(n[-u-1>>1].neg())}return"affine"===t.type?o.toP():o},Mo.prototype._wnafMulAdd=function(t,e,i,r,n){var s,o,a,h=this._wnafT1,u=this._wnafT2,f=this._wnafT3,l=0;for(s=0;s=1;s-=2){var c=s-1,p=s;if(1===h[c]&&1===h[p]){var m=[e[c],null,null,e[p]];0===e[c].y.cmp(e[p].y)?(m[1]=e[c].add(e[p]),m[2]=e[c].toJ().mixedAdd(e[p].neg())):0===e[c].y.cmp(e[p].y.redNeg())?(m[1]=e[c].toJ().mixedAdd(e[p]),m[2]=e[c].add(e[p].neg())):(m[1]=e[c].toJ().mixedAdd(e[p]),m[2]=e[c].toJ().mixedAdd(e[p].neg()));var g=[-3,-1,-5,-7,0,7,5,1,3],v=wo(i[c],i[p]);for(l=Math.max(v[0].length,l),f[c]=new Array(l),f[p]=new Array(l),o=0;o=0;s--){for(var _=0;s>=0;){var S=!0;for(o=0;o=0&&_++,w=w.dblp(_),s<0)break;for(o=0;o0?a=u[o][E-1>>1]:E<0&&(a=u[o][-E-1>>1].neg()),w="affine"===a.type?w.mixedAdd(a):w.add(a))}}for(s=0;s=Math.ceil((t.bitLength()+1)/e.step)},_o.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],r=this,n=0;n=0&&(s=e,o=i),r.negative&&(r=r.neg(),n=n.neg()),s.negative&&(s=s.neg(),o=o.neg()),[{a:r,b:n},{a:s,b:o}]},Eo.prototype._endoSplit=function(t){var e=this.endo.basis,i=e[0],r=e[1],n=r.b.mul(t).divRound(this.n),s=i.b.neg().mul(t).divRound(this.n),o=n.mul(i.a),a=s.mul(r.a),h=n.mul(i.b),u=s.mul(r.b);return{k1:t.sub(o).sub(a),k2:h.add(u).neg()}},Eo.prototype.pointFromX=function(t,e){(t=new fo(t,16)).red||(t=t.toRed(this.red));var i=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),r=i.redSqrt();if(0!==r.redSqr().redSub(i).cmp(this.zero))throw new Error("invalid point");var n=r.fromRed().isOdd();return(e&&!n||!e&&n)&&(r=r.redNeg()),this.point(t,r)},Eo.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,i=t.y,r=this.a.redMul(e),n=e.redSqr().redMul(e).redIAdd(r).redIAdd(this.b);return 0===i.redSqr().redISub(n).cmpn(0)},Eo.prototype._endoWnafMulAdd=function(t,e,i){for(var r=this._endoWnafT1,n=this._endoWnafT2,s=0;s":""},ko.prototype.isInfinity=function(){return this.inf},ko.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var i=e.redSqr().redISub(this.x).redISub(t.x),r=e.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,r)},ko.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,i=this.x.redSqr(),r=t.redInvm(),n=i.redAdd(i).redIAdd(i).redIAdd(e).redMul(r),s=n.redSqr().redISub(this.x.redAdd(this.x)),o=n.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,o)},ko.prototype.getX=function(){return this.x.fromRed()},ko.prototype.getY=function(){return this.y.fromRed()},ko.prototype.mul=function(t){return t=new fo(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},ko.prototype.mulAdd=function(t,e,i){var r=[this,e],n=[t,i];return this.curve.endo?this.curve._endoWnafMulAdd(r,n):this.curve._wnafMulAdd(1,r,n,2)},ko.prototype.jmulAdd=function(t,e,i){var r=[this,e],n=[t,i];return this.curve.endo?this.curve._endoWnafMulAdd(r,n,!0):this.curve._wnafMulAdd(1,r,n,2,!0)},ko.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},ko.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var i=this.precomputed,r=function(t){return t.neg()};e.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(r)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(r)}}}return e},ko.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},Q(Ro,bo.BasePoint),Eo.prototype.jpoint=function(t,e,i){return new Ro(this,t,e,i)},Ro.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),i=this.x.redMul(e),r=this.y.redMul(e).redMul(t);return this.curve.point(i,r)},Ro.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Ro.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),i=this.z.redSqr(),r=this.x.redMul(e),n=t.x.redMul(i),s=this.y.redMul(e.redMul(t.z)),o=t.y.redMul(i.redMul(this.z)),a=r.redSub(n),h=s.redSub(o);if(0===a.cmpn(0))return 0!==h.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),f=u.redMul(a),l=r.redMul(u),d=h.redSqr().redIAdd(f).redISub(l).redISub(l),c=h.redMul(l.redISub(d)).redISub(s.redMul(f)),p=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(d,c,p)},Ro.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),i=this.x,r=t.x.redMul(e),n=this.y,s=t.y.redMul(e).redMul(this.z),o=i.redSub(r),a=n.redSub(s);if(0===o.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=o.redSqr(),u=h.redMul(o),f=i.redMul(h),l=a.redSqr().redIAdd(u).redISub(f).redISub(f),d=a.redMul(f.redISub(l)).redISub(n.redMul(u)),c=this.z.redMul(o);return this.curve.jpoint(l,d,c)},Ro.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var i=this;for(e=0;e=0)return!1;if(i.redIAdd(n),0===this.x.cmp(i))return!0}},Ro.prototype.inspect=function(){return this.isInfinity()?"":""},Ro.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var Ao;function xo(t){bo.call(this,"mont",t),this.a=new fo(t.a,16).toRed(this.red),this.b=new fo(t.b,16).toRed(this.red),this.i4=new fo(4).toRed(this.red).redInvm(),this.two=new fo(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function To(t,e,i){bo.BasePoint.call(this,t,"projective"),null===e&&null===i?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new fo(e,16),this.z=new fo(i,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}Q(xo,bo),Ao=xo,xo.prototype.validate=function(t){var e=t.normalize().x,i=e.redSqr(),r=i.redMul(e).redAdd(i.redMul(this.a)).redAdd(e);return 0===r.redSqrt().redSqr().cmp(r)},Q(To,bo.BasePoint),xo.prototype.decodePoint=function(t,e){return this.point(go.toArray(t,e),1)},xo.prototype.point=function(t,e){return new To(this,t,e)},xo.prototype.pointFromJSON=function(t){return To.fromJSON(this,t)},To.prototype.precompute=function(){},To.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},To.fromJSON=function(t,e){return new To(t,e[0],e[1]||t.one)},To.prototype.inspect=function(){return this.isInfinity()?"":""},To.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},To.prototype.dbl=function(){var t=this.x.redAdd(this.z).redSqr(),e=this.x.redSub(this.z).redSqr(),i=t.redSub(e),r=t.redMul(e),n=i.redMul(e.redAdd(this.curve.a24.redMul(i)));return this.curve.point(r,n)},To.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},To.prototype.diffAdd=function(t,e){var i=this.x.redAdd(this.z),r=this.x.redSub(this.z),n=t.x.redAdd(t.z),s=t.x.redSub(t.z).redMul(i),o=n.redMul(r),a=e.z.redMul(s.redAdd(o).redSqr()),h=e.x.redMul(s.redISub(o).redSqr());return this.curve.point(a,h)},To.prototype.mul=function(t){for(var e=t.clone(),i=this,r=this.curve.point(null,null),n=[];0!==e.cmpn(0);e.iushrn(1))n.push(e.andln(1));for(var s=n.length-1;s>=0;s--)0===n[s]?(i=i.diffAdd(r,this),r=r.dbl()):(r=i.diffAdd(r,this),i=i.dbl());return r},To.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},To.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},To.prototype.eq=function(t){return 0===this.getX().cmp(t.getX())},To.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},To.prototype.getX=function(){return this.normalize(),this.x.fromRed()};var Po;function Bo(t){this.twisted=1!=(0|t.a),this.mOneA=this.twisted&&-1==(0|t.a),this.extended=this.mOneA,bo.call(this,"edwards",t),this.a=new fo(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new fo(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new fo(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),this.oneC=1==(0|t.c)}function Io(t,e,i,r,n){bo.BasePoint.call(this,t,"projective"),null===e&&null===i&&null===r?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new fo(e,16),this.y=new fo(i,16),this.z=r?new fo(r,16):this.curve.one,this.t=n&&new fo(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.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()))))}go.assert,Q(Bo,bo),Po=Bo,Bo.prototype._mulA=function(t){return this.mOneA?t.redNeg():this.a.redMul(t)},Bo.prototype._mulC=function(t){return this.oneC?t:this.c.redMul(t)},Bo.prototype.jpoint=function(t,e,i,r){return this.point(t,e,i,r)},Bo.prototype.pointFromX=function(t,e){(t=new fo(t,16)).red||(t=t.toRed(this.red));var i=t.redSqr(),r=this.c2.redSub(this.a.redMul(i)),n=this.one.redSub(this.c2.redMul(this.d).redMul(i)),s=r.redMul(n.redInvm()),o=s.redSqrt();if(0!==o.redSqr().redSub(s).cmp(this.zero))throw new Error("invalid point");var a=o.fromRed().isOdd();return(e&&!a||!e&&a)&&(o=o.redNeg()),this.point(t,o)},Bo.prototype.pointFromY=function(t,e){(t=new fo(t,16)).red||(t=t.toRed(this.red));var i=t.redSqr(),r=i.redSub(this.c2),n=i.redMul(this.d).redMul(this.c2).redSub(this.a),s=r.redMul(n.redInvm());if(0===s.cmp(this.zero)){if(e)throw new Error("invalid point");return this.point(this.zero,t)}var o=s.redSqrt();if(0!==o.redSqr().redSub(s).cmp(this.zero))throw new Error("invalid point");return o.fromRed().isOdd()!==e&&(o=o.redNeg()),this.point(o,t)},Bo.prototype.validate=function(t){if(t.isInfinity())return!0;t.normalize();var e=t.x.redSqr(),i=t.y.redSqr(),r=e.redMul(this.a).redAdd(i),n=this.c2.redMul(this.one.redAdd(this.d.redMul(e).redMul(i)));return 0===r.cmp(n)},Q(Io,bo.BasePoint),Bo.prototype.pointFromJSON=function(t){return Io.fromJSON(this,t)},Bo.prototype.point=function(t,e,i,r){return new Io(this,t,e,i,r)},Io.fromJSON=function(t,e){return new Io(t,e[0],e[1],e[2])},Io.prototype.inspect=function(){return this.isInfinity()?"":""},Io.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},Io.prototype._extDbl=function(){var t=this.x.redSqr(),e=this.y.redSqr(),i=this.z.redSqr();i=i.redIAdd(i);var r=this.curve._mulA(t),n=this.x.redAdd(this.y).redSqr().redISub(t).redISub(e),s=r.redAdd(e),o=s.redSub(i),a=r.redSub(e),h=n.redMul(o),u=s.redMul(a),f=n.redMul(a),l=o.redMul(s);return this.curve.point(h,u,l,f)},Io.prototype._projDbl=function(){var t,e,i,r,n,s,o=this.x.redAdd(this.y).redSqr(),a=this.x.redSqr(),h=this.y.redSqr();if(this.curve.twisted){var u=(r=this.curve._mulA(a)).redAdd(h);this.zOne?(t=o.redSub(a).redSub(h).redMul(u.redSub(this.curve.two)),e=u.redMul(r.redSub(h)),i=u.redSqr().redSub(u).redSub(u)):(n=this.z.redSqr(),s=u.redSub(n).redISub(n),t=o.redSub(a).redISub(h).redMul(s),e=u.redMul(r.redSub(h)),i=u.redMul(s))}else r=a.redAdd(h),n=this.curve._mulC(this.z).redSqr(),s=r.redSub(n).redSub(n),t=this.curve._mulC(o.redISub(r)).redMul(s),e=this.curve._mulC(r).redMul(a.redISub(h)),i=r.redMul(s);return this.curve.point(t,e,i)},Io.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},Io.prototype._extAdd=function(t){var e=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),i=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),r=this.t.redMul(this.curve.dd).redMul(t.t),n=this.z.redMul(t.z.redAdd(t.z)),s=i.redSub(e),o=n.redSub(r),a=n.redAdd(r),h=i.redAdd(e),u=s.redMul(o),f=a.redMul(h),l=s.redMul(h),d=o.redMul(a);return this.curve.point(u,f,d,l)},Io.prototype._projAdd=function(t){var e,i,r=this.z.redMul(t.z),n=r.redSqr(),s=this.x.redMul(t.x),o=this.y.redMul(t.y),a=this.curve.d.redMul(s).redMul(o),h=n.redSub(a),u=n.redAdd(a),f=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(s).redISub(o),l=r.redMul(h).redMul(f);return this.curve.twisted?(e=r.redMul(u).redMul(o.redSub(this.curve._mulA(s))),i=h.redMul(u)):(e=r.redMul(u).redMul(o.redSub(s)),i=this.curve._mulC(h).redMul(u)),this.curve.point(l,e,i)},Io.prototype.add=function(t){return this.isInfinity()?t:t.isInfinity()?this:this.curve.extended?this._extAdd(t):this._projAdd(t)},Io.prototype.mul=function(t){return this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve._wnafMul(this,t)},Io.prototype.mulAdd=function(t,e,i){return this.curve._wnafMulAdd(1,[this,e],[t,i],2,!1)},Io.prototype.jmulAdd=function(t,e,i){return this.curve._wnafMulAdd(1,[this,e],[t,i],2,!0)},Io.prototype.normalize=function(){if(this.zOne)return this;var t=this.z.redInvm();return this.x=this.x.redMul(t),this.y=this.y.redMul(t),this.t&&(this.t=this.t.redMul(t)),this.z=this.curve.one,this.zOne=!0,this},Io.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},Io.prototype.getX=function(){return this.normalize(),this.x.fromRed()},Io.prototype.getY=function(){return this.normalize(),this.y.fromRed()},Io.prototype.eq=function(t){return this===t||0===this.getX().cmp(t.getX())&&0===this.getY().cmp(t.getY())},Io.prototype.eqXToP=function(t){var e=t.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(e))return!0;for(var i=t.clone(),r=this.curve.redN.redMul(this.z);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(e.redIAdd(r),0===this.x.cmp(e))return!0}},Io.prototype.toP=Io.prototype.normalize,Io.prototype.mixedAdd=Io.prototype.add;var qo={},Oo=qo;Oo.base=bo,Oo.short=So,Oo.mont=Ao,Oo.edwards=Po;var Lo={};function jo(t,e){return 55296==(64512&t.charCodeAt(e))&&!(e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1))}function Co(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function No(t){return 1===t.length?"0"+t:t}function Do(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}Lo.inherits=Q,Lo.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var i=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),n=0;n>6|192,i[r++]=63&s|128):jo(t,n)?(s=65536+((1023&s)<<10)+(1023&t.charCodeAt(++n)),i[r++]=s>>18|240,i[r++]=s>>12&63|128,i[r++]=s>>6&63|128,i[r++]=63&s|128):(i[r++]=s>>12|224,i[r++]=s>>6&63|128,i[r++]=63&s|128)}else for(n=0;n>>0}return n},Lo.split32=function(t,e){for(var i=new Array(4*t.length),r=0,n=0;r>>24,i[n+1]=s>>>16&255,i[n+2]=s>>>8&255,i[n+3]=255&s):(i[n+3]=s>>>24,i[n+2]=s>>>16&255,i[n+1]=s>>>8&255,i[n]=255&s)}return i},Lo.rotr32=function(t,e){return t>>>e|t<<32-e},Lo.rotl32=function(t,e){return t<>>32-e},Lo.sum32=function(t,e){return t+e>>>0},Lo.sum32_3=function(t,e,i){return t+e+i>>>0},Lo.sum32_4=function(t,e,i,r){return t+e+i+r>>>0},Lo.sum32_5=function(t,e,i,r,n){return t+e+i+r+n>>>0},Lo.sum64=function(t,e,i,r){var n=t[e],s=r+t[e+1]>>>0,o=(s>>0,t[e+1]=s},Lo.sum64_hi=function(t,e,i,r){return(e+r>>>0>>0},Lo.sum64_lo=function(t,e,i,r){return e+r>>>0},Lo.sum64_4_hi=function(t,e,i,r,n,s,o,a){var h=0,u=e;return h+=(u=u+r>>>0)>>0)>>0)>>0},Lo.sum64_4_lo=function(t,e,i,r,n,s,o,a){return e+r+s+a>>>0},Lo.sum64_5_hi=function(t,e,i,r,n,s,o,a,h,u){var f=0,l=e;return f+=(l=l+r>>>0)>>0)>>0)>>0)>>0},Lo.sum64_5_lo=function(t,e,i,r,n,s,o,a,h,u){return e+r+s+a+u>>>0},Lo.rotr64_hi=function(t,e,i){return(e<<32-i|t>>>i)>>>0},Lo.rotr64_lo=function(t,e,i){return(t<<32-i|e>>>i)>>>0},Lo.shr64_hi=function(t,e,i){return t>>>i},Lo.shr64_lo=function(t,e,i){return(t<<32-i|e>>>i)>>>0};var Uo={};function $o(){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}Uo.BlockHash=$o,$o.prototype.update=function(t,e){if(t=Lo.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var i=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-i,t.length),0===this.pending.length&&(this.pending=null),t=Lo.join32(t,0,t.length-i,this.endian);for(var r=0;r>>24&255,r[n++]=t>>>16&255,r[n++]=t>>>8&255,r[n++]=255&t}else for(r[n++]=255&t,r[n++]=t>>>8&255,r[n++]=t>>>16&255,r[n++]=t>>>24&255,r[n++]=0,r[n++]=0,r[n++]=0,r[n++]=0,s=8;s>>3},zo.g1_256=function(t){return Wo(t,17)^Wo(t,19)^t>>>10};var Zo,Vo=Lo.rotl32,Go=Lo.sum32,Yo=Lo.sum32_5,Xo=zo.ft_1,Jo=Uo.BlockHash,Qo=[1518500249,1859775393,2400959708,3395469782];function ta(){if(!(this instanceof ta))return new ta;Jo.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Lo.inherits(ta,Jo),Zo=ta,ta.blockSize=512,ta.outSize=160,ta.hmacStrength=80,ta.padLength=64,ta.prototype._update=function(t,e){for(var i=this.W,r=0;r<16;r++)i[r]=t[e+r];for(;rthis.blockSize&&(t=(new this.Hash).update(t).digest());for(var e=t.length;ethis.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(r=i,i=e,e=null),i&&(i=lo.toArray(i,r||"hex"),this._update(i));for(var n=[];n.length"};var yh={};function wh(t,e){if(t instanceof wh)return t;this._importDER(t,e)||(this.r=new fo(t.r,16),this.s=new fo(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}function Mh(){this.place=0}function _h(t,e){var i=t[e.place++];if(!(128&i))return i;var r=15&i;if(0===r||r>4)return!1;for(var n=0,s=0,o=e.place;s>>=0;return!(n<=127)&&(e.place=o,n)}function Sh(t){for(var e=0,i=t.length-1;!t[e]&&!(128&t[e+1])&&e>>3);for(t.push(128|i);--i;)t.push(e>>>(i<<3)&255);t.push(e)}}go.assert,yh=wh,wh.prototype._importDER=function(t,e){t=go.toArray(t,e);var i=new Mh;if(48!==t[i.place++])return!1;var r=_h(t,i);if(!1===r)return!1;if(r+i.place!==t.length)return!1;if(2!==t[i.place++])return!1;var n=_h(t,i);if(!1===n)return!1;var s=t.slice(i.place,n+i.place);if(i.place+=n,2!==t[i.place++])return!1;var o=_h(t,i);if(!1===o)return!1;if(t.length!==o+i.place)return!1;var a=t.slice(i.place,o+i.place);if(0===s[0]){if(!(128&s[1]))return!1;s=s.slice(1)}if(0===a[0]){if(!(128&a[1]))return!1;a=a.slice(1)}return this.r=new fo(s),this.s=new fo(a),this.recoveryParam=null,!0},wh.prototype.toDER=function(t){var e=this.r.toArray(),i=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&i[0]&&(i=[0].concat(i)),e=Sh(e),i=Sh(i);!(i[0]||128&i[1]);)i=i.slice(1);var r=[2];Eh(r,e.length),(r=r.concat(e)).push(2),Eh(r,i.length);var n=r.concat(i),s=[48];return Eh(s,n.length),s=s.concat(n),go.encode(s,t)};var kh,Rh=(go.assert,vh);function Ah(t){if(!(this instanceof Ah))return new Ah(t);"string"==typeof t&&(t=lh[t]),t instanceof lh.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}kh=Ah,Ah.prototype.keyPair=function(t){return new Rh(this,t)},Ah.prototype.keyFromPrivate=function(t,e){return Rh.fromPrivate(this,t,e)},Ah.prototype.keyFromPublic=function(t,e){return Rh.fromPublic(this,t,e)},Ah.prototype.genKeyPair=function(t){t||(t={});for(var e=new mh({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||ss(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),r=this.n.sub(new fo(2));;){var n=new fo(e.generate(i));if(!(n.cmp(r)>0))return n.iaddn(1),this.keyFromPrivate(n)}},Ah.prototype._truncateToN=function(t,e){var i=8*t.byteLength()-this.n.bitLength();return i>0&&(t=t.ushrn(i)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},Ah.prototype.sign=function(t,e,i,r){"object"==typeof i&&(r=i,i=null),r||(r={}),e=this.keyFromPrivate(e,i),t=this._truncateToN(new fo(t,16));for(var n=this.n.byteLength(),s=e.getPrivate().toArray("be",n),o=t.toArray("be",n),a=new mh({hash:this.hash,entropy:s,nonce:o,pers:r.pers,persEnc:r.persEnc||"utf8"}),h=this.n.sub(new fo(1)),u=0;;u++){var f=r.k?r.k(u):new fo(a.generate(this.n.byteLength()));if(!((f=this._truncateToN(f,!0)).cmpn(1)<=0||f.cmp(h)>=0)){var l=this.g.mul(f);if(!l.isInfinity()){var d=l.getX(),c=d.umod(this.n);if(0!==c.cmpn(0)){var p=f.invm(this.n).mul(c.mul(e.getPrivate()).iadd(t));if(0!==(p=p.umod(this.n)).cmpn(0)){var m=(l.getY().isOdd()?1:0)|(0!==d.cmp(c)?2:0);return r.canonical&&p.cmp(this.nh)>0&&(p=this.n.sub(p),m^=1),new yh({r:c,s:p,recoveryParam:m})}}}}}},Ah.prototype.verify=function(t,e,i,r){t=this._truncateToN(new fo(t,16)),i=this.keyFromPublic(i,r);var n=(e=new yh(e,"hex")).r,s=e.s;if(n.cmpn(1)<0||n.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var o,a=s.invm(this.n),h=a.mul(t).umod(this.n),u=a.mul(n).umod(this.n);return this.curve._maxwellTrick?!(o=this.g.jmulAdd(h,i.getPublic(),u)).isInfinity()&&o.eqXToP(n):!(o=this.g.mulAdd(h,i.getPublic(),u)).isInfinity()&&0===o.getX().umod(this.n).cmp(n)},Ah.prototype.recoverPubKey=function(t,e,i,r){e=new yh(e,r);var n=this.n,s=new fo(t),o=e.r,a=e.s,h=1&i,u=i>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");o=u?this.curve.pointFromX(o.add(this.curve.n),h):this.curve.pointFromX(o,h);var f=e.r.invm(n),l=n.sub(s).mul(f).umod(n),d=a.mul(f).umod(n);return this.g.mulAdd(l,o,d)},Ah.prototype.getKeyRecoveryParam=function(t,e,i,r){if(null!==(e=new yh(e,r)).recoveryParam)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(t,e,n)}catch(t){continue}if(s.eq(i))return n}throw new Error("Unable to find valid recovery factor")};var xh={},Th=(go.assert,go.parseBytes),Ph=go.cachedProperty;function Bh(t,e){this.eddsa=t,this._secret=Th(e.secret),t.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=Th(e.pub)}Bh.fromPublic=function(t,e){return e instanceof Bh?e:new Bh(t,{pub:e})},Bh.fromSecret=function(t,e){return e instanceof Bh?e:new Bh(t,{secret:e})},Bh.prototype.secret=function(){return this._secret},Ph(Bh,"pubBytes",(function(){return this.eddsa.encodePoint(this.pub())})),Ph(Bh,"pub",(function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())})),Ph(Bh,"privBytes",(function(){var t=this.eddsa,e=this.hash(),i=t.encodingLength-1,r=e.slice(0,t.encodingLength);return r[0]&=248,r[i]&=127,r[i]|=64,r})),Ph(Bh,"priv",(function(){return this.eddsa.decodeInt(this.privBytes())})),Ph(Bh,"hash",(function(){return this.eddsa.hash().update(this.secret()).digest()})),Ph(Bh,"messagePrefix",(function(){return this.hash().slice(this.eddsa.encodingLength)})),Bh.prototype.sign=function(t){return this.eddsa.sign(t,this)},Bh.prototype.verify=function(t,e){return this.eddsa.verify(t,e,this)},Bh.prototype.getSecret=function(t){return go.encode(this.secret(),t)},Bh.prototype.getPublic=function(t){return go.encode(this.pubBytes(),t)},xh=Bh;var Ih={},qh=(go.assert,go.cachedProperty),Oh=go.parseBytes;function Lh(t,e){this.eddsa=t,"object"!=typeof e&&(e=Oh(e)),Array.isArray(e)&&(e={R:e.slice(0,t.encodingLength),S:e.slice(t.encodingLength)}),t.isPoint(e.R)&&(this._R=e.R),e.S instanceof fo&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}qh(Lh,"S",(function(){return this.eddsa.decodeInt(this.Sencoded())})),qh(Lh,"R",(function(){return this.eddsa.decodePoint(this.Rencoded())})),qh(Lh,"Rencoded",(function(){return this.eddsa.encodePoint(this.R())})),qh(Lh,"Sencoded",(function(){return this.eddsa.encodeInt(this.S())})),Lh.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},Lh.prototype.toHex=function(){return go.encode(this.toBytes(),"hex").toUpperCase()},Ih=Lh;var jh,Ch=(go.assert,go.parseBytes);function Nh(t){if(!(this instanceof Nh))return new Nh(t);t=lh[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=hh.sha512}jh=Nh,Nh.prototype.sign=function(t,e){t=Ch(t);var i=this.keyFromSecret(e),r=this.hashInt(i.messagePrefix(),t),n=this.g.mul(r),s=this.encodePoint(n),o=this.hashInt(s,i.pubBytes(),t).mul(i.priv()),a=r.add(o).umod(this.curve.n);return this.makeSignature({R:n,S:a,Rencoded:s})},Nh.prototype.verify=function(t,e,i){t=Ch(t),e=this.makeSignature(e);var r=this.keyFromPublic(i),n=this.hashInt(e.Rencoded(),r.pubBytes(),t),s=this.g.mul(e.S());return e.R().add(r.pub().mul(n)).eq(s)},Nh.prototype.hashInt=function(){for(var t=this.hash(),e=0;e=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return r}function o(t,e,i,r){for(var n=0,s=Math.min(t.length,i),o=e;o=49?a-49+10:a>=17?a-17+10:a}return n}r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,e){return t.cmp(e)>0?t:e},r.min=function(t,e){return t.cmp(e)<0?t:e},r.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===e?this._parseHex(t,r):this._parseBase(t,e,r),"-"===t[0]&&(this.negative=1),this.strip(),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initArray=function(t,e,i){if(t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r=0;r-=3)s=t[r]|t[r-1]<<8|t[r-2]<<16,this.words[n]|=s<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===i)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this.strip()},r.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=6)n=s(t,i,i+6),this.words[r]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,r++);i+6!==e&&(n=s(t,e,i+6),this.words[r]|=n<>>26-o&4194303),this.strip()},r.prototype._parseBase=function(t,e,i){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=e)r++;r--,n=n/e|0;for(var s=t.length-i,a=s%r,h=Math.min(s,s-a)+i,u=0,f=i;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},r.prototype.inspect=function(){return(this.red?""};var a=["","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"],h=[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],u=[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 f(t,e,i){i.negative=e.negative^t.negative;var r=t.length+e.length|0;i.length=r,r=r-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;i.words[0]=a;for(var u=1;u>>26,l=67108863&h,d=Math.min(u,e.length-1),c=Math.max(0,u-t.length+1);c<=d;c++){var p=u-c|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[c])+l)/67108864|0,l=67108863&o}i.words[u]=0|l,h=0|f}return 0!==h?i.words[u]=0|h:i.length--,i.strip()}r.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var r=0,n=0,s=0;s>>24-r&16777215)||s!==this.length-1?a[6-f.length]+f+i:f+i,(r+=2)>=26&&(r-=26,s--)}for(0!==n&&(i=n.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var l=h[t],d=u[t];i="";var c=this.clone();for(c.negative=0;!c.isZero();){var p=c.modn(d).toString(t);i=(c=c.idivn(d)).isZero()?p+i:a[l-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length,0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16)},r.prototype.toBuffer=function(t,e){return this.toArrayLike(n,t,e)},r.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},r.prototype.toArrayLike=function(t,e,i){var r=this.byteLength(),n=i||Math.max(1,r);this.strip();var s,o,a="le"===e,h=new t(n),u=this.clone();if(a){for(o=0;!u.isZero();o++)s=u.andln(255),u.iushrn(8),h[o]=s;for(;o=4096&&(i+=13,e>>>=13),e>=64&&(i+=7,e>>>=7),e>=8&&(i+=4,e>>>=4),e>=2&&(i+=2,e>>>=2),i+e},r.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,i=0;return 0==(8191&e)&&(i+=13,e>>>=13),0==(127&e)&&(i+=7,e>>>=7),0==(15&e)&&(i+=4,e>>>=4),0==(3&e)&&(i+=2,e>>>=2),0==(1&e)&&i++,i},r.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var i=0;it.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var e,i;this.length>t.length?(e=this,i=t):(e=t,i=this);for(var r=0;rt.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-i),this.strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,e){var i=t/26|0,r=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(i=this,r=t):(i=t,r=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i,r,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(i=this,r=t):(i=t,r=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,c=0|o[1],p=8191&c,m=c>>>13,g=0|o[2],v=8191&g,b=g>>>13,y=0|o[3],w=8191&y,M=y>>>13,_=0|o[4],S=8191&_,E=_>>>13,k=0|o[5],R=8191&k,A=k>>>13,x=0|o[6],T=8191&x,P=x>>>13,B=0|o[7],I=8191&B,q=B>>>13,O=0|o[8],L=8191&O,j=O>>>13,C=0|o[9],N=8191&C,D=C>>>13,U=0|a[0],$=8191&U,z=U>>>13,W=0|a[1],F=8191&W,K=W>>>13,H=0|a[2],Z=8191&H,V=H>>>13,G=0|a[3],Y=8191&G,X=G>>>13,J=0|a[4],Q=8191&J,tt=J>>>13,et=0|a[5],it=8191&et,rt=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,ft=0|a[8],lt=8191&ft,dt=ft>>>13,ct=0|a[9],pt=8191&ct,mt=ct>>>13;i.negative=t.negative^e.negative,i.length=19;var gt=(u+(r=Math.imul(l,$))|0)+((8191&(n=(n=Math.imul(l,z))+Math.imul(d,$)|0))<<13)|0;u=((s=Math.imul(d,z))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(p,$),n=(n=Math.imul(p,z))+Math.imul(m,$)|0,s=Math.imul(m,z);var vt=(u+(r=r+Math.imul(l,F)|0)|0)+((8191&(n=(n=n+Math.imul(l,K)|0)+Math.imul(d,F)|0))<<13)|0;u=((s=s+Math.imul(d,K)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(v,$),n=(n=Math.imul(v,z))+Math.imul(b,$)|0,s=Math.imul(b,z),r=r+Math.imul(p,F)|0,n=(n=n+Math.imul(p,K)|0)+Math.imul(m,F)|0,s=s+Math.imul(m,K)|0;var bt=(u+(r=r+Math.imul(l,Z)|0)|0)+((8191&(n=(n=n+Math.imul(l,V)|0)+Math.imul(d,Z)|0))<<13)|0;u=((s=s+Math.imul(d,V)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(w,$),n=(n=Math.imul(w,z))+Math.imul(M,$)|0,s=Math.imul(M,z),r=r+Math.imul(v,F)|0,n=(n=n+Math.imul(v,K)|0)+Math.imul(b,F)|0,s=s+Math.imul(b,K)|0,r=r+Math.imul(p,Z)|0,n=(n=n+Math.imul(p,V)|0)+Math.imul(m,Z)|0,s=s+Math.imul(m,V)|0;var yt=(u+(r=r+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,X)|0)+Math.imul(d,Y)|0))<<13)|0;u=((s=s+Math.imul(d,X)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(S,$),n=(n=Math.imul(S,z))+Math.imul(E,$)|0,s=Math.imul(E,z),r=r+Math.imul(w,F)|0,n=(n=n+Math.imul(w,K)|0)+Math.imul(M,F)|0,s=s+Math.imul(M,K)|0,r=r+Math.imul(v,Z)|0,n=(n=n+Math.imul(v,V)|0)+Math.imul(b,Z)|0,s=s+Math.imul(b,V)|0,r=r+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,X)|0;var wt=(u+(r=r+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(d,Q)|0))<<13)|0;u=((s=s+Math.imul(d,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(R,$),n=(n=Math.imul(R,z))+Math.imul(A,$)|0,s=Math.imul(A,z),r=r+Math.imul(S,F)|0,n=(n=n+Math.imul(S,K)|0)+Math.imul(E,F)|0,s=s+Math.imul(E,K)|0,r=r+Math.imul(w,Z)|0,n=(n=n+Math.imul(w,V)|0)+Math.imul(M,Z)|0,s=s+Math.imul(M,V)|0,r=r+Math.imul(v,Y)|0,n=(n=n+Math.imul(v,X)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,X)|0,r=r+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var Mt=(u+(r=r+Math.imul(l,it)|0)|0)+((8191&(n=(n=n+Math.imul(l,rt)|0)+Math.imul(d,it)|0))<<13)|0;u=((s=s+Math.imul(d,rt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(T,$),n=(n=Math.imul(T,z))+Math.imul(P,$)|0,s=Math.imul(P,z),r=r+Math.imul(R,F)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(A,F)|0,s=s+Math.imul(A,K)|0,r=r+Math.imul(S,Z)|0,n=(n=n+Math.imul(S,V)|0)+Math.imul(E,Z)|0,s=s+Math.imul(E,V)|0,r=r+Math.imul(w,Y)|0,n=(n=n+Math.imul(w,X)|0)+Math.imul(M,Y)|0,s=s+Math.imul(M,X)|0,r=r+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,tt)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,tt)|0,r=r+Math.imul(p,it)|0,n=(n=n+Math.imul(p,rt)|0)+Math.imul(m,it)|0,s=s+Math.imul(m,rt)|0;var _t=(u+(r=r+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(d,st)|0))<<13)|0;u=((s=s+Math.imul(d,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(I,$),n=(n=Math.imul(I,z))+Math.imul(q,$)|0,s=Math.imul(q,z),r=r+Math.imul(T,F)|0,n=(n=n+Math.imul(T,K)|0)+Math.imul(P,F)|0,s=s+Math.imul(P,K)|0,r=r+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,V)|0)+Math.imul(A,Z)|0,s=s+Math.imul(A,V)|0,r=r+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,X)|0,r=r+Math.imul(w,Q)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(M,Q)|0,s=s+Math.imul(M,tt)|0,r=r+Math.imul(v,it)|0,n=(n=n+Math.imul(v,rt)|0)+Math.imul(b,it)|0,s=s+Math.imul(b,rt)|0,r=r+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(r=r+Math.imul(l,ht)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((s=s+Math.imul(d,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(L,$),n=(n=Math.imul(L,z))+Math.imul(j,$)|0,s=Math.imul(j,z),r=r+Math.imul(I,F)|0,n=(n=n+Math.imul(I,K)|0)+Math.imul(q,F)|0,s=s+Math.imul(q,K)|0,r=r+Math.imul(T,Z)|0,n=(n=n+Math.imul(T,V)|0)+Math.imul(P,Z)|0,s=s+Math.imul(P,V)|0,r=r+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,X)|0,r=r+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(E,Q)|0,s=s+Math.imul(E,tt)|0,r=r+Math.imul(w,it)|0,n=(n=n+Math.imul(w,rt)|0)+Math.imul(M,it)|0,s=s+Math.imul(M,rt)|0,r=r+Math.imul(v,st)|0,n=(n=n+Math.imul(v,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,r=r+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,ut)|0;var Et=(u+(r=r+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,dt)|0)+Math.imul(d,lt)|0))<<13)|0;u=((s=s+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(N,$),n=(n=Math.imul(N,z))+Math.imul(D,$)|0,s=Math.imul(D,z),r=r+Math.imul(L,F)|0,n=(n=n+Math.imul(L,K)|0)+Math.imul(j,F)|0,s=s+Math.imul(j,K)|0,r=r+Math.imul(I,Z)|0,n=(n=n+Math.imul(I,V)|0)+Math.imul(q,Z)|0,s=s+Math.imul(q,V)|0,r=r+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,X)|0,r=r+Math.imul(R,Q)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(A,Q)|0,s=s+Math.imul(A,tt)|0,r=r+Math.imul(S,it)|0,n=(n=n+Math.imul(S,rt)|0)+Math.imul(E,it)|0,s=s+Math.imul(E,rt)|0,r=r+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(M,st)|0,s=s+Math.imul(M,ot)|0,r=r+Math.imul(v,ht)|0,n=(n=n+Math.imul(v,ut)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ut)|0,r=r+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,dt)|0;var kt=(u+(r=r+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(d,pt)|0))<<13)|0;u=((s=s+Math.imul(d,mt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(N,F),n=(n=Math.imul(N,K))+Math.imul(D,F)|0,s=Math.imul(D,K),r=r+Math.imul(L,Z)|0,n=(n=n+Math.imul(L,V)|0)+Math.imul(j,Z)|0,s=s+Math.imul(j,V)|0,r=r+Math.imul(I,Y)|0,n=(n=n+Math.imul(I,X)|0)+Math.imul(q,Y)|0,s=s+Math.imul(q,X)|0,r=r+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(P,Q)|0,s=s+Math.imul(P,tt)|0,r=r+Math.imul(R,it)|0,n=(n=n+Math.imul(R,rt)|0)+Math.imul(A,it)|0,s=s+Math.imul(A,rt)|0,r=r+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(E,st)|0,s=s+Math.imul(E,ot)|0,r=r+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(M,ht)|0,s=s+Math.imul(M,ut)|0,r=r+Math.imul(v,lt)|0,n=(n=n+Math.imul(v,dt)|0)+Math.imul(b,lt)|0,s=s+Math.imul(b,dt)|0;var Rt=(u+(r=r+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(N,Z),n=(n=Math.imul(N,V))+Math.imul(D,Z)|0,s=Math.imul(D,V),r=r+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(j,Y)|0,s=s+Math.imul(j,X)|0,r=r+Math.imul(I,Q)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(q,Q)|0,s=s+Math.imul(q,tt)|0,r=r+Math.imul(T,it)|0,n=(n=n+Math.imul(T,rt)|0)+Math.imul(P,it)|0,s=s+Math.imul(P,rt)|0,r=r+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(A,st)|0,s=s+Math.imul(A,ot)|0,r=r+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(E,ht)|0,s=s+Math.imul(E,ut)|0,r=r+Math.imul(w,lt)|0,n=(n=n+Math.imul(w,dt)|0)+Math.imul(M,lt)|0,s=s+Math.imul(M,dt)|0;var At=(u+(r=r+Math.imul(v,pt)|0)|0)+((8191&(n=(n=n+Math.imul(v,mt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((s=s+Math.imul(b,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(N,Y),n=(n=Math.imul(N,X))+Math.imul(D,Y)|0,s=Math.imul(D,X),r=r+Math.imul(L,Q)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(j,Q)|0,s=s+Math.imul(j,tt)|0,r=r+Math.imul(I,it)|0,n=(n=n+Math.imul(I,rt)|0)+Math.imul(q,it)|0,s=s+Math.imul(q,rt)|0,r=r+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,ot)|0,r=r+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(A,ht)|0,s=s+Math.imul(A,ut)|0,r=r+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,dt)|0)+Math.imul(E,lt)|0,s=s+Math.imul(E,dt)|0;var xt=(u+(r=r+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((s=s+Math.imul(M,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(N,Q),n=(n=Math.imul(N,tt))+Math.imul(D,Q)|0,s=Math.imul(D,tt),r=r+Math.imul(L,it)|0,n=(n=n+Math.imul(L,rt)|0)+Math.imul(j,it)|0,s=s+Math.imul(j,rt)|0,r=r+Math.imul(I,st)|0,n=(n=n+Math.imul(I,ot)|0)+Math.imul(q,st)|0,s=s+Math.imul(q,ot)|0,r=r+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,ut)|0,r=r+Math.imul(R,lt)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(A,lt)|0,s=s+Math.imul(A,dt)|0;var Tt=(u+(r=r+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(E,pt)|0))<<13)|0;u=((s=s+Math.imul(E,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(N,it),n=(n=Math.imul(N,rt))+Math.imul(D,it)|0,s=Math.imul(D,rt),r=r+Math.imul(L,st)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(j,st)|0,s=s+Math.imul(j,ot)|0,r=r+Math.imul(I,ht)|0,n=(n=n+Math.imul(I,ut)|0)+Math.imul(q,ht)|0,s=s+Math.imul(q,ut)|0,r=r+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,dt)|0)+Math.imul(P,lt)|0,s=s+Math.imul(P,dt)|0;var Pt=(u+(r=r+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((s=s+Math.imul(A,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(N,st),n=(n=Math.imul(N,ot))+Math.imul(D,st)|0,s=Math.imul(D,ot),r=r+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,ut)|0)+Math.imul(j,ht)|0,s=s+Math.imul(j,ut)|0,r=r+Math.imul(I,lt)|0,n=(n=n+Math.imul(I,dt)|0)+Math.imul(q,lt)|0,s=s+Math.imul(q,dt)|0;var Bt=(u+(r=r+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((s=s+Math.imul(P,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(N,ht),n=(n=Math.imul(N,ut))+Math.imul(D,ht)|0,s=Math.imul(D,ut),r=r+Math.imul(L,lt)|0,n=(n=n+Math.imul(L,dt)|0)+Math.imul(j,lt)|0,s=s+Math.imul(j,dt)|0;var It=(u+(r=r+Math.imul(I,pt)|0)|0)+((8191&(n=(n=n+Math.imul(I,mt)|0)+Math.imul(q,pt)|0))<<13)|0;u=((s=s+Math.imul(q,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(N,lt),n=(n=Math.imul(N,dt))+Math.imul(D,lt)|0,s=Math.imul(D,dt);var qt=(u+(r=r+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,mt)|0)+Math.imul(j,pt)|0))<<13)|0;u=((s=s+Math.imul(j,mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863;var Ot=(u+(r=Math.imul(N,pt))|0)+((8191&(n=(n=Math.imul(N,mt))+Math.imul(D,pt)|0))<<13)|0;return u=((s=Math.imul(D,mt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=vt,h[2]=bt,h[3]=yt,h[4]=wt,h[5]=Mt,h[6]=_t,h[7]=St,h[8]=Et,h[9]=kt,h[10]=Rt,h[11]=At,h[12]=xt,h[13]=Tt,h[14]=Pt,h[15]=Bt,h[16]=It,h[17]=qt,h[18]=Ot,0!==u&&(h[19]=u,i.length++),i};function d(t,e,i){return(new c).mulp(t,e,i)}function c(t,e){this.x=t,this.y=e}Math.imul||(l=f),r.prototype.mulTo=function(t,e){var i=this.length+t.length;return 10===this.length&&10===t.length?l(this,t,e):i<63?f(this,t,e):i<1024?function(t,e,i){i.negative=e.negative^t.negative,i.length=t.length+e.length;for(var r=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}i.words[s]=a,r=o,o=n}return 0!==r?i.words[s]=r:i.length--,i.strip()}(this,t,e):d(this,t,e)},c.prototype.makeRBT=function(t){for(var e=new Array(t),i=r.prototype._countBits(t)-1,n=0;n>=1;return r},c.prototype.permute=function(t,e,i,r,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*s+1]=8191&n,n>>>=13;for(s=2*e;s>=26,e+=r/67108864|0,e+=n>>>26,this.words[i]=67108863&n}return 0!==e&&(this.words[i]=e,this.length++),this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),i=0;i>>n}return e}(t);if(0===e.length)return new r(1);for(var i=this,n=0;n>>26-i<<26-i;if(0!==i){var s=0;for(e=0;e>>26-i}s&&(this.words[e]=s,this.length++)}if(0!==r){for(e=this.length-1;e>=0;e--)this.words[e+r]=this.words[e];for(e=0;e>>n<s)for(this.length-=s,h=0;h=0&&(0!==u||h>=r);h--){var f=0|this.words[h];this.words[h]=u<<26-n|f>>>n,u=f&o}return a&&0!==u&&(a.words[a.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},r.prototype.ishrn=function(t,e,i){return this.iushrn(t,e,i)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){var e=t%26,i=(t-e)/26,r=1<>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},r.prototype.isubn=function(t){if(t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(a/67108864|0),this.words[r+i]=67108863&n}for(;r>26,this.words[r+i]=67108863&n;if(0===o)return this.strip();for(o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},r.prototype._wordDiv=function(t,e){var i=(this.length,t.length),n=this.clone(),s=t,o=0|s.words[s.length-1];0!=(i=26-this._countBits(o))&&(s=s.ushln(i),n.iushln(i),o=0|s.words[s.length-1]);var a,h=n.length-s.length;if("mod"!==e){(a=new r(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u=0;l--){var d=67108864*(0|n.words[s.length+l])+(0|n.words[s.length+l-1]);for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(s,d,l);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(s,1,l),n.isZero()||(n.negative^=1);a&&(a.words[l]=d)}return a&&a.strip(),n.strip(),"div"!==e&&0!==i&&n.iushrn(i),{div:a||null,mod:n}},r.prototype.divmod=function(t,e,i){return this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),"mod"!==e&&(n=o.div.neg()),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),e),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new r(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var i=0!==e.div.negative?e.mod.isub(t):e.mod,r=t.ushrn(1),n=t.andln(1),s=i.cmp(r);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},r.prototype.modn=function(t){for(var e=(1<<26)%t,i=0,r=this.length-1;r>=0;r--)i=(e*i+(0|this.words[r]))%t;return i},r.prototype.idivn=function(t){for(var e=0,i=this.length-1;i>=0;i--){var r=(0|this.words[i])+67108864*e;this.words[i]=r/t|0,e=r%t}return this.strip()},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new r(1),s=new r(0),o=new r(0),a=new r(1),h=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++h;for(var u=i.clone(),f=e.clone();!e.isZero();){for(var l=0,d=1;0==(e.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(e.iushrn(l);l-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(u),s.isub(f)),n.iushrn(1),s.iushrn(1);for(var c=0,p=1;0==(i.words[0]&p)&&c<26;++c,p<<=1);if(c>0)for(i.iushrn(c);c-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(u),a.isub(f)),o.iushrn(1),a.iushrn(1);e.cmp(i)>=0?(e.isub(i),n.isub(o),s.isub(a)):(i.isub(e),o.isub(n),a.isub(s))}return{a:o,b:a,gcd:i.iushln(h)}},r.prototype._invmp=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new r(1),o=new r(0),a=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var h=0,u=1;0==(e.words[0]&u)&&h<26;++h,u<<=1);if(h>0)for(e.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(a),s.iushrn(1);for(var f=0,l=1;0==(i.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(i.iushrn(f);f-- >0;)o.isOdd()&&o.iadd(a),o.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o)):(i.isub(e),o.isub(s))}return(n=0===e.cmpn(1)?s:o).cmpn(0)<0&&n.iadd(t),n},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),i=t.clone();e.negative=0,i.negative=0;for(var r=0;e.isEven()&&i.isEven();r++)e.iushrn(1),i.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;i.isEven();)i.iushrn(1);var n=e.cmp(i);if(n<0){var s=e;e=i,i=s}else if(0===n||0===i.cmpn(1))break;e.isub(i)}return i.iushln(r)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){var e=t%26,i=(t-e)/26,r=1<>>26,o&=67108863,this.words[s]=o}return 0!==n&&(this.words[s]=n,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t);var r=0|this.words[0];e=r===t?0:rt.length)return 1;if(this.length=0;i--){var r=0|this.words[i],n=0|t.words[i];if(r!==n){rn&&(e=1);break}}return e},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new M(t)},r.prototype.toRed=function(t){return t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return this._forceRed(t)},r.prototype.redAdd=function(t){return this.red.add(this,t)},r.prototype.redIAdd=function(t){return this.red.iadd(this,t)},r.prototype.redSub=function(t){return this.red.sub(this,t)},r.prototype.redISub=function(t){return this.red.isub(this,t)},r.prototype.redShl=function(t){return this.red.shl(this,t)},r.prototype.redMul=function(t){return this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return this.red._verify1(this),this.red.pow(this,t)};var p={k256:null,p224:null,p192:null,p25519:null};function m(t,e){this.name=t,this.p=new r(e,16),this.n=this.p.bitLength(),this.k=new r(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 v(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function y(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(t){if("string"==typeof t){var e=r._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function _(t){M.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(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 t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},m.prototype.ireduce=function(t){var e,i=t;do{this.split(i,this.tmp),e=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(e>this.n);var r=e0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},m.prototype.split=function(t,e){t.iushrn(this.n,0,e)},m.prototype.imulK=function(t){return t.imul(this.k)},i(g,m),g.prototype.split=function(t,e){for(var i=Math.min(t.length,9),r=0;r>>22,n=s}n>>>=22,t.words[r-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},g.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,i=0;i>>=26,t.words[i]=n,e=r}return 0!==e&&(t.words[t.length++]=e),t},r._prime=function(t){if(p[t])return p[t];var e;if("k256"===t)e=new g;else if("p224"===t)e=new v;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new y}return p[t]=e,e},M.prototype._verify1=function(t){},M.prototype._verify2=function(t,e){},M.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},M.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},M.prototype.add=function(t,e){this._verify2(t,e);var i=t.add(e);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},M.prototype.iadd=function(t,e){this._verify2(t,e);var i=t.iadd(e);return i.cmp(this.m)>=0&&i.isub(this.m),i},M.prototype.sub=function(t,e){this._verify2(t,e);var i=t.sub(e);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},M.prototype.isub=function(t,e){this._verify2(t,e);var i=t.isub(e);return i.cmpn(0)<0&&i.iadd(this.m),i},M.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},M.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},M.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},M.prototype.isqr=function(t){return this.imul(t,t.clone())},M.prototype.sqr=function(t){return this.mul(t,t)},M.prototype.sqrt=function(t){if(t.isZero())return t.clone();if(3===this.m.andln(3)){var e=this.m.add(new r(1)).iushrn(2);return this.pow(t,e)}for(var i=this.m.subn(1),n=0;!i.isZero()&&0===i.andln(1);)n++,i.iushrn(1);var s=new r(1).toRed(this),o=s.redNeg(),a=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new r(2*h*h).toRed(this);0!==this.pow(h,a).cmp(o);)h.redIAdd(o);for(var u=this.pow(h,i),f=this.pow(t,i.addn(1).iushrn(1)),l=this.pow(t,i),d=n;0!==l.cmp(s);){for(var c=l,p=0;0!==c.cmp(s);p++)c=c.redSqr();var m=this.pow(u,new r(1).iushln(d-p-1));f=f.redMul(m),u=m.redSqr(),l=l.redMul(u),d=p}return f},M.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},M.prototype.pow=function(t,e){if(e.isZero())return new r(1).toRed(this);if(0===e.cmpn(1))return t.clone();var i=new Array(16);i[0]=new r(1).toRed(this),i[1]=t;for(var n=2;n=0;n--){for(var u=e.words[n],f=h-1;f>=0;f--){var l=u>>f&1;s!==i[0]&&(s=this.sqr(s)),0!==l||0!==o?(o<<=1,o|=l,(4==++a||0===n&&0===f)&&(s=this.mul(s,i[o]),a=0,o=0)):a=0}h=26}return s},M.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},M.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},r.mont=function(t){return new _(t)},i(_,M),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(e),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new r(0)._forceRed(this);var i=t.mul(e),n=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=i.isub(n).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}($h,this),$h=$h.exports;var zh={};(function(t){(function(){"use strict";var e,i=M({}),r=i.Buffer,n={};for(e in i)i.hasOwnProperty(e)&&"SlowBuffer"!==e&&"Buffer"!==e&&(n[e]=i[e]);var s=n.Buffer={};for(e in r)r.hasOwnProperty(e)&&"allocUnsafe"!==e&&"allocUnsafeSlow"!==e&&(s[e]=r[e]);if(n.Buffer.prototype=r.prototype,s.from&&s.from!==Uint8Array.from||(s.from=function(t,e,i){if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof t);if(t&&void 0===t.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);return r(t,e,i)}),s.alloc||(s.alloc=function(t,e,i){if("number"!=typeof t)throw new TypeError('The "size" argument must be of type number. Received type '+typeof t);if(t<0||t>=2*(1<<30))throw new RangeError('The value "'+t+'" is invalid for option "size"');var n=r(t);return e&&0!==e.length?"string"==typeof i?n.fill(e,i):n.fill(e):n.fill(0),n}),!n.kStringMaxLength)try{n.kStringMaxLength=t.binding("buffer").kStringMaxLength}catch(jf){}n.constants||(n.constants={MAX_LENGTH:n.kMaxLength},n.kStringMaxLength&&(n.constants.MAX_STRING_LENGTH=n.kStringMaxLength)),zh=n}).call(this)}).call(this,D);var Wh={};function Fh(t){this._reporterState={obj:null,path:[],options:t||{},errors:[]}}function Kh(t,e){this.path=t,this.rethrow(e)}Wh.Reporter=Fh,Fh.prototype.isError=function(t){return t instanceof Kh},Fh.prototype.save=function(){const t=this._reporterState;return{obj:t.obj,pathLen:t.path.length}},Fh.prototype.restore=function(t){const e=this._reporterState;e.obj=t.obj,e.path=e.path.slice(0,t.pathLen)},Fh.prototype.enterKey=function(t){return this._reporterState.path.push(t)},Fh.prototype.exitKey=function(t){const e=this._reporterState;e.path=e.path.slice(0,t-1)},Fh.prototype.leaveKey=function(t,e,i){const r=this._reporterState;this.exitKey(t),null!==r.obj&&(r.obj[e]=i)},Fh.prototype.path=function(){return this._reporterState.path.join("/")},Fh.prototype.enterObject=function(){const t=this._reporterState,e=t.obj;return t.obj={},e},Fh.prototype.leaveObject=function(t){const e=this._reporterState,i=e.obj;return e.obj=t,i},Fh.prototype.error=function(t){let e;const i=this._reporterState,r=t instanceof Kh;if(e=r?t:new Kh(i.path.map((function(t){return"["+JSON.stringify(t)+"]"})).join(""),t.message||t,t.stack),!i.options.partial)throw e;return r||i.errors.push(e),e},Fh.prototype.wrapResult=function(t){const e=this._reporterState;return e.options.partial?{result:this.isError(t)?null:t,errors:e.errors}:t},Q(Kh,Error),Kh.prototype.rethrow=function(t){if(this.message=t+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,Kh),!this.stack)try{throw new Error(this.message)}catch(jf){this.stack=jf.stack}return this};var Hh={};const Zh=Wh.Reporter,Vh=zh.Buffer;function Gh(t,e){Zh.call(this,e),Vh.isBuffer(t)?(this.base=t,this.offset=0,this.length=t.length):this.error("Input not Buffer")}function Yh(t,e){if(Array.isArray(t))this.length=0,this.value=t.map((function(t){return Yh.isEncoderBuffer(t)||(t=new Yh(t,e)),this.length+=t.length,t}),this);else if("number"==typeof t){if(!(0<=t&&t<=255))return e.error("non-byte EncoderBuffer value");this.value=t,this.length=1}else if("string"==typeof t)this.value=t,this.length=Vh.byteLength(t);else{if(!Vh.isBuffer(t))return e.error("Unsupported type: "+typeof t);this.value=t,this.length=t.length}}Q(Gh,Zh),Hh.DecoderBuffer=Gh,Gh.isDecoderBuffer=function(t){return t instanceof Gh||"object"==typeof t&&Vh.isBuffer(t.base)&&"DecoderBuffer"===t.constructor.name&&"number"==typeof t.offset&&"number"==typeof t.length&&"function"==typeof t.save&&"function"==typeof t.restore&&"function"==typeof t.isEmpty&&"function"==typeof t.readUInt8&&"function"==typeof t.skip&&"function"==typeof t.raw},Gh.prototype.save=function(){return{offset:this.offset,reporter:Zh.prototype.save.call(this)}},Gh.prototype.restore=function(t){const e=new Gh(this.base);return e.offset=t.offset,e.length=this.offset,this.offset=t.offset,Zh.prototype.restore.call(this,t.reporter),e},Gh.prototype.isEmpty=function(){return this.offset===this.length},Gh.prototype.readUInt8=function(t){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(t||"DecoderBuffer overrun")},Gh.prototype.skip=function(t,e){if(!(this.offset+t<=this.length))return this.error(e||"DecoderBuffer overrun");const i=new Gh(this.base);return i._reporterState=this._reporterState,i.offset=this.offset,i.length=this.offset+t,this.offset+=t,i},Gh.prototype.raw=function(t){return this.base.slice(t?t.offset:this.offset,this.length)},Hh.EncoderBuffer=Yh,Yh.isEncoderBuffer=function(t){return t instanceof Yh||"object"==typeof t&&"EncoderBuffer"===t.constructor.name&&"number"==typeof t.length&&"function"==typeof t.join},Yh.prototype.join=function(t,e){return t||(t=Vh.alloc(this.length)),e||(e=0),0===this.length||(Array.isArray(this.value)?this.value.forEach((function(i){i.join(t,e),e+=i.length})):("number"==typeof this.value?t[e]=this.value:"string"==typeof this.value?t.write(this.value,e):Vh.isBuffer(this.value)&&this.value.copy(t,e),e+=this.length)),t};const Xh=Wh.Reporter,Jh=Hh.EncoderBuffer,Qh=Hh.DecoderBuffer,tu=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],eu=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(tu);function iu(t,e,i){const r={};this._baseState=r,r.name=i,r.enc=t,r.parent=e||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r.default=null,r.explicit=null,r.implicit=null,r.contains=null,r.parent||(r.children=[],this._wrap())}var ru=iu;const nu=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];iu.prototype.clone=function(){const t=this._baseState,e={};nu.forEach((function(i){e[i]=t[i]}));const i=new this.constructor(e.parent);return i._baseState=e,i},iu.prototype._wrap=function(){const t=this._baseState;eu.forEach((function(e){this[e]=function(){const i=new this.constructor(this);return t.children.push(i),i[e].apply(i,arguments)}}),this)},iu.prototype._init=function(t){const e=this._baseState;t.call(this),e.children=e.children.filter((function(t){return t._baseState.parent===this}),this)},iu.prototype._useArgs=function(t){const e=this._baseState,i=t.filter((function(t){return t instanceof this.constructor}),this);t=t.filter((function(t){return!(t instanceof this.constructor)}),this),0!==i.length&&(e.children=i,i.forEach((function(t){t._baseState.parent=this}),this)),0!==t.length&&(e.args=t,e.reverseArgs=t.map((function(t){if("object"!=typeof t||t.constructor!==Object)return t;const e={};return Object.keys(t).forEach((function(i){i==(0|i)&&(i|=0);const r=t[i];e[r]=i})),e})))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach((function(t){iu.prototype[t]=function(){const e=this._baseState;throw new Error(t+" not implemented for encoding: "+e.enc)}})),tu.forEach((function(t){iu.prototype[t]=function(){const e=this._baseState,i=Array.prototype.slice.call(arguments);return e.tag=t,this._useArgs(i),this}})),iu.prototype.use=function(t){return this._baseState.use=t,this},iu.prototype.optional=function(){return this._baseState.optional=!0,this},iu.prototype.def=function(t){const e=this._baseState;return e.default=t,e.optional=!0,this},iu.prototype.explicit=function(t){return this._baseState.explicit=t,this},iu.prototype.implicit=function(t){return this._baseState.implicit=t,this},iu.prototype.obj=function(){const t=this._baseState,e=Array.prototype.slice.call(arguments);return t.obj=!0,0!==e.length&&this._useArgs(e),this},iu.prototype.key=function(t){return this._baseState.key=t,this},iu.prototype.any=function(){return this._baseState.any=!0,this},iu.prototype.choice=function(t){return this._baseState.choice=t,this._useArgs(Object.keys(t).map((function(e){return t[e]}))),this},iu.prototype.contains=function(t){return this._baseState.contains=t,this},iu.prototype._decode=function(t,e){const i=this._baseState;if(null===i.parent)return t.wrapResult(i.children[0]._decode(t,e));let r,n=i.default,s=!0,o=null;if(null!==i.key&&(o=t.enterKey(i.key)),i.optional){let r=null;if(null!==i.explicit?r=i.explicit:null!==i.implicit?r=i.implicit:null!==i.tag&&(r=i.tag),null!==r||i.any){if(s=this._peekTag(t,r,i.any),t.isError(s))return s}else{const r=t.save();try{null===i.choice?this._decodeGeneric(i.tag,t,e):this._decodeChoice(t,e),s=!0}catch(jf){s=!1}t.restore(r)}}if(i.obj&&s&&(r=t.enterObject()),s){if(null!==i.explicit){const e=this._decodeTag(t,i.explicit);if(t.isError(e))return e;t=e}const r=t.offset;if(null===i.use&&null===i.choice){let e;i.any&&(e=t.save());const r=this._decodeTag(t,null!==i.implicit?i.implicit:i.tag,i.any);if(t.isError(r))return r;i.any?n=t.raw(e):t=r}if(e&&e.track&&null!==i.tag&&e.track(t.path(),r,t.length,"tagged"),e&&e.track&&null!==i.tag&&e.track(t.path(),t.offset,t.length,"content"),i.any||(n=null===i.choice?this._decodeGeneric(i.tag,t,e):this._decodeChoice(t,e)),t.isError(n))return n;if(i.any||null!==i.choice||null===i.children||i.children.forEach((function(i){i._decode(t,e)})),i.contains&&("octstr"===i.tag||"bitstr"===i.tag)){const r=new Qh(n);n=this._getUse(i.contains,t._reporterState.obj)._decode(r,e)}}return i.obj&&s&&(n=t.leaveObject(r)),null===i.key||null===n&&!0!==s?null!==o&&t.exitKey(o):t.leaveKey(o,i.key,n),n},iu.prototype._decodeGeneric=function(t,e,i){const r=this._baseState;return"seq"===t||"set"===t?null:"seqof"===t||"setof"===t?this._decodeList(e,t,r.args[0],i):/str$/.test(t)?this._decodeStr(e,t,i):"objid"===t&&r.args?this._decodeObjid(e,r.args[0],r.args[1],i):"objid"===t?this._decodeObjid(e,null,null,i):"gentime"===t||"utctime"===t?this._decodeTime(e,t,i):"null_"===t?this._decodeNull(e,i):"bool"===t?this._decodeBool(e,i):"objDesc"===t?this._decodeStr(e,t,i):"int"===t||"enum"===t?this._decodeInt(e,r.args&&r.args[0],i):null!==r.use?this._getUse(r.use,e._reporterState.obj)._decode(e,i):e.error("unknown tag: "+t)},iu.prototype._getUse=function(t,e){const i=this._baseState;return i.useDecoder=this._use(t,e),i.useDecoder=i.useDecoder._baseState.children[0],i.implicit!==i.useDecoder._baseState.implicit&&(i.useDecoder=i.useDecoder.clone(),i.useDecoder._baseState.implicit=i.implicit),i.useDecoder},iu.prototype._decodeChoice=function(t,e){const i=this._baseState;let r=null,n=!1;return Object.keys(i.choice).some((function(s){const o=t.save(),a=i.choice[s];try{const i=a._decode(t,e);if(t.isError(i))return!1;r={type:s,value:i},n=!0}catch(jf){return t.restore(o),!1}return!0}),this),n?r:t.error("Choice not matched")},iu.prototype._createEncoderBuffer=function(t){return new Jh(t,this.reporter)},iu.prototype._encode=function(t,e,i){const r=this._baseState;if(null!==r.default&&r.default===t)return;const n=this._encodeValue(t,e,i);return void 0===n||this._skipDefault(n,e,i)?void 0:n},iu.prototype._encodeValue=function(t,e,i){const r=this._baseState;if(null===r.parent)return r.children[0]._encode(t,e||new Xh);let n=null;if(this.reporter=e,r.optional&&void 0===t){if(null===r.default)return;t=r.default}let s=null,o=!1;if(r.any)n=this._createEncoderBuffer(t);else if(r.choice)n=this._encodeChoice(t,e);else if(r.contains)s=this._getUse(r.contains,i)._encode(t,e),o=!0;else if(r.children)s=r.children.map((function(i){if("null_"===i._baseState.tag)return i._encode(null,e,t);if(null===i._baseState.key)return e.error("Child should have a key");const r=e.enterKey(i._baseState.key);if("object"!=typeof t)return e.error("Child expected, but input is not object");const n=i._encode(t[i._baseState.key],e,t);return e.leaveKey(r),n}),this).filter((function(t){return t})),s=this._createEncoderBuffer(s);else if("seqof"===r.tag||"setof"===r.tag){if(!r.args||1!==r.args.length)return e.error("Too many args for : "+r.tag);if(!Array.isArray(t))return e.error("seqof/setof, but data is not Array");const i=this.clone();i._baseState.implicit=null,s=this._createEncoderBuffer(t.map((function(i){const r=this._baseState;return this._getUse(r.args[0],t)._encode(i,e)}),i))}else null!==r.use?n=this._getUse(r.use,i)._encode(t,e):(s=this._encodePrimitive(r.tag,t),o=!0);if(!r.any&&null===r.choice){const t=null!==r.implicit?r.implicit:r.tag,i=null===r.implicit?"universal":"context";null===t?null===r.use&&e.error("Tag could be omitted only for .use()"):null===r.use&&(n=this._encodeComposite(t,o,i,s))}return null!==r.explicit&&(n=this._encodeComposite(r.explicit,!1,"context",n)),n},iu.prototype._encodeChoice=function(t,e){return this._baseState.choice[t.type]._encode(t.value,e)},iu.prototype._encodePrimitive=function(t,e){const i=this._baseState;if(/str$/.test(t))return this._encodeStr(e,t);if("objid"===t&&i.args)return this._encodeObjid(e,i.reverseArgs[0],i.args[1]);if("objid"===t)return this._encodeObjid(e,null,null);if("gentime"===t||"utctime"===t)return this._encodeTime(e,t);if("null_"===t)return this._encodeNull();if("int"===t||"enum"===t)return this._encodeInt(e,i.args&&i.reverseArgs[0]);if("bool"===t)return this._encodeBool(e);if("objDesc"===t)return this._encodeStr(e,t);throw new Error("Unsupported tag: "+t)},iu.prototype._isNumstr=function(t){return/^[0-9 ]*$/.test(t)},iu.prototype._isPrintstr=function(t){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(t)};var su={};function ou(t){const e={};return Object.keys(t).forEach((function(i){(0|i)==i&&(i|=0);const r=t[i];e[r]=i})),e}su.tagClass={0:"universal",1:"application",2:"context",3:"private"},su.tagClassByName=ou(su.tagClass),su.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},su.tagByName=ou(su.tag);var au={};const hu=zh.Buffer;function uu(t){this.enc="der",this.name=t.name,this.entity=t,this.tree=new fu,this.tree._init(t.body)}function fu(t){ru.call(this,"der",t)}function lu(t){return t<10?"0"+t:t}au=uu,uu.prototype.encode=function(t,e){return this.tree._encode(t,e).join()},Q(fu,ru),fu.prototype._encodeComposite=function(t,e,i,r){const n=function(t,e,i,r){let n;if("seqof"===t?t="seq":"setof"===t&&(t="set"),su.tagByName.hasOwnProperty(t))n=su.tagByName[t];else{if("number"!=typeof t||(0|t)!==t)return r.error("Unknown tag: "+t);n=t}return n>=31?r.error("Multi-octet tag encoding unsupported"):(e||(n|=32),n|su.tagClassByName[i||"universal"]<<6)}(t,e,i,this.reporter);if(r.length<128){const t=hu.alloc(2);return t[0]=n,t[1]=r.length,this._createEncoderBuffer([t,r])}let s=1;for(let a=r.length;a>=256;a>>=8)s++;const o=hu.alloc(2+s);o[0]=n,o[1]=128|s;for(let a=1+s,h=r.length;h>0;a--,h>>=8)o[a]=255&h;return this._createEncoderBuffer([o,r])},fu.prototype._encodeStr=function(t,e){if("bitstr"===e)return this._createEncoderBuffer([0|t.unused,t.data]);if("bmpstr"===e){const e=hu.alloc(2*t.length);for(let i=0;i=40)return this.reporter.error("Second objid identifier OOB");t.splice(0,2,40*t[0]+t[1])}let r=0;for(let o=0;o=128;e>>=7)r++}const n=hu.alloc(r);let s=n.length-1;for(let o=t.length-1;o>=0;o--){let e=t[o];for(n[s--]=127&e;(e>>=7)>0;)n[s--]=128|127&e}return this._createEncoderBuffer(n)},fu.prototype._encodeTime=function(t,e){let i;const r=new Date(t);return"gentime"===e?i=[lu(r.getUTCFullYear()),lu(r.getUTCMonth()+1),lu(r.getUTCDate()),lu(r.getUTCHours()),lu(r.getUTCMinutes()),lu(r.getUTCSeconds()),"Z"].join(""):"utctime"===e?i=[lu(r.getUTCFullYear()%100),lu(r.getUTCMonth()+1),lu(r.getUTCDate()),lu(r.getUTCHours()),lu(r.getUTCMinutes()),lu(r.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+e+" time is not supported yet"),this._encodeStr(i,"octstr")},fu.prototype._encodeNull=function(){return this._createEncoderBuffer("")},fu.prototype._encodeInt=function(t,e){if("string"==typeof t){if(!e)return this.reporter.error("String int or enum given, but no values map");if(!e.hasOwnProperty(t))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(t));t=e[t]}if("number"!=typeof t&&!hu.isBuffer(t)){const e=t.toArray();!t.sign&&128&e[0]&&e.unshift(0),t=hu.from(e)}if(hu.isBuffer(t)){let e=t.length;0===t.length&&e++;const i=hu.alloc(e);return t.copy(i),0===t.length&&(i[0]=0),this._createEncoderBuffer(i)}if(t<128)return this._createEncoderBuffer(t);if(t<256)return this._createEncoderBuffer([0,t]);let i=1;for(let n=t;n>=256;n>>=8)i++;const r=new Array(i);for(let n=r.length-1;n>=0;n--)r[n]=255&t,t>>=8;return 128&r[0]&&r.unshift(0),this._createEncoderBuffer(hu.from(r))},fu.prototype._encodeBool=function(t){return this._createEncoderBuffer(t?255:0)},fu.prototype._use=function(t,e){return"function"==typeof t&&(t=t(e)),t._getEncoder("der").tree},fu.prototype._skipDefault=function(t,e,i){const r=this._baseState;let n;if(null===r.default)return!1;const s=t.join();if(void 0===r.defaultBuffer&&(r.defaultBuffer=this._encodeValue(r.default,e,i).join()),s.length!==r.defaultBuffer.length)return!1;for(n=0;n>6],n=0==(32&i);if(31==(31&i)){let r=i;for(i=0;128==(128&r);){if(r=t.readUInt8(e),t.isError(r))return r;i<<=7,i|=127&r}}else i&=31;return{cls:r,primitive:n,tag:i,tagStr:su.tag[i]}}function Mu(t,e,i){let r=t.readUInt8(i);if(t.isError(r))return r;if(!e&&128===r)return null;if(0==(128&r))return r;const n=127&r;if(n>4)return t.error("length octect is too long");r=0;for(let s=0;s0&&i.ishrn(r),i}function vf(t,e,i){var r,n;do{for(r=cf.alloc(0);8*r.length=e)throw new Error("invalid sig")}var _f=I.Buffer;function Sf(t){ao.Writable.call(this);var e=Er[t];if(!e)throw new Error("Unknown message digest");this._hashType=e.hash,this._hash=cr(e.hash),this._tag=e.id,this._signType=e.sign}function Ef(t){ao.Writable.call(this);var e=Er[t];if(!e)throw new Error("Unknown message digest");this._hash=cr(e.hash),this._tag=e.id,this._signType=e.sign}Object.keys(Er).forEach((function(t){Er[t].id=_f.from(Er[t].id,"hex"),Er[t.toLowerCase()]=Er[t]})),Q(Sf,ao.Writable),Sf.prototype._write=function(t,e,i){this._hash.update(t),i()},Sf.prototype.update=function(t,e){return"string"==typeof t&&(t=_f.from(t,e)),this._hash.update(t),this},Sf.prototype.sign=function(t,e){this.end();var i=this._hash.digest(),r=lf(i,t,this._hashType,this._signType,this._tag);return e?r.toString(e):r},Q(Ef,ao.Writable),Ef.prototype._write=function(t,e,i){this._hash.update(t),i()},Ef.prototype.update=function(t,e){return"string"==typeof t&&(t=_f.from(t,e)),this._hash.update(t),this},Ef.prototype.verify=function(t,e,i){return"string"==typeof e&&(e=_f.from(e,i)),this.end(),function(t,e,i,r,n){var s=hf(i);if("ec"===s.type){if("ecdsa"!==r&&"ecdsa/rsa"!==r)throw new Error("wrong public key type");return function(t,e,i){var r=df[i.data.algorithm.curve.join(".")];if(!r)throw new Error("unknown curve "+i.data.algorithm.curve.join("."));var n=new wf(r),s=i.data.subjectPrivateKey.data;return n.verify(e,t,s)}(t,e,s)}if("dsa"===s.type){if("dsa"!==r)throw new Error("wrong public key type");return function(t,e,i){var r=i.data.p,n=i.data.q,s=i.data.g,o=i.data.pub_key,a=hf.signature.decode(t,"der"),h=a.s,u=a.r;Mf(h,n),Mf(u,n);var f=ho.mont(r),l=h.invm(n);return 0===s.toRed(f).redPow(new ho(e).mul(l).mod(n)).fromRed().mul(o.toRed(f).redPow(u.mul(l).mod(n)).fromRed()).mod(r).mod(n).cmp(u)}(t,e,s)}if("rsa"!==r&&"ecdsa/rsa"!==r)throw new Error("wrong public key type");e=yf.concat([n,e]);for(var o=s.modulus.byteLength(),a=[1],h=0;e.length+a.length+2=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return r}function o(t,e,i,r){for(var n=0,s=Math.min(t.length,i),o=e;o=49?a-49+10:a>=17?a-17+10:a}return n}r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,e){return t.cmp(e)>0?t:e},r.min=function(t,e){return t.cmp(e)<0?t:e},r.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===e?this._parseHex(t,r):this._parseBase(t,e,r),"-"===t[0]&&(this.negative=1),this.strip(),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initArray=function(t,e,i){if(t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r=0;r-=3)s=t[r]|t[r-1]<<8|t[r-2]<<16,this.words[n]|=s<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===i)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this.strip()},r.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=6)n=s(t,i,i+6),this.words[r]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,r++);i+6!==e&&(n=s(t,e,i+6),this.words[r]|=n<>>26-o&4194303),this.strip()},r.prototype._parseBase=function(t,e,i){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=e)r++;r--,n=n/e|0;for(var s=t.length-i,a=s%r,h=Math.min(s,s-a)+i,u=0,f=i;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},r.prototype.inspect=function(){return(this.red?""};var a=["","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"],h=[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],u=[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 f(t,e,i){i.negative=e.negative^t.negative;var r=t.length+e.length|0;i.length=r,r=r-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;i.words[0]=a;for(var u=1;u>>26,l=67108863&h,d=Math.min(u,e.length-1),c=Math.max(0,u-t.length+1);c<=d;c++){var p=u-c|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[c])+l)/67108864|0,l=67108863&o}i.words[u]=0|l,h=0|f}return 0!==h?i.words[u]=0|h:i.length--,i.strip()}r.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var r=0,n=0,s=0;s>>24-r&16777215)||s!==this.length-1?a[6-f.length]+f+i:f+i,(r+=2)>=26&&(r-=26,s--)}for(0!==n&&(i=n.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var l=h[t],d=u[t];i="";var c=this.clone();for(c.negative=0;!c.isZero();){var p=c.modn(d).toString(t);i=(c=c.idivn(d)).isZero()?p+i:a[l-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length,0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16)},r.prototype.toBuffer=function(t,e){return this.toArrayLike(n,t,e)},r.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},r.prototype.toArrayLike=function(t,e,i){var r=this.byteLength(),n=i||Math.max(1,r);this.strip();var s,o,a="le"===e,h=new t(n),u=this.clone();if(a){for(o=0;!u.isZero();o++)s=u.andln(255),u.iushrn(8),h[o]=s;for(;o=4096&&(i+=13,e>>>=13),e>=64&&(i+=7,e>>>=7),e>=8&&(i+=4,e>>>=4),e>=2&&(i+=2,e>>>=2),i+e},r.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,i=0;return 0==(8191&e)&&(i+=13,e>>>=13),0==(127&e)&&(i+=7,e>>>=7),0==(15&e)&&(i+=4,e>>>=4),0==(3&e)&&(i+=2,e>>>=2),0==(1&e)&&i++,i},r.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var i=0;it.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var e,i;this.length>t.length?(e=this,i=t):(e=t,i=this);for(var r=0;rt.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-i),this.strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,e){var i=t/26|0,r=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(i=this,r=t):(i=t,r=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i,r,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(i=this,r=t):(i=t,r=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,c=0|o[1],p=8191&c,m=c>>>13,g=0|o[2],v=8191&g,b=g>>>13,y=0|o[3],w=8191&y,M=y>>>13,_=0|o[4],S=8191&_,E=_>>>13,k=0|o[5],R=8191&k,A=k>>>13,x=0|o[6],T=8191&x,P=x>>>13,B=0|o[7],I=8191&B,q=B>>>13,O=0|o[8],L=8191&O,j=O>>>13,C=0|o[9],N=8191&C,D=C>>>13,U=0|a[0],$=8191&U,z=U>>>13,W=0|a[1],F=8191&W,K=W>>>13,H=0|a[2],Z=8191&H,V=H>>>13,G=0|a[3],Y=8191&G,X=G>>>13,J=0|a[4],Q=8191&J,tt=J>>>13,et=0|a[5],it=8191&et,rt=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,ft=0|a[8],lt=8191&ft,dt=ft>>>13,ct=0|a[9],pt=8191&ct,mt=ct>>>13;i.negative=t.negative^e.negative,i.length=19;var gt=(u+(r=Math.imul(l,$))|0)+((8191&(n=(n=Math.imul(l,z))+Math.imul(d,$)|0))<<13)|0;u=((s=Math.imul(d,z))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(p,$),n=(n=Math.imul(p,z))+Math.imul(m,$)|0,s=Math.imul(m,z);var vt=(u+(r=r+Math.imul(l,F)|0)|0)+((8191&(n=(n=n+Math.imul(l,K)|0)+Math.imul(d,F)|0))<<13)|0;u=((s=s+Math.imul(d,K)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(v,$),n=(n=Math.imul(v,z))+Math.imul(b,$)|0,s=Math.imul(b,z),r=r+Math.imul(p,F)|0,n=(n=n+Math.imul(p,K)|0)+Math.imul(m,F)|0,s=s+Math.imul(m,K)|0;var bt=(u+(r=r+Math.imul(l,Z)|0)|0)+((8191&(n=(n=n+Math.imul(l,V)|0)+Math.imul(d,Z)|0))<<13)|0;u=((s=s+Math.imul(d,V)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(w,$),n=(n=Math.imul(w,z))+Math.imul(M,$)|0,s=Math.imul(M,z),r=r+Math.imul(v,F)|0,n=(n=n+Math.imul(v,K)|0)+Math.imul(b,F)|0,s=s+Math.imul(b,K)|0,r=r+Math.imul(p,Z)|0,n=(n=n+Math.imul(p,V)|0)+Math.imul(m,Z)|0,s=s+Math.imul(m,V)|0;var yt=(u+(r=r+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,X)|0)+Math.imul(d,Y)|0))<<13)|0;u=((s=s+Math.imul(d,X)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(S,$),n=(n=Math.imul(S,z))+Math.imul(E,$)|0,s=Math.imul(E,z),r=r+Math.imul(w,F)|0,n=(n=n+Math.imul(w,K)|0)+Math.imul(M,F)|0,s=s+Math.imul(M,K)|0,r=r+Math.imul(v,Z)|0,n=(n=n+Math.imul(v,V)|0)+Math.imul(b,Z)|0,s=s+Math.imul(b,V)|0,r=r+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,X)|0;var wt=(u+(r=r+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(d,Q)|0))<<13)|0;u=((s=s+Math.imul(d,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(R,$),n=(n=Math.imul(R,z))+Math.imul(A,$)|0,s=Math.imul(A,z),r=r+Math.imul(S,F)|0,n=(n=n+Math.imul(S,K)|0)+Math.imul(E,F)|0,s=s+Math.imul(E,K)|0,r=r+Math.imul(w,Z)|0,n=(n=n+Math.imul(w,V)|0)+Math.imul(M,Z)|0,s=s+Math.imul(M,V)|0,r=r+Math.imul(v,Y)|0,n=(n=n+Math.imul(v,X)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,X)|0,r=r+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var Mt=(u+(r=r+Math.imul(l,it)|0)|0)+((8191&(n=(n=n+Math.imul(l,rt)|0)+Math.imul(d,it)|0))<<13)|0;u=((s=s+Math.imul(d,rt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(T,$),n=(n=Math.imul(T,z))+Math.imul(P,$)|0,s=Math.imul(P,z),r=r+Math.imul(R,F)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(A,F)|0,s=s+Math.imul(A,K)|0,r=r+Math.imul(S,Z)|0,n=(n=n+Math.imul(S,V)|0)+Math.imul(E,Z)|0,s=s+Math.imul(E,V)|0,r=r+Math.imul(w,Y)|0,n=(n=n+Math.imul(w,X)|0)+Math.imul(M,Y)|0,s=s+Math.imul(M,X)|0,r=r+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,tt)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,tt)|0,r=r+Math.imul(p,it)|0,n=(n=n+Math.imul(p,rt)|0)+Math.imul(m,it)|0,s=s+Math.imul(m,rt)|0;var _t=(u+(r=r+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(d,st)|0))<<13)|0;u=((s=s+Math.imul(d,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(I,$),n=(n=Math.imul(I,z))+Math.imul(q,$)|0,s=Math.imul(q,z),r=r+Math.imul(T,F)|0,n=(n=n+Math.imul(T,K)|0)+Math.imul(P,F)|0,s=s+Math.imul(P,K)|0,r=r+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,V)|0)+Math.imul(A,Z)|0,s=s+Math.imul(A,V)|0,r=r+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,X)|0,r=r+Math.imul(w,Q)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(M,Q)|0,s=s+Math.imul(M,tt)|0,r=r+Math.imul(v,it)|0,n=(n=n+Math.imul(v,rt)|0)+Math.imul(b,it)|0,s=s+Math.imul(b,rt)|0,r=r+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(r=r+Math.imul(l,ht)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((s=s+Math.imul(d,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(L,$),n=(n=Math.imul(L,z))+Math.imul(j,$)|0,s=Math.imul(j,z),r=r+Math.imul(I,F)|0,n=(n=n+Math.imul(I,K)|0)+Math.imul(q,F)|0,s=s+Math.imul(q,K)|0,r=r+Math.imul(T,Z)|0,n=(n=n+Math.imul(T,V)|0)+Math.imul(P,Z)|0,s=s+Math.imul(P,V)|0,r=r+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,X)|0,r=r+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(E,Q)|0,s=s+Math.imul(E,tt)|0,r=r+Math.imul(w,it)|0,n=(n=n+Math.imul(w,rt)|0)+Math.imul(M,it)|0,s=s+Math.imul(M,rt)|0,r=r+Math.imul(v,st)|0,n=(n=n+Math.imul(v,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,r=r+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,ut)|0;var Et=(u+(r=r+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,dt)|0)+Math.imul(d,lt)|0))<<13)|0;u=((s=s+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(N,$),n=(n=Math.imul(N,z))+Math.imul(D,$)|0,s=Math.imul(D,z),r=r+Math.imul(L,F)|0,n=(n=n+Math.imul(L,K)|0)+Math.imul(j,F)|0,s=s+Math.imul(j,K)|0,r=r+Math.imul(I,Z)|0,n=(n=n+Math.imul(I,V)|0)+Math.imul(q,Z)|0,s=s+Math.imul(q,V)|0,r=r+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,X)|0,r=r+Math.imul(R,Q)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(A,Q)|0,s=s+Math.imul(A,tt)|0,r=r+Math.imul(S,it)|0,n=(n=n+Math.imul(S,rt)|0)+Math.imul(E,it)|0,s=s+Math.imul(E,rt)|0,r=r+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(M,st)|0,s=s+Math.imul(M,ot)|0,r=r+Math.imul(v,ht)|0,n=(n=n+Math.imul(v,ut)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ut)|0,r=r+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,dt)|0;var kt=(u+(r=r+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(d,pt)|0))<<13)|0;u=((s=s+Math.imul(d,mt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(N,F),n=(n=Math.imul(N,K))+Math.imul(D,F)|0,s=Math.imul(D,K),r=r+Math.imul(L,Z)|0,n=(n=n+Math.imul(L,V)|0)+Math.imul(j,Z)|0,s=s+Math.imul(j,V)|0,r=r+Math.imul(I,Y)|0,n=(n=n+Math.imul(I,X)|0)+Math.imul(q,Y)|0,s=s+Math.imul(q,X)|0,r=r+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(P,Q)|0,s=s+Math.imul(P,tt)|0,r=r+Math.imul(R,it)|0,n=(n=n+Math.imul(R,rt)|0)+Math.imul(A,it)|0,s=s+Math.imul(A,rt)|0,r=r+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(E,st)|0,s=s+Math.imul(E,ot)|0,r=r+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(M,ht)|0,s=s+Math.imul(M,ut)|0,r=r+Math.imul(v,lt)|0,n=(n=n+Math.imul(v,dt)|0)+Math.imul(b,lt)|0,s=s+Math.imul(b,dt)|0;var Rt=(u+(r=r+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(N,Z),n=(n=Math.imul(N,V))+Math.imul(D,Z)|0,s=Math.imul(D,V),r=r+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(j,Y)|0,s=s+Math.imul(j,X)|0,r=r+Math.imul(I,Q)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(q,Q)|0,s=s+Math.imul(q,tt)|0,r=r+Math.imul(T,it)|0,n=(n=n+Math.imul(T,rt)|0)+Math.imul(P,it)|0,s=s+Math.imul(P,rt)|0,r=r+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(A,st)|0,s=s+Math.imul(A,ot)|0,r=r+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(E,ht)|0,s=s+Math.imul(E,ut)|0,r=r+Math.imul(w,lt)|0,n=(n=n+Math.imul(w,dt)|0)+Math.imul(M,lt)|0,s=s+Math.imul(M,dt)|0;var At=(u+(r=r+Math.imul(v,pt)|0)|0)+((8191&(n=(n=n+Math.imul(v,mt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((s=s+Math.imul(b,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(N,Y),n=(n=Math.imul(N,X))+Math.imul(D,Y)|0,s=Math.imul(D,X),r=r+Math.imul(L,Q)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(j,Q)|0,s=s+Math.imul(j,tt)|0,r=r+Math.imul(I,it)|0,n=(n=n+Math.imul(I,rt)|0)+Math.imul(q,it)|0,s=s+Math.imul(q,rt)|0,r=r+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,ot)|0,r=r+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(A,ht)|0,s=s+Math.imul(A,ut)|0,r=r+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,dt)|0)+Math.imul(E,lt)|0,s=s+Math.imul(E,dt)|0;var xt=(u+(r=r+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((s=s+Math.imul(M,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(N,Q),n=(n=Math.imul(N,tt))+Math.imul(D,Q)|0,s=Math.imul(D,tt),r=r+Math.imul(L,it)|0,n=(n=n+Math.imul(L,rt)|0)+Math.imul(j,it)|0,s=s+Math.imul(j,rt)|0,r=r+Math.imul(I,st)|0,n=(n=n+Math.imul(I,ot)|0)+Math.imul(q,st)|0,s=s+Math.imul(q,ot)|0,r=r+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,ut)|0,r=r+Math.imul(R,lt)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(A,lt)|0,s=s+Math.imul(A,dt)|0;var Tt=(u+(r=r+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(E,pt)|0))<<13)|0;u=((s=s+Math.imul(E,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(N,it),n=(n=Math.imul(N,rt))+Math.imul(D,it)|0,s=Math.imul(D,rt),r=r+Math.imul(L,st)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(j,st)|0,s=s+Math.imul(j,ot)|0,r=r+Math.imul(I,ht)|0,n=(n=n+Math.imul(I,ut)|0)+Math.imul(q,ht)|0,s=s+Math.imul(q,ut)|0,r=r+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,dt)|0)+Math.imul(P,lt)|0,s=s+Math.imul(P,dt)|0;var Pt=(u+(r=r+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((s=s+Math.imul(A,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(N,st),n=(n=Math.imul(N,ot))+Math.imul(D,st)|0,s=Math.imul(D,ot),r=r+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,ut)|0)+Math.imul(j,ht)|0,s=s+Math.imul(j,ut)|0,r=r+Math.imul(I,lt)|0,n=(n=n+Math.imul(I,dt)|0)+Math.imul(q,lt)|0,s=s+Math.imul(q,dt)|0;var Bt=(u+(r=r+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((s=s+Math.imul(P,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(N,ht),n=(n=Math.imul(N,ut))+Math.imul(D,ht)|0,s=Math.imul(D,ut),r=r+Math.imul(L,lt)|0,n=(n=n+Math.imul(L,dt)|0)+Math.imul(j,lt)|0,s=s+Math.imul(j,dt)|0;var It=(u+(r=r+Math.imul(I,pt)|0)|0)+((8191&(n=(n=n+Math.imul(I,mt)|0)+Math.imul(q,pt)|0))<<13)|0;u=((s=s+Math.imul(q,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(N,lt),n=(n=Math.imul(N,dt))+Math.imul(D,lt)|0,s=Math.imul(D,dt);var qt=(u+(r=r+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,mt)|0)+Math.imul(j,pt)|0))<<13)|0;u=((s=s+Math.imul(j,mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863;var Ot=(u+(r=Math.imul(N,pt))|0)+((8191&(n=(n=Math.imul(N,mt))+Math.imul(D,pt)|0))<<13)|0;return u=((s=Math.imul(D,mt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=vt,h[2]=bt,h[3]=yt,h[4]=wt,h[5]=Mt,h[6]=_t,h[7]=St,h[8]=Et,h[9]=kt,h[10]=Rt,h[11]=At,h[12]=xt,h[13]=Tt,h[14]=Pt,h[15]=Bt,h[16]=It,h[17]=qt,h[18]=Ot,0!==u&&(h[19]=u,i.length++),i};function d(t,e,i){return(new c).mulp(t,e,i)}function c(t,e){this.x=t,this.y=e}Math.imul||(l=f),r.prototype.mulTo=function(t,e){var i=this.length+t.length;return 10===this.length&&10===t.length?l(this,t,e):i<63?f(this,t,e):i<1024?function(t,e,i){i.negative=e.negative^t.negative,i.length=t.length+e.length;for(var r=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}i.words[s]=a,r=o,o=n}return 0!==r?i.words[s]=r:i.length--,i.strip()}(this,t,e):d(this,t,e)},c.prototype.makeRBT=function(t){for(var e=new Array(t),i=r.prototype._countBits(t)-1,n=0;n>=1;return r},c.prototype.permute=function(t,e,i,r,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*s+1]=8191&n,n>>>=13;for(s=2*e;s>=26,e+=r/67108864|0,e+=n>>>26,this.words[i]=67108863&n}return 0!==e&&(this.words[i]=e,this.length++),this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),i=0;i>>n}return e}(t);if(0===e.length)return new r(1);for(var i=this,n=0;n>>26-i<<26-i;if(0!==i){var s=0;for(e=0;e>>26-i}s&&(this.words[e]=s,this.length++)}if(0!==r){for(e=this.length-1;e>=0;e--)this.words[e+r]=this.words[e];for(e=0;e>>n<s)for(this.length-=s,h=0;h=0&&(0!==u||h>=r);h--){var f=0|this.words[h];this.words[h]=u<<26-n|f>>>n,u=f&o}return a&&0!==u&&(a.words[a.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},r.prototype.ishrn=function(t,e,i){return this.iushrn(t,e,i)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){var e=t%26,i=(t-e)/26,r=1<>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},r.prototype.isubn=function(t){if(t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(a/67108864|0),this.words[r+i]=67108863&n}for(;r>26,this.words[r+i]=67108863&n;if(0===o)return this.strip();for(o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},r.prototype._wordDiv=function(t,e){var i=(this.length,t.length),n=this.clone(),s=t,o=0|s.words[s.length-1];0!=(i=26-this._countBits(o))&&(s=s.ushln(i),n.iushln(i),o=0|s.words[s.length-1]);var a,h=n.length-s.length;if("mod"!==e){(a=new r(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u=0;l--){var d=67108864*(0|n.words[s.length+l])+(0|n.words[s.length+l-1]);for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(s,d,l);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(s,1,l),n.isZero()||(n.negative^=1);a&&(a.words[l]=d)}return a&&a.strip(),n.strip(),"div"!==e&&0!==i&&n.iushrn(i),{div:a||null,mod:n}},r.prototype.divmod=function(t,e,i){return this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),"mod"!==e&&(n=o.div.neg()),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),e),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new r(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var i=0!==e.div.negative?e.mod.isub(t):e.mod,r=t.ushrn(1),n=t.andln(1),s=i.cmp(r);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},r.prototype.modn=function(t){for(var e=(1<<26)%t,i=0,r=this.length-1;r>=0;r--)i=(e*i+(0|this.words[r]))%t;return i},r.prototype.idivn=function(t){for(var e=0,i=this.length-1;i>=0;i--){var r=(0|this.words[i])+67108864*e;this.words[i]=r/t|0,e=r%t}return this.strip()},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new r(1),s=new r(0),o=new r(0),a=new r(1),h=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++h;for(var u=i.clone(),f=e.clone();!e.isZero();){for(var l=0,d=1;0==(e.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(e.iushrn(l);l-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(u),s.isub(f)),n.iushrn(1),s.iushrn(1);for(var c=0,p=1;0==(i.words[0]&p)&&c<26;++c,p<<=1);if(c>0)for(i.iushrn(c);c-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(u),a.isub(f)),o.iushrn(1),a.iushrn(1);e.cmp(i)>=0?(e.isub(i),n.isub(o),s.isub(a)):(i.isub(e),o.isub(n),a.isub(s))}return{a:o,b:a,gcd:i.iushln(h)}},r.prototype._invmp=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new r(1),o=new r(0),a=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var h=0,u=1;0==(e.words[0]&u)&&h<26;++h,u<<=1);if(h>0)for(e.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(a),s.iushrn(1);for(var f=0,l=1;0==(i.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(i.iushrn(f);f-- >0;)o.isOdd()&&o.iadd(a),o.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o)):(i.isub(e),o.isub(s))}return(n=0===e.cmpn(1)?s:o).cmpn(0)<0&&n.iadd(t),n},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),i=t.clone();e.negative=0,i.negative=0;for(var r=0;e.isEven()&&i.isEven();r++)e.iushrn(1),i.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;i.isEven();)i.iushrn(1);var n=e.cmp(i);if(n<0){var s=e;e=i,i=s}else if(0===n||0===i.cmpn(1))break;e.isub(i)}return i.iushln(r)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){var e=t%26,i=(t-e)/26,r=1<>>26,o&=67108863,this.words[s]=o}return 0!==n&&(this.words[s]=n,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t);var r=0|this.words[0];e=r===t?0:rt.length)return 1;if(this.length=0;i--){var r=0|this.words[i],n=0|t.words[i];if(r!==n){rn&&(e=1);break}}return e},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new M(t)},r.prototype.toRed=function(t){return t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return this._forceRed(t)},r.prototype.redAdd=function(t){return this.red.add(this,t)},r.prototype.redIAdd=function(t){return this.red.iadd(this,t)},r.prototype.redSub=function(t){return this.red.sub(this,t)},r.prototype.redISub=function(t){return this.red.isub(this,t)},r.prototype.redShl=function(t){return this.red.shl(this,t)},r.prototype.redMul=function(t){return this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return this.red._verify1(this),this.red.pow(this,t)};var p={k256:null,p224:null,p192:null,p25519:null};function m(t,e){this.name=t,this.p=new r(e,16),this.n=this.p.bitLength(),this.k=new r(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 v(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function y(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(t){if("string"==typeof t){var e=r._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function _(t){M.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(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 t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},m.prototype.ireduce=function(t){var e,i=t;do{this.split(i,this.tmp),e=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(e>this.n);var r=e0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},m.prototype.split=function(t,e){t.iushrn(this.n,0,e)},m.prototype.imulK=function(t){return t.imul(this.k)},i(g,m),g.prototype.split=function(t,e){for(var i=Math.min(t.length,9),r=0;r>>22,n=s}n>>>=22,t.words[r-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},g.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,i=0;i>>=26,t.words[i]=n,e=r}return 0!==e&&(t.words[t.length++]=e),t},r._prime=function(t){if(p[t])return p[t];var e;if("k256"===t)e=new g;else if("p224"===t)e=new v;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new y}return p[t]=e,e},M.prototype._verify1=function(t){},M.prototype._verify2=function(t,e){},M.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},M.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},M.prototype.add=function(t,e){this._verify2(t,e);var i=t.add(e);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},M.prototype.iadd=function(t,e){this._verify2(t,e);var i=t.iadd(e);return i.cmp(this.m)>=0&&i.isub(this.m),i},M.prototype.sub=function(t,e){this._verify2(t,e);var i=t.sub(e);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},M.prototype.isub=function(t,e){this._verify2(t,e);var i=t.isub(e);return i.cmpn(0)<0&&i.iadd(this.m),i},M.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},M.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},M.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},M.prototype.isqr=function(t){return this.imul(t,t.clone())},M.prototype.sqr=function(t){return this.mul(t,t)},M.prototype.sqrt=function(t){if(t.isZero())return t.clone();if(3===this.m.andln(3)){var e=this.m.add(new r(1)).iushrn(2);return this.pow(t,e)}for(var i=this.m.subn(1),n=0;!i.isZero()&&0===i.andln(1);)n++,i.iushrn(1);var s=new r(1).toRed(this),o=s.redNeg(),a=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new r(2*h*h).toRed(this);0!==this.pow(h,a).cmp(o);)h.redIAdd(o);for(var u=this.pow(h,i),f=this.pow(t,i.addn(1).iushrn(1)),l=this.pow(t,i),d=n;0!==l.cmp(s);){for(var c=l,p=0;0!==c.cmp(s);p++)c=c.redSqr();var m=this.pow(u,new r(1).iushln(d-p-1));f=f.redMul(m),u=m.redSqr(),l=l.redMul(u),d=p}return f},M.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},M.prototype.pow=function(t,e){if(e.isZero())return new r(1).toRed(this);if(0===e.cmpn(1))return t.clone();var i=new Array(16);i[0]=new r(1).toRed(this),i[1]=t;for(var n=2;n=0;n--){for(var u=e.words[n],f=h-1;f>=0;f--){var l=u>>f&1;s!==i[0]&&(s=this.sqr(s)),0!==l||0!==o?(o<<=1,o|=l,(4==++a||0===n&&0===f)&&(s=this.mul(s,i[o]),a=0,o=0)):a=0}h=26}return s},M.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},M.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},r.mont=function(t){return new _(t)},i(_,M),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(e),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new r(0)._forceRed(this);var i=t.mul(e),n=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=i.isub(n).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(kf,this),kf=kf.exports;(function(t){(function(){(function(t){return new i(t)});var e={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};function i(t){this.curveType=e[t],this.curveType||(this.curveType={name:t}),this.curve=new Dh.ec(this.curveType.name),this.keys=void 0}function r(e,i,r){Array.isArray(e)||(e=e.toArray());var n=new t(e);if(r&&n.length=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return r}function o(t,e,i,r){for(var n=0,s=Math.min(t.length,i),o=e;o=49?a-49+10:a>=17?a-17+10:a}return n}r.isBN=function(t){return t instanceof r||null!==t&&"object"==typeof t&&t.constructor.wordSize===r.wordSize&&Array.isArray(t.words)},r.max=function(t,e){return t.cmp(e)>0?t:e},r.min=function(t,e){return t.cmp(e)<0?t:e},r.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&r++,16===e?this._parseHex(t,r):this._parseBase(t,e,r),"-"===t[0]&&(this.negative=1),this.strip(),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},r.prototype._initArray=function(t,e,i){if(t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r=0;r-=3)s=t[r]|t[r-1]<<8|t[r-2]<<16,this.words[n]|=s<>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);else if("le"===i)for(r=0,n=0;r>>26-o&67108863,(o+=24)>=26&&(o-=26,n++);return this.strip()},r.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=6)n=s(t,i,i+6),this.words[r]|=n<>>26-o&4194303,(o+=24)>=26&&(o-=26,r++);i+6!==e&&(n=s(t,e,i+6),this.words[r]|=n<>>26-o&4194303),this.strip()},r.prototype._parseBase=function(t,e,i){this.words=[0],this.length=1;for(var r=0,n=1;n<=67108863;n*=e)r++;r--,n=n/e|0;for(var s=t.length-i,a=s%r,h=Math.min(s,s-a)+i,u=0,f=i;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},r.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},r.prototype.inspect=function(){return(this.red?""};var a=["","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"],h=[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],u=[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 f(t,e,i){i.negative=e.negative^t.negative;var r=t.length+e.length|0;i.length=r,r=r-1|0;var n=0|t.words[0],s=0|e.words[0],o=n*s,a=67108863&o,h=o/67108864|0;i.words[0]=a;for(var u=1;u>>26,l=67108863&h,d=Math.min(u,e.length-1),c=Math.max(0,u-t.length+1);c<=d;c++){var p=u-c|0;f+=(o=(n=0|t.words[p])*(s=0|e.words[c])+l)/67108864|0,l=67108863&o}i.words[u]=0|l,h=0|f}return 0!==h?i.words[u]=0|h:i.length--,i.strip()}r.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var r=0,n=0,s=0;s>>24-r&16777215)||s!==this.length-1?a[6-f.length]+f+i:f+i,(r+=2)>=26&&(r-=26,s--)}for(0!==n&&(i=n.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var l=h[t],d=u[t];i="";var c=this.clone();for(c.negative=0;!c.isZero();){var p=c.modn(d).toString(t);i=(c=c.idivn(d)).isZero()?p+i:a[l-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}},r.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length,0!==this.negative?-t:t},r.prototype.toJSON=function(){return this.toString(16)},r.prototype.toBuffer=function(t,e){return this.toArrayLike(n,t,e)},r.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},r.prototype.toArrayLike=function(t,e,i){var r=this.byteLength(),n=i||Math.max(1,r);this.strip();var s,o,a="le"===e,h=new t(n),u=this.clone();if(a){for(o=0;!u.isZero();o++)s=u.andln(255),u.iushrn(8),h[o]=s;for(;o=4096&&(i+=13,e>>>=13),e>=64&&(i+=7,e>>>=7),e>=8&&(i+=4,e>>>=4),e>=2&&(i+=2,e>>>=2),i+e},r.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,i=0;return 0==(8191&e)&&(i+=13,e>>>=13),0==(127&e)&&(i+=7,e>>>=7),0==(15&e)&&(i+=4,e>>>=4),0==(3&e)&&(i+=2,e>>>=2),0==(1&e)&&i++,i},r.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},r.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},r.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var i=0;it.length?this.clone().iand(t):t.clone().iand(this)},r.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},r.prototype.iuxor=function(t){var e,i;this.length>t.length?(e=this,i=t):(e=t,i=this);for(var r=0;rt.length?this.clone().ixor(t):t.clone().ixor(this)},r.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},r.prototype.inotn=function(t){var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var r=0;r0&&(this.words[r]=~this.words[r]&67108863>>26-i),this.strip()},r.prototype.notn=function(t){return this.clone().inotn(t)},r.prototype.setn=function(t,e){var i=t/26|0,r=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(i=this,r=t):(i=t,r=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},r.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i,r,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(i=this,r=t):(i=t,r=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,c=0|o[1],p=8191&c,m=c>>>13,g=0|o[2],v=8191&g,b=g>>>13,y=0|o[3],w=8191&y,M=y>>>13,_=0|o[4],S=8191&_,E=_>>>13,k=0|o[5],R=8191&k,A=k>>>13,x=0|o[6],T=8191&x,P=x>>>13,B=0|o[7],I=8191&B,q=B>>>13,O=0|o[8],L=8191&O,j=O>>>13,C=0|o[9],N=8191&C,D=C>>>13,U=0|a[0],$=8191&U,z=U>>>13,W=0|a[1],F=8191&W,K=W>>>13,H=0|a[2],Z=8191&H,V=H>>>13,G=0|a[3],Y=8191&G,X=G>>>13,J=0|a[4],Q=8191&J,tt=J>>>13,et=0|a[5],it=8191&et,rt=et>>>13,nt=0|a[6],st=8191&nt,ot=nt>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,ft=0|a[8],lt=8191&ft,dt=ft>>>13,ct=0|a[9],pt=8191&ct,mt=ct>>>13;i.negative=t.negative^e.negative,i.length=19;var gt=(u+(r=Math.imul(l,$))|0)+((8191&(n=(n=Math.imul(l,z))+Math.imul(d,$)|0))<<13)|0;u=((s=Math.imul(d,z))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,r=Math.imul(p,$),n=(n=Math.imul(p,z))+Math.imul(m,$)|0,s=Math.imul(m,z);var vt=(u+(r=r+Math.imul(l,F)|0)|0)+((8191&(n=(n=n+Math.imul(l,K)|0)+Math.imul(d,F)|0))<<13)|0;u=((s=s+Math.imul(d,K)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,r=Math.imul(v,$),n=(n=Math.imul(v,z))+Math.imul(b,$)|0,s=Math.imul(b,z),r=r+Math.imul(p,F)|0,n=(n=n+Math.imul(p,K)|0)+Math.imul(m,F)|0,s=s+Math.imul(m,K)|0;var bt=(u+(r=r+Math.imul(l,Z)|0)|0)+((8191&(n=(n=n+Math.imul(l,V)|0)+Math.imul(d,Z)|0))<<13)|0;u=((s=s+Math.imul(d,V)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,r=Math.imul(w,$),n=(n=Math.imul(w,z))+Math.imul(M,$)|0,s=Math.imul(M,z),r=r+Math.imul(v,F)|0,n=(n=n+Math.imul(v,K)|0)+Math.imul(b,F)|0,s=s+Math.imul(b,K)|0,r=r+Math.imul(p,Z)|0,n=(n=n+Math.imul(p,V)|0)+Math.imul(m,Z)|0,s=s+Math.imul(m,V)|0;var yt=(u+(r=r+Math.imul(l,Y)|0)|0)+((8191&(n=(n=n+Math.imul(l,X)|0)+Math.imul(d,Y)|0))<<13)|0;u=((s=s+Math.imul(d,X)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,r=Math.imul(S,$),n=(n=Math.imul(S,z))+Math.imul(E,$)|0,s=Math.imul(E,z),r=r+Math.imul(w,F)|0,n=(n=n+Math.imul(w,K)|0)+Math.imul(M,F)|0,s=s+Math.imul(M,K)|0,r=r+Math.imul(v,Z)|0,n=(n=n+Math.imul(v,V)|0)+Math.imul(b,Z)|0,s=s+Math.imul(b,V)|0,r=r+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,X)|0;var wt=(u+(r=r+Math.imul(l,Q)|0)|0)+((8191&(n=(n=n+Math.imul(l,tt)|0)+Math.imul(d,Q)|0))<<13)|0;u=((s=s+Math.imul(d,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,r=Math.imul(R,$),n=(n=Math.imul(R,z))+Math.imul(A,$)|0,s=Math.imul(A,z),r=r+Math.imul(S,F)|0,n=(n=n+Math.imul(S,K)|0)+Math.imul(E,F)|0,s=s+Math.imul(E,K)|0,r=r+Math.imul(w,Z)|0,n=(n=n+Math.imul(w,V)|0)+Math.imul(M,Z)|0,s=s+Math.imul(M,V)|0,r=r+Math.imul(v,Y)|0,n=(n=n+Math.imul(v,X)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,X)|0,r=r+Math.imul(p,Q)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var Mt=(u+(r=r+Math.imul(l,it)|0)|0)+((8191&(n=(n=n+Math.imul(l,rt)|0)+Math.imul(d,it)|0))<<13)|0;u=((s=s+Math.imul(d,rt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,r=Math.imul(T,$),n=(n=Math.imul(T,z))+Math.imul(P,$)|0,s=Math.imul(P,z),r=r+Math.imul(R,F)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(A,F)|0,s=s+Math.imul(A,K)|0,r=r+Math.imul(S,Z)|0,n=(n=n+Math.imul(S,V)|0)+Math.imul(E,Z)|0,s=s+Math.imul(E,V)|0,r=r+Math.imul(w,Y)|0,n=(n=n+Math.imul(w,X)|0)+Math.imul(M,Y)|0,s=s+Math.imul(M,X)|0,r=r+Math.imul(v,Q)|0,n=(n=n+Math.imul(v,tt)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,tt)|0,r=r+Math.imul(p,it)|0,n=(n=n+Math.imul(p,rt)|0)+Math.imul(m,it)|0,s=s+Math.imul(m,rt)|0;var _t=(u+(r=r+Math.imul(l,st)|0)|0)+((8191&(n=(n=n+Math.imul(l,ot)|0)+Math.imul(d,st)|0))<<13)|0;u=((s=s+Math.imul(d,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,r=Math.imul(I,$),n=(n=Math.imul(I,z))+Math.imul(q,$)|0,s=Math.imul(q,z),r=r+Math.imul(T,F)|0,n=(n=n+Math.imul(T,K)|0)+Math.imul(P,F)|0,s=s+Math.imul(P,K)|0,r=r+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,V)|0)+Math.imul(A,Z)|0,s=s+Math.imul(A,V)|0,r=r+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,X)|0,r=r+Math.imul(w,Q)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(M,Q)|0,s=s+Math.imul(M,tt)|0,r=r+Math.imul(v,it)|0,n=(n=n+Math.imul(v,rt)|0)+Math.imul(b,it)|0,s=s+Math.imul(b,rt)|0,r=r+Math.imul(p,st)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var St=(u+(r=r+Math.imul(l,ht)|0)|0)+((8191&(n=(n=n+Math.imul(l,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((s=s+Math.imul(d,ut)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,r=Math.imul(L,$),n=(n=Math.imul(L,z))+Math.imul(j,$)|0,s=Math.imul(j,z),r=r+Math.imul(I,F)|0,n=(n=n+Math.imul(I,K)|0)+Math.imul(q,F)|0,s=s+Math.imul(q,K)|0,r=r+Math.imul(T,Z)|0,n=(n=n+Math.imul(T,V)|0)+Math.imul(P,Z)|0,s=s+Math.imul(P,V)|0,r=r+Math.imul(R,Y)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,X)|0,r=r+Math.imul(S,Q)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(E,Q)|0,s=s+Math.imul(E,tt)|0,r=r+Math.imul(w,it)|0,n=(n=n+Math.imul(w,rt)|0)+Math.imul(M,it)|0,s=s+Math.imul(M,rt)|0,r=r+Math.imul(v,st)|0,n=(n=n+Math.imul(v,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,r=r+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,ut)|0;var Et=(u+(r=r+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,dt)|0)+Math.imul(d,lt)|0))<<13)|0;u=((s=s+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,r=Math.imul(N,$),n=(n=Math.imul(N,z))+Math.imul(D,$)|0,s=Math.imul(D,z),r=r+Math.imul(L,F)|0,n=(n=n+Math.imul(L,K)|0)+Math.imul(j,F)|0,s=s+Math.imul(j,K)|0,r=r+Math.imul(I,Z)|0,n=(n=n+Math.imul(I,V)|0)+Math.imul(q,Z)|0,s=s+Math.imul(q,V)|0,r=r+Math.imul(T,Y)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,X)|0,r=r+Math.imul(R,Q)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(A,Q)|0,s=s+Math.imul(A,tt)|0,r=r+Math.imul(S,it)|0,n=(n=n+Math.imul(S,rt)|0)+Math.imul(E,it)|0,s=s+Math.imul(E,rt)|0,r=r+Math.imul(w,st)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(M,st)|0,s=s+Math.imul(M,ot)|0,r=r+Math.imul(v,ht)|0,n=(n=n+Math.imul(v,ut)|0)+Math.imul(b,ht)|0,s=s+Math.imul(b,ut)|0,r=r+Math.imul(p,lt)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(m,lt)|0,s=s+Math.imul(m,dt)|0;var kt=(u+(r=r+Math.imul(l,pt)|0)|0)+((8191&(n=(n=n+Math.imul(l,mt)|0)+Math.imul(d,pt)|0))<<13)|0;u=((s=s+Math.imul(d,mt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,r=Math.imul(N,F),n=(n=Math.imul(N,K))+Math.imul(D,F)|0,s=Math.imul(D,K),r=r+Math.imul(L,Z)|0,n=(n=n+Math.imul(L,V)|0)+Math.imul(j,Z)|0,s=s+Math.imul(j,V)|0,r=r+Math.imul(I,Y)|0,n=(n=n+Math.imul(I,X)|0)+Math.imul(q,Y)|0,s=s+Math.imul(q,X)|0,r=r+Math.imul(T,Q)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(P,Q)|0,s=s+Math.imul(P,tt)|0,r=r+Math.imul(R,it)|0,n=(n=n+Math.imul(R,rt)|0)+Math.imul(A,it)|0,s=s+Math.imul(A,rt)|0,r=r+Math.imul(S,st)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(E,st)|0,s=s+Math.imul(E,ot)|0,r=r+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(M,ht)|0,s=s+Math.imul(M,ut)|0,r=r+Math.imul(v,lt)|0,n=(n=n+Math.imul(v,dt)|0)+Math.imul(b,lt)|0,s=s+Math.imul(b,dt)|0;var Rt=(u+(r=r+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,r=Math.imul(N,Z),n=(n=Math.imul(N,V))+Math.imul(D,Z)|0,s=Math.imul(D,V),r=r+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(j,Y)|0,s=s+Math.imul(j,X)|0,r=r+Math.imul(I,Q)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(q,Q)|0,s=s+Math.imul(q,tt)|0,r=r+Math.imul(T,it)|0,n=(n=n+Math.imul(T,rt)|0)+Math.imul(P,it)|0,s=s+Math.imul(P,rt)|0,r=r+Math.imul(R,st)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(A,st)|0,s=s+Math.imul(A,ot)|0,r=r+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(E,ht)|0,s=s+Math.imul(E,ut)|0,r=r+Math.imul(w,lt)|0,n=(n=n+Math.imul(w,dt)|0)+Math.imul(M,lt)|0,s=s+Math.imul(M,dt)|0;var At=(u+(r=r+Math.imul(v,pt)|0)|0)+((8191&(n=(n=n+Math.imul(v,mt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((s=s+Math.imul(b,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,r=Math.imul(N,Y),n=(n=Math.imul(N,X))+Math.imul(D,Y)|0,s=Math.imul(D,X),r=r+Math.imul(L,Q)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(j,Q)|0,s=s+Math.imul(j,tt)|0,r=r+Math.imul(I,it)|0,n=(n=n+Math.imul(I,rt)|0)+Math.imul(q,it)|0,s=s+Math.imul(q,rt)|0,r=r+Math.imul(T,st)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,ot)|0,r=r+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(A,ht)|0,s=s+Math.imul(A,ut)|0,r=r+Math.imul(S,lt)|0,n=(n=n+Math.imul(S,dt)|0)+Math.imul(E,lt)|0,s=s+Math.imul(E,dt)|0;var xt=(u+(r=r+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((s=s+Math.imul(M,mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,r=Math.imul(N,Q),n=(n=Math.imul(N,tt))+Math.imul(D,Q)|0,s=Math.imul(D,tt),r=r+Math.imul(L,it)|0,n=(n=n+Math.imul(L,rt)|0)+Math.imul(j,it)|0,s=s+Math.imul(j,rt)|0,r=r+Math.imul(I,st)|0,n=(n=n+Math.imul(I,ot)|0)+Math.imul(q,st)|0,s=s+Math.imul(q,ot)|0,r=r+Math.imul(T,ht)|0,n=(n=n+Math.imul(T,ut)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,ut)|0,r=r+Math.imul(R,lt)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(A,lt)|0,s=s+Math.imul(A,dt)|0;var Tt=(u+(r=r+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,mt)|0)+Math.imul(E,pt)|0))<<13)|0;u=((s=s+Math.imul(E,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,r=Math.imul(N,it),n=(n=Math.imul(N,rt))+Math.imul(D,it)|0,s=Math.imul(D,rt),r=r+Math.imul(L,st)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(j,st)|0,s=s+Math.imul(j,ot)|0,r=r+Math.imul(I,ht)|0,n=(n=n+Math.imul(I,ut)|0)+Math.imul(q,ht)|0,s=s+Math.imul(q,ut)|0,r=r+Math.imul(T,lt)|0,n=(n=n+Math.imul(T,dt)|0)+Math.imul(P,lt)|0,s=s+Math.imul(P,dt)|0;var Pt=(u+(r=r+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((s=s+Math.imul(A,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,r=Math.imul(N,st),n=(n=Math.imul(N,ot))+Math.imul(D,st)|0,s=Math.imul(D,ot),r=r+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,ut)|0)+Math.imul(j,ht)|0,s=s+Math.imul(j,ut)|0,r=r+Math.imul(I,lt)|0,n=(n=n+Math.imul(I,dt)|0)+Math.imul(q,lt)|0,s=s+Math.imul(q,dt)|0;var Bt=(u+(r=r+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,mt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((s=s+Math.imul(P,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,r=Math.imul(N,ht),n=(n=Math.imul(N,ut))+Math.imul(D,ht)|0,s=Math.imul(D,ut),r=r+Math.imul(L,lt)|0,n=(n=n+Math.imul(L,dt)|0)+Math.imul(j,lt)|0,s=s+Math.imul(j,dt)|0;var It=(u+(r=r+Math.imul(I,pt)|0)|0)+((8191&(n=(n=n+Math.imul(I,mt)|0)+Math.imul(q,pt)|0))<<13)|0;u=((s=s+Math.imul(q,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,r=Math.imul(N,lt),n=(n=Math.imul(N,dt))+Math.imul(D,lt)|0,s=Math.imul(D,dt);var qt=(u+(r=r+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,mt)|0)+Math.imul(j,pt)|0))<<13)|0;u=((s=s+Math.imul(j,mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863;var Ot=(u+(r=Math.imul(N,pt))|0)+((8191&(n=(n=Math.imul(N,mt))+Math.imul(D,pt)|0))<<13)|0;return u=((s=Math.imul(D,mt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=vt,h[2]=bt,h[3]=yt,h[4]=wt,h[5]=Mt,h[6]=_t,h[7]=St,h[8]=Et,h[9]=kt,h[10]=Rt,h[11]=At,h[12]=xt,h[13]=Tt,h[14]=Pt,h[15]=Bt,h[16]=It,h[17]=qt,h[18]=Ot,0!==u&&(h[19]=u,i.length++),i};function d(t,e,i){return(new c).mulp(t,e,i)}function c(t,e){this.x=t,this.y=e}Math.imul||(l=f),r.prototype.mulTo=function(t,e){var i=this.length+t.length;return 10===this.length&&10===t.length?l(this,t,e):i<63?f(this,t,e):i<1024?function(t,e,i){i.negative=e.negative^t.negative,i.length=t.length+e.length;for(var r=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}i.words[s]=a,r=o,o=n}return 0!==r?i.words[s]=r:i.length--,i.strip()}(this,t,e):d(this,t,e)},c.prototype.makeRBT=function(t){for(var e=new Array(t),i=r.prototype._countBits(t)-1,n=0;n>=1;return r},c.prototype.permute=function(t,e,i,r,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*s+1]=8191&n,n>>>=13;for(s=2*e;s>=26,e+=r/67108864|0,e+=n>>>26,this.words[i]=67108863&n}return 0!==e&&(this.words[i]=e,this.length++),this},r.prototype.muln=function(t){return this.clone().imuln(t)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),i=0;i>>n}return e}(t);if(0===e.length)return new r(1);for(var i=this,n=0;n>>26-i<<26-i;if(0!==i){var s=0;for(e=0;e>>26-i}s&&(this.words[e]=s,this.length++)}if(0!==r){for(e=this.length-1;e>=0;e--)this.words[e+r]=this.words[e];for(e=0;e>>n<s)for(this.length-=s,h=0;h=0&&(0!==u||h>=r);h--){var f=0|this.words[h];this.words[h]=u<<26-n|f>>>n,u=f&o}return a&&0!==u&&(a.words[a.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},r.prototype.ishrn=function(t,e,i){return this.iushrn(t,e,i)},r.prototype.shln=function(t){return this.clone().ishln(t)},r.prototype.ushln=function(t){return this.clone().iushln(t)},r.prototype.shrn=function(t){return this.clone().ishrn(t)},r.prototype.ushrn=function(t){return this.clone().iushrn(t)},r.prototype.testn=function(t){var e=t%26,i=(t-e)/26,r=1<>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},r.prototype.isubn=function(t){if(t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(a/67108864|0),this.words[r+i]=67108863&n}for(;r>26,this.words[r+i]=67108863&n;if(0===o)return this.strip();for(o=0,r=0;r>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},r.prototype._wordDiv=function(t,e){var i=(this.length,t.length),n=this.clone(),s=t,o=0|s.words[s.length-1];0!=(i=26-this._countBits(o))&&(s=s.ushln(i),n.iushln(i),o=0|s.words[s.length-1]);var a,h=n.length-s.length;if("mod"!==e){(a=new r(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u=0;l--){var d=67108864*(0|n.words[s.length+l])+(0|n.words[s.length+l-1]);for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(s,d,l);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(s,1,l),n.isZero()||(n.negative^=1);a&&(a.words[l]=d)}return a&&a.strip(),n.strip(),"div"!==e&&0!==i&&n.iushrn(i),{div:a||null,mod:n}},r.prototype.divmod=function(t,e,i){return this.isZero()?{div:new r(0),mod:new r(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),"mod"!==e&&(n=o.div.neg()),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),e),"div"!==e&&(s=o.mod.neg(),i&&0!==s.negative&&s.isub(t)),{div:o.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new r(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new r(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new r(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,s,o},r.prototype.div=function(t){return this.divmod(t,"div",!1).div},r.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},r.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},r.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var i=0!==e.div.negative?e.mod.isub(t):e.mod,r=t.ushrn(1),n=t.andln(1),s=i.cmp(r);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},r.prototype.modn=function(t){for(var e=(1<<26)%t,i=0,r=this.length-1;r>=0;r--)i=(e*i+(0|this.words[r]))%t;return i},r.prototype.idivn=function(t){for(var e=0,i=this.length-1;i>=0;i--){var r=(0|this.words[i])+67108864*e;this.words[i]=r/t|0,e=r%t}return this.strip()},r.prototype.divn=function(t){return this.clone().idivn(t)},r.prototype.egcd=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new r(1),s=new r(0),o=new r(0),a=new r(1),h=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++h;for(var u=i.clone(),f=e.clone();!e.isZero();){for(var l=0,d=1;0==(e.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(e.iushrn(l);l-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(u),s.isub(f)),n.iushrn(1),s.iushrn(1);for(var c=0,p=1;0==(i.words[0]&p)&&c<26;++c,p<<=1);if(c>0)for(i.iushrn(c);c-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(u),a.isub(f)),o.iushrn(1),a.iushrn(1);e.cmp(i)>=0?(e.isub(i),n.isub(o),s.isub(a)):(i.isub(e),o.isub(n),a.isub(s))}return{a:o,b:a,gcd:i.iushln(h)}},r.prototype._invmp=function(t){var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new r(1),o=new r(0),a=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var h=0,u=1;0==(e.words[0]&u)&&h<26;++h,u<<=1);if(h>0)for(e.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(a),s.iushrn(1);for(var f=0,l=1;0==(i.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(i.iushrn(f);f-- >0;)o.isOdd()&&o.iadd(a),o.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o)):(i.isub(e),o.isub(s))}return(n=0===e.cmpn(1)?s:o).cmpn(0)<0&&n.iadd(t),n},r.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),i=t.clone();e.negative=0,i.negative=0;for(var r=0;e.isEven()&&i.isEven();r++)e.iushrn(1),i.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;i.isEven();)i.iushrn(1);var n=e.cmp(i);if(n<0){var s=e;e=i,i=s}else if(0===n||0===i.cmpn(1))break;e.isub(i)}return i.iushln(r)},r.prototype.invm=function(t){return this.egcd(t).a.umod(t)},r.prototype.isEven=function(){return 0==(1&this.words[0])},r.prototype.isOdd=function(){return 1==(1&this.words[0])},r.prototype.andln=function(t){return this.words[0]&t},r.prototype.bincn=function(t){var e=t%26,i=(t-e)/26,r=1<>>26,o&=67108863,this.words[s]=o}return 0!==n&&(this.words[s]=n,this.length++),this},r.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},r.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t);var r=0|this.words[0];e=r===t?0:rt.length)return 1;if(this.length=0;i--){var r=0|this.words[i],n=0|t.words[i];if(r!==n){rn&&(e=1);break}}return e},r.prototype.gtn=function(t){return 1===this.cmpn(t)},r.prototype.gt=function(t){return 1===this.cmp(t)},r.prototype.gten=function(t){return this.cmpn(t)>=0},r.prototype.gte=function(t){return this.cmp(t)>=0},r.prototype.ltn=function(t){return-1===this.cmpn(t)},r.prototype.lt=function(t){return-1===this.cmp(t)},r.prototype.lten=function(t){return this.cmpn(t)<=0},r.prototype.lte=function(t){return this.cmp(t)<=0},r.prototype.eqn=function(t){return 0===this.cmpn(t)},r.prototype.eq=function(t){return 0===this.cmp(t)},r.red=function(t){return new M(t)},r.prototype.toRed=function(t){return t.convertTo(this)._forceRed(t)},r.prototype.fromRed=function(){return this.red.convertFrom(this)},r.prototype._forceRed=function(t){return this.red=t,this},r.prototype.forceRed=function(t){return this._forceRed(t)},r.prototype.redAdd=function(t){return this.red.add(this,t)},r.prototype.redIAdd=function(t){return this.red.iadd(this,t)},r.prototype.redSub=function(t){return this.red.sub(this,t)},r.prototype.redISub=function(t){return this.red.isub(this,t)},r.prototype.redShl=function(t){return this.red.shl(this,t)},r.prototype.redMul=function(t){return this.red._verify2(this,t),this.red.mul(this,t)},r.prototype.redIMul=function(t){return this.red._verify2(this,t),this.red.imul(this,t)},r.prototype.redSqr=function(){return this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(t){return this.red._verify1(this),this.red.pow(this,t)};var p={k256:null,p224:null,p192:null,p25519:null};function m(t,e){this.name=t,this.p=new r(e,16),this.n=this.p.bitLength(),this.k=new r(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 v(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function y(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(t){if("string"==typeof t){var e=r._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function _(t){M.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new r(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 t=new r(null);return t.words=new Array(Math.ceil(this.n/13)),t},m.prototype.ireduce=function(t){var e,i=t;do{this.split(i,this.tmp),e=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(e>this.n);var r=e0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},m.prototype.split=function(t,e){t.iushrn(this.n,0,e)},m.prototype.imulK=function(t){return t.imul(this.k)},i(g,m),g.prototype.split=function(t,e){for(var i=Math.min(t.length,9),r=0;r>>22,n=s}n>>>=22,t.words[r-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},g.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,i=0;i>>=26,t.words[i]=n,e=r}return 0!==e&&(t.words[t.length++]=e),t},r._prime=function(t){if(p[t])return p[t];var e;if("k256"===t)e=new g;else if("p224"===t)e=new v;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new y}return p[t]=e,e},M.prototype._verify1=function(t){},M.prototype._verify2=function(t,e){},M.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},M.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},M.prototype.add=function(t,e){this._verify2(t,e);var i=t.add(e);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},M.prototype.iadd=function(t,e){this._verify2(t,e);var i=t.iadd(e);return i.cmp(this.m)>=0&&i.isub(this.m),i},M.prototype.sub=function(t,e){this._verify2(t,e);var i=t.sub(e);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},M.prototype.isub=function(t,e){this._verify2(t,e);var i=t.isub(e);return i.cmpn(0)<0&&i.iadd(this.m),i},M.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},M.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},M.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},M.prototype.isqr=function(t){return this.imul(t,t.clone())},M.prototype.sqr=function(t){return this.mul(t,t)},M.prototype.sqrt=function(t){if(t.isZero())return t.clone();if(3===this.m.andln(3)){var e=this.m.add(new r(1)).iushrn(2);return this.pow(t,e)}for(var i=this.m.subn(1),n=0;!i.isZero()&&0===i.andln(1);)n++,i.iushrn(1);var s=new r(1).toRed(this),o=s.redNeg(),a=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new r(2*h*h).toRed(this);0!==this.pow(h,a).cmp(o);)h.redIAdd(o);for(var u=this.pow(h,i),f=this.pow(t,i.addn(1).iushrn(1)),l=this.pow(t,i),d=n;0!==l.cmp(s);){for(var c=l,p=0;0!==c.cmp(s);p++)c=c.redSqr();var m=this.pow(u,new r(1).iushln(d-p-1));f=f.redMul(m),u=m.redSqr(),l=l.redMul(u),d=p}return f},M.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},M.prototype.pow=function(t,e){if(e.isZero())return new r(1).toRed(this);if(0===e.cmpn(1))return t.clone();var i=new Array(16);i[0]=new r(1).toRed(this),i[1]=t;for(var n=2;n=0;n--){for(var u=e.words[n],f=h-1;f>=0;f--){var l=u>>f&1;s!==i[0]&&(s=this.sqr(s)),0!==l||0!==o?(o<<=1,o|=l,(4==++a||0===n&&0===f)&&(s=this.mul(s,i[o]),a=0,o=0)):a=0}h=26}return s},M.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},M.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},r.mont=function(t){return new _(t)},i(_,M),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(e),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new r(0)._forceRed(this);var i=t.mul(e),n=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=i.isub(n).iushrn(this.shift),o=s;return s.cmp(this.m)>=0?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(Rf,this),Rf=Rf.exports;I.Buffer,I.Buffer,I.Buffer;var Af={};(function(t,e){(function(){"use strict";I.Buffer,I.kMaxLength;var i=e.crypto||e.msCrypto;Math.pow(2,32);i&&i.getRandomValues||t.browser}).call(this)}).call(this,D,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});var xf={};xf.createHash=cr,xf.createHmac=yr;var Tf=Object.keys(kr);["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(Tf);jr.pbkdf2,jr.pbkdf2Sync,Af.publicEncrypt,Af.privateEncrypt,Af.publicDecrypt,Af.privateDecrypt;Array.isArray;var Pf=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}},Bf=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function If(t,e){if(t.map)return t.map(e);for(var i=[],r=0;r{f=r.ERR_TIMEOUT,e.abort()},0===n?this.requestTimeout:n)}a=await fetch(t.uri,t),void 0!==u&&clearTimeout(u),f=r.ERR_RESPONSE;let s=a.headers.get("Content-Type");if(!1===e&&null===s?h=void 0===a.blob?await a.buffer():await a.blob():!1===e&&(s.startsWith("application/json")||s.startsWith("application/problem+json"))?(h=await a.json(),f=h.type,l=h.title):h=!1===e&&s.startsWith("text/")?await a.text():void 0===a.blob?await a.buffer():await a.blob(),f=r.ERR_SERVER,!a.ok)throw h}catch(g){if(s>0)return await new Promise(t=>setTimeout(t,2e3)),this._wrapWithPromise(t,e,i,n,s-1);let u;switch(u="object"==typeof g&&g.constructor===Object&&"title"in g?g.title:g,void 0===a&&(a={}),f){case r.ERR_REQUEST:f="https://api.backend.ai/probs/client-request-error",navigator.onLine?(l=u,o="sending request has failed: "+u,d=u):(l="Network disconnected.",o="sending request has failed: Network disconnected",d="Network disconnected");break;case r.ERR_RESPONSE:f="https://api.backend.ai/probs/client-response-error",l=u,o="reading response has failed: "+u,d=u;break;case r.ERR_SERVER:f="https://api.backend.ai/probs/server-error",l=`${a.status} ${a.statusText} - ${h.title}`,o="server responded failure: ",h.msg?(o+=`${a.status} ${a.statusText} - ${h.msg}`,d=h.msg):(o+=`${a.status} ${a.statusText} - ${h.title}`,d=h.title);break;case r.ERR_ABORT:f="https://api.backend.ai/probs/request-abort-error",l="Request aborted",d=o="Request aborted by user",a.status=408,a.statusText="Request aborted by user";break;case r.ERR_TIMEOUT:f="https://api.backend.ai/probs/request-timeout-error",l="Request timeout",d=o="No response returned during the timeout period",a.status=408,a.statusText="Timeout exceeded";break;default:void 0===a.status&&(a.status=500,a.statusText="Server error"),""===f&&(f=r.ERR_UNKNOWN),""===l&&(l=h.title),o=`server responded failure: ${a.status} ${a.statusText} - ${h.title}`,""!==h.title&&(d=h.title)}throw{isError:!0,timestamp:(new Date).toUTCString(),type:f,requestUrl:t.uri,requestMethod:t.method,requestParameters:t.body,statusCode:a.status,statusText:a.statusText,title:l,message:o,description:d}}let c=JSON.parse(localStorage.getItem("backendaiwebui.logs"));c&&c.length>3e3&&(c=c.slice(1,3e3));let p=Array();void 0===a&&(a={status:"No status",statusText:"No response given."});let m={isError:!1,timestamp:(new Date).toUTCString(),type:"",requestUrl:t.uri,requestMethod:t.method,requestParameters:t.body,statusCode:a.status,statusText:a.statusText,title:h.title,message:""};p.push(m),c&&(p=p.concat(c));try{localStorage.setItem("backendaiwebui.logs",JSON.stringify(p))}catch(jf){console.warn("Local storage is full. Clearing part of the logs.");let e=JSON.parse(localStorage.getItem("backendaiwebui.logs")||"[]");e=e.slice(0,Math.round(2*e.length/3)),localStorage.setItem("backendaiwebui.logs",JSON.stringify(e)),Object.entries(localStorage).map(t=>t[0]).filter(t=>t.startsWith("backendaiconsole")).map(t=>localStorage.removeItem(t))}return h}getServerVersion(t=null){let e=this.newPublicRequest("GET","/",null,"");return this._wrapWithPromise(e,!1,t)}get APIMajorVersion(){return this._apiVersionMajor}set APIMajorVersion(t){this._apiVersionMajor=t,this._config._apiVersionMajor=this._apiVersionMajor}async get_manager_version(t=null){if(null===this._managerVersion){let e=await this.getServerVersion(t);this._managerVersion=e.manager,this._apiVersion=e.version,this._config._apiVersion=this._apiVersion,this._apiVersionMajor=e.version.substr(1,2),this._config._apiVersionMajor=this._apiVersionMajor,this._apiVersionMajor>4&&(this.kernelPrefix="/session")}return this._managerVersion}supports(t){return 0===Object.keys(this._features).length&&this._updateSupportList(),t in this._features&&this._features[t]}_updateFieldCompatibilityByAPIVersion(t){const e={session_name:"sess_id"};return this._apiVersionMajor<5&&Object.keys(e).forEach(i=>{let r=t.indexOf(i);-1!==r&&(t[r]=e[i])}),t}_updateSupportList(){this.isAPIVersionCompatibleWith("v4.20190601")&&(this._features["scaling-group"]=!0,this._features.group=!0,this._features["group-folder"]=!0,this._features["system-images"]=!0,this._features["detailed-session-states"]=!0,this._features["change-user-name"]=!0),this.isAPIVersionCompatibleWith("v6.20200815")&&(this._features["multi-container"]=!0,this._features["multi-node"]=!0,this._features["storage-proxy"]=!0,this._features["hardware-metadata"]=!0)}isManagerVersionCompatibleWith(t){let e=this._managerVersion;return e=e.split(".").map(t=>t.padStart(10)).join("."),(t=t.split(".").map(t=>t.padStart(10)).join("."))<=e}isAPIVersionCompatibleWith(t){let e=this._apiVersion;return null!==e&&null!==t&&(e=e.split(".").map(t=>t.padStart(10)).join("."),t=t.split(".").map(t=>t.padStart(10)).join(".")),t<=e}async check_login(){let t,e=this.newSignedRequest("POST","/server/login-check",null);try{!0===(t=await this._wrapWithPromise(e)).authenticated&&(this._config._accessKey=t.data.access_key,this._config._session_id=t.session_id)}catch(i){return console.log(i),Promise.resolve(!1)}return t.authenticated}async login(){let t,e={username:this._config.userId,password:this._config.password},i=this.newSignedRequest("POST","/server/login",e);try{if(!0===(t=await this._wrapWithPromise(i)).authenticated)return await this.get_manager_version(),this.check_login();if(!1===t.authenticated)return t.data&&t.data.details?Promise.resolve({fail_reason:t.data.details}):Promise.resolve(!1)}catch(r){throw"statusCode"in r&&429===r.statusCode?{title:r.description,message:"Too many failed login attempts."}:{title:"No manager found at API Endpoint.",message:"Authentication failed. Check information and manager status."}}}logout(){let t=this.newSignedRequest("POST","/server/logout",{});return this._wrapWithPromise(t)}async signout(t,e){let i={username:t,password:e},r=this.newSignedRequest("POST","/auth/signout",i);return this._wrapWithPromise(r)}async update_password(t,e,i){let r={old_password:t,new_password:e,new_password2:i},n=this.newSignedRequest("POST","/auth/update-password",r);return this._wrapWithPromise(n)}async get_resource_slots(){let t;return t=this.isAPIVersionCompatibleWith("v4.20190601")?this.newPublicRequest("GET","/config/resource-slots",null,""):this.newPublicRequest("GET","/etcd/resource-slots",null,""),this._wrapWithPromise(t)}async createIfNotExists(t,e,i={},r=0){null==e&&(e=this.generateSessionId());let n,s={lang:t,clientSessionToken:e};if(i!={}){let t={};i.cpu&&(t.cpu=i.cpu),i.mem&&(t.mem=i.mem),i.gpu&&(t["cuda.device"]=parseInt(i.gpu)),i["cuda.device"]&&(t["cuda.device"]=parseInt(i["cuda.device"])),i.vgpu?t["cuda.shares"]=parseFloat(i.vgpu).toFixed(2):i.fgpu&&(t["cuda.shares"]=parseFloat(i.fgpu).toFixed(2)),i["cuda.shares"]&&(t["cuda.shares"]=parseFloat(i["cuda.shares"]).toFixed(2)),i.rocm&&(t["rocm.device"]=i.rocm),i.tpu&&(t["tpu.device"]=i.tpu),i.cluster_size&&(s.cluster_size=i.cluster_size),i.cluster_mode&&(s.cluster_mode=i.cluster_mode),i.group_name&&(s.group_name=i.group_name),i.domain&&(s.domain=i.domain),i.type&&(s.type=i.type),i.startsAt&&(s.starts_at=i.startsAt),i.enqueueOnly&&(s.enqueueOnly=i.enqueueOnly),i.maxWaitSeconds&&(s.maxWaitSeconds=i.maxWaitSeconds),i.reuseIfExists&&(s.reuseIfExists=i.reuseIfExists),i.startupCommand&&(s.startupCommand=i.startupCommand),i.bootstrapScript&&(s.bootstrapScript=i.bootstrapScript),i.bootstrap_script&&(s.bootstrap_script=i.bootstrap_script),i.owner_access_key&&(s.owner_access_key=i.owner_access_key),s.config={},i.mounts&&(s.config.mounts=i.mounts),i.scaling_group&&(s.config.scaling_group=i.scaling_group),i.shmem&&(s.config.resource_opts={},s.config.resource_opts.shmem=i.shmem),i.env&&(s.config.environ=i.env)}return n=this._apiVersionMajor<5?this.newSignedRequest("POST",this.kernelPrefix+"/create",s):this.newSignedRequest("POST",""+this.kernelPrefix,s),this._wrapWithPromise(n,!1,null,r)}async createSessionFromTemplate(t,e=null,i=null,r={},n=0){null==i&&(i=this.generateSessionId());const s={template_id:t};if(e&&(s.image=e),i&&(s.name=i),r!={}){let t={};r.cpu&&(t.cpu=r.cpu),r.mem&&(t.mem=r.mem),r["cuda.device"]&&(t["cuda.device"]=parseInt(r["cuda.device"])),r.fgpu&&(t["cuda.shares"]=parseFloat(r.fgpu).toFixed(2)),r["cuda.shares"]&&(t["cuda.shares"]=parseFloat(r["cuda.shares"]).toFixed(2)),r.rocm&&(t["rocm.device"]=r.rocm),r.tpu&&(t["tpu.device"]=r.tpu),r.cluster_size&&(s.cluster_size=r.cluster_size),r.cluster_mode&&(s.cluster_mode=r.cluster_mode),r.group_name&&(s.group_name=r.group_name),r.domain&&(s.domain=r.domain),r.type&&(s.type=r.type),r.starts_at&&(s.starts_at=r.startsAt),r.enqueueOnly&&(s.enqueueOnly=r.enqueueOnly),r.maxWaitSeconds&&(s.maxWaitSeconds=r.maxWaitSeconds),r.reuseIfExists&&(s.reuseIfExists=r.reuseIfExists),r.startupCommand&&(s.startupCommand=r.startupCommand),r.bootstrap_script&&(s.bootstrap_script=r.bootstrap_script),r.owner_access_key&&(s.owner_access_key=r.owner_access_key),s.config={resources:t},r.mounts&&(s.config.mounts=r.mounts),r.scaling_group&&(s.config.scaling_group=r.scaling_group),r.shmem&&(s.config.resource_opts={},s.config.resource_opts.shmem=r.shmem),r.env&&(s.config.environ=r.env)}const o={template_id:t,name:i,config:{}};o.config={scaling_group:"default"};const a=this.newSignedRequest("POST",this.kernelPrefix+"/_/create-from-template",o);return this._wrapWithPromise(a,!1,null,n)}async get_info(t,e=null){let i=`${this.kernelPrefix}/${t}`;null!=e&&(i=`${i}?owner_access_key=${e}`);let r=this.newSignedRequest("GET",i,null);return this._wrapWithPromise(r)}async get_logs(t,e=null,i=0){let r=`${this.kernelPrefix}/${t}/logs`;null!=e&&(r=`${r}?owner_access_key=${e}`);let n=this.newSignedRequest("GET",r,null);return this._wrapWithPromise(n,!1,null,i)}getTaskLogs(t){const e=`${this.kernelPrefix}/_/logs?session_name=${t}`;let i=this.newSignedRequest("GET",e,null);return this._wrapWithPromise(i)}async destroy(t,e=null,i=!1){let r=`${this.kernelPrefix}/${t}`;r=null!==e?`${r}?owner_access_key=${e}${i?"&forced=true":""}`:`${r}${i?"?forced=true":""}`;let n=this.newSignedRequest("DELETE",r,null);return this._wrapWithPromise(n,!1,null,15e3,2)}async restart(t,e=null){let i=`${this.kernelPrefix}/${t}`;null!=e&&(i=`${i}?owner_access_key=${e}`);let r=this.newSignedRequest("PATCH",i,null);return this._wrapWithPromise(r)}async execute(t,e,i,r,n){let s={mode:i,code:r,runId:e,options:n},o=this.newSignedRequest("POST",`${this.kernelPrefix}/${t}`,s);return this._wrapWithPromise(o)}createKernel(t,e,i={},r=0){return this.createIfNotExists(t,e,i,r)}destroyKernel(t,e=null){return this.destroy(t,e)}refreshKernel(t,e=null){return this.restart(t,e)}runCode(t,e,i,r){return this.execute(e,i,r,t,{})}async shutdown_service(t,e){let i={service_name:e};const r=Of.stringify(i);let n=this.newSignedRequest("POST",`${this.kernelPrefix}/${t}/shutdown-service?${r}`,null);return this._wrapWithPromise(n,!0)}async upload(t,e,i){const r=new FormData;r.append("src",i,e);let n=this.newSignedRequest("POST",`${this.kernelPrefix}/${t}/upload`,r);return this._wrapWithPromise(n)}async download(t,e){let i={files:e};const r=Of.stringify(i);let n=this.newSignedRequest("GET",`${this.kernelPrefix}/${t}/download?${r}`,null);return this._wrapWithPromise(n,!0)}async download_single(t,e){let i={file:e};const r=Of.stringify(i);let n=this.newSignedRequest("GET",`${this.kernelPrefix}/${t}/download_single?${r}`,null);return this._wrapWithPromise(n,!0)}mangleUserAgentSignature(){return this.clientVersion+(this.agentSignature?"; "+this.agentSignature:"")}async query(t,e,i=null,r=0,n=0){let s={query:t,variables:e},o=this.newSignedRequest("POST","/admin/graphql",s);return this._wrapWithPromise(o,!1,i,r,n)}newSignedRequest(t,i,r){let n,s,o,a,h,u="application/json",f=new Date;if(null==r?s=n="":"function"==typeof r.getBoundary||r instanceof FormData?(n=r,s="",u="multipart/form-data"):s=n=JSON.stringify(r),h="","SESSION"===this._config.connectionMode)a=new Headers({"User-Agent":"Backend.AI Client for Javascript "+this.mangleUserAgentSignature(),"X-BackendAI-Version":this._config.apiVersion,"X-BackendAI-Date":f.toISOString()}),h=!0===i.startsWith("/server")?this._config.endpoint+i:this._config.endpoint+"/func"+i;else{o=this._config._apiVersion[1]<4?this.getAuthenticationString(t,i,f.toISOString(),s,u):this.getAuthenticationString(t,i,f.toISOString(),"",u);let e=this.getSignKey(this._config.secretKey,f),r=this.sign(e,"binary",o,"hex");a=new Headers({"User-Agent":"Backend.AI Client for Javascript "+this.mangleUserAgentSignature(),"X-BackendAI-Version":this._config.apiVersion,"X-BackendAI-Date":f.toISOString(),Authorization:`BackendAI signMethod=HMAC-SHA256, credential=${this._config.accessKey}:${r}`}),h=this._config.endpoint+i}return null!=r?("function"==typeof r.getBoundary&&a.set("Content-Type",r.getHeaders()["content-type"]),r instanceof FormData||(a.set("Content-Type",u),a.set("Content-Length",e.byteLength(s)))):a.set("Content-Type",u),{method:t,headers:a,cache:"default",body:n,uri:h}}newUnsignedRequest(t,e,i){return this.newPublicRequest(t,e,i,this._config.apiVersionMajor)}newPublicRequest(t,e,i,r){let n=new Date,s={method:t,headers:new Headers({"Content-Type":"application/json","User-Agent":"Backend.AI Client for Javascript "+this.mangleUserAgentSignature(),"X-BackendAI-Version":this._config.apiVersion,"X-BackendAI-Date":n.toISOString(),credentials:"include",mode:"cors"}),mode:"cors",cache:"default",uri:""};return"SESSION"===this._config.connectionMode&&!0===e.startsWith("/server")?s.uri=this._config.endpoint+e:"SESSION"===this._config.connectionMode&&!1===e.startsWith("/server")?s.uri=this._config.endpoint+"/func"+e:s.uri=this._config.endpoint+e,s}getAuthenticationString(t,e,i,r,n="application/json"){let s=xf.createHash(this._config.hashType).update(r).digest("hex");return t+"\n"+e+"\n"+i+"\nhost:"+this._config.endpointHost+"\ncontent-type:"+n+"\nx-backendai-version:"+this._config.apiVersion+"\n"+s}getCurrentDate(t){return("0000"+t.getUTCFullYear()).slice(-4)+("0"+(t.getUTCMonth()+1)).slice(-2)+("0"+t.getUTCDate()).slice(-2)}sign(t,i,r,n){let s=new e(t,i),o=xf.createHmac(this._config.hashType,s);return o.update(r,"utf8"),o.digest(n)}getSignKey(t,e){let i=this.sign(t,"utf8",this.getCurrentDate(e),"binary");return this.sign(i,"binary",this._config.endpointHost,"binary")}generateSessionId(t=8,e=!1){for(var i="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=0;n"aaaaeeeeiiiioooouuuuncsyoarsnpwgnmuxzh------".charAt(e.indexOf(t))).replace(/&/g,"-and-").replace(/[^\w\-]+/g,"").replace(/\-\-+/g,"-").replace(/^-+/,"").replace(/-+$/,"")}async fetchSSHKeypair(){let t=this.newSignedRequest("GET","/auth/ssh-keypair",null);return this._wrapWithPromise(t,!1)}async refreshSSHKeypair(){let t=this.newSignedRequest("PATCH","/auth/ssh-keypair",null);return this._wrapWithPromise(t,!1)}}class n{constructor(t){this.client=t,this.urlPrefix="/resource"}async list(t=null){let e=this.client.newSignedRequest("GET",this.urlPrefix+"/presets",t);return this.client._wrapWithPromise(e)}async check(t=null){let e=this.client.newSignedRequest("POST",this.urlPrefix+"/check-presets",t);return this.client._wrapWithPromise(e)}async add(t=null,e){if(!0===this.client.is_admin&&null!==t){let i="mutation($name: String!, $input: CreateResourcePresetInput!) { create_resource_preset(name: $name, props: $input) { ok msg }}",r={name:t,input:e};return this.client.query(i,r)}return Promise.resolve(!1)}async mutate(t=null,e){if(!0===this.client.is_admin&&null!==t){let i="mutation($name: String!, $input: ModifyResourcePresetInput!) { modify_resource_preset(name: $name, props: $input) { ok msg }}",r={name:t,input:e};return this.client.query(i,r)}return Promise.resolve(!1)}async delete(t=null){if(!0===this.client.is_admin&&null!==t){let e="mutation($name: String!) { delete_resource_preset(name: $name) { ok msg }}",i={name:t};return this.client.query(e,i)}return Promise.resolve(!1)}}class s{constructor(t,e=null){this.client=t,this.name=e,this.urlPrefix="/folders"}async list_allowed_types(){let t=this.client.newSignedRequest("GET",this.urlPrefix+"/_/allowed_types",null);return this.client._wrapWithPromise(t)}async create(t,e="",i="",r="general",n="rw",s=!1){let o;""!==e&&(o={name:t,host:e}),this.client.supports("group-folder")&&""!==i&&(o={name:t,host:e,group:i}),this.client.isAPIVersionCompatibleWith("v4.20191215")&&(r&&(o.usage_mode=r),n&&(o.permission=n)),this.client.supports("storage-proxy")&&(o.cloneable=s);let a=this.client.newSignedRequest("POST",""+this.urlPrefix,o);return this.client._wrapWithPromise(a)}async clone(t,e=null){let i=this.client.newSignedRequest("POST",`${this.urlPrefix}/${e}/clone`,t);return this.client._wrapWithPromise(i)}async update_folder(t,e=null){let i=this.client.newSignedRequest("POST",`${this.urlPrefix}/${e}/update-options`,t);return this.client._wrapWithPromise(i)}async list(t=null){let e=this.urlPrefix;if(t){const i={group_id:t};e+="?"+Of.stringify(i)}let i=this.client.newSignedRequest("GET",e,null);return this.client._wrapWithPromise(i)}async list_hosts(){let t=this.client.newSignedRequest("GET",this.urlPrefix+"/_/hosts",null);return this.client._wrapWithPromise(t)}async info(t=null){null==t&&(t=this.name);let e=this.client.newSignedRequest("GET",`${this.urlPrefix}/${t}`,null);return this.client._wrapWithPromise(e)}async rename(t=null){const e={new_name:t};let i=this.client.newSignedRequest("POST",`${this.urlPrefix}/${this.name}/rename`,e);return this.client._wrapWithPromise(i)}async delete(t=null){null==t&&(t=this.name);let e=this.client.newSignedRequest("DELETE",`${this.urlPrefix}/${t}`,null);return this.client._wrapWithPromise(e)}async leave_invited(t=null){null==t&&(t=this.name);let e=this.client.newSignedRequest("POST",`${this.urlPrefix}/${t}/leave`,null);return this.client._wrapWithPromise(e)}async upload(t,e,i=null){null==i&&(i=this.name);let r=new FormData;r.append("src",e,t);let n=this.client.newSignedRequest("POST",`${this.urlPrefix}/${i}/upload`,r);return this.client._wrapWithPromise(n)}async uploadFormData(t,e=null){let i=this.client.newSignedRequest("POST",`${this.urlPrefix}/${e}/upload`,t);return this.client._wrapWithPromise(i)}async create_upload_session(t,e,i=null){null==i&&(i=this.name);let r,n={path:t,size:e.size};r=this.client._apiVersionMajor<6?`${this.urlPrefix}/${i}/create_upload_session`:`${this.urlPrefix}/${i}/request-upload`;const s=this.client.newSignedRequest("POST",r,n),o=await this.client._wrapWithPromise(s),a=o.token;let h;return this.client._apiVersionMajor<6?(h=this.client._config.endpoint,"SESSION"===this.client._config.connectionMode&&(h+="/func"),h+=`${this.urlPrefix}/_/tus/upload/${a}`):h=`${o.url}?token=${a}`,Promise.resolve(h)}async mkdir(t,e=null,i=null,r=null){null==e&&(e=this.name);const n={path:t};i&&(n.parents=i),r&&(n.exist_ok=r);const s=this.client.newSignedRequest("POST",`${this.urlPrefix}/${e}/mkdir`,n);return this.client._wrapWithPromise(s)}async rename_file(t,e,i=null,r=!1){let n;null==i&&(i=this.name),n=this.client.isAPIVersionCompatibleWith("v6.20200815")?{target_path:t,new_name:e,is_dir:r}:{target_path:t,new_name:e};let s=this.client.newSignedRequest("POST",`${this.urlPrefix}/${i}/rename_file`,n);return this.client._wrapWithPromise(s)}async delete_files(t,e=!1,i=null){null==i&&(i=this.name),null==e&&(e=!1);let r={files:t,recursive:e},n=this.client.newSignedRequest("DELETE",`${this.urlPrefix}/${i}/delete_files`,r);return this.client._wrapWithPromise(n)}async download(t,e=!1,i=!1,r=!1){const n={file:t,archive:i},s=Of.stringify(n);if(this.client._apiVersionMajor<6){const t=this.client.newSignedRequest("GET",`${this.urlPrefix}/${e}/download_single?${s}`,null);return this.client._wrapWithPromise(t,!0)}{const n=await this.request_download_token(t,e),s=`${n.url}?token=${n.token}&archive=${i}&no_cache=${r}`;return fetch(s)}}async request_download_token(t,e=!1,i=!1){let r,n={file:t,archive:i};r=this.client._apiVersionMajor<6?`${this.urlPrefix}/${e}/request_download`:`${this.urlPrefix}/${e}/request-download`;const s=this.client.newSignedRequest("POST",r,n);return this.client._wrapWithPromise(s)}async download_with_token(t=""){let e={token:t},i=Of.stringify(e),r=this.client.newSignedRequest("GET",`${this.urlPrefix}/_/download_with_token?${i}`,null);return this.client._wrapWithPromise(r,!0)}get_download_url_with_token(t=""){const e={token:t};let i=Of.stringify(e);return"SESSION"===this.client._config.connectionMode?`${this.client._config.endpoint}/func${this.urlPrefix}/_/download_with_token?${i}`:`${this.client._config.endpoint}${this.urlPrefix}/_/download_with_token?${i}`}async list_files(t,e=null){null==e&&(e=this.name);let i={path:t},r=Of.stringify(i),n=this.client.newSignedRequest("GET",`${this.urlPrefix}/${e}/files?${r}`,null);return this.client._wrapWithPromise(n)}async invite(t,e,i=null){null==i&&(i=this.name);let r={perm:t,user_ids:e},n=this.client.newSignedRequest("POST",`${this.urlPrefix}/${i}/invite`,r);return this.client._wrapWithPromise(n)}async invitations(){let t=this.client.newSignedRequest("GET",this.urlPrefix+"/invitations/list",null);return this.client._wrapWithPromise(t)}async accept_invitation(t){let e={inv_id:t},i=this.client.newSignedRequest("POST",this.urlPrefix+"/invitations/accept",e);return this.client._wrapWithPromise(i)}async delete_invitation(t){let e={inv_id:t},i=this.client.newSignedRequest("DELETE",this.urlPrefix+"/invitations/delete",e);return this.client._wrapWithPromise(i)}async list_invitees(t=null){let e="/folders/_/shared";null!==t&&(e=`${e}?vfolder_id=${t}`);let i=this.client.newSignedRequest("GET",e,null);return this.client._wrapWithPromise(i)}async modify_invitee_permission(t){let e=this.client.newSignedRequest("POST","/folders/_/shared",t);return this.client._wrapWithPromise(e)}async share(t,e,i=null){i||(i=this.name);const r={permission:t,emails:e},n=this.client.newSignedRequest("POST",`${this.urlPrefix}/${i}/share`,r);return this.client._wrapWithPromise(n)}async unshare(t,e=null){e||(e=this.name);const i={emails:t},r=this.client.newSignedRequest("DELETE",`${this.urlPrefix}/${e}/unshare`,i);return this.client._wrapWithPromise(r)}}class o{constructor(t){this.client=t}async list(t="ALIVE",e=["id","status","region","first_contact","cpu_cur_pct","mem_cur_bytes","available_slots","occupied_slots"],i=0){if(!1===["ALIVE","TERMINATED"].includes(t))return Promise.resolve(!1);let r="query($status: String) { agents(status: $status) { "+e.join(" ")+" }}",n={status:t};return this.client.query(r,n,null,i)}}class a{constructor(t){this.client=t}async list(t=["id","backend","capabilities"],e=20,i=0){let r=`query($offset:Int!, $limit:Int!) { storage_volume_list(limit:$limit, offset:$offset) { items { ${t.join(" ")} } total_count }}`,n={limit:e,offset:i};return this.client.query(r,n)}async detail(t="",e=["id","backend","path","fsprefix","capabilities"]){let i="query($vfolder_host: String!) { storage_volume(id: $vfolder_host) { "+e.join(" ")+" }}",r={vfolder_host:t};return this.client.query(i,r)}}class h{constructor(t,e=null){this.client=t,this.name=e}async info(t,e=["access_key","secret_key","is_active","is_admin","user_id","created_at","last_used","concurrency_limit","concurrency_used","rate_limit","num_queries","resource_policy"]){let i,r;return this.client.is_admin?(i="query($access_key: String!) { keypair(access_key: $access_key) { "+e.join(" ")+" }}",r={access_key:t}):(i="query { keypair { "+e.join(" ")+" }}",r={}),this.client.query(i,r)}async list(t=null,e=["access_key","is_active","is_admin","user_id","created_at","last_used","concurrency_used","rate_limit","num_queries","resource_policy"],i=!0){let r,n;if(this.client._apiVersionMajor<5)return r=this.client.is_admin&&null==t?`\n query($is_active: Boolean) {\n keypairs(is_active: $is_active) {\n ${e.join(" ")}\n }\n }\n `:`\n query($email: String!, $is_active: Boolean) {\n keypairs(email: $email, is_active: $is_active) {\n ${e.join(" ")}\n }\n }\n `,n={email:t||this.client.email,is_active:i},this.client.query(r,n);{const s=100,o=[];r=this.client.is_admin&&null==t?`\n query($offset:Int!, $limit:Int!, $is_active: Boolean) {\n keypair_list(offset:$offset, limit:$limit, is_active: $is_active) {\n items { ${e.join(" ")} }\n total_count\n }\n }\n `:`\n query($offset:Int!, $limit:Int!, $email: String!, $is_active: Boolean) {\n keypair_list(offset:$offset, limit:$limit, email: $email, is_active: $is_active) {\n items { ${e.join(" ")} }\n total_count\n }\n }\n `;for(let e=0;e<10*s;e+=s){n={offset:e,limit:s,email:t||this.client.email,is_active:i};const a=await this.client.query(r,n);if(o.push(...a.keypair_list.items),e>=a.keypair_list.total_count)break}const a={keypairs:o};return Promise.resolve(a)}}async add(t=null,e=!0,i=!1,r="default",n=1e3){let s=`mutation($user_id: String!, $input: KeyPairInput!) { create_keypair(user_id: $user_id, props: $input) { ok msg keypair { ${["is_active","is_admin","resource_policy","concurrency_limit","rate_limit"].join(" ")} } }}`,o={user_id:t,input:{is_active:e,is_admin:i,resource_policy:r,rate_limit:n}};return this.client.query(s,o)}async mutate(t,e){let i={access_key:t,input:e};return this.client.query("mutation($access_key: String!, $input: ModifyKeyPairInput!) { modify_keypair(access_key: $access_key, props: $input) { ok msg }}",i)}async delete(t){let e={access_key:t};return this.client.query("mutation($access_key: String!) { delete_keypair(access_key: $access_key) { ok msg }}",e)}}class u{constructor(t){this.client=t}async get(t=null,e=["name","created_at","default_for_unspecified","total_resource_slots","max_concurrent_sessions","max_containers_per_session","max_vfolder_count","max_vfolder_size","allowed_vfolder_hosts","idle_timeout"]){let i,r;return null===t?(i=`query { keypair_resource_policies { ${e.join(" ")} }}`,r={n:t}):(i=`query($n:String!) { keypair_resource_policy(name: $n) { ${e.join(" ")} }}`,r={n:t}),this.client.query(i,r)}async add(t=null,e){let i=["name","created_at","default_for_unspecified","total_resource_slots","max_concurrent_sessions","max_containers_per_session","max_vfolder_count","max_vfolder_size","allowed_vfolder_hosts","idle_timeout"];if(!0===this.client.is_admin&&null!==t){let r=`mutation($name: String!, $input: CreateKeyPairResourcePolicyInput!) { create_keypair_resource_policy(name: $name, props: $input) { ok msg resource_policy { ${i.join(" ")} } }}`,n={name:t,input:e};return this.client.query(r,n)}return Promise.resolve(!1)}async mutate(t=null,e){if(!0===this.client.is_admin&&null!==t){let i="mutation($name: String!, $input: ModifyKeyPairResourcePolicyInput!) { modify_keypair_resource_policy(name: $name, props: $input) { ok msg }}",r={name:t,input:e};return this.client.query(i,r)}return Promise.resolve(!1)}async delete(t=null){if(!0===this.client.is_superadmin&&null!==t){let e="mutation($name: String!) { delete_keypair_resource_policy(name: $name) { ok msg }}",i={name:t};return this.client.query(e,i)}return Promise.resolve(!1)}}class f{constructor(t){this.client=t}async list(t=["name","tag","registry","digest","installed","labels { key value }","resource_limits { key min max }"],e=!1,i=!1){let r,n;return this.client.supports("system-images")?!0===e?(r=`query($installed:Boolean) { images(is_installed:$installed) { ${t.join(" ")} }}`,n={installed:e,is_operation:i}):(r=`query { images { ${t.join(" ")} }}`,n={is_operation:i}):(r=`query { images { ${t.join(" ")} }}`,n={}),this.client.query(r,n)}async modifyResource(t,e,i,r){let n=[];return t=t.replace(":","%3A"),e=e.replace("/","%2F"),Object.keys(r).forEach(s=>{Object.keys(r[s]).forEach(o=>{const a=this.client.newSignedRequest("POST","/config/set",{key:`images/${t}/${e}/${i}/resource/${s}/${o}`,value:r[s][o]});n.push(this.client._wrapWithPromise(a))})}),Promise.all(n)}async modifyLabel(t,e,i,r,n){t=t.replace(":","%3A"),e=e.replace("/","%2F"),i=i.replace("/","%2F");const s=this.client.newSignedRequest("POST","/config/set",{key:`images/${t}/${e}/${i}/labels/${r}`,value:n});return this.client._wrapWithPromise(s)}async install(t,e={},i="index.docker.io"){"index.docker.io"!=i?i+="/":i="",i=i.replace(":","%3A");let r=this.client.generateSessionId();return 0===Object.keys(e).length&&(e={cpu:"1",mem:"512m"}),this.client.createIfNotExists(i+t,r,e,6e5).then(t=>this.client.destroy(r)).catch(t=>{throw t})}async uninstall(t,e="index.docker.io"){return Promise.resolve(!1)}async get(t,e,i){t=t.replace(":","%3A");const r=this.client.newSignedRequest("POST","/config/get",{key:`images/${t}/${e}/${i}/resource/`,prefix:!0});return this.client._wrapWithPromise(r)}}class l{constructor(t){this.client=t}async total_count(t="RUNNING",e="",i=1,r=0,n=""){let s,o;return s="query($limit:Int!, $offset:Int!, $ak:String, $group_id:String, $status:String) {\n compute_session_list(limit:$limit, offset:$offset, access_key:$ak, group_id:$group_id, status:$status) {\n total_count\n }\n }",o={limit:i,offset:r,status:t},""!=e&&(o.ak=e),""!=n&&(o.group_id=n),this.client.query("query($limit:Int!, $offset:Int!, $ak:String, $group_id:String, $status:String) {\n compute_session_list(limit:$limit, offset:$offset, access_key:$ak, group_id:$group_id, status:$status) {\n total_count\n }\n }",o)}async list(t=["id","name","image","created_at","terminated_at","status","status_info","occupied_slots","containers {live_stat last_stat}"],e="RUNNING",i="",r=30,n=0,s="",o=0){let a,h;return a=`query($limit:Int!, $offset:Int!, $ak:String, $group_id:String, $status:String) {\n compute_session_list(limit:$limit, offset:$offset, access_key:$ak, group_id:$group_id, status:$status) {\n items { ${(t=this.client._updateFieldCompatibilityByAPIVersion(t)).join(" ")}}\n total_count\n }\n }`,h={limit:r,offset:n,status:e},""!=i&&(h.ak=i),""!=s&&(h.group_id=s),this.client.query(a,h,null,o)}async listAll(t=["id","name","image","created_at","terminated_at","status","status_info","occupied_slots","containers {live_stat last_stat}"],e="RUNNING,RESTARTING,TERMINATING,PENDING,PREPARING,PULLING,TERMINATED,CANCELLED,ERROR",i="",r=100,n=0,s="",o=0){let a,h;const u=[];a=`query($limit:Int!, $offset:Int!, $ak:String, $group_id:String, $status:String) {\n compute_session_list(limit:$limit, offset:$offset, access_key:$ak, group_id:$group_id, status:$status) {\n items { ${(t=this.client._updateFieldCompatibilityByAPIVersion(t)).join(" ")}}\n total_count\n }\n }`;for(let f=0;f<10*r;f+=r){h={limit:r,offset:f,status:e},""!=i&&(h.access_key=i),""!=s&&(h.group_id=s);const t=await this.client.query(a,h,null,o);if(console.log(t.compute_session_list.total_count),u.push(...t.compute_session_list.items),f>=t.compute_session_list.total_count)break}return Promise.resolve(u)}async get(t=["id","session_name","lang","created_at","terminated_at","status","status_info","occupied_slots","cpu_used","io_read_bytes","io_write_bytes"],e=""){let i,r;return i=`query($session_uuid: UUID!) {\n compute_session(id:$session_uuid) {\n ${(t=this.client._updateFieldCompatibilityByAPIVersion(t)).join(" ")}\n }\n }`,r={session_uuid:e},this.client.query(i,r)}}class d{constructor(t){this.client=t,this.urlPrefix="/template/session"}async list(t=!1,e=null){let i=this.urlPrefix;if(t){const e={all:t};i+="?"+Of.stringify(e)}if(e){const t={group_id:e};i+="?"+Of.stringify(t)}let r=this.client.newSignedRequest("GET",i,null);return this.client._wrapWithPromise(r)}}class c{constructor(t){this.client=t,this.resources={},this._init_resource_values()}_init_resource_values(){this.resources.cpu={},this.resources.cpu.total=0,this.resources.cpu.used=0,this.resources.cpu.percent=0,this.resources.mem={},this.resources.mem.total=0,this.resources.mem.allocated=0,this.resources.mem.used=0,this.resources.gpu={},this.resources.gpu.total=0,this.resources.gpu.used=0,this.resources["cuda.device"]={},this.resources["cuda.device"].total=0,this.resources["cuda.device"].used=0,this.resources.fgpu={},this.resources.fgpu.total=0,this.resources.fgpu.used=0,this.resources["cuda.shares"]={},this.resources["cuda.shares"].total=0,this.resources["cuda.shares"].used=0,this.resources["rocm.device"]={},this.resources["rocm.device"].total=0,this.resources["rocm.device"].used=0,this.resources["tpu.device"]={},this.resources["tpu.device"].total=0,this.resources["tpu.device"].used=0,this.resources.agents={},this.resources.agents.total=0,this.resources.agents.using=0,this.agents=[]}async totalResourceInformation(t="ALIVE"){if(this.client.is_admin){let e=["id","addr","status","first_contact","cpu_cur_pct","mem_cur_bytes","occupied_slots","available_slots"];return this.client.agent.list(t,e).then(t=>(this._init_resource_values(),this.agents=t.agents,Object.keys(this.agents).map((t,e)=>{let i=this.agents[t],r=JSON.parse(i.occupied_slots),n=JSON.parse(i.available_slots);"cpu"in n&&(this.resources.cpu.total=this.resources.cpu.total+Math.floor(Number(n.cpu))),"cpu"in r&&(this.resources.cpu.used=this.resources.cpu.used+Math.floor(Number(r.cpu))),this.resources.cpu.percent=this.resources.cpu.percent+parseFloat(i.cpu_cur_pct),void 0===r.mem&&(r.mem=0),this.resources.mem.total=parseFloat(this.resources.mem.total)+parseInt(this.client.utils.changeBinaryUnit(n.mem,"b")),this.resources.mem.allocated=parseInt(this.resources.mem.allocated)+parseInt(this.client.utils.changeBinaryUnit(r.mem,"b")),this.resources.mem.used=parseInt(this.resources.mem.used)+parseInt(this.client.utils.changeBinaryUnit(i.mem_cur_bytes,"b")),"cuda.device"in n&&(this.resources["cuda.device"].total=parseInt(this.resources["cuda.device"].total)+Math.floor(Number(n["cuda.device"]))),"cuda.device"in r&&(this.resources["cuda.device"].used=parseInt(this.resources["cuda.device"].used)+Math.floor(Number(r["cuda.device"]))),"cuda.shares"in n&&(this.resources["cuda.shares"].total=parseFloat(this.resources["cuda.shares"].total)+parseFloat(n["cuda.shares"])),"cuda.shares"in r&&(this.resources["cuda.shares"].used=parseFloat(this.resources["cuda.shares"].used)+parseFloat(r["cuda.shares"])),"rocm.device"in n&&(this.resources["rocm.device"].total=parseInt(this.resources["rocm.device"].total)+Math.floor(Number(n["rocm.device"]))),"rocm.device"in r&&(this.resources["rocm.device"].used=parseInt(this.resources["rocm.device"].used)+Math.floor(Number(r["rocm.device"]))),"tpu.device"in n&&(this.resources["tpu.device"].total=parseInt(this.resources["tpu.device"].total)+Math.floor(Number(n["tpu.device"]))),"tpu.device"in r&&(this.resources["tpu.device"].used=parseInt(this.resources["tpu.device"].used)+Math.floor(Number(r["tpu.device"]))),isNaN(this.resources.cpu.used)&&(this.resources.cpu.used=0),isNaN(this.resources.mem.used)&&(this.resources.mem.used=0),isNaN(this.resources.gpu.used)&&(this.resources.gpu.used=0),isNaN(this.resources.fgpu.used)&&(this.resources.fgpu.used=0)}),this.resources.gpu.total=this.resources["cuda.device"].total,this.resources.gpu.used=this.resources["cuda.device"].used,this.resources.fgpu.used=this.resources["cuda.shares"].used.toFixed(2),this.resources.fgpu.total=this.resources["cuda.shares"].total.toFixed(2),this.resources.agents.total=Object.keys(this.agents).length,this.resources.agents.using=Object.keys(this.agents).length,Promise.resolve(this.resources))).catch(t=>{throw t})}return Promise.resolve(!1)}async user_stats(){const t=this.client.newSignedRequest("GET","/resource/stats/user/month",null);return this.client._wrapWithPromise(t)}}class p{constructor(t){this.client=t}async list(t=!0,e=!1,i=["id","name","description","is_active","created_at","modified_at","domain_name"]){let r,n;return!0===this.client.is_admin?(r=`query($is_active:Boolean) { groups(is_active:$is_active) { ${i.join(" ")} }}`,n={is_active:t},!1!==e&&(r=`query($domain_name: String, $is_active:Boolean) { groups(domain_name: $domain_name, is_active:$is_active) { ${i.join(" ")} }}`,n={is_active:t,domain_name:e})):(r=`query($is_active:Boolean) { groups(is_active:$is_active) { ${i.join(" ")} }}`,n={is_active:t}),this.client.query(r,n)}}class m{constructor(t){this.client=t}async get(t=!1,e=["name","description","is_active","created_at","modified_at","total_resource_slots","allowed_vfolder_hosts","allowed_docker_registries","integration_id","scaling_groups"]){let i,r;if(!1!==t)return i=`query($name: String) { domain(name: $name) { ${e.join(" ")} }}`,r={name:t},this.client.query(i,r)}async list(t=["name","description","is_active","created_at","total_resource_slots","allowed_vfolder_hosts","allowed_docker_registries","integration_id"]){let e=`query { domains { ${t.join(" ")} }}`;return this.client.query(e,{})}async update(t=!1,e){if(!0===this.client.is_superadmin){let i="mutation($name: String!, $input: ModifyDomainInput!) { modify_domain(name: $name, props: $input) { ok msg }}",r={name:t,input:e};return this.client.query(i,r)}return Promise.resolve(!1)}}class g{constructor(t){this.client=t,this.urlPrefix="/resource"}attach_background_task(t){var e="/events/background-task?task_id="+t;let i=this.client.newSignedRequest("GET",e,null);return new EventSource(i.uri,{withCredentials:!0})}async rescan_images(t=""){if(!0===this.client.is_admin){let e,i;return""!==t?(t=decodeURIComponent(t),e="mutation($registry: String) { rescan_images(registry: $registry) { ok msg task_id }}",i={registry:t}):(e="mutation { rescan_images { ok msg task_id }}",i={}),this.client.query(e,i,null,6e5)}return Promise.resolve(!1)}async recalculate_usage(){if(!0===this.client.is_superadmin){let t=this.client.newSignedRequest("POST",this.urlPrefix+"/recalculate-usage",null);return this.client._wrapWithPromise(t,null,null,6e4)}}}class v{constructor(t){this.client=t}async list(t=!0,e=["username","password","need_password_change","full_name","description","is_active","domain_name","role","groups {id name}"]){let i,r;if(this.client._apiVersionMajor<5)return i=this.client.is_admin?`\n query($is_active:Boolean) {\n users(is_active:$is_active) { ${e.join(" ")} }\n }\n `:`\n query {\n users { ${e.join(" ")} }\n }\n `,r=this.client.is_admin?{is_active:t}:{},this.client.query(i,r);{const n=100,s=[];i=this.client.is_admin?`\n query($offset:Int!, $limit:Int!, $is_active:Boolean) {\n user_list(offset:$offset, limit:$limit, is_active:$is_active) {\n items { ${e.join(" ")} }\n total_count\n }\n }\n `:`\n query($offset:Int!, $limit:Int!) {\n user_list(offset:$offset, limit:$limit) {\n items { ${e.join(" ")} }\n total_count\n }\n }\n `;for(let e=0;e<10*n;e+=n){r=this.client.is_admin?{offset:e,limit:n,is_active:t}:{offset:e,limit:n};const o=await this.client.query(i,r);if(s.push(...o.user_list.items),e>=o.user_list.total_count)break}const o={users:s};return Promise.resolve(o)}}async get(t,e=["email","username","password","need_password_change","full_name","description","is_active","domain_name","role","groups {id name}"]){let i,r;return!0===this.client.is_admin?(i=`query($email:String) { user (email:$email) { ${e.join(" ")} }}`,r={email:t}):(i=`query { user { ${e.join(" ")} }}`,r={}),this.client.query(i,r)}async create(t=null,e){let i=["username","password","need_password_change","full_name","description","is_active","domain_name","role","groups{id, name}"];if(!0===this.client.is_admin){let r=`mutation($email: String!, $input: UserInput!) { create_user(email: $email, props: $input) { ok msg user { ${i.join(" ")} } }}`,n={email:t,input:e};return this.client.query(r,n)}return Promise.resolve(!1)}async update(t=null,e){if(!0===this.client.is_superadmin){let i="mutation($email: String!, $input: ModifyUserInput!) { modify_user(email: $email, props: $input) { ok msg }}",r={email:t,input:e};return this.client.query(i,r)}return Promise.resolve(!1)}async delete(t){if(!0===this.client.is_superadmin){let e="mutation($email: String!) { delete_user(email: $email) { ok msg }}",i={email:t};return this.client.query(e,i)}return Promise.resolve(!1)}}class b{constructor(t){this.client=t}async list_available(){if(!0===this.client.is_superadmin){const t=`query { scaling_groups { ${["name","description","is_active","created_at","driver","driver_opts","scheduler","scheduler_opts"].join(" ")} }}`,e={};return this.client.query(t,e)}return Promise.resolve(!1)}async list(t="default"){const e="/scaling-groups?group="+t,i=this.client.newSignedRequest("GET",e,null);return this.client._wrapWithPromise(i)}async create(t,e=""){let i={name:t,input:{description:e,is_active:!0,driver:"static",scheduler:"fifo",driver_opts:"{}",scheduler_opts:"{}"}};return this.client.query("mutation($name: String!, $input: ScalingGroupInput!) { create_scaling_group(name: $name, props: $input) { ok msg }}",i)}async associate_domain(t,e){let i={domain:t,scaling_group:e};return this.client.query("mutation($domain: String!, $scaling_group: String!) { associate_scaling_group_with_domain(domain: $domain, scaling_group: $scaling_group) { ok msg }}",i)}async update(t,e){let i={name:t,input:e};return this.client.query("mutation($name: String!, $input: ModifyScalingGroupInput!) { modify_scaling_group(name: $name, props: $input) { ok msg }}",i)}async delete(t){let e={name:t};return this.client.query("mutation($name: String!) { delete_scaling_group(name: $name) { ok msg }}",e)}}class y{constructor(t){this.client=t}async list(){const t=this.client.newSignedRequest("POST","/config/get",{key:"config/docker/registry",prefix:!0});return this.client._wrapWithPromise(t)}async add(t,e){let i="config/docker/registry/"+(t=encodeURIComponent(t));const r=this.client.newSignedRequest("POST","/config/set",{key:i,value:e});return this.client._wrapWithPromise(r)}async delete(t){t=encodeURIComponent(t);const e=this.client.newSignedRequest("POST","/config/delete",{key:"config/docker/registry/"+t,prefix:!0});return this.client._wrapWithPromise(e)}}class w{constructor(t){this.client=t,this.config=null}async list(t=""){t="config/"+t;const e=this.client.newSignedRequest("POST","/config/get",{key:t,prefix:!0});return this.client._wrapWithPromise(e)}async get(t){t="config/"+t;const e=this.client.newSignedRequest("POST","/config/get",{key:t,prefix:!1});return this.client._wrapWithPromise(e)}async set(t,e){t="config/"+t;const i=this.client.newSignedRequest("POST","/config/set",{key:t,value:e});return this.client._wrapWithPromise(i)}async delete(t,e=!1){t="config/"+t;const i=this.client.newSignedRequest("POST","/config/delete",{key:""+t,prefix:e});return this.client._wrapWithPromise(i)}}class M{constructor(t){this.client=t,this.config=null}async get_announcement(){const t=this.client.newSignedRequest("GET","/manager/announcement",null);return this.client._wrapWithPromise(t)}async update_announcement(t=!0,e){const i=this.client.newSignedRequest("POST","/manager/announcement",{enabled:t,message:e});return this.client._wrapWithPromise(i)}}class _{constructor(t){this.client=t,this.config=null}async get_bootstrap_script(){if(!this.client._config.accessKey)throw"Your access key is not set";const t=this.client.newSignedRequest("GET","/user-config/bootstrap-script");return this.client._wrapWithPromise(t)}async update_bootstrap_script(t){const e=this.client.newSignedRequest("POST","/user-config/bootstrap-script",{script:t});return this.client._wrapWithPromise(e)}async create(t="",e){if(!this.client._config.accessKey)throw"Your access key is not set";let i={path:e,data:t,permission:"644"};const r=this.client.newSignedRequest("POST","/user-config/dotfiles",i);return this.client._wrapWithPromise(r)}async get(){if(!this.client._config.accessKey)throw"Your access key is not set";const t=this.client.newSignedRequest("GET","/user-config/dotfiles");return this.client._wrapWithPromise(t)}async update(t,e){let i={data:t,path:e,permission:"644"};const r=this.client.newSignedRequest("PATCH","/user-config/dotfiles",i);return this.client._wrapWithPromise(r)}async delete(t){let e={path:t};const i=this.client.newSignedRequest("DELETE","/user-config/dotfiles",e);return this.client._wrapWithPromise(i)}}class S{constructor(t){this.client=t,this.config=null}async getLicense(){if(!0!==this.client.is_superadmin)return Promise.resolve(!1);if(void 0===this.certificate){const t=this.client.newSignedRequest("GET","/license");let e=await this.client._wrapWithPromise(t);return this.certificate=e.certificate,"valid"===e.status?this.certificate.valid=!0:this.certificate.valid=!1,Promise.resolve(this.certificate)}}}class E{constructor(t){this.client=t,this.config=null}async ping(){const t=this.client.newSignedRequest("GET","/cloud/ping");return this.client._wrapWithPromise(t)}async verify_email(t){const e={verification_code:t},i=this.client.newSignedRequest("POST","/cloud/verify-email",e);return this.client._wrapWithPromise(i)}async send_verification_email(t){const e={email:t},i=this.client.newSignedRequest("POST","/cloud/send-verification-email",e);return this.client._wrapWithPromise(i)}async send_password_change_email(t){const e={email:t},i=this.client.newSignedRequest("POST","/cloud/send-password-change-email",e);return this.client._wrapWithPromise(i)}async change_password(t,e,i){const r={email:t,password:e,token:i},n=this.client.newSignedRequest("POST","/cloud/change-password",r);return this.client._wrapWithPromise(n)}}class k{constructor(t){this.client=t}changeBinaryUnit(t,e="g",i="b"){if(void 0===t)return t;let r;const n=["b","k","m","g","t","p","auto"],s=["B","KiB","MiB","GiB","TiB","PiB"];if(!n.includes(e))return!1;if((t=t.toString()).indexOf(" ")>=0){let e=t.split(/(\s+)/);t=s.includes(e[2])?e[0]+n[s.indexOf(e[2])]:e[0]}return n.includes(t.substr(-1))?(r=t.substr(-1),t=t.slice(0,-1)):r=i,t*Math.pow(1024,Math.floor(n.indexOf(r)-n.indexOf(e)))}elapsedTime(t,e){var i=new Date(t);if(null===e)var r=new Date;else r=new Date(e);var n=Math.floor((r.getTime()-i.getTime())/1e3),s=Math.floor(n/86400);n-=86400*s;var o=Math.floor(n/3600);n-=3600*o;var a=Math.floor(n/60),h=n-=60*a,u="";return void 0!==s&&s>0&&(u=u+String(s)+" Day "),void 0!==o&&(u=u+this._padding_zeros(o,2)+":"),void 0!==a&&(u=u+this._padding_zeros(a,2)+":"),u+this._padding_zeros(h,2)+""}_padding_zeros(t,e){return(t+="").length>=e?t:new Array(e-t.length+1).join("0")+t}gqlToObject(t,e){let i={};return t.forEach((function(t){i[t[e]]=t})),i}gqlToList(t,e){let i=[];return t.forEach((function(t){i.push(t[e])})),i}}Object.defineProperty(r,"ERR_SERVER",{value:0,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(r,"ERR_RESPONSE",{value:1,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(r,"ERR_REQUEST",{value:2,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(r,"ERR_ABORT",{value:3,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(r,"ERR_TIMEOUT",{value:4,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(r,"ERR_UNKNOWN",{value:99,writable:!1,enumerable:!0,configurable:!1});const R={Client:r,ClientConfig:i};Lf.backend=R,Lf.Client=r,Lf.ClientConfig=i,Lf.BackendAIClient=r,Lf.BackendAIClientConfig=i}).call(this)}.call(this,D,M({}).Buffer),Lf})); \ No newline at end of file diff --git a/src/lib/backend.ai-client-node.js b/src/lib/backend.ai-client-node.js index 7a8a719b2c..a181b0846a 100644 --- a/src/lib/backend.ai-client-node.js +++ b/src/lib/backend.ai-client-node.js @@ -683,8 +683,8 @@ class Client { if (resources['owner_access_key']) { params['owner_access_key'] = resources['owner_access_key']; } - //params['config'] = {}; - params['config'] = { resources: config }; + params['config'] = {}; + // params['config'] = {resources: config}; if (resources['mounts']) { params['config'].mounts = resources['mounts']; } @@ -714,7 +714,103 @@ class Client { * * @param {string} sessionId - the sessionId given when created */ - async createSesisonFromTemplate(kernelType, sessionId, resources = {}, timeout = 0) { + async createSessionFromTemplate(templateId, image = null, sessionName = null, resources = {}, timeout = 0) { + if (typeof sessionName === 'undefined' || sessionName === null) + sessionName = this.generateSessionId(); + const params = { template_id: templateId }; + if (image) { + params['image'] = image; + } + if (sessionName) { + params['name'] = sessionName; + } + if (resources != {}) { + let config = {}; + if (resources['cpu']) { + config['cpu'] = resources['cpu']; + } + if (resources['mem']) { + config['mem'] = resources['mem']; + } + if (resources['cuda.device']) { + config['cuda.device'] = parseInt(resources['cuda.device']); + } + if (resources['fgpu']) { + config['cuda.shares'] = parseFloat(resources['fgpu']).toFixed(2); // 19.09 and above + } + if (resources['cuda.shares']) { + config['cuda.shares'] = parseFloat(resources['cuda.shares']).toFixed(2); + } + if (resources['rocm']) { + config['rocm.device'] = resources['rocm']; + } + if (resources['tpu']) { + config['tpu.device'] = resources['tpu']; + } + if (resources['cluster_size']) { + params['cluster_size'] = resources['cluster_size']; + } + if (resources['cluster_mode']) { + params['cluster_mode'] = resources['cluster_mode']; + } + if (resources['group_name']) { + params['group_name'] = resources['group_name']; + } + if (resources['domain']) { + params['domain'] = resources['domain']; + } + if (resources['type']) { + params['type'] = resources['type']; + } + if (resources['starts_at']) { + params['starts_at'] = resources['startsAt']; + } + if (resources['enqueueOnly']) { + params['enqueueOnly'] = resources['enqueueOnly']; + } + if (resources['maxWaitSeconds']) { + params['maxWaitSeconds'] = resources['maxWaitSeconds']; + } + if (resources['reuseIfExists']) { + params['reuseIfExists'] = resources['reuseIfExists']; + } + if (resources['startupCommand']) { + params['startupCommand'] = resources['startupCommand']; + } + if (resources['bootstrap_script']) { + params['bootstrap_script'] = resources['bootstrap_script']; + } + if (resources['owner_access_key']) { + params['owner_access_key'] = resources['owner_access_key']; + } + // params['config'] = {}; + params['config'] = { resources: config }; + if (resources['mounts']) { + params['config'].mounts = resources['mounts']; + } + if (resources['scaling_group']) { + params['config'].scaling_group = resources['scaling_group']; + } + if (resources['shmem']) { + params['config'].resource_opts = {}; + params['config'].resource_opts.shmem = resources['shmem']; + } + if (resources['env']) { + params['config'].environ = resources['env']; + } + } + const params2 = { + template_id: templateId, + name: sessionName, + config: {}, + }; + const config2 = { + scaling_group: 'default', + }; + params2.config = config2; + // const rqst = this.newSignedRequest('POST', `${this.kernelPrefix}/_/create-from-template`, params); + const rqst = this.newSignedRequest('POST', `${this.kernelPrefix}/_/create-from-template`, params2); + return this._wrapWithPromise(rqst, false, null, timeout); } /** * Obtain the session information by given sessionId. diff --git a/src/lib/backend.ai-client-node.ts b/src/lib/backend.ai-client-node.ts index 5d8ab6a4e4..9c5b6945e0 100644 --- a/src/lib/backend.ai-client-node.ts +++ b/src/lib/backend.ai-client-node.ts @@ -769,8 +769,8 @@ class Client { if (resources['owner_access_key']) { params['owner_access_key'] = resources['owner_access_key']; } - //params['config'] = {}; - params['config'] = {resources: config}; + params['config'] = {}; + // params['config'] = {resources: config}; if (resources['mounts']) { params['config'].mounts = resources['mounts']; } @@ -800,7 +800,105 @@ class Client { * * @param {string} sessionId - the sessionId given when created */ - async createSesisonFromTemplate(kernelType, sessionId, resources = {}, timeout: number = 0) { + async createSessionFromTemplate(templateId, image = null, sessionName = null, resources = {}, timeout: number = 0) { + if (typeof sessionName === 'undefined' || sessionName === null) + sessionName = this.generateSessionId(); + const params = {template_id: templateId}; + if (image) { + params['image'] = image; + } + if (sessionName) { + params['name'] = sessionName; + } + if (resources != {}) { + let config = {}; + if (resources['cpu']) { + config['cpu'] = resources['cpu']; + } + if (resources['mem']) { + config['mem'] = resources['mem']; + } + if (resources['cuda.device']) { + config['cuda.device'] = parseInt(resources['cuda.device']); + } + if (resources['fgpu']) { + config['cuda.shares'] = parseFloat(resources['fgpu']).toFixed(2); // 19.09 and above + } + if (resources['cuda.shares']) { + config['cuda.shares'] = parseFloat(resources['cuda.shares']).toFixed(2); + } + if (resources['rocm']) { + config['rocm.device'] = resources['rocm']; + } + if (resources['tpu']) { + config['tpu.device'] = resources['tpu']; + } + if (resources['cluster_size']) { + params['cluster_size'] = resources['cluster_size']; + } + if (resources['cluster_mode']) { + params['cluster_mode'] = resources['cluster_mode']; + } + if (resources['group_name']) { + params['group_name'] = resources['group_name']; + } + if (resources['domain']) { + params['domain'] = resources['domain']; + } + if (resources['type']) { + params['type'] = resources['type']; + } + if (resources['starts_at']) { + params['starts_at'] = resources['startsAt']; + } + if (resources['enqueueOnly']) { + params['enqueueOnly'] = resources['enqueueOnly']; + } + if (resources['maxWaitSeconds']) { + params['maxWaitSeconds'] = resources['maxWaitSeconds']; + } + if (resources['reuseIfExists']) { + params['reuseIfExists'] = resources['reuseIfExists']; + } + if (resources['startupCommand']) { + params['startupCommand'] = resources['startupCommand']; + } + if (resources['bootstrap_script']) { + params['bootstrap_script'] = resources['bootstrap_script']; + } + if (resources['owner_access_key']) { + params['owner_access_key'] = resources['owner_access_key']; + } + // params['config'] = {}; + params['config'] = {resources: config}; + if (resources['mounts']) { + params['config'].mounts = resources['mounts']; + } + if (resources['scaling_group']) { + params['config'].scaling_group = resources['scaling_group']; + } + if (resources['shmem']) { + params['config'].resource_opts = {}; + params['config'].resource_opts.shmem = resources['shmem']; + } + if (resources['env']) { + params['config'].environ = resources['env']; + } + } + // TODO: not working if config is set (Manager should be fixed) + // const rqst = this.newSignedRequest('POST', `${this.kernelPrefix}/_/create-from-template`, params); + + const params2 = { + template_id: templateId, + name: sessionName, + config: {}, + }; + const config2 = { + scaling_group: 'default', + } + params2.config = config2; + const rqst = this.newSignedRequest('POST', `${this.kernelPrefix}/_/create-from-template`, params2); + return this._wrapWithPromise(rqst, false, null, timeout); } /** From 3edadd01fbd1d5b4fbeb6b9f690954956d23ef8d Mon Sep 17 00:00:00 2001 From: Jeongkyu Shin Date: Tue, 27 Apr 2021 17:02:30 +0900 Subject: [PATCH 5/5] fix: eslint (#958) --- src/components/backend-ai-edu-applauncher.ts | 6 +++--- src/components/lablup-activity-panel.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/backend-ai-edu-applauncher.ts b/src/components/backend-ai-edu-applauncher.ts index f65d96ef40..39aed46db1 100644 --- a/src/components/backend-ai-edu-applauncher.ts +++ b/src/components/backend-ai-edu-applauncher.ts @@ -108,7 +108,7 @@ export default class BackendAiEduApplauncher extends BackendAIPage { // This API should be used when there is only one group, 'default'. const groupId = globalThis.backendaiclient.current_group_id(); const sessions = await globalThis.backendaiclient.computeSession.list( - fields, statuses, accessKey, 30, 0 , groupId + fields, statuses, accessKey, 30, 0, groupId ); // URL Parameter parsing. @@ -158,8 +158,8 @@ export default class BackendAiEduApplauncher extends BackendAIPage { const resources = { scaling_group: scalingGroup, mounts: [], - } - const response = await globalThis.backendaiclient.createSessionFromTemplate(templateId, null, null, resources) + }; + const response = await globalThis.backendaiclient.createSessionFromTemplate(templateId, null, null, resources); sessionId = response.sessionId; } catch (err) { console.error(err); diff --git a/src/components/lablup-activity-panel.ts b/src/components/lablup-activity-panel.ts index 2c6bac82f6..0c6bc3c2d8 100644 --- a/src/components/lablup-activity-panel.ts +++ b/src/components/lablup-activity-panel.ts @@ -179,8 +179,8 @@ export default class LablupActivityPanel extends LitElement { this.shadowRoot.querySelector('div.card > h4').style.marginBottom = '0'; } if (this.height > 0) { - this.height == 130 ? - this.shadowRoot.querySelector('div.card').style.height = "fit-content" : + this.height == 130 ? + this.shadowRoot.querySelector('div.card').style.height = 'fit-content' : this.shadowRoot.querySelector('div.card').style.height = this.height + 'px'; } if (this.noheader === true) {