@reown/walletkit 1.2.0 → 1.2.1-canary-sign-msgs-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(kt,Nt){typeof exports=="object"&&typeof module<"u"?Nt(exports):typeof define=="function"&&define.amd?define(["exports"],Nt):(kt=typeof globalThis<"u"?globalThis:kt||self,Nt(kt["@reown/walletkit"]={}))})(this,function(kt){"use strict";var Nt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ha(t){var e=t.default;if(typeof e=="function"){var r=function(){return e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(i){var n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(r,i,n.get?n:{enumerable:!0,get:function(){return t[i]}})}),r}var jt={exports:{}},Sn=typeof Reflect=="object"?Reflect:null,Ec=Sn&&typeof Sn.apply=="function"?Sn.apply:function(e,r,i){return Function.prototype.apply.call(e,r,i)},Js;Sn&&typeof Sn.ownKeys=="function"?Js=Sn.ownKeys:Object.getOwnPropertySymbols?Js=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Js=function(e){return Object.getOwnPropertyNames(e)};function pp(t){console&&console.warn&&console.warn(t)}var Sc=Number.isNaN||function(e){return e!==e};function ot(){ot.init.call(this)}jt.exports=ot,jt.exports.once=yp,ot.EventEmitter=ot,ot.prototype._events=void 0,ot.prototype._eventsCount=0,ot.prototype._maxListeners=void 0;var Mc=10;function Ys(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(ot,"defaultMaxListeners",{enumerable:!0,get:function(){return Mc},set:function(t){if(typeof t!="number"||t<0||Sc(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Mc=t}}),ot.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},ot.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Sc(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function Ic(t){return t._maxListeners===void 0?ot.defaultMaxListeners:t._maxListeners}ot.prototype.getMaxListeners=function(){return Ic(this)},ot.prototype.emit=function(e){for(var r=[],i=1;i<arguments.length;i++)r.push(arguments[i]);var n=e==="error",s=this._events;if(s!==void 0)n=n&&s.error===void 0;else if(!n)return!1;if(n){var o;if(r.length>0&&(o=r[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=s[e];if(c===void 0)return!1;if(typeof c=="function")Ec(c,this,r);else for(var h=c.length,l=Rc(c,h),i=0;i<h;++i)Ec(l[i],this,r);return!0};function Ac(t,e,r,i){var n,s,o;if(Ys(r),s=t._events,s===void 0?(s=t._events=Object.create(null),t._eventsCount=0):(s.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),o=s[e]),o===void 0)o=s[e]=r,++t._eventsCount;else if(typeof o=="function"?o=s[e]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),n=Ic(t),n>0&&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,pp(a)}return t}ot.prototype.addListener=function(e,r){return Ac(this,e,r,!1)},ot.prototype.on=ot.prototype.addListener,ot.prototype.prependListener=function(e,r){return Ac(this,e,r,!0)};function gp(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Dc(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},n=gp.bind(i);return n.listener=r,i.wrapFn=n,n}ot.prototype.once=function(e,r){return Ys(r),this.on(e,Dc(this,e,r)),this},ot.prototype.prependOnceListener=function(e,r){return Ys(r),this.prependListener(e,Dc(this,e,r)),this},ot.prototype.removeListener=function(e,r){var i,n,s,o,a;if(Ys(r),n=this._events,n===void 0)return this;if(i=n[e],i===void 0)return this;if(i===r||i.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||r));else if(typeof i!="function"){for(s=-1,o=i.length-1;o>=0;o--)if(i[o]===r||i[o].listener===r){a=i[o].listener,s=o;break}if(s<0)return this;s===0?i.shift():bp(i,s),i.length===1&&(n[e]=i[0]),n.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this},ot.prototype.off=ot.prototype.removeListener,ot.prototype.removeAllListeners=function(e){var r,i,n;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var s=Object.keys(i),o;for(n=0;n<s.length;++n)o=s[n],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=i[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(n=r.length-1;n>=0;n--)this.removeListener(e,r[n]);return this};function Oc(t,e,r){var i=t._events;if(i===void 0)return[];var n=i[e];return n===void 0?[]:typeof n=="function"?r?[n.listener||n]:[n]:r?vp(n):Rc(n,n.length)}ot.prototype.listeners=function(e){return Oc(this,e,!0)},ot.prototype.rawListeners=function(e){return Oc(this,e,!1)},ot.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Pc.call(t,e)},ot.prototype.listenerCount=Pc;function Pc(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}ot.prototype.eventNames=function(){return this._eventsCount>0?Js(this._events):[]};function Rc(t,e){for(var r=new Array(e),i=0;i<e;++i)r[i]=t[i];return r}function bp(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function vp(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function yp(t,e){return new Promise(function(r,i){function n(o){t.removeListener(e,s),i(o)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",n),r([].slice.call(arguments))}$c(t,e,s,{once:!0}),e!=="error"&&mp(t,n,{once:!0})})}function mp(t,e,r){typeof t.on=="function"&&$c(t,"error",e,r)}function $c(t,e,r,i){if(typeof t.on=="function")i.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function n(s){i.once&&t.removeEventListener(e,n),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}const Nc="wc",wp=2,ua="WalletKit",_p=`${Nc}@2:${ua}:`,xp={database:":memory:"},Ep="request";var Y={};/*! *****************************************************************************
1
+ (function(Ot,Bt){typeof exports=="object"&&typeof module<"u"?Bt(exports):typeof define=="function"&&define.amd?define(["exports"],Bt):(Ot=typeof globalThis<"u"?globalThis:Ot||self,Bt(Ot["@reown/walletkit"]={}))})(this,function(Ot){"use strict";var Bt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function qa(t){var e=t.default;if(typeof e=="function"){var r=function(){return e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(i){var n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(r,i,n.get?n:{enumerable:!0,get:function(){return t[i]}})}),r}var Mt={exports:{}},ln=typeof Reflect=="object"?Reflect:null,Su=ln&&typeof ln.apply=="function"?ln.apply:function(e,r,i){return Function.prototype.apply.call(e,r,i)},lo;ln&&typeof ln.ownKeys=="function"?lo=ln.ownKeys:Object.getOwnPropertySymbols?lo=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:lo=function(e){return Object.getOwnPropertyNames(e)};function V1(t){console&&console.warn&&console.warn(t)}var Iu=Number.isNaN||function(e){return e!==e};function de(){de.init.call(this)}Mt.exports=de,Mt.exports.once=Y1,de.EventEmitter=de,de.prototype._events=void 0,de.prototype._eventsCount=0,de.prototype._maxListeners=void 0;var Au=10;function po(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(de,"defaultMaxListeners",{enumerable:!0,get:function(){return Au},set:function(t){if(typeof t!="number"||t<0||Iu(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Au=t}}),de.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},de.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Iu(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function Du(t){return t._maxListeners===void 0?de.defaultMaxListeners:t._maxListeners}de.prototype.getMaxListeners=function(){return Du(this)},de.prototype.emit=function(e){for(var r=[],i=1;i<arguments.length;i++)r.push(arguments[i]);var n=e==="error",s=this._events;if(s!==void 0)n=n&&s.error===void 0;else if(!n)return!1;if(n){var o;if(r.length>0&&(o=r[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=s[e];if(c===void 0)return!1;if(typeof c=="function")Su(c,this,r);else for(var f=c.length,u=Ru(c,f),i=0;i<f;++i)Su(u[i],this,r);return!0};function $u(t,e,r,i){var n,s,o;if(po(r),s=t._events,s===void 0?(s=t._events=Object.create(null),t._eventsCount=0):(s.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),o=s[e]),o===void 0)o=s[e]=r,++t._eventsCount;else if(typeof o=="function"?o=s[e]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),n=Du(t),n>0&&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,V1(a)}return t}de.prototype.addListener=function(e,r){return $u(this,e,r,!1)},de.prototype.on=de.prototype.addListener,de.prototype.prependListener=function(e,r){return $u(this,e,r,!0)};function H1(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Ou(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},n=H1.bind(i);return n.listener=r,i.wrapFn=n,n}de.prototype.once=function(e,r){return po(r),this.on(e,Ou(this,e,r)),this},de.prototype.prependOnceListener=function(e,r){return po(r),this.prependListener(e,Ou(this,e,r)),this},de.prototype.removeListener=function(e,r){var i,n,s,o,a;if(po(r),n=this._events,n===void 0)return this;if(i=n[e],i===void 0)return this;if(i===r||i.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||r));else if(typeof i!="function"){for(s=-1,o=i.length-1;o>=0;o--)if(i[o]===r||i[o].listener===r){a=i[o].listener,s=o;break}if(s<0)return this;s===0?i.shift():W1(i,s),i.length===1&&(n[e]=i[0]),n.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this},de.prototype.off=de.prototype.removeListener,de.prototype.removeAllListeners=function(e){var r,i,n;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var s=Object.keys(i),o;for(n=0;n<s.length;++n)o=s[n],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=i[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(n=r.length-1;n>=0;n--)this.removeListener(e,r[n]);return this};function Mu(t,e,r){var i=t._events;if(i===void 0)return[];var n=i[e];return n===void 0?[]:typeof n=="function"?r?[n.listener||n]:[n]:r?G1(n):Ru(n,n.length)}de.prototype.listeners=function(e){return Mu(this,e,!0)},de.prototype.rawListeners=function(e){return Mu(this,e,!1)},de.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Pu.call(t,e)},de.prototype.listenerCount=Pu;function Pu(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}de.prototype.eventNames=function(){return this._eventsCount>0?lo(this._events):[]};function Ru(t,e){for(var r=new Array(e),i=0;i<e;++i)r[i]=t[i];return r}function W1(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function G1(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function Y1(t,e){return new Promise(function(r,i){function n(o){t.removeListener(e,s),i(o)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",n),r([].slice.call(arguments))}Tu(t,e,s,{once:!0}),e!=="error"&&Z1(t,n,{once:!0})})}function Z1(t,e,r){typeof t.on=="function"&&Tu(t,"error",e,r)}function Tu(t,e,r,i){if(typeof t.on=="function")i.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function n(s){i.once&&t.removeEventListener(e,n),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}const Cu="wc",J1=2,za="WalletKit",X1=`${Cu}@2:${za}:`,Q1={database:":memory:"},eg="request";var V={};/*! *****************************************************************************
2
2
  Copyright (c) Microsoft Corporation.
3
3
 
4
4
  Permission to use, copy, modify, and/or distribute this software for any
@@ -11,23 +11,19 @@
11
11
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
12
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
13
  PERFORMANCE OF THIS SOFTWARE.
14
- ***************************************************************************** */var da=function(t,e){return da=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var n in i)i.hasOwnProperty(n)&&(r[n]=i[n])},da(t,e)};function Sp(t,e){da(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var la=function(){return la=Object.assign||function(e){for(var r,i=1,n=arguments.length;i<n;i++){r=arguments[i];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},la.apply(this,arguments)};function Mp(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]]);return r}function Ip(t,e,r,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(n<3?o(s):n>3?o(e,r,s):o(e,r))||s);return n>3&&s&&Object.defineProperty(e,r,s),s}function Ap(t,e){return function(r,i){e(r,i,t)}}function Dp(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function Op(t,e,r,i){function n(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(l){try{h(i.next(l))}catch(y){o(y)}}function c(l){try{h(i.throw(l))}catch(y){o(y)}}function h(l){l.done?s(l.value):n(l.value).then(a,c)}h((i=i.apply(t,e||[])).next())})}function Pp(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(h){return function(l){return c([h,l])}}function c(h){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,n&&(s=h[0]&2?n.return:h[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,h[1])).done)return s;switch(n=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return r.label++,{value:h[1],done:!1};case 5:r.label++,n=h[1],h=[0];continue;case 7:h=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){r=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){r.label=h[1];break}if(h[0]===6&&r.label<s[1]){r.label=s[1],s=h;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(h);break}s[2]&&r.ops.pop(),r.trys.pop();continue}h=e.call(t,r)}catch(l){h=[6,l],n=0}finally{i=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function Rp(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}function $p(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function pa(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Tc(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var i=r.call(t),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function Np(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Tc(arguments[e]));return t}function Tp(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var i=Array(t),n=0,e=0;e<r;e++)for(var s=arguments[e],o=0,a=s.length;o<a;o++,n++)i[n]=s[o];return i}function is(t){return this instanceof is?(this.v=t,this):new is(t)}function Fp(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=r.apply(t,e||[]),n,s=[];return n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n;function o(M){i[M]&&(n[M]=function(I){return new Promise(function(S,D){s.push([M,I,S,D])>1||a(M,I)})})}function a(M,I){try{c(i[M](I))}catch(S){y(s[0][3],S)}}function c(M){M.value instanceof is?Promise.resolve(M.value.v).then(h,l):y(s[0][2],M)}function h(M){a("next",M)}function l(M){a("throw",M)}function y(M,I){M(I),s.shift(),s.length&&a(s[0][0],s[0][1])}}function Cp(t){var e,r;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,s){e[n]=t[n]?function(o){return(r=!r)?{value:is(t[n](o)),done:n==="return"}:s?s(o):o}:s}}function Bp(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof pa=="function"?pa(t):t[Symbol.iterator](),r={},i("next"),i("throw"),i("return"),r[Symbol.asyncIterator]=function(){return this},r);function i(s){r[s]=t[s]&&function(o){return new Promise(function(a,c){o=t[s](o),n(a,c,o.done,o.value)})}}function n(s,o,a,c){Promise.resolve(c).then(function(h){s({value:h,done:a})},o)}}function Lp(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function qp(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function Up(t){return t&&t.__esModule?t:{default:t}}function zp(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function kp(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}var jp=Object.freeze({__proto__:null,__extends:Sp,get __assign(){return la},__rest:Mp,__decorate:Ip,__param:Ap,__metadata:Dp,__awaiter:Op,__generator:Pp,__createBinding:Rp,__exportStar:$p,__values:pa,__read:Tc,__spread:Np,__spreadArrays:Tp,__await:is,__asyncGenerator:Fp,__asyncDelegator:Cp,__asyncValues:Bp,__makeTemplateObject:Lp,__importStar:qp,__importDefault:Up,__classPrivateFieldGet:zp,__classPrivateFieldSet:kp}),Xs=ha(jp),ga={},ns={},Fc;function Kp(){if(Fc)return ns;Fc=1,Object.defineProperty(ns,"__esModule",{value:!0}),ns.delay=void 0;function t(e){return new Promise(r=>{setTimeout(()=>{r(!0)},e)})}return ns.delay=t,ns}var Xi={},ba={},Zi={},Cc;function Vp(){return Cc||(Cc=1,Object.defineProperty(Zi,"__esModule",{value:!0}),Zi.ONE_THOUSAND=Zi.ONE_HUNDRED=void 0,Zi.ONE_HUNDRED=100,Zi.ONE_THOUSAND=1e3),Zi}var va={},Bc;function Hp(){return Bc||(Bc=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ONE_YEAR=t.FOUR_WEEKS=t.THREE_WEEKS=t.TWO_WEEKS=t.ONE_WEEK=t.THIRTY_DAYS=t.SEVEN_DAYS=t.FIVE_DAYS=t.THREE_DAYS=t.ONE_DAY=t.TWENTY_FOUR_HOURS=t.TWELVE_HOURS=t.SIX_HOURS=t.THREE_HOURS=t.ONE_HOUR=t.SIXTY_MINUTES=t.THIRTY_MINUTES=t.TEN_MINUTES=t.FIVE_MINUTES=t.ONE_MINUTE=t.SIXTY_SECONDS=t.THIRTY_SECONDS=t.TEN_SECONDS=t.FIVE_SECONDS=t.ONE_SECOND=void 0,t.ONE_SECOND=1,t.FIVE_SECONDS=5,t.TEN_SECONDS=10,t.THIRTY_SECONDS=30,t.SIXTY_SECONDS=60,t.ONE_MINUTE=t.SIXTY_SECONDS,t.FIVE_MINUTES=t.ONE_MINUTE*5,t.TEN_MINUTES=t.ONE_MINUTE*10,t.THIRTY_MINUTES=t.ONE_MINUTE*30,t.SIXTY_MINUTES=t.ONE_MINUTE*60,t.ONE_HOUR=t.SIXTY_MINUTES,t.THREE_HOURS=t.ONE_HOUR*3,t.SIX_HOURS=t.ONE_HOUR*6,t.TWELVE_HOURS=t.ONE_HOUR*12,t.TWENTY_FOUR_HOURS=t.ONE_HOUR*24,t.ONE_DAY=t.TWENTY_FOUR_HOURS,t.THREE_DAYS=t.ONE_DAY*3,t.FIVE_DAYS=t.ONE_DAY*5,t.SEVEN_DAYS=t.ONE_DAY*7,t.THIRTY_DAYS=t.ONE_DAY*30,t.ONE_WEEK=t.SEVEN_DAYS,t.TWO_WEEKS=t.ONE_WEEK*2,t.THREE_WEEKS=t.ONE_WEEK*3,t.FOUR_WEEKS=t.ONE_WEEK*4,t.ONE_YEAR=t.ONE_DAY*365}(va)),va}var Lc;function qc(){return Lc||(Lc=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Xs;e.__exportStar(Vp(),t),e.__exportStar(Hp(),t)}(ba)),ba}var Uc;function Wp(){if(Uc)return Xi;Uc=1,Object.defineProperty(Xi,"__esModule",{value:!0}),Xi.fromMiliseconds=Xi.toMiliseconds=void 0;const t=qc();function e(i){return i*t.ONE_THOUSAND}Xi.toMiliseconds=e;function r(i){return Math.floor(i/t.ONE_THOUSAND)}return Xi.fromMiliseconds=r,Xi}var zc;function Gp(){return zc||(zc=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Xs;e.__exportStar(Kp(),t),e.__exportStar(Wp(),t)}(ga)),ga}var Mn={},kc;function Jp(){if(kc)return Mn;kc=1,Object.defineProperty(Mn,"__esModule",{value:!0}),Mn.Watch=void 0;class t{constructor(){this.timestamps=new Map}start(r){if(this.timestamps.has(r))throw new Error(`Watch already started for label: ${r}`);this.timestamps.set(r,{started:Date.now()})}stop(r){const i=this.get(r);if(typeof i.elapsed<"u")throw new Error(`Watch already stopped for label: ${r}`);const n=Date.now()-i.started;this.timestamps.set(r,{started:i.started,elapsed:n})}get(r){const i=this.timestamps.get(r);if(typeof i>"u")throw new Error(`No timestamp found for label: ${r}`);return i}elapsed(r){const i=this.get(r);return i.elapsed||Date.now()-i.started}}return Mn.Watch=t,Mn.default=t,Mn}var ya={},ss={},jc;function Yp(){if(jc)return ss;jc=1,Object.defineProperty(ss,"__esModule",{value:!0}),ss.IWatch=void 0;class t{}return ss.IWatch=t,ss}var Kc;function Xp(){return Kc||(Kc=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),Xs.__exportStar(Yp(),t)}(ya)),ya}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Xs;e.__exportStar(Gp(),t),e.__exportStar(Jp(),t),e.__exportStar(Xp(),t),e.__exportStar(qc(),t)})(Y);class Qi{}class Zp extends Qi{constructor(e){super()}}const Vc=Y.FIVE_SECONDS,In={pulse:"heartbeat_pulse"};class ma extends Zp{constructor(e){super(e),this.events=new jt.exports.EventEmitter,this.interval=Vc,this.interval=e?.interval||Vc}static async init(e){const r=new ma(e);return await r.init(),r}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),Y.toMiliseconds(this.interval))}pulse(){this.events.emit(In.pulse)}}const Qp=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,e1=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,t1=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function r1(t,e){if(t==="__proto__"||t==="constructor"&&e&&typeof e=="object"&&"prototype"in e){i1(t);return}return e}function i1(t){console.warn(`[destr] Dropping "${t}" key to prevent prototype pollution.`)}function Zs(t,e={}){if(typeof t!="string")return t;const r=t.trim();if(t[0]==='"'&&t.endsWith('"')&&!t.includes("\\"))return r.slice(1,-1);if(r.length<=9){const i=r.toLowerCase();if(i==="true")return!0;if(i==="false")return!1;if(i==="undefined")return;if(i==="null")return null;if(i==="nan")return Number.NaN;if(i==="infinity")return Number.POSITIVE_INFINITY;if(i==="-infinity")return Number.NEGATIVE_INFINITY}if(!t1.test(t)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return t}try{if(Qp.test(t)||e1.test(t)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(t,r1)}return JSON.parse(t)}catch(i){if(e.strict)throw i;return t}}function n1(t){return!t||typeof t.then!="function"?Promise.resolve(t):t}function St(t,...e){try{return n1(t(...e))}catch(r){return Promise.reject(r)}}function s1(t){const e=typeof t;return t===null||e!=="object"&&e!=="function"}function o1(t){const e=Object.getPrototypeOf(t);return!e||e.isPrototypeOf(Object)}function Qs(t){if(s1(t))return String(t);if(o1(t)||Array.isArray(t))return JSON.stringify(t);if(typeof t.toJSON=="function")return Qs(t.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function Hc(){if(typeof Buffer>"u")throw new TypeError("[unstorage] Buffer is not supported!")}const wa="base64:";function a1(t){if(typeof t=="string")return t;Hc();const e=Buffer.from(t).toString("base64");return wa+e}function f1(t){return typeof t!="string"||!t.startsWith(wa)?t:(Hc(),Buffer.from(t.slice(wa.length),"base64"))}function er(t){return t?t.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function c1(...t){return er(t.join(":"))}function eo(t){return t=er(t),t?t+":":""}function Sx(t){return t}const h1="memory",u1=()=>{const t=new Map;return{name:h1,getInstance:()=>t,hasItem(e){return t.has(e)},getItem(e){return t.get(e)??null},getItemRaw(e){return t.get(e)??null},setItem(e,r){t.set(e,r)},setItemRaw(e,r){t.set(e,r)},removeItem(e){t.delete(e)},getKeys(){return[...t.keys()]},clear(){t.clear()},dispose(){t.clear()}}};function d1(t={}){const e={mounts:{"":t.driver||u1()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},r=h=>{for(const l of e.mountpoints)if(h.startsWith(l))return{base:l,relativeKey:h.slice(l.length),driver:e.mounts[l]};return{base:"",relativeKey:h,driver:e.mounts[""]}},i=(h,l)=>e.mountpoints.filter(y=>y.startsWith(h)||l&&h.startsWith(y)).map(y=>({relativeBase:h.length>y.length?h.slice(y.length):void 0,mountpoint:y,driver:e.mounts[y]})),n=(h,l)=>{if(e.watching){l=er(l);for(const y of e.watchListeners)y(h,l)}},s=async()=>{if(!e.watching){e.watching=!0;for(const h in e.mounts)e.unwatch[h]=await Wc(e.mounts[h],n,h)}},o=async()=>{if(e.watching){for(const h in e.unwatch)await e.unwatch[h]();e.unwatch={},e.watching=!1}},a=(h,l,y)=>{const M=new Map,I=S=>{let D=M.get(S.base);return D||(D={driver:S.driver,base:S.base,items:[]},M.set(S.base,D)),D};for(const S of h){const D=typeof S=="string",R=er(D?S:S.key),$=D?void 0:S.value,T=D||!S.options?l:{...l,...S.options},C=r(R);I(C).items.push({key:R,value:$,relativeKey:C.relativeKey,options:T})}return Promise.all([...M.values()].map(S=>y(S))).then(S=>S.flat())},c={hasItem(h,l={}){h=er(h);const{relativeKey:y,driver:M}=r(h);return St(M.hasItem,y,l)},getItem(h,l={}){h=er(h);const{relativeKey:y,driver:M}=r(h);return St(M.getItem,y,l).then(I=>Zs(I))},getItems(h,l){return a(h,l,y=>y.driver.getItems?St(y.driver.getItems,y.items.map(M=>({key:M.relativeKey,options:M.options})),l).then(M=>M.map(I=>({key:c1(y.base,I.key),value:Zs(I.value)}))):Promise.all(y.items.map(M=>St(y.driver.getItem,M.relativeKey,M.options).then(I=>({key:M.key,value:Zs(I)})))))},getItemRaw(h,l={}){h=er(h);const{relativeKey:y,driver:M}=r(h);return M.getItemRaw?St(M.getItemRaw,y,l):St(M.getItem,y,l).then(I=>f1(I))},async setItem(h,l,y={}){if(l===void 0)return c.removeItem(h);h=er(h);const{relativeKey:M,driver:I}=r(h);I.setItem&&(await St(I.setItem,M,Qs(l),y),I.watch||n("update",h))},async setItems(h,l){await a(h,l,async y=>{if(y.driver.setItems)return St(y.driver.setItems,y.items.map(M=>({key:M.relativeKey,value:Qs(M.value),options:M.options})),l);y.driver.setItem&&await Promise.all(y.items.map(M=>St(y.driver.setItem,M.relativeKey,Qs(M.value),M.options)))})},async setItemRaw(h,l,y={}){if(l===void 0)return c.removeItem(h,y);h=er(h);const{relativeKey:M,driver:I}=r(h);if(I.setItemRaw)await St(I.setItemRaw,M,l,y);else if(I.setItem)await St(I.setItem,M,a1(l),y);else return;I.watch||n("update",h)},async removeItem(h,l={}){typeof l=="boolean"&&(l={removeMeta:l}),h=er(h);const{relativeKey:y,driver:M}=r(h);M.removeItem&&(await St(M.removeItem,y,l),(l.removeMeta||l.removeMata)&&await St(M.removeItem,y+"$",l),M.watch||n("remove",h))},async getMeta(h,l={}){typeof l=="boolean"&&(l={nativeOnly:l}),h=er(h);const{relativeKey:y,driver:M}=r(h),I=Object.create(null);if(M.getMeta&&Object.assign(I,await St(M.getMeta,y,l)),!l.nativeOnly){const S=await St(M.getItem,y+"$",l).then(D=>Zs(D));S&&typeof S=="object"&&(typeof S.atime=="string"&&(S.atime=new Date(S.atime)),typeof S.mtime=="string"&&(S.mtime=new Date(S.mtime)),Object.assign(I,S))}return I},setMeta(h,l,y={}){return this.setItem(h+"$",l,y)},removeMeta(h,l={}){return this.removeItem(h+"$",l)},async getKeys(h,l={}){h=eo(h);const y=i(h,!0);let M=[];const I=[];for(const S of y){const D=await St(S.driver.getKeys,S.relativeBase,l);for(const R of D){const $=S.mountpoint+er(R);M.some(T=>$.startsWith(T))||I.push($)}M=[S.mountpoint,...M.filter(R=>!R.startsWith(S.mountpoint))]}return h?I.filter(S=>S.startsWith(h)&&S[S.length-1]!=="$"):I.filter(S=>S[S.length-1]!=="$")},async clear(h,l={}){h=eo(h),await Promise.all(i(h,!1).map(async y=>{if(y.driver.clear)return St(y.driver.clear,y.relativeBase,l);if(y.driver.removeItem){const M=await y.driver.getKeys(y.relativeBase||"",l);return Promise.all(M.map(I=>y.driver.removeItem(I,l)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(h=>Gc(h)))},async watch(h){return await s(),e.watchListeners.push(h),async()=>{e.watchListeners=e.watchListeners.filter(l=>l!==h),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(h,l){if(h=eo(h),h&&e.mounts[h])throw new Error(`already mounted at ${h}`);return h&&(e.mountpoints.push(h),e.mountpoints.sort((y,M)=>M.length-y.length)),e.mounts[h]=l,e.watching&&Promise.resolve(Wc(l,n,h)).then(y=>{e.unwatch[h]=y}).catch(console.error),c},async unmount(h,l=!0){h=eo(h),!(!h||!e.mounts[h])&&(e.watching&&h in e.unwatch&&(e.unwatch[h](),delete e.unwatch[h]),l&&await Gc(e.mounts[h]),e.mountpoints=e.mountpoints.filter(y=>y!==h),delete e.mounts[h])},getMount(h=""){h=er(h)+":";const l=r(h);return{driver:l.driver,base:l.base}},getMounts(h="",l={}){return h=er(h),i(h,l.parents).map(M=>({driver:M.driver,base:M.mountpoint}))},keys:(h,l={})=>c.getKeys(h,l),get:(h,l={})=>c.getItem(h,l),set:(h,l,y={})=>c.setItem(h,l,y),has:(h,l={})=>c.hasItem(h,l),del:(h,l={})=>c.removeItem(h,l),remove:(h,l={})=>c.removeItem(h,l)};return c}function Wc(t,e,r){return t.watch?t.watch((i,n)=>e(i,r+n)):()=>{}}async function Gc(t){typeof t.dispose=="function"&&await St(t.dispose)}function en(t){return new Promise((e,r)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>r(t.error)})}function Jc(t,e){const r=indexedDB.open(t);r.onupgradeneeded=()=>r.result.createObjectStore(e);const i=en(r);return(n,s)=>i.then(o=>s(o.transaction(e,n).objectStore(e)))}let _a;function os(){return _a||(_a=Jc("keyval-store","keyval")),_a}function Yc(t,e=os()){return e("readonly",r=>en(r.get(t)))}function l1(t,e,r=os()){return r("readwrite",i=>(i.put(e,t),en(i.transaction)))}function p1(t,e=os()){return e("readwrite",r=>(r.delete(t),en(r.transaction)))}function g1(t=os()){return t("readwrite",e=>(e.clear(),en(e.transaction)))}function b1(t,e){return t.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},en(t.transaction)}function v1(t=os()){return t("readonly",e=>{if(e.getAllKeys)return en(e.getAllKeys());const r=[];return b1(e,i=>r.push(i.key)).then(()=>r)})}const y1=t=>JSON.stringify(t,(e,r)=>typeof r=="bigint"?r.toString()+"n":r),m1=t=>{const e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,r=t.replace(e,'$1"$2n"$3');return JSON.parse(r,(i,n)=>typeof n=="string"&&n.match(/^\d+n$/)?BigInt(n.substring(0,n.length-1)):n)};function An(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return m1(t)}catch{return t}}function tn(t){return typeof t=="string"?t:y1(t)||""}const w1="idb-keyval";var _1=(t={})=>{const e=t.base&&t.base.length>0?`${t.base}:`:"",r=n=>e+n;let i;return t.dbName&&t.storeName&&(i=Jc(t.dbName,t.storeName)),{name:w1,options:t,async hasItem(n){return!(typeof await Yc(r(n),i)>"u")},async getItem(n){return await Yc(r(n),i)??null},setItem(n,s){return l1(r(n),s,i)},removeItem(n){return p1(r(n),i)},getKeys(){return v1(i)},clear(){return g1(i)}}};const x1="WALLET_CONNECT_V2_INDEXED_DB",E1="keyvaluestorage";class S1{constructor(){this.indexedDb=d1({driver:_1({dbName:x1,storeName:E1})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){const r=await this.indexedDb.getItem(e);if(r!==null)return r}async setItem(e,r){await this.indexedDb.setItem(e,tn(r))}async removeItem(e){await this.indexedDb.removeItem(e)}}var xa=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},to={exports:{}};(function(){let t;function e(){}t=e,t.prototype.getItem=function(r){return this.hasOwnProperty(r)?String(this[r]):null},t.prototype.setItem=function(r,i){this[r]=String(i)},t.prototype.removeItem=function(r){delete this[r]},t.prototype.clear=function(){const r=this;Object.keys(r).forEach(function(i){r[i]=void 0,delete r[i]})},t.prototype.key=function(r){return r=r||0,Object.keys(this)[r]},t.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof xa<"u"&&xa.localStorage?to.exports=xa.localStorage:typeof window<"u"&&window.localStorage?to.exports=window.localStorage:to.exports=new e})();function M1(t){var e;return[t[0],An((e=t[1])!=null?e:"")]}class I1{constructor(){this.localStorage=to.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(M1)}async getItem(e){const r=this.localStorage.getItem(e);if(r!==null)return An(r)}async setItem(e,r){this.localStorage.setItem(e,tn(r))}async removeItem(e){this.localStorage.removeItem(e)}}const A1="wc_storage_version",Xc=1,D1=async(t,e,r)=>{const i=A1,n=await e.getItem(i);if(n&&n>=Xc){r(e);return}const s=await t.getKeys();if(!s.length){r(e);return}const o=[];for(;s.length;){const a=s.shift();if(!a)continue;const c=a.toLowerCase();if(c.includes("wc@")||c.includes("walletconnect")||c.includes("wc_")||c.includes("wallet_connect")){const h=await t.getItem(a);await e.setItem(a,h),o.push(a)}}await e.setItem(i,Xc),r(e),O1(t,o)},O1=async(t,e)=>{e.length&&e.forEach(async r=>{await t.removeItem(r)})};class P1{constructor(){this.initialized=!1,this.setInitialized=r=>{this.storage=r,this.initialized=!0};const e=new I1;this.storage=e;try{const r=new S1;D1(e,r,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,r){return await this.initialize(),this.storage.setItem(e,r)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{const r=setInterval(()=>{this.initialized&&(clearInterval(r),e())},20)})}}function R1(t){try{return JSON.stringify(t)}catch{return'"[Circular]"'}}var $1=N1;function N1(t,e,r){var i=r&&r.stringify||R1,n=1;if(typeof t=="object"&&t!==null){var s=e.length+n;if(s===1)return t;var o=new Array(s);o[0]=i(t);for(var a=1;a<s;a++)o[a]=i(e[a]);return o.join(" ")}if(typeof t!="string")return t;var c=e.length;if(c===0)return t;for(var h="",l=1-n,y=-1,M=t&&t.length||0,I=0;I<M;){if(t.charCodeAt(I)===37&&I+1<M){switch(y=y>-1?y:0,t.charCodeAt(I+1)){case 100:case 102:if(l>=c||e[l]==null)break;y<I&&(h+=t.slice(y,I)),h+=Number(e[l]),y=I+2,I++;break;case 105:if(l>=c||e[l]==null)break;y<I&&(h+=t.slice(y,I)),h+=Math.floor(Number(e[l])),y=I+2,I++;break;case 79:case 111:case 106:if(l>=c||e[l]===void 0)break;y<I&&(h+=t.slice(y,I));var S=typeof e[l];if(S==="string"){h+="'"+e[l]+"'",y=I+2,I++;break}if(S==="function"){h+=e[l].name||"<anonymous>",y=I+2,I++;break}h+=i(e[l]),y=I+2,I++;break;case 115:if(l>=c)break;y<I&&(h+=t.slice(y,I)),h+=String(e[l]),y=I+2,I++;break;case 37:y<I&&(h+=t.slice(y,I)),h+="%",y=I+2,I++,l--;break}++l}++I}return y===-1?t:(y<M&&(h+=t.slice(y)),h)}const Zc=$1;var ai=Kr;const as=j1().console||{},T1={mapHttpRequest:io,mapHttpResponse:io,wrapRequestSerializer:Sa,wrapResponseSerializer:Sa,wrapErrorSerializer:Sa,req:io,res:io,err:q1};function F1(t,e){return Array.isArray(t)?t.filter(function(i){return i!=="!stdSerializers.err"}):t===!0?Object.keys(e):!1}function Kr(t){t=t||{},t.browser=t.browser||{};const e=t.browser.transmit;if(e&&typeof e.send!="function")throw Error("pino: transmit option must have a send function");const r=t.browser.write||as;t.browser.write&&(t.browser.asObject=!0);const i=t.serializers||{},n=F1(t.browser.serialize,i);let s=t.browser.serialize;Array.isArray(t.browser.serialize)&&t.browser.serialize.indexOf("!stdSerializers.err")>-1&&(s=!1);const o=["error","fatal","warn","info","debug","trace"];typeof r=="function"&&(r.error=r.fatal=r.warn=r.info=r.debug=r.trace=r),t.enabled===!1&&(t.level="silent");const a=t.level||"info",c=Object.create(r);c.log||(c.log=fs),Object.defineProperty(c,"levelVal",{get:l}),Object.defineProperty(c,"level",{get:y,set:M});const h={transmit:e,serialize:n,asObject:t.browser.asObject,levels:o,timestamp:U1(t)};c.levels=Kr.levels,c.level=a,c.setMaxListeners=c.getMaxListeners=c.emit=c.addListener=c.on=c.prependListener=c.once=c.prependOnceListener=c.removeListener=c.removeAllListeners=c.listeners=c.listenerCount=c.eventNames=c.write=c.flush=fs,c.serializers=i,c._serialize=n,c._stdErrSerialize=s,c.child=I,e&&(c._logEvent=Ea());function l(){return this.level==="silent"?1/0:this.levels.values[this.level]}function y(){return this._level}function M(S){if(S!=="silent"&&!this.levels.values[S])throw Error("unknown level "+S);this._level=S,Dn(h,c,"error","log"),Dn(h,c,"fatal","error"),Dn(h,c,"warn","error"),Dn(h,c,"info","log"),Dn(h,c,"debug","log"),Dn(h,c,"trace","log")}function I(S,D){if(!S)throw new Error("missing bindings for child Pino");D=D||{},n&&S.serializers&&(D.serializers=S.serializers);const R=D.serializers;if(n&&R){var $=Object.assign({},i,R),T=t.browser.serialize===!0?Object.keys($):n;delete S.serializers,ro([S],T,$,this._stdErrSerialize)}function C(L){this._childLevel=(L._childLevel|0)+1,this.error=On(L,S,"error"),this.fatal=On(L,S,"fatal"),this.warn=On(L,S,"warn"),this.info=On(L,S,"info"),this.debug=On(L,S,"debug"),this.trace=On(L,S,"trace"),$&&(this.serializers=$,this._serialize=T),e&&(this._logEvent=Ea([].concat(L._logEvent.bindings,S)))}return C.prototype=this,new C(this)}return c}Kr.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},Kr.stdSerializers=T1,Kr.stdTimeFunctions=Object.assign({},{nullTime:Qc,epochTime:eh,unixTime:z1,isoTime:k1});function Dn(t,e,r,i){const n=Object.getPrototypeOf(e);e[r]=e.levelVal>e.levels.values[r]?fs:n[r]?n[r]:as[r]||as[i]||fs,C1(t,e,r)}function C1(t,e,r){!t.transmit&&e[r]===fs||(e[r]=function(i){return function(){const s=t.timestamp(),o=new Array(arguments.length),a=Object.getPrototypeOf&&Object.getPrototypeOf(this)===as?as:this;for(var c=0;c<o.length;c++)o[c]=arguments[c];if(t.serialize&&!t.asObject&&ro(o,this._serialize,this.serializers,this._stdErrSerialize),t.asObject?i.call(a,B1(this,r,o,s)):i.apply(a,o),t.transmit){const h=t.transmit.level||e.level,l=Kr.levels.values[h],y=Kr.levels.values[r];if(y<l)return;L1(this,{ts:s,methodLevel:r,methodValue:y,transmitLevel:h,transmitValue:Kr.levels.values[t.transmit.level||e.level],send:t.transmit.send,val:e.levelVal},o)}}}(e[r]))}function B1(t,e,r,i){t._serialize&&ro(r,t._serialize,t.serializers,t._stdErrSerialize);const n=r.slice();let s=n[0];const o={};i&&(o.time=i),o.level=Kr.levels.values[e];let a=(t._childLevel|0)+1;if(a<1&&(a=1),s!==null&&typeof s=="object"){for(;a--&&typeof n[0]=="object";)Object.assign(o,n.shift());s=n.length?Zc(n.shift(),n):void 0}else typeof s=="string"&&(s=Zc(n.shift(),n));return s!==void 0&&(o.msg=s),o}function ro(t,e,r,i){for(const n in t)if(i&&t[n]instanceof Error)t[n]=Kr.stdSerializers.err(t[n]);else if(typeof t[n]=="object"&&!Array.isArray(t[n]))for(const s in t[n])e&&e.indexOf(s)>-1&&s in r&&(t[n][s]=r[s](t[n][s]))}function On(t,e,r){return function(){const i=new Array(1+arguments.length);i[0]=e;for(var n=1;n<i.length;n++)i[n]=arguments[n-1];return t[r].apply(this,i)}}function L1(t,e,r){const i=e.send,n=e.ts,s=e.methodLevel,o=e.methodValue,a=e.val,c=t._logEvent.bindings;ro(r,t._serialize||Object.keys(t.serializers),t.serializers,t._stdErrSerialize===void 0?!0:t._stdErrSerialize),t._logEvent.ts=n,t._logEvent.messages=r.filter(function(h){return c.indexOf(h)===-1}),t._logEvent.level.label=s,t._logEvent.level.value=o,i(s,t._logEvent,a),t._logEvent=Ea(c)}function Ea(t){return{ts:0,messages:[],bindings:t||[],level:{label:"",value:0}}}function q1(t){const e={type:t.constructor.name,msg:t.message,stack:t.stack};for(const r in t)e[r]===void 0&&(e[r]=t[r]);return e}function U1(t){return typeof t.timestamp=="function"?t.timestamp:t.timestamp===!1?Qc:eh}function io(){return{}}function Sa(t){return t}function fs(){}function Qc(){return!1}function eh(){return Date.now()}function z1(){return Math.round(Date.now()/1e3)}function k1(){return new Date(Date.now()).toISOString()}function j1(){function t(e){return typeof e<"u"&&e}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return t(self)||t(window)||t(this)||{}}}const K1={level:"info"},cs="custom_context",Ma=1e3*1024;class V1{constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}}class th{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){const r=new V1(e);if(r.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${r.size}`);for(;this.size+r.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=r),this.tail=r):(this.head=r,this.tail=r),this.lengthInNodes++,this.sizeInBytes+=r.size}shift(){if(!this.head)return;const e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){const e=[];let r=this.head;for(;r!==null;)e.push(r.value),r=r.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};const r=e.value;return e=e.next,{done:!1,value:r}}}}}class rh{constructor(e,r=Ma){this.level=e??"error",this.levelValue=ai.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=r,this.logs=new th(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,r){r===ai.levels.values.error?console.error(e):r===ai.levels.values.warn?console.warn(e):r===ai.levels.values.debug?console.debug(e):r===ai.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(tn({timestamp:new Date().toISOString(),log:e}));const r=typeof e=="string"?JSON.parse(e).level:e.level;r>=this.levelValue&&this.forwardToConsole(e,r)}getLogs(){return this.logs}clearLogs(){this.logs=new th(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const r=this.getLogArray();return r.push(tn({extraMetadata:e})),new Blob(r,{type:"application/json"})}}class H1{constructor(e,r=Ma){this.baseChunkLogger=new rh(e,r)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){const r=URL.createObjectURL(this.logsToBlob(e)),i=document.createElement("a");i.href=r,i.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}}class W1{constructor(e,r=Ma){this.baseChunkLogger=new rh(e,r)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}}var G1=Object.defineProperty,J1=Object.defineProperties,Y1=Object.getOwnPropertyDescriptors,ih=Object.getOwnPropertySymbols,X1=Object.prototype.hasOwnProperty,Z1=Object.prototype.propertyIsEnumerable,nh=(t,e,r)=>e in t?G1(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,no=(t,e)=>{for(var r in e||(e={}))X1.call(e,r)&&nh(t,r,e[r]);if(ih)for(var r of ih(e))Z1.call(e,r)&&nh(t,r,e[r]);return t},so=(t,e)=>J1(t,Y1(e));function Ia(t){return so(no({},t),{level:t?.level||K1.level})}function Q1(t,e=cs){return t[e]||""}function eg(t,e,r=cs){return t[r]=e,t}function tr(t,e=cs){let r="";return typeof t.bindings>"u"?r=Q1(t,e):r=t.bindings().context||"",r}function tg(t,e,r=cs){const i=tr(t,r);return i.trim()?`${i}/${e}`:e}function Jt(t,e,r=cs){const i=tg(t,e,r),n=t.child({context:i});return eg(n,i,r)}function rg(t){var e,r;const i=new H1((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:ai(so(no({},t.opts),{level:"trace",browser:so(no({},(r=t.opts)==null?void 0:r.browser),{write:n=>i.write(n)})})),chunkLoggerController:i}}function ig(t){var e;const r=new W1((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:ai(so(no({},t.opts),{level:"trace"})),chunkLoggerController:r}}function ng(t){return typeof t.loggerOverride<"u"&&typeof t.loggerOverride!="string"?{logger:t.loggerOverride,chunkLoggerController:null}:typeof window<"u"?rg(t):ig(t)}class sg extends Qi{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}class og extends Qi{constructor(e,r){super(),this.core=e,this.logger=r,this.records=new Map}}class ag{constructor(e,r){this.logger=e,this.core=r}}class fg extends Qi{constructor(e,r){super(),this.relayer=e,this.logger=r}}class cg extends Qi{constructor(e){super()}}class hg{constructor(e,r,i,n){this.core=e,this.logger=r,this.name=i}}class ug extends Qi{constructor(e,r){super(),this.relayer=e,this.logger=r}}class dg extends Qi{constructor(e,r){super(),this.core=e,this.logger=r}}class lg{constructor(e,r,i){this.core=e,this.logger=r,this.store=i}}class pg{constructor(e,r){this.projectId=e,this.logger=r}}class gg{constructor(e,r,i){this.core=e,this.logger=r,this.telemetryEnabled=i}}class bg{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}class vg{constructor(e){this.client=e}}function yg(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function sh(t,...e){if(!yg(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function oh(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function mg(t,e){sh(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const Pn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Aa=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);function wg(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function ah(t){return typeof t=="string"&&(t=wg(t)),sh(t),t}class _g{clone(){return this._cloneInto()}}function xg(t){const e=i=>t().update(ah(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function fh(t=32){if(Pn&&typeof Pn.getRandomValues=="function")return Pn.getRandomValues(new Uint8Array(t));if(Pn&&typeof Pn.randomBytes=="function")return Pn.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}function Eg(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);const n=BigInt(32),s=BigInt(4294967295),o=Number(r>>n&s),a=Number(r&s),c=i?4:0,h=i?0:4;t.setUint32(e+c,o,i),t.setUint32(e+h,a,i)}class Sg extends _g{constructor(e,r,i,n){super(),this.blockLen=e,this.outputLen=r,this.padOffset=i,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Aa(this.buffer)}update(e){oh(this);const{view:r,buffer:i,blockLen:n}=this;e=ah(e);const s=e.length;for(let o=0;o<s;){const a=Math.min(n-this.pos,s-o);if(a===n){const c=Aa(e);for(;n<=s-o;o+=n)this.process(c,o);continue}i.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){oh(this),mg(e,this),this.finished=!0;const{buffer:r,view:i,blockLen:n,isLE:s}=this;let{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(i,0),o=0);for(let y=o;y<n;y++)r[y]=0;Eg(i,n-8,BigInt(this.length*8),s),this.process(i,0);const a=Aa(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const h=c/4,l=this.get();if(h>l.length)throw new Error("_sha2: outputLen bigger than state");for(let y=0;y<h;y++)a.setUint32(4*y,l[y],s)}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const i=e.slice(0,r);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:r,buffer:i,length:n,finished:s,destroyed:o,pos:a}=this;return e.length=n,e.pos=a,e.finished=s,e.destroyed=o,n%r&&e.buffer.set(i),e}}const oo=BigInt(2**32-1),Da=BigInt(32);function ch(t,e=!1){return e?{h:Number(t&oo),l:Number(t>>Da&oo)}:{h:Number(t>>Da&oo)|0,l:Number(t&oo)|0}}function Mg(t,e=!1){let r=new Uint32Array(t.length),i=new Uint32Array(t.length);for(let n=0;n<t.length;n++){const{h:s,l:o}=ch(t[n],e);[r[n],i[n]]=[s,o]}return[r,i]}const Ig=(t,e)=>BigInt(t>>>0)<<Da|BigInt(e>>>0),Ag=(t,e,r)=>t>>>r,Dg=(t,e,r)=>t<<32-r|e>>>r,Og=(t,e,r)=>t>>>r|e<<32-r,Pg=(t,e,r)=>t<<32-r|e>>>r,Rg=(t,e,r)=>t<<64-r|e>>>r-32,$g=(t,e,r)=>t>>>r-32|e<<64-r,Ng=(t,e)=>e,Tg=(t,e)=>t,Fg=(t,e,r)=>t<<r|e>>>32-r,Cg=(t,e,r)=>e<<r|t>>>32-r,Bg=(t,e,r)=>e<<r-32|t>>>64-r,Lg=(t,e,r)=>t<<r-32|e>>>64-r;function qg(t,e,r,i){const n=(e>>>0)+(i>>>0);return{h:t+r+(n/2**32|0)|0,l:n|0}}const Ug=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),zg=(t,e,r,i)=>e+r+i+(t/2**32|0)|0,kg=(t,e,r,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0),jg=(t,e,r,i,n)=>e+r+i+n+(t/2**32|0)|0,Kg=(t,e,r,i,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0)+(n>>>0),Vg=(t,e,r,i,n,s)=>e+r+i+n+s+(t/2**32|0)|0,_e={fromBig:ch,split:Mg,toBig:Ig,shrSH:Ag,shrSL:Dg,rotrSH:Og,rotrSL:Pg,rotrBH:Rg,rotrBL:$g,rotr32H:Ng,rotr32L:Tg,rotlSH:Fg,rotlSL:Cg,rotlBH:Bg,rotlBL:Lg,add:qg,add3L:Ug,add3H:zg,add4L:kg,add4H:jg,add5H:Vg,add5L:Kg},[Hg,Wg]=(()=>_e.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))))(),Ni=new Uint32Array(80),Ti=new Uint32Array(80);class Gg extends Sg{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:r,Bh:i,Bl:n,Ch:s,Cl:o,Dh:a,Dl:c,Eh:h,El:l,Fh:y,Fl:M,Gh:I,Gl:S,Hh:D,Hl:R}=this;return[e,r,i,n,s,o,a,c,h,l,y,M,I,S,D,R]}set(e,r,i,n,s,o,a,c,h,l,y,M,I,S,D,R){this.Ah=e|0,this.Al=r|0,this.Bh=i|0,this.Bl=n|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=h|0,this.El=l|0,this.Fh=y|0,this.Fl=M|0,this.Gh=I|0,this.Gl=S|0,this.Hh=D|0,this.Hl=R|0}process(e,r){for(let C=0;C<16;C++,r+=4)Ni[C]=e.getUint32(r),Ti[C]=e.getUint32(r+=4);for(let C=16;C<80;C++){const L=Ni[C-15]|0,k=Ti[C-15]|0,j=_e.rotrSH(L,k,1)^_e.rotrSH(L,k,8)^_e.shrSH(L,k,7),G=_e.rotrSL(L,k,1)^_e.rotrSL(L,k,8)^_e.shrSL(L,k,7),K=Ni[C-2]|0,V=Ti[C-2]|0,re=_e.rotrSH(K,V,19)^_e.rotrBH(K,V,61)^_e.shrSH(K,V,6),O=_e.rotrSL(K,V,19)^_e.rotrBL(K,V,61)^_e.shrSL(K,V,6),g=_e.add4L(G,O,Ti[C-7],Ti[C-16]),p=_e.add4H(g,j,re,Ni[C-7],Ni[C-16]);Ni[C]=p|0,Ti[C]=g|0}let{Ah:i,Al:n,Bh:s,Bl:o,Ch:a,Cl:c,Dh:h,Dl:l,Eh:y,El:M,Fh:I,Fl:S,Gh:D,Gl:R,Hh:$,Hl:T}=this;for(let C=0;C<80;C++){const L=_e.rotrSH(y,M,14)^_e.rotrSH(y,M,18)^_e.rotrBH(y,M,41),k=_e.rotrSL(y,M,14)^_e.rotrSL(y,M,18)^_e.rotrBL(y,M,41),j=y&I^~y&D,G=M&S^~M&R,K=_e.add5L(T,k,G,Wg[C],Ti[C]),V=_e.add5H(K,$,L,j,Hg[C],Ni[C]),re=K|0,O=_e.rotrSH(i,n,28)^_e.rotrBH(i,n,34)^_e.rotrBH(i,n,39),g=_e.rotrSL(i,n,28)^_e.rotrBL(i,n,34)^_e.rotrBL(i,n,39),p=i&s^i&a^s&a,f=n&o^n&c^o&c;$=D|0,T=R|0,D=I|0,R=S|0,I=y|0,S=M|0,{h:y,l:M}=_e.add(h|0,l|0,V|0,re|0),h=a|0,l=c|0,a=s|0,c=o|0,s=i|0,o=n|0;const u=_e.add3L(re,g,f);i=_e.add3H(u,V,O,p),n=u|0}({h:i,l:n}=_e.add(this.Ah|0,this.Al|0,i|0,n|0)),{h:s,l:o}=_e.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=_e.add(this.Ch|0,this.Cl|0,a|0,c|0),{h,l}=_e.add(this.Dh|0,this.Dl|0,h|0,l|0),{h:y,l:M}=_e.add(this.Eh|0,this.El|0,y|0,M|0),{h:I,l:S}=_e.add(this.Fh|0,this.Fl|0,I|0,S|0),{h:D,l:R}=_e.add(this.Gh|0,this.Gl|0,D|0,R|0),{h:$,l:T}=_e.add(this.Hh|0,this.Hl|0,$|0,T|0),this.set(i,n,s,o,a,c,h,l,y,M,I,S,D,R,$,T)}roundClean(){Ni.fill(0),Ti.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Jg=xg(()=>new Gg);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Oa=BigInt(0),hh=BigInt(1),Yg=BigInt(2);function Pa(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Ra(t){if(!Pa(t))throw new Error("Uint8Array expected")}function $a(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const Xg=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Na(t){Ra(t);let e="";for(let r=0;r<t.length;r++)e+=Xg[t[r]];return e}function uh(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Oa:BigInt("0x"+t)}const fi={_0:48,_9:57,A:65,F:70,a:97,f:102};function dh(t){if(t>=fi._0&&t<=fi._9)return t-fi._0;if(t>=fi.A&&t<=fi.F)return t-(fi.A-10);if(t>=fi.a&&t<=fi.f)return t-(fi.a-10)}function lh(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const i=new Uint8Array(r);for(let n=0,s=0;n<r;n++,s+=2){const o=dh(t.charCodeAt(s)),a=dh(t.charCodeAt(s+1));if(o===void 0||a===void 0){const c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}i[n]=o*16+a}return i}function Zg(t){return uh(Na(t))}function ao(t){return Ra(t),uh(Na(Uint8Array.from(t).reverse()))}function ph(t,e){return lh(t.toString(16).padStart(e*2,"0"))}function Ta(t,e){return ph(t,e).reverse()}function ci(t,e,r){let i;if(typeof e=="string")try{i=lh(e)}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(Pa(e))i=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const n=i.length;if(typeof r=="number"&&n!==r)throw new Error(t+" of length "+r+" expected, got "+n);return i}function gh(...t){let e=0;for(let i=0;i<t.length;i++){const n=t[i];Ra(n),e+=n.length}const r=new Uint8Array(e);for(let i=0,n=0;i<t.length;i++){const s=t[i];r.set(s,n),n+=s.length}return r}const Fa=t=>typeof t=="bigint"&&Oa<=t;function Qg(t,e,r){return Fa(t)&&Fa(e)&&Fa(r)&&e<=t&&t<r}function hs(t,e,r,i){if(!Qg(e,r,i))throw new Error("expected valid "+t+": "+r+" <= n < "+i+", got "+e)}function eb(t){let e;for(e=0;t>Oa;t>>=hh,e+=1);return e}const tb=t=>(Yg<<BigInt(t-1))-hh,rb={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||Pa(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function Ca(t,e,r={}){const i=(n,s,o)=>{const a=rb[s];if(typeof a!="function")throw new Error("invalid validator function");const c=t[n];if(!(o&&c===void 0)&&!a(c,t))throw new Error("param "+String(n)+" is invalid. Expected "+s+", got "+c)};for(const[n,s]of Object.entries(e))i(n,s,!1);for(const[n,s]of Object.entries(r))i(n,s,!0);return t}function bh(t){const e=new WeakMap;return(r,...i)=>{const n=e.get(r);if(n!==void 0)return n;const s=t(r,...i);return e.set(r,s),s}}const Mt=BigInt(0),vt=BigInt(1),rn=BigInt(2),ib=BigInt(3),Ba=BigInt(4),vh=BigInt(5),yh=BigInt(8);function _t(t,e){const r=t%e;return r>=Mt?r:e+r}function nb(t,e,r){if(e<Mt)throw new Error("invalid exponent, negatives unsupported");if(r<=Mt)throw new Error("invalid modulus");if(r===vt)return Mt;let i=vt;for(;e>Mt;)e&vt&&(i=i*t%r),t=t*t%r,e>>=vt;return i}function Vr(t,e,r){let i=t;for(;e-- >Mt;)i*=i,i%=r;return i}function mh(t,e){if(t===Mt)throw new Error("invert: expected non-zero number");if(e<=Mt)throw new Error("invert: expected positive modulus, got "+e);let r=_t(t,e),i=e,n=Mt,s=vt;for(;r!==Mt;){const o=i/r,a=i%r,c=n-s*o;i=r,r=a,n=s,s=c}if(i!==vt)throw new Error("invert: does not exist");return _t(n,e)}function sb(t){const e=(t-vt)/rn;let r,i,n;for(r=t-vt,i=0;r%rn===Mt;r/=rn,i++);for(n=rn;n<t&&nb(n,e,t)!==t-vt;n++)if(n>1e3)throw new Error("Cannot find square root: likely non-prime P");if(i===1){const o=(t+vt)/Ba;return function(a,c){const h=a.pow(c,o);if(!a.eql(a.sqr(h),c))throw new Error("Cannot find square root");return h}}const s=(r+vt)/rn;return function(o,a){if(o.pow(a,e)===o.neg(o.ONE))throw new Error("Cannot find square root");let c=i,h=o.pow(o.mul(o.ONE,n),r),l=o.pow(a,s),y=o.pow(a,r);for(;!o.eql(y,o.ONE);){if(o.eql(y,o.ZERO))return o.ZERO;let M=1;for(let S=o.sqr(y);M<c&&!o.eql(S,o.ONE);M++)S=o.sqr(S);const I=o.pow(h,vt<<BigInt(c-M-1));h=o.sqr(I),l=o.mul(l,I),y=o.mul(y,h),c=M}return l}}function ob(t){if(t%Ba===ib){const e=(t+vt)/Ba;return function(r,i){const n=r.pow(i,e);if(!r.eql(r.sqr(n),i))throw new Error("Cannot find square root");return n}}if(t%yh===vh){const e=(t-vh)/yh;return function(r,i){const n=r.mul(i,rn),s=r.pow(n,e),o=r.mul(i,s),a=r.mul(r.mul(o,rn),s),c=r.mul(o,r.sub(a,r.ONE));if(!r.eql(r.sqr(c),i))throw new Error("Cannot find square root");return c}}return sb(t)}const ab=(t,e)=>(_t(t,e)&vt)===vt,fb=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function cb(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=fb.reduce((i,n)=>(i[n]="function",i),e);return Ca(t,r)}function hb(t,e,r){if(r<Mt)throw new Error("invalid exponent, negatives unsupported");if(r===Mt)return t.ONE;if(r===vt)return e;let i=t.ONE,n=e;for(;r>Mt;)r&vt&&(i=t.mul(i,n)),n=t.sqr(n),r>>=vt;return i}function ub(t,e){const r=new Array(e.length),i=e.reduce((s,o,a)=>t.is0(o)?s:(r[a]=s,t.mul(s,o)),t.ONE),n=t.inv(i);return e.reduceRight((s,o,a)=>t.is0(o)?s:(r[a]=t.mul(s,r[a]),t.mul(s,o)),n),r}function wh(t,e){const r=e!==void 0?e:t.toString(2).length,i=Math.ceil(r/8);return{nBitLength:r,nByteLength:i}}function _h(t,e,r=!1,i={}){if(t<=Mt)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:n,nByteLength:s}=wh(t,e);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:t,isLE:r,BITS:n,BYTES:s,MASK:tb(n),ZERO:Mt,ONE:vt,create:c=>_t(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return Mt<=c&&c<t},is0:c=>c===Mt,isOdd:c=>(c&vt)===vt,neg:c=>_t(-c,t),eql:(c,h)=>c===h,sqr:c=>_t(c*c,t),add:(c,h)=>_t(c+h,t),sub:(c,h)=>_t(c-h,t),mul:(c,h)=>_t(c*h,t),pow:(c,h)=>hb(a,c,h),div:(c,h)=>_t(c*mh(h,t),t),sqrN:c=>c*c,addN:(c,h)=>c+h,subN:(c,h)=>c-h,mulN:(c,h)=>c*h,inv:c=>mh(c,t),sqrt:i.sqrt||(c=>(o||(o=ob(t)),o(a,c))),invertBatch:c=>ub(a,c),cmov:(c,h,l)=>l?h:c,toBytes:c=>r?Ta(c,s):ph(c,s),fromBytes:c=>{if(c.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+c.length);return r?ao(c):Zg(c)}});return Object.freeze(a)}const xh=BigInt(0),fo=BigInt(1);function La(t,e){const r=e.negate();return t?r:e}function Eh(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function qa(t,e){Eh(t,e);const r=Math.ceil(e/t)+1,i=2**(t-1);return{windows:r,windowSize:i}}function db(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((r,i)=>{if(!(r instanceof e))throw new Error("invalid point at index "+i)})}function lb(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,i)=>{if(!e.isValid(r))throw new Error("invalid scalar at index "+i)})}const Ua=new WeakMap,Sh=new WeakMap;function za(t){return Sh.get(t)||1}function pb(t,e){return{constTimeNegate:La,hasPrecomputes(r){return za(r)!==1},unsafeLadder(r,i,n=t.ZERO){let s=r;for(;i>xh;)i&fo&&(n=n.add(s)),s=s.double(),i>>=fo;return n},precomputeWindow(r,i){const{windows:n,windowSize:s}=qa(i,e),o=[];let a=r,c=a;for(let h=0;h<n;h++){c=a,o.push(c);for(let l=1;l<s;l++)c=c.add(a),o.push(c);a=c.double()}return o},wNAF(r,i,n){const{windows:s,windowSize:o}=qa(r,e);let a=t.ZERO,c=t.BASE;const h=BigInt(2**r-1),l=2**r,y=BigInt(r);for(let M=0;M<s;M++){const I=M*o;let S=Number(n&h);n>>=y,S>o&&(S-=l,n+=fo);const D=I,R=I+Math.abs(S)-1,$=M%2!==0,T=S<0;S===0?c=c.add(La($,i[D])):a=a.add(La(T,i[R]))}return{p:a,f:c}},wNAFUnsafe(r,i,n,s=t.ZERO){const{windows:o,windowSize:a}=qa(r,e),c=BigInt(2**r-1),h=2**r,l=BigInt(r);for(let y=0;y<o;y++){const M=y*a;if(n===xh)break;let I=Number(n&c);if(n>>=l,I>a&&(I-=h,n+=fo),I===0)continue;let S=i[M+Math.abs(I)-1];I<0&&(S=S.negate()),s=s.add(S)}return s},getPrecomputes(r,i,n){let s=Ua.get(i);return s||(s=this.precomputeWindow(i,r),r!==1&&Ua.set(i,n(s))),s},wNAFCached(r,i,n){const s=za(r);return this.wNAF(s,this.getPrecomputes(s,r,n),i)},wNAFCachedUnsafe(r,i,n,s){const o=za(r);return o===1?this.unsafeLadder(r,i,s):this.wNAFUnsafe(o,this.getPrecomputes(o,r,n),i,s)},setWindowSize(r,i){Eh(i,e),Sh.set(r,i),Ua.delete(r)}}}function gb(t,e,r,i){if(db(r,t),lb(i,e),r.length!==i.length)throw new Error("arrays of points and scalars must have equal length");const n=t.ZERO,s=eb(BigInt(r.length)),o=s>12?s-3:s>4?s-2:s?2:1,a=(1<<o)-1,c=new Array(a+1).fill(n),h=Math.floor((e.BITS-1)/o)*o;let l=n;for(let y=h;y>=0;y-=o){c.fill(n);for(let I=0;I<i.length;I++){const S=i[I],D=Number(S>>BigInt(y)&BigInt(a));c[D]=c[D].add(r[I])}let M=n;for(let I=c.length-1,S=n;I>0;I--)S=S.add(c[I]),M=M.add(S);if(l=l.add(M),y!==0)for(let I=0;I<o;I++)l=l.double()}return l}function bb(t){return cb(t.Fp),Ca(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...wh(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}const Nr=BigInt(0),rr=BigInt(1),co=BigInt(2),vb=BigInt(8),yb={zip215:!0};function mb(t){const e=bb(t);return Ca(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function wb(t){const e=mb(t),{Fp:r,n:i,prehash:n,hash:s,randomBytes:o,nByteLength:a,h:c}=e,h=co<<BigInt(a*8)-rr,l=r.create,y=_h(e.n,e.nBitLength),M=e.uvRatio||((u,b)=>{try{return{isValid:!0,value:r.sqrt(u*r.inv(b))}}catch{return{isValid:!1,value:Nr}}}),I=e.adjustScalarBytes||(u=>u),S=e.domain||((u,b,_)=>{if($a("phflag",_),b.length||_)throw new Error("Contexts/pre-hash are not supported");return u});function D(u,b){hs("coordinate "+u,b,Nr,h)}function R(u){if(!(u instanceof C))throw new Error("ExtendedPoint expected")}const $=bh((u,b)=>{const{ex:_,ey:E,ez:w}=u,d=u.is0();b==null&&(b=d?vb:r.inv(w));const m=l(_*b),v=l(E*b),A=l(w*b);if(d)return{x:Nr,y:rr};if(A!==rr)throw new Error("invZ was invalid");return{x:m,y:v}}),T=bh(u=>{const{a:b,d:_}=e;if(u.is0())throw new Error("bad point: ZERO");const{ex:E,ey:w,ez:d,et:m}=u,v=l(E*E),A=l(w*w),U=l(d*d),x=l(U*U),N=l(v*b),B=l(U*l(N+A)),q=l(x+l(_*l(v*A)));if(B!==q)throw new Error("bad point: equation left != right (1)");const z=l(E*w),J=l(d*m);if(z!==J)throw new Error("bad point: equation left != right (2)");return!0});class C{constructor(b,_,E,w){this.ex=b,this.ey=_,this.ez=E,this.et=w,D("x",b),D("y",_),D("z",E),D("t",w),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(b){if(b instanceof C)throw new Error("extended point not allowed");const{x:_,y:E}=b||{};return D("x",_),D("y",E),new C(_,E,rr,l(_*E))}static normalizeZ(b){const _=r.invertBatch(b.map(E=>E.ez));return b.map((E,w)=>E.toAffine(_[w])).map(C.fromAffine)}static msm(b,_){return gb(C,y,b,_)}_setWindowSize(b){j.setWindowSize(this,b)}assertValidity(){T(this)}equals(b){R(b);const{ex:_,ey:E,ez:w}=this,{ex:d,ey:m,ez:v}=b,A=l(_*v),U=l(d*w),x=l(E*v),N=l(m*w);return A===U&&x===N}is0(){return this.equals(C.ZERO)}negate(){return new C(l(-this.ex),this.ey,this.ez,l(-this.et))}double(){const{a:b}=e,{ex:_,ey:E,ez:w}=this,d=l(_*_),m=l(E*E),v=l(co*l(w*w)),A=l(b*d),U=_+E,x=l(l(U*U)-d-m),N=A+m,B=N-v,q=A-m,z=l(x*B),J=l(N*q),X=l(x*q),W=l(B*N);return new C(z,J,W,X)}add(b){R(b);const{a:_,d:E}=e,{ex:w,ey:d,ez:m,et:v}=this,{ex:A,ey:U,ez:x,et:N}=b;if(_===BigInt(-1)){const Pe=l((d-w)*(U+A)),Re=l((d+w)*(U-A)),ae=l(Re-Pe);if(ae===Nr)return this.double();const $e=l(m*co*N),Ne=l(v*co*x),ce=Ne+$e,Te=Re+Pe,Fe=Ne-$e,oe=l(ce*ae),De=l(Te*Fe),Ce=l(ce*Fe),ie=l(ae*Te);return new C(oe,De,ie,Ce)}const B=l(w*A),q=l(d*U),z=l(v*E*N),J=l(m*x),X=l((w+d)*(A+U)-B-q),W=J-z,ne=J+z,Q=l(q-_*B),ee=l(X*W),qe=l(ne*Q),Ue=l(X*Q),he=l(W*ne);return new C(ee,qe,he,Ue)}subtract(b){return this.add(b.negate())}wNAF(b){return j.wNAFCached(this,b,C.normalizeZ)}multiply(b){const _=b;hs("scalar",_,rr,i);const{p:E,f:w}=this.wNAF(_);return C.normalizeZ([E,w])[0]}multiplyUnsafe(b,_=C.ZERO){const E=b;return hs("scalar",E,Nr,i),E===Nr?k:this.is0()||E===rr?this:j.wNAFCachedUnsafe(this,E,C.normalizeZ,_)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return j.unsafeLadder(this,i).is0()}toAffine(b){return $(this,b)}clearCofactor(){const{h:b}=e;return b===rr?this:this.multiplyUnsafe(b)}static fromHex(b,_=!1){const{d:E,a:w}=e,d=r.BYTES;b=ci("pointHex",b,d),$a("zip215",_);const m=b.slice(),v=b[d-1];m[d-1]=v&-129;const A=ao(m),U=_?h:r.ORDER;hs("pointHex.y",A,Nr,U);const x=l(A*A),N=l(x-rr),B=l(E*x-w);let{isValid:q,value:z}=M(N,B);if(!q)throw new Error("Point.fromHex: invalid y coordinate");const J=(z&rr)===rr,X=(v&128)!==0;if(!_&&z===Nr&&X)throw new Error("Point.fromHex: x=0 and x_0=1");return X!==J&&(z=l(-z)),C.fromAffine({x:z,y:A})}static fromPrivateKey(b){return V(b).point}toRawBytes(){const{x:b,y:_}=this.toAffine(),E=Ta(_,r.BYTES);return E[E.length-1]|=b&rr?128:0,E}toHex(){return Na(this.toRawBytes())}}C.BASE=new C(e.Gx,e.Gy,rr,l(e.Gx*e.Gy)),C.ZERO=new C(Nr,rr,rr,Nr);const{BASE:L,ZERO:k}=C,j=pb(C,a*8);function G(u){return _t(u,i)}function K(u){return G(ao(u))}function V(u){const b=r.BYTES;u=ci("private key",u,b);const _=ci("hashed private key",s(u),2*b),E=I(_.slice(0,b)),w=_.slice(b,2*b),d=K(E),m=L.multiply(d),v=m.toRawBytes();return{head:E,prefix:w,scalar:d,point:m,pointBytes:v}}function re(u){return V(u).pointBytes}function O(u=new Uint8Array,...b){const _=gh(...b);return K(s(S(_,ci("context",u),!!n)))}function g(u,b,_={}){u=ci("message",u),n&&(u=n(u));const{prefix:E,scalar:w,pointBytes:d}=V(b),m=O(_.context,E,u),v=L.multiply(m).toRawBytes(),A=O(_.context,v,d,u),U=G(m+A*w);hs("signature.s",U,Nr,i);const x=gh(v,Ta(U,r.BYTES));return ci("result",x,r.BYTES*2)}const p=yb;function f(u,b,_,E=p){const{context:w,zip215:d}=E,m=r.BYTES;u=ci("signature",u,2*m),b=ci("message",b),_=ci("publicKey",_,m),d!==void 0&&$a("zip215",d),n&&(b=n(b));const v=ao(u.slice(m,2*m));let A,U,x;try{A=C.fromHex(_,d),U=C.fromHex(u.slice(0,m),d),x=L.multiplyUnsafe(v)}catch{return!1}if(!d&&A.isSmallOrder())return!1;const N=O(w,U.toRawBytes(),A.toRawBytes(),b);return U.add(A.multiplyUnsafe(N)).subtract(x).clearCofactor().equals(C.ZERO)}return L._setWindowSize(8),{CURVE:e,getPublicKey:re,sign:g,verify:f,ExtendedPoint:C,utils:{getExtendedPublicKey:V,randomPrivateKey:()=>o(r.BYTES),precompute(u=8,b=C.BASE){return b._setWindowSize(u),b.multiply(BigInt(3)),b}}}}BigInt(0),BigInt(1);const ka=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Mh=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const _b=BigInt(1),Ih=BigInt(2);BigInt(3);const xb=BigInt(5),Eb=BigInt(8);function Sb(t){const e=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),s=ka,o=t*t%s*t%s,a=Vr(o,Ih,s)*o%s,c=Vr(a,_b,s)*t%s,h=Vr(c,xb,s)*c%s,l=Vr(h,e,s)*h%s,y=Vr(l,r,s)*l%s,M=Vr(y,i,s)*y%s,I=Vr(M,n,s)*M%s,S=Vr(I,n,s)*M%s,D=Vr(S,e,s)*h%s;return{pow_p_5_8:Vr(D,Ih,s)*t%s,b2:o}}function Mb(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function Ib(t,e){const r=ka,i=_t(e*e*e,r),n=_t(i*i*e,r),s=Sb(t*n).pow_p_5_8;let o=_t(t*i*s,r);const a=_t(e*o*o,r),c=o,h=_t(o*Mh,r),l=a===t,y=a===_t(-t,r),M=a===_t(-t*Mh,r);return l&&(o=c),(y||M)&&(o=h),ab(o,r)&&(o=_t(-o,r)),{isValid:l||y,value:o}}const Ab=(()=>_h(ka,void 0,!0))(),Db=(()=>({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Ab,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Eb,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Jg,randomBytes:fh,adjustScalarBytes:Mb,uvRatio:Ib}))(),Ah=(()=>wb(Db))(),Ob="EdDSA",Pb="JWT",ho=".",uo="base64url",Dh="utf8",Oh="utf8",Rb=":",$b="did",Nb="key",Ph="base58btc",Tb="z",Fb="K36",Cb=32;function ja(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function Rh(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?ja(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function $h(t,e){e||(e=t.reduce((n,s)=>n+s.length,0));const r=Rh(e);let i=0;for(const n of t)r.set(n,i),i+=n.length;return ja(r)}function Bb(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=n}var a=t.length,c=t.charAt(0),h=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function y(S){if(S instanceof Uint8Array||(ArrayBuffer.isView(S)?S=new Uint8Array(S.buffer,S.byteOffset,S.byteLength):Array.isArray(S)&&(S=Uint8Array.from(S))),!(S instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(S.length===0)return"";for(var D=0,R=0,$=0,T=S.length;$!==T&&S[$]===0;)$++,D++;for(var C=(T-$)*l+1>>>0,L=new Uint8Array(C);$!==T;){for(var k=S[$],j=0,G=C-1;(k!==0||j<R)&&G!==-1;G--,j++)k+=256*L[G]>>>0,L[G]=k%a>>>0,k=k/a>>>0;if(k!==0)throw new Error("Non-zero carry");R=j,$++}for(var K=C-R;K!==C&&L[K]===0;)K++;for(var V=c.repeat(D);K<C;++K)V+=t.charAt(L[K]);return V}function M(S){if(typeof S!="string")throw new TypeError("Expected String");if(S.length===0)return new Uint8Array;var D=0;if(S[D]!==" "){for(var R=0,$=0;S[D]===c;)R++,D++;for(var T=(S.length-D)*h+1>>>0,C=new Uint8Array(T);S[D];){var L=r[S.charCodeAt(D)];if(L===255)return;for(var k=0,j=T-1;(L!==0||k<$)&&j!==-1;j--,k++)L+=a*C[j]>>>0,C[j]=L%256>>>0,L=L/256>>>0;if(L!==0)throw new Error("Non-zero carry");$=k,D++}if(S[D]!==" "){for(var G=T-$;G!==T&&C[G]===0;)G++;for(var K=new Uint8Array(R+(T-G)),V=R;G!==T;)K[V++]=C[G++];return K}}}function I(S){var D=M(S);if(D)return D;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:M,decode:I}}var Lb=Bb,qb=Lb;const Nh=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},Ub=t=>new TextEncoder().encode(t),zb=t=>new TextDecoder().decode(t);class kb{constructor(e,r,i){this.name=e,this.prefix=r,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class jb{constructor(e,r,i){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Th(this,e)}}class Kb{constructor(e){this.decoders=e}or(e){return Th(this,e)}decode(e){const r=e[0],i=this.decoders[r];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Th=(t,e)=>new Kb({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class Vb{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new kb(e,r,i),this.decoder=new jb(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const lo=({name:t,prefix:e,encode:r,decode:i})=>new Vb(t,e,r,i),us=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=qb(r,e);return lo({prefix:t,name:e,encode:i,decode:s=>Nh(n(s))})},Hb=(t,e,r,i)=>{const n={};for(let l=0;l<e.length;++l)n[e[l]]=l;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,h=0;for(let l=0;l<s;++l){const y=n[t[l]];if(y===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<r|y,a+=r,a>=8&&(a-=8,o[h++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},Wb=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>r;)o-=r,s+=e[n&a>>o];if(o&&(s+=e[n&a<<r-o]),i)for(;s.length*r&7;)s+="=";return s},Tt=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>lo({prefix:e,name:t,encode(n){return Wb(n,i,r)},decode(n){return Hb(n,i,r,t)}}),Gb=lo({prefix:"\0",name:"identity",encode:t=>zb(t),decode:t=>Ub(t)});var Jb=Object.freeze({__proto__:null,identity:Gb});const Yb=Tt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Xb=Object.freeze({__proto__:null,base2:Yb});const Zb=Tt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Qb=Object.freeze({__proto__:null,base8:Zb});const ev=us({prefix:"9",name:"base10",alphabet:"0123456789"});var tv=Object.freeze({__proto__:null,base10:ev});const rv=Tt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),iv=Tt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var nv=Object.freeze({__proto__:null,base16:rv,base16upper:iv});const sv=Tt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ov=Tt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),av=Tt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),fv=Tt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),cv=Tt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),hv=Tt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),uv=Tt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),dv=Tt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),lv=Tt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var pv=Object.freeze({__proto__:null,base32:sv,base32upper:ov,base32pad:av,base32padupper:fv,base32hex:cv,base32hexupper:hv,base32hexpad:uv,base32hexpadupper:dv,base32z:lv});const gv=us({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),bv=us({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var vv=Object.freeze({__proto__:null,base36:gv,base36upper:bv});const yv=us({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),mv=us({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var wv=Object.freeze({__proto__:null,base58btc:yv,base58flickr:mv});const _v=Tt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),xv=Tt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ev=Tt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Sv=Tt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Mv=Object.freeze({__proto__:null,base64:_v,base64pad:xv,base64url:Ev,base64urlpad:Sv});const Fh=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Iv=Fh.reduce((t,e,r)=>(t[r]=e,t),[]),Av=Fh.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function Dv(t){return t.reduce((e,r)=>(e+=Iv[r],e),"")}function Ov(t){const e=[];for(const r of t){const i=Av[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const Pv=lo({prefix:"\u{1F680}",name:"base256emoji",encode:Dv,decode:Ov});var Rv=Object.freeze({__proto__:null,base256emoji:Pv}),$v=Bh,Ch=128,Nv=127,Tv=~Nv,Fv=Math.pow(2,31);function Bh(t,e,r){e=e||[],r=r||0;for(var i=r;t>=Fv;)e[r++]=t&255|Ch,t/=128;for(;t&Tv;)e[r++]=t&255|Ch,t>>>=7;return e[r]=t|0,Bh.bytes=r-i+1,e}var Cv=Ka,Bv=128,Lh=127;function Ka(t,i){var r=0,i=i||0,n=0,s=i,o,a=t.length;do{if(s>=a)throw Ka.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=n<28?(o&Lh)<<n:(o&Lh)*Math.pow(2,n),n+=7}while(o>=Bv);return Ka.bytes=s-i,r}var Lv=Math.pow(2,7),qv=Math.pow(2,14),Uv=Math.pow(2,21),zv=Math.pow(2,28),kv=Math.pow(2,35),jv=Math.pow(2,42),Kv=Math.pow(2,49),Vv=Math.pow(2,56),Hv=Math.pow(2,63),Wv=function(t){return t<Lv?1:t<qv?2:t<Uv?3:t<zv?4:t<kv?5:t<jv?6:t<Kv?7:t<Vv?8:t<Hv?9:10},Gv={encode:$v,decode:Cv,encodingLength:Wv},qh=Gv;const Uh=(t,e,r=0)=>(qh.encode(t,e,r),e),zh=t=>qh.encodingLength(t),Va=(t,e)=>{const r=e.byteLength,i=zh(t),n=i+zh(r),s=new Uint8Array(n+r);return Uh(t,s,0),Uh(r,s,i),s.set(e,n),new Jv(t,r,e,s)};class Jv{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const kh=({name:t,code:e,encode:r})=>new Yv(t,e,r);class Yv{constructor(e,r,i){this.name=e,this.code=r,this.encode=i}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?Va(this.code,r):r.then(i=>Va(this.code,i))}else throw Error("Unknown type, must be binary type")}}const jh=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Xv=kh({name:"sha2-256",code:18,encode:jh("SHA-256")}),Zv=kh({name:"sha2-512",code:19,encode:jh("SHA-512")});var Qv=Object.freeze({__proto__:null,sha256:Xv,sha512:Zv});const Kh=0,ey="identity",Vh=Nh;var ty=Object.freeze({__proto__:null,identity:{code:Kh,name:ey,encode:Vh,digest:t=>Va(Kh,Vh(t))}});new TextEncoder,new TextDecoder;const Hh={...Jb,...Xb,...Qb,...tv,...nv,...pv,...vv,...wv,...Mv,...Rv};({...Qv,...ty});function Wh(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const Gh=Wh("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Ha=Wh("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=Rh(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Jh={utf8:Gh,"utf-8":Gh,hex:Hh.base16,latin1:Ha,ascii:Ha,binary:Ha,...Hh};function po(t,e="utf8"){const r=Jh[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}function Rn(t,e="utf8"){const r=Jh[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?ja(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}function Yh(t){return An(po(Rn(t,uo),Dh))}function go(t){return po(Rn(tn(t),Dh),uo)}function Xh(t){const e=Rn(Fb,Ph),r=Tb+po($h([e,t]),Ph);return[$b,Nb,r].join(Rb)}function ry(t){return po(t,uo)}function iy(t){return Rn(t,uo)}function ny(t){return Rn([go(t.header),go(t.payload)].join(ho),Oh)}function sy(t){return[go(t.header),go(t.payload),ry(t.signature)].join(ho)}function Wa(t){const e=t.split(ho),r=Yh(e[0]),i=Yh(e[1]),n=iy(e[2]),s=Rn(e.slice(0,2).join(ho),Oh);return{header:r,payload:i,signature:n,data:s}}function Zh(t=fh(Cb)){const e=Ah.getPublicKey(t);return{secretKey:$h([t,e]),publicKey:e}}async function oy(t,e,r,i,n=Y.fromMiliseconds(Date.now())){const s={alg:Ob,typ:Pb},o=Xh(i.publicKey),a=n+r,c={iss:o,sub:t,aud:e,iat:n,exp:a},h=ny({header:s,payload:c}),l=Ah.sign(h,i.secretKey.slice(0,32));return sy({header:s,payload:c,signature:l})}var Qh=function(t,e,r){if(r||arguments.length===2)for(var i=0,n=e.length,s;i<n;i++)(s||!(i in e))&&(s||(s=Array.prototype.slice.call(e,0,i)),s[i]=e[i]);return t.concat(s||Array.prototype.slice.call(e))},ay=function(){function t(e,r,i){this.name=e,this.version=r,this.os=i,this.type="browser"}return t}(),fy=function(){function t(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return t}(),cy=function(){function t(e,r,i,n){this.name=e,this.version=r,this.os=i,this.bot=n,this.type="bot-device"}return t}(),hy=function(){function t(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return t}(),uy=function(){function t(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return t}(),dy=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,ly=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,eu=3,py=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["pie",/^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],["pie",/^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],["netfront",/^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FB[AS]V\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["curl",/^curl\/([0-9\.]+)$/],["searchbot",dy]],tu=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Windows CE",/Windows CE|WinCE|Microsoft Pocket Internet Explorer/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function gy(t){return t?ru(t):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new uy:typeof navigator<"u"?ru(navigator.userAgent):yy()}function by(t){return t!==""&&py.reduce(function(e,r){var i=r[0],n=r[1];if(e)return e;var s=n.exec(t);return!!s&&[i,s]},!1)}function ru(t){var e=by(t);if(!e)return null;var r=e[0],i=e[1];if(r==="searchbot")return new hy;var n=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);n?n.length<eu&&(n=Qh(Qh([],n,!0),my(eu-n.length),!0)):n=[];var s=n.join("."),o=vy(t),a=ly.exec(t);return a&&a[1]?new cy(r,s,o,a[1]):new ay(r,s,o)}function vy(t){for(var e=0,r=tu.length;e<r;e++){var i=tu[e],n=i[0],s=i[1],o=s.exec(t);if(o)return n}return null}function yy(){var t=typeof process<"u"&&process.version;return t?new fy(process.version.slice(1)):null}function my(t){for(var e=[],r=0;r<t;r++)e.push("0");return e}var at={};Object.defineProperty(at,"__esModule",{value:!0}),at.getLocalStorage=at.getLocalStorageOrThrow=at.getCrypto=at.getCryptoOrThrow=iu=at.getLocation=at.getLocationOrThrow=Ga=at.getNavigator=at.getNavigatorOrThrow=ds=at.getDocument=at.getDocumentOrThrow=at.getFromWindowOrThrow=at.getFromWindow=void 0;function nn(t){let e;return typeof window<"u"&&typeof window[t]<"u"&&(e=window[t]),e}at.getFromWindow=nn;function $n(t){const e=nn(t);if(!e)throw new Error(`${t} is not defined in Window`);return e}at.getFromWindowOrThrow=$n;function wy(){return $n("document")}at.getDocumentOrThrow=wy;function _y(){return nn("document")}var ds=at.getDocument=_y;function xy(){return $n("navigator")}at.getNavigatorOrThrow=xy;function Ey(){return nn("navigator")}var Ga=at.getNavigator=Ey;function Sy(){return $n("location")}at.getLocationOrThrow=Sy;function My(){return nn("location")}var iu=at.getLocation=My;function Iy(){return $n("crypto")}at.getCryptoOrThrow=Iy;function Ay(){return nn("crypto")}at.getCrypto=Ay;function Dy(){return $n("localStorage")}at.getLocalStorageOrThrow=Dy;function Oy(){return nn("localStorage")}at.getLocalStorage=Oy;var Ja={};Object.defineProperty(Ja,"__esModule",{value:!0});var nu=Ja.getWindowMetadata=void 0;const su=at;function Py(){let t,e;try{t=su.getDocumentOrThrow(),e=su.getLocationOrThrow()}catch{return null}function r(){const y=t.getElementsByTagName("link"),M=[];for(let I=0;I<y.length;I++){const S=y[I],D=S.getAttribute("rel");if(D&&D.toLowerCase().indexOf("icon")>-1){const R=S.getAttribute("href");if(R)if(R.toLowerCase().indexOf("https:")===-1&&R.toLowerCase().indexOf("http:")===-1&&R.indexOf("//")!==0){let $=e.protocol+"//"+e.host;if(R.indexOf("/")===0)$+=R;else{const T=e.pathname.split("/");T.pop();const C=T.join("/");$+=C+"/"+R}M.push($)}else if(R.indexOf("//")===0){const $=e.protocol+R;M.push($)}else M.push(R)}}return M}function i(...y){const M=t.getElementsByTagName("meta");for(let I=0;I<M.length;I++){const S=M[I],D=["itemprop","property","name"].map(R=>S.getAttribute(R)).filter(R=>R?y.includes(R):!1);if(D.length&&D){const R=S.getAttribute("content");if(R)return R}}return""}function n(){let y=i("name","og:site_name","og:title","twitter:title");return y||(y=t.title),y}function s(){return i("description","og:description","twitter:description","keywords")}const o=n(),a=s(),c=e.origin,h=r();return{description:a,url:c,icons:h,name:o}}nu=Ja.getWindowMetadata=Py;const Ry="logger/5.7.0";let ou=!1,au=!1;const bo={debug:1,default:2,info:2,warning:3,error:4,off:5};let fu=bo.default,Ya=null;function $y(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{t.push(e)}}),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}const cu=$y();var Xa;(function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"})(Xa||(Xa={}));var Tr;(function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED",t.ACTION_REJECTED="ACTION_REJECTED"})(Tr||(Tr={}));const hu="0123456789abcdef";class Ee{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,r){const i=e.toLowerCase();bo[i]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(fu>bo[i])&&console.log.apply(console,r)}debug(...e){this._log(Ee.levels.DEBUG,e)}info(...e){this._log(Ee.levels.INFO,e)}warn(...e){this._log(Ee.levels.WARNING,e)}makeError(e,r,i){if(au)return this.makeError("censored error",r,{});r||(r=Ee.errors.UNKNOWN_ERROR),i||(i={});const n=[];Object.keys(i).forEach(c=>{const h=i[c];try{if(h instanceof Uint8Array){let l="";for(let y=0;y<h.length;y++)l+=hu[h[y]>>4],l+=hu[h[y]&15];n.push(c+"=Uint8Array(0x"+l+")")}else n.push(c+"="+JSON.stringify(h))}catch{n.push(c+"="+JSON.stringify(i[c].toString()))}}),n.push(`code=${r}`),n.push(`version=${this.version}`);const s=e;let o="";switch(r){case Tr.NUMERIC_FAULT:{o="NUMERIC_FAULT";const c=e;switch(c){case"overflow":case"underflow":case"division-by-zero":o+="-"+c;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result";break}break}case Tr.CALL_EXCEPTION:case Tr.INSUFFICIENT_FUNDS:case Tr.MISSING_NEW:case Tr.NONCE_EXPIRED:case Tr.REPLACEMENT_UNDERPRICED:case Tr.TRANSACTION_REPLACED:case Tr.UNPREDICTABLE_GAS_LIMIT:o=r;break}o&&(e+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),n.length&&(e+=" ("+n.join(", ")+")");const a=new Error(e);return a.reason=s,a.code=r,Object.keys(i).forEach(function(c){a[c]=i[c]}),a}throwError(e,r,i){throw this.makeError(e,r,i)}throwArgumentError(e,r,i){return this.throwError(e,Ee.errors.INVALID_ARGUMENT,{argument:r,value:i})}assert(e,r,i,n){e||this.throwError(r,i,n)}assertArgument(e,r,i,n){e||this.throwArgumentError(r,i,n)}checkNormalize(e){cu&&this.throwError("platform missing String.prototype.normalize",Ee.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:cu})}checkSafeUint53(e,r){typeof e=="number"&&(r==null&&(r="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(r,Ee.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(r,Ee.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,r,i){i?i=": "+i:i="",e<r&&this.throwError("missing argument"+i,Ee.errors.MISSING_ARGUMENT,{count:e,expectedCount:r}),e>r&&this.throwError("too many arguments"+i,Ee.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:r})}checkNew(e,r){(e===Object||e==null)&&this.throwError("missing new",Ee.errors.MISSING_NEW,{name:r.name})}checkAbstract(e,r){e===r?this.throwError("cannot instantiate abstract class "+JSON.stringify(r.name)+" directly; use a sub-class",Ee.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",Ee.errors.MISSING_NEW,{name:r.name})}static globalLogger(){return Ya||(Ya=new Ee(Ry)),Ya}static setCensorship(e,r){if(!e&&r&&this.globalLogger().throwError("cannot permanently disable censorship",Ee.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),ou){if(!e)return;this.globalLogger().throwError("error censorship permanent",Ee.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}au=!!e,ou=!!r}static setLogLevel(e){const r=bo[e.toLowerCase()];if(r==null){Ee.globalLogger().warn("invalid log level - "+e);return}fu=r}static from(e){return new Ee(e)}}Ee.errors=Tr,Ee.levels=Xa;const Ny="bytes/5.7.0",yt=new Ee(Ny);function uu(t){return!!t.toHexString}function ls(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return ls(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function Ty(t){return ur(t)&&!(t.length%2)||Nn(t)}function du(t){return typeof t=="number"&&t==t&&t%1===0}function Nn(t){if(t==null)return!1;if(t.constructor===Uint8Array)return!0;if(typeof t=="string"||!du(t.length)||t.length<0)return!1;for(let e=0;e<t.length;e++){const r=t[e];if(!du(r)||r<0||r>=256)return!1}return!0}function xt(t,e){if(e||(e={}),typeof t=="number"){yt.checkSafeUint53(t,"invalid arrayify value");const r=[];for(;t;)r.unshift(t&255),t=parseInt(String(t/256));return r.length===0&&r.push(0),ls(new Uint8Array(r))}if(e.allowMissingPrefix&&typeof t=="string"&&t.substring(0,2)!=="0x"&&(t="0x"+t),uu(t)&&(t=t.toHexString()),ur(t)){let r=t.substring(2);r.length%2&&(e.hexPad==="left"?r="0"+r:e.hexPad==="right"?r+="0":yt.throwArgumentError("hex data is odd-length","value",t));const i=[];for(let n=0;n<r.length;n+=2)i.push(parseInt(r.substring(n,n+2),16));return ls(new Uint8Array(i))}return Nn(t)?ls(new Uint8Array(t)):yt.throwArgumentError("invalid arrayify value","value",t)}function Fy(t,e){t=xt(t),t.length>e&&yt.throwArgumentError("value out of range","value",arguments[0]);const r=new Uint8Array(e);return r.set(t,e-t.length),ls(r)}function ur(t,e){return!(typeof t!="string"||!t.match(/^0x[0-9A-Fa-f]*$/)||e&&t.length!==2+2*e)}const Za="0123456789abcdef";function Yt(t,e){if(e||(e={}),typeof t=="number"){yt.checkSafeUint53(t,"invalid hexlify value");let r="";for(;t;)r=Za[t&15]+r,t=Math.floor(t/16);return r.length?(r.length%2&&(r="0"+r),"0x"+r):"0x00"}if(typeof t=="bigint")return t=t.toString(16),t.length%2?"0x0"+t:"0x"+t;if(e.allowMissingPrefix&&typeof t=="string"&&t.substring(0,2)!=="0x"&&(t="0x"+t),uu(t))return t.toHexString();if(ur(t))return t.length%2&&(e.hexPad==="left"?t="0x0"+t.substring(2):e.hexPad==="right"?t+="0":yt.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(Nn(t)){let r="0x";for(let i=0;i<t.length;i++){let n=t[i];r+=Za[(n&240)>>4]+Za[n&15]}return r}return yt.throwArgumentError("invalid hexlify value","value",t)}function Cy(t){if(typeof t!="string")t=Yt(t);else if(!ur(t)||t.length%2)return null;return(t.length-2)/2}function lu(t,e,r){return typeof t!="string"?t=Yt(t):(!ur(t)||t.length%2)&&yt.throwArgumentError("invalid hexData","value",t),e=2+2*e,r!=null?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}function Fi(t,e){for(typeof t!="string"?t=Yt(t):ur(t)||yt.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&yt.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}function pu(t){const e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(Ty(t)){let r=xt(t);r.length===64?(e.v=27+(r[32]>>7),r[32]&=127,e.r=Yt(r.slice(0,32)),e.s=Yt(r.slice(32,64))):r.length===65?(e.r=Yt(r.slice(0,32)),e.s=Yt(r.slice(32,64)),e.v=r[64]):yt.throwArgumentError("invalid signature string","signature",t),e.v<27&&(e.v===0||e.v===1?e.v+=27:yt.throwArgumentError("signature invalid v byte","signature",t)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(r[32]|=128),e._vs=Yt(r.slice(32,64))}else{if(e.r=t.r,e.s=t.s,e.v=t.v,e.recoveryParam=t.recoveryParam,e._vs=t._vs,e._vs!=null){const n=Fy(xt(e._vs),32);e._vs=Yt(n);const s=n[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=s:e.recoveryParam!==s&&yt.throwArgumentError("signature recoveryParam mismatch _vs","signature",t),n[0]&=127;const o=Yt(n);e.s==null?e.s=o:e.s!==o&&yt.throwArgumentError("signature v mismatch _vs","signature",t)}if(e.recoveryParam==null)e.v==null?yt.throwArgumentError("signature missing v and recoveryParam","signature",t):e.v===0||e.v===1?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2;else if(e.v==null)e.v=27+e.recoveryParam;else{const n=e.v===0||e.v===1?e.v:1-e.v%2;e.recoveryParam!==n&&yt.throwArgumentError("signature recoveryParam mismatch v","signature",t)}e.r==null||!ur(e.r)?yt.throwArgumentError("signature missing or invalid r","signature",t):e.r=Fi(e.r,32),e.s==null||!ur(e.s)?yt.throwArgumentError("signature missing or invalid s","signature",t):e.s=Fi(e.s,32);const r=xt(e.s);r[0]>=128&&yt.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(r[0]|=128);const i=Yt(r);e._vs&&(ur(e._vs)||yt.throwArgumentError("signature invalid _vs","signature",t),e._vs=Fi(e._vs,32)),e._vs==null?e._vs=i:e._vs!==i&&yt.throwArgumentError("signature _vs mismatch v and s","signature",t)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}var gu={exports:{}},By={},Ly=Object.freeze({__proto__:null,default:By}),Qa=ha(Ly);(function(t){(function(e,r){function i(p,f){if(!p)throw new Error(f||"Assertion failed")}function n(p,f){p.super_=f;var u=function(){};u.prototype=f.prototype,p.prototype=new u,p.prototype.constructor=p}function s(p,f,u){if(s.isBN(p))return p;this.negative=0,this.words=null,this.length=0,this.red=null,p!==null&&((f==="le"||f==="be")&&(u=f,f=10),this._init(p||0,f||10,u||"be"))}typeof e=="object"?e.exports=s:r.BN=s,s.BN=s,s.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Qa.Buffer}catch{}s.isBN=function(f){return f instanceof s?!0:f!==null&&typeof f=="object"&&f.constructor.wordSize===s.wordSize&&Array.isArray(f.words)},s.max=function(f,u){return f.cmp(u)>0?f:u},s.min=function(f,u){return f.cmp(u)<0?f:u},s.prototype._init=function(f,u,b){if(typeof f=="number")return this._initNumber(f,u,b);if(typeof f=="object")return this._initArray(f,u,b);u==="hex"&&(u=16),i(u===(u|0)&&u>=2&&u<=36),f=f.toString().replace(/\s+/g,"");var _=0;f[0]==="-"&&(_++,this.negative=1),_<f.length&&(u===16?this._parseHex(f,_,b):(this._parseBase(f,u,_),b==="le"&&this._initArray(this.toArray(),u,b)))},s.prototype._initNumber=function(f,u,b){f<0&&(this.negative=1,f=-f),f<67108864?(this.words=[f&67108863],this.length=1):f<4503599627370496?(this.words=[f&67108863,f/67108864&67108863],this.length=2):(i(f<9007199254740992),this.words=[f&67108863,f/67108864&67108863,1],this.length=3),b==="le"&&this._initArray(this.toArray(),u,b)},s.prototype._initArray=function(f,u,b){if(i(typeof f.length=="number"),f.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(f.length/3),this.words=new Array(this.length);for(var _=0;_<this.length;_++)this.words[_]=0;var E,w,d=0;if(b==="be")for(_=f.length-1,E=0;_>=0;_-=3)w=f[_]|f[_-1]<<8|f[_-2]<<16,this.words[E]|=w<<d&67108863,this.words[E+1]=w>>>26-d&67108863,d+=24,d>=26&&(d-=26,E++);else if(b==="le")for(_=0,E=0;_<f.length;_+=3)w=f[_]|f[_+1]<<8|f[_+2]<<16,this.words[E]|=w<<d&67108863,this.words[E+1]=w>>>26-d&67108863,d+=24,d>=26&&(d-=26,E++);return this._strip()};function a(p,f){var u=p.charCodeAt(f);if(u>=48&&u<=57)return u-48;if(u>=65&&u<=70)return u-55;if(u>=97&&u<=102)return u-87;i(!1,"Invalid character in "+p)}function c(p,f,u){var b=a(p,u);return u-1>=f&&(b|=a(p,u-1)<<4),b}s.prototype._parseHex=function(f,u,b){this.length=Math.ceil((f.length-u)/6),this.words=new Array(this.length);for(var _=0;_<this.length;_++)this.words[_]=0;var E=0,w=0,d;if(b==="be")for(_=f.length-1;_>=u;_-=2)d=c(f,u,_)<<E,this.words[w]|=d&67108863,E>=18?(E-=18,w+=1,this.words[w]|=d>>>26):E+=8;else{var m=f.length-u;for(_=m%2===0?u+1:u;_<f.length;_+=2)d=c(f,u,_)<<E,this.words[w]|=d&67108863,E>=18?(E-=18,w+=1,this.words[w]|=d>>>26):E+=8}this._strip()};function h(p,f,u,b){for(var _=0,E=0,w=Math.min(p.length,u),d=f;d<w;d++){var m=p.charCodeAt(d)-48;_*=b,m>=49?E=m-49+10:m>=17?E=m-17+10:E=m,i(m>=0&&E<b,"Invalid character"),_+=E}return _}s.prototype._parseBase=function(f,u,b){this.words=[0],this.length=1;for(var _=0,E=1;E<=67108863;E*=u)_++;_--,E=E/u|0;for(var w=f.length-b,d=w%_,m=Math.min(w,w-d)+b,v=0,A=b;A<m;A+=_)v=h(f,A,A+_,u),this.imuln(E),this.words[0]+v<67108864?this.words[0]+=v:this._iaddn(v);if(d!==0){var U=1;for(v=h(f,A,f.length,u),A=0;A<d;A++)U*=u;this.imuln(U),this.words[0]+v<67108864?this.words[0]+=v:this._iaddn(v)}this._strip()},s.prototype.copy=function(f){f.words=new Array(this.length);for(var u=0;u<this.length;u++)f.words[u]=this.words[u];f.length=this.length,f.negative=this.negative,f.red=this.red};function l(p,f){p.words=f.words,p.length=f.length,p.negative=f.negative,p.red=f.red}if(s.prototype._move=function(f){l(f,this)},s.prototype.clone=function(){var f=new s(null);return this.copy(f),f},s.prototype._expand=function(f){for(;this.length<f;)this.words[this.length++]=0;return this},s.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{s.prototype[Symbol.for("nodejs.util.inspect.custom")]=y}catch{s.prototype.inspect=y}else s.prototype.inspect=y;function y(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var M=["","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"],I=[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],S=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];s.prototype.toString=function(f,u){f=f||10,u=u|0||1;var b;if(f===16||f==="hex"){b="";for(var _=0,E=0,w=0;w<this.length;w++){var d=this.words[w],m=((d<<_|E)&16777215).toString(16);E=d>>>24-_&16777215,_+=2,_>=26&&(_-=26,w--),E!==0||w!==this.length-1?b=M[6-m.length]+m+b:b=m+b}for(E!==0&&(b=E.toString(16)+b);b.length%u!==0;)b="0"+b;return this.negative!==0&&(b="-"+b),b}if(f===(f|0)&&f>=2&&f<=36){var v=I[f],A=S[f];b="";var U=this.clone();for(U.negative=0;!U.isZero();){var x=U.modrn(A).toString(f);U=U.idivn(A),U.isZero()?b=x+b:b=M[v-x.length]+x+b}for(this.isZero()&&(b="0"+b);b.length%u!==0;)b="0"+b;return this.negative!==0&&(b="-"+b),b}i(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var f=this.words[0];return this.length===2?f+=this.words[1]*67108864:this.length===3&&this.words[2]===1?f+=4503599627370496+this.words[1]*67108864:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-f:f},s.prototype.toJSON=function(){return this.toString(16,2)},o&&(s.prototype.toBuffer=function(f,u){return this.toArrayLike(o,f,u)}),s.prototype.toArray=function(f,u){return this.toArrayLike(Array,f,u)};var D=function(f,u){return f.allocUnsafe?f.allocUnsafe(u):new f(u)};s.prototype.toArrayLike=function(f,u,b){this._strip();var _=this.byteLength(),E=b||Math.max(1,_);i(_<=E,"byte array longer than desired length"),i(E>0,"Requested array length <= 0");var w=D(f,E),d=u==="le"?"LE":"BE";return this["_toArrayLike"+d](w,_),w},s.prototype._toArrayLikeLE=function(f,u){for(var b=0,_=0,E=0,w=0;E<this.length;E++){var d=this.words[E]<<w|_;f[b++]=d&255,b<f.length&&(f[b++]=d>>8&255),b<f.length&&(f[b++]=d>>16&255),w===6?(b<f.length&&(f[b++]=d>>24&255),_=0,w=0):(_=d>>>24,w+=2)}if(b<f.length)for(f[b++]=_;b<f.length;)f[b++]=0},s.prototype._toArrayLikeBE=function(f,u){for(var b=f.length-1,_=0,E=0,w=0;E<this.length;E++){var d=this.words[E]<<w|_;f[b--]=d&255,b>=0&&(f[b--]=d>>8&255),b>=0&&(f[b--]=d>>16&255),w===6?(b>=0&&(f[b--]=d>>24&255),_=0,w=0):(_=d>>>24,w+=2)}if(b>=0)for(f[b--]=_;b>=0;)f[b--]=0},Math.clz32?s.prototype._countBits=function(f){return 32-Math.clz32(f)}:s.prototype._countBits=function(f){var u=f,b=0;return u>=4096&&(b+=13,u>>>=13),u>=64&&(b+=7,u>>>=7),u>=8&&(b+=4,u>>>=4),u>=2&&(b+=2,u>>>=2),b+u},s.prototype._zeroBits=function(f){if(f===0)return 26;var u=f,b=0;return u&8191||(b+=13,u>>>=13),u&127||(b+=7,u>>>=7),u&15||(b+=4,u>>>=4),u&3||(b+=2,u>>>=2),u&1||b++,b},s.prototype.bitLength=function(){var f=this.words[this.length-1],u=this._countBits(f);return(this.length-1)*26+u};function R(p){for(var f=new Array(p.bitLength()),u=0;u<f.length;u++){var b=u/26|0,_=u%26;f[u]=p.words[b]>>>_&1}return f}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var f=0,u=0;u<this.length;u++){var b=this._zeroBits(this.words[u]);if(f+=b,b!==26)break}return f},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(f){return this.negative!==0?this.abs().inotn(f).iaddn(1):this.clone()},s.prototype.fromTwos=function(f){return this.testn(f-1)?this.notn(f).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return this.negative!==0},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(f){for(;this.length<f.length;)this.words[this.length++]=0;for(var u=0;u<f.length;u++)this.words[u]=this.words[u]|f.words[u];return this._strip()},s.prototype.ior=function(f){return i((this.negative|f.negative)===0),this.iuor(f)},s.prototype.or=function(f){return this.length>f.length?this.clone().ior(f):f.clone().ior(this)},s.prototype.uor=function(f){return this.length>f.length?this.clone().iuor(f):f.clone().iuor(this)},s.prototype.iuand=function(f){var u;this.length>f.length?u=f:u=this;for(var b=0;b<u.length;b++)this.words[b]=this.words[b]&f.words[b];return this.length=u.length,this._strip()},s.prototype.iand=function(f){return i((this.negative|f.negative)===0),this.iuand(f)},s.prototype.and=function(f){return this.length>f.length?this.clone().iand(f):f.clone().iand(this)},s.prototype.uand=function(f){return this.length>f.length?this.clone().iuand(f):f.clone().iuand(this)},s.prototype.iuxor=function(f){var u,b;this.length>f.length?(u=this,b=f):(u=f,b=this);for(var _=0;_<b.length;_++)this.words[_]=u.words[_]^b.words[_];if(this!==u)for(;_<u.length;_++)this.words[_]=u.words[_];return this.length=u.length,this._strip()},s.prototype.ixor=function(f){return i((this.negative|f.negative)===0),this.iuxor(f)},s.prototype.xor=function(f){return this.length>f.length?this.clone().ixor(f):f.clone().ixor(this)},s.prototype.uxor=function(f){return this.length>f.length?this.clone().iuxor(f):f.clone().iuxor(this)},s.prototype.inotn=function(f){i(typeof f=="number"&&f>=0);var u=Math.ceil(f/26)|0,b=f%26;this._expand(u),b>0&&u--;for(var _=0;_<u;_++)this.words[_]=~this.words[_]&67108863;return b>0&&(this.words[_]=~this.words[_]&67108863>>26-b),this._strip()},s.prototype.notn=function(f){return this.clone().inotn(f)},s.prototype.setn=function(f,u){i(typeof f=="number"&&f>=0);var b=f/26|0,_=f%26;return this._expand(b+1),u?this.words[b]=this.words[b]|1<<_:this.words[b]=this.words[b]&~(1<<_),this._strip()},s.prototype.iadd=function(f){var u;if(this.negative!==0&&f.negative===0)return this.negative=0,u=this.isub(f),this.negative^=1,this._normSign();if(this.negative===0&&f.negative!==0)return f.negative=0,u=this.isub(f),f.negative=1,u._normSign();var b,_;this.length>f.length?(b=this,_=f):(b=f,_=this);for(var E=0,w=0;w<_.length;w++)u=(b.words[w]|0)+(_.words[w]|0)+E,this.words[w]=u&67108863,E=u>>>26;for(;E!==0&&w<b.length;w++)u=(b.words[w]|0)+E,this.words[w]=u&67108863,E=u>>>26;if(this.length=b.length,E!==0)this.words[this.length]=E,this.length++;else if(b!==this)for(;w<b.length;w++)this.words[w]=b.words[w];return this},s.prototype.add=function(f){var u;return f.negative!==0&&this.negative===0?(f.negative=0,u=this.sub(f),f.negative^=1,u):f.negative===0&&this.negative!==0?(this.negative=0,u=f.sub(this),this.negative=1,u):this.length>f.length?this.clone().iadd(f):f.clone().iadd(this)},s.prototype.isub=function(f){if(f.negative!==0){f.negative=0;var u=this.iadd(f);return f.negative=1,u._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(f),this.negative=1,this._normSign();var b=this.cmp(f);if(b===0)return this.negative=0,this.length=1,this.words[0]=0,this;var _,E;b>0?(_=this,E=f):(_=f,E=this);for(var w=0,d=0;d<E.length;d++)u=(_.words[d]|0)-(E.words[d]|0)+w,w=u>>26,this.words[d]=u&67108863;for(;w!==0&&d<_.length;d++)u=(_.words[d]|0)+w,w=u>>26,this.words[d]=u&67108863;if(w===0&&d<_.length&&_!==this)for(;d<_.length;d++)this.words[d]=_.words[d];return this.length=Math.max(this.length,d),_!==this&&(this.negative=1),this._strip()},s.prototype.sub=function(f){return this.clone().isub(f)};function $(p,f,u){u.negative=f.negative^p.negative;var b=p.length+f.length|0;u.length=b,b=b-1|0;var _=p.words[0]|0,E=f.words[0]|0,w=_*E,d=w&67108863,m=w/67108864|0;u.words[0]=d;for(var v=1;v<b;v++){for(var A=m>>>26,U=m&67108863,x=Math.min(v,f.length-1),N=Math.max(0,v-p.length+1);N<=x;N++){var B=v-N|0;_=p.words[B]|0,E=f.words[N]|0,w=_*E+U,A+=w/67108864|0,U=w&67108863}u.words[v]=U|0,m=A|0}return m!==0?u.words[v]=m|0:u.length--,u._strip()}var T=function(f,u,b){var _=f.words,E=u.words,w=b.words,d=0,m,v,A,U=_[0]|0,x=U&8191,N=U>>>13,B=_[1]|0,q=B&8191,z=B>>>13,J=_[2]|0,X=J&8191,W=J>>>13,ne=_[3]|0,Q=ne&8191,ee=ne>>>13,qe=_[4]|0,Ue=qe&8191,he=qe>>>13,Pe=_[5]|0,Re=Pe&8191,ae=Pe>>>13,$e=_[6]|0,Ne=$e&8191,ce=$e>>>13,Te=_[7]|0,Fe=Te&8191,oe=Te>>>13,De=_[8]|0,Ce=De&8191,ie=De>>>13,Ve=_[9]|0,He=Ve&8191,pe=Ve>>>13,We=E[0]|0,Be=We&8191,de=We>>>13,Ge=E[1]|0,Xe=Ge&8191,se=Ge>>>13,Je=E[2]|0,Ze=Je&8191,ge=Je>>>13,ze=E[3]|0,Oe=ze&8191,ue=ze>>>13,ke=E[4]|0,je=ke&8191,fe=ke>>>13,Qe=E[5]|0,et=Qe&8191,be=Qe>>>13,tt=E[6]|0,rt=tt&8191,le=tt>>>13,Ke=E[7]|0,Ae=Ke&8191,ve=Ke>>>13,it=E[8]|0,nt=it&8191,ye=it>>>13,st=E[9]|0,xe=st&8191,Ye=st>>>13;b.negative=f.negative^u.negative,b.length=19,m=Math.imul(x,Be),v=Math.imul(x,de),v=v+Math.imul(N,Be)|0,A=Math.imul(N,de);var ar=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(ar>>>26)|0,ar&=67108863,m=Math.imul(q,Be),v=Math.imul(q,de),v=v+Math.imul(z,Be)|0,A=Math.imul(z,de),m=m+Math.imul(x,Xe)|0,v=v+Math.imul(x,se)|0,v=v+Math.imul(N,Xe)|0,A=A+Math.imul(N,se)|0;var fr=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(fr>>>26)|0,fr&=67108863,m=Math.imul(X,Be),v=Math.imul(X,de),v=v+Math.imul(W,Be)|0,A=Math.imul(W,de),m=m+Math.imul(q,Xe)|0,v=v+Math.imul(q,se)|0,v=v+Math.imul(z,Xe)|0,A=A+Math.imul(z,se)|0,m=m+Math.imul(x,Ze)|0,v=v+Math.imul(x,ge)|0,v=v+Math.imul(N,Ze)|0,A=A+Math.imul(N,ge)|0;var cr=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(cr>>>26)|0,cr&=67108863,m=Math.imul(Q,Be),v=Math.imul(Q,de),v=v+Math.imul(ee,Be)|0,A=Math.imul(ee,de),m=m+Math.imul(X,Xe)|0,v=v+Math.imul(X,se)|0,v=v+Math.imul(W,Xe)|0,A=A+Math.imul(W,se)|0,m=m+Math.imul(q,Ze)|0,v=v+Math.imul(q,ge)|0,v=v+Math.imul(z,Ze)|0,A=A+Math.imul(z,ge)|0,m=m+Math.imul(x,Oe)|0,v=v+Math.imul(x,ue)|0,v=v+Math.imul(N,Oe)|0,A=A+Math.imul(N,ue)|0;var hr=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(hr>>>26)|0,hr&=67108863,m=Math.imul(Ue,Be),v=Math.imul(Ue,de),v=v+Math.imul(he,Be)|0,A=Math.imul(he,de),m=m+Math.imul(Q,Xe)|0,v=v+Math.imul(Q,se)|0,v=v+Math.imul(ee,Xe)|0,A=A+Math.imul(ee,se)|0,m=m+Math.imul(X,Ze)|0,v=v+Math.imul(X,ge)|0,v=v+Math.imul(W,Ze)|0,A=A+Math.imul(W,ge)|0,m=m+Math.imul(q,Oe)|0,v=v+Math.imul(q,ue)|0,v=v+Math.imul(z,Oe)|0,A=A+Math.imul(z,ue)|0,m=m+Math.imul(x,je)|0,v=v+Math.imul(x,fe)|0,v=v+Math.imul(N,je)|0,A=A+Math.imul(N,fe)|0;var wt=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(wt>>>26)|0,wt&=67108863,m=Math.imul(Re,Be),v=Math.imul(Re,de),v=v+Math.imul(ae,Be)|0,A=Math.imul(ae,de),m=m+Math.imul(Ue,Xe)|0,v=v+Math.imul(Ue,se)|0,v=v+Math.imul(he,Xe)|0,A=A+Math.imul(he,se)|0,m=m+Math.imul(Q,Ze)|0,v=v+Math.imul(Q,ge)|0,v=v+Math.imul(ee,Ze)|0,A=A+Math.imul(ee,ge)|0,m=m+Math.imul(X,Oe)|0,v=v+Math.imul(X,ue)|0,v=v+Math.imul(W,Oe)|0,A=A+Math.imul(W,ue)|0,m=m+Math.imul(q,je)|0,v=v+Math.imul(q,fe)|0,v=v+Math.imul(z,je)|0,A=A+Math.imul(z,fe)|0,m=m+Math.imul(x,et)|0,v=v+Math.imul(x,be)|0,v=v+Math.imul(N,et)|0,A=A+Math.imul(N,be)|0;var xi=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(xi>>>26)|0,xi&=67108863,m=Math.imul(Ne,Be),v=Math.imul(Ne,de),v=v+Math.imul(ce,Be)|0,A=Math.imul(ce,de),m=m+Math.imul(Re,Xe)|0,v=v+Math.imul(Re,se)|0,v=v+Math.imul(ae,Xe)|0,A=A+Math.imul(ae,se)|0,m=m+Math.imul(Ue,Ze)|0,v=v+Math.imul(Ue,ge)|0,v=v+Math.imul(he,Ze)|0,A=A+Math.imul(he,ge)|0,m=m+Math.imul(Q,Oe)|0,v=v+Math.imul(Q,ue)|0,v=v+Math.imul(ee,Oe)|0,A=A+Math.imul(ee,ue)|0,m=m+Math.imul(X,je)|0,v=v+Math.imul(X,fe)|0,v=v+Math.imul(W,je)|0,A=A+Math.imul(W,fe)|0,m=m+Math.imul(q,et)|0,v=v+Math.imul(q,be)|0,v=v+Math.imul(z,et)|0,A=A+Math.imul(z,be)|0,m=m+Math.imul(x,rt)|0,v=v+Math.imul(x,le)|0,v=v+Math.imul(N,rt)|0,A=A+Math.imul(N,le)|0;var Ei=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(Ei>>>26)|0,Ei&=67108863,m=Math.imul(Fe,Be),v=Math.imul(Fe,de),v=v+Math.imul(oe,Be)|0,A=Math.imul(oe,de),m=m+Math.imul(Ne,Xe)|0,v=v+Math.imul(Ne,se)|0,v=v+Math.imul(ce,Xe)|0,A=A+Math.imul(ce,se)|0,m=m+Math.imul(Re,Ze)|0,v=v+Math.imul(Re,ge)|0,v=v+Math.imul(ae,Ze)|0,A=A+Math.imul(ae,ge)|0,m=m+Math.imul(Ue,Oe)|0,v=v+Math.imul(Ue,ue)|0,v=v+Math.imul(he,Oe)|0,A=A+Math.imul(he,ue)|0,m=m+Math.imul(Q,je)|0,v=v+Math.imul(Q,fe)|0,v=v+Math.imul(ee,je)|0,A=A+Math.imul(ee,fe)|0,m=m+Math.imul(X,et)|0,v=v+Math.imul(X,be)|0,v=v+Math.imul(W,et)|0,A=A+Math.imul(W,be)|0,m=m+Math.imul(q,rt)|0,v=v+Math.imul(q,le)|0,v=v+Math.imul(z,rt)|0,A=A+Math.imul(z,le)|0,m=m+Math.imul(x,Ae)|0,v=v+Math.imul(x,ve)|0,v=v+Math.imul(N,Ae)|0,A=A+Math.imul(N,ve)|0;var Si=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(Si>>>26)|0,Si&=67108863,m=Math.imul(Ce,Be),v=Math.imul(Ce,de),v=v+Math.imul(ie,Be)|0,A=Math.imul(ie,de),m=m+Math.imul(Fe,Xe)|0,v=v+Math.imul(Fe,se)|0,v=v+Math.imul(oe,Xe)|0,A=A+Math.imul(oe,se)|0,m=m+Math.imul(Ne,Ze)|0,v=v+Math.imul(Ne,ge)|0,v=v+Math.imul(ce,Ze)|0,A=A+Math.imul(ce,ge)|0,m=m+Math.imul(Re,Oe)|0,v=v+Math.imul(Re,ue)|0,v=v+Math.imul(ae,Oe)|0,A=A+Math.imul(ae,ue)|0,m=m+Math.imul(Ue,je)|0,v=v+Math.imul(Ue,fe)|0,v=v+Math.imul(he,je)|0,A=A+Math.imul(he,fe)|0,m=m+Math.imul(Q,et)|0,v=v+Math.imul(Q,be)|0,v=v+Math.imul(ee,et)|0,A=A+Math.imul(ee,be)|0,m=m+Math.imul(X,rt)|0,v=v+Math.imul(X,le)|0,v=v+Math.imul(W,rt)|0,A=A+Math.imul(W,le)|0,m=m+Math.imul(q,Ae)|0,v=v+Math.imul(q,ve)|0,v=v+Math.imul(z,Ae)|0,A=A+Math.imul(z,ve)|0,m=m+Math.imul(x,nt)|0,v=v+Math.imul(x,ye)|0,v=v+Math.imul(N,nt)|0,A=A+Math.imul(N,ye)|0;var Mi=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(Mi>>>26)|0,Mi&=67108863,m=Math.imul(He,Be),v=Math.imul(He,de),v=v+Math.imul(pe,Be)|0,A=Math.imul(pe,de),m=m+Math.imul(Ce,Xe)|0,v=v+Math.imul(Ce,se)|0,v=v+Math.imul(ie,Xe)|0,A=A+Math.imul(ie,se)|0,m=m+Math.imul(Fe,Ze)|0,v=v+Math.imul(Fe,ge)|0,v=v+Math.imul(oe,Ze)|0,A=A+Math.imul(oe,ge)|0,m=m+Math.imul(Ne,Oe)|0,v=v+Math.imul(Ne,ue)|0,v=v+Math.imul(ce,Oe)|0,A=A+Math.imul(ce,ue)|0,m=m+Math.imul(Re,je)|0,v=v+Math.imul(Re,fe)|0,v=v+Math.imul(ae,je)|0,A=A+Math.imul(ae,fe)|0,m=m+Math.imul(Ue,et)|0,v=v+Math.imul(Ue,be)|0,v=v+Math.imul(he,et)|0,A=A+Math.imul(he,be)|0,m=m+Math.imul(Q,rt)|0,v=v+Math.imul(Q,le)|0,v=v+Math.imul(ee,rt)|0,A=A+Math.imul(ee,le)|0,m=m+Math.imul(X,Ae)|0,v=v+Math.imul(X,ve)|0,v=v+Math.imul(W,Ae)|0,A=A+Math.imul(W,ve)|0,m=m+Math.imul(q,nt)|0,v=v+Math.imul(q,ye)|0,v=v+Math.imul(z,nt)|0,A=A+Math.imul(z,ye)|0,m=m+Math.imul(x,xe)|0,v=v+Math.imul(x,Ye)|0,v=v+Math.imul(N,xe)|0,A=A+Math.imul(N,Ye)|0;var Ii=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(Ii>>>26)|0,Ii&=67108863,m=Math.imul(He,Xe),v=Math.imul(He,se),v=v+Math.imul(pe,Xe)|0,A=Math.imul(pe,se),m=m+Math.imul(Ce,Ze)|0,v=v+Math.imul(Ce,ge)|0,v=v+Math.imul(ie,Ze)|0,A=A+Math.imul(ie,ge)|0,m=m+Math.imul(Fe,Oe)|0,v=v+Math.imul(Fe,ue)|0,v=v+Math.imul(oe,Oe)|0,A=A+Math.imul(oe,ue)|0,m=m+Math.imul(Ne,je)|0,v=v+Math.imul(Ne,fe)|0,v=v+Math.imul(ce,je)|0,A=A+Math.imul(ce,fe)|0,m=m+Math.imul(Re,et)|0,v=v+Math.imul(Re,be)|0,v=v+Math.imul(ae,et)|0,A=A+Math.imul(ae,be)|0,m=m+Math.imul(Ue,rt)|0,v=v+Math.imul(Ue,le)|0,v=v+Math.imul(he,rt)|0,A=A+Math.imul(he,le)|0,m=m+Math.imul(Q,Ae)|0,v=v+Math.imul(Q,ve)|0,v=v+Math.imul(ee,Ae)|0,A=A+Math.imul(ee,ve)|0,m=m+Math.imul(X,nt)|0,v=v+Math.imul(X,ye)|0,v=v+Math.imul(W,nt)|0,A=A+Math.imul(W,ye)|0,m=m+Math.imul(q,xe)|0,v=v+Math.imul(q,Ye)|0,v=v+Math.imul(z,xe)|0,A=A+Math.imul(z,Ye)|0;var Pr=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(Pr>>>26)|0,Pr&=67108863,m=Math.imul(He,Ze),v=Math.imul(He,ge),v=v+Math.imul(pe,Ze)|0,A=Math.imul(pe,ge),m=m+Math.imul(Ce,Oe)|0,v=v+Math.imul(Ce,ue)|0,v=v+Math.imul(ie,Oe)|0,A=A+Math.imul(ie,ue)|0,m=m+Math.imul(Fe,je)|0,v=v+Math.imul(Fe,fe)|0,v=v+Math.imul(oe,je)|0,A=A+Math.imul(oe,fe)|0,m=m+Math.imul(Ne,et)|0,v=v+Math.imul(Ne,be)|0,v=v+Math.imul(ce,et)|0,A=A+Math.imul(ce,be)|0,m=m+Math.imul(Re,rt)|0,v=v+Math.imul(Re,le)|0,v=v+Math.imul(ae,rt)|0,A=A+Math.imul(ae,le)|0,m=m+Math.imul(Ue,Ae)|0,v=v+Math.imul(Ue,ve)|0,v=v+Math.imul(he,Ae)|0,A=A+Math.imul(he,ve)|0,m=m+Math.imul(Q,nt)|0,v=v+Math.imul(Q,ye)|0,v=v+Math.imul(ee,nt)|0,A=A+Math.imul(ee,ye)|0,m=m+Math.imul(X,xe)|0,v=v+Math.imul(X,Ye)|0,v=v+Math.imul(W,xe)|0,A=A+Math.imul(W,Ye)|0;var Ai=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(Ai>>>26)|0,Ai&=67108863,m=Math.imul(He,Oe),v=Math.imul(He,ue),v=v+Math.imul(pe,Oe)|0,A=Math.imul(pe,ue),m=m+Math.imul(Ce,je)|0,v=v+Math.imul(Ce,fe)|0,v=v+Math.imul(ie,je)|0,A=A+Math.imul(ie,fe)|0,m=m+Math.imul(Fe,et)|0,v=v+Math.imul(Fe,be)|0,v=v+Math.imul(oe,et)|0,A=A+Math.imul(oe,be)|0,m=m+Math.imul(Ne,rt)|0,v=v+Math.imul(Ne,le)|0,v=v+Math.imul(ce,rt)|0,A=A+Math.imul(ce,le)|0,m=m+Math.imul(Re,Ae)|0,v=v+Math.imul(Re,ve)|0,v=v+Math.imul(ae,Ae)|0,A=A+Math.imul(ae,ve)|0,m=m+Math.imul(Ue,nt)|0,v=v+Math.imul(Ue,ye)|0,v=v+Math.imul(he,nt)|0,A=A+Math.imul(he,ye)|0,m=m+Math.imul(Q,xe)|0,v=v+Math.imul(Q,Ye)|0,v=v+Math.imul(ee,xe)|0,A=A+Math.imul(ee,Ye)|0;var Di=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(Di>>>26)|0,Di&=67108863,m=Math.imul(He,je),v=Math.imul(He,fe),v=v+Math.imul(pe,je)|0,A=Math.imul(pe,fe),m=m+Math.imul(Ce,et)|0,v=v+Math.imul(Ce,be)|0,v=v+Math.imul(ie,et)|0,A=A+Math.imul(ie,be)|0,m=m+Math.imul(Fe,rt)|0,v=v+Math.imul(Fe,le)|0,v=v+Math.imul(oe,rt)|0,A=A+Math.imul(oe,le)|0,m=m+Math.imul(Ne,Ae)|0,v=v+Math.imul(Ne,ve)|0,v=v+Math.imul(ce,Ae)|0,A=A+Math.imul(ce,ve)|0,m=m+Math.imul(Re,nt)|0,v=v+Math.imul(Re,ye)|0,v=v+Math.imul(ae,nt)|0,A=A+Math.imul(ae,ye)|0,m=m+Math.imul(Ue,xe)|0,v=v+Math.imul(Ue,Ye)|0,v=v+Math.imul(he,xe)|0,A=A+Math.imul(he,Ye)|0;var Wt=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(Wt>>>26)|0,Wt&=67108863,m=Math.imul(He,et),v=Math.imul(He,be),v=v+Math.imul(pe,et)|0,A=Math.imul(pe,be),m=m+Math.imul(Ce,rt)|0,v=v+Math.imul(Ce,le)|0,v=v+Math.imul(ie,rt)|0,A=A+Math.imul(ie,le)|0,m=m+Math.imul(Fe,Ae)|0,v=v+Math.imul(Fe,ve)|0,v=v+Math.imul(oe,Ae)|0,A=A+Math.imul(oe,ve)|0,m=m+Math.imul(Ne,nt)|0,v=v+Math.imul(Ne,ye)|0,v=v+Math.imul(ce,nt)|0,A=A+Math.imul(ce,ye)|0,m=m+Math.imul(Re,xe)|0,v=v+Math.imul(Re,Ye)|0,v=v+Math.imul(ae,xe)|0,A=A+Math.imul(ae,Ye)|0;var Oi=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(Oi>>>26)|0,Oi&=67108863,m=Math.imul(He,rt),v=Math.imul(He,le),v=v+Math.imul(pe,rt)|0,A=Math.imul(pe,le),m=m+Math.imul(Ce,Ae)|0,v=v+Math.imul(Ce,ve)|0,v=v+Math.imul(ie,Ae)|0,A=A+Math.imul(ie,ve)|0,m=m+Math.imul(Fe,nt)|0,v=v+Math.imul(Fe,ye)|0,v=v+Math.imul(oe,nt)|0,A=A+Math.imul(oe,ye)|0,m=m+Math.imul(Ne,xe)|0,v=v+Math.imul(Ne,Ye)|0,v=v+Math.imul(ce,xe)|0,A=A+Math.imul(ce,Ye)|0;var Pi=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(Pi>>>26)|0,Pi&=67108863,m=Math.imul(He,Ae),v=Math.imul(He,ve),v=v+Math.imul(pe,Ae)|0,A=Math.imul(pe,ve),m=m+Math.imul(Ce,nt)|0,v=v+Math.imul(Ce,ye)|0,v=v+Math.imul(ie,nt)|0,A=A+Math.imul(ie,ye)|0,m=m+Math.imul(Fe,xe)|0,v=v+Math.imul(Fe,Ye)|0,v=v+Math.imul(oe,xe)|0,A=A+Math.imul(oe,Ye)|0;var Ri=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(Ri>>>26)|0,Ri&=67108863,m=Math.imul(He,nt),v=Math.imul(He,ye),v=v+Math.imul(pe,nt)|0,A=Math.imul(pe,ye),m=m+Math.imul(Ce,xe)|0,v=v+Math.imul(Ce,Ye)|0,v=v+Math.imul(ie,xe)|0,A=A+Math.imul(ie,Ye)|0;var Vs=(d+m|0)+((v&8191)<<13)|0;d=(A+(v>>>13)|0)+(Vs>>>26)|0,Vs&=67108863,m=Math.imul(He,xe),v=Math.imul(He,Ye),v=v+Math.imul(pe,xe)|0,A=Math.imul(pe,Ye);var Hs=(d+m|0)+((v&8191)<<13)|0;return d=(A+(v>>>13)|0)+(Hs>>>26)|0,Hs&=67108863,w[0]=ar,w[1]=fr,w[2]=cr,w[3]=hr,w[4]=wt,w[5]=xi,w[6]=Ei,w[7]=Si,w[8]=Mi,w[9]=Ii,w[10]=Pr,w[11]=Ai,w[12]=Di,w[13]=Wt,w[14]=Oi,w[15]=Pi,w[16]=Ri,w[17]=Vs,w[18]=Hs,d!==0&&(w[19]=d,b.length++),b};Math.imul||(T=$);function C(p,f,u){u.negative=f.negative^p.negative,u.length=p.length+f.length;for(var b=0,_=0,E=0;E<u.length-1;E++){var w=_;_=0;for(var d=b&67108863,m=Math.min(E,f.length-1),v=Math.max(0,E-p.length+1);v<=m;v++){var A=E-v,U=p.words[A]|0,x=f.words[v]|0,N=U*x,B=N&67108863;w=w+(N/67108864|0)|0,B=B+d|0,d=B&67108863,w=w+(B>>>26)|0,_+=w>>>26,w&=67108863}u.words[E]=d,b=w,w=_}return b!==0?u.words[E]=b:u.length--,u._strip()}function L(p,f,u){return C(p,f,u)}s.prototype.mulTo=function(f,u){var b,_=this.length+f.length;return this.length===10&&f.length===10?b=T(this,f,u):_<63?b=$(this,f,u):_<1024?b=C(this,f,u):b=L(this,f,u),b},s.prototype.mul=function(f){var u=new s(null);return u.words=new Array(this.length+f.length),this.mulTo(f,u)},s.prototype.mulf=function(f){var u=new s(null);return u.words=new Array(this.length+f.length),L(this,f,u)},s.prototype.imul=function(f){return this.clone().mulTo(f,this)},s.prototype.imuln=function(f){var u=f<0;u&&(f=-f),i(typeof f=="number"),i(f<67108864);for(var b=0,_=0;_<this.length;_++){var E=(this.words[_]|0)*f,w=(E&67108863)+(b&67108863);b>>=26,b+=E/67108864|0,b+=w>>>26,this.words[_]=w&67108863}return b!==0&&(this.words[_]=b,this.length++),u?this.ineg():this},s.prototype.muln=function(f){return this.clone().imuln(f)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(f){var u=R(f);if(u.length===0)return new s(1);for(var b=this,_=0;_<u.length&&u[_]===0;_++,b=b.sqr());if(++_<u.length)for(var E=b.sqr();_<u.length;_++,E=E.sqr())u[_]!==0&&(b=b.mul(E));return b},s.prototype.iushln=function(f){i(typeof f=="number"&&f>=0);var u=f%26,b=(f-u)/26,_=67108863>>>26-u<<26-u,E;if(u!==0){var w=0;for(E=0;E<this.length;E++){var d=this.words[E]&_,m=(this.words[E]|0)-d<<u;this.words[E]=m|w,w=d>>>26-u}w&&(this.words[E]=w,this.length++)}if(b!==0){for(E=this.length-1;E>=0;E--)this.words[E+b]=this.words[E];for(E=0;E<b;E++)this.words[E]=0;this.length+=b}return this._strip()},s.prototype.ishln=function(f){return i(this.negative===0),this.iushln(f)},s.prototype.iushrn=function(f,u,b){i(typeof f=="number"&&f>=0);var _;u?_=(u-u%26)/26:_=0;var E=f%26,w=Math.min((f-E)/26,this.length),d=67108863^67108863>>>E<<E,m=b;if(_-=w,_=Math.max(0,_),m){for(var v=0;v<w;v++)m.words[v]=this.words[v];m.length=w}if(w!==0)if(this.length>w)for(this.length-=w,v=0;v<this.length;v++)this.words[v]=this.words[v+w];else this.words[0]=0,this.length=1;var A=0;for(v=this.length-1;v>=0&&(A!==0||v>=_);v--){var U=this.words[v]|0;this.words[v]=A<<26-E|U>>>E,A=U&d}return m&&A!==0&&(m.words[m.length++]=A),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(f,u,b){return i(this.negative===0),this.iushrn(f,u,b)},s.prototype.shln=function(f){return this.clone().ishln(f)},s.prototype.ushln=function(f){return this.clone().iushln(f)},s.prototype.shrn=function(f){return this.clone().ishrn(f)},s.prototype.ushrn=function(f){return this.clone().iushrn(f)},s.prototype.testn=function(f){i(typeof f=="number"&&f>=0);var u=f%26,b=(f-u)/26,_=1<<u;if(this.length<=b)return!1;var E=this.words[b];return!!(E&_)},s.prototype.imaskn=function(f){i(typeof f=="number"&&f>=0);var u=f%26,b=(f-u)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=b)return this;if(u!==0&&b++,this.length=Math.min(b,this.length),u!==0){var _=67108863^67108863>>>u<<u;this.words[this.length-1]&=_}return this._strip()},s.prototype.maskn=function(f){return this.clone().imaskn(f)},s.prototype.iaddn=function(f){return i(typeof f=="number"),i(f<67108864),f<0?this.isubn(-f):this.negative!==0?this.length===1&&(this.words[0]|0)<=f?(this.words[0]=f-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(f),this.negative=1,this):this._iaddn(f)},s.prototype._iaddn=function(f){this.words[0]+=f;for(var u=0;u<this.length&&this.words[u]>=67108864;u++)this.words[u]-=67108864,u===this.length-1?this.words[u+1]=1:this.words[u+1]++;return this.length=Math.max(this.length,u+1),this},s.prototype.isubn=function(f){if(i(typeof f=="number"),i(f<67108864),f<0)return this.iaddn(-f);if(this.negative!==0)return this.negative=0,this.iaddn(f),this.negative=1,this;if(this.words[0]-=f,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var u=0;u<this.length&&this.words[u]<0;u++)this.words[u]+=67108864,this.words[u+1]-=1;return this._strip()},s.prototype.addn=function(f){return this.clone().iaddn(f)},s.prototype.subn=function(f){return this.clone().isubn(f)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(f,u,b){var _=f.length+b,E;this._expand(_);var w,d=0;for(E=0;E<f.length;E++){w=(this.words[E+b]|0)+d;var m=(f.words[E]|0)*u;w-=m&67108863,d=(w>>26)-(m/67108864|0),this.words[E+b]=w&67108863}for(;E<this.length-b;E++)w=(this.words[E+b]|0)+d,d=w>>26,this.words[E+b]=w&67108863;if(d===0)return this._strip();for(i(d===-1),d=0,E=0;E<this.length;E++)w=-(this.words[E]|0)+d,d=w>>26,this.words[E]=w&67108863;return this.negative=1,this._strip()},s.prototype._wordDiv=function(f,u){var b=this.length-f.length,_=this.clone(),E=f,w=E.words[E.length-1]|0,d=this._countBits(w);b=26-d,b!==0&&(E=E.ushln(b),_.iushln(b),w=E.words[E.length-1]|0);var m=_.length-E.length,v;if(u!=="mod"){v=new s(null),v.length=m+1,v.words=new Array(v.length);for(var A=0;A<v.length;A++)v.words[A]=0}var U=_.clone()._ishlnsubmul(E,1,m);U.negative===0&&(_=U,v&&(v.words[m]=1));for(var x=m-1;x>=0;x--){var N=(_.words[E.length+x]|0)*67108864+(_.words[E.length+x-1]|0);for(N=Math.min(N/w|0,67108863),_._ishlnsubmul(E,N,x);_.negative!==0;)N--,_.negative=0,_._ishlnsubmul(E,1,x),_.isZero()||(_.negative^=1);v&&(v.words[x]=N)}return v&&v._strip(),_._strip(),u!=="div"&&b!==0&&_.iushrn(b),{div:v||null,mod:_}},s.prototype.divmod=function(f,u,b){if(i(!f.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var _,E,w;return this.negative!==0&&f.negative===0?(w=this.neg().divmod(f,u),u!=="mod"&&(_=w.div.neg()),u!=="div"&&(E=w.mod.neg(),b&&E.negative!==0&&E.iadd(f)),{div:_,mod:E}):this.negative===0&&f.negative!==0?(w=this.divmod(f.neg(),u),u!=="mod"&&(_=w.div.neg()),{div:_,mod:w.mod}):this.negative&f.negative?(w=this.neg().divmod(f.neg(),u),u!=="div"&&(E=w.mod.neg(),b&&E.negative!==0&&E.isub(f)),{div:w.div,mod:E}):f.length>this.length||this.cmp(f)<0?{div:new s(0),mod:this}:f.length===1?u==="div"?{div:this.divn(f.words[0]),mod:null}:u==="mod"?{div:null,mod:new s(this.modrn(f.words[0]))}:{div:this.divn(f.words[0]),mod:new s(this.modrn(f.words[0]))}:this._wordDiv(f,u)},s.prototype.div=function(f){return this.divmod(f,"div",!1).div},s.prototype.mod=function(f){return this.divmod(f,"mod",!1).mod},s.prototype.umod=function(f){return this.divmod(f,"mod",!0).mod},s.prototype.divRound=function(f){var u=this.divmod(f);if(u.mod.isZero())return u.div;var b=u.div.negative!==0?u.mod.isub(f):u.mod,_=f.ushrn(1),E=f.andln(1),w=b.cmp(_);return w<0||E===1&&w===0?u.div:u.div.negative!==0?u.div.isubn(1):u.div.iaddn(1)},s.prototype.modrn=function(f){var u=f<0;u&&(f=-f),i(f<=67108863);for(var b=(1<<26)%f,_=0,E=this.length-1;E>=0;E--)_=(b*_+(this.words[E]|0))%f;return u?-_:_},s.prototype.modn=function(f){return this.modrn(f)},s.prototype.idivn=function(f){var u=f<0;u&&(f=-f),i(f<=67108863);for(var b=0,_=this.length-1;_>=0;_--){var E=(this.words[_]|0)+b*67108864;this.words[_]=E/f|0,b=E%f}return this._strip(),u?this.ineg():this},s.prototype.divn=function(f){return this.clone().idivn(f)},s.prototype.egcd=function(f){i(f.negative===0),i(!f.isZero());var u=this,b=f.clone();u.negative!==0?u=u.umod(f):u=u.clone();for(var _=new s(1),E=new s(0),w=new s(0),d=new s(1),m=0;u.isEven()&&b.isEven();)u.iushrn(1),b.iushrn(1),++m;for(var v=b.clone(),A=u.clone();!u.isZero();){for(var U=0,x=1;!(u.words[0]&x)&&U<26;++U,x<<=1);if(U>0)for(u.iushrn(U);U-- >0;)(_.isOdd()||E.isOdd())&&(_.iadd(v),E.isub(A)),_.iushrn(1),E.iushrn(1);for(var N=0,B=1;!(b.words[0]&B)&&N<26;++N,B<<=1);if(N>0)for(b.iushrn(N);N-- >0;)(w.isOdd()||d.isOdd())&&(w.iadd(v),d.isub(A)),w.iushrn(1),d.iushrn(1);u.cmp(b)>=0?(u.isub(b),_.isub(w),E.isub(d)):(b.isub(u),w.isub(_),d.isub(E))}return{a:w,b:d,gcd:b.iushln(m)}},s.prototype._invmp=function(f){i(f.negative===0),i(!f.isZero());var u=this,b=f.clone();u.negative!==0?u=u.umod(f):u=u.clone();for(var _=new s(1),E=new s(0),w=b.clone();u.cmpn(1)>0&&b.cmpn(1)>0;){for(var d=0,m=1;!(u.words[0]&m)&&d<26;++d,m<<=1);if(d>0)for(u.iushrn(d);d-- >0;)_.isOdd()&&_.iadd(w),_.iushrn(1);for(var v=0,A=1;!(b.words[0]&A)&&v<26;++v,A<<=1);if(v>0)for(b.iushrn(v);v-- >0;)E.isOdd()&&E.iadd(w),E.iushrn(1);u.cmp(b)>=0?(u.isub(b),_.isub(E)):(b.isub(u),E.isub(_))}var U;return u.cmpn(1)===0?U=_:U=E,U.cmpn(0)<0&&U.iadd(f),U},s.prototype.gcd=function(f){if(this.isZero())return f.abs();if(f.isZero())return this.abs();var u=this.clone(),b=f.clone();u.negative=0,b.negative=0;for(var _=0;u.isEven()&&b.isEven();_++)u.iushrn(1),b.iushrn(1);do{for(;u.isEven();)u.iushrn(1);for(;b.isEven();)b.iushrn(1);var E=u.cmp(b);if(E<0){var w=u;u=b,b=w}else if(E===0||b.cmpn(1)===0)break;u.isub(b)}while(!0);return b.iushln(_)},s.prototype.invm=function(f){return this.egcd(f).a.umod(f)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(f){return this.words[0]&f},s.prototype.bincn=function(f){i(typeof f=="number");var u=f%26,b=(f-u)/26,_=1<<u;if(this.length<=b)return this._expand(b+1),this.words[b]|=_,this;for(var E=_,w=b;E!==0&&w<this.length;w++){var d=this.words[w]|0;d+=E,E=d>>>26,d&=67108863,this.words[w]=d}return E!==0&&(this.words[w]=E,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(f){var u=f<0;if(this.negative!==0&&!u)return-1;if(this.negative===0&&u)return 1;this._strip();var b;if(this.length>1)b=1;else{u&&(f=-f),i(f<=67108863,"Number is too big");var _=this.words[0]|0;b=_===f?0:_<f?-1:1}return this.negative!==0?-b|0:b},s.prototype.cmp=function(f){if(this.negative!==0&&f.negative===0)return-1;if(this.negative===0&&f.negative!==0)return 1;var u=this.ucmp(f);return this.negative!==0?-u|0:u},s.prototype.ucmp=function(f){if(this.length>f.length)return 1;if(this.length<f.length)return-1;for(var u=0,b=this.length-1;b>=0;b--){var _=this.words[b]|0,E=f.words[b]|0;if(_!==E){_<E?u=-1:_>E&&(u=1);break}}return u},s.prototype.gtn=function(f){return this.cmpn(f)===1},s.prototype.gt=function(f){return this.cmp(f)===1},s.prototype.gten=function(f){return this.cmpn(f)>=0},s.prototype.gte=function(f){return this.cmp(f)>=0},s.prototype.ltn=function(f){return this.cmpn(f)===-1},s.prototype.lt=function(f){return this.cmp(f)===-1},s.prototype.lten=function(f){return this.cmpn(f)<=0},s.prototype.lte=function(f){return this.cmp(f)<=0},s.prototype.eqn=function(f){return this.cmpn(f)===0},s.prototype.eq=function(f){return this.cmp(f)===0},s.red=function(f){return new O(f)},s.prototype.toRed=function(f){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),f.convertTo(this)._forceRed(f)},s.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(f){return this.red=f,this},s.prototype.forceRed=function(f){return i(!this.red,"Already a number in reduction context"),this._forceRed(f)},s.prototype.redAdd=function(f){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,f)},s.prototype.redIAdd=function(f){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,f)},s.prototype.redSub=function(f){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,f)},s.prototype.redISub=function(f){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,f)},s.prototype.redShl=function(f){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,f)},s.prototype.redMul=function(f){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,f),this.red.mul(this,f)},s.prototype.redIMul=function(f){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,f),this.red.imul(this,f)},s.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(f){return i(this.red&&!f.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,f)};var k={k256:null,p224:null,p192:null,p25519:null};function j(p,f){this.name=p,this.p=new s(f,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}j.prototype._tmp=function(){var f=new s(null);return f.words=new Array(Math.ceil(this.n/13)),f},j.prototype.ireduce=function(f){var u=f,b;do this.split(u,this.tmp),u=this.imulK(u),u=u.iadd(this.tmp),b=u.bitLength();while(b>this.n);var _=b<this.n?-1:u.ucmp(this.p);return _===0?(u.words[0]=0,u.length=1):_>0?u.isub(this.p):u.strip!==void 0?u.strip():u._strip(),u},j.prototype.split=function(f,u){f.iushrn(this.n,0,u)},j.prototype.imulK=function(f){return f.imul(this.k)};function G(){j.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(G,j),G.prototype.split=function(f,u){for(var b=4194303,_=Math.min(f.length,9),E=0;E<_;E++)u.words[E]=f.words[E];if(u.length=_,f.length<=9){f.words[0]=0,f.length=1;return}var w=f.words[9];for(u.words[u.length++]=w&b,E=10;E<f.length;E++){var d=f.words[E]|0;f.words[E-10]=(d&b)<<4|w>>>22,w=d}w>>>=22,f.words[E-10]=w,w===0&&f.length>10?f.length-=10:f.length-=9},G.prototype.imulK=function(f){f.words[f.length]=0,f.words[f.length+1]=0,f.length+=2;for(var u=0,b=0;b<f.length;b++){var _=f.words[b]|0;u+=_*977,f.words[b]=u&67108863,u=_*64+(u/67108864|0)}return f.words[f.length-1]===0&&(f.length--,f.words[f.length-1]===0&&f.length--),f};function K(){j.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(K,j);function V(){j.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(V,j);function re(){j.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(re,j),re.prototype.imulK=function(f){for(var u=0,b=0;b<f.length;b++){var _=(f.words[b]|0)*19+u,E=_&67108863;_>>>=26,f.words[b]=E,u=_}return u!==0&&(f.words[f.length++]=u),f},s._prime=function(f){if(k[f])return k[f];var u;if(f==="k256")u=new G;else if(f==="p224")u=new K;else if(f==="p192")u=new V;else if(f==="p25519")u=new re;else throw new Error("Unknown prime "+f);return k[f]=u,u};function O(p){if(typeof p=="string"){var f=s._prime(p);this.m=f.p,this.prime=f}else i(p.gtn(1),"modulus must be greater than 1"),this.m=p,this.prime=null}O.prototype._verify1=function(f){i(f.negative===0,"red works only with positives"),i(f.red,"red works only with red numbers")},O.prototype._verify2=function(f,u){i((f.negative|u.negative)===0,"red works only with positives"),i(f.red&&f.red===u.red,"red works only with red numbers")},O.prototype.imod=function(f){return this.prime?this.prime.ireduce(f)._forceRed(this):(l(f,f.umod(this.m)._forceRed(this)),f)},O.prototype.neg=function(f){return f.isZero()?f.clone():this.m.sub(f)._forceRed(this)},O.prototype.add=function(f,u){this._verify2(f,u);var b=f.add(u);return b.cmp(this.m)>=0&&b.isub(this.m),b._forceRed(this)},O.prototype.iadd=function(f,u){this._verify2(f,u);var b=f.iadd(u);return b.cmp(this.m)>=0&&b.isub(this.m),b},O.prototype.sub=function(f,u){this._verify2(f,u);var b=f.sub(u);return b.cmpn(0)<0&&b.iadd(this.m),b._forceRed(this)},O.prototype.isub=function(f,u){this._verify2(f,u);var b=f.isub(u);return b.cmpn(0)<0&&b.iadd(this.m),b},O.prototype.shl=function(f,u){return this._verify1(f),this.imod(f.ushln(u))},O.prototype.imul=function(f,u){return this._verify2(f,u),this.imod(f.imul(u))},O.prototype.mul=function(f,u){return this._verify2(f,u),this.imod(f.mul(u))},O.prototype.isqr=function(f){return this.imul(f,f.clone())},O.prototype.sqr=function(f){return this.mul(f,f)},O.prototype.sqrt=function(f){if(f.isZero())return f.clone();var u=this.m.andln(3);if(i(u%2===1),u===3){var b=this.m.add(new s(1)).iushrn(2);return this.pow(f,b)}for(var _=this.m.subn(1),E=0;!_.isZero()&&_.andln(1)===0;)E++,_.iushrn(1);i(!_.isZero());var w=new s(1).toRed(this),d=w.redNeg(),m=this.m.subn(1).iushrn(1),v=this.m.bitLength();for(v=new s(2*v*v).toRed(this);this.pow(v,m).cmp(d)!==0;)v.redIAdd(d);for(var A=this.pow(v,_),U=this.pow(f,_.addn(1).iushrn(1)),x=this.pow(f,_),N=E;x.cmp(w)!==0;){for(var B=x,q=0;B.cmp(w)!==0;q++)B=B.redSqr();i(q<N);var z=this.pow(A,new s(1).iushln(N-q-1));U=U.redMul(z),A=z.redSqr(),x=x.redMul(A),N=q}return U},O.prototype.invm=function(f){var u=f._invmp(this.m);return u.negative!==0?(u.negative=0,this.imod(u).redNeg()):this.imod(u)},O.prototype.pow=function(f,u){if(u.isZero())return new s(1).toRed(this);if(u.cmpn(1)===0)return f.clone();var b=4,_=new Array(1<<b);_[0]=new s(1).toRed(this),_[1]=f;for(var E=2;E<_.length;E++)_[E]=this.mul(_[E-1],f);var w=_[0],d=0,m=0,v=u.bitLength()%26;for(v===0&&(v=26),E=u.length-1;E>=0;E--){for(var A=u.words[E],U=v-1;U>=0;U--){var x=A>>U&1;if(w!==_[0]&&(w=this.sqr(w)),x===0&&d===0){m=0;continue}d<<=1,d|=x,m++,!(m!==b&&(E!==0||U!==0))&&(w=this.mul(w,_[d]),m=0,d=0)}v=26}return w},O.prototype.convertTo=function(f){var u=f.umod(this.m);return u===f?u.clone():u},O.prototype.convertFrom=function(f){var u=f.clone();return u.red=null,u},s.mont=function(f){return new g(f)};function g(p){O.call(this,p),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}n(g,O),g.prototype.convertTo=function(f){return this.imod(f.ushln(this.shift))},g.prototype.convertFrom=function(f){var u=this.imod(f.mul(this.rinv));return u.red=null,u},g.prototype.imul=function(f,u){if(f.isZero()||u.isZero())return f.words[0]=0,f.length=1,f;var b=f.imul(u),_=b.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),E=b.isub(_).iushrn(this.shift),w=E;return E.cmp(this.m)>=0?w=E.isub(this.m):E.cmpn(0)<0&&(w=E.iadd(this.m)),w._forceRed(this)},g.prototype.mul=function(f,u){if(f.isZero()||u.isZero())return new s(0)._forceRed(this);var b=f.mul(u),_=b.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),E=b.isub(_).iushrn(this.shift),w=E;return E.cmp(this.m)>=0?w=E.isub(this.m):E.cmpn(0)<0&&(w=E.iadd(this.m)),w._forceRed(this)},g.prototype.invm=function(f){var u=this.imod(f._invmp(this.m).mul(this.r2));return u._forceRed(this)}})(t,Nt)})(gu);var me=gu.exports;const bu="bignumber/5.7.0";var vo=me.BN;const hi=new Ee(bu),ef={},vu=9007199254740991;function qy(t){return t!=null&&(lt.isBigNumber(t)||typeof t=="number"&&t%1===0||typeof t=="string"&&!!t.match(/^-?[0-9]+$/)||ur(t)||typeof t=="bigint"||Nn(t))}let yu=!1;class lt{constructor(e,r){e!==ef&&hi.throwError("cannot call constructor directly; use BigNumber.from",Ee.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=r,this._isBigNumber=!0,Object.freeze(this)}fromTwos(e){return ir(Me(this).fromTwos(e))}toTwos(e){return ir(Me(this).toTwos(e))}abs(){return this._hex[0]==="-"?lt.from(this._hex.substring(1)):this}add(e){return ir(Me(this).add(Me(e)))}sub(e){return ir(Me(this).sub(Me(e)))}div(e){return lt.from(e).isZero()&&mr("division-by-zero","div"),ir(Me(this).div(Me(e)))}mul(e){return ir(Me(this).mul(Me(e)))}mod(e){const r=Me(e);return r.isNeg()&&mr("division-by-zero","mod"),ir(Me(this).umod(r))}pow(e){const r=Me(e);return r.isNeg()&&mr("negative-power","pow"),ir(Me(this).pow(r))}and(e){const r=Me(e);return(this.isNegative()||r.isNeg())&&mr("unbound-bitwise-result","and"),ir(Me(this).and(r))}or(e){const r=Me(e);return(this.isNegative()||r.isNeg())&&mr("unbound-bitwise-result","or"),ir(Me(this).or(r))}xor(e){const r=Me(e);return(this.isNegative()||r.isNeg())&&mr("unbound-bitwise-result","xor"),ir(Me(this).xor(r))}mask(e){return(this.isNegative()||e<0)&&mr("negative-width","mask"),ir(Me(this).maskn(e))}shl(e){return(this.isNegative()||e<0)&&mr("negative-width","shl"),ir(Me(this).shln(e))}shr(e){return(this.isNegative()||e<0)&&mr("negative-width","shr"),ir(Me(this).shrn(e))}eq(e){return Me(this).eq(Me(e))}lt(e){return Me(this).lt(Me(e))}lte(e){return Me(this).lte(Me(e))}gt(e){return Me(this).gt(Me(e))}gte(e){return Me(this).gte(Me(e))}isNegative(){return this._hex[0]==="-"}isZero(){return Me(this).isZero()}toNumber(){try{return Me(this).toNumber()}catch{mr("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch{}return hi.throwError("this platform does not support BigInt",Ee.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(arguments[0]===10?yu||(yu=!0,hi.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):arguments[0]===16?hi.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",Ee.errors.UNEXPECTED_ARGUMENT,{}):hi.throwError("BigNumber.toString does not accept parameters",Ee.errors.UNEXPECTED_ARGUMENT,{})),Me(this).toString(10)}toHexString(){return this._hex}toJSON(e){return{type:"BigNumber",hex:this.toHexString()}}static from(e){if(e instanceof lt)return e;if(typeof e=="string")return e.match(/^-?0x[0-9a-f]+$/i)?new lt(ef,ps(e)):e.match(/^-?[0-9]+$/)?new lt(ef,ps(new vo(e))):hi.throwArgumentError("invalid BigNumber string","value",e);if(typeof e=="number")return e%1&&mr("underflow","BigNumber.from",e),(e>=vu||e<=-vu)&&mr("overflow","BigNumber.from",e),lt.from(String(e));const r=e;if(typeof r=="bigint")return lt.from(r.toString());if(Nn(r))return lt.from(Yt(r));if(r)if(r.toHexString){const i=r.toHexString();if(typeof i=="string")return lt.from(i)}else{let i=r._hex;if(i==null&&r.type==="BigNumber"&&(i=r.hex),typeof i=="string"&&(ur(i)||i[0]==="-"&&ur(i.substring(1))))return lt.from(i)}return hi.throwArgumentError("invalid BigNumber value","value",e)}static isBigNumber(e){return!!(e&&e._isBigNumber)}}function ps(t){if(typeof t!="string")return ps(t.toString(16));if(t[0]==="-")return t=t.substring(1),t[0]==="-"&&hi.throwArgumentError("invalid hex","value",t),t=ps(t),t==="0x00"?t:"-"+t;if(t.substring(0,2)!=="0x"&&(t="0x"+t),t==="0x")return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&t.substring(0,4)==="0x00";)t="0x"+t.substring(4);return t}function ir(t){return lt.from(ps(t))}function Me(t){const e=lt.from(t).toHexString();return e[0]==="-"?new vo("-"+e.substring(3),16):new vo(e.substring(2),16)}function mr(t,e,r){const i={fault:t,operation:e};return r!=null&&(i.value=r),hi.throwError(t,Ee.errors.NUMERIC_FAULT,i)}function Uy(t){return new vo(t,36).toString(16)}const Xt=new Ee(bu),gs={},mu=lt.from(0),wu=lt.from(-1);function _u(t,e,r,i){const n={fault:e,operation:r};return i!==void 0&&(n.value=i),Xt.throwError(t,Ee.errors.NUMERIC_FAULT,n)}let bs="0";for(;bs.length<256;)bs+=bs;function tf(t){if(typeof t!="number")try{t=lt.from(t).toNumber()}catch{}return typeof t=="number"&&t>=0&&t<=256&&!(t%1)?"1"+bs.substring(0,t):Xt.throwArgumentError("invalid decimal size","decimals",t)}function rf(t,e){e==null&&(e=0);const r=tf(e);t=lt.from(t);const i=t.lt(mu);i&&(t=t.mul(wu));let n=t.mod(r).toString();for(;n.length<r.length-1;)n="0"+n;n=n.match(/^([0-9]*[1-9]|0)(0*)/)[1];const s=t.div(r).toString();return r.length===1?t=s:t=s+"."+n,i&&(t="-"+t),t}function ui(t,e){e==null&&(e=0);const r=tf(e);(typeof t!="string"||!t.match(/^-?[0-9.]+$/))&&Xt.throwArgumentError("invalid decimal value","value",t);const i=t.substring(0,1)==="-";i&&(t=t.substring(1)),t==="."&&Xt.throwArgumentError("missing value","value",t);const n=t.split(".");n.length>2&&Xt.throwArgumentError("too many decimal points","value",t);let s=n[0],o=n[1];for(s||(s="0"),o||(o="0");o[o.length-1]==="0";)o=o.substring(0,o.length-1);for(o.length>r.length-1&&_u("fractional component exceeds decimals","underflow","parseFixed"),o===""&&(o="0");o.length<r.length-1;)o+="0";const a=lt.from(s),c=lt.from(o);let h=a.mul(r).add(c);return i&&(h=h.mul(wu)),h}class Tn{constructor(e,r,i,n){e!==gs&&Xt.throwError("cannot use FixedFormat constructor; use FixedFormat.from",Ee.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.signed=r,this.width=i,this.decimals=n,this.name=(r?"":"u")+"fixed"+String(i)+"x"+String(n),this._multiplier=tf(n),Object.freeze(this)}static from(e){if(e instanceof Tn)return e;typeof e=="number"&&(e=`fixed128x${e}`);let r=!0,i=128,n=18;if(typeof e=="string"){if(e!=="fixed")if(e==="ufixed")r=!1;else{const s=e.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);s||Xt.throwArgumentError("invalid fixed format","format",e),r=s[1]!=="u",i=parseInt(s[2]),n=parseInt(s[3])}}else if(e){const s=(o,a,c)=>e[o]==null?c:(typeof e[o]!==a&&Xt.throwArgumentError("invalid fixed format ("+o+" not "+a+")","format."+o,e[o]),e[o]);r=s("signed","boolean",r),i=s("width","number",i),n=s("decimals","number",n)}return i%8&&Xt.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",i),n>80&&Xt.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",n),new Tn(gs,r,i,n)}}class Ft{constructor(e,r,i,n){e!==gs&&Xt.throwError("cannot use FixedNumber constructor; use FixedNumber.from",Ee.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=n,this._hex=r,this._value=i,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(e){this.format.name!==e.format.name&&Xt.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)}addUnsafe(e){this._checkFormat(e);const r=ui(this._value,this.format.decimals),i=ui(e._value,e.format.decimals);return Ft.fromValue(r.add(i),this.format.decimals,this.format)}subUnsafe(e){this._checkFormat(e);const r=ui(this._value,this.format.decimals),i=ui(e._value,e.format.decimals);return Ft.fromValue(r.sub(i),this.format.decimals,this.format)}mulUnsafe(e){this._checkFormat(e);const r=ui(this._value,this.format.decimals),i=ui(e._value,e.format.decimals);return Ft.fromValue(r.mul(i).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(e){this._checkFormat(e);const r=ui(this._value,this.format.decimals),i=ui(e._value,e.format.decimals);return Ft.fromValue(r.mul(this.format._multiplier).div(i),this.format.decimals,this.format)}floor(){const e=this.toString().split(".");e.length===1&&e.push("0");let r=Ft.from(e[0],this.format);const i=!e[1].match(/^(0*)$/);return this.isNegative()&&i&&(r=r.subUnsafe(xu.toFormat(r.format))),r}ceiling(){const e=this.toString().split(".");e.length===1&&e.push("0");let r=Ft.from(e[0],this.format);const i=!e[1].match(/^(0*)$/);return!this.isNegative()&&i&&(r=r.addUnsafe(xu.toFormat(r.format))),r}round(e){e==null&&(e=0);const r=this.toString().split(".");if(r.length===1&&r.push("0"),(e<0||e>80||e%1)&&Xt.throwArgumentError("invalid decimal count","decimals",e),r[1].length<=e)return this;const i=Ft.from("1"+bs.substring(0,e),this.format),n=zy.toFormat(this.format);return this.mulUnsafe(i).addUnsafe(n).floor().divUnsafe(i)}isZero(){return this._value==="0.0"||this._value==="0"}isNegative(){return this._value[0]==="-"}toString(){return this._value}toHexString(e){if(e==null)return this._hex;e%8&&Xt.throwArgumentError("invalid byte width","width",e);const r=lt.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString();return Fi(r,e/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return Ft.fromString(this._value,e)}static fromValue(e,r,i){return i==null&&r!=null&&!qy(r)&&(i=r,r=null),r==null&&(r=0),i==null&&(i="fixed"),Ft.fromString(rf(e,r),Tn.from(i))}static fromString(e,r){r==null&&(r="fixed");const i=Tn.from(r),n=ui(e,i.decimals);!i.signed&&n.lt(mu)&&_u("unsigned value cannot be negative","overflow","value",e);let s=null;i.signed?s=n.toTwos(i.width).toHexString():(s=n.toHexString(),s=Fi(s,i.width/8));const o=rf(n,i.decimals);return new Ft(gs,s,o,i)}static fromBytes(e,r){r==null&&(r="fixed");const i=Tn.from(r);if(xt(e).length>i.width/8)throw new Error("overflow");let n=lt.from(e);i.signed&&(n=n.fromTwos(i.width));const s=n.toTwos((i.signed?0:1)+i.width).toHexString(),o=rf(n,i.decimals);return new Ft(gs,s,o,i)}static from(e,r){if(typeof e=="string")return Ft.fromString(e,r);if(Nn(e))return Ft.fromBytes(e,r);try{return Ft.fromValue(e,0,r)}catch(i){if(i.code!==Ee.errors.INVALID_ARGUMENT)throw i}return Xt.throwArgumentError("invalid FixedNumber value","value",e)}static isFixedNumber(e){return!!(e&&e._isFixedNumber)}}const xu=Ft.from(1),zy=Ft.from("0.5");var Eu={exports:{}};/**
15
- * [js-sha3]{@link https://github.com/emn178/js-sha3}
16
- *
17
- * @version 0.8.0
18
- * @author Chen, Yi-Cyuan [emn178@gmail.com]
19
- * @copyright Chen, Yi-Cyuan 2015-2018
20
- * @license MIT
21
- */(function(t){(function(){var e="input is invalid type",r="finalize already called",i=typeof window=="object",n=i?window:{};n.JS_SHA3_NO_WINDOW&&(i=!1);var s=!i&&typeof self=="object",o=!n.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;o?n=Nt:s&&(n=self);var a=!n.JS_SHA3_NO_COMMON_JS&&!0&&t.exports,c=!n.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",h="0123456789abcdef".split(""),l=[31,7936,2031616,520093696],y=[4,1024,262144,67108864],M=[1,256,65536,16777216],I=[6,1536,393216,100663296],S=[0,8,16,24],D=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],R=[224,256,384,512],$=[128,256],T=["hex","buffer","arrayBuffer","array","digest"],C={128:168,256:136};(n.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(x){return Object.prototype.toString.call(x)==="[object Array]"}),c&&(n.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(x){return typeof x=="object"&&x.buffer&&x.buffer.constructor===ArrayBuffer});for(var L=function(x,N,B){return function(q){return new v(x,N,x).update(q)[B]()}},k=function(x,N,B){return function(q,z){return new v(x,N,z).update(q)[B]()}},j=function(x,N,B){return function(q,z,J,X){return f["cshake"+x].update(q,z,J,X)[B]()}},G=function(x,N,B){return function(q,z,J,X){return f["kmac"+x].update(q,z,J,X)[B]()}},K=function(x,N,B,q){for(var z=0;z<T.length;++z){var J=T[z];x[J]=N(B,q,J)}return x},V=function(x,N){var B=L(x,N,"hex");return B.create=function(){return new v(x,N,x)},B.update=function(q){return B.create().update(q)},K(B,L,x,N)},re=function(x,N){var B=k(x,N,"hex");return B.create=function(q){return new v(x,N,q)},B.update=function(q,z){return B.create(z).update(q)},K(B,k,x,N)},O=function(x,N){var B=C[x],q=j(x,N,"hex");return q.create=function(z,J,X){return!J&&!X?f["shake"+x].create(z):new v(x,N,z).bytepad([J,X],B)},q.update=function(z,J,X,W){return q.create(J,X,W).update(z)},K(q,j,x,N)},g=function(x,N){var B=C[x],q=G(x,N,"hex");return q.create=function(z,J,X){return new A(x,N,J).bytepad(["KMAC",X],B).bytepad([z],B)},q.update=function(z,J,X,W){return q.create(z,X,W).update(J)},K(q,G,x,N)},p=[{name:"keccak",padding:M,bits:R,createMethod:V},{name:"sha3",padding:I,bits:R,createMethod:V},{name:"shake",padding:l,bits:$,createMethod:re},{name:"cshake",padding:y,bits:$,createMethod:O},{name:"kmac",padding:y,bits:$,createMethod:g}],f={},u=[],b=0;b<p.length;++b)for(var _=p[b],E=_.bits,w=0;w<E.length;++w){var d=_.name+"_"+E[w];if(u.push(d),f[d]=_.createMethod(E[w],_.padding),_.name!=="sha3"){var m=_.name+E[w];u.push(m),f[m]=f[d]}}function v(x,N,B){this.blocks=[],this.s=[],this.padding=N,this.outputBits=B,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(x<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=B>>5,this.extraBytes=(B&31)>>3;for(var q=0;q<50;++q)this.s[q]=0}v.prototype.update=function(x){if(this.finalized)throw new Error(r);var N,B=typeof x;if(B!=="string"){if(B==="object"){if(x===null)throw new Error(e);if(c&&x.constructor===ArrayBuffer)x=new Uint8Array(x);else if(!Array.isArray(x)&&(!c||!ArrayBuffer.isView(x)))throw new Error(e)}else throw new Error(e);N=!0}for(var q=this.blocks,z=this.byteCount,J=x.length,X=this.blockCount,W=0,ne=this.s,Q,ee;W<J;){if(this.reset)for(this.reset=!1,q[0]=this.block,Q=1;Q<X+1;++Q)q[Q]=0;if(N)for(Q=this.start;W<J&&Q<z;++W)q[Q>>2]|=x[W]<<S[Q++&3];else for(Q=this.start;W<J&&Q<z;++W)ee=x.charCodeAt(W),ee<128?q[Q>>2]|=ee<<S[Q++&3]:ee<2048?(q[Q>>2]|=(192|ee>>6)<<S[Q++&3],q[Q>>2]|=(128|ee&63)<<S[Q++&3]):ee<55296||ee>=57344?(q[Q>>2]|=(224|ee>>12)<<S[Q++&3],q[Q>>2]|=(128|ee>>6&63)<<S[Q++&3],q[Q>>2]|=(128|ee&63)<<S[Q++&3]):(ee=65536+((ee&1023)<<10|x.charCodeAt(++W)&1023),q[Q>>2]|=(240|ee>>18)<<S[Q++&3],q[Q>>2]|=(128|ee>>12&63)<<S[Q++&3],q[Q>>2]|=(128|ee>>6&63)<<S[Q++&3],q[Q>>2]|=(128|ee&63)<<S[Q++&3]);if(this.lastByteIndex=Q,Q>=z){for(this.start=Q-z,this.block=q[X],Q=0;Q<X;++Q)ne[Q]^=q[Q];U(ne),this.reset=!0}else this.start=Q}return this},v.prototype.encode=function(x,N){var B=x&255,q=1,z=[B];for(x=x>>8,B=x&255;B>0;)z.unshift(B),x=x>>8,B=x&255,++q;return N?z.push(q):z.unshift(q),this.update(z),z.length},v.prototype.encodeString=function(x){var N,B=typeof x;if(B!=="string"){if(B==="object"){if(x===null)throw new Error(e);if(c&&x.constructor===ArrayBuffer)x=new Uint8Array(x);else if(!Array.isArray(x)&&(!c||!ArrayBuffer.isView(x)))throw new Error(e)}else throw new Error(e);N=!0}var q=0,z=x.length;if(N)q=z;else for(var J=0;J<x.length;++J){var X=x.charCodeAt(J);X<128?q+=1:X<2048?q+=2:X<55296||X>=57344?q+=3:(X=65536+((X&1023)<<10|x.charCodeAt(++J)&1023),q+=4)}return q+=this.encode(q*8),this.update(x),q},v.prototype.bytepad=function(x,N){for(var B=this.encode(N),q=0;q<x.length;++q)B+=this.encodeString(x[q]);var z=N-B%N,J=[];return J.length=z,this.update(J),this},v.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var x=this.blocks,N=this.lastByteIndex,B=this.blockCount,q=this.s;if(x[N>>2]|=this.padding[N&3],this.lastByteIndex===this.byteCount)for(x[0]=x[B],N=1;N<B+1;++N)x[N]=0;for(x[B-1]|=2147483648,N=0;N<B;++N)q[N]^=x[N];U(q)}},v.prototype.toString=v.prototype.hex=function(){this.finalize();for(var x=this.blockCount,N=this.s,B=this.outputBlocks,q=this.extraBytes,z=0,J=0,X="",W;J<B;){for(z=0;z<x&&J<B;++z,++J)W=N[z],X+=h[W>>4&15]+h[W&15]+h[W>>12&15]+h[W>>8&15]+h[W>>20&15]+h[W>>16&15]+h[W>>28&15]+h[W>>24&15];J%x===0&&(U(N),z=0)}return q&&(W=N[z],X+=h[W>>4&15]+h[W&15],q>1&&(X+=h[W>>12&15]+h[W>>8&15]),q>2&&(X+=h[W>>20&15]+h[W>>16&15])),X},v.prototype.arrayBuffer=function(){this.finalize();var x=this.blockCount,N=this.s,B=this.outputBlocks,q=this.extraBytes,z=0,J=0,X=this.outputBits>>3,W;q?W=new ArrayBuffer(B+1<<2):W=new ArrayBuffer(X);for(var ne=new Uint32Array(W);J<B;){for(z=0;z<x&&J<B;++z,++J)ne[J]=N[z];J%x===0&&U(N)}return q&&(ne[z]=N[z],W=W.slice(0,X)),W},v.prototype.buffer=v.prototype.arrayBuffer,v.prototype.digest=v.prototype.array=function(){this.finalize();for(var x=this.blockCount,N=this.s,B=this.outputBlocks,q=this.extraBytes,z=0,J=0,X=[],W,ne;J<B;){for(z=0;z<x&&J<B;++z,++J)W=J<<2,ne=N[z],X[W]=ne&255,X[W+1]=ne>>8&255,X[W+2]=ne>>16&255,X[W+3]=ne>>24&255;J%x===0&&U(N)}return q&&(W=J<<2,ne=N[z],X[W]=ne&255,q>1&&(X[W+1]=ne>>8&255),q>2&&(X[W+2]=ne>>16&255)),X};function A(x,N,B){v.call(this,x,N,B)}A.prototype=new v,A.prototype.finalize=function(){return this.encode(this.outputBits,!0),v.prototype.finalize.call(this)};var U=function(x){var N,B,q,z,J,X,W,ne,Q,ee,qe,Ue,he,Pe,Re,ae,$e,Ne,ce,Te,Fe,oe,De,Ce,ie,Ve,He,pe,We,Be,de,Ge,Xe,se,Je,Ze,ge,ze,Oe,ue,ke,je,fe,Qe,et,be,tt,rt,le,Ke,Ae,ve,it,nt,ye,st,xe,Ye,ar,fr,cr,hr,wt;for(q=0;q<48;q+=2)z=x[0]^x[10]^x[20]^x[30]^x[40],J=x[1]^x[11]^x[21]^x[31]^x[41],X=x[2]^x[12]^x[22]^x[32]^x[42],W=x[3]^x[13]^x[23]^x[33]^x[43],ne=x[4]^x[14]^x[24]^x[34]^x[44],Q=x[5]^x[15]^x[25]^x[35]^x[45],ee=x[6]^x[16]^x[26]^x[36]^x[46],qe=x[7]^x[17]^x[27]^x[37]^x[47],Ue=x[8]^x[18]^x[28]^x[38]^x[48],he=x[9]^x[19]^x[29]^x[39]^x[49],N=Ue^(X<<1|W>>>31),B=he^(W<<1|X>>>31),x[0]^=N,x[1]^=B,x[10]^=N,x[11]^=B,x[20]^=N,x[21]^=B,x[30]^=N,x[31]^=B,x[40]^=N,x[41]^=B,N=z^(ne<<1|Q>>>31),B=J^(Q<<1|ne>>>31),x[2]^=N,x[3]^=B,x[12]^=N,x[13]^=B,x[22]^=N,x[23]^=B,x[32]^=N,x[33]^=B,x[42]^=N,x[43]^=B,N=X^(ee<<1|qe>>>31),B=W^(qe<<1|ee>>>31),x[4]^=N,x[5]^=B,x[14]^=N,x[15]^=B,x[24]^=N,x[25]^=B,x[34]^=N,x[35]^=B,x[44]^=N,x[45]^=B,N=ne^(Ue<<1|he>>>31),B=Q^(he<<1|Ue>>>31),x[6]^=N,x[7]^=B,x[16]^=N,x[17]^=B,x[26]^=N,x[27]^=B,x[36]^=N,x[37]^=B,x[46]^=N,x[47]^=B,N=ee^(z<<1|J>>>31),B=qe^(J<<1|z>>>31),x[8]^=N,x[9]^=B,x[18]^=N,x[19]^=B,x[28]^=N,x[29]^=B,x[38]^=N,x[39]^=B,x[48]^=N,x[49]^=B,Pe=x[0],Re=x[1],be=x[11]<<4|x[10]>>>28,tt=x[10]<<4|x[11]>>>28,pe=x[20]<<3|x[21]>>>29,We=x[21]<<3|x[20]>>>29,fr=x[31]<<9|x[30]>>>23,cr=x[30]<<9|x[31]>>>23,je=x[40]<<18|x[41]>>>14,fe=x[41]<<18|x[40]>>>14,se=x[2]<<1|x[3]>>>31,Je=x[3]<<1|x[2]>>>31,ae=x[13]<<12|x[12]>>>20,$e=x[12]<<12|x[13]>>>20,rt=x[22]<<10|x[23]>>>22,le=x[23]<<10|x[22]>>>22,Be=x[33]<<13|x[32]>>>19,de=x[32]<<13|x[33]>>>19,hr=x[42]<<2|x[43]>>>30,wt=x[43]<<2|x[42]>>>30,nt=x[5]<<30|x[4]>>>2,ye=x[4]<<30|x[5]>>>2,Ze=x[14]<<6|x[15]>>>26,ge=x[15]<<6|x[14]>>>26,Ne=x[25]<<11|x[24]>>>21,ce=x[24]<<11|x[25]>>>21,Ke=x[34]<<15|x[35]>>>17,Ae=x[35]<<15|x[34]>>>17,Ge=x[45]<<29|x[44]>>>3,Xe=x[44]<<29|x[45]>>>3,Ce=x[6]<<28|x[7]>>>4,ie=x[7]<<28|x[6]>>>4,st=x[17]<<23|x[16]>>>9,xe=x[16]<<23|x[17]>>>9,ze=x[26]<<25|x[27]>>>7,Oe=x[27]<<25|x[26]>>>7,Te=x[36]<<21|x[37]>>>11,Fe=x[37]<<21|x[36]>>>11,ve=x[47]<<24|x[46]>>>8,it=x[46]<<24|x[47]>>>8,Qe=x[8]<<27|x[9]>>>5,et=x[9]<<27|x[8]>>>5,Ve=x[18]<<20|x[19]>>>12,He=x[19]<<20|x[18]>>>12,Ye=x[29]<<7|x[28]>>>25,ar=x[28]<<7|x[29]>>>25,ue=x[38]<<8|x[39]>>>24,ke=x[39]<<8|x[38]>>>24,oe=x[48]<<14|x[49]>>>18,De=x[49]<<14|x[48]>>>18,x[0]=Pe^~ae&Ne,x[1]=Re^~$e&ce,x[10]=Ce^~Ve&pe,x[11]=ie^~He&We,x[20]=se^~Ze&ze,x[21]=Je^~ge&Oe,x[30]=Qe^~be&rt,x[31]=et^~tt&le,x[40]=nt^~st&Ye,x[41]=ye^~xe&ar,x[2]=ae^~Ne&Te,x[3]=$e^~ce&Fe,x[12]=Ve^~pe&Be,x[13]=He^~We&de,x[22]=Ze^~ze&ue,x[23]=ge^~Oe&ke,x[32]=be^~rt&Ke,x[33]=tt^~le&Ae,x[42]=st^~Ye&fr,x[43]=xe^~ar&cr,x[4]=Ne^~Te&oe,x[5]=ce^~Fe&De,x[14]=pe^~Be&Ge,x[15]=We^~de&Xe,x[24]=ze^~ue&je,x[25]=Oe^~ke&fe,x[34]=rt^~Ke&ve,x[35]=le^~Ae&it,x[44]=Ye^~fr&hr,x[45]=ar^~cr&wt,x[6]=Te^~oe&Pe,x[7]=Fe^~De&Re,x[16]=Be^~Ge&Ce,x[17]=de^~Xe&ie,x[26]=ue^~je&se,x[27]=ke^~fe&Je,x[36]=Ke^~ve&Qe,x[37]=Ae^~it&et,x[46]=fr^~hr&nt,x[47]=cr^~wt&ye,x[8]=oe^~Pe&ae,x[9]=De^~Re&$e,x[18]=Ge^~Ce&Ve,x[19]=Xe^~ie&He,x[28]=je^~se&Ze,x[29]=fe^~Je&ge,x[38]=ve^~Qe&be,x[39]=it^~et&tt,x[48]=hr^~nt&st,x[49]=wt^~ye&xe,x[0]^=D[q],x[1]^=D[q+1]};if(a)t.exports=f;else for(b=0;b<u.length;++b)n[u[b]]=f[u[b]]})()})(Eu);var ky=Eu.exports;function Su(t){return"0x"+ky.keccak_256(xt(t))}const jy="rlp/5.7.0";new Ee(jy);const Ky="address/5.7.0",vs=new Ee(Ky);function Mu(t){ur(t,20)||vs.throwArgumentError("invalid address","address",t),t=t.toLowerCase();const e=t.substring(2).split(""),r=new Uint8Array(40);for(let n=0;n<40;n++)r[n]=e[n].charCodeAt(0);const i=xt(Su(r));for(let n=0;n<40;n+=2)i[n>>1]>>4>=8&&(e[n]=e[n].toUpperCase()),(i[n>>1]&15)>=8&&(e[n+1]=e[n+1].toUpperCase());return"0x"+e.join("")}const Vy=9007199254740991;function Hy(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10}const nf={};for(let t=0;t<10;t++)nf[String(t)]=String(t);for(let t=0;t<26;t++)nf[String.fromCharCode(65+t)]=String(10+t);const Iu=Math.floor(Hy(Vy));function Wy(t){t=t.toUpperCase(),t=t.substring(4)+t.substring(0,2)+"00";let e=t.split("").map(i=>nf[i]).join("");for(;e.length>=Iu;){let i=e.substring(0,Iu);e=parseInt(i,10)%97+e.substring(i.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}function Gy(t){let e=null;if(typeof t!="string"&&vs.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))t.substring(0,2)!=="0x"&&(t="0x"+t),e=Mu(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&vs.throwArgumentError("bad address checksum","address",t);else if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(t.substring(2,4)!==Wy(t)&&vs.throwArgumentError("bad icap checksum","address",t),e=Uy(t.substring(4));e.length<40;)e="0"+e;e=Mu("0x"+e)}else vs.throwArgumentError("invalid address","address",t);return e}const Jy="properties/5.7.0";new Ee(Jy);function ys(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}var dr={},Ie={},sn=Au;function Au(t,e){if(!t)throw new Error(e||"Assertion failed")}Au.equal=function(e,r,i){if(e!=r)throw new Error(i||"Assertion failed: "+e+" != "+r)};var Fn={exports:{}};typeof Object.create=="function"?Fn.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:Fn.exports=function(e,r){if(r){e.super_=r;var i=function(){};i.prototype=r.prototype,e.prototype=new i,e.prototype.constructor=e}};var Yy=sn,Xy=Fn.exports;Ie.inherits=Xy;function Zy(t,e){return(t.charCodeAt(e)&64512)!==55296||e<0||e+1>=t.length?!1:(t.charCodeAt(e+1)&64512)===56320}function Qy(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if(typeof t=="string")if(e){if(e==="hex")for(t=t.replace(/[^a-z0-9]+/ig,""),t.length%2!==0&&(t="0"+t),n=0;n<t.length;n+=2)r.push(parseInt(t[n]+t[n+1],16))}else for(var i=0,n=0;n<t.length;n++){var s=t.charCodeAt(n);s<128?r[i++]=s:s<2048?(r[i++]=s>>6|192,r[i++]=s&63|128):Zy(t,n)?(s=65536+((s&1023)<<10)+(t.charCodeAt(++n)&1023),r[i++]=s>>18|240,r[i++]=s>>12&63|128,r[i++]=s>>6&63|128,r[i++]=s&63|128):(r[i++]=s>>12|224,r[i++]=s>>6&63|128,r[i++]=s&63|128)}else for(n=0;n<t.length;n++)r[n]=t[n]|0;return r}Ie.toArray=Qy;function em(t){for(var e="",r=0;r<t.length;r++)e+=Ou(t[r].toString(16));return e}Ie.toHex=em;function Du(t){var e=t>>>24|t>>>8&65280|t<<8&16711680|(t&255)<<24;return e>>>0}Ie.htonl=Du;function tm(t,e){for(var r="",i=0;i<t.length;i++){var n=t[i];e==="little"&&(n=Du(n)),r+=Pu(n.toString(16))}return r}Ie.toHex32=tm;function Ou(t){return t.length===1?"0"+t:t}Ie.zero2=Ou;function Pu(t){return t.length===7?"0"+t:t.length===6?"00"+t:t.length===5?"000"+t:t.length===4?"0000"+t:t.length===3?"00000"+t:t.length===2?"000000"+t:t.length===1?"0000000"+t:t}Ie.zero8=Pu;function rm(t,e,r,i){var n=r-e;Yy(n%4===0);for(var s=new Array(n/4),o=0,a=e;o<s.length;o++,a+=4){var c;i==="big"?c=t[a]<<24|t[a+1]<<16|t[a+2]<<8|t[a+3]:c=t[a+3]<<24|t[a+2]<<16|t[a+1]<<8|t[a],s[o]=c>>>0}return s}Ie.join32=rm;function im(t,e){for(var r=new Array(t.length*4),i=0,n=0;i<t.length;i++,n+=4){var s=t[i];e==="big"?(r[n]=s>>>24,r[n+1]=s>>>16&255,r[n+2]=s>>>8&255,r[n+3]=s&255):(r[n+3]=s>>>24,r[n+2]=s>>>16&255,r[n+1]=s>>>8&255,r[n]=s&255)}return r}Ie.split32=im;function nm(t,e){return t>>>e|t<<32-e}Ie.rotr32=nm;function sm(t,e){return t<<e|t>>>32-e}Ie.rotl32=sm;function om(t,e){return t+e>>>0}Ie.sum32=om;function am(t,e,r){return t+e+r>>>0}Ie.sum32_3=am;function fm(t,e,r,i){return t+e+r+i>>>0}Ie.sum32_4=fm;function cm(t,e,r,i,n){return t+e+r+i+n>>>0}Ie.sum32_5=cm;function hm(t,e,r,i){var n=t[e],s=t[e+1],o=i+s>>>0,a=(o<i?1:0)+r+n;t[e]=a>>>0,t[e+1]=o}Ie.sum64=hm;function um(t,e,r,i){var n=e+i>>>0,s=(n<e?1:0)+t+r;return s>>>0}Ie.sum64_hi=um;function dm(t,e,r,i){var n=e+i;return n>>>0}Ie.sum64_lo=dm;function lm(t,e,r,i,n,s,o,a){var c=0,h=e;h=h+i>>>0,c+=h<e?1:0,h=h+s>>>0,c+=h<s?1:0,h=h+a>>>0,c+=h<a?1:0;var l=t+r+n+o+c;return l>>>0}Ie.sum64_4_hi=lm;function pm(t,e,r,i,n,s,o,a){var c=e+i+s+a;return c>>>0}Ie.sum64_4_lo=pm;function gm(t,e,r,i,n,s,o,a,c,h){var l=0,y=e;y=y+i>>>0,l+=y<e?1:0,y=y+s>>>0,l+=y<s?1:0,y=y+a>>>0,l+=y<a?1:0,y=y+h>>>0,l+=y<h?1:0;var M=t+r+n+o+c+l;return M>>>0}Ie.sum64_5_hi=gm;function bm(t,e,r,i,n,s,o,a,c,h){var l=e+i+s+a+h;return l>>>0}Ie.sum64_5_lo=bm;function vm(t,e,r){var i=e<<32-r|t>>>r;return i>>>0}Ie.rotr64_hi=vm;function ym(t,e,r){var i=t<<32-r|e>>>r;return i>>>0}Ie.rotr64_lo=ym;function mm(t,e,r){return t>>>r}Ie.shr64_hi=mm;function wm(t,e,r){var i=t<<32-r|e>>>r;return i>>>0}Ie.shr64_lo=wm;var Cn={},Ru=Ie,_m=sn;function yo(){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}Cn.BlockHash=yo,yo.prototype.update=function(e,r){if(e=Ru.toArray(e,r),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var i=e.length%this._delta8;this.pending=e.slice(e.length-i,e.length),this.pending.length===0&&(this.pending=null),e=Ru.join32(e,0,e.length-i,this.endian);for(var n=0;n<e.length;n+=this._delta32)this._update(e,n,n+this._delta32)}return this},yo.prototype.digest=function(e){return this.update(this._pad()),_m(this.pending===null),this._digest(e)},yo.prototype._pad=function(){var e=this.pendingTotal,r=this._delta8,i=r-(e+this.padLength)%r,n=new Array(i+this.padLength);n[0]=128;for(var s=1;s<i;s++)n[s]=0;if(e<<=3,this.endian==="big"){for(var o=8;o<this.padLength;o++)n[s++]=0;n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=e>>>24&255,n[s++]=e>>>16&255,n[s++]=e>>>8&255,n[s++]=e&255}else for(n[s++]=e&255,n[s++]=e>>>8&255,n[s++]=e>>>16&255,n[s++]=e>>>24&255,n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=0,o=8;o<this.padLength;o++)n[s++]=0;return n};var Bn={},Hr={},xm=Ie,Wr=xm.rotr32;function Em(t,e,r,i){if(t===0)return $u(e,r,i);if(t===1||t===3)return Tu(e,r,i);if(t===2)return Nu(e,r,i)}Hr.ft_1=Em;function $u(t,e,r){return t&e^~t&r}Hr.ch32=$u;function Nu(t,e,r){return t&e^t&r^e&r}Hr.maj32=Nu;function Tu(t,e,r){return t^e^r}Hr.p32=Tu;function Sm(t){return Wr(t,2)^Wr(t,13)^Wr(t,22)}Hr.s0_256=Sm;function Mm(t){return Wr(t,6)^Wr(t,11)^Wr(t,25)}Hr.s1_256=Mm;function Im(t){return Wr(t,7)^Wr(t,18)^t>>>3}Hr.g0_256=Im;function Am(t){return Wr(t,17)^Wr(t,19)^t>>>10}Hr.g1_256=Am;var Ln=Ie,Dm=Cn,Om=Hr,sf=Ln.rotl32,ms=Ln.sum32,Pm=Ln.sum32_5,Rm=Om.ft_1,Fu=Dm.BlockHash,$m=[1518500249,1859775393,2400959708,3395469782];function Gr(){if(!(this instanceof Gr))return new Gr;Fu.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Ln.inherits(Gr,Fu);var Nm=Gr;Gr.blockSize=512,Gr.outSize=160,Gr.hmacStrength=80,Gr.padLength=64,Gr.prototype._update=function(e,r){for(var i=this.W,n=0;n<16;n++)i[n]=e[r+n];for(;n<i.length;n++)i[n]=sf(i[n-3]^i[n-8]^i[n-14]^i[n-16],1);var s=this.h[0],o=this.h[1],a=this.h[2],c=this.h[3],h=this.h[4];for(n=0;n<i.length;n++){var l=~~(n/20),y=Pm(sf(s,5),Rm(l,o,a,c),h,i[n],$m[l]);h=c,c=a,a=sf(o,30),o=s,s=y}this.h[0]=ms(this.h[0],s),this.h[1]=ms(this.h[1],o),this.h[2]=ms(this.h[2],a),this.h[3]=ms(this.h[3],c),this.h[4]=ms(this.h[4],h)},Gr.prototype._digest=function(e){return e==="hex"?Ln.toHex32(this.h,"big"):Ln.split32(this.h,"big")};var qn=Ie,Tm=Cn,Un=Hr,Fm=sn,Fr=qn.sum32,Cm=qn.sum32_4,Bm=qn.sum32_5,Lm=Un.ch32,qm=Un.maj32,Um=Un.s0_256,zm=Un.s1_256,km=Un.g0_256,jm=Un.g1_256,Cu=Tm.BlockHash,Km=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function Jr(){if(!(this instanceof Jr))return new Jr;Cu.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=Km,this.W=new Array(64)}qn.inherits(Jr,Cu);var Bu=Jr;Jr.blockSize=512,Jr.outSize=256,Jr.hmacStrength=192,Jr.padLength=64,Jr.prototype._update=function(e,r){for(var i=this.W,n=0;n<16;n++)i[n]=e[r+n];for(;n<i.length;n++)i[n]=Cm(jm(i[n-2]),i[n-7],km(i[n-15]),i[n-16]);var s=this.h[0],o=this.h[1],a=this.h[2],c=this.h[3],h=this.h[4],l=this.h[5],y=this.h[6],M=this.h[7];for(Fm(this.k.length===i.length),n=0;n<i.length;n++){var I=Bm(M,zm(h),Lm(h,l,y),this.k[n],i[n]),S=Fr(Um(s),qm(s,o,a));M=y,y=l,l=h,h=Fr(c,I),c=a,a=o,o=s,s=Fr(I,S)}this.h[0]=Fr(this.h[0],s),this.h[1]=Fr(this.h[1],o),this.h[2]=Fr(this.h[2],a),this.h[3]=Fr(this.h[3],c),this.h[4]=Fr(this.h[4],h),this.h[5]=Fr(this.h[5],l),this.h[6]=Fr(this.h[6],y),this.h[7]=Fr(this.h[7],M)},Jr.prototype._digest=function(e){return e==="hex"?qn.toHex32(this.h,"big"):qn.split32(this.h,"big")};var of=Ie,Lu=Bu;function di(){if(!(this instanceof di))return new di;Lu.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}of.inherits(di,Lu);var Vm=di;di.blockSize=512,di.outSize=224,di.hmacStrength=192,di.padLength=64,di.prototype._digest=function(e){return e==="hex"?of.toHex32(this.h.slice(0,7),"big"):of.split32(this.h.slice(0,7),"big")};var nr=Ie,Hm=Cn,Wm=sn,Yr=nr.rotr64_hi,Xr=nr.rotr64_lo,qu=nr.shr64_hi,Uu=nr.shr64_lo,Ci=nr.sum64,af=nr.sum64_hi,ff=nr.sum64_lo,Gm=nr.sum64_4_hi,Jm=nr.sum64_4_lo,Ym=nr.sum64_5_hi,Xm=nr.sum64_5_lo,zu=Hm.BlockHash,Zm=[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];function Cr(){if(!(this instanceof Cr))return new Cr;zu.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=Zm,this.W=new Array(160)}nr.inherits(Cr,zu);var ku=Cr;Cr.blockSize=1024,Cr.outSize=512,Cr.hmacStrength=192,Cr.padLength=128,Cr.prototype._prepareBlock=function(e,r){for(var i=this.W,n=0;n<32;n++)i[n]=e[r+n];for(;n<i.length;n+=2){var s=c2(i[n-4],i[n-3]),o=h2(i[n-4],i[n-3]),a=i[n-14],c=i[n-13],h=a2(i[n-30],i[n-29]),l=f2(i[n-30],i[n-29]),y=i[n-32],M=i[n-31];i[n]=Gm(s,o,a,c,h,l,y,M),i[n+1]=Jm(s,o,a,c,h,l,y,M)}},Cr.prototype._update=function(e,r){this._prepareBlock(e,r);var i=this.W,n=this.h[0],s=this.h[1],o=this.h[2],a=this.h[3],c=this.h[4],h=this.h[5],l=this.h[6],y=this.h[7],M=this.h[8],I=this.h[9],S=this.h[10],D=this.h[11],R=this.h[12],$=this.h[13],T=this.h[14],C=this.h[15];Wm(this.k.length===i.length);for(var L=0;L<i.length;L+=2){var k=T,j=C,G=s2(M,I),K=o2(M,I),V=Qm(M,I,S,D,R),re=e2(M,I,S,D,R,$),O=this.k[L],g=this.k[L+1],p=i[L],f=i[L+1],u=Ym(k,j,G,K,V,re,O,g,p,f),b=Xm(k,j,G,K,V,re,O,g,p,f);k=i2(n,s),j=n2(n,s),G=t2(n,s,o,a,c),K=r2(n,s,o,a,c,h);var _=af(k,j,G,K),E=ff(k,j,G,K);T=R,C=$,R=S,$=D,S=M,D=I,M=af(l,y,u,b),I=ff(y,y,u,b),l=c,y=h,c=o,h=a,o=n,a=s,n=af(u,b,_,E),s=ff(u,b,_,E)}Ci(this.h,0,n,s),Ci(this.h,2,o,a),Ci(this.h,4,c,h),Ci(this.h,6,l,y),Ci(this.h,8,M,I),Ci(this.h,10,S,D),Ci(this.h,12,R,$),Ci(this.h,14,T,C)},Cr.prototype._digest=function(e){return e==="hex"?nr.toHex32(this.h,"big"):nr.split32(this.h,"big")};function Qm(t,e,r,i,n){var s=t&r^~t&n;return s<0&&(s+=4294967296),s}function e2(t,e,r,i,n,s){var o=e&i^~e&s;return o<0&&(o+=4294967296),o}function t2(t,e,r,i,n){var s=t&r^t&n^r&n;return s<0&&(s+=4294967296),s}function r2(t,e,r,i,n,s){var o=e&i^e&s^i&s;return o<0&&(o+=4294967296),o}function i2(t,e){var r=Yr(t,e,28),i=Yr(e,t,2),n=Yr(e,t,7),s=r^i^n;return s<0&&(s+=4294967296),s}function n2(t,e){var r=Xr(t,e,28),i=Xr(e,t,2),n=Xr(e,t,7),s=r^i^n;return s<0&&(s+=4294967296),s}function s2(t,e){var r=Yr(t,e,14),i=Yr(t,e,18),n=Yr(e,t,9),s=r^i^n;return s<0&&(s+=4294967296),s}function o2(t,e){var r=Xr(t,e,14),i=Xr(t,e,18),n=Xr(e,t,9),s=r^i^n;return s<0&&(s+=4294967296),s}function a2(t,e){var r=Yr(t,e,1),i=Yr(t,e,8),n=qu(t,e,7),s=r^i^n;return s<0&&(s+=4294967296),s}function f2(t,e){var r=Xr(t,e,1),i=Xr(t,e,8),n=Uu(t,e,7),s=r^i^n;return s<0&&(s+=4294967296),s}function c2(t,e){var r=Yr(t,e,19),i=Yr(e,t,29),n=qu(t,e,6),s=r^i^n;return s<0&&(s+=4294967296),s}function h2(t,e){var r=Xr(t,e,19),i=Xr(e,t,29),n=Uu(t,e,6),s=r^i^n;return s<0&&(s+=4294967296),s}var cf=Ie,ju=ku;function li(){if(!(this instanceof li))return new li;ju.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}cf.inherits(li,ju);var u2=li;li.blockSize=1024,li.outSize=384,li.hmacStrength=192,li.padLength=128,li.prototype._digest=function(e){return e==="hex"?cf.toHex32(this.h.slice(0,12),"big"):cf.split32(this.h.slice(0,12),"big")},Bn.sha1=Nm,Bn.sha224=Vm,Bn.sha256=Bu,Bn.sha384=u2,Bn.sha512=ku;var Ku={},on=Ie,d2=Cn,mo=on.rotl32,Vu=on.sum32,ws=on.sum32_3,Hu=on.sum32_4,Wu=d2.BlockHash;function Zr(){if(!(this instanceof Zr))return new Zr;Wu.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}on.inherits(Zr,Wu),Ku.ripemd160=Zr,Zr.blockSize=512,Zr.outSize=160,Zr.hmacStrength=192,Zr.padLength=64,Zr.prototype._update=function(e,r){for(var i=this.h[0],n=this.h[1],s=this.h[2],o=this.h[3],a=this.h[4],c=i,h=n,l=s,y=o,M=a,I=0;I<80;I++){var S=Vu(mo(Hu(i,Gu(I,n,s,o),e[g2[I]+r],l2(I)),v2[I]),a);i=a,a=o,o=mo(s,10),s=n,n=S,S=Vu(mo(Hu(c,Gu(79-I,h,l,y),e[b2[I]+r],p2(I)),y2[I]),M),c=M,M=y,y=mo(l,10),l=h,h=S}S=ws(this.h[1],s,y),this.h[1]=ws(this.h[2],o,M),this.h[2]=ws(this.h[3],a,c),this.h[3]=ws(this.h[4],i,h),this.h[4]=ws(this.h[0],n,l),this.h[0]=S},Zr.prototype._digest=function(e){return e==="hex"?on.toHex32(this.h,"little"):on.split32(this.h,"little")};function Gu(t,e,r,i){return t<=15?e^r^i:t<=31?e&r|~e&i:t<=47?(e|~r)^i:t<=63?e&i|r&~i:e^(r|~i)}function l2(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function p2(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}var g2=[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],b2=[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],v2=[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],y2=[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],m2=Ie,w2=sn;function zn(t,e,r){if(!(this instanceof zn))return new zn(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(m2.toArray(e,r))}var _2=zn;zn.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),w2(e.length<=this.blockSize);for(var r=e.length;r<this.blockSize;r++)e.push(0);for(r=0;r<e.length;r++)e[r]^=54;for(this.inner=new this.Hash().update(e),r=0;r<e.length;r++)e[r]^=106;this.outer=new this.Hash().update(e)},zn.prototype.update=function(e,r){return this.inner.update(e,r),this},zn.prototype.digest=function(e){return this.outer.update(this.inner.digest()),this.outer.digest(e)},function(t){var e=t;e.utils=Ie,e.common=Cn,e.sha=Bn,e.ripemd=Ku,e.hmac=_2,e.sha1=e.sha.sha1,e.sha256=e.sha.sha256,e.sha224=e.sha.sha224,e.sha384=e.sha.sha384,e.sha512=e.sha.sha512,e.ripemd160=e.ripemd.ripemd160}(dr);function kn(t,e,r){return r={path:e,exports:{},require:function(i,n){return x2(i,n??r.path)}},t(r,r.exports),r.exports}function x2(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var hf=Ju;function Ju(t,e){if(!t)throw new Error(e||"Assertion failed")}Ju.equal=function(e,r,i){if(e!=r)throw new Error(i||"Assertion failed: "+e+" != "+r)};var Br=kn(function(t,e){var r=e;function i(o,a){if(Array.isArray(o))return o.slice();if(!o)return[];var c=[];if(typeof o!="string"){for(var h=0;h<o.length;h++)c[h]=o[h]|0;return c}if(a==="hex"){o=o.replace(/[^a-z0-9]+/ig,""),o.length%2!==0&&(o="0"+o);for(var h=0;h<o.length;h+=2)c.push(parseInt(o[h]+o[h+1],16))}else for(var h=0;h<o.length;h++){var l=o.charCodeAt(h),y=l>>8,M=l&255;y?c.push(y,M):c.push(M)}return c}r.toArray=i;function n(o){return o.length===1?"0"+o:o}r.zero2=n;function s(o){for(var a="",c=0;c<o.length;c++)a+=n(o[c].toString(16));return a}r.toHex=s,r.encode=function(a,c){return c==="hex"?s(a):a}}),lr=kn(function(t,e){var r=e;r.assert=hf,r.toArray=Br.toArray,r.zero2=Br.zero2,r.toHex=Br.toHex,r.encode=Br.encode;function i(c,h,l){var y=new Array(Math.max(c.bitLength(),l)+1);y.fill(0);for(var M=1<<h+1,I=c.clone(),S=0;S<y.length;S++){var D,R=I.andln(M-1);I.isOdd()?(R>(M>>1)-1?D=(M>>1)-R:D=R,I.isubn(D)):D=0,y[S]=D,I.iushrn(1)}return y}r.getNAF=i;function n(c,h){var l=[[],[]];c=c.clone(),h=h.clone();for(var y=0,M=0,I;c.cmpn(-y)>0||h.cmpn(-M)>0;){var S=c.andln(3)+y&3,D=h.andln(3)+M&3;S===3&&(S=-1),D===3&&(D=-1);var R;S&1?(I=c.andln(7)+y&7,(I===3||I===5)&&D===2?R=-S:R=S):R=0,l[0].push(R);var $;D&1?(I=h.andln(7)+M&7,(I===3||I===5)&&S===2?$=-D:$=D):$=0,l[1].push($),2*y===R+1&&(y=1-y),2*M===$+1&&(M=1-M),c.iushrn(1),h.iushrn(1)}return l}r.getJSF=n;function s(c,h,l){var y="_"+h;c.prototype[h]=function(){return this[y]!==void 0?this[y]:this[y]=l.call(this)}}r.cachedProperty=s;function o(c){return typeof c=="string"?r.toArray(c,"hex"):c}r.parseBytes=o;function a(c){return new me(c,"hex","le")}r.intFromLE=a}),wo=lr.getNAF,E2=lr.getJSF,_o=lr.assert;function Bi(t,e){this.type=t,this.p=new me(e.p,16),this.red=e.prime?me.red(e.prime):me.mont(this.p),this.zero=new me(0).toRed(this.red),this.one=new me(1).toRed(this.red),this.two=new me(2).toRed(this.red),this.n=e.n&&new me(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 r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var an=Bi;Bi.prototype.point=function(){throw new Error("Not implemented")},Bi.prototype.validate=function(){throw new Error("Not implemented")},Bi.prototype._fixedNafMul=function(e,r){_o(e.precomputed);var i=e._getDoubles(),n=wo(r,1,this._bitLength),s=(1<<i.step+1)-(i.step%2===0?2:1);s/=3;var o=[],a,c;for(a=0;a<n.length;a+=i.step){c=0;for(var h=a+i.step-1;h>=a;h--)c=(c<<1)+n[h];o.push(c)}for(var l=this.jpoint(null,null,null),y=this.jpoint(null,null,null),M=s;M>0;M--){for(a=0;a<o.length;a++)c=o[a],c===M?y=y.mixedAdd(i.points[a]):c===-M&&(y=y.mixedAdd(i.points[a].neg()));l=l.add(y)}return l.toP()},Bi.prototype._wnafMul=function(e,r){var i=4,n=e._getNAFPoints(i);i=n.wnd;for(var s=n.points,o=wo(r,i,this._bitLength),a=this.jpoint(null,null,null),c=o.length-1;c>=0;c--){for(var h=0;c>=0&&o[c]===0;c--)h++;if(c>=0&&h++,a=a.dblp(h),c<0)break;var l=o[c];_o(l!==0),e.type==="affine"?l>0?a=a.mixedAdd(s[l-1>>1]):a=a.mixedAdd(s[-l-1>>1].neg()):l>0?a=a.add(s[l-1>>1]):a=a.add(s[-l-1>>1].neg())}return e.type==="affine"?a.toP():a},Bi.prototype._wnafMulAdd=function(e,r,i,n,s){var o=this._wnafT1,a=this._wnafT2,c=this._wnafT3,h=0,l,y,M;for(l=0;l<n;l++){M=r[l];var I=M._getNAFPoints(e);o[l]=I.wnd,a[l]=I.points}for(l=n-1;l>=1;l-=2){var S=l-1,D=l;if(o[S]!==1||o[D]!==1){c[S]=wo(i[S],o[S],this._bitLength),c[D]=wo(i[D],o[D],this._bitLength),h=Math.max(c[S].length,h),h=Math.max(c[D].length,h);continue}var R=[r[S],null,null,r[D]];r[S].y.cmp(r[D].y)===0?(R[1]=r[S].add(r[D]),R[2]=r[S].toJ().mixedAdd(r[D].neg())):r[S].y.cmp(r[D].y.redNeg())===0?(R[1]=r[S].toJ().mixedAdd(r[D]),R[2]=r[S].add(r[D].neg())):(R[1]=r[S].toJ().mixedAdd(r[D]),R[2]=r[S].toJ().mixedAdd(r[D].neg()));var $=[-3,-1,-5,-7,0,7,5,1,3],T=E2(i[S],i[D]);for(h=Math.max(T[0].length,h),c[S]=new Array(h),c[D]=new Array(h),y=0;y<h;y++){var C=T[0][y]|0,L=T[1][y]|0;c[S][y]=$[(C+1)*3+(L+1)],c[D][y]=0,a[S]=R}}var k=this.jpoint(null,null,null),j=this._wnafT4;for(l=h;l>=0;l--){for(var G=0;l>=0;){var K=!0;for(y=0;y<n;y++)j[y]=c[y][l]|0,j[y]!==0&&(K=!1);if(!K)break;G++,l--}if(l>=0&&G++,k=k.dblp(G),l<0)break;for(y=0;y<n;y++){var V=j[y];V!==0&&(V>0?M=a[y][V-1>>1]:V<0&&(M=a[y][-V-1>>1].neg()),M.type==="affine"?k=k.mixedAdd(M):k=k.add(M))}}for(l=0;l<n;l++)a[l]=null;return s?k:k.toP()};function wr(t,e){this.curve=t,this.type=e,this.precomputed=null}Bi.BasePoint=wr,wr.prototype.eq=function(){throw new Error("Not implemented")},wr.prototype.validate=function(){return this.curve.validate(this)},Bi.prototype.decodePoint=function(e,r){e=lr.toArray(e,r);var i=this.p.byteLength();if((e[0]===4||e[0]===6||e[0]===7)&&e.length-1===2*i){e[0]===6?_o(e[e.length-1]%2===0):e[0]===7&&_o(e[e.length-1]%2===1);var n=this.point(e.slice(1,1+i),e.slice(1+i,1+2*i));return n}else if((e[0]===2||e[0]===3)&&e.length-1===i)return this.pointFromX(e.slice(1,1+i),e[0]===3);throw new Error("Unknown point format")},wr.prototype.encodeCompressed=function(e){return this.encode(e,!0)},wr.prototype._encode=function(e){var r=this.curve.p.byteLength(),i=this.getX().toArray("be",r);return e?[this.getY().isEven()?2:3].concat(i):[4].concat(i,this.getY().toArray("be",r))},wr.prototype.encode=function(e,r){return lr.encode(this._encode(r),e)},wr.prototype.precompute=function(e){if(this.precomputed)return this;var r={doubles:null,naf:null,beta:null};return r.naf=this._getNAFPoints(8),r.doubles=this._getDoubles(4,e),r.beta=this._getBeta(),this.precomputed=r,this},wr.prototype._hasDoubles=function(e){if(!this.precomputed)return!1;var r=this.precomputed.doubles;return r?r.points.length>=Math.ceil((e.bitLength()+1)/r.step):!1},wr.prototype._getDoubles=function(e,r){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s<r;s+=e){for(var o=0;o<e;o++)n=n.dbl();i.push(n)}return{step:e,points:i}},wr.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var r=[this],i=(1<<e)-1,n=i===1?null:this.dbl(),s=1;s<i;s++)r[s]=r[s-1].add(n);return{wnd:e,points:r}},wr.prototype._getBeta=function(){return null},wr.prototype.dblp=function(e){for(var r=this,i=0;i<e;i++)r=r.dbl();return r};var uf=kn(function(t){typeof Object.create=="function"?t.exports=function(r,i){i&&(r.super_=i,r.prototype=Object.create(i.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(r,i){if(i){r.super_=i;var n=function(){};n.prototype=i.prototype,r.prototype=new n,r.prototype.constructor=r}}}),S2=lr.assert;function _r(t){an.call(this,"short",t),this.a=new me(t.a,16).toRed(this.red),this.b=new me(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}uf(_r,an);var M2=_r;_r.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var r,i;if(e.beta)r=new me(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);r=n[0].cmp(n[1])<0?n[0]:n[1],r=r.toRed(this.red)}if(e.lambda)i=new me(e.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(r))===0?i=s[0]:(i=s[1],S2(this.g.mul(i).x.cmp(this.g.x.redMul(r))===0))}var o;return e.basis?o=e.basis.map(function(a){return{a:new me(a.a,16),b:new me(a.b,16)}}):o=this._getEndoBasis(i),{beta:r,lambda:i,basis:o}}},_r.prototype._getEndoRoots=function(e){var r=e===this.p?this.red:me.mont(e),i=new me(2).toRed(r).redInvm(),n=i.redNeg(),s=new me(3).toRed(r).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),a=n.redSub(s).fromRed();return[o,a]},_r.prototype._getEndoBasis=function(e){for(var r=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new me(1),o=new me(0),a=new me(0),c=new me(1),h,l,y,M,I,S,D,R=0,$,T;i.cmpn(0)!==0;){var C=n.div(i);$=n.sub(C.mul(i)),T=a.sub(C.mul(s));var L=c.sub(C.mul(o));if(!y&&$.cmp(r)<0)h=D.neg(),l=s,y=$.neg(),M=T;else if(y&&++R===2)break;D=$,n=i,i=$,a=s,s=T,c=o,o=L}I=$.neg(),S=T;var k=y.sqr().add(M.sqr()),j=I.sqr().add(S.sqr());return j.cmp(k)>=0&&(I=h,S=l),y.negative&&(y=y.neg(),M=M.neg()),I.negative&&(I=I.neg(),S=S.neg()),[{a:y,b:M},{a:I,b:S}]},_r.prototype._endoSplit=function(e){var r=this.endo.basis,i=r[0],n=r[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),a=s.mul(i.a),c=o.mul(n.a),h=s.mul(i.b),l=o.mul(n.b),y=e.sub(a).sub(c),M=h.add(l).neg();return{k1:y,k2:M}},_r.prototype.pointFromX=function(e,r){e=new me(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(r&&!s||!r&&s)&&(n=n.redNeg()),this.point(e,n)},_r.prototype.validate=function(e){if(e.inf)return!0;var r=e.x,i=e.y,n=this.a.redMul(r),s=r.redSqr().redMul(r).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0},_r.prototype._endoWnafMulAdd=function(e,r,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o<e.length;o++){var a=this._endoSplit(r[o]),c=e[o],h=c._getBeta();a.k1.negative&&(a.k1.ineg(),c=c.neg(!0)),a.k2.negative&&(a.k2.ineg(),h=h.neg(!0)),n[o*2]=c,n[o*2+1]=h,s[o*2]=a.k1,s[o*2+1]=a.k2}for(var l=this._wnafMulAdd(1,n,s,o*2,i),y=0;y<o*2;y++)n[y]=null,s[y]=null;return l};function It(t,e,r,i){an.BasePoint.call(this,t,"affine"),e===null&&r===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new me(e,16),this.y=new me(r,16),i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}uf(It,an.BasePoint),_r.prototype.point=function(e,r,i){return new It(this,e,r,i)},_r.prototype.pointFromJSON=function(e,r){return It.fromJSON(this,e,r)},It.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var r=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var i=this.curve,n=function(s){return i.point(s.x.redMul(i.endo.beta),s.y)};e.beta=r,r.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(n)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(n)}}}return r}},It.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},It.fromJSON=function(e,r,i){typeof r=="string"&&(r=JSON.parse(r));var n=e.point(r[0],r[1],i);if(!r[2])return n;function s(a){return e.point(a[0],a[1],i)}var o=r[2];return n.precomputed={beta:null,doubles:o.doubles&&{step:o.doubles.step,points:[n].concat(o.doubles.points.map(s))},naf:o.naf&&{wnd:o.naf.wnd,points:[n].concat(o.naf.points.map(s))}},n},It.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},It.prototype.isInfinity=function(){return this.inf},It.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var r=this.y.redSub(e.y);r.cmpn(0)!==0&&(r=r.redMul(this.x.redSub(e.x).redInvm()));var i=r.redSqr().redISub(this.x).redISub(e.x),n=r.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)},It.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var r=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(r).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),a=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},It.prototype.getX=function(){return this.x.fromRed()},It.prototype.getY=function(){return this.y.fromRed()},It.prototype.mul=function(e){return e=new me(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},It.prototype.mulAdd=function(e,r,i){var n=[this,r],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)},It.prototype.jmulAdd=function(e,r,i){var n=[this,r],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)},It.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)},It.prototype.neg=function(e){if(this.inf)return this;var r=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};r.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return r},It.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function Ct(t,e,r,i){an.BasePoint.call(this,t,"jacobian"),e===null&&r===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new me(0)):(this.x=new me(e,16),this.y=new me(r,16),this.z=new me(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}uf(Ct,an.BasePoint),_r.prototype.jpoint=function(e,r,i){return new Ct(this,e,r,i)},Ct.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),r=e.redSqr(),i=this.x.redMul(r),n=this.y.redMul(r).redMul(e);return this.curve.point(i,n)},Ct.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Ct.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var r=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(r),s=e.x.redMul(i),o=this.y.redMul(r.redMul(e.z)),a=e.y.redMul(i.redMul(this.z)),c=n.redSub(s),h=o.redSub(a);if(c.cmpn(0)===0)return h.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var l=c.redSqr(),y=l.redMul(c),M=n.redMul(l),I=h.redSqr().redIAdd(y).redISub(M).redISub(M),S=h.redMul(M.redISub(I)).redISub(o.redMul(y)),D=this.z.redMul(e.z).redMul(c);return this.curve.jpoint(I,S,D)},Ct.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var r=this.z.redSqr(),i=this.x,n=e.x.redMul(r),s=this.y,o=e.y.redMul(r).redMul(this.z),a=i.redSub(n),c=s.redSub(o);if(a.cmpn(0)===0)return c.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var h=a.redSqr(),l=h.redMul(a),y=i.redMul(h),M=c.redSqr().redIAdd(l).redISub(y).redISub(y),I=c.redMul(y.redISub(M)).redISub(s.redMul(l)),S=this.z.redMul(a);return this.curve.jpoint(M,I,S)},Ct.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var r;if(this.curve.zeroA||this.curve.threeA){var i=this;for(r=0;r<e;r++)i=i.dbl();return i}var n=this.curve.a,s=this.curve.tinv,o=this.x,a=this.y,c=this.z,h=c.redSqr().redSqr(),l=a.redAdd(a);for(r=0;r<e;r++){var y=o.redSqr(),M=l.redSqr(),I=M.redSqr(),S=y.redAdd(y).redIAdd(y).redIAdd(n.redMul(h)),D=o.redMul(M),R=S.redSqr().redISub(D.redAdd(D)),$=D.redISub(R),T=S.redMul($);T=T.redIAdd(T).redISub(I);var C=l.redMul(c);r+1<e&&(h=h.redMul(I)),o=R,c=C,l=T}return this.curve.jpoint(o,l.redMul(s),c)},Ct.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},Ct.prototype._zeroDbl=function(){var e,r,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),a=this.x.redAdd(s).redSqr().redISub(n).redISub(o);a=a.redIAdd(a);var c=n.redAdd(n).redIAdd(n),h=c.redSqr().redISub(a).redISub(a),l=o.redIAdd(o);l=l.redIAdd(l),l=l.redIAdd(l),e=h,r=c.redMul(a.redISub(h)).redISub(l),i=this.y.redAdd(this.y)}else{var y=this.x.redSqr(),M=this.y.redSqr(),I=M.redSqr(),S=this.x.redAdd(M).redSqr().redISub(y).redISub(I);S=S.redIAdd(S);var D=y.redAdd(y).redIAdd(y),R=D.redSqr(),$=I.redIAdd(I);$=$.redIAdd($),$=$.redIAdd($),e=R.redISub(S).redISub(S),r=D.redMul(S.redISub(e)).redISub($),i=this.y.redMul(this.z),i=i.redIAdd(i)}return this.curve.jpoint(e,r,i)},Ct.prototype._threeDbl=function(){var e,r,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),a=this.x.redAdd(s).redSqr().redISub(n).redISub(o);a=a.redIAdd(a);var c=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),h=c.redSqr().redISub(a).redISub(a);e=h;var l=o.redIAdd(o);l=l.redIAdd(l),l=l.redIAdd(l),r=c.redMul(a.redISub(h)).redISub(l),i=this.y.redAdd(this.y)}else{var y=this.z.redSqr(),M=this.y.redSqr(),I=this.x.redMul(M),S=this.x.redSub(y).redMul(this.x.redAdd(y));S=S.redAdd(S).redIAdd(S);var D=I.redIAdd(I);D=D.redIAdd(D);var R=D.redAdd(D);e=S.redSqr().redISub(R),i=this.y.redAdd(this.z).redSqr().redISub(M).redISub(y);var $=M.redSqr();$=$.redIAdd($),$=$.redIAdd($),$=$.redIAdd($),r=S.redMul(D.redISub(e)).redISub($)}return this.curve.jpoint(e,r,i)},Ct.prototype._dbl=function(){var e=this.curve.a,r=this.x,i=this.y,n=this.z,s=n.redSqr().redSqr(),o=r.redSqr(),a=i.redSqr(),c=o.redAdd(o).redIAdd(o).redIAdd(e.redMul(s)),h=r.redAdd(r);h=h.redIAdd(h);var l=h.redMul(a),y=c.redSqr().redISub(l.redAdd(l)),M=l.redISub(y),I=a.redSqr();I=I.redIAdd(I),I=I.redIAdd(I),I=I.redIAdd(I);var S=c.redMul(M).redISub(I),D=i.redAdd(i).redMul(n);return this.curve.jpoint(y,S,D)},Ct.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),r=this.y.redSqr(),i=this.z.redSqr(),n=r.redSqr(),s=e.redAdd(e).redIAdd(e),o=s.redSqr(),a=this.x.redAdd(r).redSqr().redISub(e).redISub(n);a=a.redIAdd(a),a=a.redAdd(a).redIAdd(a),a=a.redISub(o);var c=a.redSqr(),h=n.redIAdd(n);h=h.redIAdd(h),h=h.redIAdd(h),h=h.redIAdd(h);var l=s.redIAdd(a).redSqr().redISub(o).redISub(c).redISub(h),y=r.redMul(l);y=y.redIAdd(y),y=y.redIAdd(y);var M=this.x.redMul(c).redISub(y);M=M.redIAdd(M),M=M.redIAdd(M);var I=this.y.redMul(l.redMul(h.redISub(l)).redISub(a.redMul(c)));I=I.redIAdd(I),I=I.redIAdd(I),I=I.redIAdd(I);var S=this.z.redAdd(a).redSqr().redISub(i).redISub(c);return this.curve.jpoint(M,I,S)},Ct.prototype.mul=function(e,r){return e=new me(e,r),this.curve._wnafMul(this,e)},Ct.prototype.eq=function(e){if(e.type==="affine")return this.eq(e.toJ());if(this===e)return!0;var r=this.z.redSqr(),i=e.z.redSqr();if(this.x.redMul(i).redISub(e.x.redMul(r)).cmpn(0)!==0)return!1;var n=r.redMul(this.z),s=i.redMul(e.z);return this.y.redMul(s).redISub(e.y.redMul(n)).cmpn(0)===0},Ct.prototype.eqXToP=function(e){var r=this.z.redSqr(),i=e.toRed(this.curve.red).redMul(r);if(this.x.cmp(i)===0)return!0;for(var n=e.clone(),s=this.curve.redN.redMul(r);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}},Ct.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},Ct.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var xo=kn(function(t,e){var r=e;r.base=an,r.short=M2,r.mont=null,r.edwards=null}),Eo=kn(function(t,e){var r=e,i=lr.assert;function n(a){a.type==="short"?this.curve=new xo.short(a):a.type==="edwards"?this.curve=new xo.edwards(a):this.curve=new xo.mont(a),this.g=this.curve.g,this.n=this.curve.n,this.hash=a.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}r.PresetCurve=n;function s(a,c){Object.defineProperty(r,a,{configurable:!0,enumerable:!0,get:function(){var h=new n(c);return Object.defineProperty(r,a,{configurable:!0,enumerable:!0,value:h}),h}})}s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:dr.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:dr.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:dr.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:dr.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:dr.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:dr.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:dr.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var o;try{o=null.crash()}catch{o=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:dr.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})});function Li(t){if(!(this instanceof Li))return new Li(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Br.toArray(t.entropy,t.entropyEnc||"hex"),r=Br.toArray(t.nonce,t.nonceEnc||"hex"),i=Br.toArray(t.pers,t.persEnc||"hex");hf(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,i)}var Yu=Li;Li.prototype._init=function(e,r,i){var n=e.concat(r).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s<this.V.length;s++)this.K[s]=0,this.V[s]=1;this._update(n),this._reseed=1,this.reseedInterval=281474976710656},Li.prototype._hmac=function(){return new dr.hmac(this.hash,this.K)},Li.prototype._update=function(e){var r=this._hmac().update(this.V).update([0]);e&&(r=r.update(e)),this.K=r.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())},Li.prototype.reseed=function(e,r,i,n){typeof r!="string"&&(n=i,i=r,r=null),e=Br.toArray(e,r),i=Br.toArray(i,n),hf(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1},Li.prototype.generate=function(e,r,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof r!="string"&&(n=i,i=r,r=null),i&&(i=Br.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length<e;)this.V=this._hmac().update(this.V).digest(),s=s.concat(this.V);var o=s.slice(0,e);return this._update(i),this._reseed++,Br.encode(o,r)};var df=lr.assert;function Kt(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var lf=Kt;Kt.fromPublic=function(e,r,i){return r instanceof Kt?r:new Kt(e,{pub:r,pubEnc:i})},Kt.fromPrivate=function(e,r,i){return r instanceof Kt?r:new Kt(e,{priv:r,privEnc:i})},Kt.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},Kt.prototype.getPublic=function(e,r){return typeof e=="string"&&(r=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),r?this.pub.encode(r,e):this.pub},Kt.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv},Kt.prototype._importPrivate=function(e,r){this.priv=new me(e,r||16),this.priv=this.priv.umod(this.ec.curve.n)},Kt.prototype._importPublic=function(e,r){if(e.x||e.y){this.ec.curve.type==="mont"?df(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&df(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,r)},Kt.prototype.derive=function(e){return e.validate()||df(e.validate(),"public point not validated"),e.mul(this.priv).getX()},Kt.prototype.sign=function(e,r,i){return this.ec.sign(e,this,r,i)},Kt.prototype.verify=function(e,r){return this.ec.verify(e,r,this)},Kt.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var I2=lr.assert;function So(t,e){if(t instanceof So)return t;this._importDER(t,e)||(I2(t.r&&t.s,"Signature without r or s"),this.r=new me(t.r,16),this.s=new me(t.s,16),t.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var Mo=So;function A2(){this.place=0}function pf(t,e){var r=t[e.place++];if(!(r&128))return r;var i=r&15;if(i===0||i>4)return!1;for(var n=0,s=0,o=e.place;s<i;s++,o++)n<<=8,n|=t[o],n>>>=0;return n<=127?!1:(e.place=o,n)}function Xu(t){for(var e=0,r=t.length-1;!t[e]&&!(t[e+1]&128)&&e<r;)e++;return e===0?t:t.slice(e)}So.prototype._importDER=function(e,r){e=lr.toArray(e,r);var i=new A2;if(e[i.place++]!==48)return!1;var n=pf(e,i);if(n===!1||n+i.place!==e.length||e[i.place++]!==2)return!1;var s=pf(e,i);if(s===!1)return!1;var o=e.slice(i.place,s+i.place);if(i.place+=s,e[i.place++]!==2)return!1;var a=pf(e,i);if(a===!1||e.length!==a+i.place)return!1;var c=e.slice(i.place,a+i.place);if(o[0]===0)if(o[1]&128)o=o.slice(1);else return!1;if(c[0]===0)if(c[1]&128)c=c.slice(1);else return!1;return this.r=new me(o),this.s=new me(c),this.recoveryParam=null,!0};function gf(t,e){if(e<128){t.push(e);return}var r=1+(Math.log(e)/Math.LN2>>>3);for(t.push(r|128);--r;)t.push(e>>>(r<<3)&255);t.push(e)}So.prototype.toDER=function(e){var r=this.r.toArray(),i=this.s.toArray();for(r[0]&128&&(r=[0].concat(r)),i[0]&128&&(i=[0].concat(i)),r=Xu(r),i=Xu(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];gf(n,r.length),n=n.concat(r),n.push(2),gf(n,i.length);var s=n.concat(i),o=[48];return gf(o,s.length),o=o.concat(s),lr.encode(o,e)};var D2=function(){throw new Error("unsupported")},Zu=lr.assert;function xr(t){if(!(this instanceof xr))return new xr(t);typeof t=="string"&&(Zu(Object.prototype.hasOwnProperty.call(Eo,t),"Unknown curve "+t),t=Eo[t]),t instanceof Eo.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}var O2=xr;xr.prototype.keyPair=function(e){return new lf(this,e)},xr.prototype.keyFromPrivate=function(e,r){return lf.fromPrivate(this,e,r)},xr.prototype.keyFromPublic=function(e,r){return lf.fromPublic(this,e,r)},xr.prototype.genKeyPair=function(e){e||(e={});for(var r=new Yu({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||D2(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new me(2));;){var s=new me(r.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}},xr.prototype._truncateToN=function(e,r){var i=e.byteLength()*8-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!r&&e.cmp(this.n)>=0?e.sub(this.n):e},xr.prototype.sign=function(e,r,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),r=this.keyFromPrivate(r,i),e=this._truncateToN(new me(e,16));for(var s=this.n.byteLength(),o=r.getPrivate().toArray("be",s),a=e.toArray("be",s),c=new Yu({hash:this.hash,entropy:o,nonce:a,pers:n.pers,persEnc:n.persEnc||"utf8"}),h=this.n.sub(new me(1)),l=0;;l++){var y=n.k?n.k(l):new me(c.generate(this.n.byteLength()));if(y=this._truncateToN(y,!0),!(y.cmpn(1)<=0||y.cmp(h)>=0)){var M=this.g.mul(y);if(!M.isInfinity()){var I=M.getX(),S=I.umod(this.n);if(S.cmpn(0)!==0){var D=y.invm(this.n).mul(S.mul(r.getPrivate()).iadd(e));if(D=D.umod(this.n),D.cmpn(0)!==0){var R=(M.getY().isOdd()?1:0)|(I.cmp(S)!==0?2:0);return n.canonical&&D.cmp(this.nh)>0&&(D=this.n.sub(D),R^=1),new Mo({r:S,s:D,recoveryParam:R})}}}}}},xr.prototype.verify=function(e,r,i,n){e=this._truncateToN(new me(e,16)),i=this.keyFromPublic(i,n),r=new Mo(r,"hex");var s=r.r,o=r.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a=o.invm(this.n),c=a.mul(e).umod(this.n),h=a.mul(s).umod(this.n),l;return this.curve._maxwellTrick?(l=this.g.jmulAdd(c,i.getPublic(),h),l.isInfinity()?!1:l.eqXToP(s)):(l=this.g.mulAdd(c,i.getPublic(),h),l.isInfinity()?!1:l.getX().umod(this.n).cmp(s)===0)},xr.prototype.recoverPubKey=function(t,e,r,i){Zu((3&r)===r,"The recovery param is more than two bits"),e=new Mo(e,i);var n=this.n,s=new me(t),o=e.r,a=e.s,c=r&1,h=r>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&h)throw new Error("Unable to find sencond key candinate");h?o=this.curve.pointFromX(o.add(this.curve.n),c):o=this.curve.pointFromX(o,c);var l=e.r.invm(n),y=n.sub(s).mul(l).umod(n),M=a.mul(l).umod(n);return this.g.mulAdd(y,o,M)},xr.prototype.getKeyRecoveryParam=function(t,e,r,i){if(e=new Mo(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(t,e,n)}catch{continue}if(s.eq(r))return n}throw new Error("Unable to find valid recovery factor")};var P2=kn(function(t,e){var r=e;r.version="6.5.4",r.utils=lr,r.rand=function(){throw new Error("unsupported")},r.curve=xo,r.curves=Eo,r.ec=O2,r.eddsa=null}),R2=P2.ec;const $2="signing-key/5.7.0",bf=new Ee($2);let vf=null;function Qr(){return vf||(vf=new R2("secp256k1")),vf}class N2{constructor(e){ys(this,"curve","secp256k1"),ys(this,"privateKey",Yt(e)),Cy(this.privateKey)!==32&&bf.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const r=Qr().keyFromPrivate(xt(this.privateKey));ys(this,"publicKey","0x"+r.getPublic(!1,"hex")),ys(this,"compressedPublicKey","0x"+r.getPublic(!0,"hex")),ys(this,"_isSigningKey",!0)}_addPoint(e){const r=Qr().keyFromPublic(xt(this.publicKey)),i=Qr().keyFromPublic(xt(e));return"0x"+r.pub.add(i.pub).encodeCompressed("hex")}signDigest(e){const r=Qr().keyFromPrivate(xt(this.privateKey)),i=xt(e);i.length!==32&&bf.throwArgumentError("bad digest length","digest",e);const n=r.sign(i,{canonical:!0});return pu({recoveryParam:n.recoveryParam,r:Fi("0x"+n.r.toString(16),32),s:Fi("0x"+n.s.toString(16),32)})}computeSharedSecret(e){const r=Qr().keyFromPrivate(xt(this.privateKey)),i=Qr().keyFromPublic(xt(Qu(e)));return Fi("0x"+r.derive(i.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}}function T2(t,e){const r=pu(e),i={r:xt(r.r),s:xt(r.s)};return"0x"+Qr().recoverPubKey(xt(t),i,r.recoveryParam).encode("hex",!1)}function Qu(t,e){const r=xt(t);if(r.length===32){const i=new N2(r);return e?"0x"+Qr().keyFromPrivate(r).getPublic(!0,"hex"):i.publicKey}else{if(r.length===33)return e?Yt(r):"0x"+Qr().keyFromPublic(r).getPublic(!1,"hex");if(r.length===65)return e?"0x"+Qr().keyFromPublic(r).getPublic(!0,"hex"):Yt(r)}return bf.throwArgumentError("invalid public or private key","key","[REDACTED]")}const F2="transactions/5.7.0";new Ee(F2);var ed;(function(t){t[t.legacy=0]="legacy",t[t.eip2930=1]="eip2930",t[t.eip1559=2]="eip1559"})(ed||(ed={}));function C2(t){const e=Qu(t);return Gy(lu(Su(lu(e,1)),12))}function B2(t,e){return C2(T2(xt(t),e))}function td(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function yf(t,e){e||(e=t.reduce((n,s)=>n+s.length,0));const r=td(e);let i=0;for(const n of t)r.set(n,i),i+=n.length;return r}function L2(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=n}var a=t.length,c=t.charAt(0),h=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function y(S){if(S instanceof Uint8Array||(ArrayBuffer.isView(S)?S=new Uint8Array(S.buffer,S.byteOffset,S.byteLength):Array.isArray(S)&&(S=Uint8Array.from(S))),!(S instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(S.length===0)return"";for(var D=0,R=0,$=0,T=S.length;$!==T&&S[$]===0;)$++,D++;for(var C=(T-$)*l+1>>>0,L=new Uint8Array(C);$!==T;){for(var k=S[$],j=0,G=C-1;(k!==0||j<R)&&G!==-1;G--,j++)k+=256*L[G]>>>0,L[G]=k%a>>>0,k=k/a>>>0;if(k!==0)throw new Error("Non-zero carry");R=j,$++}for(var K=C-R;K!==C&&L[K]===0;)K++;for(var V=c.repeat(D);K<C;++K)V+=t.charAt(L[K]);return V}function M(S){if(typeof S!="string")throw new TypeError("Expected String");if(S.length===0)return new Uint8Array;var D=0;if(S[D]!==" "){for(var R=0,$=0;S[D]===c;)R++,D++;for(var T=(S.length-D)*h+1>>>0,C=new Uint8Array(T);S[D];){var L=r[S.charCodeAt(D)];if(L===255)return;for(var k=0,j=T-1;(L!==0||k<$)&&j!==-1;j--,k++)L+=a*C[j]>>>0,C[j]=L%256>>>0,L=L/256>>>0;if(L!==0)throw new Error("Non-zero carry");$=k,D++}if(S[D]!==" "){for(var G=T-$;G!==T&&C[G]===0;)G++;for(var K=new Uint8Array(R+(T-G)),V=R;G!==T;)K[V++]=C[G++];return K}}}function I(S){var D=M(S);if(D)return D;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:M,decode:I}}var q2=L2,U2=q2;const rd=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},z2=t=>new TextEncoder().encode(t),k2=t=>new TextDecoder().decode(t);class j2{constructor(e,r,i){this.name=e,this.prefix=r,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class K2{constructor(e,r,i){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return id(this,e)}}class V2{constructor(e){this.decoders=e}or(e){return id(this,e)}decode(e){const r=e[0],i=this.decoders[r];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const id=(t,e)=>new V2({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class H2{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new j2(e,r,i),this.decoder=new K2(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Io=({name:t,prefix:e,encode:r,decode:i})=>new H2(t,e,r,i),_s=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=U2(r,e);return Io({prefix:t,name:e,encode:i,decode:s=>rd(n(s))})},W2=(t,e,r,i)=>{const n={};for(let l=0;l<e.length;++l)n[e[l]]=l;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,h=0;for(let l=0;l<s;++l){const y=n[t[l]];if(y===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<r|y,a+=r,a>=8&&(a-=8,o[h++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},G2=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>r;)o-=r,s+=e[n&a>>o];if(o&&(s+=e[n&a<<r-o]),i)for(;s.length*r&7;)s+="=";return s},Bt=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>Io({prefix:e,name:t,encode(n){return G2(n,i,r)},decode(n){return W2(n,i,r,t)}}),J2=Io({prefix:"\0",name:"identity",encode:t=>k2(t),decode:t=>z2(t)});var Y2=Object.freeze({__proto__:null,identity:J2});const X2=Bt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Z2=Object.freeze({__proto__:null,base2:X2});const Q2=Bt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var e3=Object.freeze({__proto__:null,base8:Q2});const t3=_s({prefix:"9",name:"base10",alphabet:"0123456789"});var r3=Object.freeze({__proto__:null,base10:t3});const i3=Bt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),n3=Bt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var s3=Object.freeze({__proto__:null,base16:i3,base16upper:n3});const o3=Bt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),a3=Bt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),f3=Bt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),c3=Bt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),h3=Bt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),u3=Bt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),d3=Bt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),l3=Bt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),p3=Bt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var g3=Object.freeze({__proto__:null,base32:o3,base32upper:a3,base32pad:f3,base32padupper:c3,base32hex:h3,base32hexupper:u3,base32hexpad:d3,base32hexpadupper:l3,base32z:p3});const b3=_s({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),v3=_s({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var y3=Object.freeze({__proto__:null,base36:b3,base36upper:v3});const m3=_s({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),w3=_s({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var _3=Object.freeze({__proto__:null,base58btc:m3,base58flickr:w3});const x3=Bt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),E3=Bt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),S3=Bt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),M3=Bt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var I3=Object.freeze({__proto__:null,base64:x3,base64pad:E3,base64url:S3,base64urlpad:M3});const nd=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),A3=nd.reduce((t,e,r)=>(t[r]=e,t),[]),D3=nd.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function O3(t){return t.reduce((e,r)=>(e+=A3[r],e),"")}function P3(t){const e=[];for(const r of t){const i=D3[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const R3=Io({prefix:"\u{1F680}",name:"base256emoji",encode:O3,decode:P3});var $3=Object.freeze({__proto__:null,base256emoji:R3}),N3=od,sd=128,T3=127,F3=~T3,C3=Math.pow(2,31);function od(t,e,r){e=e||[],r=r||0;for(var i=r;t>=C3;)e[r++]=t&255|sd,t/=128;for(;t&F3;)e[r++]=t&255|sd,t>>>=7;return e[r]=t|0,od.bytes=r-i+1,e}var B3=mf,L3=128,ad=127;function mf(t,i){var r=0,i=i||0,n=0,s=i,o,a=t.length;do{if(s>=a)throw mf.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=n<28?(o&ad)<<n:(o&ad)*Math.pow(2,n),n+=7}while(o>=L3);return mf.bytes=s-i,r}var q3=Math.pow(2,7),U3=Math.pow(2,14),z3=Math.pow(2,21),k3=Math.pow(2,28),j3=Math.pow(2,35),K3=Math.pow(2,42),V3=Math.pow(2,49),H3=Math.pow(2,56),W3=Math.pow(2,63),G3=function(t){return t<q3?1:t<U3?2:t<z3?3:t<k3?4:t<j3?5:t<K3?6:t<V3?7:t<H3?8:t<W3?9:10},J3={encode:N3,decode:B3,encodingLength:G3},fd=J3;const cd=(t,e,r=0)=>(fd.encode(t,e,r),e),hd=t=>fd.encodingLength(t),wf=(t,e)=>{const r=e.byteLength,i=hd(t),n=i+hd(r),s=new Uint8Array(n+r);return cd(t,s,0),cd(r,s,i),s.set(e,n),new Y3(t,r,e,s)};class Y3{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const ud=({name:t,code:e,encode:r})=>new X3(t,e,r);class X3{constructor(e,r,i){this.name=e,this.code=r,this.encode=i}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?wf(this.code,r):r.then(i=>wf(this.code,i))}else throw Error("Unknown type, must be binary type")}}const dd=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Z3=ud({name:"sha2-256",code:18,encode:dd("SHA-256")}),Q3=ud({name:"sha2-512",code:19,encode:dd("SHA-512")});var ew=Object.freeze({__proto__:null,sha256:Z3,sha512:Q3});const ld=0,tw="identity",pd=rd;var rw=Object.freeze({__proto__:null,identity:{code:ld,name:tw,encode:pd,digest:t=>wf(ld,pd(t))}});new TextEncoder,new TextDecoder;const gd={...Y2,...Z2,...e3,...r3,...s3,...g3,...y3,..._3,...I3,...$3};({...ew,...rw});function bd(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const vd=bd("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),_f=bd("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=td(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),yd={utf8:vd,"utf-8":vd,hex:gd.base16,latin1:_f,ascii:_f,binary:_f,...gd};function Er(t,e="utf8"){const r=yd[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t,"utf8"):r.decoder.decode(`${r.prefix}${t}`)}function Zt(t,e="utf8"){const r=yd[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var md={},iw="elliptic",nw="6.6.1",sw="EC cryptography",ow="lib/elliptic.js",aw=["lib"],fw={lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},cw={type:"git",url:"git@github.com:indutny/elliptic"},hw=["EC","Elliptic","curve","Cryptography"],uw="Fedor Indutny <fedor@indutny.com>",dw="MIT",lw={url:"https://github.com/indutny/elliptic/issues"},pw="https://github.com/indutny/elliptic",gw={brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},bw={"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"},vw={name:iw,version:nw,description:sw,main:ow,files:aw,scripts:fw,repository:cw,keywords:hw,author:uw,license:dw,bugs:lw,homepage:pw,devDependencies:gw,dependencies:bw},pr={},ei={exports:{}};(function(t){(function(e,r){function i(O,g){if(!O)throw new Error(g||"Assertion failed")}function n(O,g){O.super_=g;var p=function(){};p.prototype=g.prototype,O.prototype=new p,O.prototype.constructor=O}function s(O,g,p){if(s.isBN(O))return O;this.negative=0,this.words=null,this.length=0,this.red=null,O!==null&&((g==="le"||g==="be")&&(p=g,g=10),this._init(O||0,g||10,p||"be"))}typeof e=="object"?e.exports=s:r.BN=s,s.BN=s,s.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Qa.Buffer}catch{}s.isBN=function(g){return g instanceof s?!0:g!==null&&typeof g=="object"&&g.constructor.wordSize===s.wordSize&&Array.isArray(g.words)},s.max=function(g,p){return g.cmp(p)>0?g:p},s.min=function(g,p){return g.cmp(p)<0?g:p},s.prototype._init=function(g,p,f){if(typeof g=="number")return this._initNumber(g,p,f);if(typeof g=="object")return this._initArray(g,p,f);p==="hex"&&(p=16),i(p===(p|0)&&p>=2&&p<=36),g=g.toString().replace(/\s+/g,"");var u=0;g[0]==="-"&&(u++,this.negative=1),u<g.length&&(p===16?this._parseHex(g,u,f):(this._parseBase(g,p,u),f==="le"&&this._initArray(this.toArray(),p,f)))},s.prototype._initNumber=function(g,p,f){g<0&&(this.negative=1,g=-g),g<67108864?(this.words=[g&67108863],this.length=1):g<4503599627370496?(this.words=[g&67108863,g/67108864&67108863],this.length=2):(i(g<9007199254740992),this.words=[g&67108863,g/67108864&67108863,1],this.length=3),f==="le"&&this._initArray(this.toArray(),p,f)},s.prototype._initArray=function(g,p,f){if(i(typeof g.length=="number"),g.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(g.length/3),this.words=new Array(this.length);for(var u=0;u<this.length;u++)this.words[u]=0;var b,_,E=0;if(f==="be")for(u=g.length-1,b=0;u>=0;u-=3)_=g[u]|g[u-1]<<8|g[u-2]<<16,this.words[b]|=_<<E&67108863,this.words[b+1]=_>>>26-E&67108863,E+=24,E>=26&&(E-=26,b++);else if(f==="le")for(u=0,b=0;u<g.length;u+=3)_=g[u]|g[u+1]<<8|g[u+2]<<16,this.words[b]|=_<<E&67108863,this.words[b+1]=_>>>26-E&67108863,E+=24,E>=26&&(E-=26,b++);return this.strip()};function a(O,g){var p=O.charCodeAt(g);return p>=65&&p<=70?p-55:p>=97&&p<=102?p-87:p-48&15}function c(O,g,p){var f=a(O,p);return p-1>=g&&(f|=a(O,p-1)<<4),f}s.prototype._parseHex=function(g,p,f){this.length=Math.ceil((g.length-p)/6),this.words=new Array(this.length);for(var u=0;u<this.length;u++)this.words[u]=0;var b=0,_=0,E;if(f==="be")for(u=g.length-1;u>=p;u-=2)E=c(g,p,u)<<b,this.words[_]|=E&67108863,b>=18?(b-=18,_+=1,this.words[_]|=E>>>26):b+=8;else{var w=g.length-p;for(u=w%2===0?p+1:p;u<g.length;u+=2)E=c(g,p,u)<<b,this.words[_]|=E&67108863,b>=18?(b-=18,_+=1,this.words[_]|=E>>>26):b+=8}this.strip()};function h(O,g,p,f){for(var u=0,b=Math.min(O.length,p),_=g;_<b;_++){var E=O.charCodeAt(_)-48;u*=f,E>=49?u+=E-49+10:E>=17?u+=E-17+10:u+=E}return u}s.prototype._parseBase=function(g,p,f){this.words=[0],this.length=1;for(var u=0,b=1;b<=67108863;b*=p)u++;u--,b=b/p|0;for(var _=g.length-f,E=_%u,w=Math.min(_,_-E)+f,d=0,m=f;m<w;m+=u)d=h(g,m,m+u,p),this.imuln(b),this.words[0]+d<67108864?this.words[0]+=d:this._iaddn(d);if(E!==0){var v=1;for(d=h(g,m,g.length,p),m=0;m<E;m++)v*=p;this.imuln(v),this.words[0]+d<67108864?this.words[0]+=d:this._iaddn(d)}this.strip()},s.prototype.copy=function(g){g.words=new Array(this.length);for(var p=0;p<this.length;p++)g.words[p]=this.words[p];g.length=this.length,g.negative=this.negative,g.red=this.red},s.prototype.clone=function(){var g=new s(null);return this.copy(g),g},s.prototype._expand=function(g){for(;this.length<g;)this.words[this.length++]=0;return this},s.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},s.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var l=["","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"],y=[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],M=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];s.prototype.toString=function(g,p){g=g||10,p=p|0||1;var f;if(g===16||g==="hex"){f="";for(var u=0,b=0,_=0;_<this.length;_++){var E=this.words[_],w=((E<<u|b)&16777215).toString(16);b=E>>>24-u&16777215,u+=2,u>=26&&(u-=26,_--),b!==0||_!==this.length-1?f=l[6-w.length]+w+f:f=w+f}for(b!==0&&(f=b.toString(16)+f);f.length%p!==0;)f="0"+f;return this.negative!==0&&(f="-"+f),f}if(g===(g|0)&&g>=2&&g<=36){var d=y[g],m=M[g];f="";var v=this.clone();for(v.negative=0;!v.isZero();){var A=v.modn(m).toString(g);v=v.idivn(m),v.isZero()?f=A+f:f=l[d-A.length]+A+f}for(this.isZero()&&(f="0"+f);f.length%p!==0;)f="0"+f;return this.negative!==0&&(f="-"+f),f}i(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var g=this.words[0];return this.length===2?g+=this.words[1]*67108864:this.length===3&&this.words[2]===1?g+=4503599627370496+this.words[1]*67108864:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-g:g},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(g,p){return i(typeof o<"u"),this.toArrayLike(o,g,p)},s.prototype.toArray=function(g,p){return this.toArrayLike(Array,g,p)},s.prototype.toArrayLike=function(g,p,f){var u=this.byteLength(),b=f||Math.max(1,u);i(u<=b,"byte array longer than desired length"),i(b>0,"Requested array length <= 0"),this.strip();var _=p==="le",E=new g(b),w,d,m=this.clone();if(_){for(d=0;!m.isZero();d++)w=m.andln(255),m.iushrn(8),E[d]=w;for(;d<b;d++)E[d]=0}else{for(d=0;d<b-u;d++)E[d]=0;for(d=0;!m.isZero();d++)w=m.andln(255),m.iushrn(8),E[b-d-1]=w}return E},Math.clz32?s.prototype._countBits=function(g){return 32-Math.clz32(g)}:s.prototype._countBits=function(g){var p=g,f=0;return p>=4096&&(f+=13,p>>>=13),p>=64&&(f+=7,p>>>=7),p>=8&&(f+=4,p>>>=4),p>=2&&(f+=2,p>>>=2),f+p},s.prototype._zeroBits=function(g){if(g===0)return 26;var p=g,f=0;return p&8191||(f+=13,p>>>=13),p&127||(f+=7,p>>>=7),p&15||(f+=4,p>>>=4),p&3||(f+=2,p>>>=2),p&1||f++,f},s.prototype.bitLength=function(){var g=this.words[this.length-1],p=this._countBits(g);return(this.length-1)*26+p};function I(O){for(var g=new Array(O.bitLength()),p=0;p<g.length;p++){var f=p/26|0,u=p%26;g[p]=(O.words[f]&1<<u)>>>u}return g}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var g=0,p=0;p<this.length;p++){var f=this._zeroBits(this.words[p]);if(g+=f,f!==26)break}return g},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(g){return this.negative!==0?this.abs().inotn(g).iaddn(1):this.clone()},s.prototype.fromTwos=function(g){return this.testn(g-1)?this.notn(g).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return this.negative!==0},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(g){for(;this.length<g.length;)this.words[this.length++]=0;for(var p=0;p<g.length;p++)this.words[p]=this.words[p]|g.words[p];return this.strip()},s.prototype.ior=function(g){return i((this.negative|g.negative)===0),this.iuor(g)},s.prototype.or=function(g){return this.length>g.length?this.clone().ior(g):g.clone().ior(this)},s.prototype.uor=function(g){return this.length>g.length?this.clone().iuor(g):g.clone().iuor(this)},s.prototype.iuand=function(g){var p;this.length>g.length?p=g:p=this;for(var f=0;f<p.length;f++)this.words[f]=this.words[f]&g.words[f];return this.length=p.length,this.strip()},s.prototype.iand=function(g){return i((this.negative|g.negative)===0),this.iuand(g)},s.prototype.and=function(g){return this.length>g.length?this.clone().iand(g):g.clone().iand(this)},s.prototype.uand=function(g){return this.length>g.length?this.clone().iuand(g):g.clone().iuand(this)},s.prototype.iuxor=function(g){var p,f;this.length>g.length?(p=this,f=g):(p=g,f=this);for(var u=0;u<f.length;u++)this.words[u]=p.words[u]^f.words[u];if(this!==p)for(;u<p.length;u++)this.words[u]=p.words[u];return this.length=p.length,this.strip()},s.prototype.ixor=function(g){return i((this.negative|g.negative)===0),this.iuxor(g)},s.prototype.xor=function(g){return this.length>g.length?this.clone().ixor(g):g.clone().ixor(this)},s.prototype.uxor=function(g){return this.length>g.length?this.clone().iuxor(g):g.clone().iuxor(this)},s.prototype.inotn=function(g){i(typeof g=="number"&&g>=0);var p=Math.ceil(g/26)|0,f=g%26;this._expand(p),f>0&&p--;for(var u=0;u<p;u++)this.words[u]=~this.words[u]&67108863;return f>0&&(this.words[u]=~this.words[u]&67108863>>26-f),this.strip()},s.prototype.notn=function(g){return this.clone().inotn(g)},s.prototype.setn=function(g,p){i(typeof g=="number"&&g>=0);var f=g/26|0,u=g%26;return this._expand(f+1),p?this.words[f]=this.words[f]|1<<u:this.words[f]=this.words[f]&~(1<<u),this.strip()},s.prototype.iadd=function(g){var p;if(this.negative!==0&&g.negative===0)return this.negative=0,p=this.isub(g),this.negative^=1,this._normSign();if(this.negative===0&&g.negative!==0)return g.negative=0,p=this.isub(g),g.negative=1,p._normSign();var f,u;this.length>g.length?(f=this,u=g):(f=g,u=this);for(var b=0,_=0;_<u.length;_++)p=(f.words[_]|0)+(u.words[_]|0)+b,this.words[_]=p&67108863,b=p>>>26;for(;b!==0&&_<f.length;_++)p=(f.words[_]|0)+b,this.words[_]=p&67108863,b=p>>>26;if(this.length=f.length,b!==0)this.words[this.length]=b,this.length++;else if(f!==this)for(;_<f.length;_++)this.words[_]=f.words[_];return this},s.prototype.add=function(g){var p;return g.negative!==0&&this.negative===0?(g.negative=0,p=this.sub(g),g.negative^=1,p):g.negative===0&&this.negative!==0?(this.negative=0,p=g.sub(this),this.negative=1,p):this.length>g.length?this.clone().iadd(g):g.clone().iadd(this)},s.prototype.isub=function(g){if(g.negative!==0){g.negative=0;var p=this.iadd(g);return g.negative=1,p._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(g),this.negative=1,this._normSign();var f=this.cmp(g);if(f===0)return this.negative=0,this.length=1,this.words[0]=0,this;var u,b;f>0?(u=this,b=g):(u=g,b=this);for(var _=0,E=0;E<b.length;E++)p=(u.words[E]|0)-(b.words[E]|0)+_,_=p>>26,this.words[E]=p&67108863;for(;_!==0&&E<u.length;E++)p=(u.words[E]|0)+_,_=p>>26,this.words[E]=p&67108863;if(_===0&&E<u.length&&u!==this)for(;E<u.length;E++)this.words[E]=u.words[E];return this.length=Math.max(this.length,E),u!==this&&(this.negative=1),this.strip()},s.prototype.sub=function(g){return this.clone().isub(g)};function S(O,g,p){p.negative=g.negative^O.negative;var f=O.length+g.length|0;p.length=f,f=f-1|0;var u=O.words[0]|0,b=g.words[0]|0,_=u*b,E=_&67108863,w=_/67108864|0;p.words[0]=E;for(var d=1;d<f;d++){for(var m=w>>>26,v=w&67108863,A=Math.min(d,g.length-1),U=Math.max(0,d-O.length+1);U<=A;U++){var x=d-U|0;u=O.words[x]|0,b=g.words[U]|0,_=u*b+v,m+=_/67108864|0,v=_&67108863}p.words[d]=v|0,w=m|0}return w!==0?p.words[d]=w|0:p.length--,p.strip()}var D=function(g,p,f){var u=g.words,b=p.words,_=f.words,E=0,w,d,m,v=u[0]|0,A=v&8191,U=v>>>13,x=u[1]|0,N=x&8191,B=x>>>13,q=u[2]|0,z=q&8191,J=q>>>13,X=u[3]|0,W=X&8191,ne=X>>>13,Q=u[4]|0,ee=Q&8191,qe=Q>>>13,Ue=u[5]|0,he=Ue&8191,Pe=Ue>>>13,Re=u[6]|0,ae=Re&8191,$e=Re>>>13,Ne=u[7]|0,ce=Ne&8191,Te=Ne>>>13,Fe=u[8]|0,oe=Fe&8191,De=Fe>>>13,Ce=u[9]|0,ie=Ce&8191,Ve=Ce>>>13,He=b[0]|0,pe=He&8191,We=He>>>13,Be=b[1]|0,de=Be&8191,Ge=Be>>>13,Xe=b[2]|0,se=Xe&8191,Je=Xe>>>13,Ze=b[3]|0,ge=Ze&8191,ze=Ze>>>13,Oe=b[4]|0,ue=Oe&8191,ke=Oe>>>13,je=b[5]|0,fe=je&8191,Qe=je>>>13,et=b[6]|0,be=et&8191,tt=et>>>13,rt=b[7]|0,le=rt&8191,Ke=rt>>>13,Ae=b[8]|0,ve=Ae&8191,it=Ae>>>13,nt=b[9]|0,ye=nt&8191,st=nt>>>13;f.negative=g.negative^p.negative,f.length=19,w=Math.imul(A,pe),d=Math.imul(A,We),d=d+Math.imul(U,pe)|0,m=Math.imul(U,We);var xe=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(xe>>>26)|0,xe&=67108863,w=Math.imul(N,pe),d=Math.imul(N,We),d=d+Math.imul(B,pe)|0,m=Math.imul(B,We),w=w+Math.imul(A,de)|0,d=d+Math.imul(A,Ge)|0,d=d+Math.imul(U,de)|0,m=m+Math.imul(U,Ge)|0;var Ye=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(Ye>>>26)|0,Ye&=67108863,w=Math.imul(z,pe),d=Math.imul(z,We),d=d+Math.imul(J,pe)|0,m=Math.imul(J,We),w=w+Math.imul(N,de)|0,d=d+Math.imul(N,Ge)|0,d=d+Math.imul(B,de)|0,m=m+Math.imul(B,Ge)|0,w=w+Math.imul(A,se)|0,d=d+Math.imul(A,Je)|0,d=d+Math.imul(U,se)|0,m=m+Math.imul(U,Je)|0;var ar=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(ar>>>26)|0,ar&=67108863,w=Math.imul(W,pe),d=Math.imul(W,We),d=d+Math.imul(ne,pe)|0,m=Math.imul(ne,We),w=w+Math.imul(z,de)|0,d=d+Math.imul(z,Ge)|0,d=d+Math.imul(J,de)|0,m=m+Math.imul(J,Ge)|0,w=w+Math.imul(N,se)|0,d=d+Math.imul(N,Je)|0,d=d+Math.imul(B,se)|0,m=m+Math.imul(B,Je)|0,w=w+Math.imul(A,ge)|0,d=d+Math.imul(A,ze)|0,d=d+Math.imul(U,ge)|0,m=m+Math.imul(U,ze)|0;var fr=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(fr>>>26)|0,fr&=67108863,w=Math.imul(ee,pe),d=Math.imul(ee,We),d=d+Math.imul(qe,pe)|0,m=Math.imul(qe,We),w=w+Math.imul(W,de)|0,d=d+Math.imul(W,Ge)|0,d=d+Math.imul(ne,de)|0,m=m+Math.imul(ne,Ge)|0,w=w+Math.imul(z,se)|0,d=d+Math.imul(z,Je)|0,d=d+Math.imul(J,se)|0,m=m+Math.imul(J,Je)|0,w=w+Math.imul(N,ge)|0,d=d+Math.imul(N,ze)|0,d=d+Math.imul(B,ge)|0,m=m+Math.imul(B,ze)|0,w=w+Math.imul(A,ue)|0,d=d+Math.imul(A,ke)|0,d=d+Math.imul(U,ue)|0,m=m+Math.imul(U,ke)|0;var cr=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(cr>>>26)|0,cr&=67108863,w=Math.imul(he,pe),d=Math.imul(he,We),d=d+Math.imul(Pe,pe)|0,m=Math.imul(Pe,We),w=w+Math.imul(ee,de)|0,d=d+Math.imul(ee,Ge)|0,d=d+Math.imul(qe,de)|0,m=m+Math.imul(qe,Ge)|0,w=w+Math.imul(W,se)|0,d=d+Math.imul(W,Je)|0,d=d+Math.imul(ne,se)|0,m=m+Math.imul(ne,Je)|0,w=w+Math.imul(z,ge)|0,d=d+Math.imul(z,ze)|0,d=d+Math.imul(J,ge)|0,m=m+Math.imul(J,ze)|0,w=w+Math.imul(N,ue)|0,d=d+Math.imul(N,ke)|0,d=d+Math.imul(B,ue)|0,m=m+Math.imul(B,ke)|0,w=w+Math.imul(A,fe)|0,d=d+Math.imul(A,Qe)|0,d=d+Math.imul(U,fe)|0,m=m+Math.imul(U,Qe)|0;var hr=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(hr>>>26)|0,hr&=67108863,w=Math.imul(ae,pe),d=Math.imul(ae,We),d=d+Math.imul($e,pe)|0,m=Math.imul($e,We),w=w+Math.imul(he,de)|0,d=d+Math.imul(he,Ge)|0,d=d+Math.imul(Pe,de)|0,m=m+Math.imul(Pe,Ge)|0,w=w+Math.imul(ee,se)|0,d=d+Math.imul(ee,Je)|0,d=d+Math.imul(qe,se)|0,m=m+Math.imul(qe,Je)|0,w=w+Math.imul(W,ge)|0,d=d+Math.imul(W,ze)|0,d=d+Math.imul(ne,ge)|0,m=m+Math.imul(ne,ze)|0,w=w+Math.imul(z,ue)|0,d=d+Math.imul(z,ke)|0,d=d+Math.imul(J,ue)|0,m=m+Math.imul(J,ke)|0,w=w+Math.imul(N,fe)|0,d=d+Math.imul(N,Qe)|0,d=d+Math.imul(B,fe)|0,m=m+Math.imul(B,Qe)|0,w=w+Math.imul(A,be)|0,d=d+Math.imul(A,tt)|0,d=d+Math.imul(U,be)|0,m=m+Math.imul(U,tt)|0;var wt=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(wt>>>26)|0,wt&=67108863,w=Math.imul(ce,pe),d=Math.imul(ce,We),d=d+Math.imul(Te,pe)|0,m=Math.imul(Te,We),w=w+Math.imul(ae,de)|0,d=d+Math.imul(ae,Ge)|0,d=d+Math.imul($e,de)|0,m=m+Math.imul($e,Ge)|0,w=w+Math.imul(he,se)|0,d=d+Math.imul(he,Je)|0,d=d+Math.imul(Pe,se)|0,m=m+Math.imul(Pe,Je)|0,w=w+Math.imul(ee,ge)|0,d=d+Math.imul(ee,ze)|0,d=d+Math.imul(qe,ge)|0,m=m+Math.imul(qe,ze)|0,w=w+Math.imul(W,ue)|0,d=d+Math.imul(W,ke)|0,d=d+Math.imul(ne,ue)|0,m=m+Math.imul(ne,ke)|0,w=w+Math.imul(z,fe)|0,d=d+Math.imul(z,Qe)|0,d=d+Math.imul(J,fe)|0,m=m+Math.imul(J,Qe)|0,w=w+Math.imul(N,be)|0,d=d+Math.imul(N,tt)|0,d=d+Math.imul(B,be)|0,m=m+Math.imul(B,tt)|0,w=w+Math.imul(A,le)|0,d=d+Math.imul(A,Ke)|0,d=d+Math.imul(U,le)|0,m=m+Math.imul(U,Ke)|0;var xi=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(xi>>>26)|0,xi&=67108863,w=Math.imul(oe,pe),d=Math.imul(oe,We),d=d+Math.imul(De,pe)|0,m=Math.imul(De,We),w=w+Math.imul(ce,de)|0,d=d+Math.imul(ce,Ge)|0,d=d+Math.imul(Te,de)|0,m=m+Math.imul(Te,Ge)|0,w=w+Math.imul(ae,se)|0,d=d+Math.imul(ae,Je)|0,d=d+Math.imul($e,se)|0,m=m+Math.imul($e,Je)|0,w=w+Math.imul(he,ge)|0,d=d+Math.imul(he,ze)|0,d=d+Math.imul(Pe,ge)|0,m=m+Math.imul(Pe,ze)|0,w=w+Math.imul(ee,ue)|0,d=d+Math.imul(ee,ke)|0,d=d+Math.imul(qe,ue)|0,m=m+Math.imul(qe,ke)|0,w=w+Math.imul(W,fe)|0,d=d+Math.imul(W,Qe)|0,d=d+Math.imul(ne,fe)|0,m=m+Math.imul(ne,Qe)|0,w=w+Math.imul(z,be)|0,d=d+Math.imul(z,tt)|0,d=d+Math.imul(J,be)|0,m=m+Math.imul(J,tt)|0,w=w+Math.imul(N,le)|0,d=d+Math.imul(N,Ke)|0,d=d+Math.imul(B,le)|0,m=m+Math.imul(B,Ke)|0,w=w+Math.imul(A,ve)|0,d=d+Math.imul(A,it)|0,d=d+Math.imul(U,ve)|0,m=m+Math.imul(U,it)|0;var Ei=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(Ei>>>26)|0,Ei&=67108863,w=Math.imul(ie,pe),d=Math.imul(ie,We),d=d+Math.imul(Ve,pe)|0,m=Math.imul(Ve,We),w=w+Math.imul(oe,de)|0,d=d+Math.imul(oe,Ge)|0,d=d+Math.imul(De,de)|0,m=m+Math.imul(De,Ge)|0,w=w+Math.imul(ce,se)|0,d=d+Math.imul(ce,Je)|0,d=d+Math.imul(Te,se)|0,m=m+Math.imul(Te,Je)|0,w=w+Math.imul(ae,ge)|0,d=d+Math.imul(ae,ze)|0,d=d+Math.imul($e,ge)|0,m=m+Math.imul($e,ze)|0,w=w+Math.imul(he,ue)|0,d=d+Math.imul(he,ke)|0,d=d+Math.imul(Pe,ue)|0,m=m+Math.imul(Pe,ke)|0,w=w+Math.imul(ee,fe)|0,d=d+Math.imul(ee,Qe)|0,d=d+Math.imul(qe,fe)|0,m=m+Math.imul(qe,Qe)|0,w=w+Math.imul(W,be)|0,d=d+Math.imul(W,tt)|0,d=d+Math.imul(ne,be)|0,m=m+Math.imul(ne,tt)|0,w=w+Math.imul(z,le)|0,d=d+Math.imul(z,Ke)|0,d=d+Math.imul(J,le)|0,m=m+Math.imul(J,Ke)|0,w=w+Math.imul(N,ve)|0,d=d+Math.imul(N,it)|0,d=d+Math.imul(B,ve)|0,m=m+Math.imul(B,it)|0,w=w+Math.imul(A,ye)|0,d=d+Math.imul(A,st)|0,d=d+Math.imul(U,ye)|0,m=m+Math.imul(U,st)|0;var Si=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(Si>>>26)|0,Si&=67108863,w=Math.imul(ie,de),d=Math.imul(ie,Ge),d=d+Math.imul(Ve,de)|0,m=Math.imul(Ve,Ge),w=w+Math.imul(oe,se)|0,d=d+Math.imul(oe,Je)|0,d=d+Math.imul(De,se)|0,m=m+Math.imul(De,Je)|0,w=w+Math.imul(ce,ge)|0,d=d+Math.imul(ce,ze)|0,d=d+Math.imul(Te,ge)|0,m=m+Math.imul(Te,ze)|0,w=w+Math.imul(ae,ue)|0,d=d+Math.imul(ae,ke)|0,d=d+Math.imul($e,ue)|0,m=m+Math.imul($e,ke)|0,w=w+Math.imul(he,fe)|0,d=d+Math.imul(he,Qe)|0,d=d+Math.imul(Pe,fe)|0,m=m+Math.imul(Pe,Qe)|0,w=w+Math.imul(ee,be)|0,d=d+Math.imul(ee,tt)|0,d=d+Math.imul(qe,be)|0,m=m+Math.imul(qe,tt)|0,w=w+Math.imul(W,le)|0,d=d+Math.imul(W,Ke)|0,d=d+Math.imul(ne,le)|0,m=m+Math.imul(ne,Ke)|0,w=w+Math.imul(z,ve)|0,d=d+Math.imul(z,it)|0,d=d+Math.imul(J,ve)|0,m=m+Math.imul(J,it)|0,w=w+Math.imul(N,ye)|0,d=d+Math.imul(N,st)|0,d=d+Math.imul(B,ye)|0,m=m+Math.imul(B,st)|0;var Mi=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(Mi>>>26)|0,Mi&=67108863,w=Math.imul(ie,se),d=Math.imul(ie,Je),d=d+Math.imul(Ve,se)|0,m=Math.imul(Ve,Je),w=w+Math.imul(oe,ge)|0,d=d+Math.imul(oe,ze)|0,d=d+Math.imul(De,ge)|0,m=m+Math.imul(De,ze)|0,w=w+Math.imul(ce,ue)|0,d=d+Math.imul(ce,ke)|0,d=d+Math.imul(Te,ue)|0,m=m+Math.imul(Te,ke)|0,w=w+Math.imul(ae,fe)|0,d=d+Math.imul(ae,Qe)|0,d=d+Math.imul($e,fe)|0,m=m+Math.imul($e,Qe)|0,w=w+Math.imul(he,be)|0,d=d+Math.imul(he,tt)|0,d=d+Math.imul(Pe,be)|0,m=m+Math.imul(Pe,tt)|0,w=w+Math.imul(ee,le)|0,d=d+Math.imul(ee,Ke)|0,d=d+Math.imul(qe,le)|0,m=m+Math.imul(qe,Ke)|0,w=w+Math.imul(W,ve)|0,d=d+Math.imul(W,it)|0,d=d+Math.imul(ne,ve)|0,m=m+Math.imul(ne,it)|0,w=w+Math.imul(z,ye)|0,d=d+Math.imul(z,st)|0,d=d+Math.imul(J,ye)|0,m=m+Math.imul(J,st)|0;var Ii=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(Ii>>>26)|0,Ii&=67108863,w=Math.imul(ie,ge),d=Math.imul(ie,ze),d=d+Math.imul(Ve,ge)|0,m=Math.imul(Ve,ze),w=w+Math.imul(oe,ue)|0,d=d+Math.imul(oe,ke)|0,d=d+Math.imul(De,ue)|0,m=m+Math.imul(De,ke)|0,w=w+Math.imul(ce,fe)|0,d=d+Math.imul(ce,Qe)|0,d=d+Math.imul(Te,fe)|0,m=m+Math.imul(Te,Qe)|0,w=w+Math.imul(ae,be)|0,d=d+Math.imul(ae,tt)|0,d=d+Math.imul($e,be)|0,m=m+Math.imul($e,tt)|0,w=w+Math.imul(he,le)|0,d=d+Math.imul(he,Ke)|0,d=d+Math.imul(Pe,le)|0,m=m+Math.imul(Pe,Ke)|0,w=w+Math.imul(ee,ve)|0,d=d+Math.imul(ee,it)|0,d=d+Math.imul(qe,ve)|0,m=m+Math.imul(qe,it)|0,w=w+Math.imul(W,ye)|0,d=d+Math.imul(W,st)|0,d=d+Math.imul(ne,ye)|0,m=m+Math.imul(ne,st)|0;var Pr=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(Pr>>>26)|0,Pr&=67108863,w=Math.imul(ie,ue),d=Math.imul(ie,ke),d=d+Math.imul(Ve,ue)|0,m=Math.imul(Ve,ke),w=w+Math.imul(oe,fe)|0,d=d+Math.imul(oe,Qe)|0,d=d+Math.imul(De,fe)|0,m=m+Math.imul(De,Qe)|0,w=w+Math.imul(ce,be)|0,d=d+Math.imul(ce,tt)|0,d=d+Math.imul(Te,be)|0,m=m+Math.imul(Te,tt)|0,w=w+Math.imul(ae,le)|0,d=d+Math.imul(ae,Ke)|0,d=d+Math.imul($e,le)|0,m=m+Math.imul($e,Ke)|0,w=w+Math.imul(he,ve)|0,d=d+Math.imul(he,it)|0,d=d+Math.imul(Pe,ve)|0,m=m+Math.imul(Pe,it)|0,w=w+Math.imul(ee,ye)|0,d=d+Math.imul(ee,st)|0,d=d+Math.imul(qe,ye)|0,m=m+Math.imul(qe,st)|0;var Ai=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(Ai>>>26)|0,Ai&=67108863,w=Math.imul(ie,fe),d=Math.imul(ie,Qe),d=d+Math.imul(Ve,fe)|0,m=Math.imul(Ve,Qe),w=w+Math.imul(oe,be)|0,d=d+Math.imul(oe,tt)|0,d=d+Math.imul(De,be)|0,m=m+Math.imul(De,tt)|0,w=w+Math.imul(ce,le)|0,d=d+Math.imul(ce,Ke)|0,d=d+Math.imul(Te,le)|0,m=m+Math.imul(Te,Ke)|0,w=w+Math.imul(ae,ve)|0,d=d+Math.imul(ae,it)|0,d=d+Math.imul($e,ve)|0,m=m+Math.imul($e,it)|0,w=w+Math.imul(he,ye)|0,d=d+Math.imul(he,st)|0,d=d+Math.imul(Pe,ye)|0,m=m+Math.imul(Pe,st)|0;var Di=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(Di>>>26)|0,Di&=67108863,w=Math.imul(ie,be),d=Math.imul(ie,tt),d=d+Math.imul(Ve,be)|0,m=Math.imul(Ve,tt),w=w+Math.imul(oe,le)|0,d=d+Math.imul(oe,Ke)|0,d=d+Math.imul(De,le)|0,m=m+Math.imul(De,Ke)|0,w=w+Math.imul(ce,ve)|0,d=d+Math.imul(ce,it)|0,d=d+Math.imul(Te,ve)|0,m=m+Math.imul(Te,it)|0,w=w+Math.imul(ae,ye)|0,d=d+Math.imul(ae,st)|0,d=d+Math.imul($e,ye)|0,m=m+Math.imul($e,st)|0;var Wt=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(Wt>>>26)|0,Wt&=67108863,w=Math.imul(ie,le),d=Math.imul(ie,Ke),d=d+Math.imul(Ve,le)|0,m=Math.imul(Ve,Ke),w=w+Math.imul(oe,ve)|0,d=d+Math.imul(oe,it)|0,d=d+Math.imul(De,ve)|0,m=m+Math.imul(De,it)|0,w=w+Math.imul(ce,ye)|0,d=d+Math.imul(ce,st)|0,d=d+Math.imul(Te,ye)|0,m=m+Math.imul(Te,st)|0;var Oi=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(Oi>>>26)|0,Oi&=67108863,w=Math.imul(ie,ve),d=Math.imul(ie,it),d=d+Math.imul(Ve,ve)|0,m=Math.imul(Ve,it),w=w+Math.imul(oe,ye)|0,d=d+Math.imul(oe,st)|0,d=d+Math.imul(De,ye)|0,m=m+Math.imul(De,st)|0;var Pi=(E+w|0)+((d&8191)<<13)|0;E=(m+(d>>>13)|0)+(Pi>>>26)|0,Pi&=67108863,w=Math.imul(ie,ye),d=Math.imul(ie,st),d=d+Math.imul(Ve,ye)|0,m=Math.imul(Ve,st);var Ri=(E+w|0)+((d&8191)<<13)|0;return E=(m+(d>>>13)|0)+(Ri>>>26)|0,Ri&=67108863,_[0]=xe,_[1]=Ye,_[2]=ar,_[3]=fr,_[4]=cr,_[5]=hr,_[6]=wt,_[7]=xi,_[8]=Ei,_[9]=Si,_[10]=Mi,_[11]=Ii,_[12]=Pr,_[13]=Ai,_[14]=Di,_[15]=Wt,_[16]=Oi,_[17]=Pi,_[18]=Ri,E!==0&&(_[19]=E,f.length++),f};Math.imul||(D=S);function R(O,g,p){p.negative=g.negative^O.negative,p.length=O.length+g.length;for(var f=0,u=0,b=0;b<p.length-1;b++){var _=u;u=0;for(var E=f&67108863,w=Math.min(b,g.length-1),d=Math.max(0,b-O.length+1);d<=w;d++){var m=b-d,v=O.words[m]|0,A=g.words[d]|0,U=v*A,x=U&67108863;_=_+(U/67108864|0)|0,x=x+E|0,E=x&67108863,_=_+(x>>>26)|0,u+=_>>>26,_&=67108863}p.words[b]=E,f=_,_=u}return f!==0?p.words[b]=f:p.length--,p.strip()}function $(O,g,p){var f=new T;return f.mulp(O,g,p)}s.prototype.mulTo=function(g,p){var f,u=this.length+g.length;return this.length===10&&g.length===10?f=D(this,g,p):u<63?f=S(this,g,p):u<1024?f=R(this,g,p):f=$(this,g,p),f};function T(O,g){this.x=O,this.y=g}T.prototype.makeRBT=function(g){for(var p=new Array(g),f=s.prototype._countBits(g)-1,u=0;u<g;u++)p[u]=this.revBin(u,f,g);return p},T.prototype.revBin=function(g,p,f){if(g===0||g===f-1)return g;for(var u=0,b=0;b<p;b++)u|=(g&1)<<p-b-1,g>>=1;return u},T.prototype.permute=function(g,p,f,u,b,_){for(var E=0;E<_;E++)u[E]=p[g[E]],b[E]=f[g[E]]},T.prototype.transform=function(g,p,f,u,b,_){this.permute(_,g,p,f,u,b);for(var E=1;E<b;E<<=1)for(var w=E<<1,d=Math.cos(2*Math.PI/w),m=Math.sin(2*Math.PI/w),v=0;v<b;v+=w)for(var A=d,U=m,x=0;x<E;x++){var N=f[v+x],B=u[v+x],q=f[v+x+E],z=u[v+x+E],J=A*q-U*z;z=A*z+U*q,q=J,f[v+x]=N+q,u[v+x]=B+z,f[v+x+E]=N-q,u[v+x+E]=B-z,x!==w&&(J=d*A-m*U,U=d*U+m*A,A=J)}},T.prototype.guessLen13b=function(g,p){var f=Math.max(p,g)|1,u=f&1,b=0;for(f=f/2|0;f;f=f>>>1)b++;return 1<<b+1+u},T.prototype.conjugate=function(g,p,f){if(!(f<=1))for(var u=0;u<f/2;u++){var b=g[u];g[u]=g[f-u-1],g[f-u-1]=b,b=p[u],p[u]=-p[f-u-1],p[f-u-1]=-b}},T.prototype.normalize13b=function(g,p){for(var f=0,u=0;u<p/2;u++){var b=Math.round(g[2*u+1]/p)*8192+Math.round(g[2*u]/p)+f;g[u]=b&67108863,b<67108864?f=0:f=b/67108864|0}return g},T.prototype.convert13b=function(g,p,f,u){for(var b=0,_=0;_<p;_++)b=b+(g[_]|0),f[2*_]=b&8191,b=b>>>13,f[2*_+1]=b&8191,b=b>>>13;for(_=2*p;_<u;++_)f[_]=0;i(b===0),i((b&-8192)===0)},T.prototype.stub=function(g){for(var p=new Array(g),f=0;f<g;f++)p[f]=0;return p},T.prototype.mulp=function(g,p,f){var u=2*this.guessLen13b(g.length,p.length),b=this.makeRBT(u),_=this.stub(u),E=new Array(u),w=new Array(u),d=new Array(u),m=new Array(u),v=new Array(u),A=new Array(u),U=f.words;U.length=u,this.convert13b(g.words,g.length,E,u),this.convert13b(p.words,p.length,m,u),this.transform(E,_,w,d,u,b),this.transform(m,_,v,A,u,b);for(var x=0;x<u;x++){var N=w[x]*v[x]-d[x]*A[x];d[x]=w[x]*A[x]+d[x]*v[x],w[x]=N}return this.conjugate(w,d,u),this.transform(w,d,U,_,u,b),this.conjugate(U,_,u),this.normalize13b(U,u),f.negative=g.negative^p.negative,f.length=g.length+p.length,f.strip()},s.prototype.mul=function(g){var p=new s(null);return p.words=new Array(this.length+g.length),this.mulTo(g,p)},s.prototype.mulf=function(g){var p=new s(null);return p.words=new Array(this.length+g.length),$(this,g,p)},s.prototype.imul=function(g){return this.clone().mulTo(g,this)},s.prototype.imuln=function(g){i(typeof g=="number"),i(g<67108864);for(var p=0,f=0;f<this.length;f++){var u=(this.words[f]|0)*g,b=(u&67108863)+(p&67108863);p>>=26,p+=u/67108864|0,p+=b>>>26,this.words[f]=b&67108863}return p!==0&&(this.words[f]=p,this.length++),this},s.prototype.muln=function(g){return this.clone().imuln(g)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(g){var p=I(g);if(p.length===0)return new s(1);for(var f=this,u=0;u<p.length&&p[u]===0;u++,f=f.sqr());if(++u<p.length)for(var b=f.sqr();u<p.length;u++,b=b.sqr())p[u]!==0&&(f=f.mul(b));return f},s.prototype.iushln=function(g){i(typeof g=="number"&&g>=0);var p=g%26,f=(g-p)/26,u=67108863>>>26-p<<26-p,b;if(p!==0){var _=0;for(b=0;b<this.length;b++){var E=this.words[b]&u,w=(this.words[b]|0)-E<<p;this.words[b]=w|_,_=E>>>26-p}_&&(this.words[b]=_,this.length++)}if(f!==0){for(b=this.length-1;b>=0;b--)this.words[b+f]=this.words[b];for(b=0;b<f;b++)this.words[b]=0;this.length+=f}return this.strip()},s.prototype.ishln=function(g){return i(this.negative===0),this.iushln(g)},s.prototype.iushrn=function(g,p,f){i(typeof g=="number"&&g>=0);var u;p?u=(p-p%26)/26:u=0;var b=g%26,_=Math.min((g-b)/26,this.length),E=67108863^67108863>>>b<<b,w=f;if(u-=_,u=Math.max(0,u),w){for(var d=0;d<_;d++)w.words[d]=this.words[d];w.length=_}if(_!==0)if(this.length>_)for(this.length-=_,d=0;d<this.length;d++)this.words[d]=this.words[d+_];else this.words[0]=0,this.length=1;var m=0;for(d=this.length-1;d>=0&&(m!==0||d>=u);d--){var v=this.words[d]|0;this.words[d]=m<<26-b|v>>>b,m=v&E}return w&&m!==0&&(w.words[w.length++]=m),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(g,p,f){return i(this.negative===0),this.iushrn(g,p,f)},s.prototype.shln=function(g){return this.clone().ishln(g)},s.prototype.ushln=function(g){return this.clone().iushln(g)},s.prototype.shrn=function(g){return this.clone().ishrn(g)},s.prototype.ushrn=function(g){return this.clone().iushrn(g)},s.prototype.testn=function(g){i(typeof g=="number"&&g>=0);var p=g%26,f=(g-p)/26,u=1<<p;if(this.length<=f)return!1;var b=this.words[f];return!!(b&u)},s.prototype.imaskn=function(g){i(typeof g=="number"&&g>=0);var p=g%26,f=(g-p)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=f)return this;if(p!==0&&f++,this.length=Math.min(f,this.length),p!==0){var u=67108863^67108863>>>p<<p;this.words[this.length-1]&=u}return this.strip()},s.prototype.maskn=function(g){return this.clone().imaskn(g)},s.prototype.iaddn=function(g){return i(typeof g=="number"),i(g<67108864),g<0?this.isubn(-g):this.negative!==0?this.length===1&&(this.words[0]|0)<g?(this.words[0]=g-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(g),this.negative=1,this):this._iaddn(g)},s.prototype._iaddn=function(g){this.words[0]+=g;for(var p=0;p<this.length&&this.words[p]>=67108864;p++)this.words[p]-=67108864,p===this.length-1?this.words[p+1]=1:this.words[p+1]++;return this.length=Math.max(this.length,p+1),this},s.prototype.isubn=function(g){if(i(typeof g=="number"),i(g<67108864),g<0)return this.iaddn(-g);if(this.negative!==0)return this.negative=0,this.iaddn(g),this.negative=1,this;if(this.words[0]-=g,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var p=0;p<this.length&&this.words[p]<0;p++)this.words[p]+=67108864,this.words[p+1]-=1;return this.strip()},s.prototype.addn=function(g){return this.clone().iaddn(g)},s.prototype.subn=function(g){return this.clone().isubn(g)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(g,p,f){var u=g.length+f,b;this._expand(u);var _,E=0;for(b=0;b<g.length;b++){_=(this.words[b+f]|0)+E;var w=(g.words[b]|0)*p;_-=w&67108863,E=(_>>26)-(w/67108864|0),this.words[b+f]=_&67108863}for(;b<this.length-f;b++)_=(this.words[b+f]|0)+E,E=_>>26,this.words[b+f]=_&67108863;if(E===0)return this.strip();for(i(E===-1),E=0,b=0;b<this.length;b++)_=-(this.words[b]|0)+E,E=_>>26,this.words[b]=_&67108863;return this.negative=1,this.strip()},s.prototype._wordDiv=function(g,p){var f=this.length-g.length,u=this.clone(),b=g,_=b.words[b.length-1]|0,E=this._countBits(_);f=26-E,f!==0&&(b=b.ushln(f),u.iushln(f),_=b.words[b.length-1]|0);var w=u.length-b.length,d;if(p!=="mod"){d=new s(null),d.length=w+1,d.words=new Array(d.length);for(var m=0;m<d.length;m++)d.words[m]=0}var v=u.clone()._ishlnsubmul(b,1,w);v.negative===0&&(u=v,d&&(d.words[w]=1));for(var A=w-1;A>=0;A--){var U=(u.words[b.length+A]|0)*67108864+(u.words[b.length+A-1]|0);for(U=Math.min(U/_|0,67108863),u._ishlnsubmul(b,U,A);u.negative!==0;)U--,u.negative=0,u._ishlnsubmul(b,1,A),u.isZero()||(u.negative^=1);d&&(d.words[A]=U)}return d&&d.strip(),u.strip(),p!=="div"&&f!==0&&u.iushrn(f),{div:d||null,mod:u}},s.prototype.divmod=function(g,p,f){if(i(!g.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var u,b,_;return this.negative!==0&&g.negative===0?(_=this.neg().divmod(g,p),p!=="mod"&&(u=_.div.neg()),p!=="div"&&(b=_.mod.neg(),f&&b.negative!==0&&b.iadd(g)),{div:u,mod:b}):this.negative===0&&g.negative!==0?(_=this.divmod(g.neg(),p),p!=="mod"&&(u=_.div.neg()),{div:u,mod:_.mod}):this.negative&g.negative?(_=this.neg().divmod(g.neg(),p),p!=="div"&&(b=_.mod.neg(),f&&b.negative!==0&&b.isub(g)),{div:_.div,mod:b}):g.length>this.length||this.cmp(g)<0?{div:new s(0),mod:this}:g.length===1?p==="div"?{div:this.divn(g.words[0]),mod:null}:p==="mod"?{div:null,mod:new s(this.modn(g.words[0]))}:{div:this.divn(g.words[0]),mod:new s(this.modn(g.words[0]))}:this._wordDiv(g,p)},s.prototype.div=function(g){return this.divmod(g,"div",!1).div},s.prototype.mod=function(g){return this.divmod(g,"mod",!1).mod},s.prototype.umod=function(g){return this.divmod(g,"mod",!0).mod},s.prototype.divRound=function(g){var p=this.divmod(g);if(p.mod.isZero())return p.div;var f=p.div.negative!==0?p.mod.isub(g):p.mod,u=g.ushrn(1),b=g.andln(1),_=f.cmp(u);return _<0||b===1&&_===0?p.div:p.div.negative!==0?p.div.isubn(1):p.div.iaddn(1)},s.prototype.modn=function(g){i(g<=67108863);for(var p=(1<<26)%g,f=0,u=this.length-1;u>=0;u--)f=(p*f+(this.words[u]|0))%g;return f},s.prototype.idivn=function(g){i(g<=67108863);for(var p=0,f=this.length-1;f>=0;f--){var u=(this.words[f]|0)+p*67108864;this.words[f]=u/g|0,p=u%g}return this.strip()},s.prototype.divn=function(g){return this.clone().idivn(g)},s.prototype.egcd=function(g){i(g.negative===0),i(!g.isZero());var p=this,f=g.clone();p.negative!==0?p=p.umod(g):p=p.clone();for(var u=new s(1),b=new s(0),_=new s(0),E=new s(1),w=0;p.isEven()&&f.isEven();)p.iushrn(1),f.iushrn(1),++w;for(var d=f.clone(),m=p.clone();!p.isZero();){for(var v=0,A=1;!(p.words[0]&A)&&v<26;++v,A<<=1);if(v>0)for(p.iushrn(v);v-- >0;)(u.isOdd()||b.isOdd())&&(u.iadd(d),b.isub(m)),u.iushrn(1),b.iushrn(1);for(var U=0,x=1;!(f.words[0]&x)&&U<26;++U,x<<=1);if(U>0)for(f.iushrn(U);U-- >0;)(_.isOdd()||E.isOdd())&&(_.iadd(d),E.isub(m)),_.iushrn(1),E.iushrn(1);p.cmp(f)>=0?(p.isub(f),u.isub(_),b.isub(E)):(f.isub(p),_.isub(u),E.isub(b))}return{a:_,b:E,gcd:f.iushln(w)}},s.prototype._invmp=function(g){i(g.negative===0),i(!g.isZero());var p=this,f=g.clone();p.negative!==0?p=p.umod(g):p=p.clone();for(var u=new s(1),b=new s(0),_=f.clone();p.cmpn(1)>0&&f.cmpn(1)>0;){for(var E=0,w=1;!(p.words[0]&w)&&E<26;++E,w<<=1);if(E>0)for(p.iushrn(E);E-- >0;)u.isOdd()&&u.iadd(_),u.iushrn(1);for(var d=0,m=1;!(f.words[0]&m)&&d<26;++d,m<<=1);if(d>0)for(f.iushrn(d);d-- >0;)b.isOdd()&&b.iadd(_),b.iushrn(1);p.cmp(f)>=0?(p.isub(f),u.isub(b)):(f.isub(p),b.isub(u))}var v;return p.cmpn(1)===0?v=u:v=b,v.cmpn(0)<0&&v.iadd(g),v},s.prototype.gcd=function(g){if(this.isZero())return g.abs();if(g.isZero())return this.abs();var p=this.clone(),f=g.clone();p.negative=0,f.negative=0;for(var u=0;p.isEven()&&f.isEven();u++)p.iushrn(1),f.iushrn(1);do{for(;p.isEven();)p.iushrn(1);for(;f.isEven();)f.iushrn(1);var b=p.cmp(f);if(b<0){var _=p;p=f,f=_}else if(b===0||f.cmpn(1)===0)break;p.isub(f)}while(!0);return f.iushln(u)},s.prototype.invm=function(g){return this.egcd(g).a.umod(g)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(g){return this.words[0]&g},s.prototype.bincn=function(g){i(typeof g=="number");var p=g%26,f=(g-p)/26,u=1<<p;if(this.length<=f)return this._expand(f+1),this.words[f]|=u,this;for(var b=u,_=f;b!==0&&_<this.length;_++){var E=this.words[_]|0;E+=b,b=E>>>26,E&=67108863,this.words[_]=E}return b!==0&&(this.words[_]=b,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(g){var p=g<0;if(this.negative!==0&&!p)return-1;if(this.negative===0&&p)return 1;this.strip();var f;if(this.length>1)f=1;else{p&&(g=-g),i(g<=67108863,"Number is too big");var u=this.words[0]|0;f=u===g?0:u<g?-1:1}return this.negative!==0?-f|0:f},s.prototype.cmp=function(g){if(this.negative!==0&&g.negative===0)return-1;if(this.negative===0&&g.negative!==0)return 1;var p=this.ucmp(g);return this.negative!==0?-p|0:p},s.prototype.ucmp=function(g){if(this.length>g.length)return 1;if(this.length<g.length)return-1;for(var p=0,f=this.length-1;f>=0;f--){var u=this.words[f]|0,b=g.words[f]|0;if(u!==b){u<b?p=-1:u>b&&(p=1);break}}return p},s.prototype.gtn=function(g){return this.cmpn(g)===1},s.prototype.gt=function(g){return this.cmp(g)===1},s.prototype.gten=function(g){return this.cmpn(g)>=0},s.prototype.gte=function(g){return this.cmp(g)>=0},s.prototype.ltn=function(g){return this.cmpn(g)===-1},s.prototype.lt=function(g){return this.cmp(g)===-1},s.prototype.lten=function(g){return this.cmpn(g)<=0},s.prototype.lte=function(g){return this.cmp(g)<=0},s.prototype.eqn=function(g){return this.cmpn(g)===0},s.prototype.eq=function(g){return this.cmp(g)===0},s.red=function(g){return new V(g)},s.prototype.toRed=function(g){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),g.convertTo(this)._forceRed(g)},s.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(g){return this.red=g,this},s.prototype.forceRed=function(g){return i(!this.red,"Already a number in reduction context"),this._forceRed(g)},s.prototype.redAdd=function(g){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,g)},s.prototype.redIAdd=function(g){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,g)},s.prototype.redSub=function(g){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,g)},s.prototype.redISub=function(g){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,g)},s.prototype.redShl=function(g){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,g)},s.prototype.redMul=function(g){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,g),this.red.mul(this,g)},s.prototype.redIMul=function(g){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,g),this.red.imul(this,g)},s.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(g){return i(this.red&&!g.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,g)};var C={k256:null,p224:null,p192:null,p25519:null};function L(O,g){this.name=O,this.p=new s(g,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}L.prototype._tmp=function(){var g=new s(null);return g.words=new Array(Math.ceil(this.n/13)),g},L.prototype.ireduce=function(g){var p=g,f;do this.split(p,this.tmp),p=this.imulK(p),p=p.iadd(this.tmp),f=p.bitLength();while(f>this.n);var u=f<this.n?-1:p.ucmp(this.p);return u===0?(p.words[0]=0,p.length=1):u>0?p.isub(this.p):p.strip!==void 0?p.strip():p._strip(),p},L.prototype.split=function(g,p){g.iushrn(this.n,0,p)},L.prototype.imulK=function(g){return g.imul(this.k)};function k(){L.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(k,L),k.prototype.split=function(g,p){for(var f=4194303,u=Math.min(g.length,9),b=0;b<u;b++)p.words[b]=g.words[b];if(p.length=u,g.length<=9){g.words[0]=0,g.length=1;return}var _=g.words[9];for(p.words[p.length++]=_&f,b=10;b<g.length;b++){var E=g.words[b]|0;g.words[b-10]=(E&f)<<4|_>>>22,_=E}_>>>=22,g.words[b-10]=_,_===0&&g.length>10?g.length-=10:g.length-=9},k.prototype.imulK=function(g){g.words[g.length]=0,g.words[g.length+1]=0,g.length+=2;for(var p=0,f=0;f<g.length;f++){var u=g.words[f]|0;p+=u*977,g.words[f]=p&67108863,p=u*64+(p/67108864|0)}return g.words[g.length-1]===0&&(g.length--,g.words[g.length-1]===0&&g.length--),g};function j(){L.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(j,L);function G(){L.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(G,L);function K(){L.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(K,L),K.prototype.imulK=function(g){for(var p=0,f=0;f<g.length;f++){var u=(g.words[f]|0)*19+p,b=u&67108863;u>>>=26,g.words[f]=b,p=u}return p!==0&&(g.words[g.length++]=p),g},s._prime=function(g){if(C[g])return C[g];var p;if(g==="k256")p=new k;else if(g==="p224")p=new j;else if(g==="p192")p=new G;else if(g==="p25519")p=new K;else throw new Error("Unknown prime "+g);return C[g]=p,p};function V(O){if(typeof O=="string"){var g=s._prime(O);this.m=g.p,this.prime=g}else i(O.gtn(1),"modulus must be greater than 1"),this.m=O,this.prime=null}V.prototype._verify1=function(g){i(g.negative===0,"red works only with positives"),i(g.red,"red works only with red numbers")},V.prototype._verify2=function(g,p){i((g.negative|p.negative)===0,"red works only with positives"),i(g.red&&g.red===p.red,"red works only with red numbers")},V.prototype.imod=function(g){return this.prime?this.prime.ireduce(g)._forceRed(this):g.umod(this.m)._forceRed(this)},V.prototype.neg=function(g){return g.isZero()?g.clone():this.m.sub(g)._forceRed(this)},V.prototype.add=function(g,p){this._verify2(g,p);var f=g.add(p);return f.cmp(this.m)>=0&&f.isub(this.m),f._forceRed(this)},V.prototype.iadd=function(g,p){this._verify2(g,p);var f=g.iadd(p);return f.cmp(this.m)>=0&&f.isub(this.m),f},V.prototype.sub=function(g,p){this._verify2(g,p);var f=g.sub(p);return f.cmpn(0)<0&&f.iadd(this.m),f._forceRed(this)},V.prototype.isub=function(g,p){this._verify2(g,p);var f=g.isub(p);return f.cmpn(0)<0&&f.iadd(this.m),f},V.prototype.shl=function(g,p){return this._verify1(g),this.imod(g.ushln(p))},V.prototype.imul=function(g,p){return this._verify2(g,p),this.imod(g.imul(p))},V.prototype.mul=function(g,p){return this._verify2(g,p),this.imod(g.mul(p))},V.prototype.isqr=function(g){return this.imul(g,g.clone())},V.prototype.sqr=function(g){return this.mul(g,g)},V.prototype.sqrt=function(g){if(g.isZero())return g.clone();var p=this.m.andln(3);if(i(p%2===1),p===3){var f=this.m.add(new s(1)).iushrn(2);return this.pow(g,f)}for(var u=this.m.subn(1),b=0;!u.isZero()&&u.andln(1)===0;)b++,u.iushrn(1);i(!u.isZero());var _=new s(1).toRed(this),E=_.redNeg(),w=this.m.subn(1).iushrn(1),d=this.m.bitLength();for(d=new s(2*d*d).toRed(this);this.pow(d,w).cmp(E)!==0;)d.redIAdd(E);for(var m=this.pow(d,u),v=this.pow(g,u.addn(1).iushrn(1)),A=this.pow(g,u),U=b;A.cmp(_)!==0;){for(var x=A,N=0;x.cmp(_)!==0;N++)x=x.redSqr();i(N<U);var B=this.pow(m,new s(1).iushln(U-N-1));v=v.redMul(B),m=B.redSqr(),A=A.redMul(m),U=N}return v},V.prototype.invm=function(g){var p=g._invmp(this.m);return p.negative!==0?(p.negative=0,this.imod(p).redNeg()):this.imod(p)},V.prototype.pow=function(g,p){if(p.isZero())return new s(1).toRed(this);if(p.cmpn(1)===0)return g.clone();var f=4,u=new Array(1<<f);u[0]=new s(1).toRed(this),u[1]=g;for(var b=2;b<u.length;b++)u[b]=this.mul(u[b-1],g);var _=u[0],E=0,w=0,d=p.bitLength()%26;for(d===0&&(d=26),b=p.length-1;b>=0;b--){for(var m=p.words[b],v=d-1;v>=0;v--){var A=m>>v&1;if(_!==u[0]&&(_=this.sqr(_)),A===0&&E===0){w=0;continue}E<<=1,E|=A,w++,!(w!==f&&(b!==0||v!==0))&&(_=this.mul(_,u[E]),w=0,E=0)}d=26}return _},V.prototype.convertTo=function(g){var p=g.umod(this.m);return p===g?p.clone():p},V.prototype.convertFrom=function(g){var p=g.clone();return p.red=null,p},s.mont=function(g){return new re(g)};function re(O){V.call(this,O),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}n(re,V),re.prototype.convertTo=function(g){return this.imod(g.ushln(this.shift))},re.prototype.convertFrom=function(g){var p=this.imod(g.mul(this.rinv));return p.red=null,p},re.prototype.imul=function(g,p){if(g.isZero()||p.isZero())return g.words[0]=0,g.length=1,g;var f=g.imul(p),u=f.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),b=f.isub(u).iushrn(this.shift),_=b;return b.cmp(this.m)>=0?_=b.isub(this.m):b.cmpn(0)<0&&(_=b.iadd(this.m)),_._forceRed(this)},re.prototype.mul=function(g,p){if(g.isZero()||p.isZero())return new s(0)._forceRed(this);var f=g.mul(p),u=f.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),b=f.isub(u).iushrn(this.shift),_=b;return b.cmp(this.m)>=0?_=b.isub(this.m):b.cmpn(0)<0&&(_=b.iadd(this.m)),_._forceRed(this)},re.prototype.invm=function(g){var p=this.imod(g._invmp(this.m).mul(this.r2));return p._forceRed(this)}})(t,Nt)})(ei);var xf={};(function(t){var e=t;function r(s,o){if(Array.isArray(s))return s.slice();if(!s)return[];var a=[];if(typeof s!="string"){for(var c=0;c<s.length;c++)a[c]=s[c]|0;return a}if(o==="hex"){s=s.replace(/[^a-z0-9]+/ig,""),s.length%2!==0&&(s="0"+s);for(var c=0;c<s.length;c+=2)a.push(parseInt(s[c]+s[c+1],16))}else for(var c=0;c<s.length;c++){var h=s.charCodeAt(c),l=h>>8,y=h&255;l?a.push(l,y):a.push(y)}return a}e.toArray=r;function i(s){return s.length===1?"0"+s:s}e.zero2=i;function n(s){for(var o="",a=0;a<s.length;a++)o+=i(s[a].toString(16));return o}e.toHex=n,e.encode=function(o,a){return a==="hex"?n(o):o}})(xf),function(t){var e=t,r=ei.exports,i=sn,n=xf;e.assert=i,e.toArray=n.toArray,e.zero2=n.zero2,e.toHex=n.toHex,e.encode=n.encode;function s(l,y,M){var I=new Array(Math.max(l.bitLength(),M)+1),S;for(S=0;S<I.length;S+=1)I[S]=0;var D=1<<y+1,R=l.clone();for(S=0;S<I.length;S++){var $,T=R.andln(D-1);R.isOdd()?(T>(D>>1)-1?$=(D>>1)-T:$=T,R.isubn($)):$=0,I[S]=$,R.iushrn(1)}return I}e.getNAF=s;function o(l,y){var M=[[],[]];l=l.clone(),y=y.clone();for(var I=0,S=0,D;l.cmpn(-I)>0||y.cmpn(-S)>0;){var R=l.andln(3)+I&3,$=y.andln(3)+S&3;R===3&&(R=-1),$===3&&($=-1);var T;R&1?(D=l.andln(7)+I&7,(D===3||D===5)&&$===2?T=-R:T=R):T=0,M[0].push(T);var C;$&1?(D=y.andln(7)+S&7,(D===3||D===5)&&R===2?C=-$:C=$):C=0,M[1].push(C),2*I===T+1&&(I=1-I),2*S===C+1&&(S=1-S),l.iushrn(1),y.iushrn(1)}return M}e.getJSF=o;function a(l,y,M){var I="_"+y;l.prototype[y]=function(){return this[I]!==void 0?this[I]:this[I]=M.call(this)}}e.cachedProperty=a;function c(l){return typeof l=="string"?e.toArray(l,"hex"):l}e.parseBytes=c;function h(l){return new r(l,"hex","le")}e.intFromLE=h}(pr);var Ao={exports:{}},Ef;Ao.exports=function(e){return Ef||(Ef=new qi(null)),Ef.generate(e)};function qi(t){this.rand=t}if(Ao.exports.Rand=qi,qi.prototype.generate=function(e){return this._rand(e)},qi.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var r=new Uint8Array(e),i=0;i<r.length;i++)r[i]=this.rand.getByte();return r},typeof self=="object")self.crypto&&self.crypto.getRandomValues?qi.prototype._rand=function(e){var r=new Uint8Array(e);return self.crypto.getRandomValues(r),r}:self.msCrypto&&self.msCrypto.getRandomValues?qi.prototype._rand=function(e){var r=new Uint8Array(e);return self.msCrypto.getRandomValues(r),r}:typeof window=="object"&&(qi.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var wd=Qa;if(typeof wd.randomBytes!="function")throw new Error("Not supported");qi.prototype._rand=function(e){return wd.randomBytes(e)}}catch{}var Sf={},fn=ei.exports,xs=pr,Do=xs.getNAF,yw=xs.getJSF,Oo=xs.assert;function Ui(t,e){this.type=t,this.p=new fn(e.p,16),this.red=e.prime?fn.red(e.prime):fn.mont(this.p),this.zero=new fn(0).toRed(this.red),this.one=new fn(1).toRed(this.red),this.two=new fn(2).toRed(this.red),this.n=e.n&&new fn(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 r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Po=Ui;Ui.prototype.point=function(){throw new Error("Not implemented")},Ui.prototype.validate=function(){throw new Error("Not implemented")},Ui.prototype._fixedNafMul=function(e,r){Oo(e.precomputed);var i=e._getDoubles(),n=Do(r,1,this._bitLength),s=(1<<i.step+1)-(i.step%2===0?2:1);s/=3;var o=[],a,c;for(a=0;a<n.length;a+=i.step){c=0;for(var h=a+i.step-1;h>=a;h--)c=(c<<1)+n[h];o.push(c)}for(var l=this.jpoint(null,null,null),y=this.jpoint(null,null,null),M=s;M>0;M--){for(a=0;a<o.length;a++)c=o[a],c===M?y=y.mixedAdd(i.points[a]):c===-M&&(y=y.mixedAdd(i.points[a].neg()));l=l.add(y)}return l.toP()},Ui.prototype._wnafMul=function(e,r){var i=4,n=e._getNAFPoints(i);i=n.wnd;for(var s=n.points,o=Do(r,i,this._bitLength),a=this.jpoint(null,null,null),c=o.length-1;c>=0;c--){for(var h=0;c>=0&&o[c]===0;c--)h++;if(c>=0&&h++,a=a.dblp(h),c<0)break;var l=o[c];Oo(l!==0),e.type==="affine"?l>0?a=a.mixedAdd(s[l-1>>1]):a=a.mixedAdd(s[-l-1>>1].neg()):l>0?a=a.add(s[l-1>>1]):a=a.add(s[-l-1>>1].neg())}return e.type==="affine"?a.toP():a},Ui.prototype._wnafMulAdd=function(e,r,i,n,s){var o=this._wnafT1,a=this._wnafT2,c=this._wnafT3,h=0,l,y,M;for(l=0;l<n;l++){M=r[l];var I=M._getNAFPoints(e);o[l]=I.wnd,a[l]=I.points}for(l=n-1;l>=1;l-=2){var S=l-1,D=l;if(o[S]!==1||o[D]!==1){c[S]=Do(i[S],o[S],this._bitLength),c[D]=Do(i[D],o[D],this._bitLength),h=Math.max(c[S].length,h),h=Math.max(c[D].length,h);continue}var R=[r[S],null,null,r[D]];r[S].y.cmp(r[D].y)===0?(R[1]=r[S].add(r[D]),R[2]=r[S].toJ().mixedAdd(r[D].neg())):r[S].y.cmp(r[D].y.redNeg())===0?(R[1]=r[S].toJ().mixedAdd(r[D]),R[2]=r[S].add(r[D].neg())):(R[1]=r[S].toJ().mixedAdd(r[D]),R[2]=r[S].toJ().mixedAdd(r[D].neg()));var $=[-3,-1,-5,-7,0,7,5,1,3],T=yw(i[S],i[D]);for(h=Math.max(T[0].length,h),c[S]=new Array(h),c[D]=new Array(h),y=0;y<h;y++){var C=T[0][y]|0,L=T[1][y]|0;c[S][y]=$[(C+1)*3+(L+1)],c[D][y]=0,a[S]=R}}var k=this.jpoint(null,null,null),j=this._wnafT4;for(l=h;l>=0;l--){for(var G=0;l>=0;){var K=!0;for(y=0;y<n;y++)j[y]=c[y][l]|0,j[y]!==0&&(K=!1);if(!K)break;G++,l--}if(l>=0&&G++,k=k.dblp(G),l<0)break;for(y=0;y<n;y++){var V=j[y];V!==0&&(V>0?M=a[y][V-1>>1]:V<0&&(M=a[y][-V-1>>1].neg()),M.type==="affine"?k=k.mixedAdd(M):k=k.add(M))}}for(l=0;l<n;l++)a[l]=null;return s?k:k.toP()};function Sr(t,e){this.curve=t,this.type=e,this.precomputed=null}Ui.BasePoint=Sr,Sr.prototype.eq=function(){throw new Error("Not implemented")},Sr.prototype.validate=function(){return this.curve.validate(this)},Ui.prototype.decodePoint=function(e,r){e=xs.toArray(e,r);var i=this.p.byteLength();if((e[0]===4||e[0]===6||e[0]===7)&&e.length-1===2*i){e[0]===6?Oo(e[e.length-1]%2===0):e[0]===7&&Oo(e[e.length-1]%2===1);var n=this.point(e.slice(1,1+i),e.slice(1+i,1+2*i));return n}else if((e[0]===2||e[0]===3)&&e.length-1===i)return this.pointFromX(e.slice(1,1+i),e[0]===3);throw new Error("Unknown point format")},Sr.prototype.encodeCompressed=function(e){return this.encode(e,!0)},Sr.prototype._encode=function(e){var r=this.curve.p.byteLength(),i=this.getX().toArray("be",r);return e?[this.getY().isEven()?2:3].concat(i):[4].concat(i,this.getY().toArray("be",r))},Sr.prototype.encode=function(e,r){return xs.encode(this._encode(r),e)},Sr.prototype.precompute=function(e){if(this.precomputed)return this;var r={doubles:null,naf:null,beta:null};return r.naf=this._getNAFPoints(8),r.doubles=this._getDoubles(4,e),r.beta=this._getBeta(),this.precomputed=r,this},Sr.prototype._hasDoubles=function(e){if(!this.precomputed)return!1;var r=this.precomputed.doubles;return r?r.points.length>=Math.ceil((e.bitLength()+1)/r.step):!1},Sr.prototype._getDoubles=function(e,r){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s<r;s+=e){for(var o=0;o<e;o++)n=n.dbl();i.push(n)}return{step:e,points:i}},Sr.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var r=[this],i=(1<<e)-1,n=i===1?null:this.dbl(),s=1;s<i;s++)r[s]=r[s-1].add(n);return{wnd:e,points:r}},Sr.prototype._getBeta=function(){return null},Sr.prototype.dblp=function(e){for(var r=this,i=0;i<e;i++)r=r.dbl();return r};var mw=pr,pt=ei.exports,Mf=Fn.exports,jn=Po,ww=mw.assert;function Mr(t){jn.call(this,"short",t),this.a=new pt(t.a,16).toRed(this.red),this.b=new pt(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}Mf(Mr,jn);var _w=Mr;Mr.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var r,i;if(e.beta)r=new pt(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);r=n[0].cmp(n[1])<0?n[0]:n[1],r=r.toRed(this.red)}if(e.lambda)i=new pt(e.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(r))===0?i=s[0]:(i=s[1],ww(this.g.mul(i).x.cmp(this.g.x.redMul(r))===0))}var o;return e.basis?o=e.basis.map(function(a){return{a:new pt(a.a,16),b:new pt(a.b,16)}}):o=this._getEndoBasis(i),{beta:r,lambda:i,basis:o}}},Mr.prototype._getEndoRoots=function(e){var r=e===this.p?this.red:pt.mont(e),i=new pt(2).toRed(r).redInvm(),n=i.redNeg(),s=new pt(3).toRed(r).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),a=n.redSub(s).fromRed();return[o,a]},Mr.prototype._getEndoBasis=function(e){for(var r=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new pt(1),o=new pt(0),a=new pt(0),c=new pt(1),h,l,y,M,I,S,D,R=0,$,T;i.cmpn(0)!==0;){var C=n.div(i);$=n.sub(C.mul(i)),T=a.sub(C.mul(s));var L=c.sub(C.mul(o));if(!y&&$.cmp(r)<0)h=D.neg(),l=s,y=$.neg(),M=T;else if(y&&++R===2)break;D=$,n=i,i=$,a=s,s=T,c=o,o=L}I=$.neg(),S=T;var k=y.sqr().add(M.sqr()),j=I.sqr().add(S.sqr());return j.cmp(k)>=0&&(I=h,S=l),y.negative&&(y=y.neg(),M=M.neg()),I.negative&&(I=I.neg(),S=S.neg()),[{a:y,b:M},{a:I,b:S}]},Mr.prototype._endoSplit=function(e){var r=this.endo.basis,i=r[0],n=r[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),a=s.mul(i.a),c=o.mul(n.a),h=s.mul(i.b),l=o.mul(n.b),y=e.sub(a).sub(c),M=h.add(l).neg();return{k1:y,k2:M}},Mr.prototype.pointFromX=function(e,r){e=new pt(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(r&&!s||!r&&s)&&(n=n.redNeg()),this.point(e,n)},Mr.prototype.validate=function(e){if(e.inf)return!0;var r=e.x,i=e.y,n=this.a.redMul(r),s=r.redSqr().redMul(r).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0},Mr.prototype._endoWnafMulAdd=function(e,r,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o<e.length;o++){var a=this._endoSplit(r[o]),c=e[o],h=c._getBeta();a.k1.negative&&(a.k1.ineg(),c=c.neg(!0)),a.k2.negative&&(a.k2.ineg(),h=h.neg(!0)),n[o*2]=c,n[o*2+1]=h,s[o*2]=a.k1,s[o*2+1]=a.k2}for(var l=this._wnafMulAdd(1,n,s,o*2,i),y=0;y<o*2;y++)n[y]=null,s[y]=null;return l};function At(t,e,r,i){jn.BasePoint.call(this,t,"affine"),e===null&&r===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new pt(e,16),this.y=new pt(r,16),i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}Mf(At,jn.BasePoint),Mr.prototype.point=function(e,r,i){return new At(this,e,r,i)},Mr.prototype.pointFromJSON=function(e,r){return At.fromJSON(this,e,r)},At.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var r=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var i=this.curve,n=function(s){return i.point(s.x.redMul(i.endo.beta),s.y)};e.beta=r,r.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(n)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(n)}}}return r}},At.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},At.fromJSON=function(e,r,i){typeof r=="string"&&(r=JSON.parse(r));var n=e.point(r[0],r[1],i);if(!r[2])return n;function s(a){return e.point(a[0],a[1],i)}var o=r[2];return n.precomputed={beta:null,doubles:o.doubles&&{step:o.doubles.step,points:[n].concat(o.doubles.points.map(s))},naf:o.naf&&{wnd:o.naf.wnd,points:[n].concat(o.naf.points.map(s))}},n},At.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},At.prototype.isInfinity=function(){return this.inf},At.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var r=this.y.redSub(e.y);r.cmpn(0)!==0&&(r=r.redMul(this.x.redSub(e.x).redInvm()));var i=r.redSqr().redISub(this.x).redISub(e.x),n=r.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)},At.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var r=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(r).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),a=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},At.prototype.getX=function(){return this.x.fromRed()},At.prototype.getY=function(){return this.y.fromRed()},At.prototype.mul=function(e){return e=new pt(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},At.prototype.mulAdd=function(e,r,i){var n=[this,r],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)},At.prototype.jmulAdd=function(e,r,i){var n=[this,r],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)},At.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)},At.prototype.neg=function(e){if(this.inf)return this;var r=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};r.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return r},At.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function Lt(t,e,r,i){jn.BasePoint.call(this,t,"jacobian"),e===null&&r===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new pt(0)):(this.x=new pt(e,16),this.y=new pt(r,16),this.z=new pt(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}Mf(Lt,jn.BasePoint),Mr.prototype.jpoint=function(e,r,i){return new Lt(this,e,r,i)},Lt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),r=e.redSqr(),i=this.x.redMul(r),n=this.y.redMul(r).redMul(e);return this.curve.point(i,n)},Lt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Lt.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var r=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(r),s=e.x.redMul(i),o=this.y.redMul(r.redMul(e.z)),a=e.y.redMul(i.redMul(this.z)),c=n.redSub(s),h=o.redSub(a);if(c.cmpn(0)===0)return h.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var l=c.redSqr(),y=l.redMul(c),M=n.redMul(l),I=h.redSqr().redIAdd(y).redISub(M).redISub(M),S=h.redMul(M.redISub(I)).redISub(o.redMul(y)),D=this.z.redMul(e.z).redMul(c);return this.curve.jpoint(I,S,D)},Lt.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var r=this.z.redSqr(),i=this.x,n=e.x.redMul(r),s=this.y,o=e.y.redMul(r).redMul(this.z),a=i.redSub(n),c=s.redSub(o);if(a.cmpn(0)===0)return c.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var h=a.redSqr(),l=h.redMul(a),y=i.redMul(h),M=c.redSqr().redIAdd(l).redISub(y).redISub(y),I=c.redMul(y.redISub(M)).redISub(s.redMul(l)),S=this.z.redMul(a);return this.curve.jpoint(M,I,S)},Lt.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var r;if(this.curve.zeroA||this.curve.threeA){var i=this;for(r=0;r<e;r++)i=i.dbl();return i}var n=this.curve.a,s=this.curve.tinv,o=this.x,a=this.y,c=this.z,h=c.redSqr().redSqr(),l=a.redAdd(a);for(r=0;r<e;r++){var y=o.redSqr(),M=l.redSqr(),I=M.redSqr(),S=y.redAdd(y).redIAdd(y).redIAdd(n.redMul(h)),D=o.redMul(M),R=S.redSqr().redISub(D.redAdd(D)),$=D.redISub(R),T=S.redMul($);T=T.redIAdd(T).redISub(I);var C=l.redMul(c);r+1<e&&(h=h.redMul(I)),o=R,c=C,l=T}return this.curve.jpoint(o,l.redMul(s),c)},Lt.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},Lt.prototype._zeroDbl=function(){var e,r,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),a=this.x.redAdd(s).redSqr().redISub(n).redISub(o);a=a.redIAdd(a);var c=n.redAdd(n).redIAdd(n),h=c.redSqr().redISub(a).redISub(a),l=o.redIAdd(o);l=l.redIAdd(l),l=l.redIAdd(l),e=h,r=c.redMul(a.redISub(h)).redISub(l),i=this.y.redAdd(this.y)}else{var y=this.x.redSqr(),M=this.y.redSqr(),I=M.redSqr(),S=this.x.redAdd(M).redSqr().redISub(y).redISub(I);S=S.redIAdd(S);var D=y.redAdd(y).redIAdd(y),R=D.redSqr(),$=I.redIAdd(I);$=$.redIAdd($),$=$.redIAdd($),e=R.redISub(S).redISub(S),r=D.redMul(S.redISub(e)).redISub($),i=this.y.redMul(this.z),i=i.redIAdd(i)}return this.curve.jpoint(e,r,i)},Lt.prototype._threeDbl=function(){var e,r,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),a=this.x.redAdd(s).redSqr().redISub(n).redISub(o);a=a.redIAdd(a);var c=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),h=c.redSqr().redISub(a).redISub(a);e=h;var l=o.redIAdd(o);l=l.redIAdd(l),l=l.redIAdd(l),r=c.redMul(a.redISub(h)).redISub(l),i=this.y.redAdd(this.y)}else{var y=this.z.redSqr(),M=this.y.redSqr(),I=this.x.redMul(M),S=this.x.redSub(y).redMul(this.x.redAdd(y));S=S.redAdd(S).redIAdd(S);var D=I.redIAdd(I);D=D.redIAdd(D);var R=D.redAdd(D);e=S.redSqr().redISub(R),i=this.y.redAdd(this.z).redSqr().redISub(M).redISub(y);var $=M.redSqr();$=$.redIAdd($),$=$.redIAdd($),$=$.redIAdd($),r=S.redMul(D.redISub(e)).redISub($)}return this.curve.jpoint(e,r,i)},Lt.prototype._dbl=function(){var e=this.curve.a,r=this.x,i=this.y,n=this.z,s=n.redSqr().redSqr(),o=r.redSqr(),a=i.redSqr(),c=o.redAdd(o).redIAdd(o).redIAdd(e.redMul(s)),h=r.redAdd(r);h=h.redIAdd(h);var l=h.redMul(a),y=c.redSqr().redISub(l.redAdd(l)),M=l.redISub(y),I=a.redSqr();I=I.redIAdd(I),I=I.redIAdd(I),I=I.redIAdd(I);var S=c.redMul(M).redISub(I),D=i.redAdd(i).redMul(n);return this.curve.jpoint(y,S,D)},Lt.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),r=this.y.redSqr(),i=this.z.redSqr(),n=r.redSqr(),s=e.redAdd(e).redIAdd(e),o=s.redSqr(),a=this.x.redAdd(r).redSqr().redISub(e).redISub(n);a=a.redIAdd(a),a=a.redAdd(a).redIAdd(a),a=a.redISub(o);var c=a.redSqr(),h=n.redIAdd(n);h=h.redIAdd(h),h=h.redIAdd(h),h=h.redIAdd(h);var l=s.redIAdd(a).redSqr().redISub(o).redISub(c).redISub(h),y=r.redMul(l);y=y.redIAdd(y),y=y.redIAdd(y);var M=this.x.redMul(c).redISub(y);M=M.redIAdd(M),M=M.redIAdd(M);var I=this.y.redMul(l.redMul(h.redISub(l)).redISub(a.redMul(c)));I=I.redIAdd(I),I=I.redIAdd(I),I=I.redIAdd(I);var S=this.z.redAdd(a).redSqr().redISub(i).redISub(c);return this.curve.jpoint(M,I,S)},Lt.prototype.mul=function(e,r){return e=new pt(e,r),this.curve._wnafMul(this,e)},Lt.prototype.eq=function(e){if(e.type==="affine")return this.eq(e.toJ());if(this===e)return!0;var r=this.z.redSqr(),i=e.z.redSqr();if(this.x.redMul(i).redISub(e.x.redMul(r)).cmpn(0)!==0)return!1;var n=r.redMul(this.z),s=i.redMul(e.z);return this.y.redMul(s).redISub(e.y.redMul(n)).cmpn(0)===0},Lt.prototype.eqXToP=function(e){var r=this.z.redSqr(),i=e.toRed(this.curve.red).redMul(r);if(this.x.cmp(i)===0)return!0;for(var n=e.clone(),s=this.curve.redN.redMul(r);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}},Lt.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},Lt.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Kn=ei.exports,_d=Fn.exports,Ro=Po,xw=pr;function Vn(t){Ro.call(this,"mont",t),this.a=new Kn(t.a,16).toRed(this.red),this.b=new Kn(t.b,16).toRed(this.red),this.i4=new Kn(4).toRed(this.red).redInvm(),this.two=new Kn(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}_d(Vn,Ro);var Ew=Vn;Vn.prototype.validate=function(e){var r=e.normalize().x,i=r.redSqr(),n=i.redMul(r).redAdd(i.redMul(this.a)).redAdd(r),s=n.redSqrt();return s.redSqr().cmp(n)===0};function Dt(t,e,r){Ro.BasePoint.call(this,t,"projective"),e===null&&r===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new Kn(e,16),this.z=new Kn(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}_d(Dt,Ro.BasePoint),Vn.prototype.decodePoint=function(e,r){return this.point(xw.toArray(e,r),1)},Vn.prototype.point=function(e,r){return new Dt(this,e,r)},Vn.prototype.pointFromJSON=function(e){return Dt.fromJSON(this,e)},Dt.prototype.precompute=function(){},Dt.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},Dt.fromJSON=function(e,r){return new Dt(e,r[0],r[1]||e.one)},Dt.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},Dt.prototype.isInfinity=function(){return this.z.cmpn(0)===0},Dt.prototype.dbl=function(){var e=this.x.redAdd(this.z),r=e.redSqr(),i=this.x.redSub(this.z),n=i.redSqr(),s=r.redSub(n),o=r.redMul(n),a=s.redMul(n.redAdd(this.curve.a24.redMul(s)));return this.curve.point(o,a)},Dt.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Dt.prototype.diffAdd=function(e,r){var i=this.x.redAdd(this.z),n=this.x.redSub(this.z),s=e.x.redAdd(e.z),o=e.x.redSub(e.z),a=o.redMul(i),c=s.redMul(n),h=r.z.redMul(a.redAdd(c).redSqr()),l=r.x.redMul(a.redISub(c).redSqr());return this.curve.point(h,l)},Dt.prototype.mul=function(e){for(var r=e.clone(),i=this,n=this.curve.point(null,null),s=this,o=[];r.cmpn(0)!==0;r.iushrn(1))o.push(r.andln(1));for(var a=o.length-1;a>=0;a--)o[a]===0?(i=i.diffAdd(n,s),n=n.dbl()):(n=i.diffAdd(n,s),i=i.dbl());return n},Dt.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Dt.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},Dt.prototype.eq=function(e){return this.getX().cmp(e.getX())===0},Dt.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Dt.prototype.getX=function(){return this.normalize(),this.x.fromRed()};var Sw=pr,pi=ei.exports,xd=Fn.exports,$o=Po,Mw=Sw.assert;function ti(t){this.twisted=(t.a|0)!==1,this.mOneA=this.twisted&&(t.a|0)===-1,this.extended=this.mOneA,$o.call(this,"edwards",t),this.a=new pi(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new pi(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new pi(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),Mw(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(t.c|0)===1}xd(ti,$o);var Iw=ti;ti.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},ti.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},ti.prototype.jpoint=function(e,r,i,n){return this.point(e,r,i,n)},ti.prototype.pointFromX=function(e,r){e=new pi(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=this.c2.redSub(this.a.redMul(i)),s=this.one.redSub(this.c2.redMul(this.d).redMul(i)),o=n.redMul(s.redInvm()),a=o.redSqrt();if(a.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");var c=a.fromRed().isOdd();return(r&&!c||!r&&c)&&(a=a.redNeg()),this.point(e,a)},ti.prototype.pointFromY=function(e,r){e=new pi(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=i.redSub(this.c2),s=i.redMul(this.d).redMul(this.c2).redSub(this.a),o=n.redMul(s.redInvm());if(o.cmp(this.zero)===0){if(r)throw new Error("invalid point");return this.point(this.zero,e)}var a=o.redSqrt();if(a.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");return a.fromRed().isOdd()!==r&&(a=a.redNeg()),this.point(a,e)},ti.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var r=e.x.redSqr(),i=e.y.redSqr(),n=r.redMul(this.a).redAdd(i),s=this.c2.redMul(this.one.redAdd(this.d.redMul(r).redMul(i)));return n.cmp(s)===0};function ft(t,e,r,i,n){$o.BasePoint.call(this,t,"projective"),e===null&&r===null&&i===null?(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 pi(e,16),this.y=new pi(r,16),this.z=i?new pi(i,16):this.curve.one,this.t=n&&new pi(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()))))}xd(ft,$o.BasePoint),ti.prototype.pointFromJSON=function(e){return ft.fromJSON(this,e)},ti.prototype.point=function(e,r,i,n){return new ft(this,e,r,i,n)},ft.fromJSON=function(e,r){return new ft(e,r[0],r[1],r[2])},ft.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},ft.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},ft.prototype._extDbl=function(){var e=this.x.redSqr(),r=this.y.redSqr(),i=this.z.redSqr();i=i.redIAdd(i);var n=this.curve._mulA(e),s=this.x.redAdd(this.y).redSqr().redISub(e).redISub(r),o=n.redAdd(r),a=o.redSub(i),c=n.redSub(r),h=s.redMul(a),l=o.redMul(c),y=s.redMul(c),M=a.redMul(o);return this.curve.point(h,l,M,y)},ft.prototype._projDbl=function(){var e=this.x.redAdd(this.y).redSqr(),r=this.x.redSqr(),i=this.y.redSqr(),n,s,o,a,c,h;if(this.curve.twisted){a=this.curve._mulA(r);var l=a.redAdd(i);this.zOne?(n=e.redSub(r).redSub(i).redMul(l.redSub(this.curve.two)),s=l.redMul(a.redSub(i)),o=l.redSqr().redSub(l).redSub(l)):(c=this.z.redSqr(),h=l.redSub(c).redISub(c),n=e.redSub(r).redISub(i).redMul(h),s=l.redMul(a.redSub(i)),o=l.redMul(h))}else a=r.redAdd(i),c=this.curve._mulC(this.z).redSqr(),h=a.redSub(c).redSub(c),n=this.curve._mulC(e.redISub(a)).redMul(h),s=this.curve._mulC(a).redMul(r.redISub(i)),o=a.redMul(h);return this.curve.point(n,s,o)},ft.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},ft.prototype._extAdd=function(e){var r=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),i=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),s=this.z.redMul(e.z.redAdd(e.z)),o=i.redSub(r),a=s.redSub(n),c=s.redAdd(n),h=i.redAdd(r),l=o.redMul(a),y=c.redMul(h),M=o.redMul(h),I=a.redMul(c);return this.curve.point(l,y,I,M)},ft.prototype._projAdd=function(e){var r=this.z.redMul(e.z),i=r.redSqr(),n=this.x.redMul(e.x),s=this.y.redMul(e.y),o=this.curve.d.redMul(n).redMul(s),a=i.redSub(o),c=i.redAdd(o),h=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(n).redISub(s),l=r.redMul(a).redMul(h),y,M;return this.curve.twisted?(y=r.redMul(c).redMul(s.redSub(this.curve._mulA(n))),M=a.redMul(c)):(y=r.redMul(c).redMul(s.redSub(n)),M=this.curve._mulC(a).redMul(c)),this.curve.point(l,y,M)},ft.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},ft.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},ft.prototype.mulAdd=function(e,r,i){return this.curve._wnafMulAdd(1,[this,r],[e,i],2,!1)},ft.prototype.jmulAdd=function(e,r,i){return this.curve._wnafMulAdd(1,[this,r],[e,i],2,!0)},ft.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},ft.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},ft.prototype.getX=function(){return this.normalize(),this.x.fromRed()},ft.prototype.getY=function(){return this.normalize(),this.y.fromRed()},ft.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0},ft.prototype.eqXToP=function(e){var r=e.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(r)===0)return!0;for(var i=e.clone(),n=this.curve.redN.redMul(this.z);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(n),this.x.cmp(r)===0)return!0}},ft.prototype.toP=ft.prototype.normalize,ft.prototype.mixedAdd=ft.prototype.add,function(t){var e=t;e.base=Po,e.short=_w,e.mont=Ew,e.edwards=Iw}(Sf);var No={},If,Ed;function Aw(){return Ed||(Ed=1,If={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}),If}(function(t){var e=t,r=dr,i=Sf,n=pr,s=n.assert;function o(h){h.type==="short"?this.curve=new i.short(h):h.type==="edwards"?this.curve=new i.edwards(h):this.curve=new i.mont(h),this.g=this.curve.g,this.n=this.curve.n,this.hash=h.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}e.PresetCurve=o;function a(h,l){Object.defineProperty(e,h,{configurable:!0,enumerable:!0,get:function(){var y=new o(l);return Object.defineProperty(e,h,{configurable:!0,enumerable:!0,value:y}),y}})}a("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:r.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),a("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:r.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),a("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:r.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),a("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:r.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),a("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:r.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),a("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:r.sha256,gRed:!1,g:["9"]}),a("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:r.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var c;try{c=Aw()}catch{c=void 0}a("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:r.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",c]})})(No);var Dw=dr,cn=xf,Sd=sn;function zi(t){if(!(this instanceof zi))return new zi(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=cn.toArray(t.entropy,t.entropyEnc||"hex"),r=cn.toArray(t.nonce,t.nonceEnc||"hex"),i=cn.toArray(t.pers,t.persEnc||"hex");Sd(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,i)}var Ow=zi;zi.prototype._init=function(e,r,i){var n=e.concat(r).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s<this.V.length;s++)this.K[s]=0,this.V[s]=1;this._update(n),this._reseed=1,this.reseedInterval=281474976710656},zi.prototype._hmac=function(){return new Dw.hmac(this.hash,this.K)},zi.prototype._update=function(e){var r=this._hmac().update(this.V).update([0]);e&&(r=r.update(e)),this.K=r.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())},zi.prototype.reseed=function(e,r,i,n){typeof r!="string"&&(n=i,i=r,r=null),e=cn.toArray(e,r),i=cn.toArray(i,n),Sd(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1},zi.prototype.generate=function(e,r,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof r!="string"&&(n=i,i=r,r=null),i&&(i=cn.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length<e;)this.V=this._hmac().update(this.V).digest(),s=s.concat(this.V);var o=s.slice(0,e);return this._update(i),this._reseed++,cn.encode(o,r)};var Pw=ei.exports,Rw=pr,Af=Rw.assert;function Vt(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var $w=Vt;Vt.fromPublic=function(e,r,i){return r instanceof Vt?r:new Vt(e,{pub:r,pubEnc:i})},Vt.fromPrivate=function(e,r,i){return r instanceof Vt?r:new Vt(e,{priv:r,privEnc:i})},Vt.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},Vt.prototype.getPublic=function(e,r){return typeof e=="string"&&(r=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),r?this.pub.encode(r,e):this.pub},Vt.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv},Vt.prototype._importPrivate=function(e,r){this.priv=new Pw(e,r||16),this.priv=this.priv.umod(this.ec.curve.n)},Vt.prototype._importPublic=function(e,r){if(e.x||e.y){this.ec.curve.type==="mont"?Af(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&Af(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,r)},Vt.prototype.derive=function(e){return e.validate()||Af(e.validate(),"public point not validated"),e.mul(this.priv).getX()},Vt.prototype.sign=function(e,r,i){return this.ec.sign(e,this,r,i)},Vt.prototype.verify=function(e,r,i){return this.ec.verify(e,r,this,void 0,i)},Vt.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var To=ei.exports,Df=pr,Nw=Df.assert;function Fo(t,e){if(t instanceof Fo)return t;this._importDER(t,e)||(Nw(t.r&&t.s,"Signature without r or s"),this.r=new To(t.r,16),this.s=new To(t.s,16),t.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var Tw=Fo;function Fw(){this.place=0}function Of(t,e){var r=t[e.place++];if(!(r&128))return r;var i=r&15;if(i===0||i>4||t[e.place]===0)return!1;for(var n=0,s=0,o=e.place;s<i;s++,o++)n<<=8,n|=t[o],n>>>=0;return n<=127?!1:(e.place=o,n)}function Md(t){for(var e=0,r=t.length-1;!t[e]&&!(t[e+1]&128)&&e<r;)e++;return e===0?t:t.slice(e)}Fo.prototype._importDER=function(e,r){e=Df.toArray(e,r);var i=new Fw;if(e[i.place++]!==48)return!1;var n=Of(e,i);if(n===!1||n+i.place!==e.length||e[i.place++]!==2)return!1;var s=Of(e,i);if(s===!1||e[i.place]&128)return!1;var o=e.slice(i.place,s+i.place);if(i.place+=s,e[i.place++]!==2)return!1;var a=Of(e,i);if(a===!1||e.length!==a+i.place||e[i.place]&128)return!1;var c=e.slice(i.place,a+i.place);if(o[0]===0)if(o[1]&128)o=o.slice(1);else return!1;if(c[0]===0)if(c[1]&128)c=c.slice(1);else return!1;return this.r=new To(o),this.s=new To(c),this.recoveryParam=null,!0};function Pf(t,e){if(e<128){t.push(e);return}var r=1+(Math.log(e)/Math.LN2>>>3);for(t.push(r|128);--r;)t.push(e>>>(r<<3)&255);t.push(e)}Fo.prototype.toDER=function(e){var r=this.r.toArray(),i=this.s.toArray();for(r[0]&128&&(r=[0].concat(r)),i[0]&128&&(i=[0].concat(i)),r=Md(r),i=Md(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];Pf(n,r.length),n=n.concat(r),n.push(2),Pf(n,i.length);var s=n.concat(i),o=[48];return Pf(o,s.length),o=o.concat(s),Df.encode(o,e)};var Lr=ei.exports,Id=Ow,Cw=pr,Rf=No,Bw=Ao.exports,hn=Cw.assert,$f=$w,Co=Tw;function Ir(t){if(!(this instanceof Ir))return new Ir(t);typeof t=="string"&&(hn(Object.prototype.hasOwnProperty.call(Rf,t),"Unknown curve "+t),t=Rf[t]),t instanceof Rf.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}var Lw=Ir;Ir.prototype.keyPair=function(e){return new $f(this,e)},Ir.prototype.keyFromPrivate=function(e,r){return $f.fromPrivate(this,e,r)},Ir.prototype.keyFromPublic=function(e,r){return $f.fromPublic(this,e,r)},Ir.prototype.genKeyPair=function(e){e||(e={});for(var r=new Id({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||Bw(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new Lr(2));;){var s=new Lr(r.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}},Ir.prototype._truncateToN=function(e,r,i){var n;if(Lr.isBN(e)||typeof e=="number")e=new Lr(e,16),n=e.byteLength();else if(typeof e=="object")n=e.length,e=new Lr(e,16);else{var s=e.toString();n=s.length+1>>>1,e=new Lr(s,16)}typeof i!="number"&&(i=n*8);var o=i-this.n.bitLength();return o>0&&(e=e.ushrn(o)),!r&&e.cmp(this.n)>=0?e.sub(this.n):e},Ir.prototype.sign=function(e,r,i,n){if(typeof i=="object"&&(n=i,i=null),n||(n={}),typeof e!="string"&&typeof e!="number"&&!Lr.isBN(e)){hn(typeof e=="object"&&e&&typeof e.length=="number","Expected message to be an array-like, a hex string, or a BN instance"),hn(e.length>>>0===e.length);for(var s=0;s<e.length;s++)hn((e[s]&255)===e[s])}r=this.keyFromPrivate(r,i),e=this._truncateToN(e,!1,n.msgBitLength),hn(!e.isNeg(),"Can not sign a negative message");var o=this.n.byteLength(),a=r.getPrivate().toArray("be",o),c=e.toArray("be",o);hn(new Lr(c).eq(e),"Can not sign message");for(var h=new Id({hash:this.hash,entropy:a,nonce:c,pers:n.pers,persEnc:n.persEnc||"utf8"}),l=this.n.sub(new Lr(1)),y=0;;y++){var M=n.k?n.k(y):new Lr(h.generate(this.n.byteLength()));if(M=this._truncateToN(M,!0),!(M.cmpn(1)<=0||M.cmp(l)>=0)){var I=this.g.mul(M);if(!I.isInfinity()){var S=I.getX(),D=S.umod(this.n);if(D.cmpn(0)!==0){var R=M.invm(this.n).mul(D.mul(r.getPrivate()).iadd(e));if(R=R.umod(this.n),R.cmpn(0)!==0){var $=(I.getY().isOdd()?1:0)|(S.cmp(D)!==0?2:0);return n.canonical&&R.cmp(this.nh)>0&&(R=this.n.sub(R),$^=1),new Co({r:D,s:R,recoveryParam:$})}}}}}},Ir.prototype.verify=function(e,r,i,n,s){s||(s={}),e=this._truncateToN(e,!1,s.msgBitLength),i=this.keyFromPublic(i,n),r=new Co(r,"hex");var o=r.r,a=r.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0||a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var c=a.invm(this.n),h=c.mul(e).umod(this.n),l=c.mul(o).umod(this.n),y;return this.curve._maxwellTrick?(y=this.g.jmulAdd(h,i.getPublic(),l),y.isInfinity()?!1:y.eqXToP(o)):(y=this.g.mulAdd(h,i.getPublic(),l),y.isInfinity()?!1:y.getX().umod(this.n).cmp(o)===0)},Ir.prototype.recoverPubKey=function(t,e,r,i){hn((3&r)===r,"The recovery param is more than two bits"),e=new Co(e,i);var n=this.n,s=new Lr(t),o=e.r,a=e.s,c=r&1,h=r>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&h)throw new Error("Unable to find sencond key candinate");h?o=this.curve.pointFromX(o.add(this.curve.n),c):o=this.curve.pointFromX(o,c);var l=e.r.invm(n),y=n.sub(s).mul(l).umod(n),M=a.mul(l).umod(n);return this.g.mulAdd(y,o,M)},Ir.prototype.getKeyRecoveryParam=function(t,e,r,i){if(e=new Co(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(t,e,n)}catch{continue}if(s.eq(r))return n}throw new Error("Unable to find valid recovery factor")};var Es=pr,Ad=Es.assert,Dd=Es.parseBytes,Hn=Es.cachedProperty;function Ot(t,e){this.eddsa=t,this._secret=Dd(e.secret),t.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=Dd(e.pub)}Ot.fromPublic=function(e,r){return r instanceof Ot?r:new Ot(e,{pub:r})},Ot.fromSecret=function(e,r){return r instanceof Ot?r:new Ot(e,{secret:r})},Ot.prototype.secret=function(){return this._secret},Hn(Ot,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),Hn(Ot,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),Hn(Ot,"privBytes",function(){var e=this.eddsa,r=this.hash(),i=e.encodingLength-1,n=r.slice(0,e.encodingLength);return n[0]&=248,n[i]&=127,n[i]|=64,n}),Hn(Ot,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),Hn(Ot,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),Hn(Ot,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),Ot.prototype.sign=function(e){return Ad(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)},Ot.prototype.verify=function(e,r){return this.eddsa.verify(e,r,this)},Ot.prototype.getSecret=function(e){return Ad(this._secret,"KeyPair is public only"),Es.encode(this.secret(),e)},Ot.prototype.getPublic=function(e){return Es.encode(this.pubBytes(),e)};var qw=Ot,Uw=ei.exports,Bo=pr,Od=Bo.assert,Lo=Bo.cachedProperty,zw=Bo.parseBytes;function un(t,e){this.eddsa=t,typeof e!="object"&&(e=zw(e)),Array.isArray(e)&&(Od(e.length===t.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,t.encodingLength),S:e.slice(t.encodingLength)}),Od(e.R&&e.S,"Signature without R or S"),t.isPoint(e.R)&&(this._R=e.R),e.S instanceof Uw&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}Lo(un,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),Lo(un,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),Lo(un,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),Lo(un,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),un.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},un.prototype.toHex=function(){return Bo.encode(this.toBytes(),"hex").toUpperCase()};var kw=un,jw=dr,Kw=No,Wn=pr,Vw=Wn.assert,Pd=Wn.parseBytes,Rd=qw,$d=kw;function sr(t){if(Vw(t==="ed25519","only tested with ed25519 so far"),!(this instanceof sr))return new sr(t);t=Kw[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=jw.sha512}var Hw=sr;sr.prototype.sign=function(e,r){e=Pd(e);var i=this.keyFromSecret(r),n=this.hashInt(i.messagePrefix(),e),s=this.g.mul(n),o=this.encodePoint(s),a=this.hashInt(o,i.pubBytes(),e).mul(i.priv()),c=n.add(a).umod(this.curve.n);return this.makeSignature({R:s,S:c,Rencoded:o})},sr.prototype.verify=function(e,r,i){if(e=Pd(e),r=this.makeSignature(r),r.S().gte(r.eddsa.curve.n)||r.S().isNeg())return!1;var n=this.keyFromPublic(i),s=this.hashInt(r.Rencoded(),n.pubBytes(),e),o=this.g.mul(r.S()),a=r.R().add(n.pub().mul(s));return a.eq(o)},sr.prototype.hashInt=function(){for(var e=this.hash(),r=0;r<arguments.length;r++)e.update(arguments[r]);return Wn.intFromLE(e.digest()).umod(this.curve.n)},sr.prototype.keyFromPublic=function(e){return Rd.fromPublic(this,e)},sr.prototype.keyFromSecret=function(e){return Rd.fromSecret(this,e)},sr.prototype.makeSignature=function(e){return e instanceof $d?e:new $d(this,e)},sr.prototype.encodePoint=function(e){var r=e.getY().toArray("le",this.encodingLength);return r[this.encodingLength-1]|=e.getX().isOdd()?128:0,r},sr.prototype.decodePoint=function(e){e=Wn.parseBytes(e);var r=e.length-1,i=e.slice(0,r).concat(e[r]&-129),n=(e[r]&128)!==0,s=Wn.intFromLE(i);return this.curve.pointFromY(s,n)},sr.prototype.encodeInt=function(e){return e.toArray("le",this.encodingLength)},sr.prototype.decodeInt=function(e){return Wn.intFromLE(e)},sr.prototype.isPoint=function(e){return e instanceof this.pointClass},function(t){var e=t;e.version=vw.version,e.utils=pr,e.rand=Ao.exports,e.curve=Sf,e.curves=No,e.ec=Lw,e.eddsa=Hw}(md);const Ww={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}},Gw=":";function qo(t){const[e,r]=t.split(Gw);return{namespace:e,reference:r}}function Nd(t,e){return t.includes(":")?[t]:e.chains||[]}const Jw="ReactNative",gr={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},Yw="js";function Uo(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function ki(){return!ds()&&!!Ga()&&navigator.product===Jw}function Xw(){return ki()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="android"}function Zw(){return ki()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="ios"}function Ss(){return!Uo()&&!!Ga()&&!!ds()}function Ms(){return ki()?gr.reactNative:Uo()?gr.node:Ss()?gr.browser:gr.unknown}function Td(){var t;try{return ki()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(t=global.Application)==null?void 0:t.applicationId:void 0}catch{return}}function Qw(t,e){const r=new URLSearchParams(t);for(const i of Object.keys(e).sort())if(e.hasOwnProperty(i)){const n=e[i];n!==void 0&&r.set(i,n)}return r.toString()}function Fd(){return nu()||{name:"",description:"",url:"",icons:[""]}}function e6(){if(Ms()===gr.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){const{OS:r,Version:i}=global.Platform;return[r,i].join("-")}const t=gy();if(t===null)return"unknown";const e=t.os?t.os.replace(" ","").toLowerCase():"unknown";return t.type==="browser"?[e,t.name,t.version].join("-"):[e,t.version].join("-")}function t6(){var t;const e=Ms();return e===gr.browser?[e,((t=iu())==null?void 0:t.host)||"unknown"].join(":"):e}function Cd(t,e,r){const i=e6(),n=t6();return[[t,e].join("-"),[Yw,r].join("-"),i,n].join("/")}function r6({protocol:t,version:e,relayUrl:r,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:a,packageName:c}){const h=r.split("?"),l=Cd(t,e,i),y={auth:n,ua:l,projectId:s,useOnCloseEvent:o||void 0,packageName:c||void 0,bundleId:a||void 0},M=Qw(h[1]||"",y);return h[0]+"?"+M}function dn(t,e){return t.filter(r=>e.includes(r)).length===t.length}function Bd(t){return Object.fromEntries(t.entries())}function Ld(t){return new Map(Object.entries(t))}function ln(t=Y.FIVE_MINUTES,e){const r=Y.toMiliseconds(t||Y.FIVE_MINUTES);let i,n,s,o;return{resolve:a=>{s&&i&&(clearTimeout(s),i(a),o=Promise.resolve(a))},reject:a=>{s&&n&&(clearTimeout(s),n(a))},done:()=>new Promise((a,c)=>{if(o)return a(o);s=setTimeout(()=>{const h=new Error(e);o=Promise.reject(h),c(h)},r),i=a,n=c})}}function ji(t,e,r){return new Promise(async(i,n)=>{const s=setTimeout(()=>n(new Error(r)),e);try{const o=await t;i(o)}catch(o){n(o)}clearTimeout(s)})}function qd(t,e){if(typeof e=="string"&&e.startsWith(`${t}:`))return e;if(t.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(t.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${t}`)}function i6(t){return qd("topic",t)}function n6(t){return qd("id",t)}function Ud(t){const[e,r]=t.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof r=="string")i.topic=r;else if(e==="id"&&Number.isInteger(Number(r)))i.id=Number(r);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${r}`);return i}function Et(t,e){return Y.fromMiliseconds((e||Date.now())+Y.toMiliseconds(t))}function Ki(t){return Date.now()>=Y.toMiliseconds(t)}function Se(t,e){return`${t}${e?`:${e}`:""}`}function s6(t=[],e=[]){return[...new Set([...t,...e])]}async function o6({id:t,topic:e,wcDeepLink:r}){var i;try{if(!r)return;const n=typeof r=="string"?JSON.parse(r):r,s=n?.href;if(typeof s!="string")return;const o=a6(s,t,e),a=Ms();if(a===gr.browser){if(!((i=ds())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}f6(o)}else a===gr.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(n){console.error(n)}}function a6(t,e,r){const i=`requestId=${e}&sessionTopic=${r}`;t.endsWith("/")&&(t=t.slice(0,-1));let n=`${t}`;if(t.startsWith("https://t.me")){const s=t.includes("?")?"&startapp=":"?startapp=";n=`${n}${s}${d6(i,!0)}`}else n=`${n}/wc?${i}`;return n}function f6(t){let e="_self";u6()?e="_top":(h6()||t.startsWith("https://")||t.startsWith("http://"))&&(e="_blank"),window.open(t,e,"noreferrer noopener")}async function c6(t,e){let r="";try{if(Ss()&&(r=localStorage.getItem(e),r))return r;r=await t.getItem(e)}catch(i){console.error(i)}return r}function zd(t,e){if(!t.includes(e))return null;const r=t.split(/([&,?,=])/),i=r.indexOf(e);return r[i+2]}function kd(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function Nf(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function h6(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function u6(){try{return window.self!==window.top}catch{return!1}}function d6(t,e=!1){const r=Buffer.from(t).toString("base64");return e?r.replace(/[=]/g,""):r}function jd(t){return Buffer.from(t,"base64").toString("utf-8")}function l6(t){return new Promise(e=>setTimeout(e,t))}function Is(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function p6(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function zo(t,...e){if(!p6(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Tf(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Is(t.outputLen),Is(t.blockLen)}function Gn(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Kd(t,e){zo(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const ko=BigInt(2**32-1),Vd=BigInt(32);function g6(t,e=!1){return e?{h:Number(t&ko),l:Number(t>>Vd&ko)}:{h:Number(t>>Vd&ko)|0,l:Number(t&ko)|0}}function b6(t,e=!1){let r=new Uint32Array(t.length),i=new Uint32Array(t.length);for(let n=0;n<t.length;n++){const{h:s,l:o}=g6(t[n],e);[r[n],i[n]]=[s,o]}return[r,i]}const v6=(t,e,r)=>t<<r|e>>>32-r,y6=(t,e,r)=>e<<r|t>>>32-r,m6=(t,e,r)=>e<<r-32|t>>>64-r,w6=(t,e,r)=>t<<r-32|e>>>64-r,Jn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function _6(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Ff(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function ri(t,e){return t<<32-e|t>>>e}const Hd=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function x6(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Wd(t){for(let e=0;e<t.length;e++)t[e]=x6(t[e])}function E6(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function Yn(t){return typeof t=="string"&&(t=E6(t)),zo(t),t}class Cf{clone(){return this._cloneInto()}}function Gd(t){const e=i=>t().update(Yn(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function As(t=32){if(Jn&&typeof Jn.getRandomValues=="function")return Jn.getRandomValues(new Uint8Array(t));if(Jn&&typeof Jn.randomBytes=="function")return Jn.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const Jd=[],Yd=[],Xd=[],S6=BigInt(0),Ds=BigInt(1),M6=BigInt(2),I6=BigInt(7),A6=BigInt(256),D6=BigInt(113);for(let t=0,e=Ds,r=1,i=0;t<24;t++){[r,i]=[i,(2*r+3*i)%5],Jd.push(2*(5*i+r)),Yd.push((t+1)*(t+2)/2%64);let n=S6;for(let s=0;s<7;s++)e=(e<<Ds^(e>>I6)*D6)%A6,e&M6&&(n^=Ds<<(Ds<<BigInt(s))-Ds);Xd.push(n)}const[O6,P6]=b6(Xd,!0),Zd=(t,e,r)=>r>32?m6(t,e,r):v6(t,e,r),Qd=(t,e,r)=>r>32?w6(t,e,r):y6(t,e,r);function R6(t,e=24){const r=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)r[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,h=r[c],l=r[c+1],y=Zd(h,l,1)^r[a],M=Qd(h,l,1)^r[a+1];for(let I=0;I<50;I+=10)t[o+I]^=y,t[o+I+1]^=M}let n=t[2],s=t[3];for(let o=0;o<24;o++){const a=Yd[o],c=Zd(n,s,a),h=Qd(n,s,a),l=Jd[o];n=t[l],s=t[l+1],t[l]=c,t[l+1]=h}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)r[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~r[(a+2)%10]&r[(a+4)%10]}t[0]^=O6[i],t[1]^=P6[i]}r.fill(0)}class Bf extends Cf{constructor(e,r,i,n=!1,s=24){if(super(),this.blockLen=e,this.suffix=r,this.outputLen=i,this.enableXOF=n,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Is(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=_6(this.state)}keccak(){Hd||Wd(this.state32),R6(this.state32,this.rounds),Hd||Wd(this.state32),this.posOut=0,this.pos=0}update(e){Gn(this);const{blockLen:r,state:i}=this;e=Yn(e);const n=e.length;for(let s=0;s<n;){const o=Math.min(r-this.pos,n-s);for(let a=0;a<o;a++)i[this.pos++]^=e[s++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:r,pos:i,blockLen:n}=this;e[i]^=r,r&128&&i===n-1&&this.keccak(),e[n-1]^=128,this.keccak()}writeInto(e){Gn(this,!1),zo(e),this.finish();const r=this.state,{blockLen:i}=this;for(let n=0,s=e.length;n<s;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,s-n);e.set(r.subarray(this.posOut,this.posOut+o),n),this.posOut+=o,n+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Is(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Kd(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:r,suffix:i,outputLen:n,rounds:s,enableXOF:o}=this;return e||(e=new Bf(r,i,n,o,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=i,e.outputLen=n,e.enableXOF=o,e.destroyed=this.destroyed,e}}const $6=(t,e,r)=>Gd(()=>new Bf(e,t,r)),N6=$6(1,136,256/8),T6="https://rpc.walletconnect.org/v1";function el(t){const e=`Ethereum Signed Message:
22
- ${t.length}`,r=new TextEncoder().encode(e+t);return"0x"+Buffer.from(N6(r)).toString("hex")}async function F6(t,e,r,i,n,s){switch(r.t){case"eip191":return C6(t,e,r.s);case"eip1271":return await B6(t,e,r.s,i,n,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r.t}`)}}function C6(t,e,r){return B2(el(e),r).toLowerCase()===t.toLowerCase()}async function B6(t,e,r,i,n,s){const o=qo(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{const a="0x1626ba7e",c="0000000000000000000000000000000000000000000000000000000000000040",h="0000000000000000000000000000000000000000000000000000000000000041",l=r.substring(2),y=el(e).substring(2),M=a+y+c+h+l,I=await fetch(`${s||T6}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:L6(),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:M},"latest"]})}),{result:S}=await I.json();return S?S.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function L6(){return Date.now()+Math.floor(Math.random()*1e3)}var q6=Object.defineProperty,U6=Object.defineProperties,z6=Object.getOwnPropertyDescriptors,tl=Object.getOwnPropertySymbols,k6=Object.prototype.hasOwnProperty,j6=Object.prototype.propertyIsEnumerable,rl=(t,e,r)=>e in t?q6(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,K6=(t,e)=>{for(var r in e||(e={}))k6.call(e,r)&&rl(t,r,e[r]);if(tl)for(var r of tl(e))j6.call(e,r)&&rl(t,r,e[r]);return t},V6=(t,e)=>U6(t,z6(e));const H6="did:pkh:",Lf=t=>t?.split(":"),W6=t=>{const e=t&&Lf(t);if(e)return t.includes(H6)?e[3]:e[1]},qf=t=>{const e=t&&Lf(t);if(e)return e[2]+":"+e[3]},jo=t=>{const e=t&&Lf(t);if(e)return e.pop()};async function il(t){const{cacao:e,projectId:r}=t,{s:i,p:n}=e,s=nl(n,n.iss),o=jo(n.iss);return await F6(o,s,i,qf(n.iss),r)}const nl=(t,e)=>{const r=`${t.domain} wants you to sign in with your Ethereum account:`,i=jo(e);if(!t.aud&&!t.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let n=t.statement||void 0;const s=`URI: ${t.aud||t.uri}`,o=`Version: ${t.version}`,a=`Chain ID: ${W6(e)}`,c=`Nonce: ${t.nonce}`,h=`Issued At: ${t.iat}`,l=t.exp?`Expiration Time: ${t.exp}`:void 0,y=t.nbf?`Not Before: ${t.nbf}`:void 0,M=t.requestId?`Request ID: ${t.requestId}`:void 0,I=t.resources?`Resources:${t.resources.map(D=>`
23
- - ${D}`).join("")}`:void 0,S=Ko(t.resources);if(S){const D=Os(S);n=r4(n,D)}return[r,i,"",n,"",s,o,a,c,h,l,y,M,I].filter(D=>D!=null).join(`
24
- `)};function G6(t){return Buffer.from(JSON.stringify(t)).toString("base64")}function J6(t){return JSON.parse(Buffer.from(t,"base64").toString("utf-8"))}function pn(t){if(!t)throw new Error("No recap provided, value is undefined");if(!t.att)throw new Error("No `att` property found");const e=Object.keys(t.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(r=>{const i=t.att[r];if(Array.isArray(i))throw new Error(`Resource must be an object: ${r}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${r}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${r}`);Object.keys(i).forEach(n=>{const s=i[n];if(!Array.isArray(s))throw new Error(`Ability limits ${n} must be an array of objects, found: ${s}`);if(!s.length)throw new Error(`Value of ${n} is empty array, must be an array with objects`);s.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${n}) must be an array of objects, found: ${o}`)})})})}function Y6(t,e,r,i={}){return r?.sort((n,s)=>n.localeCompare(s)),{att:{[t]:X6(e,r,i)}}}function X6(t,e,r={}){e=e?.sort((n,s)=>n.localeCompare(s));const i=e.map(n=>({[`${t}/${n}`]:[r]}));return Object.assign({},...i)}function sl(t){return pn(t),`urn:recap:${G6(t).replace(/=/g,"")}`}function Os(t){const e=J6(t.replace("urn:recap:",""));return pn(e),e}function Z6(t,e,r){const i=Y6(t,e,r);return sl(i)}function Q6(t){return t&&t.includes("urn:recap:")}function e4(t,e){const r=Os(t),i=Os(e),n=t4(r,i);return sl(n)}function t4(t,e){pn(t),pn(e);const r=Object.keys(t.att).concat(Object.keys(e.att)).sort((n,s)=>n.localeCompare(s)),i={att:{}};return r.forEach(n=>{var s,o;Object.keys(((s=t.att)==null?void 0:s[n])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[n])||{})).sort((a,c)=>a.localeCompare(c)).forEach(a=>{var c,h;i.att[n]=V6(K6({},i.att[n]),{[a]:((c=t.att[n])==null?void 0:c[a])||((h=e.att[n])==null?void 0:h[a])})})}),i}function r4(t="",e){pn(e);const r="I further authorize the stated URI to perform the following actions on my behalf: ";if(t.includes(r))return t;const i=[];let n=0;Object.keys(e.att).forEach(a=>{const c=Object.keys(e.att[a]).map(y=>({ability:y.split("/")[0],action:y.split("/")[1]}));c.sort((y,M)=>y.action.localeCompare(M.action));const h={};c.forEach(y=>{h[y.ability]||(h[y.ability]=[]),h[y.ability].push(y.action)});const l=Object.keys(h).map(y=>(n++,`(${n}) '${y}': '${h[y].join("', '")}' for '${a}'.`));i.push(l.join(", ").replace(".,","."))});const s=i.join(" "),o=`${r}${s}`;return`${t?t+" ":""}${o}`}function ol(t){var e;const r=Os(t);pn(r);const i=(e=r.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function al(t){const e=Os(t);pn(e);const r=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(n=>{var s;(s=n?.[0])!=null&&s.chains&&r.push(n[0].chains)})}),[...new Set(r.flat())]}function Ko(t){if(!t)return;const e=t?.[t.length-1];return Q6(e)?e:void 0}function Uf(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function fl(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function br(t,...e){if(!fl(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function cl(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function i4(t,e){br(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function hl(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}const Vi=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),n4=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");function s4(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function zf(t){if(typeof t=="string")t=s4(t);else if(fl(t))t=kf(t);else throw new Error("Uint8Array expected, got "+typeof t);return t}function o4(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function a4(t,e){if(t.length!==e.length)return!1;let r=0;for(let i=0;i<t.length;i++)r|=t[i]^e[i];return r===0}const f4=(t,e)=>{function r(i,...n){if(br(i),t.nonceLength!==void 0){const h=n[0];if(!h)throw new Error("nonce / iv required");t.varSizeNonce?br(h):br(h,t.nonceLength)}const s=t.tagLength;s&&n[1]!==void 0&&br(n[1]);const o=e(i,...n),a=(h,l)=>{if(l!==void 0){if(h!==2)throw new Error("cipher output not supported");br(l)}};let c=!1;return{encrypt(h,l){if(c)throw new Error("cannot encrypt() twice with same key + nonce");return c=!0,br(h),a(o.encrypt.length,l),o.encrypt(h,l)},decrypt(h,l){if(br(h),s&&h.length<s)throw new Error("invalid ciphertext length: smaller than tagLength="+s);return a(o.decrypt.length,l),o.decrypt(h,l)}}}return Object.assign(r,t),r};function ul(t,e,r=!0){if(e===void 0)return new Uint8Array(t);if(e.length!==t)throw new Error("invalid output length, expected "+t+", got: "+e.length);if(r&&!c4(e))throw new Error("invalid output, must be aligned");return e}function dl(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);const n=BigInt(32),s=BigInt(4294967295),o=Number(r>>n&s),a=Number(r&s),c=i?4:0,h=i?0:4;t.setUint32(e+c,o,i),t.setUint32(e+h,a,i)}function c4(t){return t.byteOffset%4===0}function kf(t){return Uint8Array.from(t)}function Xn(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const ll=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),h4=ll("expand 16-byte k"),u4=ll("expand 32-byte k"),d4=Vi(h4),l4=Vi(u4);function Le(t,e){return t<<e|t>>>32-e}function jf(t){return t.byteOffset%4===0}const Vo=64,p4=16,pl=2**32-1,gl=new Uint32Array;function g4(t,e,r,i,n,s,o,a){const c=n.length,h=new Uint8Array(Vo),l=Vi(h),y=jf(n)&&jf(s),M=y?Vi(n):gl,I=y?Vi(s):gl;for(let S=0;S<c;o++){if(t(e,r,i,l,o,a),o>=pl)throw new Error("arx: counter overflow");const D=Math.min(Vo,c-S);if(y&&D===Vo){const R=S/4;if(S%4!==0)throw new Error("arx: invalid block position");for(let $=0,T;$<p4;$++)T=R+$,I[T]=M[T]^l[$];S+=Vo;continue}for(let R=0,$;R<D;R++)$=S+R,s[$]=n[$]^h[R];S+=D}}function b4(t,e){const{allowShortKeys:r,extendNonceFn:i,counterLength:n,counterRight:s,rounds:o}=o4({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return Uf(n),Uf(o),hl(s),hl(r),(a,c,h,l,y=0)=>{br(a),br(c),br(h);const M=h.length;if(l===void 0&&(l=new Uint8Array(M)),br(l),Uf(y),y<0||y>=pl)throw new Error("arx: counter overflow");if(l.length<M)throw new Error(`arx: output (${l.length}) is shorter than data (${M})`);const I=[];let S=a.length,D,R;if(S===32)I.push(D=kf(a)),R=l4;else if(S===16&&r)D=new Uint8Array(32),D.set(a),D.set(a,16),R=d4,I.push(D);else throw new Error(`arx: invalid 32-byte key, got length=${S}`);jf(c)||I.push(c=kf(c));const $=Vi(D);if(i){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");i(R,$,Vi(c.subarray(0,16)),$),c=c.subarray(16)}const T=16-n;if(T!==c.length)throw new Error(`arx: nonce must be ${T} or 16 bytes`);if(T!==12){const L=new Uint8Array(12);L.set(c,s?0:12-c.length),c=L,I.push(c)}const C=Vi(c);return g4(t,R,$,C,h,l,y,o),Xn(...I),l}}const qt=(t,e)=>t[e++]&255|(t[e++]&255)<<8;class v4{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,e=zf(e),br(e,32);const r=qt(e,0),i=qt(e,2),n=qt(e,4),s=qt(e,6),o=qt(e,8),a=qt(e,10),c=qt(e,12),h=qt(e,14);this.r[0]=r&8191,this.r[1]=(r>>>13|i<<3)&8191,this.r[2]=(i>>>10|n<<6)&7939,this.r[3]=(n>>>7|s<<9)&8191,this.r[4]=(s>>>4|o<<12)&255,this.r[5]=o>>>1&8190,this.r[6]=(o>>>14|a<<2)&8191,this.r[7]=(a>>>11|c<<5)&8065,this.r[8]=(c>>>8|h<<8)&8191,this.r[9]=h>>>5&127;for(let l=0;l<8;l++)this.pad[l]=qt(e,16+2*l)}process(e,r,i=!1){const n=i?0:2048,{h:s,r:o}=this,a=o[0],c=o[1],h=o[2],l=o[3],y=o[4],M=o[5],I=o[6],S=o[7],D=o[8],R=o[9],$=qt(e,r+0),T=qt(e,r+2),C=qt(e,r+4),L=qt(e,r+6),k=qt(e,r+8),j=qt(e,r+10),G=qt(e,r+12),K=qt(e,r+14);let V=s[0]+($&8191),re=s[1]+(($>>>13|T<<3)&8191),O=s[2]+((T>>>10|C<<6)&8191),g=s[3]+((C>>>7|L<<9)&8191),p=s[4]+((L>>>4|k<<12)&8191),f=s[5]+(k>>>1&8191),u=s[6]+((k>>>14|j<<2)&8191),b=s[7]+((j>>>11|G<<5)&8191),_=s[8]+((G>>>8|K<<8)&8191),E=s[9]+(K>>>5|n),w=0,d=w+V*a+re*(5*R)+O*(5*D)+g*(5*S)+p*(5*I);w=d>>>13,d&=8191,d+=f*(5*M)+u*(5*y)+b*(5*l)+_*(5*h)+E*(5*c),w+=d>>>13,d&=8191;let m=w+V*c+re*a+O*(5*R)+g*(5*D)+p*(5*S);w=m>>>13,m&=8191,m+=f*(5*I)+u*(5*M)+b*(5*y)+_*(5*l)+E*(5*h),w+=m>>>13,m&=8191;let v=w+V*h+re*c+O*a+g*(5*R)+p*(5*D);w=v>>>13,v&=8191,v+=f*(5*S)+u*(5*I)+b*(5*M)+_*(5*y)+E*(5*l),w+=v>>>13,v&=8191;let A=w+V*l+re*h+O*c+g*a+p*(5*R);w=A>>>13,A&=8191,A+=f*(5*D)+u*(5*S)+b*(5*I)+_*(5*M)+E*(5*y),w+=A>>>13,A&=8191;let U=w+V*y+re*l+O*h+g*c+p*a;w=U>>>13,U&=8191,U+=f*(5*R)+u*(5*D)+b*(5*S)+_*(5*I)+E*(5*M),w+=U>>>13,U&=8191;let x=w+V*M+re*y+O*l+g*h+p*c;w=x>>>13,x&=8191,x+=f*a+u*(5*R)+b*(5*D)+_*(5*S)+E*(5*I),w+=x>>>13,x&=8191;let N=w+V*I+re*M+O*y+g*l+p*h;w=N>>>13,N&=8191,N+=f*c+u*a+b*(5*R)+_*(5*D)+E*(5*S),w+=N>>>13,N&=8191;let B=w+V*S+re*I+O*M+g*y+p*l;w=B>>>13,B&=8191,B+=f*h+u*c+b*a+_*(5*R)+E*(5*D),w+=B>>>13,B&=8191;let q=w+V*D+re*S+O*I+g*M+p*y;w=q>>>13,q&=8191,q+=f*l+u*h+b*c+_*a+E*(5*R),w+=q>>>13,q&=8191;let z=w+V*R+re*D+O*S+g*I+p*M;w=z>>>13,z&=8191,z+=f*y+u*l+b*h+_*c+E*a,w+=z>>>13,z&=8191,w=(w<<2)+w|0,w=w+d|0,d=w&8191,w=w>>>13,m+=w,s[0]=d,s[1]=m,s[2]=v,s[3]=A,s[4]=U,s[5]=x,s[6]=N,s[7]=B,s[8]=q,s[9]=z}finalize(){const{h:e,pad:r}=this,i=new Uint16Array(10);let n=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=n,n=e[a]>>>13,e[a]&=8191;e[0]+=n*5,n=e[0]>>>13,e[0]&=8191,e[1]+=n,n=e[1]>>>13,e[1]&=8191,e[2]+=n,i[0]=e[0]+5,n=i[0]>>>13,i[0]&=8191;for(let a=1;a<10;a++)i[a]=e[a]+n,n=i[a]>>>13,i[a]&=8191;i[9]-=8192;let s=(n^1)-1;for(let a=0;a<10;a++)i[a]&=s;s=~s;for(let a=0;a<10;a++)e[a]=e[a]&s|i[a];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let o=e[0]+r[0];e[0]=o&65535;for(let a=1;a<8;a++)o=(e[a]+r[a]|0)+(o>>>16)|0,e[a]=o&65535;Xn(i)}update(e){cl(this);const{buffer:r,blockLen:i}=this;e=zf(e);const n=e.length;for(let s=0;s<n;){const o=Math.min(i-this.pos,n-s);if(o===i){for(;i<=n-s;s+=i)this.process(e,s);continue}r.set(e.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===i&&(this.process(r,0,!1),this.pos=0)}return this}destroy(){Xn(this.h,this.r,this.buffer,this.pad)}digestInto(e){cl(this),i4(e,this),this.finished=!0;const{buffer:r,h:i}=this;let{pos:n}=this;if(n){for(r[n++]=1;n<16;n++)r[n]=0;this.process(r,0,!0)}this.finalize();let s=0;for(let o=0;o<8;o++)e[s++]=i[o]>>>0,e[s++]=i[o]>>>8;return e}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const i=e.slice(0,r);return this.destroy(),i}}function y4(t){const e=(i,n)=>t(n).update(zf(i)).digest(),r=t(new Uint8Array(32));return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=i=>t(i),e}const m4=y4(t=>new v4(t));function w4(t,e,r,i,n,s=20){let o=t[0],a=t[1],c=t[2],h=t[3],l=e[0],y=e[1],M=e[2],I=e[3],S=e[4],D=e[5],R=e[6],$=e[7],T=n,C=r[0],L=r[1],k=r[2],j=o,G=a,K=c,V=h,re=l,O=y,g=M,p=I,f=S,u=D,b=R,_=$,E=T,w=C,d=L,m=k;for(let A=0;A<s;A+=2)j=j+re|0,E=Le(E^j,16),f=f+E|0,re=Le(re^f,12),j=j+re|0,E=Le(E^j,8),f=f+E|0,re=Le(re^f,7),G=G+O|0,w=Le(w^G,16),u=u+w|0,O=Le(O^u,12),G=G+O|0,w=Le(w^G,8),u=u+w|0,O=Le(O^u,7),K=K+g|0,d=Le(d^K,16),b=b+d|0,g=Le(g^b,12),K=K+g|0,d=Le(d^K,8),b=b+d|0,g=Le(g^b,7),V=V+p|0,m=Le(m^V,16),_=_+m|0,p=Le(p^_,12),V=V+p|0,m=Le(m^V,8),_=_+m|0,p=Le(p^_,7),j=j+O|0,m=Le(m^j,16),b=b+m|0,O=Le(O^b,12),j=j+O|0,m=Le(m^j,8),b=b+m|0,O=Le(O^b,7),G=G+g|0,E=Le(E^G,16),_=_+E|0,g=Le(g^_,12),G=G+g|0,E=Le(E^G,8),_=_+E|0,g=Le(g^_,7),K=K+p|0,w=Le(w^K,16),f=f+w|0,p=Le(p^f,12),K=K+p|0,w=Le(w^K,8),f=f+w|0,p=Le(p^f,7),V=V+re|0,d=Le(d^V,16),u=u+d|0,re=Le(re^u,12),V=V+re|0,d=Le(d^V,8),u=u+d|0,re=Le(re^u,7);let v=0;i[v++]=o+j|0,i[v++]=a+G|0,i[v++]=c+K|0,i[v++]=h+V|0,i[v++]=l+re|0,i[v++]=y+O|0,i[v++]=M+g|0,i[v++]=I+p|0,i[v++]=S+f|0,i[v++]=D+u|0,i[v++]=R+b|0,i[v++]=$+_|0,i[v++]=T+E|0,i[v++]=C+w|0,i[v++]=L+d|0,i[v++]=k+m|0}const _4=b4(w4,{counterRight:!1,counterLength:4,allowShortKeys:!1}),x4=new Uint8Array(16),bl=(t,e)=>{t.update(e);const r=e.length%16;r&&t.update(x4.subarray(r))},E4=new Uint8Array(32);function vl(t,e,r,i,n){const s=t(e,r,E4),o=m4.create(s);n&&bl(o,n),bl(o,i);const a=new Uint8Array(16),c=n4(a);dl(c,0,BigInt(n?n.length:0),!0),dl(c,8,BigInt(i.length),!0),o.update(a);const h=o.digest();return Xn(s,a),h}const S4=t=>(e,r,i)=>({encrypt(n,s){const o=n.length;s=ul(o+16,s,!1),s.set(n);const a=s.subarray(0,-16);t(e,r,a,a,1);const c=vl(t,e,r,a,i);return s.set(c,o),Xn(c),s},decrypt(n,s){s=ul(n.length-16,s,!1);const o=n.subarray(0,-16),a=n.subarray(-16),c=vl(t,e,r,o,i);if(!a4(a,c))throw new Error("invalid tag");return s.set(n.subarray(0,-16)),t(e,r,s,s,1),Xn(c),s}}),yl=f4({blockSize:64,nonceLength:12,tagLength:16},S4(_4));class ml extends Cf{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,Tf(e);const i=Yn(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const n=this.blockLen,s=new Uint8Array(n);s.set(i.length>n?e.create().update(i).digest():i);for(let o=0;o<s.length;o++)s[o]^=54;this.iHash.update(s),this.oHash=e.create();for(let o=0;o<s.length;o++)s[o]^=106;this.oHash.update(s),s.fill(0)}update(e){return Gn(this),this.iHash.update(e),this}digestInto(e){Gn(this),zo(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:r,iHash:i,finished:n,destroyed:s,blockLen:o,outputLen:a}=this;return e=e,e.finished=n,e.destroyed=s,e.blockLen=o,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=i._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Kf=(t,e,r)=>new ml(t,e).update(r).digest();Kf.create=(t,e)=>new ml(t,e);function M4(t,e,r){return Tf(t),r===void 0&&(r=new Uint8Array(t.outputLen)),Kf(t,Yn(r),Yn(e))}const Vf=new Uint8Array([0]),wl=new Uint8Array;function I4(t,e,r,i=32){if(Tf(t),Is(i),i>255*t.outputLen)throw new Error("Length should be <= 255*HashLen");const n=Math.ceil(i/t.outputLen);r===void 0&&(r=wl);const s=new Uint8Array(n*t.outputLen),o=Kf.create(t,e),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let h=0;h<n;h++)Vf[0]=h+1,a.update(h===0?wl:c).update(r).update(Vf).digestInto(c),s.set(c,t.outputLen*h),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),Vf.fill(0),s.slice(0,i)}const A4=(t,e,r,i,n)=>I4(t,M4(t,e,r),i,n);function D4(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);const n=BigInt(32),s=BigInt(4294967295),o=Number(r>>n&s),a=Number(r&s),c=i?4:0,h=i?0:4;t.setUint32(e+c,o,i),t.setUint32(e+h,a,i)}function O4(t,e,r){return t&e^~t&r}function P4(t,e,r){return t&e^t&r^e&r}class R4 extends Cf{constructor(e,r,i,n){super(),this.blockLen=e,this.outputLen=r,this.padOffset=i,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Ff(this.buffer)}update(e){Gn(this);const{view:r,buffer:i,blockLen:n}=this;e=Yn(e);const s=e.length;for(let o=0;o<s;){const a=Math.min(n-this.pos,s-o);if(a===n){const c=Ff(e);for(;n<=s-o;o+=n)this.process(c,o);continue}i.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Gn(this),Kd(e,this),this.finished=!0;const{buffer:r,view:i,blockLen:n,isLE:s}=this;let{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(i,0),o=0);for(let y=o;y<n;y++)r[y]=0;D4(i,n-8,BigInt(this.length*8),s),this.process(i,0);const a=Ff(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const h=c/4,l=this.get();if(h>l.length)throw new Error("_sha2: outputLen bigger than state");for(let y=0;y<h;y++)a.setUint32(4*y,l[y],s)}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const i=e.slice(0,r);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:r,buffer:i,length:n,finished:s,destroyed:o,pos:a}=this;return e.length=n,e.pos=a,e.finished=s,e.destroyed=o,n%r&&e.buffer.set(i),e}}const $4=new Uint32Array([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]),Hi=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Wi=new Uint32Array(64);class N4 extends R4{constructor(){super(64,32,8,!1),this.A=Hi[0]|0,this.B=Hi[1]|0,this.C=Hi[2]|0,this.D=Hi[3]|0,this.E=Hi[4]|0,this.F=Hi[5]|0,this.G=Hi[6]|0,this.H=Hi[7]|0}get(){const{A:e,B:r,C:i,D:n,E:s,F:o,G:a,H:c}=this;return[e,r,i,n,s,o,a,c]}set(e,r,i,n,s,o,a,c){this.A=e|0,this.B=r|0,this.C=i|0,this.D=n|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,r){for(let y=0;y<16;y++,r+=4)Wi[y]=e.getUint32(r,!1);for(let y=16;y<64;y++){const M=Wi[y-15],I=Wi[y-2],S=ri(M,7)^ri(M,18)^M>>>3,D=ri(I,17)^ri(I,19)^I>>>10;Wi[y]=D+Wi[y-7]+S+Wi[y-16]|0}let{A:i,B:n,C:s,D:o,E:a,F:c,G:h,H:l}=this;for(let y=0;y<64;y++){const M=ri(a,6)^ri(a,11)^ri(a,25),I=l+M+O4(a,c,h)+$4[y]+Wi[y]|0,S=(ri(i,2)^ri(i,13)^ri(i,22))+P4(i,n,s)|0;l=h,h=c,c=a,a=o+I|0,o=s,s=n,n=i,i=I+S|0}i=i+this.A|0,n=n+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,h=h+this.G|0,l=l+this.H|0,this.set(i,n,s,o,a,c,h,l)}roundClean(){Wi.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Ho=Gd(()=>new N4);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _l=BigInt(0);function Hf(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function xl(t){if(!Hf(t))throw new Error("Uint8Array expected")}const T4=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function F4(t){xl(t);let e="";for(let r=0;r<t.length;r++)e+=T4[t[r]];return e}function C4(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?_l:BigInt("0x"+t)}const gi={_0:48,_9:57,A:65,F:70,a:97,f:102};function El(t){if(t>=gi._0&&t<=gi._9)return t-gi._0;if(t>=gi.A&&t<=gi.F)return t-(gi.A-10);if(t>=gi.a&&t<=gi.f)return t-(gi.a-10)}function Sl(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const i=new Uint8Array(r);for(let n=0,s=0;n<r;n++,s+=2){const o=El(t.charCodeAt(s)),a=El(t.charCodeAt(s+1));if(o===void 0||a===void 0){const c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}i[n]=o*16+a}return i}function Ml(t){return xl(t),C4(F4(Uint8Array.from(t).reverse()))}function B4(t,e){return Sl(t.toString(16).padStart(e*2,"0"))}function L4(t,e){return B4(t,e).reverse()}function Il(t,e,r){let i;if(typeof e=="string")try{i=Sl(e)}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(Hf(e))i=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const n=i.length;if(typeof r=="number"&&n!==r)throw new Error(t+" of length "+r+" expected, got "+n);return i}const Wf=t=>typeof t=="bigint"&&_l<=t;function q4(t,e,r){return Wf(t)&&Wf(e)&&Wf(r)&&e<=t&&t<r}function Al(t,e,r,i){if(!q4(e,r,i))throw new Error("expected valid "+t+": "+r+" <= n < "+i+", got "+e)}const U4={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||Hf(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function z4(t,e,r={}){const i=(n,s,o)=>{const a=U4[s];if(typeof a!="function")throw new Error("invalid validator function");const c=t[n];if(!(o&&c===void 0)&&!a(c,t))throw new Error("param "+String(n)+" is invalid. Expected "+s+", got "+c)};for(const[n,s]of Object.entries(e))i(n,s,!1);for(const[n,s]of Object.entries(r))i(n,s,!0);return t}const Zn=BigInt(0),Wo=BigInt(1);function Dl(t,e){const r=t%e;return r>=Zn?r:e+r}function k4(t,e,r){if(e<Zn)throw new Error("invalid exponent, negatives unsupported");if(r<=Zn)throw new Error("invalid modulus");if(r===Wo)return Zn;let i=Wo;for(;e>Zn;)e&Wo&&(i=i*t%r),t=t*t%r,e>>=Wo;return i}function qr(t,e,r){let i=t;for(;e-- >Zn;)i*=i,i%=r;return i}BigInt(0),BigInt(1),BigInt(0),BigInt(1),BigInt(2),BigInt(8);const Qn=BigInt(0),Gf=BigInt(1);function j4(t){return z4(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function K4(t){const e=j4(t),{P:r}=e,i=T=>Dl(T,r),n=e.montgomeryBits,s=Math.ceil(n/8),o=e.nByteLength,a=e.adjustScalarBytes||(T=>T),c=e.powPminus2||(T=>k4(T,r-BigInt(2),r));function h(T,C,L){const k=i(T*(C-L));return C=i(C-k),L=i(L+k),[C,L]}const l=(e.a-BigInt(2))/BigInt(4);function y(T,C){Al("u",T,Qn,r),Al("scalar",C,Qn,r);const L=C,k=T;let j=Gf,G=Qn,K=T,V=Gf,re=Qn,O;for(let p=BigInt(n-1);p>=Qn;p--){const f=L>>p&Gf;re^=f,O=h(re,j,K),j=O[0],K=O[1],O=h(re,G,V),G=O[0],V=O[1],re=f;const u=j+G,b=i(u*u),_=j-G,E=i(_*_),w=b-E,d=K+V,m=K-V,v=i(m*u),A=i(d*_),U=v+A,x=v-A;K=i(U*U),V=i(k*i(x*x)),j=i(b*E),G=i(w*(b+i(l*w)))}O=h(re,j,K),j=O[0],K=O[1],O=h(re,G,V),G=O[0],V=O[1];const g=c(G);return i(j*g)}function M(T){return L4(i(T),s)}function I(T){const C=Il("u coordinate",T,s);return o===32&&(C[31]&=127),Ml(C)}function S(T){const C=Il("scalar",T),L=C.length;if(L!==s&&L!==o){let k=""+s+" or "+o;throw new Error("invalid scalar, expected "+k+" bytes, got "+L)}return Ml(a(C))}function D(T,C){const L=I(C),k=S(T),j=y(L,k);if(j===Qn)throw new Error("invalid private or public key received");return M(j)}const R=M(e.Gu);function $(T){return D(T,R)}return{scalarMult:D,scalarMultBase:$,getSharedSecret:(T,C)=>D(T,C),getPublicKey:T=>$(T),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:R}}const Jf=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const V4=BigInt(1),Ol=BigInt(2),H4=BigInt(3),W4=BigInt(5);BigInt(8);function G4(t){const e=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),s=Jf,o=t*t%s*t%s,a=qr(o,Ol,s)*o%s,c=qr(a,V4,s)*t%s,h=qr(c,W4,s)*c%s,l=qr(h,e,s)*h%s,y=qr(l,r,s)*l%s,M=qr(y,i,s)*y%s,I=qr(M,n,s)*M%s,S=qr(I,n,s)*M%s,D=qr(S,e,s)*h%s;return{pow_p_5_8:qr(D,Ol,s)*t%s,b2:o}}function J4(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const Yf=(()=>K4({P:Jf,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{const e=Jf,{pow_p_5_8:r,b2:i}=G4(t);return Dl(qr(r,H4,e)*i,e)},adjustScalarBytes:J4,randomBytes:As}))(),Pl="base10",Ht="base16",Gi="base64pad",Ps="base64url",Rs="utf8",Rl=0,bi=1,$s=2,Y4=0,$l=1,Ns=12,Xf=32;function X4(){const t=Yf.utils.randomPrivateKey(),e=Yf.getPublicKey(t);return{privateKey:Zt(t,Ht),publicKey:Zt(e,Ht)}}function Zf(){const t=As(Xf);return Zt(t,Ht)}function Z4(t,e){const r=Yf.getSharedSecret(Er(t,Ht),Er(e,Ht)),i=A4(Ho,r,void 0,void 0,Xf);return Zt(i,Ht)}function Go(t){const e=Ho(Er(t,Ht));return Zt(e,Ht)}function vi(t){const e=Ho(Er(t,Rs));return Zt(e,Ht)}function Nl(t){return Er(`${t}`,Pl)}function gn(t){return Number(Zt(t,Pl))}function Q4(t){const e=Nl(typeof t.type<"u"?t.type:Rl);if(gn(e)===bi&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof t.senderPublicKey<"u"?Er(t.senderPublicKey,Ht):void 0,i=typeof t.iv<"u"?Er(t.iv,Ht):As(Ns),n=Er(t.symKey,Ht),s=yl(n,i).encrypt(Er(t.message,Rs));return Tl({type:e,sealed:s,iv:i,senderPublicKey:r,encoding:t.encoding})}function e8(t){const e=Er(t.symKey,Ht),{sealed:r,iv:i}=Ts(t),n=yl(e,i).decrypt(r);if(n===null)throw new Error("Failed to decrypt");return Zt(n,Rs)}function t8(t,e){const r=Nl($s),i=As(Ns),n=Er(t,Rs);return Tl({type:r,sealed:n,iv:i,encoding:e})}function r8(t,e){const{sealed:r}=Ts({encoded:t,encoding:e});return Zt(r,Rs)}function Tl(t){const{encoding:e=Gi}=t;if(gn(t.type)===$s)return Zt(yf([t.type,t.sealed]),e);if(gn(t.type)===bi){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return Zt(yf([t.type,t.senderPublicKey,t.iv,t.sealed]),e)}return Zt(yf([t.type,t.iv,t.sealed]),e)}function Ts(t){const{encoded:e,encoding:r=Gi}=t,i=Er(e,r),n=i.slice(Y4,$l),s=$l;if(gn(n)===bi){const h=s+Xf,l=h+Ns,y=i.slice(s,h),M=i.slice(h,l),I=i.slice(l);return{type:n,sealed:I,iv:M,senderPublicKey:y}}if(gn(n)===$s){const h=i.slice(s),l=As(Ns);return{type:n,sealed:h,iv:l}}const o=s+Ns,a=i.slice(s,o),c=i.slice(o);return{type:n,sealed:c,iv:a}}function i8(t,e){const r=Ts({encoded:t,encoding:e?.encoding});return Fl({type:gn(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?Zt(r.senderPublicKey,Ht):void 0,receiverPublicKey:e?.receiverPublicKey})}function Fl(t){const e=t?.type||Rl;if(e===bi){if(typeof t?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof t?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:t?.senderPublicKey,receiverPublicKey:t?.receiverPublicKey}}function Cl(t){return t.type===bi&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}function Bl(t){return t.type===$s}function n8(t){return new md.ec("p256").keyFromPublic({x:Buffer.from(t.x,"base64").toString("hex"),y:Buffer.from(t.y,"base64").toString("hex")},"hex")}function s8(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");const r=e.length%4;return r>0&&(e+="=".repeat(4-r)),e}function o8(t){return Buffer.from(s8(t),"base64")}function a8(t,e){const[r,i,n]=t.split("."),s=o8(n);if(s.length!==64)throw new Error("Invalid signature length");const o=s.slice(0,32).toString("hex"),a=s.slice(32,64).toString("hex"),c=`${r}.${i}`,h=Ho(c),l=n8(e),y=Zt(h,Ht);if(!l.verify(y,{r:o,s:a}))throw new Error("Invalid signature");return Wa(t).payload}const f8="irn";function Jo(t){return t?.relay||{protocol:f8}}function Fs(t){const e=Ww[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}function c8(t,e="-"){const r={},i="relay"+e;return Object.keys(t).forEach(n=>{if(n.startsWith(i)){const s=n.replace(i,""),o=t[n];r[s]=o}}),r}function Ll(t){if(!t.includes("wc:")){const h=jd(t);h!=null&&h.includes("wc:")&&(t=h)}t=t.includes("wc://")?t.replace("wc://",""):t,t=t.includes("wc:")?t.replace("wc:",""):t;const e=t.indexOf(":"),r=t.indexOf("?")!==-1?t.indexOf("?"):void 0,i=t.substring(0,e),n=t.substring(e+1,r).split("@"),s=typeof r<"u"?t.substring(r):"",o=new URLSearchParams(s),a={};o.forEach((h,l)=>{a[l]=h});const c=typeof a.methods=="string"?a.methods.split(","):void 0;return{protocol:i,topic:h8(n[0]),version:parseInt(n[1],10),symKey:a.symKey,relay:c8(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function h8(t){return t.startsWith("//")?t.substring(2):t}function u8(t,e="-"){const r="relay",i={};return Object.keys(t).forEach(n=>{const s=r+e+n;t[n]&&(i[s]=t[n])}),i}function ql(t){const e=new URLSearchParams,r=u8(t.relay);Object.keys(r).sort().forEach(n=>{e.set(n,r[n])}),e.set("symKey",t.symKey),t.expiryTimestamp&&e.set("expiryTimestamp",t.expiryTimestamp.toString()),t.methods&&e.set("methods",t.methods.join(","));const i=e.toString();return`${t.protocol}:${t.topic}@${t.version}?${i}`}function Yo(t,e,r){return`${t}?wc_ev=${r}&topic=${e}`}function es(t){const e=[];return t.forEach(r=>{const[i,n]=r.split(":");e.push(`${i}:${n}`)}),e}function d8(t){const e=[];return Object.values(t).forEach(r=>{e.push(...es(r.accounts))}),e}function l8(t,e){const r=[];return Object.values(t).forEach(i=>{es(i.accounts).includes(e)&&r.push(...i.methods)}),r}function p8(t,e){const r=[];return Object.values(t).forEach(i=>{es(i.accounts).includes(e)&&r.push(...i.events)}),r}function g8(t){const e={};return t?.forEach(r=>{const[i,n]=r.split(":");e[i]||(e[i]={accounts:[],chains:[],events:[]}),e[i].accounts.push(r),e[i].chains.push(`${i}:${n}`)}),e}function Ul(t,e){e=e.map(i=>i.replace("did:pkh:",""));const r=g8(e);for(const[i,n]of Object.entries(r))n.methods?n.methods=s6(n.methods,t):n.methods=t,n.events=["chainChanged","accountsChanged"];return r}const b8={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},v8={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function Z(t,e){const{message:r,code:i}=v8[t];return{message:e?`${r} ${e}`:r,code:i}}function ct(t,e){const{message:r,code:i}=b8[t];return{message:e?`${r} ${e}`:r,code:i}}function Xo(t,e){return Array.isArray(t)?typeof e<"u"&&t.length?t.every(e):!0:!1}function Zo(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function Qt(t){return typeof t>"u"}function mt(t,e){return e&&Qt(t)?!0:typeof t=="string"&&!!t.trim().length}function Qf(t,e){return e&&Qt(t)?!0:typeof t=="number"&&!isNaN(t)}function y8(t,e){const{requiredNamespaces:r}=e,i=Object.keys(t.namespaces),n=Object.keys(r);let s=!0;return dn(n,i)?(i.forEach(o=>{const{accounts:a,methods:c,events:h}=t.namespaces[o],l=es(a),y=r[o];(!dn(Nd(o,y),l)||!dn(y.methods,c)||!dn(y.events,h))&&(s=!1)}),s):!1}function Qo(t){return mt(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function m8(t){if(mt(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const r=e[0]+":"+e[1];return!!e[2]&&Qo(r)}}return!1}function w8(t){function e(r){try{return typeof new URL(r)<"u"}catch{return!1}}try{if(mt(t,!1)){if(e(t))return!0;const r=jd(t);return e(r)}}catch{}return!1}function _8(t){var e;return(e=t?.proposer)==null?void 0:e.publicKey}function x8(t){return t?.topic}function E8(t,e){let r=null;return mt(t?.publicKey,!1)||(r=Z("MISSING_OR_INVALID",`${e} controller public key should be a string`)),r}function zl(t){let e=!0;return Xo(t)?t.length&&(e=t.every(r=>mt(r,!1))):e=!1,e}function S8(t,e,r){let i=null;return Xo(e)&&e.length?e.forEach(n=>{i||Qo(n)||(i=ct("UNSUPPORTED_CHAINS",`${r}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):Qo(t)||(i=ct("UNSUPPORTED_CHAINS",`${r}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}function M8(t,e,r){let i=null;return Object.entries(t).forEach(([n,s])=>{if(i)return;const o=S8(n,Nd(n,s),`${e} ${r}`);o&&(i=o)}),i}function I8(t,e){let r=null;return Xo(t)?t.forEach(i=>{r||m8(i)||(r=ct("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):r=ct("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function A8(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=I8(i?.accounts,`${e} namespace`);n&&(r=n)}),r}function D8(t,e){let r=null;return zl(t?.methods)?zl(t?.events)||(r=ct("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):r=ct("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),r}function kl(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=D8(i,`${e}, namespace`);n&&(r=n)}),r}function O8(t,e,r){let i=null;if(t&&Zo(t)){const n=kl(t,e);n&&(i=n);const s=M8(t,e,r);s&&(i=s)}else i=Z("MISSING_OR_INVALID",`${e}, ${r} should be an object with data`);return i}function ec(t,e){let r=null;if(t&&Zo(t)){const i=kl(t,e);i&&(r=i);const n=A8(t,e);n&&(r=n)}else r=Z("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function jl(t){return mt(t.protocol,!0)}function P8(t,e){let r=!1;return e&&!t?r=!0:t&&Xo(t)&&t.length&&t.forEach(i=>{r=jl(i)}),r}function R8(t){return typeof t=="number"}function or(t){return typeof t<"u"&&typeof t!==null}function $8(t){return!(!t||typeof t!="object"||!t.code||!Qf(t.code,!1)||!t.message||!mt(t.message,!1))}function N8(t){return!(Qt(t)||!mt(t.method,!1))}function T8(t){return!(Qt(t)||Qt(t.result)&&Qt(t.error)||!Qf(t.id,!1)||!mt(t.jsonrpc,!1))}function F8(t){return!(Qt(t)||!mt(t.name,!1))}function Kl(t,e){return!(!Qo(e)||!d8(t).includes(e))}function C8(t,e,r){return mt(r,!1)?l8(t,e).includes(r):!1}function B8(t,e,r){return mt(r,!1)?p8(t,e).includes(r):!1}function Vl(t,e,r){let i=null;const n=L8(t),s=q8(e),o=Object.keys(n),a=Object.keys(s),c=Hl(Object.keys(t)),h=Hl(Object.keys(e)),l=c.filter(y=>!h.includes(y));return l.length&&(i=Z("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces.
25
- Required: ${l.toString()}
26
- Received: ${Object.keys(e).toString()}`)),dn(o,a)||(i=Z("NON_CONFORMING_NAMESPACES",`${r} namespaces chains don't satisfy required namespaces.
14
+ ***************************************************************************** */var Ua=function(t,e){return Ua=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var n in i)i.hasOwnProperty(n)&&(r[n]=i[n])},Ua(t,e)};function tg(t,e){Ua(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var ka=function(){return ka=Object.assign||function(e){for(var r,i=1,n=arguments.length;i<n;i++){r=arguments[i];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},ka.apply(this,arguments)};function rg(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]]);return r}function ig(t,e,r,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(n<3?o(s):n>3?o(e,r,s):o(e,r))||s);return n>3&&s&&Object.defineProperty(e,r,s),s}function ng(t,e){return function(r,i){e(r,i,t)}}function sg(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function og(t,e,r,i){function n(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(u){try{f(i.next(u))}catch(d){o(d)}}function c(u){try{f(i.throw(u))}catch(d){o(d)}}function f(u){u.done?s(u.value):n(u.value).then(a,c)}f((i=i.apply(t,e||[])).next())})}function ag(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(f){return function(u){return c([f,u])}}function c(f){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,n&&(s=f[0]&2?n.return:f[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,f[1])).done)return s;switch(n=0,s&&(f=[f[0]&2,s.value]),f[0]){case 0:case 1:s=f;break;case 4:return r.label++,{value:f[1],done:!1};case 5:r.label++,n=f[1],f=[0];continue;case 7:f=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(f[0]===6||f[0]===2)){r=0;continue}if(f[0]===3&&(!s||f[1]>s[0]&&f[1]<s[3])){r.label=f[1];break}if(f[0]===6&&r.label<s[1]){r.label=s[1],s=f;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(f);break}s[2]&&r.ops.pop(),r.trys.pop();continue}f=e.call(t,r)}catch(u){f=[6,u],n=0}finally{i=s=0}if(f[0]&5)throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}}function cg(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}function fg(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function ja(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Nu(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var i=r.call(t),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function ug(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Nu(arguments[e]));return t}function hg(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var i=Array(t),n=0,e=0;e<r;e++)for(var s=arguments[e],o=0,a=s.length;o<a;o++,n++)i[n]=s[o];return i}function is(t){return this instanceof is?(this.v=t,this):new is(t)}function dg(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=r.apply(t,e||[]),n,s=[];return n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n;function o(g){i[g]&&(n[g]=function(m){return new Promise(function(b,x){s.push([g,m,b,x])>1||a(g,m)})})}function a(g,m){try{c(i[g](m))}catch(b){d(s[0][3],b)}}function c(g){g.value instanceof is?Promise.resolve(g.value.v).then(f,u):d(s[0][2],g)}function f(g){a("next",g)}function u(g){a("throw",g)}function d(g,m){g(m),s.shift(),s.length&&a(s[0][0],s[0][1])}}function lg(t){var e,r;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,s){e[n]=t[n]?function(o){return(r=!r)?{value:is(t[n](o)),done:n==="return"}:s?s(o):o}:s}}function pg(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof ja=="function"?ja(t):t[Symbol.iterator](),r={},i("next"),i("throw"),i("return"),r[Symbol.asyncIterator]=function(){return this},r);function i(s){r[s]=t[s]&&function(o){return new Promise(function(a,c){o=t[s](o),n(a,c,o.done,o.value)})}}function n(s,o,a,c){Promise.resolve(c).then(function(f){s({value:f,done:a})},o)}}function gg(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function bg(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function yg(t){return t&&t.__esModule?t:{default:t}}function vg(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function mg(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}var wg=Object.freeze({__proto__:null,__extends:tg,get __assign(){return ka},__rest:rg,__decorate:ig,__param:ng,__metadata:sg,__awaiter:og,__generator:ag,__createBinding:cg,__exportStar:fg,__values:ja,__read:Nu,__spread:ug,__spreadArrays:hg,__await:is,__asyncGenerator:dg,__asyncDelegator:lg,__asyncValues:pg,__makeTemplateObject:gg,__importStar:bg,__importDefault:yg,__classPrivateFieldGet:vg,__classPrivateFieldSet:mg}),go=qa(wg),Ka={},ns={},Bu;function _g(){if(Bu)return ns;Bu=1,Object.defineProperty(ns,"__esModule",{value:!0}),ns.delay=void 0;function t(e){return new Promise(r=>{setTimeout(()=>{r(!0)},e)})}return ns.delay=t,ns}var Ti={},Va={},Ci={},Fu;function xg(){return Fu||(Fu=1,Object.defineProperty(Ci,"__esModule",{value:!0}),Ci.ONE_THOUSAND=Ci.ONE_HUNDRED=void 0,Ci.ONE_HUNDRED=100,Ci.ONE_THOUSAND=1e3),Ci}var Ha={},Lu;function Eg(){return Lu||(Lu=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ONE_YEAR=t.FOUR_WEEKS=t.THREE_WEEKS=t.TWO_WEEKS=t.ONE_WEEK=t.THIRTY_DAYS=t.SEVEN_DAYS=t.FIVE_DAYS=t.THREE_DAYS=t.ONE_DAY=t.TWENTY_FOUR_HOURS=t.TWELVE_HOURS=t.SIX_HOURS=t.THREE_HOURS=t.ONE_HOUR=t.SIXTY_MINUTES=t.THIRTY_MINUTES=t.TEN_MINUTES=t.FIVE_MINUTES=t.ONE_MINUTE=t.SIXTY_SECONDS=t.THIRTY_SECONDS=t.TEN_SECONDS=t.FIVE_SECONDS=t.ONE_SECOND=void 0,t.ONE_SECOND=1,t.FIVE_SECONDS=5,t.TEN_SECONDS=10,t.THIRTY_SECONDS=30,t.SIXTY_SECONDS=60,t.ONE_MINUTE=t.SIXTY_SECONDS,t.FIVE_MINUTES=t.ONE_MINUTE*5,t.TEN_MINUTES=t.ONE_MINUTE*10,t.THIRTY_MINUTES=t.ONE_MINUTE*30,t.SIXTY_MINUTES=t.ONE_MINUTE*60,t.ONE_HOUR=t.SIXTY_MINUTES,t.THREE_HOURS=t.ONE_HOUR*3,t.SIX_HOURS=t.ONE_HOUR*6,t.TWELVE_HOURS=t.ONE_HOUR*12,t.TWENTY_FOUR_HOURS=t.ONE_HOUR*24,t.ONE_DAY=t.TWENTY_FOUR_HOURS,t.THREE_DAYS=t.ONE_DAY*3,t.FIVE_DAYS=t.ONE_DAY*5,t.SEVEN_DAYS=t.ONE_DAY*7,t.THIRTY_DAYS=t.ONE_DAY*30,t.ONE_WEEK=t.SEVEN_DAYS,t.TWO_WEEKS=t.ONE_WEEK*2,t.THREE_WEEKS=t.ONE_WEEK*3,t.FOUR_WEEKS=t.ONE_WEEK*4,t.ONE_YEAR=t.ONE_DAY*365}(Ha)),Ha}var qu;function zu(){return qu||(qu=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=go;e.__exportStar(xg(),t),e.__exportStar(Eg(),t)}(Va)),Va}var Uu;function Sg(){if(Uu)return Ti;Uu=1,Object.defineProperty(Ti,"__esModule",{value:!0}),Ti.fromMiliseconds=Ti.toMiliseconds=void 0;const t=zu();function e(i){return i*t.ONE_THOUSAND}Ti.toMiliseconds=e;function r(i){return Math.floor(i/t.ONE_THOUSAND)}return Ti.fromMiliseconds=r,Ti}var ku;function Ig(){return ku||(ku=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=go;e.__exportStar(_g(),t),e.__exportStar(Sg(),t)}(Ka)),Ka}var pn={},ju;function Ag(){if(ju)return pn;ju=1,Object.defineProperty(pn,"__esModule",{value:!0}),pn.Watch=void 0;class t{constructor(){this.timestamps=new Map}start(r){if(this.timestamps.has(r))throw new Error(`Watch already started for label: ${r}`);this.timestamps.set(r,{started:Date.now()})}stop(r){const i=this.get(r);if(typeof i.elapsed<"u")throw new Error(`Watch already stopped for label: ${r}`);const n=Date.now()-i.started;this.timestamps.set(r,{started:i.started,elapsed:n})}get(r){const i=this.timestamps.get(r);if(typeof i>"u")throw new Error(`No timestamp found for label: ${r}`);return i}elapsed(r){const i=this.get(r);return i.elapsed||Date.now()-i.started}}return pn.Watch=t,pn.default=t,pn}var Wa={},ss={},Ku;function Dg(){if(Ku)return ss;Ku=1,Object.defineProperty(ss,"__esModule",{value:!0}),ss.IWatch=void 0;class t{}return ss.IWatch=t,ss}var Vu;function $g(){return Vu||(Vu=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),go.__exportStar(Dg(),t)}(Wa)),Wa}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=go;e.__exportStar(Ig(),t),e.__exportStar(Ag(),t),e.__exportStar($g(),t),e.__exportStar(zu(),t)})(V);class Ni{}class Og extends Ni{constructor(e){super()}}const Hu=V.FIVE_SECONDS,gn={pulse:"heartbeat_pulse"};class Ga extends Og{constructor(e){super(e),this.events=new Mt.exports.EventEmitter,this.interval=Hu,this.interval=e?.interval||Hu}static async init(e){const r=new Ga(e);return await r.init(),r}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),V.toMiliseconds(this.interval))}pulse(){this.events.emit(gn.pulse)}}const Mg=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,Pg=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,Rg=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function Tg(t,e){if(t==="__proto__"||t==="constructor"&&e&&typeof e=="object"&&"prototype"in e){Cg(t);return}return e}function Cg(t){console.warn(`[destr] Dropping "${t}" key to prevent prototype pollution.`)}function bo(t,e={}){if(typeof t!="string")return t;const r=t.trim();if(t[0]==='"'&&t.endsWith('"')&&!t.includes("\\"))return r.slice(1,-1);if(r.length<=9){const i=r.toLowerCase();if(i==="true")return!0;if(i==="false")return!1;if(i==="undefined")return;if(i==="null")return null;if(i==="nan")return Number.NaN;if(i==="infinity")return Number.POSITIVE_INFINITY;if(i==="-infinity")return Number.NEGATIVE_INFINITY}if(!Rg.test(t)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return t}try{if(Mg.test(t)||Pg.test(t)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(t,Tg)}return JSON.parse(t)}catch(i){if(e.strict)throw i;return t}}function Ng(t){return!t||typeof t.then!="function"?Promise.resolve(t):t}function ft(t,...e){try{return Ng(t(...e))}catch(r){return Promise.reject(r)}}function Bg(t){const e=typeof t;return t===null||e!=="object"&&e!=="function"}function Fg(t){const e=Object.getPrototypeOf(t);return!e||e.isPrototypeOf(Object)}function yo(t){if(Bg(t))return String(t);if(Fg(t)||Array.isArray(t))return JSON.stringify(t);if(typeof t.toJSON=="function")return yo(t.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function Wu(){if(typeof Buffer>"u")throw new TypeError("[unstorage] Buffer is not supported!")}const Ya="base64:";function Lg(t){if(typeof t=="string")return t;Wu();const e=Buffer.from(t).toString("base64");return Ya+e}function qg(t){return typeof t!="string"||!t.startsWith(Ya)?t:(Wu(),Buffer.from(t.slice(Ya.length),"base64"))}function Ut(t){return t?t.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function zg(...t){return Ut(t.join(":"))}function vo(t){return t=Ut(t),t?t+":":""}function xA(t){return t}const Ug="memory",kg=()=>{const t=new Map;return{name:Ug,getInstance:()=>t,hasItem(e){return t.has(e)},getItem(e){return t.get(e)??null},getItemRaw(e){return t.get(e)??null},setItem(e,r){t.set(e,r)},setItemRaw(e,r){t.set(e,r)},removeItem(e){t.delete(e)},getKeys(){return[...t.keys()]},clear(){t.clear()},dispose(){t.clear()}}};function jg(t={}){const e={mounts:{"":t.driver||kg()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},r=f=>{for(const u of e.mountpoints)if(f.startsWith(u))return{base:u,relativeKey:f.slice(u.length),driver:e.mounts[u]};return{base:"",relativeKey:f,driver:e.mounts[""]}},i=(f,u)=>e.mountpoints.filter(d=>d.startsWith(f)||u&&f.startsWith(d)).map(d=>({relativeBase:f.length>d.length?f.slice(d.length):void 0,mountpoint:d,driver:e.mounts[d]})),n=(f,u)=>{if(e.watching){u=Ut(u);for(const d of e.watchListeners)d(f,u)}},s=async()=>{if(!e.watching){e.watching=!0;for(const f in e.mounts)e.unwatch[f]=await Gu(e.mounts[f],n,f)}},o=async()=>{if(e.watching){for(const f in e.unwatch)await e.unwatch[f]();e.unwatch={},e.watching=!1}},a=(f,u,d)=>{const g=new Map,m=b=>{let x=g.get(b.base);return x||(x={driver:b.driver,base:b.base,items:[]},g.set(b.base,x)),x};for(const b of f){const x=typeof b=="string",I=Ut(x?b:b.key),O=x?void 0:b.value,$=x||!b.options?u:{...u,...b.options},P=r(I);m(P).items.push({key:I,value:O,relativeKey:P.relativeKey,options:$})}return Promise.all([...g.values()].map(b=>d(b))).then(b=>b.flat())},c={hasItem(f,u={}){f=Ut(f);const{relativeKey:d,driver:g}=r(f);return ft(g.hasItem,d,u)},getItem(f,u={}){f=Ut(f);const{relativeKey:d,driver:g}=r(f);return ft(g.getItem,d,u).then(m=>bo(m))},getItems(f,u){return a(f,u,d=>d.driver.getItems?ft(d.driver.getItems,d.items.map(g=>({key:g.relativeKey,options:g.options})),u).then(g=>g.map(m=>({key:zg(d.base,m.key),value:bo(m.value)}))):Promise.all(d.items.map(g=>ft(d.driver.getItem,g.relativeKey,g.options).then(m=>({key:g.key,value:bo(m)})))))},getItemRaw(f,u={}){f=Ut(f);const{relativeKey:d,driver:g}=r(f);return g.getItemRaw?ft(g.getItemRaw,d,u):ft(g.getItem,d,u).then(m=>qg(m))},async setItem(f,u,d={}){if(u===void 0)return c.removeItem(f);f=Ut(f);const{relativeKey:g,driver:m}=r(f);m.setItem&&(await ft(m.setItem,g,yo(u),d),m.watch||n("update",f))},async setItems(f,u){await a(f,u,async d=>{if(d.driver.setItems)return ft(d.driver.setItems,d.items.map(g=>({key:g.relativeKey,value:yo(g.value),options:g.options})),u);d.driver.setItem&&await Promise.all(d.items.map(g=>ft(d.driver.setItem,g.relativeKey,yo(g.value),g.options)))})},async setItemRaw(f,u,d={}){if(u===void 0)return c.removeItem(f,d);f=Ut(f);const{relativeKey:g,driver:m}=r(f);if(m.setItemRaw)await ft(m.setItemRaw,g,u,d);else if(m.setItem)await ft(m.setItem,g,Lg(u),d);else return;m.watch||n("update",f)},async removeItem(f,u={}){typeof u=="boolean"&&(u={removeMeta:u}),f=Ut(f);const{relativeKey:d,driver:g}=r(f);g.removeItem&&(await ft(g.removeItem,d,u),(u.removeMeta||u.removeMata)&&await ft(g.removeItem,d+"$",u),g.watch||n("remove",f))},async getMeta(f,u={}){typeof u=="boolean"&&(u={nativeOnly:u}),f=Ut(f);const{relativeKey:d,driver:g}=r(f),m=Object.create(null);if(g.getMeta&&Object.assign(m,await ft(g.getMeta,d,u)),!u.nativeOnly){const b=await ft(g.getItem,d+"$",u).then(x=>bo(x));b&&typeof b=="object"&&(typeof b.atime=="string"&&(b.atime=new Date(b.atime)),typeof b.mtime=="string"&&(b.mtime=new Date(b.mtime)),Object.assign(m,b))}return m},setMeta(f,u,d={}){return this.setItem(f+"$",u,d)},removeMeta(f,u={}){return this.removeItem(f+"$",u)},async getKeys(f,u={}){f=vo(f);const d=i(f,!0);let g=[];const m=[];for(const b of d){const x=await ft(b.driver.getKeys,b.relativeBase,u);for(const I of x){const O=b.mountpoint+Ut(I);g.some($=>O.startsWith($))||m.push(O)}g=[b.mountpoint,...g.filter(I=>!I.startsWith(b.mountpoint))]}return f?m.filter(b=>b.startsWith(f)&&b[b.length-1]!=="$"):m.filter(b=>b[b.length-1]!=="$")},async clear(f,u={}){f=vo(f),await Promise.all(i(f,!1).map(async d=>{if(d.driver.clear)return ft(d.driver.clear,d.relativeBase,u);if(d.driver.removeItem){const g=await d.driver.getKeys(d.relativeBase||"",u);return Promise.all(g.map(m=>d.driver.removeItem(m,u)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(f=>Yu(f)))},async watch(f){return await s(),e.watchListeners.push(f),async()=>{e.watchListeners=e.watchListeners.filter(u=>u!==f),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(f,u){if(f=vo(f),f&&e.mounts[f])throw new Error(`already mounted at ${f}`);return f&&(e.mountpoints.push(f),e.mountpoints.sort((d,g)=>g.length-d.length)),e.mounts[f]=u,e.watching&&Promise.resolve(Gu(u,n,f)).then(d=>{e.unwatch[f]=d}).catch(console.error),c},async unmount(f,u=!0){f=vo(f),!(!f||!e.mounts[f])&&(e.watching&&f in e.unwatch&&(e.unwatch[f](),delete e.unwatch[f]),u&&await Yu(e.mounts[f]),e.mountpoints=e.mountpoints.filter(d=>d!==f),delete e.mounts[f])},getMount(f=""){f=Ut(f)+":";const u=r(f);return{driver:u.driver,base:u.base}},getMounts(f="",u={}){return f=Ut(f),i(f,u.parents).map(g=>({driver:g.driver,base:g.mountpoint}))},keys:(f,u={})=>c.getKeys(f,u),get:(f,u={})=>c.getItem(f,u),set:(f,u,d={})=>c.setItem(f,u,d),has:(f,u={})=>c.hasItem(f,u),del:(f,u={})=>c.removeItem(f,u),remove:(f,u={})=>c.removeItem(f,u)};return c}function Gu(t,e,r){return t.watch?t.watch((i,n)=>e(i,r+n)):()=>{}}async function Yu(t){typeof t.dispose=="function"&&await ft(t.dispose)}function Bi(t){return new Promise((e,r)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>r(t.error)})}function Zu(t,e){const r=indexedDB.open(t);r.onupgradeneeded=()=>r.result.createObjectStore(e);const i=Bi(r);return(n,s)=>i.then(o=>s(o.transaction(e,n).objectStore(e)))}let Za;function os(){return Za||(Za=Zu("keyval-store","keyval")),Za}function Ju(t,e=os()){return e("readonly",r=>Bi(r.get(t)))}function Kg(t,e,r=os()){return r("readwrite",i=>(i.put(e,t),Bi(i.transaction)))}function Vg(t,e=os()){return e("readwrite",r=>(r.delete(t),Bi(r.transaction)))}function Hg(t=os()){return t("readwrite",e=>(e.clear(),Bi(e.transaction)))}function Wg(t,e){return t.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},Bi(t.transaction)}function Gg(t=os()){return t("readonly",e=>{if(e.getAllKeys)return Bi(e.getAllKeys());const r=[];return Wg(e,i=>r.push(i.key)).then(()=>r)})}const Yg=t=>JSON.stringify(t,(e,r)=>typeof r=="bigint"?r.toString()+"n":r),Zg=t=>{const e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,r=t.replace(e,'$1"$2n"$3');return JSON.parse(r,(i,n)=>typeof n=="string"&&n.match(/^\d+n$/)?BigInt(n.substring(0,n.length-1)):n)};function bn(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return Zg(t)}catch{return t}}function Fi(t){return typeof t=="string"?t:Yg(t)||""}const Jg="idb-keyval";var Xg=(t={})=>{const e=t.base&&t.base.length>0?`${t.base}:`:"",r=n=>e+n;let i;return t.dbName&&t.storeName&&(i=Zu(t.dbName,t.storeName)),{name:Jg,options:t,async hasItem(n){return!(typeof await Ju(r(n),i)>"u")},async getItem(n){return await Ju(r(n),i)??null},setItem(n,s){return Kg(r(n),s,i)},removeItem(n){return Vg(r(n),i)},getKeys(){return Gg(i)},clear(){return Hg(i)}}};const Qg="WALLET_CONNECT_V2_INDEXED_DB",eb="keyvaluestorage";class tb{constructor(){this.indexedDb=jg({driver:Xg({dbName:Qg,storeName:eb})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){const r=await this.indexedDb.getItem(e);if(r!==null)return r}async setItem(e,r){await this.indexedDb.setItem(e,Fi(r))}async removeItem(e){await this.indexedDb.removeItem(e)}}var Ja=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},mo={exports:{}};(function(){let t;function e(){}t=e,t.prototype.getItem=function(r){return this.hasOwnProperty(r)?String(this[r]):null},t.prototype.setItem=function(r,i){this[r]=String(i)},t.prototype.removeItem=function(r){delete this[r]},t.prototype.clear=function(){const r=this;Object.keys(r).forEach(function(i){r[i]=void 0,delete r[i]})},t.prototype.key=function(r){return r=r||0,Object.keys(this)[r]},t.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Ja<"u"&&Ja.localStorage?mo.exports=Ja.localStorage:typeof window<"u"&&window.localStorage?mo.exports=window.localStorage:mo.exports=new e})();function rb(t){var e;return[t[0],bn((e=t[1])!=null?e:"")]}class ib{constructor(){this.localStorage=mo.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(rb)}async getItem(e){const r=this.localStorage.getItem(e);if(r!==null)return bn(r)}async setItem(e,r){this.localStorage.setItem(e,Fi(r))}async removeItem(e){this.localStorage.removeItem(e)}}const nb="wc_storage_version",Xu=1,sb=async(t,e,r)=>{const i=nb,n=await e.getItem(i);if(n&&n>=Xu){r(e);return}const s=await t.getKeys();if(!s.length){r(e);return}const o=[];for(;s.length;){const a=s.shift();if(!a)continue;const c=a.toLowerCase();if(c.includes("wc@")||c.includes("walletconnect")||c.includes("wc_")||c.includes("wallet_connect")){const f=await t.getItem(a);await e.setItem(a,f),o.push(a)}}await e.setItem(i,Xu),r(e),ob(t,o)},ob=async(t,e)=>{e.length&&e.forEach(async r=>{await t.removeItem(r)})};class ab{constructor(){this.initialized=!1,this.setInitialized=r=>{this.storage=r,this.initialized=!0};const e=new ib;this.storage=e;try{const r=new tb;sb(e,r,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,r){return await this.initialize(),this.storage.setItem(e,r)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{const r=setInterval(()=>{this.initialized&&(clearInterval(r),e())},20)})}}function cb(t){try{return JSON.stringify(t)}catch{return'"[Circular]"'}}var fb=ub;function ub(t,e,r){var i=r&&r.stringify||cb,n=1;if(typeof t=="object"&&t!==null){var s=e.length+n;if(s===1)return t;var o=new Array(s);o[0]=i(t);for(var a=1;a<s;a++)o[a]=i(e[a]);return o.join(" ")}if(typeof t!="string")return t;var c=e.length;if(c===0)return t;for(var f="",u=1-n,d=-1,g=t&&t.length||0,m=0;m<g;){if(t.charCodeAt(m)===37&&m+1<g){switch(d=d>-1?d:0,t.charCodeAt(m+1)){case 100:case 102:if(u>=c||e[u]==null)break;d<m&&(f+=t.slice(d,m)),f+=Number(e[u]),d=m+2,m++;break;case 105:if(u>=c||e[u]==null)break;d<m&&(f+=t.slice(d,m)),f+=Math.floor(Number(e[u])),d=m+2,m++;break;case 79:case 111:case 106:if(u>=c||e[u]===void 0)break;d<m&&(f+=t.slice(d,m));var b=typeof e[u];if(b==="string"){f+="'"+e[u]+"'",d=m+2,m++;break}if(b==="function"){f+=e[u].name||"<anonymous>",d=m+2,m++;break}f+=i(e[u]),d=m+2,m++;break;case 115:if(u>=c)break;d<m&&(f+=t.slice(d,m)),f+=String(e[u]),d=m+2,m++;break;case 37:d<m&&(f+=t.slice(d,m)),f+="%",d=m+2,m++,u--;break}++u}++m}return d===-1?t:(d<g&&(f+=t.slice(d)),f)}const Qu=fb;var Wr=Sr;const as=wb().console||{},hb={mapHttpRequest:_o,mapHttpResponse:_o,wrapRequestSerializer:Qa,wrapResponseSerializer:Qa,wrapErrorSerializer:Qa,req:_o,res:_o,err:bb};function db(t,e){return Array.isArray(t)?t.filter(function(i){return i!=="!stdSerializers.err"}):t===!0?Object.keys(e):!1}function Sr(t){t=t||{},t.browser=t.browser||{};const e=t.browser.transmit;if(e&&typeof e.send!="function")throw Error("pino: transmit option must have a send function");const r=t.browser.write||as;t.browser.write&&(t.browser.asObject=!0);const i=t.serializers||{},n=db(t.browser.serialize,i);let s=t.browser.serialize;Array.isArray(t.browser.serialize)&&t.browser.serialize.indexOf("!stdSerializers.err")>-1&&(s=!1);const o=["error","fatal","warn","info","debug","trace"];typeof r=="function"&&(r.error=r.fatal=r.warn=r.info=r.debug=r.trace=r),t.enabled===!1&&(t.level="silent");const a=t.level||"info",c=Object.create(r);c.log||(c.log=cs),Object.defineProperty(c,"levelVal",{get:u}),Object.defineProperty(c,"level",{get:d,set:g});const f={transmit:e,serialize:n,asObject:t.browser.asObject,levels:o,timestamp:yb(t)};c.levels=Sr.levels,c.level=a,c.setMaxListeners=c.getMaxListeners=c.emit=c.addListener=c.on=c.prependListener=c.once=c.prependOnceListener=c.removeListener=c.removeAllListeners=c.listeners=c.listenerCount=c.eventNames=c.write=c.flush=cs,c.serializers=i,c._serialize=n,c._stdErrSerialize=s,c.child=m,e&&(c._logEvent=Xa());function u(){return this.level==="silent"?1/0:this.levels.values[this.level]}function d(){return this._level}function g(b){if(b!=="silent"&&!this.levels.values[b])throw Error("unknown level "+b);this._level=b,yn(f,c,"error","log"),yn(f,c,"fatal","error"),yn(f,c,"warn","error"),yn(f,c,"info","log"),yn(f,c,"debug","log"),yn(f,c,"trace","log")}function m(b,x){if(!b)throw new Error("missing bindings for child Pino");x=x||{},n&&b.serializers&&(x.serializers=b.serializers);const I=x.serializers;if(n&&I){var O=Object.assign({},i,I),$=t.browser.serialize===!0?Object.keys(O):n;delete b.serializers,wo([b],$,O,this._stdErrSerialize)}function P(R){this._childLevel=(R._childLevel|0)+1,this.error=vn(R,b,"error"),this.fatal=vn(R,b,"fatal"),this.warn=vn(R,b,"warn"),this.info=vn(R,b,"info"),this.debug=vn(R,b,"debug"),this.trace=vn(R,b,"trace"),O&&(this.serializers=O,this._serialize=$),e&&(this._logEvent=Xa([].concat(R._logEvent.bindings,b)))}return P.prototype=this,new P(this)}return c}Sr.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},Sr.stdSerializers=hb,Sr.stdTimeFunctions=Object.assign({},{nullTime:eh,epochTime:th,unixTime:vb,isoTime:mb});function yn(t,e,r,i){const n=Object.getPrototypeOf(e);e[r]=e.levelVal>e.levels.values[r]?cs:n[r]?n[r]:as[r]||as[i]||cs,lb(t,e,r)}function lb(t,e,r){!t.transmit&&e[r]===cs||(e[r]=function(i){return function(){const s=t.timestamp(),o=new Array(arguments.length),a=Object.getPrototypeOf&&Object.getPrototypeOf(this)===as?as:this;for(var c=0;c<o.length;c++)o[c]=arguments[c];if(t.serialize&&!t.asObject&&wo(o,this._serialize,this.serializers,this._stdErrSerialize),t.asObject?i.call(a,pb(this,r,o,s)):i.apply(a,o),t.transmit){const f=t.transmit.level||e.level,u=Sr.levels.values[f],d=Sr.levels.values[r];if(d<u)return;gb(this,{ts:s,methodLevel:r,methodValue:d,transmitLevel:f,transmitValue:Sr.levels.values[t.transmit.level||e.level],send:t.transmit.send,val:e.levelVal},o)}}}(e[r]))}function pb(t,e,r,i){t._serialize&&wo(r,t._serialize,t.serializers,t._stdErrSerialize);const n=r.slice();let s=n[0];const o={};i&&(o.time=i),o.level=Sr.levels.values[e];let a=(t._childLevel|0)+1;if(a<1&&(a=1),s!==null&&typeof s=="object"){for(;a--&&typeof n[0]=="object";)Object.assign(o,n.shift());s=n.length?Qu(n.shift(),n):void 0}else typeof s=="string"&&(s=Qu(n.shift(),n));return s!==void 0&&(o.msg=s),o}function wo(t,e,r,i){for(const n in t)if(i&&t[n]instanceof Error)t[n]=Sr.stdSerializers.err(t[n]);else if(typeof t[n]=="object"&&!Array.isArray(t[n]))for(const s in t[n])e&&e.indexOf(s)>-1&&s in r&&(t[n][s]=r[s](t[n][s]))}function vn(t,e,r){return function(){const i=new Array(1+arguments.length);i[0]=e;for(var n=1;n<i.length;n++)i[n]=arguments[n-1];return t[r].apply(this,i)}}function gb(t,e,r){const i=e.send,n=e.ts,s=e.methodLevel,o=e.methodValue,a=e.val,c=t._logEvent.bindings;wo(r,t._serialize||Object.keys(t.serializers),t.serializers,t._stdErrSerialize===void 0?!0:t._stdErrSerialize),t._logEvent.ts=n,t._logEvent.messages=r.filter(function(f){return c.indexOf(f)===-1}),t._logEvent.level.label=s,t._logEvent.level.value=o,i(s,t._logEvent,a),t._logEvent=Xa(c)}function Xa(t){return{ts:0,messages:[],bindings:t||[],level:{label:"",value:0}}}function bb(t){const e={type:t.constructor.name,msg:t.message,stack:t.stack};for(const r in t)e[r]===void 0&&(e[r]=t[r]);return e}function yb(t){return typeof t.timestamp=="function"?t.timestamp:t.timestamp===!1?eh:th}function _o(){return{}}function Qa(t){return t}function cs(){}function eh(){return!1}function th(){return Date.now()}function vb(){return Math.round(Date.now()/1e3)}function mb(){return new Date(Date.now()).toISOString()}function wb(){function t(e){return typeof e<"u"&&e}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return t(self)||t(window)||t(this)||{}}}const _b={level:"info"},fs="custom_context",ec=1e3*1024;class xb{constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}}class rh{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){const r=new xb(e);if(r.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${r.size}`);for(;this.size+r.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=r),this.tail=r):(this.head=r,this.tail=r),this.lengthInNodes++,this.sizeInBytes+=r.size}shift(){if(!this.head)return;const e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){const e=[];let r=this.head;for(;r!==null;)e.push(r.value),r=r.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};const r=e.value;return e=e.next,{done:!1,value:r}}}}}class ih{constructor(e,r=ec){this.level=e??"error",this.levelValue=Wr.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=r,this.logs=new rh(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,r){r===Wr.levels.values.error?console.error(e):r===Wr.levels.values.warn?console.warn(e):r===Wr.levels.values.debug?console.debug(e):r===Wr.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(Fi({timestamp:new Date().toISOString(),log:e}));const r=typeof e=="string"?JSON.parse(e).level:e.level;r>=this.levelValue&&this.forwardToConsole(e,r)}getLogs(){return this.logs}clearLogs(){this.logs=new rh(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const r=this.getLogArray();return r.push(Fi({extraMetadata:e})),new Blob(r,{type:"application/json"})}}class Eb{constructor(e,r=ec){this.baseChunkLogger=new ih(e,r)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){const r=URL.createObjectURL(this.logsToBlob(e)),i=document.createElement("a");i.href=r,i.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}}class Sb{constructor(e,r=ec){this.baseChunkLogger=new ih(e,r)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}}var Ib=Object.defineProperty,Ab=Object.defineProperties,Db=Object.getOwnPropertyDescriptors,nh=Object.getOwnPropertySymbols,$b=Object.prototype.hasOwnProperty,Ob=Object.prototype.propertyIsEnumerable,sh=(t,e,r)=>e in t?Ib(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,xo=(t,e)=>{for(var r in e||(e={}))$b.call(e,r)&&sh(t,r,e[r]);if(nh)for(var r of nh(e))Ob.call(e,r)&&sh(t,r,e[r]);return t},Eo=(t,e)=>Ab(t,Db(e));function tc(t){return Eo(xo({},t),{level:t?.level||_b.level})}function Mb(t,e=fs){return t[e]||""}function Pb(t,e,r=fs){return t[r]=e,t}function kt(t,e=fs){let r="";return typeof t.bindings>"u"?r=Mb(t,e):r=t.bindings().context||"",r}function Rb(t,e,r=fs){const i=kt(t,r);return i.trim()?`${i}/${e}`:e}function Ft(t,e,r=fs){const i=Rb(t,e,r),n=t.child({context:i});return Pb(n,i,r)}function Tb(t){var e,r;const i=new Eb((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:Wr(Eo(xo({},t.opts),{level:"trace",browser:Eo(xo({},(r=t.opts)==null?void 0:r.browser),{write:n=>i.write(n)})})),chunkLoggerController:i}}function Cb(t){var e;const r=new Sb((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:Wr(Eo(xo({},t.opts),{level:"trace"})),chunkLoggerController:r}}function Nb(t){return typeof t.loggerOverride<"u"&&typeof t.loggerOverride!="string"?{logger:t.loggerOverride,chunkLoggerController:null}:typeof window<"u"?Tb(t):Cb(t)}var Bb=Object.defineProperty,Fb=(t,e,r)=>e in t?Bb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,oh=(t,e,r)=>Fb(t,typeof e!="symbol"?e+"":e,r);class Lb extends Ni{constructor(e){super(),this.opts=e,oh(this,"protocol","wc"),oh(this,"version",2)}}var qb=Object.defineProperty,zb=(t,e,r)=>e in t?qb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ub=(t,e,r)=>zb(t,typeof e!="symbol"?e+"":e,r);class kb extends Ni{constructor(e,r){super(),this.core=e,this.logger=r,Ub(this,"records",new Map)}}class jb{constructor(e,r){this.logger=e,this.core=r}}class Kb extends Ni{constructor(e,r){super(),this.relayer=e,this.logger=r}}class Vb extends Ni{constructor(e){super()}}class Hb{constructor(e,r,i,n){this.core=e,this.logger=r,this.name=i}}class Wb extends Ni{constructor(e,r){super(),this.relayer=e,this.logger=r}}class Gb extends Ni{constructor(e,r){super(),this.core=e,this.logger=r}}class Yb{constructor(e,r,i){this.core=e,this.logger=r,this.store=i}}class Zb{constructor(e,r){this.projectId=e,this.logger=r}}class Jb{constructor(e,r,i){this.core=e,this.logger=r,this.telemetryEnabled=i}}var Xb=Object.defineProperty,Qb=(t,e,r)=>e in t?Xb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ah=(t,e,r)=>Qb(t,typeof e!="symbol"?e+"":e,r);class ey{constructor(e){this.opts=e,ah(this,"protocol","wc"),ah(this,"version",2)}}class ty{constructor(e){this.client=e}}function ry(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ch(t,...e){if(!ry(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function fh(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function iy(t,e){ch(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const mn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const rc=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);function ny(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function uh(t){return typeof t=="string"&&(t=ny(t)),ch(t),t}class sy{clone(){return this._cloneInto()}}function oy(t){const e=i=>t().update(uh(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function hh(t=32){if(mn&&typeof mn.getRandomValues=="function")return mn.getRandomValues(new Uint8Array(t));if(mn&&typeof mn.randomBytes=="function")return mn.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}function ay(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);const n=BigInt(32),s=BigInt(4294967295),o=Number(r>>n&s),a=Number(r&s),c=i?4:0,f=i?0:4;t.setUint32(e+c,o,i),t.setUint32(e+f,a,i)}class cy extends sy{constructor(e,r,i,n){super(),this.blockLen=e,this.outputLen=r,this.padOffset=i,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=rc(this.buffer)}update(e){fh(this);const{view:r,buffer:i,blockLen:n}=this;e=uh(e);const s=e.length;for(let o=0;o<s;){const a=Math.min(n-this.pos,s-o);if(a===n){const c=rc(e);for(;n<=s-o;o+=n)this.process(c,o);continue}i.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){fh(this),iy(e,this),this.finished=!0;const{buffer:r,view:i,blockLen:n,isLE:s}=this;let{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(i,0),o=0);for(let d=o;d<n;d++)r[d]=0;ay(i,n-8,BigInt(this.length*8),s),this.process(i,0);const a=rc(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=c/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<f;d++)a.setUint32(4*d,u[d],s)}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const i=e.slice(0,r);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:r,buffer:i,length:n,finished:s,destroyed:o,pos:a}=this;return e.length=n,e.pos=a,e.finished=s,e.destroyed=o,n%r&&e.buffer.set(i),e}}const So=BigInt(2**32-1),ic=BigInt(32);function dh(t,e=!1){return e?{h:Number(t&So),l:Number(t>>ic&So)}:{h:Number(t>>ic&So)|0,l:Number(t&So)|0}}function fy(t,e=!1){let r=new Uint32Array(t.length),i=new Uint32Array(t.length);for(let n=0;n<t.length;n++){const{h:s,l:o}=dh(t[n],e);[r[n],i[n]]=[s,o]}return[r,i]}const uy=(t,e)=>BigInt(t>>>0)<<ic|BigInt(e>>>0),hy=(t,e,r)=>t>>>r,dy=(t,e,r)=>t<<32-r|e>>>r,ly=(t,e,r)=>t>>>r|e<<32-r,py=(t,e,r)=>t<<32-r|e>>>r,gy=(t,e,r)=>t<<64-r|e>>>r-32,by=(t,e,r)=>t>>>r-32|e<<64-r,yy=(t,e)=>e,vy=(t,e)=>t,my=(t,e,r)=>t<<r|e>>>32-r,wy=(t,e,r)=>e<<r|t>>>32-r,_y=(t,e,r)=>e<<r-32|t>>>64-r,xy=(t,e,r)=>t<<r-32|e>>>64-r;function Ey(t,e,r,i){const n=(e>>>0)+(i>>>0);return{h:t+r+(n/2**32|0)|0,l:n|0}}const Sy=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),Iy=(t,e,r,i)=>e+r+i+(t/2**32|0)|0,Ay=(t,e,r,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0),Dy=(t,e,r,i,n)=>e+r+i+n+(t/2**32|0)|0,$y=(t,e,r,i,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0)+(n>>>0),Oy=(t,e,r,i,n,s)=>e+r+i+n+s+(t/2**32|0)|0,te={fromBig:dh,split:fy,toBig:uy,shrSH:hy,shrSL:dy,rotrSH:ly,rotrSL:py,rotrBH:gy,rotrBL:by,rotr32H:yy,rotr32L:vy,rotlSH:my,rotlSL:wy,rotlBH:_y,rotlBL:xy,add:Ey,add3L:Sy,add3H:Iy,add4L:Ay,add4H:Dy,add5H:Oy,add5L:$y},[My,Py]=(()=>te.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))))(),fi=new Uint32Array(80),ui=new Uint32Array(80);class Ry extends cy{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:r,Bh:i,Bl:n,Ch:s,Cl:o,Dh:a,Dl:c,Eh:f,El:u,Fh:d,Fl:g,Gh:m,Gl:b,Hh:x,Hl:I}=this;return[e,r,i,n,s,o,a,c,f,u,d,g,m,b,x,I]}set(e,r,i,n,s,o,a,c,f,u,d,g,m,b,x,I){this.Ah=e|0,this.Al=r|0,this.Bh=i|0,this.Bl=n|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=u|0,this.Fh=d|0,this.Fl=g|0,this.Gh=m|0,this.Gl=b|0,this.Hh=x|0,this.Hl=I|0}process(e,r){for(let P=0;P<16;P++,r+=4)fi[P]=e.getUint32(r),ui[P]=e.getUint32(r+=4);for(let P=16;P<80;P++){const R=fi[P-15]|0,N=ui[P-15]|0,B=te.rotrSH(R,N,1)^te.rotrSH(R,N,8)^te.shrSH(R,N,7),F=te.rotrSL(R,N,1)^te.rotrSL(R,N,8)^te.shrSL(R,N,7),L=fi[P-2]|0,C=ui[P-2]|0,W=te.rotrSH(L,C,19)^te.rotrBH(L,C,61)^te.shrSH(L,C,6),A=te.rotrSL(L,C,19)^te.rotrBL(L,C,61)^te.shrSL(L,C,6),h=te.add4L(F,A,ui[P-7],ui[P-16]),p=te.add4H(h,B,W,fi[P-7],fi[P-16]);fi[P]=p|0,ui[P]=h|0}let{Ah:i,Al:n,Bh:s,Bl:o,Ch:a,Cl:c,Dh:f,Dl:u,Eh:d,El:g,Fh:m,Fl:b,Gh:x,Gl:I,Hh:O,Hl:$}=this;for(let P=0;P<80;P++){const R=te.rotrSH(d,g,14)^te.rotrSH(d,g,18)^te.rotrBH(d,g,41),N=te.rotrSL(d,g,14)^te.rotrSL(d,g,18)^te.rotrBL(d,g,41),B=d&m^~d&x,F=g&b^~g&I,L=te.add5L($,N,F,Py[P],ui[P]),C=te.add5H(L,O,R,B,My[P],fi[P]),W=L|0,A=te.rotrSH(i,n,28)^te.rotrBH(i,n,34)^te.rotrBH(i,n,39),h=te.rotrSL(i,n,28)^te.rotrBL(i,n,34)^te.rotrBL(i,n,39),p=i&s^i&a^s&a,v=n&o^n&c^o&c;O=x|0,$=I|0,x=m|0,I=b|0,m=d|0,b=g|0,{h:d,l:g}=te.add(f|0,u|0,C|0,W|0),f=a|0,u=c|0,a=s|0,c=o|0,s=i|0,o=n|0;const y=te.add3L(W,h,v);i=te.add3H(y,C,A,p),n=y|0}({h:i,l:n}=te.add(this.Ah|0,this.Al|0,i|0,n|0)),{h:s,l:o}=te.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=te.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=te.add(this.Dh|0,this.Dl|0,f|0,u|0),{h:d,l:g}=te.add(this.Eh|0,this.El|0,d|0,g|0),{h:m,l:b}=te.add(this.Fh|0,this.Fl|0,m|0,b|0),{h:x,l:I}=te.add(this.Gh|0,this.Gl|0,x|0,I|0),{h:O,l:$}=te.add(this.Hh|0,this.Hl|0,O|0,$|0),this.set(i,n,s,o,a,c,f,u,d,g,m,b,x,I,O,$)}roundClean(){fi.fill(0),ui.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Ty=oy(()=>new Ry);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const nc=BigInt(0),lh=BigInt(1),Cy=BigInt(2);function sc(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function oc(t){if(!sc(t))throw new Error("Uint8Array expected")}function ac(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const Ny=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function cc(t){oc(t);let e="";for(let r=0;r<t.length;r++)e+=Ny[t[r]];return e}function ph(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?nc:BigInt("0x"+t)}const Gr={_0:48,_9:57,A:65,F:70,a:97,f:102};function gh(t){if(t>=Gr._0&&t<=Gr._9)return t-Gr._0;if(t>=Gr.A&&t<=Gr.F)return t-(Gr.A-10);if(t>=Gr.a&&t<=Gr.f)return t-(Gr.a-10)}function bh(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const i=new Uint8Array(r);for(let n=0,s=0;n<r;n++,s+=2){const o=gh(t.charCodeAt(s)),a=gh(t.charCodeAt(s+1));if(o===void 0||a===void 0){const c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}i[n]=o*16+a}return i}function By(t){return ph(cc(t))}function Io(t){return oc(t),ph(cc(Uint8Array.from(t).reverse()))}function yh(t,e){return bh(t.toString(16).padStart(e*2,"0"))}function fc(t,e){return yh(t,e).reverse()}function Yr(t,e,r){let i;if(typeof e=="string")try{i=bh(e)}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(sc(e))i=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const n=i.length;if(typeof r=="number"&&n!==r)throw new Error(t+" of length "+r+" expected, got "+n);return i}function vh(...t){let e=0;for(let i=0;i<t.length;i++){const n=t[i];oc(n),e+=n.length}const r=new Uint8Array(e);for(let i=0,n=0;i<t.length;i++){const s=t[i];r.set(s,n),n+=s.length}return r}const uc=t=>typeof t=="bigint"&&nc<=t;function Fy(t,e,r){return uc(t)&&uc(e)&&uc(r)&&e<=t&&t<r}function us(t,e,r,i){if(!Fy(e,r,i))throw new Error("expected valid "+t+": "+r+" <= n < "+i+", got "+e)}function Ly(t){let e;for(e=0;t>nc;t>>=lh,e+=1);return e}const qy=t=>(Cy<<BigInt(t-1))-lh,zy={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||sc(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function hc(t,e,r={}){const i=(n,s,o)=>{const a=zy[s];if(typeof a!="function")throw new Error("invalid validator function");const c=t[n];if(!(o&&c===void 0)&&!a(c,t))throw new Error("param "+String(n)+" is invalid. Expected "+s+", got "+c)};for(const[n,s]of Object.entries(e))i(n,s,!1);for(const[n,s]of Object.entries(r))i(n,s,!0);return t}function mh(t){const e=new WeakMap;return(r,...i)=>{const n=e.get(r);if(n!==void 0)return n;const s=t(r,...i);return e.set(r,s),s}}const ut=BigInt(0),rt=BigInt(1),Li=BigInt(2),Uy=BigInt(3),dc=BigInt(4),wh=BigInt(5),_h=BigInt(8);function ot(t,e){const r=t%e;return r>=ut?r:e+r}function ky(t,e,r){if(e<ut)throw new Error("invalid exponent, negatives unsupported");if(r<=ut)throw new Error("invalid modulus");if(r===rt)return ut;let i=rt;for(;e>ut;)e&rt&&(i=i*t%r),t=t*t%r,e>>=rt;return i}function Ir(t,e,r){let i=t;for(;e-- >ut;)i*=i,i%=r;return i}function xh(t,e){if(t===ut)throw new Error("invert: expected non-zero number");if(e<=ut)throw new Error("invert: expected positive modulus, got "+e);let r=ot(t,e),i=e,n=ut,s=rt;for(;r!==ut;){const o=i/r,a=i%r,c=n-s*o;i=r,r=a,n=s,s=c}if(i!==rt)throw new Error("invert: does not exist");return ot(n,e)}function jy(t){const e=(t-rt)/Li;let r,i,n;for(r=t-rt,i=0;r%Li===ut;r/=Li,i++);for(n=Li;n<t&&ky(n,e,t)!==t-rt;n++)if(n>1e3)throw new Error("Cannot find square root: likely non-prime P");if(i===1){const o=(t+rt)/dc;return function(a,c){const f=a.pow(c,o);if(!a.eql(a.sqr(f),c))throw new Error("Cannot find square root");return f}}const s=(r+rt)/Li;return function(o,a){if(o.pow(a,e)===o.neg(o.ONE))throw new Error("Cannot find square root");let c=i,f=o.pow(o.mul(o.ONE,n),r),u=o.pow(a,s),d=o.pow(a,r);for(;!o.eql(d,o.ONE);){if(o.eql(d,o.ZERO))return o.ZERO;let g=1;for(let b=o.sqr(d);g<c&&!o.eql(b,o.ONE);g++)b=o.sqr(b);const m=o.pow(f,rt<<BigInt(c-g-1));f=o.sqr(m),u=o.mul(u,m),d=o.mul(d,f),c=g}return u}}function Ky(t){if(t%dc===Uy){const e=(t+rt)/dc;return function(r,i){const n=r.pow(i,e);if(!r.eql(r.sqr(n),i))throw new Error("Cannot find square root");return n}}if(t%_h===wh){const e=(t-wh)/_h;return function(r,i){const n=r.mul(i,Li),s=r.pow(n,e),o=r.mul(i,s),a=r.mul(r.mul(o,Li),s),c=r.mul(o,r.sub(a,r.ONE));if(!r.eql(r.sqr(c),i))throw new Error("Cannot find square root");return c}}return jy(t)}const Vy=(t,e)=>(ot(t,e)&rt)===rt,Hy=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Wy(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=Hy.reduce((i,n)=>(i[n]="function",i),e);return hc(t,r)}function Gy(t,e,r){if(r<ut)throw new Error("invalid exponent, negatives unsupported");if(r===ut)return t.ONE;if(r===rt)return e;let i=t.ONE,n=e;for(;r>ut;)r&rt&&(i=t.mul(i,n)),n=t.sqr(n),r>>=rt;return i}function Yy(t,e){const r=new Array(e.length),i=e.reduce((s,o,a)=>t.is0(o)?s:(r[a]=s,t.mul(s,o)),t.ONE),n=t.inv(i);return e.reduceRight((s,o,a)=>t.is0(o)?s:(r[a]=t.mul(s,r[a]),t.mul(s,o)),n),r}function Eh(t,e){const r=e!==void 0?e:t.toString(2).length,i=Math.ceil(r/8);return{nBitLength:r,nByteLength:i}}function Sh(t,e,r=!1,i={}){if(t<=ut)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:n,nByteLength:s}=Eh(t,e);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:t,isLE:r,BITS:n,BYTES:s,MASK:qy(n),ZERO:ut,ONE:rt,create:c=>ot(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return ut<=c&&c<t},is0:c=>c===ut,isOdd:c=>(c&rt)===rt,neg:c=>ot(-c,t),eql:(c,f)=>c===f,sqr:c=>ot(c*c,t),add:(c,f)=>ot(c+f,t),sub:(c,f)=>ot(c-f,t),mul:(c,f)=>ot(c*f,t),pow:(c,f)=>Gy(a,c,f),div:(c,f)=>ot(c*xh(f,t),t),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>xh(c,t),sqrt:i.sqrt||(c=>(o||(o=Ky(t)),o(a,c))),invertBatch:c=>Yy(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>r?fc(c,s):yh(c,s),fromBytes:c=>{if(c.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+c.length);return r?Io(c):By(c)}});return Object.freeze(a)}const Ih=BigInt(0),Ao=BigInt(1);function lc(t,e){const r=e.negate();return t?r:e}function Ah(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function pc(t,e){Ah(t,e);const r=Math.ceil(e/t)+1,i=2**(t-1);return{windows:r,windowSize:i}}function Zy(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((r,i)=>{if(!(r instanceof e))throw new Error("invalid point at index "+i)})}function Jy(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,i)=>{if(!e.isValid(r))throw new Error("invalid scalar at index "+i)})}const gc=new WeakMap,Dh=new WeakMap;function bc(t){return Dh.get(t)||1}function Xy(t,e){return{constTimeNegate:lc,hasPrecomputes(r){return bc(r)!==1},unsafeLadder(r,i,n=t.ZERO){let s=r;for(;i>Ih;)i&Ao&&(n=n.add(s)),s=s.double(),i>>=Ao;return n},precomputeWindow(r,i){const{windows:n,windowSize:s}=pc(i,e),o=[];let a=r,c=a;for(let f=0;f<n;f++){c=a,o.push(c);for(let u=1;u<s;u++)c=c.add(a),o.push(c);a=c.double()}return o},wNAF(r,i,n){const{windows:s,windowSize:o}=pc(r,e);let a=t.ZERO,c=t.BASE;const f=BigInt(2**r-1),u=2**r,d=BigInt(r);for(let g=0;g<s;g++){const m=g*o;let b=Number(n&f);n>>=d,b>o&&(b-=u,n+=Ao);const x=m,I=m+Math.abs(b)-1,O=g%2!==0,$=b<0;b===0?c=c.add(lc(O,i[x])):a=a.add(lc($,i[I]))}return{p:a,f:c}},wNAFUnsafe(r,i,n,s=t.ZERO){const{windows:o,windowSize:a}=pc(r,e),c=BigInt(2**r-1),f=2**r,u=BigInt(r);for(let d=0;d<o;d++){const g=d*a;if(n===Ih)break;let m=Number(n&c);if(n>>=u,m>a&&(m-=f,n+=Ao),m===0)continue;let b=i[g+Math.abs(m)-1];m<0&&(b=b.negate()),s=s.add(b)}return s},getPrecomputes(r,i,n){let s=gc.get(i);return s||(s=this.precomputeWindow(i,r),r!==1&&gc.set(i,n(s))),s},wNAFCached(r,i,n){const s=bc(r);return this.wNAF(s,this.getPrecomputes(s,r,n),i)},wNAFCachedUnsafe(r,i,n,s){const o=bc(r);return o===1?this.unsafeLadder(r,i,s):this.wNAFUnsafe(o,this.getPrecomputes(o,r,n),i,s)},setWindowSize(r,i){Ah(i,e),Dh.set(r,i),gc.delete(r)}}}function Qy(t,e,r,i){if(Zy(r,t),Jy(i,e),r.length!==i.length)throw new Error("arrays of points and scalars must have equal length");const n=t.ZERO,s=Ly(BigInt(r.length)),o=s>12?s-3:s>4?s-2:s?2:1,a=(1<<o)-1,c=new Array(a+1).fill(n),f=Math.floor((e.BITS-1)/o)*o;let u=n;for(let d=f;d>=0;d-=o){c.fill(n);for(let m=0;m<i.length;m++){const b=i[m],x=Number(b>>BigInt(d)&BigInt(a));c[x]=c[x].add(r[m])}let g=n;for(let m=c.length-1,b=n;m>0;m--)b=b.add(c[m]),g=g.add(b);if(u=u.add(g),d!==0)for(let m=0;m<o;m++)u=u.double()}return u}function e2(t){return Wy(t.Fp),hc(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Eh(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}const lr=BigInt(0),jt=BigInt(1),Do=BigInt(2),t2=BigInt(8),r2={zip215:!0};function i2(t){const e=e2(t);return hc(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function n2(t){const e=i2(t),{Fp:r,n:i,prehash:n,hash:s,randomBytes:o,nByteLength:a,h:c}=e,f=Do<<BigInt(a*8)-jt,u=r.create,d=Sh(e.n,e.nBitLength),g=e.uvRatio||((y,w)=>{try{return{isValid:!0,value:r.sqrt(y*r.inv(w))}}catch{return{isValid:!1,value:lr}}}),m=e.adjustScalarBytes||(y=>y),b=e.domain||((y,w,S)=>{if(ac("phflag",S),w.length||S)throw new Error("Contexts/pre-hash are not supported");return y});function x(y,w){us("coordinate "+y,w,lr,f)}function I(y){if(!(y instanceof P))throw new Error("ExtendedPoint expected")}const O=mh((y,w)=>{const{ex:S,ey:D,ez:_}=y,l=y.is0();w==null&&(w=l?t2:r.inv(_));const E=u(S*w),q=u(D*w),z=u(_*w);if(l)return{x:lr,y:jt};if(z!==jt)throw new Error("invZ was invalid");return{x:E,y:q}}),$=mh(y=>{const{a:w,d:S}=e;if(y.is0())throw new Error("bad point: ZERO");const{ex:D,ey:_,ez:l,et:E}=y,q=u(D*D),z=u(_*_),U=u(l*l),k=u(U*U),G=u(q*w),J=u(U*u(G+z)),X=u(k+u(S*u(q*z)));if(J!==X)throw new Error("bad point: equation left != right (1)");const Z=u(D*_),Q=u(l*E);if(Z!==Q)throw new Error("bad point: equation left != right (2)");return!0});class P{constructor(w,S,D,_){this.ex=w,this.ey=S,this.ez=D,this.et=_,x("x",w),x("y",S),x("z",D),x("t",_),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(w){if(w instanceof P)throw new Error("extended point not allowed");const{x:S,y:D}=w||{};return x("x",S),x("y",D),new P(S,D,jt,u(S*D))}static normalizeZ(w){const S=r.invertBatch(w.map(D=>D.ez));return w.map((D,_)=>D.toAffine(S[_])).map(P.fromAffine)}static msm(w,S){return Qy(P,d,w,S)}_setWindowSize(w){B.setWindowSize(this,w)}assertValidity(){$(this)}equals(w){I(w);const{ex:S,ey:D,ez:_}=this,{ex:l,ey:E,ez:q}=w,z=u(S*q),U=u(l*_),k=u(D*q),G=u(E*_);return z===U&&k===G}is0(){return this.equals(P.ZERO)}negate(){return new P(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){const{a:w}=e,{ex:S,ey:D,ez:_}=this,l=u(S*S),E=u(D*D),q=u(Do*u(_*_)),z=u(w*l),U=S+D,k=u(u(U*U)-l-E),G=z+E,J=G-q,X=z-E,Z=u(k*J),Q=u(G*X),Fe=u(k*X),re=u(J*G);return new P(Z,Q,re,Fe)}add(w){I(w);const{a:S,d:D}=e,{ex:_,ey:l,ez:E,et:q}=this,{ex:z,ey:U,ez:k,et:G}=w;if(S===BigInt(-1)){const Ae=u((l-_)*(U+z)),on=u((l+_)*(U-z)),xe=u(on-Ae);if(xe===lr)return this.double();const De=u(E*Do*G),an=u(q*Do*k),$e=an+De,Oe=on+Ae,cn=an-De,ye=u($e*xe),Ee=u(Oe*cn),fn=u($e*cn),ae=u(xe*Oe);return new P(ye,Ee,ae,fn)}const J=u(_*z),X=u(l*U),Z=u(q*D*G),Q=u(E*k),Fe=u((_+l)*(z+U)-J-X),re=Q-Z,oe=Q+Z,ct=u(X-S*J),he=u(Fe*re),Pe=u(oe*ct),es=u(Fe*ct),Re=u(re*oe);return new P(he,Pe,Re,es)}subtract(w){return this.add(w.negate())}wNAF(w){return B.wNAFCached(this,w,P.normalizeZ)}multiply(w){const S=w;us("scalar",S,jt,i);const{p:D,f:_}=this.wNAF(S);return P.normalizeZ([D,_])[0]}multiplyUnsafe(w,S=P.ZERO){const D=w;return us("scalar",D,lr,i),D===lr?N:this.is0()||D===jt?this:B.wNAFCachedUnsafe(this,D,P.normalizeZ,S)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return B.unsafeLadder(this,i).is0()}toAffine(w){return O(this,w)}clearCofactor(){const{h:w}=e;return w===jt?this:this.multiplyUnsafe(w)}static fromHex(w,S=!1){const{d:D,a:_}=e,l=r.BYTES;w=Yr("pointHex",w,l),ac("zip215",S);const E=w.slice(),q=w[l-1];E[l-1]=q&-129;const z=Io(E),U=S?f:r.ORDER;us("pointHex.y",z,lr,U);const k=u(z*z),G=u(k-jt),J=u(D*k-_);let{isValid:X,value:Z}=g(G,J);if(!X)throw new Error("Point.fromHex: invalid y coordinate");const Q=(Z&jt)===jt,Fe=(q&128)!==0;if(!S&&Z===lr&&Fe)throw new Error("Point.fromHex: x=0 and x_0=1");return Fe!==Q&&(Z=u(-Z)),P.fromAffine({x:Z,y:z})}static fromPrivateKey(w){return C(w).point}toRawBytes(){const{x:w,y:S}=this.toAffine(),D=fc(S,r.BYTES);return D[D.length-1]|=w&jt?128:0,D}toHex(){return cc(this.toRawBytes())}}P.BASE=new P(e.Gx,e.Gy,jt,u(e.Gx*e.Gy)),P.ZERO=new P(lr,jt,jt,lr);const{BASE:R,ZERO:N}=P,B=Xy(P,a*8);function F(y){return ot(y,i)}function L(y){return F(Io(y))}function C(y){const w=r.BYTES;y=Yr("private key",y,w);const S=Yr("hashed private key",s(y),2*w),D=m(S.slice(0,w)),_=S.slice(w,2*w),l=L(D),E=R.multiply(l),q=E.toRawBytes();return{head:D,prefix:_,scalar:l,point:E,pointBytes:q}}function W(y){return C(y).pointBytes}function A(y=new Uint8Array,...w){const S=vh(...w);return L(s(b(S,Yr("context",y),!!n)))}function h(y,w,S={}){y=Yr("message",y),n&&(y=n(y));const{prefix:D,scalar:_,pointBytes:l}=C(w),E=A(S.context,D,y),q=R.multiply(E).toRawBytes(),z=A(S.context,q,l,y),U=F(E+z*_);us("signature.s",U,lr,i);const k=vh(q,fc(U,r.BYTES));return Yr("result",k,r.BYTES*2)}const p=r2;function v(y,w,S,D=p){const{context:_,zip215:l}=D,E=r.BYTES;y=Yr("signature",y,2*E),w=Yr("message",w),S=Yr("publicKey",S,E),l!==void 0&&ac("zip215",l),n&&(w=n(w));const q=Io(y.slice(E,2*E));let z,U,k;try{z=P.fromHex(S,l),U=P.fromHex(y.slice(0,E),l),k=R.multiplyUnsafe(q)}catch{return!1}if(!l&&z.isSmallOrder())return!1;const G=A(_,U.toRawBytes(),z.toRawBytes(),w);return U.add(z.multiplyUnsafe(G)).subtract(k).clearCofactor().equals(P.ZERO)}return R._setWindowSize(8),{CURVE:e,getPublicKey:W,sign:h,verify:v,ExtendedPoint:P,utils:{getExtendedPublicKey:C,randomPrivateKey:()=>o(r.BYTES),precompute(y=8,w=P.BASE){return w._setWindowSize(y),w.multiply(BigInt(3)),w}}}}BigInt(0),BigInt(1);const yc=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),$h=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const s2=BigInt(1),Oh=BigInt(2);BigInt(3);const o2=BigInt(5),a2=BigInt(8);function c2(t){const e=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),s=yc,o=t*t%s*t%s,a=Ir(o,Oh,s)*o%s,c=Ir(a,s2,s)*t%s,f=Ir(c,o2,s)*c%s,u=Ir(f,e,s)*f%s,d=Ir(u,r,s)*u%s,g=Ir(d,i,s)*d%s,m=Ir(g,n,s)*g%s,b=Ir(m,n,s)*g%s,x=Ir(b,e,s)*f%s;return{pow_p_5_8:Ir(x,Oh,s)*t%s,b2:o}}function f2(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function u2(t,e){const r=yc,i=ot(e*e*e,r),n=ot(i*i*e,r),s=c2(t*n).pow_p_5_8;let o=ot(t*i*s,r);const a=ot(e*o*o,r),c=o,f=ot(o*$h,r),u=a===t,d=a===ot(-t,r),g=a===ot(-t*$h,r);return u&&(o=c),(d||g)&&(o=f),Vy(o,r)&&(o=ot(-o,r)),{isValid:u||d,value:o}}const h2=(()=>Sh(yc,void 0,!0))(),d2=(()=>({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:h2,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:a2,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Ty,randomBytes:hh,adjustScalarBytes:f2,uvRatio:u2}))(),Mh=(()=>n2(d2))(),l2="EdDSA",p2="JWT",$o=".",Oo="base64url",Ph="utf8",Rh="utf8",g2=":",b2="did",y2="key",Th="base58btc",v2="z",m2="K36",w2=32;function vc(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function Ch(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?vc(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function Nh(t,e){e||(e=t.reduce((n,s)=>n+s.length,0));const r=Ch(e);let i=0;for(const n of t)r.set(n,i),i+=n.length;return vc(r)}function _2(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=n}var a=t.length,c=t.charAt(0),f=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function d(b){if(b instanceof Uint8Array||(ArrayBuffer.isView(b)?b=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):Array.isArray(b)&&(b=Uint8Array.from(b))),!(b instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(b.length===0)return"";for(var x=0,I=0,O=0,$=b.length;O!==$&&b[O]===0;)O++,x++;for(var P=($-O)*u+1>>>0,R=new Uint8Array(P);O!==$;){for(var N=b[O],B=0,F=P-1;(N!==0||B<I)&&F!==-1;F--,B++)N+=256*R[F]>>>0,R[F]=N%a>>>0,N=N/a>>>0;if(N!==0)throw new Error("Non-zero carry");I=B,O++}for(var L=P-I;L!==P&&R[L]===0;)L++;for(var C=c.repeat(x);L<P;++L)C+=t.charAt(R[L]);return C}function g(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;var x=0;if(b[x]!==" "){for(var I=0,O=0;b[x]===c;)I++,x++;for(var $=(b.length-x)*f+1>>>0,P=new Uint8Array($);b[x];){var R=r[b.charCodeAt(x)];if(R===255)return;for(var N=0,B=$-1;(R!==0||N<O)&&B!==-1;B--,N++)R+=a*P[B]>>>0,P[B]=R%256>>>0,R=R/256>>>0;if(R!==0)throw new Error("Non-zero carry");O=N,x++}if(b[x]!==" "){for(var F=$-O;F!==$&&P[F]===0;)F++;for(var L=new Uint8Array(I+($-F)),C=I;F!==$;)L[C++]=P[F++];return L}}}function m(b){var x=g(b);if(x)return x;throw new Error(`Non-${e} character`)}return{encode:d,decodeUnsafe:g,decode:m}}var x2=_2,E2=x2;const Bh=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},S2=t=>new TextEncoder().encode(t),I2=t=>new TextDecoder().decode(t);class A2{constructor(e,r,i){this.name=e,this.prefix=r,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class D2{constructor(e,r,i){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Fh(this,e)}}class $2{constructor(e){this.decoders=e}or(e){return Fh(this,e)}decode(e){const r=e[0],i=this.decoders[r];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Fh=(t,e)=>new $2({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class O2{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new A2(e,r,i),this.decoder=new D2(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Mo=({name:t,prefix:e,encode:r,decode:i})=>new O2(t,e,r,i),hs=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=E2(r,e);return Mo({prefix:t,name:e,encode:i,decode:s=>Bh(n(s))})},M2=(t,e,r,i)=>{const n={};for(let u=0;u<e.length;++u)n[e[u]]=u;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,f=0;for(let u=0;u<s;++u){const d=n[t[u]];if(d===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<r|d,a+=r,a>=8&&(a-=8,o[f++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},P2=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>r;)o-=r,s+=e[n&a>>o];if(o&&(s+=e[n&a<<r-o]),i)for(;s.length*r&7;)s+="=";return s},wt=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>Mo({prefix:e,name:t,encode(n){return P2(n,i,r)},decode(n){return M2(n,i,r,t)}}),R2=Mo({prefix:"\0",name:"identity",encode:t=>I2(t),decode:t=>S2(t)});var T2=Object.freeze({__proto__:null,identity:R2});const C2=wt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var N2=Object.freeze({__proto__:null,base2:C2});const B2=wt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var F2=Object.freeze({__proto__:null,base8:B2});const L2=hs({prefix:"9",name:"base10",alphabet:"0123456789"});var q2=Object.freeze({__proto__:null,base10:L2});const z2=wt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),U2=wt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var k2=Object.freeze({__proto__:null,base16:z2,base16upper:U2});const j2=wt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),K2=wt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),V2=wt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),H2=wt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),W2=wt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),G2=wt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Y2=wt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Z2=wt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),J2=wt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var X2=Object.freeze({__proto__:null,base32:j2,base32upper:K2,base32pad:V2,base32padupper:H2,base32hex:W2,base32hexupper:G2,base32hexpad:Y2,base32hexpadupper:Z2,base32z:J2});const Q2=hs({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ev=hs({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var tv=Object.freeze({__proto__:null,base36:Q2,base36upper:ev});const rv=hs({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),iv=hs({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var nv=Object.freeze({__proto__:null,base58btc:rv,base58flickr:iv});const sv=wt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ov=wt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),av=wt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),cv=wt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var fv=Object.freeze({__proto__:null,base64:sv,base64pad:ov,base64url:av,base64urlpad:cv});const Lh=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),uv=Lh.reduce((t,e,r)=>(t[r]=e,t),[]),hv=Lh.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function dv(t){return t.reduce((e,r)=>(e+=uv[r],e),"")}function lv(t){const e=[];for(const r of t){const i=hv[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const pv=Mo({prefix:"\u{1F680}",name:"base256emoji",encode:dv,decode:lv});var gv=Object.freeze({__proto__:null,base256emoji:pv}),bv=zh,qh=128,yv=127,vv=~yv,mv=Math.pow(2,31);function zh(t,e,r){e=e||[],r=r||0;for(var i=r;t>=mv;)e[r++]=t&255|qh,t/=128;for(;t&vv;)e[r++]=t&255|qh,t>>>=7;return e[r]=t|0,zh.bytes=r-i+1,e}var wv=mc,_v=128,Uh=127;function mc(t,i){var r=0,i=i||0,n=0,s=i,o,a=t.length;do{if(s>=a)throw mc.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=n<28?(o&Uh)<<n:(o&Uh)*Math.pow(2,n),n+=7}while(o>=_v);return mc.bytes=s-i,r}var xv=Math.pow(2,7),Ev=Math.pow(2,14),Sv=Math.pow(2,21),Iv=Math.pow(2,28),Av=Math.pow(2,35),Dv=Math.pow(2,42),$v=Math.pow(2,49),Ov=Math.pow(2,56),Mv=Math.pow(2,63),Pv=function(t){return t<xv?1:t<Ev?2:t<Sv?3:t<Iv?4:t<Av?5:t<Dv?6:t<$v?7:t<Ov?8:t<Mv?9:10},Rv={encode:bv,decode:wv,encodingLength:Pv},kh=Rv;const jh=(t,e,r=0)=>(kh.encode(t,e,r),e),Kh=t=>kh.encodingLength(t),wc=(t,e)=>{const r=e.byteLength,i=Kh(t),n=i+Kh(r),s=new Uint8Array(n+r);return jh(t,s,0),jh(r,s,i),s.set(e,n),new Tv(t,r,e,s)};class Tv{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const Vh=({name:t,code:e,encode:r})=>new Cv(t,e,r);class Cv{constructor(e,r,i){this.name=e,this.code=r,this.encode=i}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?wc(this.code,r):r.then(i=>wc(this.code,i))}else throw Error("Unknown type, must be binary type")}}const Hh=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Nv=Vh({name:"sha2-256",code:18,encode:Hh("SHA-256")}),Bv=Vh({name:"sha2-512",code:19,encode:Hh("SHA-512")});var Fv=Object.freeze({__proto__:null,sha256:Nv,sha512:Bv});const Wh=0,Lv="identity",Gh=Bh;var qv=Object.freeze({__proto__:null,identity:{code:Wh,name:Lv,encode:Gh,digest:t=>wc(Wh,Gh(t))}});new TextEncoder,new TextDecoder;const Yh={...T2,...N2,...F2,...q2,...k2,...X2,...tv,...nv,...fv,...gv};({...Fv,...qv});function Zh(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const Jh=Zh("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),_c=Zh("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=Ch(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Xh={utf8:Jh,"utf-8":Jh,hex:Yh.base16,latin1:_c,ascii:_c,binary:_c,...Yh};function Po(t,e="utf8"){const r=Xh[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}function wn(t,e="utf8"){const r=Xh[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?vc(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}function Qh(t){return bn(Po(wn(t,Oo),Ph))}function Ro(t){return Po(wn(Fi(t),Ph),Oo)}function ed(t){const e=wn(m2,Th),r=v2+Po(Nh([e,t]),Th);return[b2,y2,r].join(g2)}function zv(t){return Po(t,Oo)}function Uv(t){return wn(t,Oo)}function kv(t){return wn([Ro(t.header),Ro(t.payload)].join($o),Rh)}function jv(t){return[Ro(t.header),Ro(t.payload),zv(t.signature)].join($o)}function xc(t){const e=t.split($o),r=Qh(e[0]),i=Qh(e[1]),n=Uv(e[2]),s=wn(e.slice(0,2).join($o),Rh);return{header:r,payload:i,signature:n,data:s}}function td(t=hh(w2)){const e=Mh.getPublicKey(t);return{secretKey:Nh([t,e]),publicKey:e}}async function Kv(t,e,r,i,n=V.fromMiliseconds(Date.now())){const s={alg:l2,typ:p2},o=ed(i.publicKey),a=n+r,c={iss:o,sub:t,aud:e,iat:n,exp:a},f=kv({header:s,payload:c}),u=Mh.sign(f,i.secretKey.slice(0,32));return jv({header:s,payload:c,signature:u})}var rd=function(t,e,r){if(r||arguments.length===2)for(var i=0,n=e.length,s;i<n;i++)(s||!(i in e))&&(s||(s=Array.prototype.slice.call(e,0,i)),s[i]=e[i]);return t.concat(s||Array.prototype.slice.call(e))},Vv=function(){function t(e,r,i){this.name=e,this.version=r,this.os=i,this.type="browser"}return t}(),Hv=function(){function t(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return t}(),Wv=function(){function t(e,r,i,n){this.name=e,this.version=r,this.os=i,this.bot=n,this.type="bot-device"}return t}(),Gv=function(){function t(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return t}(),Yv=function(){function t(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return t}(),Zv=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,Jv=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,id=3,Xv=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["pie",/^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],["pie",/^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],["netfront",/^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FB[AS]V\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["curl",/^curl\/([0-9\.]+)$/],["searchbot",Zv]],nd=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Windows CE",/Windows CE|WinCE|Microsoft Pocket Internet Explorer/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function Qv(t){return t?sd(t):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new Yv:typeof navigator<"u"?sd(navigator.userAgent):rm()}function em(t){return t!==""&&Xv.reduce(function(e,r){var i=r[0],n=r[1];if(e)return e;var s=n.exec(t);return!!s&&[i,s]},!1)}function sd(t){var e=em(t);if(!e)return null;var r=e[0],i=e[1];if(r==="searchbot")return new Gv;var n=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);n?n.length<id&&(n=rd(rd([],n,!0),im(id-n.length),!0)):n=[];var s=n.join("."),o=tm(t),a=Jv.exec(t);return a&&a[1]?new Wv(r,s,o,a[1]):new Vv(r,s,o)}function tm(t){for(var e=0,r=nd.length;e<r;e++){var i=nd[e],n=i[0],s=i[1],o=s.exec(t);if(o)return n}return null}function rm(){var t=typeof process<"u"&&process.version;return t?new Hv(process.version.slice(1)):null}function im(t){for(var e=[],r=0;r<t;r++)e.push("0");return e}var ve={};Object.defineProperty(ve,"__esModule",{value:!0}),ve.getLocalStorage=ve.getLocalStorageOrThrow=ve.getCrypto=ve.getCryptoOrThrow=od=ve.getLocation=ve.getLocationOrThrow=Ec=ve.getNavigator=ve.getNavigatorOrThrow=ds=ve.getDocument=ve.getDocumentOrThrow=ve.getFromWindowOrThrow=ve.getFromWindow=void 0;function qi(t){let e;return typeof window<"u"&&typeof window[t]<"u"&&(e=window[t]),e}ve.getFromWindow=qi;function _n(t){const e=qi(t);if(!e)throw new Error(`${t} is not defined in Window`);return e}ve.getFromWindowOrThrow=_n;function nm(){return _n("document")}ve.getDocumentOrThrow=nm;function sm(){return qi("document")}var ds=ve.getDocument=sm;function om(){return _n("navigator")}ve.getNavigatorOrThrow=om;function am(){return qi("navigator")}var Ec=ve.getNavigator=am;function cm(){return _n("location")}ve.getLocationOrThrow=cm;function fm(){return qi("location")}var od=ve.getLocation=fm;function um(){return _n("crypto")}ve.getCryptoOrThrow=um;function hm(){return qi("crypto")}ve.getCrypto=hm;function dm(){return _n("localStorage")}ve.getLocalStorageOrThrow=dm;function lm(){return qi("localStorage")}ve.getLocalStorage=lm;var Sc={};Object.defineProperty(Sc,"__esModule",{value:!0});var ad=Sc.getWindowMetadata=void 0;const cd=ve;function pm(){let t,e;try{t=cd.getDocumentOrThrow(),e=cd.getLocationOrThrow()}catch{return null}function r(){const d=t.getElementsByTagName("link"),g=[];for(let m=0;m<d.length;m++){const b=d[m],x=b.getAttribute("rel");if(x&&x.toLowerCase().indexOf("icon")>-1){const I=b.getAttribute("href");if(I)if(I.toLowerCase().indexOf("https:")===-1&&I.toLowerCase().indexOf("http:")===-1&&I.indexOf("//")!==0){let O=e.protocol+"//"+e.host;if(I.indexOf("/")===0)O+=I;else{const $=e.pathname.split("/");$.pop();const P=$.join("/");O+=P+"/"+I}g.push(O)}else if(I.indexOf("//")===0){const O=e.protocol+I;g.push(O)}else g.push(I)}}return g}function i(...d){const g=t.getElementsByTagName("meta");for(let m=0;m<g.length;m++){const b=g[m],x=["itemprop","property","name"].map(I=>b.getAttribute(I)).filter(I=>I?d.includes(I):!1);if(x.length&&x){const I=b.getAttribute("content");if(I)return I}}return""}function n(){let d=i("name","og:site_name","og:title","twitter:title");return d||(d=t.title),d}function s(){return i("description","og:description","twitter:description","keywords")}const o=n(),a=s(),c=e.origin,f=r();return{description:a,url:c,icons:f,name:o}}ad=Sc.getWindowMetadata=pm;function ls(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function fd(t){return ls(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const ud="2.23.2";let Ic={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:r})=>e?`${t??"https://viem.sh"}${e}${r?`#${r}`:""}`:void 0,version:`viem@${ud}`};class zi extends Error{constructor(e,r={}){const i=(()=>r.cause instanceof zi?r.cause.details:r.cause?.message?r.cause.message:r.details)(),n=(()=>r.cause instanceof zi&&r.cause.docsPath||r.docsPath)(),s=Ic.getDocsUrl?.({...r,docsPath:n}),o=[e||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...i?[`Details: ${i}`]:[],...Ic.version?[`Version: ${Ic.version}`]:[]].join(`
15
+ `);super(o,r.cause?{cause:r.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=i,this.docsPath=n,this.metaMessages=r.metaMessages,this.name=r.name??this.name,this.shortMessage=e,this.version=ud}walk(e){return hd(this,e)}}function hd(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?hd(t.cause,e):e?null:t}class dd extends zi{constructor({size:e,targetSize:r,type:i}){super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (${e}) exceeds padding size (${r}).`,{name:"SizeExceedsPaddingSizeError"})}}function xn(t,{dir:e,size:r=32}={}){return typeof t=="string"?gm(t,{dir:e,size:r}):bm(t,{dir:e,size:r})}function gm(t,{dir:e,size:r=32}={}){if(r===null)return t;const i=t.replace("0x","");if(i.length>r*2)throw new dd({size:Math.ceil(i.length/2),targetSize:r,type:"hex"});return`0x${i[e==="right"?"padEnd":"padStart"](r*2,"0")}`}function bm(t,{dir:e,size:r=32}={}){if(r===null)return t;if(t.length>r)throw new dd({size:t.length,targetSize:r,type:"bytes"});const i=new Uint8Array(r);for(let n=0;n<r;n++){const s=e==="right";i[s?n:r-n-1]=t[s?n:t.length-n-1]}return i}class ym extends zi{constructor({max:e,min:r,signed:i,size:n,value:s}){super(`Number "${s}" is not in safe ${n?`${n*8}-bit ${i?"signed":"unsigned"} `:""}integer range ${e?`(${r} to ${e})`:`(above ${r})`}`,{name:"IntegerOutOfRangeError"})}}class vm extends zi{constructor({givenSize:e,maxSize:r}){super(`Size cannot exceed ${r} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function En(t,{size:e}){if(fd(t)>e)throw new vm({givenSize:fd(t),maxSize:e})}function Ac(t,e={}){const{signed:r}=e;e.size&&En(t,{size:e.size});const i=BigInt(t);if(!r)return i;const n=(t.length-2)/2,s=(1n<<BigInt(n)*8n-1n)-1n;return i<=s?i:i-BigInt(`0x${"f".padStart(n*2,"f")}`)-1n}function mm(t,e={}){return Number(Ac(t,e))}const wm=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Dc(t,e={}){return typeof t=="number"||typeof t=="bigint"?pd(t,e):typeof t=="string"?Em(t,e):typeof t=="boolean"?_m(t,e):ld(t,e)}function _m(t,e={}){const r=`0x${Number(t)}`;return typeof e.size=="number"?(En(r,{size:e.size}),xn(r,{size:e.size})):r}function ld(t,e={}){let r="";for(let n=0;n<t.length;n++)r+=wm[t[n]];const i=`0x${r}`;return typeof e.size=="number"?(En(i,{size:e.size}),xn(i,{dir:"right",size:e.size})):i}function pd(t,e={}){const{signed:r,size:i}=e,n=BigInt(t);let s;i?r?s=(1n<<BigInt(i)*8n-1n)-1n:s=2n**(BigInt(i)*8n)-1n:typeof t=="number"&&(s=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof s=="bigint"&&r?-s-1n:0;if(s&&n>s||n<o){const c=typeof t=="bigint"?"n":"";throw new ym({max:s?`${s}${c}`:void 0,min:`${o}${c}`,signed:r,size:i,value:`${t}${c}`})}const a=`0x${(r&&n<0?(1n<<BigInt(i*8))+BigInt(n):n).toString(16)}`;return i?xn(a,{size:i}):a}const xm=new TextEncoder;function Em(t,e={}){const r=xm.encode(t);return ld(r,e)}const Sm=new TextEncoder;function Im(t,e={}){return typeof t=="number"||typeof t=="bigint"?Dm(t,e):typeof t=="boolean"?Am(t,e):ls(t)?bd(t,e):yd(t,e)}function Am(t,e={}){const r=new Uint8Array(1);return r[0]=Number(t),typeof e.size=="number"?(En(r,{size:e.size}),xn(r,{size:e.size})):r}const Zr={zero:48,nine:57,A:65,F:70,a:97,f:102};function gd(t){if(t>=Zr.zero&&t<=Zr.nine)return t-Zr.zero;if(t>=Zr.A&&t<=Zr.F)return t-(Zr.A-10);if(t>=Zr.a&&t<=Zr.f)return t-(Zr.a-10)}function bd(t,e={}){let r=t;e.size&&(En(r,{size:e.size}),r=xn(r,{dir:"right",size:e.size}));let i=r.slice(2);i.length%2&&(i=`0${i}`);const n=i.length/2,s=new Uint8Array(n);for(let o=0,a=0;o<n;o++){const c=gd(i.charCodeAt(a++)),f=gd(i.charCodeAt(a++));if(c===void 0||f===void 0)throw new zi(`Invalid byte sequence ("${i[a-2]}${i[a-1]}" in "${i}").`);s[o]=c*16+f}return s}function Dm(t,e){const r=pd(t,e);return bd(r)}function yd(t,e={}){const r=Sm.encode(t);return typeof e.size=="number"?(En(r,{size:e.size}),xn(r,{dir:"right",size:e.size})):r}function To(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function $m(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ps(t,...e){if(!$m(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Om(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");To(t.outputLen),To(t.blockLen)}function Sn(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function vd(t,e){ps(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const Co=BigInt(2**32-1),md=BigInt(32);function Mm(t,e=!1){return e?{h:Number(t&Co),l:Number(t>>md&Co)}:{h:Number(t>>md&Co)|0,l:Number(t&Co)|0}}function Pm(t,e=!1){let r=new Uint32Array(t.length),i=new Uint32Array(t.length);for(let n=0;n<t.length;n++){const{h:s,l:o}=Mm(t[n],e);[r[n],i[n]]=[s,o]}return[r,i]}const Rm=(t,e,r)=>t<<r|e>>>32-r,Tm=(t,e,r)=>e<<r|t>>>32-r,Cm=(t,e,r)=>e<<r-32|t>>>64-r,Nm=(t,e,r)=>t<<r-32|e>>>64-r,In=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Bm(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function $c(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Ar(t,e){return t<<32-e|t>>>e}const wd=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function Fm(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function _d(t){for(let e=0;e<t.length;e++)t[e]=Fm(t[e])}function Lm(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function No(t){return typeof t=="string"&&(t=Lm(t)),ps(t),t}function qm(...t){let e=0;for(let i=0;i<t.length;i++){const n=t[i];ps(n),e+=n.length}const r=new Uint8Array(e);for(let i=0,n=0;i<t.length;i++){const s=t[i];r.set(s,n),n+=s.length}return r}class Oc{clone(){return this._cloneInto()}}function xd(t){const e=i=>t().update(No(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Ed(t=32){if(In&&typeof In.getRandomValues=="function")return In.getRandomValues(new Uint8Array(t));if(In&&typeof In.randomBytes=="function")return In.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const Sd=[],Id=[],Ad=[],zm=BigInt(0),gs=BigInt(1),Um=BigInt(2),km=BigInt(7),jm=BigInt(256),Km=BigInt(113);for(let t=0,e=gs,r=1,i=0;t<24;t++){[r,i]=[i,(2*r+3*i)%5],Sd.push(2*(5*i+r)),Id.push((t+1)*(t+2)/2%64);let n=zm;for(let s=0;s<7;s++)e=(e<<gs^(e>>km)*Km)%jm,e&Um&&(n^=gs<<(gs<<BigInt(s))-gs);Ad.push(n)}const[Vm,Hm]=Pm(Ad,!0),Dd=(t,e,r)=>r>32?Cm(t,e,r):Rm(t,e,r),$d=(t,e,r)=>r>32?Nm(t,e,r):Tm(t,e,r);function Wm(t,e=24){const r=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)r[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,f=r[c],u=r[c+1],d=Dd(f,u,1)^r[a],g=$d(f,u,1)^r[a+1];for(let m=0;m<50;m+=10)t[o+m]^=d,t[o+m+1]^=g}let n=t[2],s=t[3];for(let o=0;o<24;o++){const a=Id[o],c=Dd(n,s,a),f=$d(n,s,a),u=Sd[o];n=t[u],s=t[u+1],t[u]=c,t[u+1]=f}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)r[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~r[(a+2)%10]&r[(a+4)%10]}t[0]^=Vm[i],t[1]^=Hm[i]}r.fill(0)}class Mc extends Oc{constructor(e,r,i,n=!1,s=24){if(super(),this.blockLen=e,this.suffix=r,this.outputLen=i,this.enableXOF=n,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,To(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Bm(this.state)}keccak(){wd||_d(this.state32),Wm(this.state32,this.rounds),wd||_d(this.state32),this.posOut=0,this.pos=0}update(e){Sn(this);const{blockLen:r,state:i}=this;e=No(e);const n=e.length;for(let s=0;s<n;){const o=Math.min(r-this.pos,n-s);for(let a=0;a<o;a++)i[this.pos++]^=e[s++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:r,pos:i,blockLen:n}=this;e[i]^=r,r&128&&i===n-1&&this.keccak(),e[n-1]^=128,this.keccak()}writeInto(e){Sn(this,!1),ps(e),this.finish();const r=this.state,{blockLen:i}=this;for(let n=0,s=e.length;n<s;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,s-n);e.set(r.subarray(this.posOut,this.posOut+o),n),this.posOut+=o,n+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return To(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(vd(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:r,suffix:i,outputLen:n,rounds:s,enableXOF:o}=this;return e||(e=new Mc(r,i,n,o,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=i,e.outputLen=n,e.enableXOF=o,e.destroyed=this.destroyed,e}}const Od=((t,e,r)=>xd(()=>new Mc(e,t,r)))(1,136,256/8);function Md(t,e){const r=e||"hex",i=Od(ls(t,{strict:!1})?Im(t):t);return r==="bytes"?i:Dc(i)}class Pd extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const r=super.get(e);return super.has(e)&&r!==void 0&&(this.delete(e),super.set(e,r)),r}set(e,r){if(super.set(e,r),this.maxSize&&this.size>this.maxSize){const i=this.keys().next().value;i&&this.delete(i)}return this}}const Pc=new Pd(8192);function Gm(t,e){if(Pc.has(`${t}.${e}`))return Pc.get(`${t}.${e}`);const r=e?`${e}${t.toLowerCase()}`:t.substring(2).toLowerCase(),i=Md(yd(r),"bytes"),n=(e?r.substring(`${e}0x`.length):r).split("");for(let o=0;o<40;o+=2)i[o>>1]>>4>=8&&n[o]&&(n[o]=n[o].toUpperCase()),(i[o>>1]&15)>=8&&n[o+1]&&(n[o+1]=n[o+1].toUpperCase());const s=`0x${n.join("")}`;return Pc.set(`${t}.${e}`,s),s}function Ym(t){const e=Md(`0x${t.substring(4)}`).substring(26);return Gm(`0x${e}`)}async function Zm({hash:t,signature:e}){const r=ls(t)?t:Dc(t),{secp256k1:i}=await Promise.resolve().then(function(){return M3});return`0x${(()=>{if(typeof e=="object"&&"r"in e&&"s"in e){const{r:f,s:u,v:d,yParity:g}=e,m=Number(g??d),b=Rd(m);return new i.Signature(Ac(f),Ac(u)).addRecoveryBit(b)}const o=ls(e)?e:Dc(e),a=mm(`0x${o.slice(130)}`),c=Rd(a);return i.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(c)})().recoverPublicKey(r.substring(2)).toHex(!1)}`}function Rd(t){if(t===0||t===1)return t;if(t===27)return 0;if(t===28)return 1;throw new Error("Invalid yParityOrV value")}async function Jm({hash:t,signature:e}){return Ym(await Zm({hash:t,signature:e}))}function Xm(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);const n=BigInt(32),s=BigInt(4294967295),o=Number(r>>n&s),a=Number(r&s),c=i?4:0,f=i?0:4;t.setUint32(e+c,o,i),t.setUint32(e+f,a,i)}function Qm(t,e,r){return t&e^~t&r}function ew(t,e,r){return t&e^t&r^e&r}class tw extends Oc{constructor(e,r,i,n){super(),this.blockLen=e,this.outputLen=r,this.padOffset=i,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=$c(this.buffer)}update(e){Sn(this);const{view:r,buffer:i,blockLen:n}=this;e=No(e);const s=e.length;for(let o=0;o<s;){const a=Math.min(n-this.pos,s-o);if(a===n){const c=$c(e);for(;n<=s-o;o+=n)this.process(c,o);continue}i.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Sn(this),vd(e,this),this.finished=!0;const{buffer:r,view:i,blockLen:n,isLE:s}=this;let{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(i,0),o=0);for(let d=o;d<n;d++)r[d]=0;Xm(i,n-8,BigInt(this.length*8),s),this.process(i,0);const a=$c(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=c/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<f;d++)a.setUint32(4*d,u[d],s)}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const i=e.slice(0,r);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:r,buffer:i,length:n,finished:s,destroyed:o,pos:a}=this;return e.length=n,e.pos=a,e.finished=s,e.destroyed=o,n%r&&e.buffer.set(i),e}}const rw=new Uint32Array([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]),hi=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),di=new Uint32Array(64);class iw extends tw{constructor(){super(64,32,8,!1),this.A=hi[0]|0,this.B=hi[1]|0,this.C=hi[2]|0,this.D=hi[3]|0,this.E=hi[4]|0,this.F=hi[5]|0,this.G=hi[6]|0,this.H=hi[7]|0}get(){const{A:e,B:r,C:i,D:n,E:s,F:o,G:a,H:c}=this;return[e,r,i,n,s,o,a,c]}set(e,r,i,n,s,o,a,c){this.A=e|0,this.B=r|0,this.C=i|0,this.D=n|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,r){for(let d=0;d<16;d++,r+=4)di[d]=e.getUint32(r,!1);for(let d=16;d<64;d++){const g=di[d-15],m=di[d-2],b=Ar(g,7)^Ar(g,18)^g>>>3,x=Ar(m,17)^Ar(m,19)^m>>>10;di[d]=x+di[d-7]+b+di[d-16]|0}let{A:i,B:n,C:s,D:o,E:a,F:c,G:f,H:u}=this;for(let d=0;d<64;d++){const g=Ar(a,6)^Ar(a,11)^Ar(a,25),m=u+g+Qm(a,c,f)+rw[d]+di[d]|0,x=(Ar(i,2)^Ar(i,13)^Ar(i,22))+ew(i,n,s)|0;u=f,f=c,c=a,a=o+m|0,o=s,s=n,n=i,i=m+x|0}i=i+this.A|0,n=n+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(i,n,s,o,a,c,f,u)}roundClean(){di.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Bo=xd(()=>new iw);new Pd(128);const nw=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Td=new Uint8Array(new Array(16).fill(0).map((t,e)=>e)),sw=Td.map(t=>(9*t+5)%16);let ow=[Td],aw=[sw];for(let t=0;t<4;t++)for(let e of[ow,aw])e.push(e[t].map(r=>nw[r]));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Fo=BigInt(0),Lo=BigInt(1),cw=BigInt(2);function Ui(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Dr(t){if(!Ui(t))throw new Error("Uint8Array expected")}function An(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const fw=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Dn(t){Dr(t);let e="";for(let r=0;r<t.length;r++)e+=fw[t[r]];return e}function $n(t){const e=t.toString(16);return e.length&1?"0"+e:e}function Rc(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Fo:BigInt("0x"+t)}const Jr={_0:48,_9:57,A:65,F:70,a:97,f:102};function Cd(t){if(t>=Jr._0&&t<=Jr._9)return t-Jr._0;if(t>=Jr.A&&t<=Jr.F)return t-(Jr.A-10);if(t>=Jr.a&&t<=Jr.f)return t-(Jr.a-10)}function On(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const i=new Uint8Array(r);for(let n=0,s=0;n<r;n++,s+=2){const o=Cd(t.charCodeAt(s)),a=Cd(t.charCodeAt(s+1));if(o===void 0||a===void 0){const c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}i[n]=o*16+a}return i}function $r(t){return Rc(Dn(t))}function Tc(t){return Dr(t),Rc(Dn(Uint8Array.from(t).reverse()))}function li(t,e){return On(t.toString(16).padStart(e*2,"0"))}function Cc(t,e){return li(t,e).reverse()}function uw(t){return On($n(t))}function Pt(t,e,r){let i;if(typeof e=="string")try{i=On(e)}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(Ui(e))i=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const n=i.length;if(typeof r=="number"&&n!==r)throw new Error(t+" of length "+r+" expected, got "+n);return i}function Gt(...t){let e=0;for(let i=0;i<t.length;i++){const n=t[i];Dr(n),e+=n.length}const r=new Uint8Array(e);for(let i=0,n=0;i<t.length;i++){const s=t[i];r.set(s,n),n+=s.length}return r}function hw(t,e){if(t.length!==e.length)return!1;let r=0;for(let i=0;i<t.length;i++)r|=t[i]^e[i];return r===0}function qo(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}const Nc=t=>typeof t=="bigint"&&Fo<=t;function Mn(t,e,r){return Nc(t)&&Nc(e)&&Nc(r)&&e<=t&&t<r}function pi(t,e,r,i){if(!Mn(e,r,i))throw new Error("expected valid "+t+": "+r+" <= n < "+i+", got "+e)}function Nd(t){let e;for(e=0;t>Fo;t>>=Lo,e+=1);return e}function dw(t,e){return t>>BigInt(e)&Lo}function lw(t,e,r){return t|(r?Lo:Fo)<<BigInt(e)}const Bc=t=>(cw<<BigInt(t-1))-Lo,Fc=t=>new Uint8Array(t),Bd=t=>Uint8Array.from(t);function Fd(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let i=Fc(t),n=Fc(t),s=0;const o=()=>{i.fill(1),n.fill(0),s=0},a=(...d)=>r(n,i,...d),c=(d=Fc())=>{n=a(Bd([0]),d),i=a(),d.length!==0&&(n=a(Bd([1]),d),i=a())},f=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let d=0;const g=[];for(;d<e;){i=a();const m=i.slice();g.push(m),d+=i.length}return Gt(...g)};return(d,g)=>{o(),c(d);let m;for(;!(m=g(f()));)c();return o(),m}}const pw={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||Ui(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function Pn(t,e,r={}){const i=(n,s,o)=>{const a=pw[s];if(typeof a!="function")throw new Error("invalid validator function");const c=t[n];if(!(o&&c===void 0)&&!a(c,t))throw new Error("param "+String(n)+" is invalid. Expected "+s+", got "+c)};for(const[n,s]of Object.entries(e))i(n,s,!1);for(const[n,s]of Object.entries(r))i(n,s,!0);return t}const gw=()=>{throw new Error("not implemented")};function Lc(t){const e=new WeakMap;return(r,...i)=>{const n=e.get(r);if(n!==void 0)return n;const s=t(r,...i);return e.set(r,s),s}}var bw=Object.freeze({__proto__:null,isBytes:Ui,abytes:Dr,abool:An,bytesToHex:Dn,numberToHexUnpadded:$n,hexToNumber:Rc,hexToBytes:On,bytesToNumberBE:$r,bytesToNumberLE:Tc,numberToBytesBE:li,numberToBytesLE:Cc,numberToVarBytesBE:uw,ensureBytes:Pt,concatBytes:Gt,equalBytes:hw,utf8ToBytes:qo,inRange:Mn,aInRange:pi,bitLen:Nd,bitGet:dw,bitSet:lw,bitMask:Bc,createHmacDrbg:Fd,validateObject:Pn,notImplemented:gw,memoized:Lc});const yw="0.1.1";function vw(){return yw}class Lt extends Error{constructor(e,r={}){const i=(()=>{if(r.cause instanceof Lt){if(r.cause.details)return r.cause.details;if(r.cause.shortMessage)return r.cause.shortMessage}return r.cause?.message?r.cause.message:r.details})(),n=(()=>r.cause instanceof Lt&&r.cause.docsPath||r.docsPath)(),o=`https://oxlib.sh${n??""}`,a=[e||"An error occurred.",...r.metaMessages?["",...r.metaMessages]:[],...i||n?["",i?`Details: ${i}`:void 0,n?`See: ${o}`:void 0]:[]].filter(c=>typeof c=="string").join(`
16
+ `);super(a,r.cause?{cause:r.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:`ox@${vw()}`}),this.cause=r.cause,this.details=i,this.docs=o,this.docsPath=n,this.shortMessage=e}walk(e){return Ld(this,e)}}function Ld(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause?Ld(t.cause,e):e?null:t}function mw(t,e){if(Ud(t)>e)throw new Dw({givenSize:Ud(t),maxSize:e})}const Xr={zero:48,nine:57,A:65,F:70,a:97,f:102};function qd(t){if(t>=Xr.zero&&t<=Xr.nine)return t-Xr.zero;if(t>=Xr.A&&t<=Xr.F)return t-(Xr.A-10);if(t>=Xr.a&&t<=Xr.f)return t-(Xr.a-10)}function ww(t,e={}){const{dir:r,size:i=32}=e;if(i===0)return t;if(t.length>i)throw new $w({size:t.length,targetSize:i,type:"Bytes"});const n=new Uint8Array(i);for(let s=0;s<i;s++){const o=r==="right";n[o?s:i-s-1]=t[o?s:t.length-s-1]}return n}function qc(t,e){if(Uc(t)>e)throw new Nw({givenSize:Uc(t),maxSize:e})}function zd(t,e={}){const{dir:r,size:i=32}=e;if(i===0)return t;const n=t.replace("0x","");if(n.length>i*2)throw new Bw({size:Math.ceil(n.length/2),targetSize:i,type:"Hex"});return`0x${n[r==="right"?"padEnd":"padStart"](i*2,"0")}`}const _w=new TextEncoder;function xw(t){return t instanceof Uint8Array?t:typeof t=="string"?Sw(t):Ew(t)}function Ew(t){return t instanceof Uint8Array?t:new Uint8Array(t)}function Sw(t,e={}){const{size:r}=e;let i=t;r&&(qc(t,r),i=zc(t,r));let n=i.slice(2);n.length%2&&(n=`0${n}`);const s=n.length/2,o=new Uint8Array(s);for(let a=0,c=0;a<s;a++){const f=qd(n.charCodeAt(c++)),u=qd(n.charCodeAt(c++));if(f===void 0||u===void 0)throw new Lt(`Invalid byte sequence ("${n[c-2]}${n[c-1]}" in "${n}").`);o[a]=f*16+u}return o}function Iw(t,e={}){const{size:r}=e,i=_w.encode(t);return typeof r=="number"?(mw(i,r),Aw(i,r)):i}function Aw(t,e){return ww(t,{dir:"right",size:e})}function Ud(t){return t.length}class Dw extends Lt{constructor({givenSize:e,maxSize:r}){super(`Size cannot exceed \`${r}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}}class $w extends Lt{constructor({size:e,targetSize:r,type:i}){super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${r}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeExceedsPaddingSizeError"})}}const Ow=new TextEncoder,Mw=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function kd(...t){return`0x${t.reduce((e,r)=>e+r.replace("0x",""),"")}`}function Pw(t,e={}){const r=`0x${Number(t)}`;return typeof e.size=="number"?(qc(r,e.size),zo(r,e.size)):r}function jd(t,e={}){let r="";for(let n=0;n<t.length;n++)r+=Mw[t[n]];const i=`0x${r}`;return typeof e.size=="number"?(qc(i,e.size),zc(i,e.size)):i}function Rw(t,e={}){const{signed:r,size:i}=e,n=BigInt(t);let s;i?r?s=(1n<<BigInt(i)*8n-1n)-1n:s=2n**(BigInt(i)*8n)-1n:typeof t=="number"&&(s=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof s=="bigint"&&r?-s-1n:0;if(s&&n>s||n<o){const f=typeof t=="bigint"?"n":"";throw new Cw({max:s?`${s}${f}`:void 0,min:`${o}${f}`,signed:r,size:i,value:`${t}${f}`})}const c=`0x${(r&&n<0?(1n<<BigInt(i*8))+BigInt(n):n).toString(16)}`;return i?zo(c,i):c}function Tw(t,e={}){return jd(Ow.encode(t),e)}function zo(t,e){return zd(t,{dir:"left",size:e})}function zc(t,e){return zd(t,{dir:"right",size:e})}function Uc(t){return Math.ceil((t.length-2)/2)}class Cw extends Lt{constructor({max:e,min:r,signed:i,size:n,value:s}){super(`Number \`${s}\` is not in safe${n?` ${n*8}-bit`:""}${i?" signed":" unsigned"} integer range ${e?`(\`${r}\` to \`${e}\`)`:`(above \`${r}\`)`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.IntegerOutOfRangeError"})}}class Nw extends Lt{constructor({givenSize:e,maxSize:r}){super(`Size cannot exceed \`${r}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeOverflowError"})}}class Bw extends Lt{constructor({size:e,targetSize:r,type:i}){super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${r}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}}function Fw(t,e={}){const{as:r=typeof t=="string"?"Hex":"Bytes"}=e,i=Od(xw(t));return r==="Bytes"?i:jd(i)}class Lw extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const r=super.get(e);return super.has(e)&&r!==void 0&&(this.delete(e),super.set(e,r)),r}set(e,r){if(super.set(e,r),this.maxSize&&this.size>this.maxSize){const i=this.keys().next().value;i&&this.delete(i)}return this}}const kc={checksum:new Lw(8192)}.checksum,qw=/^0x[a-fA-F0-9]{40}$/;function Kd(t,e={}){const{strict:r=!0}=e;if(!qw.test(t))throw new Vd({address:t,cause:new Uw});if(r){if(t.toLowerCase()===t)return;if(zw(t)!==t)throw new Vd({address:t,cause:new kw})}}function zw(t){if(kc.has(t))return kc.get(t);Kd(t,{strict:!1});const e=t.substring(2).toLowerCase(),r=Fw(Iw(e),{as:"Bytes"}),i=e.split("");for(let s=0;s<40;s+=2)r[s>>1]>>4>=8&&i[s]&&(i[s]=i[s].toUpperCase()),(r[s>>1]&15)>=8&&i[s+1]&&(i[s+1]=i[s+1].toUpperCase());const n=`0x${i.join("")}`;return kc.set(t,n),n}class Vd extends Lt{constructor({address:e,cause:r}){super(`Address "${e}" is invalid.`,{cause:r}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}class Uw extends Lt{constructor(){super("Address is not a 20 byte (40 hexadecimal character) value."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidInputError"})}}class kw extends Lt{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}const jw=/^(.*)\[([0-9]*)\]$/,Kw=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Vw=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;function jc(t,e){if(t.length!==e.length)throw new Ww({expectedLength:t.length,givenLength:e.length});const r=[];for(let i=0;i<t.length;i++){const n=t[i],s=e[i];r.push(jc.encode(n,s))}return kd(...r)}(function(t){function e(r,i,n=!1){if(r==="address"){const c=i;return Kd(c),zo(c.toLowerCase(),n?32:0)}if(r==="string")return Tw(i);if(r==="bytes")return i;if(r==="bool")return zo(Pw(i),n?32:1);const s=r.match(Vw);if(s){const[c,f,u="256"]=s,d=Number.parseInt(u)/8;return Rw(i,{size:n?32:d,signed:f==="int"})}const o=r.match(Kw);if(o){const[c,f]=o;if(Number.parseInt(f)!==(i.length-2)/2)throw new Hw({expectedSize:Number.parseInt(f),value:i});return zc(i,n?32:0)}const a=r.match(jw);if(a&&Array.isArray(i)){const[c,f]=a,u=[];for(let d=0;d<i.length;d++)u.push(e(f,i[d],!0));return u.length===0?"0x":kd(...u)}throw new Gw(r)}t.encode=e})(jc||(jc={}));class Hw extends Lt{constructor({expectedSize:e,value:r}){super(`Size of bytes "${r}" (bytes${Uc(r)}) does not match expected size (bytes${e}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.BytesSizeMismatchError"})}}class Ww extends Lt{constructor({expectedLength:e,givenLength:r}){super(["ABI encoding parameters/values length mismatch.",`Expected length (parameters): ${e}`,`Given length (values): ${r}`].join(`
17
+ `)),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.LengthMismatchError"})}}class Gw extends Lt{constructor(e){super(`Type \`${e}\` is not a valid ABI Type.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidTypeError"})}}class Hd extends Oc{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,Om(e);const i=No(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const n=this.blockLen,s=new Uint8Array(n);s.set(i.length>n?e.create().update(i).digest():i);for(let o=0;o<s.length;o++)s[o]^=54;this.iHash.update(s),this.oHash=e.create();for(let o=0;o<s.length;o++)s[o]^=106;this.oHash.update(s),s.fill(0)}update(e){return Sn(this),this.iHash.update(e),this}digestInto(e){Sn(this),ps(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:r,iHash:i,finished:n,destroyed:s,blockLen:o,outputLen:a}=this;return e=e,e.finished=n,e.destroyed=s,e.blockLen=o,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=i._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Wd=(t,e,r)=>new Hd(t,e).update(r).digest();Wd.create=(t,e)=>new Hd(t,e);const ht=BigInt(0),it=BigInt(1),ki=BigInt(2),Yw=BigInt(3),Kc=BigInt(4),Gd=BigInt(5),Yd=BigInt(8);function dt(t,e){const r=t%e;return r>=ht?r:e+r}function Zw(t,e,r){if(e<ht)throw new Error("invalid exponent, negatives unsupported");if(r<=ht)throw new Error("invalid modulus");if(r===it)return ht;let i=it;for(;e>ht;)e&it&&(i=i*t%r),t=t*t%r,e>>=it;return i}function rr(t,e,r){let i=t;for(;e-- >ht;)i*=i,i%=r;return i}function Vc(t,e){if(t===ht)throw new Error("invert: expected non-zero number");if(e<=ht)throw new Error("invert: expected positive modulus, got "+e);let r=dt(t,e),i=e,n=ht,s=it;for(;r!==ht;){const a=i/r,c=i%r,f=n-s*a;i=r,r=c,n=s,s=f}if(i!==it)throw new Error("invert: does not exist");return dt(n,e)}function Jw(t){const e=(t-it)/ki;let r,i,n;for(r=t-it,i=0;r%ki===ht;r/=ki,i++);for(n=ki;n<t&&Zw(n,e,t)!==t-it;n++)if(n>1e3)throw new Error("Cannot find square root: likely non-prime P");if(i===1){const o=(t+it)/Kc;return function(c,f){const u=c.pow(f,o);if(!c.eql(c.sqr(u),f))throw new Error("Cannot find square root");return u}}const s=(r+it)/ki;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=i,u=a.pow(a.mul(a.ONE,n),r),d=a.pow(c,s),g=a.pow(c,r);for(;!a.eql(g,a.ONE);){if(a.eql(g,a.ZERO))return a.ZERO;let m=1;for(let x=a.sqr(g);m<f&&!a.eql(x,a.ONE);m++)x=a.sqr(x);const b=a.pow(u,it<<BigInt(f-m-1));u=a.sqr(b),d=a.mul(d,b),g=a.mul(g,u),f=m}return d}}function Xw(t){if(t%Kc===Yw){const e=(t+it)/Kc;return function(i,n){const s=i.pow(n,e);if(!i.eql(i.sqr(s),n))throw new Error("Cannot find square root");return s}}if(t%Yd===Gd){const e=(t-Gd)/Yd;return function(i,n){const s=i.mul(n,ki),o=i.pow(s,e),a=i.mul(n,o),c=i.mul(i.mul(a,ki),o),f=i.mul(a,i.sub(c,i.ONE));if(!i.eql(i.sqr(f),n))throw new Error("Cannot find square root");return f}}return Jw(t)}const Qw=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Zd(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=Qw.reduce((i,n)=>(i[n]="function",i),e);return Pn(t,r)}function e3(t,e,r){if(r<ht)throw new Error("invalid exponent, negatives unsupported");if(r===ht)return t.ONE;if(r===it)return e;let i=t.ONE,n=e;for(;r>ht;)r&it&&(i=t.mul(i,n)),n=t.sqr(n),r>>=it;return i}function t3(t,e){const r=new Array(e.length),i=e.reduce((s,o,a)=>t.is0(o)?s:(r[a]=s,t.mul(s,o)),t.ONE),n=t.inv(i);return e.reduceRight((s,o,a)=>t.is0(o)?s:(r[a]=t.mul(s,r[a]),t.mul(s,o)),n),r}function Jd(t,e){const r=e!==void 0?e:t.toString(2).length,i=Math.ceil(r/8);return{nBitLength:r,nByteLength:i}}function Xd(t,e,r=!1,i={}){if(t<=ht)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:n,nByteLength:s}=Jd(t,e);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:t,isLE:r,BITS:n,BYTES:s,MASK:Bc(n),ZERO:ht,ONE:it,create:c=>dt(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return ht<=c&&c<t},is0:c=>c===ht,isOdd:c=>(c&it)===it,neg:c=>dt(-c,t),eql:(c,f)=>c===f,sqr:c=>dt(c*c,t),add:(c,f)=>dt(c+f,t),sub:(c,f)=>dt(c-f,t),mul:(c,f)=>dt(c*f,t),pow:(c,f)=>e3(a,c,f),div:(c,f)=>dt(c*Vc(f,t),t),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>Vc(c,t),sqrt:i.sqrt||(c=>(o||(o=Xw(t)),o(a,c))),invertBatch:c=>t3(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>r?Cc(c,s):li(c,s),fromBytes:c=>{if(c.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+c.length);return r?Tc(c):$r(c)}});return Object.freeze(a)}function Qd(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function el(t){const e=Qd(t);return e+Math.ceil(e/2)}function r3(t,e,r=!1){const i=t.length,n=Qd(e),s=el(e);if(i<16||i<s||i>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+i);const o=r?Tc(t):$r(t),a=dt(o,e-it)+it;return r?Cc(a,n):li(a,n)}const tl=BigInt(0),Uo=BigInt(1);function Hc(t,e){const r=e.negate();return t?r:e}function rl(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Wc(t,e){rl(t,e);const r=Math.ceil(e/t)+1,i=2**(t-1);return{windows:r,windowSize:i}}function i3(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((r,i)=>{if(!(r instanceof e))throw new Error("invalid point at index "+i)})}function n3(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,i)=>{if(!e.isValid(r))throw new Error("invalid scalar at index "+i)})}const Gc=new WeakMap,il=new WeakMap;function Yc(t){return il.get(t)||1}function s3(t,e){return{constTimeNegate:Hc,hasPrecomputes(r){return Yc(r)!==1},unsafeLadder(r,i,n=t.ZERO){let s=r;for(;i>tl;)i&Uo&&(n=n.add(s)),s=s.double(),i>>=Uo;return n},precomputeWindow(r,i){const{windows:n,windowSize:s}=Wc(i,e),o=[];let a=r,c=a;for(let f=0;f<n;f++){c=a,o.push(c);for(let u=1;u<s;u++)c=c.add(a),o.push(c);a=c.double()}return o},wNAF(r,i,n){const{windows:s,windowSize:o}=Wc(r,e);let a=t.ZERO,c=t.BASE;const f=BigInt(2**r-1),u=2**r,d=BigInt(r);for(let g=0;g<s;g++){const m=g*o;let b=Number(n&f);n>>=d,b>o&&(b-=u,n+=Uo);const x=m,I=m+Math.abs(b)-1,O=g%2!==0,$=b<0;b===0?c=c.add(Hc(O,i[x])):a=a.add(Hc($,i[I]))}return{p:a,f:c}},wNAFUnsafe(r,i,n,s=t.ZERO){const{windows:o,windowSize:a}=Wc(r,e),c=BigInt(2**r-1),f=2**r,u=BigInt(r);for(let d=0;d<o;d++){const g=d*a;if(n===tl)break;let m=Number(n&c);if(n>>=u,m>a&&(m-=f,n+=Uo),m===0)continue;let b=i[g+Math.abs(m)-1];m<0&&(b=b.negate()),s=s.add(b)}return s},getPrecomputes(r,i,n){let s=Gc.get(i);return s||(s=this.precomputeWindow(i,r),r!==1&&Gc.set(i,n(s))),s},wNAFCached(r,i,n){const s=Yc(r);return this.wNAF(s,this.getPrecomputes(s,r,n),i)},wNAFCachedUnsafe(r,i,n,s){const o=Yc(r);return o===1?this.unsafeLadder(r,i,s):this.wNAFUnsafe(o,this.getPrecomputes(o,r,n),i,s)},setWindowSize(r,i){rl(i,e),il.set(r,i),Gc.delete(r)}}}function o3(t,e,r,i){if(i3(r,t),n3(i,e),r.length!==i.length)throw new Error("arrays of points and scalars must have equal length");const n=t.ZERO,s=Nd(BigInt(r.length)),o=s>12?s-3:s>4?s-2:s?2:1,a=(1<<o)-1,c=new Array(a+1).fill(n),f=Math.floor((e.BITS-1)/o)*o;let u=n;for(let d=f;d>=0;d-=o){c.fill(n);for(let m=0;m<i.length;m++){const b=i[m],x=Number(b>>BigInt(d)&BigInt(a));c[x]=c[x].add(r[m])}let g=n;for(let m=c.length-1,b=n;m>0;m--)b=b.add(c[m]),g=g.add(b);if(u=u.add(g),d!==0)for(let m=0;m<o;m++)u=u.double()}return u}function nl(t){return Zd(t.Fp),Pn(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Jd(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}function sl(t){t.lowS!==void 0&&An("lowS",t.lowS),t.prehash!==void 0&&An("prehash",t.prehash)}function a3(t){const e=nl(t);Pn(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:r,Fp:i,a:n}=e;if(r){if(!i.eql(n,i.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:c3,hexToBytes:f3}=bw;class u3 extends Error{constructor(e=""){super(e)}}const Qr={Err:u3,_tlv:{encode:(t,e)=>{const{Err:r}=Qr;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");const i=e.length/2,n=$n(i);if(n.length/2&128)throw new r("tlv.encode: long form length too big");const s=i>127?$n(n.length/2|128):"";return $n(t)+s+n+e},decode(t,e){const{Err:r}=Qr;let i=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[i++]!==t)throw new r("tlv.decode: wrong tlv");const n=e[i++],s=!!(n&128);let o=0;if(!s)o=n;else{const c=n&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");const f=e.subarray(i,i+c);if(f.length!==c)throw new r("tlv.decode: length bytes not complete");if(f[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(const u of f)o=o<<8|u;if(i+=c,o<128)throw new r("tlv.decode(long): not minimal encoding")}const a=e.subarray(i,i+o);if(a.length!==o)throw new r("tlv.decode: wrong value length");return{v:a,l:e.subarray(i+o)}}},_int:{encode(t){const{Err:e}=Qr;if(t<pr)throw new e("integer: negative integers are not allowed");let r=$n(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){const{Err:e}=Qr;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return c3(t)}},toSig(t){const{Err:e,_int:r,_tlv:i}=Qr,n=typeof t=="string"?f3(t):t;Dr(n);const{v:s,l:o}=i.decode(48,n);if(o.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:c}=i.decode(2,s),{v:f,l:u}=i.decode(2,c);if(u.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(f)}},hexFromSig(t){const{_tlv:e,_int:r}=Qr,i=e.encode(2,r.encode(t.r)),n=e.encode(2,r.encode(t.s)),s=i+n;return e.encode(48,s)}},pr=BigInt(0),le=BigInt(1),gi=BigInt(2),ko=BigInt(3),ol=BigInt(4);function h3(t){const e=a3(t),{Fp:r}=e,i=Xd(e.n,e.nBitLength),n=e.toBytes||((x,I,O)=>{const $=I.toAffine();return Gt(Uint8Array.from([4]),r.toBytes($.x),r.toBytes($.y))}),s=e.fromBytes||(x=>{const I=x.subarray(1),O=r.fromBytes(I.subarray(0,r.BYTES)),$=r.fromBytes(I.subarray(r.BYTES,2*r.BYTES));return{x:O,y:$}});function o(x){const{a:I,b:O}=e,$=r.sqr(x),P=r.mul($,x);return r.add(r.add(P,r.mul(x,I)),O)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function a(x){return Mn(x,le,e.n)}function c(x){const{allowedPrivateKeyLengths:I,nByteLength:O,wrapPrivateKey:$,n:P}=e;if(I&&typeof x!="bigint"){if(Ui(x)&&(x=Dn(x)),typeof x!="string"||!I.includes(x.length))throw new Error("invalid private key");x=x.padStart(O*2,"0")}let R;try{R=typeof x=="bigint"?x:$r(Pt("private key",x,O))}catch{throw new Error("invalid private key, expected hex or "+O+" bytes, got "+typeof x)}return $&&(R=dt(R,P)),pi("private key",R,le,P),R}function f(x){if(!(x instanceof g))throw new Error("ProjectivePoint expected")}const u=Lc((x,I)=>{const{px:O,py:$,pz:P}=x;if(r.eql(P,r.ONE))return{x:O,y:$};const R=x.is0();I==null&&(I=R?r.ONE:r.inv(P));const N=r.mul(O,I),B=r.mul($,I),F=r.mul(P,I);if(R)return{x:r.ZERO,y:r.ZERO};if(!r.eql(F,r.ONE))throw new Error("invZ was invalid");return{x:N,y:B}}),d=Lc(x=>{if(x.is0()){if(e.allowInfinityPoint&&!r.is0(x.py))return;throw new Error("bad point: ZERO")}const{x:I,y:O}=x.toAffine();if(!r.isValid(I)||!r.isValid(O))throw new Error("bad point: x or y not FE");const $=r.sqr(O),P=o(I);if(!r.eql($,P))throw new Error("bad point: equation left != right");if(!x.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class g{constructor(I,O,$){if(this.px=I,this.py=O,this.pz=$,I==null||!r.isValid(I))throw new Error("x required");if(O==null||!r.isValid(O))throw new Error("y required");if($==null||!r.isValid($))throw new Error("z required");Object.freeze(this)}static fromAffine(I){const{x:O,y:$}=I||{};if(!I||!r.isValid(O)||!r.isValid($))throw new Error("invalid affine point");if(I instanceof g)throw new Error("projective point not allowed");const P=R=>r.eql(R,r.ZERO);return P(O)&&P($)?g.ZERO:new g(O,$,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(I){const O=r.invertBatch(I.map($=>$.pz));return I.map(($,P)=>$.toAffine(O[P])).map(g.fromAffine)}static fromHex(I){const O=g.fromAffine(s(Pt("pointHex",I)));return O.assertValidity(),O}static fromPrivateKey(I){return g.BASE.multiply(c(I))}static msm(I,O){return o3(g,i,I,O)}_setWindowSize(I){b.setWindowSize(this,I)}assertValidity(){d(this)}hasEvenY(){const{y:I}=this.toAffine();if(r.isOdd)return!r.isOdd(I);throw new Error("Field doesn't support isOdd")}equals(I){f(I);const{px:O,py:$,pz:P}=this,{px:R,py:N,pz:B}=I,F=r.eql(r.mul(O,B),r.mul(R,P)),L=r.eql(r.mul($,B),r.mul(N,P));return F&&L}negate(){return new g(this.px,r.neg(this.py),this.pz)}double(){const{a:I,b:O}=e,$=r.mul(O,ko),{px:P,py:R,pz:N}=this;let B=r.ZERO,F=r.ZERO,L=r.ZERO,C=r.mul(P,P),W=r.mul(R,R),A=r.mul(N,N),h=r.mul(P,R);return h=r.add(h,h),L=r.mul(P,N),L=r.add(L,L),B=r.mul(I,L),F=r.mul($,A),F=r.add(B,F),B=r.sub(W,F),F=r.add(W,F),F=r.mul(B,F),B=r.mul(h,B),L=r.mul($,L),A=r.mul(I,A),h=r.sub(C,A),h=r.mul(I,h),h=r.add(h,L),L=r.add(C,C),C=r.add(L,C),C=r.add(C,A),C=r.mul(C,h),F=r.add(F,C),A=r.mul(R,N),A=r.add(A,A),C=r.mul(A,h),B=r.sub(B,C),L=r.mul(A,W),L=r.add(L,L),L=r.add(L,L),new g(B,F,L)}add(I){f(I);const{px:O,py:$,pz:P}=this,{px:R,py:N,pz:B}=I;let F=r.ZERO,L=r.ZERO,C=r.ZERO;const W=e.a,A=r.mul(e.b,ko);let h=r.mul(O,R),p=r.mul($,N),v=r.mul(P,B),y=r.add(O,$),w=r.add(R,N);y=r.mul(y,w),w=r.add(h,p),y=r.sub(y,w),w=r.add(O,P);let S=r.add(R,B);return w=r.mul(w,S),S=r.add(h,v),w=r.sub(w,S),S=r.add($,P),F=r.add(N,B),S=r.mul(S,F),F=r.add(p,v),S=r.sub(S,F),C=r.mul(W,w),F=r.mul(A,v),C=r.add(F,C),F=r.sub(p,C),C=r.add(p,C),L=r.mul(F,C),p=r.add(h,h),p=r.add(p,h),v=r.mul(W,v),w=r.mul(A,w),p=r.add(p,v),v=r.sub(h,v),v=r.mul(W,v),w=r.add(w,v),h=r.mul(p,w),L=r.add(L,h),h=r.mul(S,w),F=r.mul(y,F),F=r.sub(F,h),h=r.mul(y,p),C=r.mul(S,C),C=r.add(C,h),new g(F,L,C)}subtract(I){return this.add(I.negate())}is0(){return this.equals(g.ZERO)}wNAF(I){return b.wNAFCached(this,I,g.normalizeZ)}multiplyUnsafe(I){const{endo:O,n:$}=e;pi("scalar",I,pr,$);const P=g.ZERO;if(I===pr)return P;if(this.is0()||I===le)return this;if(!O||b.hasPrecomputes(this))return b.wNAFCachedUnsafe(this,I,g.normalizeZ);let{k1neg:R,k1:N,k2neg:B,k2:F}=O.splitScalar(I),L=P,C=P,W=this;for(;N>pr||F>pr;)N&le&&(L=L.add(W)),F&le&&(C=C.add(W)),W=W.double(),N>>=le,F>>=le;return R&&(L=L.negate()),B&&(C=C.negate()),C=new g(r.mul(C.px,O.beta),C.py,C.pz),L.add(C)}multiply(I){const{endo:O,n:$}=e;pi("scalar",I,le,$);let P,R;if(O){const{k1neg:N,k1:B,k2neg:F,k2:L}=O.splitScalar(I);let{p:C,f:W}=this.wNAF(B),{p:A,f:h}=this.wNAF(L);C=b.constTimeNegate(N,C),A=b.constTimeNegate(F,A),A=new g(r.mul(A.px,O.beta),A.py,A.pz),P=C.add(A),R=W.add(h)}else{const{p:N,f:B}=this.wNAF(I);P=N,R=B}return g.normalizeZ([P,R])[0]}multiplyAndAddUnsafe(I,O,$){const P=g.BASE,R=(B,F)=>F===pr||F===le||!B.equals(P)?B.multiplyUnsafe(F):B.multiply(F),N=R(this,O).add(R(I,$));return N.is0()?void 0:N}toAffine(I){return u(this,I)}isTorsionFree(){const{h:I,isTorsionFree:O}=e;if(I===le)return!0;if(O)return O(g,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:I,clearCofactor:O}=e;return I===le?this:O?O(g,this):this.multiplyUnsafe(e.h)}toRawBytes(I=!0){return An("isCompressed",I),this.assertValidity(),n(g,this,I)}toHex(I=!0){return An("isCompressed",I),Dn(this.toRawBytes(I))}}g.BASE=new g(e.Gx,e.Gy,r.ONE),g.ZERO=new g(r.ZERO,r.ONE,r.ZERO);const m=e.nBitLength,b=s3(g,e.endo?Math.ceil(m/2):m);return{CURVE:e,ProjectivePoint:g,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:a}}function d3(t){const e=nl(t);return Pn(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function l3(t){const e=d3(t),{Fp:r,n:i}=e,n=r.BYTES+1,s=2*r.BYTES+1;function o(v){return dt(v,i)}function a(v){return Vc(v,i)}const{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:d}=h3({...e,toBytes(v,y,w){const S=y.toAffine(),D=r.toBytes(S.x),_=Gt;return An("isCompressed",w),w?_(Uint8Array.from([y.hasEvenY()?2:3]),D):_(Uint8Array.from([4]),D,r.toBytes(S.y))},fromBytes(v){const y=v.length,w=v[0],S=v.subarray(1);if(y===n&&(w===2||w===3)){const D=$r(S);if(!Mn(D,le,r.ORDER))throw new Error("Point is not on curve");const _=u(D);let l;try{l=r.sqrt(_)}catch(z){const U=z instanceof Error?": "+z.message:"";throw new Error("Point is not on curve"+U)}const E=(l&le)===le;return(w&1)===1!==E&&(l=r.neg(l)),{x:D,y:l}}else if(y===s&&w===4){const D=r.fromBytes(S.subarray(0,r.BYTES)),_=r.fromBytes(S.subarray(r.BYTES,2*r.BYTES));return{x:D,y:_}}else{const D=n,_=s;throw new Error("invalid Point, expected length of "+D+", or uncompressed "+_+", got "+y)}}}),g=v=>Dn(li(v,e.nByteLength));function m(v){const y=i>>le;return v>y}function b(v){return m(v)?o(-v):v}const x=(v,y,w)=>$r(v.slice(y,w));class I{constructor(y,w,S){this.r=y,this.s=w,this.recovery=S,this.assertValidity()}static fromCompact(y){const w=e.nByteLength;return y=Pt("compactSignature",y,w*2),new I(x(y,0,w),x(y,w,2*w))}static fromDER(y){const{r:w,s:S}=Qr.toSig(Pt("DER",y));return new I(w,S)}assertValidity(){pi("r",this.r,le,i),pi("s",this.s,le,i)}addRecoveryBit(y){return new I(this.r,this.s,y)}recoverPublicKey(y){const{r:w,s:S,recovery:D}=this,_=B(Pt("msgHash",y));if(D==null||![0,1,2,3].includes(D))throw new Error("recovery id invalid");const l=D===2||D===3?w+e.n:w;if(l>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");const E=D&1?"03":"02",q=c.fromHex(E+g(l)),z=a(l),U=o(-_*z),k=o(S*z),G=c.BASE.multiplyAndAddUnsafe(q,U,k);if(!G)throw new Error("point at infinify");return G.assertValidity(),G}hasHighS(){return m(this.s)}normalizeS(){return this.hasHighS()?new I(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return On(this.toDERHex())}toDERHex(){return Qr.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return On(this.toCompactHex())}toCompactHex(){return g(this.r)+g(this.s)}}const O={isValidPrivateKey(v){try{return f(v),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{const v=el(e.n);return r3(e.randomBytes(v),e.n)},precompute(v=8,y=c.BASE){return y._setWindowSize(v),y.multiply(BigInt(3)),y}};function $(v,y=!0){return c.fromPrivateKey(v).toRawBytes(y)}function P(v){const y=Ui(v),w=typeof v=="string",S=(y||w)&&v.length;return y?S===n||S===s:w?S===2*n||S===2*s:v instanceof c}function R(v,y,w=!0){if(P(v))throw new Error("first arg must be private key");if(!P(y))throw new Error("second arg must be public key");return c.fromHex(y).multiply(f(v)).toRawBytes(w)}const N=e.bits2int||function(v){if(v.length>8192)throw new Error("input is too large");const y=$r(v),w=v.length*8-e.nBitLength;return w>0?y>>BigInt(w):y},B=e.bits2int_modN||function(v){return o(N(v))},F=Bc(e.nBitLength);function L(v){return pi("num < 2^"+e.nBitLength,v,pr,F),li(v,e.nByteLength)}function C(v,y,w=W){if(["recovered","canonical"].some(X=>X in w))throw new Error("sign() legacy options not supported");const{hash:S,randomBytes:D}=e;let{lowS:_,prehash:l,extraEntropy:E}=w;_==null&&(_=!0),v=Pt("msgHash",v),sl(w),l&&(v=Pt("prehashed msgHash",S(v)));const q=B(v),z=f(y),U=[L(z),L(q)];if(E!=null&&E!==!1){const X=E===!0?D(r.BYTES):E;U.push(Pt("extraEntropy",X))}const k=Gt(...U),G=q;function J(X){const Z=N(X);if(!d(Z))return;const Q=a(Z),Fe=c.BASE.multiply(Z).toAffine(),re=o(Fe.x);if(re===pr)return;const oe=o(Q*o(G+re*z));if(oe===pr)return;let ct=(Fe.x===re?0:2)|Number(Fe.y&le),he=oe;return _&&m(oe)&&(he=b(oe),ct^=1),new I(re,he,ct)}return{seed:k,k2sig:J}}const W={lowS:e.lowS,prehash:!1},A={lowS:e.lowS,prehash:!1};function h(v,y,w=W){const{seed:S,k2sig:D}=C(v,y,w),_=e;return Fd(_.hash.outputLen,_.nByteLength,_.hmac)(S,D)}c.BASE._setWindowSize(8);function p(v,y,w,S=A){const D=v;y=Pt("msgHash",y),w=Pt("publicKey",w);const{lowS:_,prehash:l,format:E}=S;if(sl(S),"strict"in S)throw new Error("options.strict was renamed to lowS");if(E!==void 0&&E!=="compact"&&E!=="der")throw new Error("format must be compact or der");const q=typeof D=="string"||Ui(D),z=!q&&!E&&typeof D=="object"&&D!==null&&typeof D.r=="bigint"&&typeof D.s=="bigint";if(!q&&!z)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let U,k;try{if(z&&(U=new I(D.r,D.s)),q){try{E!=="compact"&&(U=I.fromDER(D))}catch(ct){if(!(ct instanceof Qr.Err))throw ct}!U&&E!=="der"&&(U=I.fromCompact(D))}k=c.fromHex(w)}catch{return!1}if(!U||_&&U.hasHighS())return!1;l&&(y=e.hash(y));const{r:G,s:J}=U,X=B(y),Z=a(J),Q=o(X*Z),Fe=o(G*Z),re=c.BASE.multiplyAndAddUnsafe(k,Q,Fe)?.toAffine();return re?o(re.x)===G:!1}return{CURVE:e,getPublicKey:$,getSharedSecret:R,sign:h,verify:p,ProjectivePoint:c,Signature:I,utils:O}}function p3(t,e){const r=t.ORDER;let i=pr;for(let b=r-le;b%gi===pr;b/=gi)i+=le;const n=i,s=gi<<n-le-le,o=s*gi,a=(r-le)/o,c=(a-le)/gi,f=o-le,u=s,d=t.pow(e,a),g=t.pow(e,(a+le)/gi);let m=(b,x)=>{let I=d,O=t.pow(x,f),$=t.sqr(O);$=t.mul($,x);let P=t.mul(b,$);P=t.pow(P,c),P=t.mul(P,O),O=t.mul(P,x),$=t.mul(P,b);let R=t.mul($,O);P=t.pow(R,u);let N=t.eql(P,t.ONE);O=t.mul($,g),P=t.mul(R,I),$=t.cmov(O,$,N),R=t.cmov(P,R,N);for(let B=n;B>le;B--){let F=B-gi;F=gi<<F-le;let L=t.pow(R,F);const C=t.eql(L,t.ONE);O=t.mul($,I),I=t.mul(I,I),L=t.mul(R,I),$=t.cmov(O,$,C),R=t.cmov(L,R,C)}return{isValid:N,value:$}};if(t.ORDER%ol===ko){const b=(t.ORDER-ko)/ol,x=t.sqrt(t.neg(e));m=(I,O)=>{let $=t.sqr(O);const P=t.mul(I,O);$=t.mul($,P);let R=t.pow($,b);R=t.mul(R,P);const N=t.mul(R,x),B=t.mul(t.sqr(R),O),F=t.eql(B,I);let L=t.cmov(N,R,F);return{isValid:F,value:L}}}return m}function g3(t,e){if(Zd(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const r=p3(t,e.Z);if(!t.isOdd)throw new Error("Fp.isOdd is not implemented!");return i=>{let n,s,o,a,c,f,u,d;n=t.sqr(i),n=t.mul(n,e.Z),s=t.sqr(n),s=t.add(s,n),o=t.add(s,t.ONE),o=t.mul(o,e.B),a=t.cmov(e.Z,t.neg(s),!t.eql(s,t.ZERO)),a=t.mul(a,e.A),s=t.sqr(o),f=t.sqr(a),c=t.mul(f,e.A),s=t.add(s,c),s=t.mul(s,o),f=t.mul(f,a),c=t.mul(f,e.B),s=t.add(s,c),u=t.mul(n,o);const{isValid:g,value:m}=r(s,f);d=t.mul(n,i),d=t.mul(d,m),u=t.cmov(u,o,g),d=t.cmov(d,m,g);const b=t.isOdd(i)===t.isOdd(d);return d=t.cmov(t.neg(d),d,b),u=t.div(u,a),{x:u,y:d}}}function b3(t){return{hash:t,hmac:(e,...r)=>Wd(t,e,qm(...r)),randomBytes:Ed}}function y3(t,e){const r=i=>l3({...t,...b3(i)});return{...r(e),create:r}}const v3=$r;function bi(t,e){if(bs(t),bs(e),t<0||t>=1<<8*e)throw new Error("invalid I2OSP input: "+t);const r=Array.from({length:e}).fill(0);for(let i=e-1;i>=0;i--)r[i]=t&255,t>>>=8;return new Uint8Array(r)}function m3(t,e){const r=new Uint8Array(t.length);for(let i=0;i<t.length;i++)r[i]=t[i]^e[i];return r}function bs(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function w3(t,e,r,i){Dr(t),Dr(e),bs(r),e.length>255&&(e=i(Gt(qo("H2C-OVERSIZE-DST-"),e)));const{outputLen:n,blockLen:s}=i,o=Math.ceil(r/n);if(r>65535||o>255)throw new Error("expand_message_xmd: invalid lenInBytes");const a=Gt(e,bi(e.length,1)),c=bi(0,s),f=bi(r,2),u=new Array(o),d=i(Gt(c,t,f,bi(0,1),a));u[0]=i(Gt(d,bi(1,1),a));for(let m=1;m<=o;m++){const b=[m3(d,u[m-1]),bi(m+1,1),a];u[m]=i(Gt(...b))}return Gt(...u).slice(0,r)}function _3(t,e,r,i,n){if(Dr(t),Dr(e),bs(r),e.length>255){const s=Math.ceil(2*i/8);e=n.create({dkLen:s}).update(qo("H2C-OVERSIZE-DST-")).update(e).digest()}if(r>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return n.create({dkLen:r}).update(t).update(bi(r,2)).update(e).update(bi(e.length,1)).digest()}function al(t,e,r){Pn(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:i,k:n,m:s,hash:o,expand:a,DST:c}=r;Dr(t),bs(e);const f=typeof c=="string"?qo(c):c,u=i.toString(2).length,d=Math.ceil((u+n)/8),g=e*s*d;let m;if(a==="xmd")m=w3(t,f,g,o);else if(a==="xof")m=_3(t,f,g,n,o);else if(a==="_internal_pass")m=t;else throw new Error('expand must be "xmd" or "xof"');const b=new Array(e);for(let x=0;x<e;x++){const I=new Array(s);for(let O=0;O<s;O++){const $=d*(O+x*s),P=m.subarray($,$+d);I[O]=dt(v3(P),i)}b[x]=I}return b}function x3(t,e){const r=e.map(i=>Array.from(i).reverse());return(i,n)=>{const[s,o,a,c]=r.map(f=>f.reduce((u,d)=>t.add(t.mul(u,i),d)));return i=t.div(s,o),n=t.mul(n,t.div(a,c)),{x:i,y:n}}}function E3(t,e,r){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(i,n){const s=al(i,2,{...r,DST:r.DST,...n}),o=t.fromAffine(e(s[0])),a=t.fromAffine(e(s[1])),c=o.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(i,n){const s=al(i,1,{...r,DST:r.encodeDST,...n}),o=t.fromAffine(e(s[0])).clearCofactor();return o.assertValidity(),o},mapToCurve(i){if(!Array.isArray(i))throw new Error("mapToCurve: expected array of bigints");for(const s of i)if(typeof s!="bigint")throw new Error("mapToCurve: expected array of bigints");const n=t.fromAffine(e(i)).clearCofactor();return n.assertValidity(),n}}}const ys=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),jo=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),vs=BigInt(1),Ko=BigInt(2),cl=(t,e)=>(t+e/Ko)/e;function fl(t){const e=ys,r=BigInt(3),i=BigInt(6),n=BigInt(11),s=BigInt(22),o=BigInt(23),a=BigInt(44),c=BigInt(88),f=t*t*t%e,u=f*f*t%e,d=rr(u,r,e)*u%e,g=rr(d,r,e)*u%e,m=rr(g,Ko,e)*f%e,b=rr(m,n,e)*m%e,x=rr(b,s,e)*b%e,I=rr(x,a,e)*x%e,O=rr(I,c,e)*I%e,$=rr(O,a,e)*x%e,P=rr($,r,e)*u%e,R=rr(P,o,e)*b%e,N=rr(R,i,e)*f%e,B=rr(N,Ko,e);if(!yi.eql(yi.sqr(B),t))throw new Error("Cannot find square root");return B}const yi=Xd(ys,void 0,void 0,{sqrt:fl}),ms=y3({a:BigInt(0),b:BigInt(7),Fp:yi,n:jo,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=jo,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),i=-vs*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),n=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=r,o=BigInt("0x100000000000000000000000000000000"),a=cl(s*t,e),c=cl(-i*t,e);let f=dt(t-a*r-c*n,e),u=dt(-a*i-c*s,e);const d=f>o,g=u>o;if(d&&(f=e-f),g&&(u=e-u),f>o||u>o)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:d,k1:f,k2neg:g,k2:u}}}},Bo),ul=BigInt(0),hl={};function Vo(t,...e){let r=hl[t];if(r===void 0){const i=Bo(Uint8Array.from(t,n=>n.charCodeAt(0)));r=Gt(i,i),hl[t]=r}return Bo(Gt(r,...e))}const Zc=t=>t.toRawBytes(!0).slice(1),Jc=t=>li(t,32),Xc=t=>dt(t,ys),ws=t=>dt(t,jo),Qc=ms.ProjectivePoint,S3=(t,e,r)=>Qc.BASE.multiplyAndAddUnsafe(t,e,r);function ef(t){let e=ms.utils.normPrivateKeyToScalar(t),r=Qc.fromPrivateKey(e);return{scalar:r.hasEvenY()?e:ws(-e),bytes:Zc(r)}}function dl(t){pi("x",t,vs,ys);const e=Xc(t*t),r=Xc(e*t+BigInt(7));let i=fl(r);i%Ko!==ul&&(i=Xc(-i));const n=new Qc(t,i,vs);return n.assertValidity(),n}const Rn=$r;function ll(...t){return ws(Rn(Vo("BIP0340/challenge",...t)))}function I3(t){return ef(t).bytes}function A3(t,e,r=Ed(32)){const i=Pt("message",t),{bytes:n,scalar:s}=ef(e),o=Pt("auxRand",r,32),a=Jc(s^Rn(Vo("BIP0340/aux",o))),c=Vo("BIP0340/nonce",a,n,i),f=ws(Rn(c));if(f===ul)throw new Error("sign failed: k is zero");const{bytes:u,scalar:d}=ef(f),g=ll(u,n,i),m=new Uint8Array(64);if(m.set(u,0),m.set(Jc(ws(d+g*s)),32),!pl(m,i,n))throw new Error("sign: Invalid signature produced");return m}function pl(t,e,r){const i=Pt("signature",t,64),n=Pt("message",e),s=Pt("publicKey",r,32);try{const o=dl(Rn(s)),a=Rn(i.subarray(0,32));if(!Mn(a,vs,ys))return!1;const c=Rn(i.subarray(32,64));if(!Mn(c,vs,jo))return!1;const f=ll(Jc(a),Zc(o),n),u=S3(o,c,ws(-f));return!(!u||!u.hasEvenY()||u.toAffine().x!==a)}catch{return!1}}const D3=(()=>({getPublicKey:I3,sign:A3,verify:pl,utils:{randomPrivateKey:ms.utils.randomPrivateKey,lift_x:dl,pointToBytes:Zc,numberToBytesBE:li,bytesToNumberBE:$r,taggedHash:Vo,mod:dt}}))(),$3=(()=>x3(yi,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(t=>t.map(e=>BigInt(e)))))(),O3=(()=>g3(yi,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:yi.create(BigInt("-11"))}))(),gl=(()=>E3(ms.ProjectivePoint,t=>{const{x:e,y:r}=O3(yi.create(t[0]));return $3(e,r)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:yi.ORDER,m:1,k:128,expand:"xmd",hash:Bo}))();var M3=Object.freeze({__proto__:null,secp256k1:ms,schnorr:D3,hashToCurve:(()=>gl.hashToCurve)(),encodeToCurve:(()=>gl.encodeToCurve)()});function P3(t){if(t.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let f=0;f<e.length;f++)e[f]=255;for(let f=0;f<t.length;f++){const u=t.charAt(f),d=u.charCodeAt(0);if(e[d]!==255)throw new TypeError(u+" is ambiguous");e[d]=f}const r=t.length,i=t.charAt(0),n=Math.log(r)/Math.log(256),s=Math.log(256)/Math.log(r);function o(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";let u=0,d=0,g=0;const m=f.length;for(;g!==m&&f[g]===0;)g++,u++;const b=(m-g)*s+1>>>0,x=new Uint8Array(b);for(;g!==m;){let $=f[g],P=0;for(let R=b-1;($!==0||P<d)&&R!==-1;R--,P++)$+=256*x[R]>>>0,x[R]=$%r>>>0,$=$/r>>>0;if($!==0)throw new Error("Non-zero carry");d=P,g++}let I=b-d;for(;I!==b&&x[I]===0;)I++;let O=i.repeat(u);for(;I<b;++I)O+=t.charAt(x[I]);return O}function a(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;let u=0,d=0,g=0;for(;f[u]===i;)d++,u++;const m=(f.length-u)*n+1>>>0,b=new Uint8Array(m);for(;u<f.length;){const $=f.charCodeAt(u);if($>255)return;let P=e[$];if(P===255)return;let R=0;for(let N=m-1;(P!==0||R<g)&&N!==-1;N--,R++)P+=r*b[N]>>>0,b[N]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");g=R,u++}let x=m-g;for(;x!==m&&b[x]===0;)x++;const I=new Uint8Array(d+(m-x));let O=d;for(;x!==m;)I[O++]=b[x++];return I}function c(f){const u=a(f);if(u)return u;throw new Error("Non-base"+r+" character")}return{encode:o,decodeUnsafe:a,decode:c}}var R3="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",T3=P3(R3);function bl(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function tf(t,e){e||(e=t.reduce((n,s)=>n+s.length,0));const r=bl(e);let i=0;for(const n of t)r.set(n,i),i+=n.length;return r}function C3(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=n}var a=t.length,c=t.charAt(0),f=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function d(b){if(b instanceof Uint8Array||(ArrayBuffer.isView(b)?b=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):Array.isArray(b)&&(b=Uint8Array.from(b))),!(b instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(b.length===0)return"";for(var x=0,I=0,O=0,$=b.length;O!==$&&b[O]===0;)O++,x++;for(var P=($-O)*u+1>>>0,R=new Uint8Array(P);O!==$;){for(var N=b[O],B=0,F=P-1;(N!==0||B<I)&&F!==-1;F--,B++)N+=256*R[F]>>>0,R[F]=N%a>>>0,N=N/a>>>0;if(N!==0)throw new Error("Non-zero carry");I=B,O++}for(var L=P-I;L!==P&&R[L]===0;)L++;for(var C=c.repeat(x);L<P;++L)C+=t.charAt(R[L]);return C}function g(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;var x=0;if(b[x]!==" "){for(var I=0,O=0;b[x]===c;)I++,x++;for(var $=(b.length-x)*f+1>>>0,P=new Uint8Array($);b[x];){var R=r[b.charCodeAt(x)];if(R===255)return;for(var N=0,B=$-1;(R!==0||N<O)&&B!==-1;B--,N++)R+=a*P[B]>>>0,P[B]=R%256>>>0,R=R/256>>>0;if(R!==0)throw new Error("Non-zero carry");O=N,x++}if(b[x]!==" "){for(var F=$-O;F!==$&&P[F]===0;)F++;for(var L=new Uint8Array(I+($-F)),C=I;F!==$;)L[C++]=P[F++];return L}}}function m(b){var x=g(b);if(x)return x;throw new Error(`Non-${e} character`)}return{encode:d,decodeUnsafe:g,decode:m}}var N3=C3,B3=N3;const yl=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},F3=t=>new TextEncoder().encode(t),L3=t=>new TextDecoder().decode(t);class q3{constructor(e,r,i){this.name=e,this.prefix=r,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class z3{constructor(e,r,i){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return vl(this,e)}}class U3{constructor(e){this.decoders=e}or(e){return vl(this,e)}decode(e){const r=e[0],i=this.decoders[r];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const vl=(t,e)=>new U3({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class k3{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new q3(e,r,i),this.decoder=new z3(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Ho=({name:t,prefix:e,encode:r,decode:i})=>new k3(t,e,r,i),_s=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=B3(r,e);return Ho({prefix:t,name:e,encode:i,decode:s=>yl(n(s))})},j3=(t,e,r,i)=>{const n={};for(let u=0;u<e.length;++u)n[e[u]]=u;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,f=0;for(let u=0;u<s;++u){const d=n[t[u]];if(d===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<r|d,a+=r,a>=8&&(a-=8,o[f++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},K3=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>r;)o-=r,s+=e[n&a>>o];if(o&&(s+=e[n&a<<r-o]),i)for(;s.length*r&7;)s+="=";return s},_t=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>Ho({prefix:e,name:t,encode(n){return K3(n,i,r)},decode(n){return j3(n,i,r,t)}}),V3=Ho({prefix:"\0",name:"identity",encode:t=>L3(t),decode:t=>F3(t)});var H3=Object.freeze({__proto__:null,identity:V3});const W3=_t({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var G3=Object.freeze({__proto__:null,base2:W3});const Y3=_t({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Z3=Object.freeze({__proto__:null,base8:Y3});const J3=_s({prefix:"9",name:"base10",alphabet:"0123456789"});var X3=Object.freeze({__proto__:null,base10:J3});const Q3=_t({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),e6=_t({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var t6=Object.freeze({__proto__:null,base16:Q3,base16upper:e6});const r6=_t({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),i6=_t({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),n6=_t({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),s6=_t({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),o6=_t({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),a6=_t({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),c6=_t({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),f6=_t({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),u6=_t({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var h6=Object.freeze({__proto__:null,base32:r6,base32upper:i6,base32pad:n6,base32padupper:s6,base32hex:o6,base32hexupper:a6,base32hexpad:c6,base32hexpadupper:f6,base32z:u6});const d6=_s({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),l6=_s({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var p6=Object.freeze({__proto__:null,base36:d6,base36upper:l6});const g6=_s({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),b6=_s({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var y6=Object.freeze({__proto__:null,base58btc:g6,base58flickr:b6});const v6=_t({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),m6=_t({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),w6=_t({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),_6=_t({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var x6=Object.freeze({__proto__:null,base64:v6,base64pad:m6,base64url:w6,base64urlpad:_6});const ml=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),E6=ml.reduce((t,e,r)=>(t[r]=e,t),[]),S6=ml.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function I6(t){return t.reduce((e,r)=>(e+=E6[r],e),"")}function A6(t){const e=[];for(const r of t){const i=S6[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const D6=Ho({prefix:"\u{1F680}",name:"base256emoji",encode:I6,decode:A6});var $6=Object.freeze({__proto__:null,base256emoji:D6}),O6=_l,wl=128,M6=127,P6=~M6,R6=Math.pow(2,31);function _l(t,e,r){e=e||[],r=r||0;for(var i=r;t>=R6;)e[r++]=t&255|wl,t/=128;for(;t&P6;)e[r++]=t&255|wl,t>>>=7;return e[r]=t|0,_l.bytes=r-i+1,e}var T6=rf,C6=128,xl=127;function rf(t,i){var r=0,i=i||0,n=0,s=i,o,a=t.length;do{if(s>=a)throw rf.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=n<28?(o&xl)<<n:(o&xl)*Math.pow(2,n),n+=7}while(o>=C6);return rf.bytes=s-i,r}var N6=Math.pow(2,7),B6=Math.pow(2,14),F6=Math.pow(2,21),L6=Math.pow(2,28),q6=Math.pow(2,35),z6=Math.pow(2,42),U6=Math.pow(2,49),k6=Math.pow(2,56),j6=Math.pow(2,63),K6=function(t){return t<N6?1:t<B6?2:t<F6?3:t<L6?4:t<q6?5:t<z6?6:t<U6?7:t<k6?8:t<j6?9:10},V6={encode:O6,decode:T6,encodingLength:K6},El=V6;const Sl=(t,e,r=0)=>(El.encode(t,e,r),e),Il=t=>El.encodingLength(t),nf=(t,e)=>{const r=e.byteLength,i=Il(t),n=i+Il(r),s=new Uint8Array(n+r);return Sl(t,s,0),Sl(r,s,i),s.set(e,n),new H6(t,r,e,s)};class H6{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const Al=({name:t,code:e,encode:r})=>new W6(t,e,r);class W6{constructor(e,r,i){this.name=e,this.code=r,this.encode=i}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?nf(this.code,r):r.then(i=>nf(this.code,i))}else throw Error("Unknown type, must be binary type")}}const Dl=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),G6=Al({name:"sha2-256",code:18,encode:Dl("SHA-256")}),Y6=Al({name:"sha2-512",code:19,encode:Dl("SHA-512")});var Z6=Object.freeze({__proto__:null,sha256:G6,sha512:Y6});const $l=0,J6="identity",Ol=yl;var X6=Object.freeze({__proto__:null,identity:{code:$l,name:J6,encode:Ol,digest:t=>nf($l,Ol(t))}});new TextEncoder,new TextDecoder;const Ml={...H3,...G3,...Z3,...X3,...t6,...h6,...p6,...y6,...x6,...$6};({...Z6,...X6});function Pl(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const Rl=Pl("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),sf=Pl("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=bl(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Tl={utf8:Rl,"utf-8":Rl,hex:Ml.base16,latin1:sf,ascii:sf,binary:sf,...Ml};function ir(t,e="utf8"){const r=Tl[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t,"utf8"):r.decoder.decode(`${r.prefix}${t}`)}function qt(t,e="utf8"){const r=Tl[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var Cl={},Q6="elliptic",e8="6.6.1",t8="EC cryptography",r8="lib/elliptic.js",i8=["lib"],n8={lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},s8={type:"git",url:"git@github.com:indutny/elliptic"},o8=["EC","Elliptic","curve","Cryptography"],a8="Fedor Indutny <fedor@indutny.com>",c8="MIT",f8={url:"https://github.com/indutny/elliptic/issues"},u8="https://github.com/indutny/elliptic",h8={brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},d8={"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"},l8={name:Q6,version:e8,description:t8,main:r8,files:i8,scripts:n8,repository:s8,keywords:o8,author:a8,license:c8,bugs:f8,homepage:u8,devDependencies:h8,dependencies:d8},Yt={},Or={exports:{}},p8={},g8=Object.freeze({__proto__:null,default:p8}),Nl=qa(g8);(function(t){(function(e,r){function i(A,h){if(!A)throw new Error(h||"Assertion failed")}function n(A,h){A.super_=h;var p=function(){};p.prototype=h.prototype,A.prototype=new p,A.prototype.constructor=A}function s(A,h,p){if(s.isBN(A))return A;this.negative=0,this.words=null,this.length=0,this.red=null,A!==null&&((h==="le"||h==="be")&&(p=h,h=10),this._init(A||0,h||10,p||"be"))}typeof e=="object"?e.exports=s:r.BN=s,s.BN=s,s.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Nl.Buffer}catch{}s.isBN=function(h){return h instanceof s?!0:h!==null&&typeof h=="object"&&h.constructor.wordSize===s.wordSize&&Array.isArray(h.words)},s.max=function(h,p){return h.cmp(p)>0?h:p},s.min=function(h,p){return h.cmp(p)<0?h:p},s.prototype._init=function(h,p,v){if(typeof h=="number")return this._initNumber(h,p,v);if(typeof h=="object")return this._initArray(h,p,v);p==="hex"&&(p=16),i(p===(p|0)&&p>=2&&p<=36),h=h.toString().replace(/\s+/g,"");var y=0;h[0]==="-"&&(y++,this.negative=1),y<h.length&&(p===16?this._parseHex(h,y,v):(this._parseBase(h,p,y),v==="le"&&this._initArray(this.toArray(),p,v)))},s.prototype._initNumber=function(h,p,v){h<0&&(this.negative=1,h=-h),h<67108864?(this.words=[h&67108863],this.length=1):h<4503599627370496?(this.words=[h&67108863,h/67108864&67108863],this.length=2):(i(h<9007199254740992),this.words=[h&67108863,h/67108864&67108863,1],this.length=3),v==="le"&&this._initArray(this.toArray(),p,v)},s.prototype._initArray=function(h,p,v){if(i(typeof h.length=="number"),h.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(h.length/3),this.words=new Array(this.length);for(var y=0;y<this.length;y++)this.words[y]=0;var w,S,D=0;if(v==="be")for(y=h.length-1,w=0;y>=0;y-=3)S=h[y]|h[y-1]<<8|h[y-2]<<16,this.words[w]|=S<<D&67108863,this.words[w+1]=S>>>26-D&67108863,D+=24,D>=26&&(D-=26,w++);else if(v==="le")for(y=0,w=0;y<h.length;y+=3)S=h[y]|h[y+1]<<8|h[y+2]<<16,this.words[w]|=S<<D&67108863,this.words[w+1]=S>>>26-D&67108863,D+=24,D>=26&&(D-=26,w++);return this.strip()};function a(A,h){var p=A.charCodeAt(h);return p>=65&&p<=70?p-55:p>=97&&p<=102?p-87:p-48&15}function c(A,h,p){var v=a(A,p);return p-1>=h&&(v|=a(A,p-1)<<4),v}s.prototype._parseHex=function(h,p,v){this.length=Math.ceil((h.length-p)/6),this.words=new Array(this.length);for(var y=0;y<this.length;y++)this.words[y]=0;var w=0,S=0,D;if(v==="be")for(y=h.length-1;y>=p;y-=2)D=c(h,p,y)<<w,this.words[S]|=D&67108863,w>=18?(w-=18,S+=1,this.words[S]|=D>>>26):w+=8;else{var _=h.length-p;for(y=_%2===0?p+1:p;y<h.length;y+=2)D=c(h,p,y)<<w,this.words[S]|=D&67108863,w>=18?(w-=18,S+=1,this.words[S]|=D>>>26):w+=8}this.strip()};function f(A,h,p,v){for(var y=0,w=Math.min(A.length,p),S=h;S<w;S++){var D=A.charCodeAt(S)-48;y*=v,D>=49?y+=D-49+10:D>=17?y+=D-17+10:y+=D}return y}s.prototype._parseBase=function(h,p,v){this.words=[0],this.length=1;for(var y=0,w=1;w<=67108863;w*=p)y++;y--,w=w/p|0;for(var S=h.length-v,D=S%y,_=Math.min(S,S-D)+v,l=0,E=v;E<_;E+=y)l=f(h,E,E+y,p),this.imuln(w),this.words[0]+l<67108864?this.words[0]+=l:this._iaddn(l);if(D!==0){var q=1;for(l=f(h,E,h.length,p),E=0;E<D;E++)q*=p;this.imuln(q),this.words[0]+l<67108864?this.words[0]+=l:this._iaddn(l)}this.strip()},s.prototype.copy=function(h){h.words=new Array(this.length);for(var p=0;p<this.length;p++)h.words[p]=this.words[p];h.length=this.length,h.negative=this.negative,h.red=this.red},s.prototype.clone=function(){var h=new s(null);return this.copy(h),h},s.prototype._expand=function(h){for(;this.length<h;)this.words[this.length++]=0;return this},s.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},s.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};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"],d=[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],g=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];s.prototype.toString=function(h,p){h=h||10,p=p|0||1;var v;if(h===16||h==="hex"){v="";for(var y=0,w=0,S=0;S<this.length;S++){var D=this.words[S],_=((D<<y|w)&16777215).toString(16);w=D>>>24-y&16777215,y+=2,y>=26&&(y-=26,S--),w!==0||S!==this.length-1?v=u[6-_.length]+_+v:v=_+v}for(w!==0&&(v=w.toString(16)+v);v.length%p!==0;)v="0"+v;return this.negative!==0&&(v="-"+v),v}if(h===(h|0)&&h>=2&&h<=36){var l=d[h],E=g[h];v="";var q=this.clone();for(q.negative=0;!q.isZero();){var z=q.modn(E).toString(h);q=q.idivn(E),q.isZero()?v=z+v:v=u[l-z.length]+z+v}for(this.isZero()&&(v="0"+v);v.length%p!==0;)v="0"+v;return this.negative!==0&&(v="-"+v),v}i(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var h=this.words[0];return this.length===2?h+=this.words[1]*67108864:this.length===3&&this.words[2]===1?h+=4503599627370496+this.words[1]*67108864:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-h:h},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(h,p){return i(typeof o<"u"),this.toArrayLike(o,h,p)},s.prototype.toArray=function(h,p){return this.toArrayLike(Array,h,p)},s.prototype.toArrayLike=function(h,p,v){var y=this.byteLength(),w=v||Math.max(1,y);i(y<=w,"byte array longer than desired length"),i(w>0,"Requested array length <= 0"),this.strip();var S=p==="le",D=new h(w),_,l,E=this.clone();if(S){for(l=0;!E.isZero();l++)_=E.andln(255),E.iushrn(8),D[l]=_;for(;l<w;l++)D[l]=0}else{for(l=0;l<w-y;l++)D[l]=0;for(l=0;!E.isZero();l++)_=E.andln(255),E.iushrn(8),D[w-l-1]=_}return D},Math.clz32?s.prototype._countBits=function(h){return 32-Math.clz32(h)}:s.prototype._countBits=function(h){var p=h,v=0;return p>=4096&&(v+=13,p>>>=13),p>=64&&(v+=7,p>>>=7),p>=8&&(v+=4,p>>>=4),p>=2&&(v+=2,p>>>=2),v+p},s.prototype._zeroBits=function(h){if(h===0)return 26;var p=h,v=0;return p&8191||(v+=13,p>>>=13),p&127||(v+=7,p>>>=7),p&15||(v+=4,p>>>=4),p&3||(v+=2,p>>>=2),p&1||v++,v},s.prototype.bitLength=function(){var h=this.words[this.length-1],p=this._countBits(h);return(this.length-1)*26+p};function m(A){for(var h=new Array(A.bitLength()),p=0;p<h.length;p++){var v=p/26|0,y=p%26;h[p]=(A.words[v]&1<<y)>>>y}return h}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var h=0,p=0;p<this.length;p++){var v=this._zeroBits(this.words[p]);if(h+=v,v!==26)break}return h},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(h){return this.negative!==0?this.abs().inotn(h).iaddn(1):this.clone()},s.prototype.fromTwos=function(h){return this.testn(h-1)?this.notn(h).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return this.negative!==0},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(h){for(;this.length<h.length;)this.words[this.length++]=0;for(var p=0;p<h.length;p++)this.words[p]=this.words[p]|h.words[p];return this.strip()},s.prototype.ior=function(h){return i((this.negative|h.negative)===0),this.iuor(h)},s.prototype.or=function(h){return this.length>h.length?this.clone().ior(h):h.clone().ior(this)},s.prototype.uor=function(h){return this.length>h.length?this.clone().iuor(h):h.clone().iuor(this)},s.prototype.iuand=function(h){var p;this.length>h.length?p=h:p=this;for(var v=0;v<p.length;v++)this.words[v]=this.words[v]&h.words[v];return this.length=p.length,this.strip()},s.prototype.iand=function(h){return i((this.negative|h.negative)===0),this.iuand(h)},s.prototype.and=function(h){return this.length>h.length?this.clone().iand(h):h.clone().iand(this)},s.prototype.uand=function(h){return this.length>h.length?this.clone().iuand(h):h.clone().iuand(this)},s.prototype.iuxor=function(h){var p,v;this.length>h.length?(p=this,v=h):(p=h,v=this);for(var y=0;y<v.length;y++)this.words[y]=p.words[y]^v.words[y];if(this!==p)for(;y<p.length;y++)this.words[y]=p.words[y];return this.length=p.length,this.strip()},s.prototype.ixor=function(h){return i((this.negative|h.negative)===0),this.iuxor(h)},s.prototype.xor=function(h){return this.length>h.length?this.clone().ixor(h):h.clone().ixor(this)},s.prototype.uxor=function(h){return this.length>h.length?this.clone().iuxor(h):h.clone().iuxor(this)},s.prototype.inotn=function(h){i(typeof h=="number"&&h>=0);var p=Math.ceil(h/26)|0,v=h%26;this._expand(p),v>0&&p--;for(var y=0;y<p;y++)this.words[y]=~this.words[y]&67108863;return v>0&&(this.words[y]=~this.words[y]&67108863>>26-v),this.strip()},s.prototype.notn=function(h){return this.clone().inotn(h)},s.prototype.setn=function(h,p){i(typeof h=="number"&&h>=0);var v=h/26|0,y=h%26;return this._expand(v+1),p?this.words[v]=this.words[v]|1<<y:this.words[v]=this.words[v]&~(1<<y),this.strip()},s.prototype.iadd=function(h){var p;if(this.negative!==0&&h.negative===0)return this.negative=0,p=this.isub(h),this.negative^=1,this._normSign();if(this.negative===0&&h.negative!==0)return h.negative=0,p=this.isub(h),h.negative=1,p._normSign();var v,y;this.length>h.length?(v=this,y=h):(v=h,y=this);for(var w=0,S=0;S<y.length;S++)p=(v.words[S]|0)+(y.words[S]|0)+w,this.words[S]=p&67108863,w=p>>>26;for(;w!==0&&S<v.length;S++)p=(v.words[S]|0)+w,this.words[S]=p&67108863,w=p>>>26;if(this.length=v.length,w!==0)this.words[this.length]=w,this.length++;else if(v!==this)for(;S<v.length;S++)this.words[S]=v.words[S];return this},s.prototype.add=function(h){var p;return h.negative!==0&&this.negative===0?(h.negative=0,p=this.sub(h),h.negative^=1,p):h.negative===0&&this.negative!==0?(this.negative=0,p=h.sub(this),this.negative=1,p):this.length>h.length?this.clone().iadd(h):h.clone().iadd(this)},s.prototype.isub=function(h){if(h.negative!==0){h.negative=0;var p=this.iadd(h);return h.negative=1,p._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(h),this.negative=1,this._normSign();var v=this.cmp(h);if(v===0)return this.negative=0,this.length=1,this.words[0]=0,this;var y,w;v>0?(y=this,w=h):(y=h,w=this);for(var S=0,D=0;D<w.length;D++)p=(y.words[D]|0)-(w.words[D]|0)+S,S=p>>26,this.words[D]=p&67108863;for(;S!==0&&D<y.length;D++)p=(y.words[D]|0)+S,S=p>>26,this.words[D]=p&67108863;if(S===0&&D<y.length&&y!==this)for(;D<y.length;D++)this.words[D]=y.words[D];return this.length=Math.max(this.length,D),y!==this&&(this.negative=1),this.strip()},s.prototype.sub=function(h){return this.clone().isub(h)};function b(A,h,p){p.negative=h.negative^A.negative;var v=A.length+h.length|0;p.length=v,v=v-1|0;var y=A.words[0]|0,w=h.words[0]|0,S=y*w,D=S&67108863,_=S/67108864|0;p.words[0]=D;for(var l=1;l<v;l++){for(var E=_>>>26,q=_&67108863,z=Math.min(l,h.length-1),U=Math.max(0,l-A.length+1);U<=z;U++){var k=l-U|0;y=A.words[k]|0,w=h.words[U]|0,S=y*w+q,E+=S/67108864|0,q=S&67108863}p.words[l]=q|0,_=E|0}return _!==0?p.words[l]=_|0:p.length--,p.strip()}var x=function(h,p,v){var y=h.words,w=p.words,S=v.words,D=0,_,l,E,q=y[0]|0,z=q&8191,U=q>>>13,k=y[1]|0,G=k&8191,J=k>>>13,X=y[2]|0,Z=X&8191,Q=X>>>13,Fe=y[3]|0,re=Fe&8191,oe=Fe>>>13,ct=y[4]|0,he=ct&8191,Pe=ct>>>13,es=y[5]|0,Re=es&8191,Ae=es>>>13,on=y[6]|0,xe=on&8191,De=on>>>13,an=y[7]|0,$e=an&8191,Oe=an>>>13,cn=y[8]|0,ye=cn&8191,Ee=cn>>>13,fn=y[9]|0,ae=fn&8191,Le=fn>>>13,Gs=w[0]|0,He=Gs&8191,qe=Gs>>>13,un=w[1]|0,ze=un&8191,Ue=un>>>13,Oa=w[2]|0,pe=Oa&8191,ke=Oa>>>13,Ma=w[3]|0,We=Ma&8191,Te=Ma>>>13,Oi=w[4]|0,Ce=Oi&8191,Ne=Oi>>>13,ts=w[5]|0,Se=ts&8191,Ge=ts>>>13,Pa=w[6]|0,Ye=Pa&8191,Ze=Pa>>>13,Ra=w[7]|0,je=Ra&8191,Be=Ra>>>13,Hr=w[8]|0,Je=Hr&8191,Xe=Hr>>>13,Ta=w[9]|0,Qe=Ta&8191,et=Ta>>>13;v.negative=h.negative^p.negative,v.length=19,_=Math.imul(z,He),l=Math.imul(z,qe),l=l+Math.imul(U,He)|0,E=Math.imul(U,qe);var er=(D+_|0)+((l&8191)<<13)|0;D=(E+(l>>>13)|0)+(er>>>26)|0,er&=67108863,_=Math.imul(G,He),l=Math.imul(G,qe),l=l+Math.imul(J,He)|0,E=Math.imul(J,qe),_=_+Math.imul(z,ze)|0,l=l+Math.imul(z,Ue)|0,l=l+Math.imul(U,ze)|0,E=E+Math.imul(U,Ue)|0;var Ys=(D+_|0)+((l&8191)<<13)|0;D=(E+(l>>>13)|0)+(Ys>>>26)|0,Ys&=67108863,_=Math.imul(Z,He),l=Math.imul(Z,qe),l=l+Math.imul(Q,He)|0,E=Math.imul(Q,qe),_=_+Math.imul(G,ze)|0,l=l+Math.imul(G,Ue)|0,l=l+Math.imul(J,ze)|0,E=E+Math.imul(J,Ue)|0,_=_+Math.imul(z,pe)|0,l=l+Math.imul(z,ke)|0,l=l+Math.imul(U,pe)|0,E=E+Math.imul(U,ke)|0;var Zs=(D+_|0)+((l&8191)<<13)|0;D=(E+(l>>>13)|0)+(Zs>>>26)|0,Zs&=67108863,_=Math.imul(re,He),l=Math.imul(re,qe),l=l+Math.imul(oe,He)|0,E=Math.imul(oe,qe),_=_+Math.imul(Z,ze)|0,l=l+Math.imul(Z,Ue)|0,l=l+Math.imul(Q,ze)|0,E=E+Math.imul(Q,Ue)|0,_=_+Math.imul(G,pe)|0,l=l+Math.imul(G,ke)|0,l=l+Math.imul(J,pe)|0,E=E+Math.imul(J,ke)|0,_=_+Math.imul(z,We)|0,l=l+Math.imul(z,Te)|0,l=l+Math.imul(U,We)|0,E=E+Math.imul(U,Te)|0;var Js=(D+_|0)+((l&8191)<<13)|0;D=(E+(l>>>13)|0)+(Js>>>26)|0,Js&=67108863,_=Math.imul(he,He),l=Math.imul(he,qe),l=l+Math.imul(Pe,He)|0,E=Math.imul(Pe,qe),_=_+Math.imul(re,ze)|0,l=l+Math.imul(re,Ue)|0,l=l+Math.imul(oe,ze)|0,E=E+Math.imul(oe,Ue)|0,_=_+Math.imul(Z,pe)|0,l=l+Math.imul(Z,ke)|0,l=l+Math.imul(Q,pe)|0,E=E+Math.imul(Q,ke)|0,_=_+Math.imul(G,We)|0,l=l+Math.imul(G,Te)|0,l=l+Math.imul(J,We)|0,E=E+Math.imul(J,Te)|0,_=_+Math.imul(z,Ce)|0,l=l+Math.imul(z,Ne)|0,l=l+Math.imul(U,Ce)|0,E=E+Math.imul(U,Ne)|0;var Xs=(D+_|0)+((l&8191)<<13)|0;D=(E+(l>>>13)|0)+(Xs>>>26)|0,Xs&=67108863,_=Math.imul(Re,He),l=Math.imul(Re,qe),l=l+Math.imul(Ae,He)|0,E=Math.imul(Ae,qe),_=_+Math.imul(he,ze)|0,l=l+Math.imul(he,Ue)|0,l=l+Math.imul(Pe,ze)|0,E=E+Math.imul(Pe,Ue)|0,_=_+Math.imul(re,pe)|0,l=l+Math.imul(re,ke)|0,l=l+Math.imul(oe,pe)|0,E=E+Math.imul(oe,ke)|0,_=_+Math.imul(Z,We)|0,l=l+Math.imul(Z,Te)|0,l=l+Math.imul(Q,We)|0,E=E+Math.imul(Q,Te)|0,_=_+Math.imul(G,Ce)|0,l=l+Math.imul(G,Ne)|0,l=l+Math.imul(J,Ce)|0,E=E+Math.imul(J,Ne)|0,_=_+Math.imul(z,Se)|0,l=l+Math.imul(z,Ge)|0,l=l+Math.imul(U,Se)|0,E=E+Math.imul(U,Ge)|0;var Qs=(D+_|0)+((l&8191)<<13)|0;D=(E+(l>>>13)|0)+(Qs>>>26)|0,Qs&=67108863,_=Math.imul(xe,He),l=Math.imul(xe,qe),l=l+Math.imul(De,He)|0,E=Math.imul(De,qe),_=_+Math.imul(Re,ze)|0,l=l+Math.imul(Re,Ue)|0,l=l+Math.imul(Ae,ze)|0,E=E+Math.imul(Ae,Ue)|0,_=_+Math.imul(he,pe)|0,l=l+Math.imul(he,ke)|0,l=l+Math.imul(Pe,pe)|0,E=E+Math.imul(Pe,ke)|0,_=_+Math.imul(re,We)|0,l=l+Math.imul(re,Te)|0,l=l+Math.imul(oe,We)|0,E=E+Math.imul(oe,Te)|0,_=_+Math.imul(Z,Ce)|0,l=l+Math.imul(Z,Ne)|0,l=l+Math.imul(Q,Ce)|0,E=E+Math.imul(Q,Ne)|0,_=_+Math.imul(G,Se)|0,l=l+Math.imul(G,Ge)|0,l=l+Math.imul(J,Se)|0,E=E+Math.imul(J,Ge)|0,_=_+Math.imul(z,Ye)|0,l=l+Math.imul(z,Ze)|0,l=l+Math.imul(U,Ye)|0,E=E+Math.imul(U,Ze)|0;var xr=(D+_|0)+((l&8191)<<13)|0;D=(E+(l>>>13)|0)+(xr>>>26)|0,xr&=67108863,_=Math.imul($e,He),l=Math.imul($e,qe),l=l+Math.imul(Oe,He)|0,E=Math.imul(Oe,qe),_=_+Math.imul(xe,ze)|0,l=l+Math.imul(xe,Ue)|0,l=l+Math.imul(De,ze)|0,E=E+Math.imul(De,Ue)|0,_=_+Math.imul(Re,pe)|0,l=l+Math.imul(Re,ke)|0,l=l+Math.imul(Ae,pe)|0,E=E+Math.imul(Ae,ke)|0,_=_+Math.imul(he,We)|0,l=l+Math.imul(he,Te)|0,l=l+Math.imul(Pe,We)|0,E=E+Math.imul(Pe,Te)|0,_=_+Math.imul(re,Ce)|0,l=l+Math.imul(re,Ne)|0,l=l+Math.imul(oe,Ce)|0,E=E+Math.imul(oe,Ne)|0,_=_+Math.imul(Z,Se)|0,l=l+Math.imul(Z,Ge)|0,l=l+Math.imul(Q,Se)|0,E=E+Math.imul(Q,Ge)|0,_=_+Math.imul(G,Ye)|0,l=l+Math.imul(G,Ze)|0,l=l+Math.imul(J,Ye)|0,E=E+Math.imul(J,Ze)|0,_=_+Math.imul(z,je)|0,l=l+Math.imul(z,Be)|0,l=l+Math.imul(U,je)|0,E=E+Math.imul(U,Be)|0;var eo=(D+_|0)+((l&8191)<<13)|0;D=(E+(l>>>13)|0)+(eo>>>26)|0,eo&=67108863,_=Math.imul(ye,He),l=Math.imul(ye,qe),l=l+Math.imul(Ee,He)|0,E=Math.imul(Ee,qe),_=_+Math.imul($e,ze)|0,l=l+Math.imul($e,Ue)|0,l=l+Math.imul(Oe,ze)|0,E=E+Math.imul(Oe,Ue)|0,_=_+Math.imul(xe,pe)|0,l=l+Math.imul(xe,ke)|0,l=l+Math.imul(De,pe)|0,E=E+Math.imul(De,ke)|0,_=_+Math.imul(Re,We)|0,l=l+Math.imul(Re,Te)|0,l=l+Math.imul(Ae,We)|0,E=E+Math.imul(Ae,Te)|0,_=_+Math.imul(he,Ce)|0,l=l+Math.imul(he,Ne)|0,l=l+Math.imul(Pe,Ce)|0,E=E+Math.imul(Pe,Ne)|0,_=_+Math.imul(re,Se)|0,l=l+Math.imul(re,Ge)|0,l=l+Math.imul(oe,Se)|0,E=E+Math.imul(oe,Ge)|0,_=_+Math.imul(Z,Ye)|0,l=l+Math.imul(Z,Ze)|0,l=l+Math.imul(Q,Ye)|0,E=E+Math.imul(Q,Ze)|0,_=_+Math.imul(G,je)|0,l=l+Math.imul(G,Be)|0,l=l+Math.imul(J,je)|0,E=E+Math.imul(J,Be)|0,_=_+Math.imul(z,Je)|0,l=l+Math.imul(z,Xe)|0,l=l+Math.imul(U,Je)|0,E=E+Math.imul(U,Xe)|0;var to=(D+_|0)+((l&8191)<<13)|0;D=(E+(l>>>13)|0)+(to>>>26)|0,to&=67108863,_=Math.imul(ae,He),l=Math.imul(ae,qe),l=l+Math.imul(Le,He)|0,E=Math.imul(Le,qe),_=_+Math.imul(ye,ze)|0,l=l+Math.imul(ye,Ue)|0,l=l+Math.imul(Ee,ze)|0,E=E+Math.imul(Ee,Ue)|0,_=_+Math.imul($e,pe)|0,l=l+Math.imul($e,ke)|0,l=l+Math.imul(Oe,pe)|0,E=E+Math.imul(Oe,ke)|0,_=_+Math.imul(xe,We)|0,l=l+Math.imul(xe,Te)|0,l=l+Math.imul(De,We)|0,E=E+Math.imul(De,Te)|0,_=_+Math.imul(Re,Ce)|0,l=l+Math.imul(Re,Ne)|0,l=l+Math.imul(Ae,Ce)|0,E=E+Math.imul(Ae,Ne)|0,_=_+Math.imul(he,Se)|0,l=l+Math.imul(he,Ge)|0,l=l+Math.imul(Pe,Se)|0,E=E+Math.imul(Pe,Ge)|0,_=_+Math.imul(re,Ye)|0,l=l+Math.imul(re,Ze)|0,l=l+Math.imul(oe,Ye)|0,E=E+Math.imul(oe,Ze)|0,_=_+Math.imul(Z,je)|0,l=l+Math.imul(Z,Be)|0,l=l+Math.imul(Q,je)|0,E=E+Math.imul(Q,Be)|0,_=_+Math.imul(G,Je)|0,l=l+Math.imul(G,Xe)|0,l=l+Math.imul(J,Je)|0,E=E+Math.imul(J,Xe)|0,_=_+Math.imul(z,Qe)|0,l=l+Math.imul(z,et)|0,l=l+Math.imul(U,Qe)|0,E=E+Math.imul(U,et)|0;var ro=(D+_|0)+((l&8191)<<13)|0;D=(E+(l>>>13)|0)+(ro>>>26)|0,ro&=67108863,_=Math.imul(ae,ze),l=Math.imul(ae,Ue),l=l+Math.imul(Le,ze)|0,E=Math.imul(Le,Ue),_=_+Math.imul(ye,pe)|0,l=l+Math.imul(ye,ke)|0,l=l+Math.imul(Ee,pe)|0,E=E+Math.imul(Ee,ke)|0,_=_+Math.imul($e,We)|0,l=l+Math.imul($e,Te)|0,l=l+Math.imul(Oe,We)|0,E=E+Math.imul(Oe,Te)|0,_=_+Math.imul(xe,Ce)|0,l=l+Math.imul(xe,Ne)|0,l=l+Math.imul(De,Ce)|0,E=E+Math.imul(De,Ne)|0,_=_+Math.imul(Re,Se)|0,l=l+Math.imul(Re,Ge)|0,l=l+Math.imul(Ae,Se)|0,E=E+Math.imul(Ae,Ge)|0,_=_+Math.imul(he,Ye)|0,l=l+Math.imul(he,Ze)|0,l=l+Math.imul(Pe,Ye)|0,E=E+Math.imul(Pe,Ze)|0,_=_+Math.imul(re,je)|0,l=l+Math.imul(re,Be)|0,l=l+Math.imul(oe,je)|0,E=E+Math.imul(oe,Be)|0,_=_+Math.imul(Z,Je)|0,l=l+Math.imul(Z,Xe)|0,l=l+Math.imul(Q,Je)|0,E=E+Math.imul(Q,Xe)|0,_=_+Math.imul(G,Qe)|0,l=l+Math.imul(G,et)|0,l=l+Math.imul(J,Qe)|0,E=E+Math.imul(J,et)|0;var io=(D+_|0)+((l&8191)<<13)|0;D=(E+(l>>>13)|0)+(io>>>26)|0,io&=67108863,_=Math.imul(ae,pe),l=Math.imul(ae,ke),l=l+Math.imul(Le,pe)|0,E=Math.imul(Le,ke),_=_+Math.imul(ye,We)|0,l=l+Math.imul(ye,Te)|0,l=l+Math.imul(Ee,We)|0,E=E+Math.imul(Ee,Te)|0,_=_+Math.imul($e,Ce)|0,l=l+Math.imul($e,Ne)|0,l=l+Math.imul(Oe,Ce)|0,E=E+Math.imul(Oe,Ne)|0,_=_+Math.imul(xe,Se)|0,l=l+Math.imul(xe,Ge)|0,l=l+Math.imul(De,Se)|0,E=E+Math.imul(De,Ge)|0,_=_+Math.imul(Re,Ye)|0,l=l+Math.imul(Re,Ze)|0,l=l+Math.imul(Ae,Ye)|0,E=E+Math.imul(Ae,Ze)|0,_=_+Math.imul(he,je)|0,l=l+Math.imul(he,Be)|0,l=l+Math.imul(Pe,je)|0,E=E+Math.imul(Pe,Be)|0,_=_+Math.imul(re,Je)|0,l=l+Math.imul(re,Xe)|0,l=l+Math.imul(oe,Je)|0,E=E+Math.imul(oe,Xe)|0,_=_+Math.imul(Z,Qe)|0,l=l+Math.imul(Z,et)|0,l=l+Math.imul(Q,Qe)|0,E=E+Math.imul(Q,et)|0;var no=(D+_|0)+((l&8191)<<13)|0;D=(E+(l>>>13)|0)+(no>>>26)|0,no&=67108863,_=Math.imul(ae,We),l=Math.imul(ae,Te),l=l+Math.imul(Le,We)|0,E=Math.imul(Le,Te),_=_+Math.imul(ye,Ce)|0,l=l+Math.imul(ye,Ne)|0,l=l+Math.imul(Ee,Ce)|0,E=E+Math.imul(Ee,Ne)|0,_=_+Math.imul($e,Se)|0,l=l+Math.imul($e,Ge)|0,l=l+Math.imul(Oe,Se)|0,E=E+Math.imul(Oe,Ge)|0,_=_+Math.imul(xe,Ye)|0,l=l+Math.imul(xe,Ze)|0,l=l+Math.imul(De,Ye)|0,E=E+Math.imul(De,Ze)|0,_=_+Math.imul(Re,je)|0,l=l+Math.imul(Re,Be)|0,l=l+Math.imul(Ae,je)|0,E=E+Math.imul(Ae,Be)|0,_=_+Math.imul(he,Je)|0,l=l+Math.imul(he,Xe)|0,l=l+Math.imul(Pe,Je)|0,E=E+Math.imul(Pe,Xe)|0,_=_+Math.imul(re,Qe)|0,l=l+Math.imul(re,et)|0,l=l+Math.imul(oe,Qe)|0,E=E+Math.imul(oe,et)|0;var Mi=(D+_|0)+((l&8191)<<13)|0;D=(E+(l>>>13)|0)+(Mi>>>26)|0,Mi&=67108863,_=Math.imul(ae,Ce),l=Math.imul(ae,Ne),l=l+Math.imul(Le,Ce)|0,E=Math.imul(Le,Ne),_=_+Math.imul(ye,Se)|0,l=l+Math.imul(ye,Ge)|0,l=l+Math.imul(Ee,Se)|0,E=E+Math.imul(Ee,Ge)|0,_=_+Math.imul($e,Ye)|0,l=l+Math.imul($e,Ze)|0,l=l+Math.imul(Oe,Ye)|0,E=E+Math.imul(Oe,Ze)|0,_=_+Math.imul(xe,je)|0,l=l+Math.imul(xe,Be)|0,l=l+Math.imul(De,je)|0,E=E+Math.imul(De,Be)|0,_=_+Math.imul(Re,Je)|0,l=l+Math.imul(Re,Xe)|0,l=l+Math.imul(Ae,Je)|0,E=E+Math.imul(Ae,Xe)|0,_=_+Math.imul(he,Qe)|0,l=l+Math.imul(he,et)|0,l=l+Math.imul(Pe,Qe)|0,E=E+Math.imul(Pe,et)|0;var so=(D+_|0)+((l&8191)<<13)|0;D=(E+(l>>>13)|0)+(so>>>26)|0,so&=67108863,_=Math.imul(ae,Se),l=Math.imul(ae,Ge),l=l+Math.imul(Le,Se)|0,E=Math.imul(Le,Ge),_=_+Math.imul(ye,Ye)|0,l=l+Math.imul(ye,Ze)|0,l=l+Math.imul(Ee,Ye)|0,E=E+Math.imul(Ee,Ze)|0,_=_+Math.imul($e,je)|0,l=l+Math.imul($e,Be)|0,l=l+Math.imul(Oe,je)|0,E=E+Math.imul(Oe,Be)|0,_=_+Math.imul(xe,Je)|0,l=l+Math.imul(xe,Xe)|0,l=l+Math.imul(De,Je)|0,E=E+Math.imul(De,Xe)|0,_=_+Math.imul(Re,Qe)|0,l=l+Math.imul(Re,et)|0,l=l+Math.imul(Ae,Qe)|0,E=E+Math.imul(Ae,et)|0;var oo=(D+_|0)+((l&8191)<<13)|0;D=(E+(l>>>13)|0)+(oo>>>26)|0,oo&=67108863,_=Math.imul(ae,Ye),l=Math.imul(ae,Ze),l=l+Math.imul(Le,Ye)|0,E=Math.imul(Le,Ze),_=_+Math.imul(ye,je)|0,l=l+Math.imul(ye,Be)|0,l=l+Math.imul(Ee,je)|0,E=E+Math.imul(Ee,Be)|0,_=_+Math.imul($e,Je)|0,l=l+Math.imul($e,Xe)|0,l=l+Math.imul(Oe,Je)|0,E=E+Math.imul(Oe,Xe)|0,_=_+Math.imul(xe,Qe)|0,l=l+Math.imul(xe,et)|0,l=l+Math.imul(De,Qe)|0,E=E+Math.imul(De,et)|0;var ur=(D+_|0)+((l&8191)<<13)|0;D=(E+(l>>>13)|0)+(ur>>>26)|0,ur&=67108863,_=Math.imul(ae,je),l=Math.imul(ae,Be),l=l+Math.imul(Le,je)|0,E=Math.imul(Le,Be),_=_+Math.imul(ye,Je)|0,l=l+Math.imul(ye,Xe)|0,l=l+Math.imul(Ee,Je)|0,E=E+Math.imul(Ee,Xe)|0,_=_+Math.imul($e,Qe)|0,l=l+Math.imul($e,et)|0,l=l+Math.imul(Oe,Qe)|0,E=E+Math.imul(Oe,et)|0;var ao=(D+_|0)+((l&8191)<<13)|0;D=(E+(l>>>13)|0)+(ao>>>26)|0,ao&=67108863,_=Math.imul(ae,Je),l=Math.imul(ae,Xe),l=l+Math.imul(Le,Je)|0,E=Math.imul(Le,Xe),_=_+Math.imul(ye,Qe)|0,l=l+Math.imul(ye,et)|0,l=l+Math.imul(Ee,Qe)|0,E=E+Math.imul(Ee,et)|0;var co=(D+_|0)+((l&8191)<<13)|0;D=(E+(l>>>13)|0)+(co>>>26)|0,co&=67108863,_=Math.imul(ae,Qe),l=Math.imul(ae,et),l=l+Math.imul(Le,Qe)|0,E=Math.imul(Le,et);var fo=(D+_|0)+((l&8191)<<13)|0;return D=(E+(l>>>13)|0)+(fo>>>26)|0,fo&=67108863,S[0]=er,S[1]=Ys,S[2]=Zs,S[3]=Js,S[4]=Xs,S[5]=Qs,S[6]=xr,S[7]=eo,S[8]=to,S[9]=ro,S[10]=io,S[11]=no,S[12]=Mi,S[13]=so,S[14]=oo,S[15]=ur,S[16]=ao,S[17]=co,S[18]=fo,D!==0&&(S[19]=D,v.length++),v};Math.imul||(x=b);function I(A,h,p){p.negative=h.negative^A.negative,p.length=A.length+h.length;for(var v=0,y=0,w=0;w<p.length-1;w++){var S=y;y=0;for(var D=v&67108863,_=Math.min(w,h.length-1),l=Math.max(0,w-A.length+1);l<=_;l++){var E=w-l,q=A.words[E]|0,z=h.words[l]|0,U=q*z,k=U&67108863;S=S+(U/67108864|0)|0,k=k+D|0,D=k&67108863,S=S+(k>>>26)|0,y+=S>>>26,S&=67108863}p.words[w]=D,v=S,S=y}return v!==0?p.words[w]=v:p.length--,p.strip()}function O(A,h,p){var v=new $;return v.mulp(A,h,p)}s.prototype.mulTo=function(h,p){var v,y=this.length+h.length;return this.length===10&&h.length===10?v=x(this,h,p):y<63?v=b(this,h,p):y<1024?v=I(this,h,p):v=O(this,h,p),v};function $(A,h){this.x=A,this.y=h}$.prototype.makeRBT=function(h){for(var p=new Array(h),v=s.prototype._countBits(h)-1,y=0;y<h;y++)p[y]=this.revBin(y,v,h);return p},$.prototype.revBin=function(h,p,v){if(h===0||h===v-1)return h;for(var y=0,w=0;w<p;w++)y|=(h&1)<<p-w-1,h>>=1;return y},$.prototype.permute=function(h,p,v,y,w,S){for(var D=0;D<S;D++)y[D]=p[h[D]],w[D]=v[h[D]]},$.prototype.transform=function(h,p,v,y,w,S){this.permute(S,h,p,v,y,w);for(var D=1;D<w;D<<=1)for(var _=D<<1,l=Math.cos(2*Math.PI/_),E=Math.sin(2*Math.PI/_),q=0;q<w;q+=_)for(var z=l,U=E,k=0;k<D;k++){var G=v[q+k],J=y[q+k],X=v[q+k+D],Z=y[q+k+D],Q=z*X-U*Z;Z=z*Z+U*X,X=Q,v[q+k]=G+X,y[q+k]=J+Z,v[q+k+D]=G-X,y[q+k+D]=J-Z,k!==_&&(Q=l*z-E*U,U=l*U+E*z,z=Q)}},$.prototype.guessLen13b=function(h,p){var v=Math.max(p,h)|1,y=v&1,w=0;for(v=v/2|0;v;v=v>>>1)w++;return 1<<w+1+y},$.prototype.conjugate=function(h,p,v){if(!(v<=1))for(var y=0;y<v/2;y++){var w=h[y];h[y]=h[v-y-1],h[v-y-1]=w,w=p[y],p[y]=-p[v-y-1],p[v-y-1]=-w}},$.prototype.normalize13b=function(h,p){for(var v=0,y=0;y<p/2;y++){var w=Math.round(h[2*y+1]/p)*8192+Math.round(h[2*y]/p)+v;h[y]=w&67108863,w<67108864?v=0:v=w/67108864|0}return h},$.prototype.convert13b=function(h,p,v,y){for(var w=0,S=0;S<p;S++)w=w+(h[S]|0),v[2*S]=w&8191,w=w>>>13,v[2*S+1]=w&8191,w=w>>>13;for(S=2*p;S<y;++S)v[S]=0;i(w===0),i((w&-8192)===0)},$.prototype.stub=function(h){for(var p=new Array(h),v=0;v<h;v++)p[v]=0;return p},$.prototype.mulp=function(h,p,v){var y=2*this.guessLen13b(h.length,p.length),w=this.makeRBT(y),S=this.stub(y),D=new Array(y),_=new Array(y),l=new Array(y),E=new Array(y),q=new Array(y),z=new Array(y),U=v.words;U.length=y,this.convert13b(h.words,h.length,D,y),this.convert13b(p.words,p.length,E,y),this.transform(D,S,_,l,y,w),this.transform(E,S,q,z,y,w);for(var k=0;k<y;k++){var G=_[k]*q[k]-l[k]*z[k];l[k]=_[k]*z[k]+l[k]*q[k],_[k]=G}return this.conjugate(_,l,y),this.transform(_,l,U,S,y,w),this.conjugate(U,S,y),this.normalize13b(U,y),v.negative=h.negative^p.negative,v.length=h.length+p.length,v.strip()},s.prototype.mul=function(h){var p=new s(null);return p.words=new Array(this.length+h.length),this.mulTo(h,p)},s.prototype.mulf=function(h){var p=new s(null);return p.words=new Array(this.length+h.length),O(this,h,p)},s.prototype.imul=function(h){return this.clone().mulTo(h,this)},s.prototype.imuln=function(h){i(typeof h=="number"),i(h<67108864);for(var p=0,v=0;v<this.length;v++){var y=(this.words[v]|0)*h,w=(y&67108863)+(p&67108863);p>>=26,p+=y/67108864|0,p+=w>>>26,this.words[v]=w&67108863}return p!==0&&(this.words[v]=p,this.length++),this},s.prototype.muln=function(h){return this.clone().imuln(h)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(h){var p=m(h);if(p.length===0)return new s(1);for(var v=this,y=0;y<p.length&&p[y]===0;y++,v=v.sqr());if(++y<p.length)for(var w=v.sqr();y<p.length;y++,w=w.sqr())p[y]!==0&&(v=v.mul(w));return v},s.prototype.iushln=function(h){i(typeof h=="number"&&h>=0);var p=h%26,v=(h-p)/26,y=67108863>>>26-p<<26-p,w;if(p!==0){var S=0;for(w=0;w<this.length;w++){var D=this.words[w]&y,_=(this.words[w]|0)-D<<p;this.words[w]=_|S,S=D>>>26-p}S&&(this.words[w]=S,this.length++)}if(v!==0){for(w=this.length-1;w>=0;w--)this.words[w+v]=this.words[w];for(w=0;w<v;w++)this.words[w]=0;this.length+=v}return this.strip()},s.prototype.ishln=function(h){return i(this.negative===0),this.iushln(h)},s.prototype.iushrn=function(h,p,v){i(typeof h=="number"&&h>=0);var y;p?y=(p-p%26)/26:y=0;var w=h%26,S=Math.min((h-w)/26,this.length),D=67108863^67108863>>>w<<w,_=v;if(y-=S,y=Math.max(0,y),_){for(var l=0;l<S;l++)_.words[l]=this.words[l];_.length=S}if(S!==0)if(this.length>S)for(this.length-=S,l=0;l<this.length;l++)this.words[l]=this.words[l+S];else this.words[0]=0,this.length=1;var E=0;for(l=this.length-1;l>=0&&(E!==0||l>=y);l--){var q=this.words[l]|0;this.words[l]=E<<26-w|q>>>w,E=q&D}return _&&E!==0&&(_.words[_.length++]=E),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(h,p,v){return i(this.negative===0),this.iushrn(h,p,v)},s.prototype.shln=function(h){return this.clone().ishln(h)},s.prototype.ushln=function(h){return this.clone().iushln(h)},s.prototype.shrn=function(h){return this.clone().ishrn(h)},s.prototype.ushrn=function(h){return this.clone().iushrn(h)},s.prototype.testn=function(h){i(typeof h=="number"&&h>=0);var p=h%26,v=(h-p)/26,y=1<<p;if(this.length<=v)return!1;var w=this.words[v];return!!(w&y)},s.prototype.imaskn=function(h){i(typeof h=="number"&&h>=0);var p=h%26,v=(h-p)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=v)return this;if(p!==0&&v++,this.length=Math.min(v,this.length),p!==0){var y=67108863^67108863>>>p<<p;this.words[this.length-1]&=y}return this.strip()},s.prototype.maskn=function(h){return this.clone().imaskn(h)},s.prototype.iaddn=function(h){return i(typeof h=="number"),i(h<67108864),h<0?this.isubn(-h):this.negative!==0?this.length===1&&(this.words[0]|0)<h?(this.words[0]=h-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(h),this.negative=1,this):this._iaddn(h)},s.prototype._iaddn=function(h){this.words[0]+=h;for(var p=0;p<this.length&&this.words[p]>=67108864;p++)this.words[p]-=67108864,p===this.length-1?this.words[p+1]=1:this.words[p+1]++;return this.length=Math.max(this.length,p+1),this},s.prototype.isubn=function(h){if(i(typeof h=="number"),i(h<67108864),h<0)return this.iaddn(-h);if(this.negative!==0)return this.negative=0,this.iaddn(h),this.negative=1,this;if(this.words[0]-=h,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var p=0;p<this.length&&this.words[p]<0;p++)this.words[p]+=67108864,this.words[p+1]-=1;return this.strip()},s.prototype.addn=function(h){return this.clone().iaddn(h)},s.prototype.subn=function(h){return this.clone().isubn(h)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(h,p,v){var y=h.length+v,w;this._expand(y);var S,D=0;for(w=0;w<h.length;w++){S=(this.words[w+v]|0)+D;var _=(h.words[w]|0)*p;S-=_&67108863,D=(S>>26)-(_/67108864|0),this.words[w+v]=S&67108863}for(;w<this.length-v;w++)S=(this.words[w+v]|0)+D,D=S>>26,this.words[w+v]=S&67108863;if(D===0)return this.strip();for(i(D===-1),D=0,w=0;w<this.length;w++)S=-(this.words[w]|0)+D,D=S>>26,this.words[w]=S&67108863;return this.negative=1,this.strip()},s.prototype._wordDiv=function(h,p){var v=this.length-h.length,y=this.clone(),w=h,S=w.words[w.length-1]|0,D=this._countBits(S);v=26-D,v!==0&&(w=w.ushln(v),y.iushln(v),S=w.words[w.length-1]|0);var _=y.length-w.length,l;if(p!=="mod"){l=new s(null),l.length=_+1,l.words=new Array(l.length);for(var E=0;E<l.length;E++)l.words[E]=0}var q=y.clone()._ishlnsubmul(w,1,_);q.negative===0&&(y=q,l&&(l.words[_]=1));for(var z=_-1;z>=0;z--){var U=(y.words[w.length+z]|0)*67108864+(y.words[w.length+z-1]|0);for(U=Math.min(U/S|0,67108863),y._ishlnsubmul(w,U,z);y.negative!==0;)U--,y.negative=0,y._ishlnsubmul(w,1,z),y.isZero()||(y.negative^=1);l&&(l.words[z]=U)}return l&&l.strip(),y.strip(),p!=="div"&&v!==0&&y.iushrn(v),{div:l||null,mod:y}},s.prototype.divmod=function(h,p,v){if(i(!h.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var y,w,S;return this.negative!==0&&h.negative===0?(S=this.neg().divmod(h,p),p!=="mod"&&(y=S.div.neg()),p!=="div"&&(w=S.mod.neg(),v&&w.negative!==0&&w.iadd(h)),{div:y,mod:w}):this.negative===0&&h.negative!==0?(S=this.divmod(h.neg(),p),p!=="mod"&&(y=S.div.neg()),{div:y,mod:S.mod}):this.negative&h.negative?(S=this.neg().divmod(h.neg(),p),p!=="div"&&(w=S.mod.neg(),v&&w.negative!==0&&w.isub(h)),{div:S.div,mod:w}):h.length>this.length||this.cmp(h)<0?{div:new s(0),mod:this}:h.length===1?p==="div"?{div:this.divn(h.words[0]),mod:null}:p==="mod"?{div:null,mod:new s(this.modn(h.words[0]))}:{div:this.divn(h.words[0]),mod:new s(this.modn(h.words[0]))}:this._wordDiv(h,p)},s.prototype.div=function(h){return this.divmod(h,"div",!1).div},s.prototype.mod=function(h){return this.divmod(h,"mod",!1).mod},s.prototype.umod=function(h){return this.divmod(h,"mod",!0).mod},s.prototype.divRound=function(h){var p=this.divmod(h);if(p.mod.isZero())return p.div;var v=p.div.negative!==0?p.mod.isub(h):p.mod,y=h.ushrn(1),w=h.andln(1),S=v.cmp(y);return S<0||w===1&&S===0?p.div:p.div.negative!==0?p.div.isubn(1):p.div.iaddn(1)},s.prototype.modn=function(h){i(h<=67108863);for(var p=(1<<26)%h,v=0,y=this.length-1;y>=0;y--)v=(p*v+(this.words[y]|0))%h;return v},s.prototype.idivn=function(h){i(h<=67108863);for(var p=0,v=this.length-1;v>=0;v--){var y=(this.words[v]|0)+p*67108864;this.words[v]=y/h|0,p=y%h}return this.strip()},s.prototype.divn=function(h){return this.clone().idivn(h)},s.prototype.egcd=function(h){i(h.negative===0),i(!h.isZero());var p=this,v=h.clone();p.negative!==0?p=p.umod(h):p=p.clone();for(var y=new s(1),w=new s(0),S=new s(0),D=new s(1),_=0;p.isEven()&&v.isEven();)p.iushrn(1),v.iushrn(1),++_;for(var l=v.clone(),E=p.clone();!p.isZero();){for(var q=0,z=1;!(p.words[0]&z)&&q<26;++q,z<<=1);if(q>0)for(p.iushrn(q);q-- >0;)(y.isOdd()||w.isOdd())&&(y.iadd(l),w.isub(E)),y.iushrn(1),w.iushrn(1);for(var U=0,k=1;!(v.words[0]&k)&&U<26;++U,k<<=1);if(U>0)for(v.iushrn(U);U-- >0;)(S.isOdd()||D.isOdd())&&(S.iadd(l),D.isub(E)),S.iushrn(1),D.iushrn(1);p.cmp(v)>=0?(p.isub(v),y.isub(S),w.isub(D)):(v.isub(p),S.isub(y),D.isub(w))}return{a:S,b:D,gcd:v.iushln(_)}},s.prototype._invmp=function(h){i(h.negative===0),i(!h.isZero());var p=this,v=h.clone();p.negative!==0?p=p.umod(h):p=p.clone();for(var y=new s(1),w=new s(0),S=v.clone();p.cmpn(1)>0&&v.cmpn(1)>0;){for(var D=0,_=1;!(p.words[0]&_)&&D<26;++D,_<<=1);if(D>0)for(p.iushrn(D);D-- >0;)y.isOdd()&&y.iadd(S),y.iushrn(1);for(var l=0,E=1;!(v.words[0]&E)&&l<26;++l,E<<=1);if(l>0)for(v.iushrn(l);l-- >0;)w.isOdd()&&w.iadd(S),w.iushrn(1);p.cmp(v)>=0?(p.isub(v),y.isub(w)):(v.isub(p),w.isub(y))}var q;return p.cmpn(1)===0?q=y:q=w,q.cmpn(0)<0&&q.iadd(h),q},s.prototype.gcd=function(h){if(this.isZero())return h.abs();if(h.isZero())return this.abs();var p=this.clone(),v=h.clone();p.negative=0,v.negative=0;for(var y=0;p.isEven()&&v.isEven();y++)p.iushrn(1),v.iushrn(1);do{for(;p.isEven();)p.iushrn(1);for(;v.isEven();)v.iushrn(1);var w=p.cmp(v);if(w<0){var S=p;p=v,v=S}else if(w===0||v.cmpn(1)===0)break;p.isub(v)}while(!0);return v.iushln(y)},s.prototype.invm=function(h){return this.egcd(h).a.umod(h)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(h){return this.words[0]&h},s.prototype.bincn=function(h){i(typeof h=="number");var p=h%26,v=(h-p)/26,y=1<<p;if(this.length<=v)return this._expand(v+1),this.words[v]|=y,this;for(var w=y,S=v;w!==0&&S<this.length;S++){var D=this.words[S]|0;D+=w,w=D>>>26,D&=67108863,this.words[S]=D}return w!==0&&(this.words[S]=w,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(h){var p=h<0;if(this.negative!==0&&!p)return-1;if(this.negative===0&&p)return 1;this.strip();var v;if(this.length>1)v=1;else{p&&(h=-h),i(h<=67108863,"Number is too big");var y=this.words[0]|0;v=y===h?0:y<h?-1:1}return this.negative!==0?-v|0:v},s.prototype.cmp=function(h){if(this.negative!==0&&h.negative===0)return-1;if(this.negative===0&&h.negative!==0)return 1;var p=this.ucmp(h);return this.negative!==0?-p|0:p},s.prototype.ucmp=function(h){if(this.length>h.length)return 1;if(this.length<h.length)return-1;for(var p=0,v=this.length-1;v>=0;v--){var y=this.words[v]|0,w=h.words[v]|0;if(y!==w){y<w?p=-1:y>w&&(p=1);break}}return p},s.prototype.gtn=function(h){return this.cmpn(h)===1},s.prototype.gt=function(h){return this.cmp(h)===1},s.prototype.gten=function(h){return this.cmpn(h)>=0},s.prototype.gte=function(h){return this.cmp(h)>=0},s.prototype.ltn=function(h){return this.cmpn(h)===-1},s.prototype.lt=function(h){return this.cmp(h)===-1},s.prototype.lten=function(h){return this.cmpn(h)<=0},s.prototype.lte=function(h){return this.cmp(h)<=0},s.prototype.eqn=function(h){return this.cmpn(h)===0},s.prototype.eq=function(h){return this.cmp(h)===0},s.red=function(h){return new C(h)},s.prototype.toRed=function(h){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),h.convertTo(this)._forceRed(h)},s.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(h){return this.red=h,this},s.prototype.forceRed=function(h){return i(!this.red,"Already a number in reduction context"),this._forceRed(h)},s.prototype.redAdd=function(h){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,h)},s.prototype.redIAdd=function(h){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,h)},s.prototype.redSub=function(h){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,h)},s.prototype.redISub=function(h){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,h)},s.prototype.redShl=function(h){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,h)},s.prototype.redMul=function(h){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,h),this.red.mul(this,h)},s.prototype.redIMul=function(h){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,h),this.red.imul(this,h)},s.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(h){return i(this.red&&!h.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,h)};var P={k256:null,p224:null,p192:null,p25519:null};function R(A,h){this.name=A,this.p=new s(h,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}R.prototype._tmp=function(){var h=new s(null);return h.words=new Array(Math.ceil(this.n/13)),h},R.prototype.ireduce=function(h){var p=h,v;do this.split(p,this.tmp),p=this.imulK(p),p=p.iadd(this.tmp),v=p.bitLength();while(v>this.n);var y=v<this.n?-1:p.ucmp(this.p);return y===0?(p.words[0]=0,p.length=1):y>0?p.isub(this.p):p.strip!==void 0?p.strip():p._strip(),p},R.prototype.split=function(h,p){h.iushrn(this.n,0,p)},R.prototype.imulK=function(h){return h.imul(this.k)};function N(){R.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(N,R),N.prototype.split=function(h,p){for(var v=4194303,y=Math.min(h.length,9),w=0;w<y;w++)p.words[w]=h.words[w];if(p.length=y,h.length<=9){h.words[0]=0,h.length=1;return}var S=h.words[9];for(p.words[p.length++]=S&v,w=10;w<h.length;w++){var D=h.words[w]|0;h.words[w-10]=(D&v)<<4|S>>>22,S=D}S>>>=22,h.words[w-10]=S,S===0&&h.length>10?h.length-=10:h.length-=9},N.prototype.imulK=function(h){h.words[h.length]=0,h.words[h.length+1]=0,h.length+=2;for(var p=0,v=0;v<h.length;v++){var y=h.words[v]|0;p+=y*977,h.words[v]=p&67108863,p=y*64+(p/67108864|0)}return h.words[h.length-1]===0&&(h.length--,h.words[h.length-1]===0&&h.length--),h};function B(){R.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(B,R);function F(){R.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(F,R);function L(){R.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(L,R),L.prototype.imulK=function(h){for(var p=0,v=0;v<h.length;v++){var y=(h.words[v]|0)*19+p,w=y&67108863;y>>>=26,h.words[v]=w,p=y}return p!==0&&(h.words[h.length++]=p),h},s._prime=function(h){if(P[h])return P[h];var p;if(h==="k256")p=new N;else if(h==="p224")p=new B;else if(h==="p192")p=new F;else if(h==="p25519")p=new L;else throw new Error("Unknown prime "+h);return P[h]=p,p};function C(A){if(typeof A=="string"){var h=s._prime(A);this.m=h.p,this.prime=h}else i(A.gtn(1),"modulus must be greater than 1"),this.m=A,this.prime=null}C.prototype._verify1=function(h){i(h.negative===0,"red works only with positives"),i(h.red,"red works only with red numbers")},C.prototype._verify2=function(h,p){i((h.negative|p.negative)===0,"red works only with positives"),i(h.red&&h.red===p.red,"red works only with red numbers")},C.prototype.imod=function(h){return this.prime?this.prime.ireduce(h)._forceRed(this):h.umod(this.m)._forceRed(this)},C.prototype.neg=function(h){return h.isZero()?h.clone():this.m.sub(h)._forceRed(this)},C.prototype.add=function(h,p){this._verify2(h,p);var v=h.add(p);return v.cmp(this.m)>=0&&v.isub(this.m),v._forceRed(this)},C.prototype.iadd=function(h,p){this._verify2(h,p);var v=h.iadd(p);return v.cmp(this.m)>=0&&v.isub(this.m),v},C.prototype.sub=function(h,p){this._verify2(h,p);var v=h.sub(p);return v.cmpn(0)<0&&v.iadd(this.m),v._forceRed(this)},C.prototype.isub=function(h,p){this._verify2(h,p);var v=h.isub(p);return v.cmpn(0)<0&&v.iadd(this.m),v},C.prototype.shl=function(h,p){return this._verify1(h),this.imod(h.ushln(p))},C.prototype.imul=function(h,p){return this._verify2(h,p),this.imod(h.imul(p))},C.prototype.mul=function(h,p){return this._verify2(h,p),this.imod(h.mul(p))},C.prototype.isqr=function(h){return this.imul(h,h.clone())},C.prototype.sqr=function(h){return this.mul(h,h)},C.prototype.sqrt=function(h){if(h.isZero())return h.clone();var p=this.m.andln(3);if(i(p%2===1),p===3){var v=this.m.add(new s(1)).iushrn(2);return this.pow(h,v)}for(var y=this.m.subn(1),w=0;!y.isZero()&&y.andln(1)===0;)w++,y.iushrn(1);i(!y.isZero());var S=new s(1).toRed(this),D=S.redNeg(),_=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new s(2*l*l).toRed(this);this.pow(l,_).cmp(D)!==0;)l.redIAdd(D);for(var E=this.pow(l,y),q=this.pow(h,y.addn(1).iushrn(1)),z=this.pow(h,y),U=w;z.cmp(S)!==0;){for(var k=z,G=0;k.cmp(S)!==0;G++)k=k.redSqr();i(G<U);var J=this.pow(E,new s(1).iushln(U-G-1));q=q.redMul(J),E=J.redSqr(),z=z.redMul(E),U=G}return q},C.prototype.invm=function(h){var p=h._invmp(this.m);return p.negative!==0?(p.negative=0,this.imod(p).redNeg()):this.imod(p)},C.prototype.pow=function(h,p){if(p.isZero())return new s(1).toRed(this);if(p.cmpn(1)===0)return h.clone();var v=4,y=new Array(1<<v);y[0]=new s(1).toRed(this),y[1]=h;for(var w=2;w<y.length;w++)y[w]=this.mul(y[w-1],h);var S=y[0],D=0,_=0,l=p.bitLength()%26;for(l===0&&(l=26),w=p.length-1;w>=0;w--){for(var E=p.words[w],q=l-1;q>=0;q--){var z=E>>q&1;if(S!==y[0]&&(S=this.sqr(S)),z===0&&D===0){_=0;continue}D<<=1,D|=z,_++,!(_!==v&&(w!==0||q!==0))&&(S=this.mul(S,y[D]),_=0,D=0)}l=26}return S},C.prototype.convertTo=function(h){var p=h.umod(this.m);return p===h?p.clone():p},C.prototype.convertFrom=function(h){var p=h.clone();return p.red=null,p},s.mont=function(h){return new W(h)};function W(A){C.call(this,A),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}n(W,C),W.prototype.convertTo=function(h){return this.imod(h.ushln(this.shift))},W.prototype.convertFrom=function(h){var p=this.imod(h.mul(this.rinv));return p.red=null,p},W.prototype.imul=function(h,p){if(h.isZero()||p.isZero())return h.words[0]=0,h.length=1,h;var v=h.imul(p),y=v.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),w=v.isub(y).iushrn(this.shift),S=w;return w.cmp(this.m)>=0?S=w.isub(this.m):w.cmpn(0)<0&&(S=w.iadd(this.m)),S._forceRed(this)},W.prototype.mul=function(h,p){if(h.isZero()||p.isZero())return new s(0)._forceRed(this);var v=h.mul(p),y=v.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),w=v.isub(y).iushrn(this.shift),S=w;return w.cmp(this.m)>=0?S=w.isub(this.m):w.cmpn(0)<0&&(S=w.iadd(this.m)),S._forceRed(this)},W.prototype.invm=function(h){var p=this.imod(h._invmp(this.m).mul(this.r2));return p._forceRed(this)}})(t,Bt)})(Or);var ji=Bl;function Bl(t,e){if(!t)throw new Error(e||"Assertion failed")}Bl.equal=function(e,r,i){if(e!=r)throw new Error(i||"Assertion failed: "+e+" != "+r)};var of={};(function(t){var e=t;function r(s,o){if(Array.isArray(s))return s.slice();if(!s)return[];var a=[];if(typeof s!="string"){for(var c=0;c<s.length;c++)a[c]=s[c]|0;return a}if(o==="hex"){s=s.replace(/[^a-z0-9]+/ig,""),s.length%2!==0&&(s="0"+s);for(var c=0;c<s.length;c+=2)a.push(parseInt(s[c]+s[c+1],16))}else for(var c=0;c<s.length;c++){var f=s.charCodeAt(c),u=f>>8,d=f&255;u?a.push(u,d):a.push(d)}return a}e.toArray=r;function i(s){return s.length===1?"0"+s:s}e.zero2=i;function n(s){for(var o="",a=0;a<s.length;a++)o+=i(s[a].toString(16));return o}e.toHex=n,e.encode=function(o,a){return a==="hex"?n(o):o}})(of),function(t){var e=t,r=Or.exports,i=ji,n=of;e.assert=i,e.toArray=n.toArray,e.zero2=n.zero2,e.toHex=n.toHex,e.encode=n.encode;function s(u,d,g){var m=new Array(Math.max(u.bitLength(),g)+1),b;for(b=0;b<m.length;b+=1)m[b]=0;var x=1<<d+1,I=u.clone();for(b=0;b<m.length;b++){var O,$=I.andln(x-1);I.isOdd()?($>(x>>1)-1?O=(x>>1)-$:O=$,I.isubn(O)):O=0,m[b]=O,I.iushrn(1)}return m}e.getNAF=s;function o(u,d){var g=[[],[]];u=u.clone(),d=d.clone();for(var m=0,b=0,x;u.cmpn(-m)>0||d.cmpn(-b)>0;){var I=u.andln(3)+m&3,O=d.andln(3)+b&3;I===3&&(I=-1),O===3&&(O=-1);var $;I&1?(x=u.andln(7)+m&7,(x===3||x===5)&&O===2?$=-I:$=I):$=0,g[0].push($);var P;O&1?(x=d.andln(7)+b&7,(x===3||x===5)&&I===2?P=-O:P=O):P=0,g[1].push(P),2*m===$+1&&(m=1-m),2*b===P+1&&(b=1-b),u.iushrn(1),d.iushrn(1)}return g}e.getJSF=o;function a(u,d,g){var m="_"+d;u.prototype[d]=function(){return this[m]!==void 0?this[m]:this[m]=g.call(this)}}e.cachedProperty=a;function c(u){return typeof u=="string"?e.toArray(u,"hex"):u}e.parseBytes=c;function f(u){return new r(u,"hex","le")}e.intFromLE=f}(Yt);var Wo={exports:{}},af;Wo.exports=function(e){return af||(af=new vi(null)),af.generate(e)};function vi(t){this.rand=t}if(Wo.exports.Rand=vi,vi.prototype.generate=function(e){return this._rand(e)},vi.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var r=new Uint8Array(e),i=0;i<r.length;i++)r[i]=this.rand.getByte();return r},typeof self=="object")self.crypto&&self.crypto.getRandomValues?vi.prototype._rand=function(e){var r=new Uint8Array(e);return self.crypto.getRandomValues(r),r}:self.msCrypto&&self.msCrypto.getRandomValues?vi.prototype._rand=function(e){var r=new Uint8Array(e);return self.msCrypto.getRandomValues(r),r}:typeof window=="object"&&(vi.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var Fl=Nl;if(typeof Fl.randomBytes!="function")throw new Error("Not supported");vi.prototype._rand=function(e){return Fl.randomBytes(e)}}catch{}var cf={},Ki=Or.exports,xs=Yt,Go=xs.getNAF,b8=xs.getJSF,Yo=xs.assert;function mi(t,e){this.type=t,this.p=new Ki(e.p,16),this.red=e.prime?Ki.red(e.prime):Ki.mont(this.p),this.zero=new Ki(0).toRed(this.red),this.one=new Ki(1).toRed(this.red),this.two=new Ki(2).toRed(this.red),this.n=e.n&&new Ki(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 r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Zo=mi;mi.prototype.point=function(){throw new Error("Not implemented")},mi.prototype.validate=function(){throw new Error("Not implemented")},mi.prototype._fixedNafMul=function(e,r){Yo(e.precomputed);var i=e._getDoubles(),n=Go(r,1,this._bitLength),s=(1<<i.step+1)-(i.step%2===0?2:1);s/=3;var o=[],a,c;for(a=0;a<n.length;a+=i.step){c=0;for(var f=a+i.step-1;f>=a;f--)c=(c<<1)+n[f];o.push(c)}for(var u=this.jpoint(null,null,null),d=this.jpoint(null,null,null),g=s;g>0;g--){for(a=0;a<o.length;a++)c=o[a],c===g?d=d.mixedAdd(i.points[a]):c===-g&&(d=d.mixedAdd(i.points[a].neg()));u=u.add(d)}return u.toP()},mi.prototype._wnafMul=function(e,r){var i=4,n=e._getNAFPoints(i);i=n.wnd;for(var s=n.points,o=Go(r,i,this._bitLength),a=this.jpoint(null,null,null),c=o.length-1;c>=0;c--){for(var f=0;c>=0&&o[c]===0;c--)f++;if(c>=0&&f++,a=a.dblp(f),c<0)break;var u=o[c];Yo(u!==0),e.type==="affine"?u>0?a=a.mixedAdd(s[u-1>>1]):a=a.mixedAdd(s[-u-1>>1].neg()):u>0?a=a.add(s[u-1>>1]):a=a.add(s[-u-1>>1].neg())}return e.type==="affine"?a.toP():a},mi.prototype._wnafMulAdd=function(e,r,i,n,s){var o=this._wnafT1,a=this._wnafT2,c=this._wnafT3,f=0,u,d,g;for(u=0;u<n;u++){g=r[u];var m=g._getNAFPoints(e);o[u]=m.wnd,a[u]=m.points}for(u=n-1;u>=1;u-=2){var b=u-1,x=u;if(o[b]!==1||o[x]!==1){c[b]=Go(i[b],o[b],this._bitLength),c[x]=Go(i[x],o[x],this._bitLength),f=Math.max(c[b].length,f),f=Math.max(c[x].length,f);continue}var I=[r[b],null,null,r[x]];r[b].y.cmp(r[x].y)===0?(I[1]=r[b].add(r[x]),I[2]=r[b].toJ().mixedAdd(r[x].neg())):r[b].y.cmp(r[x].y.redNeg())===0?(I[1]=r[b].toJ().mixedAdd(r[x]),I[2]=r[b].add(r[x].neg())):(I[1]=r[b].toJ().mixedAdd(r[x]),I[2]=r[b].toJ().mixedAdd(r[x].neg()));var O=[-3,-1,-5,-7,0,7,5,1,3],$=b8(i[b],i[x]);for(f=Math.max($[0].length,f),c[b]=new Array(f),c[x]=new Array(f),d=0;d<f;d++){var P=$[0][d]|0,R=$[1][d]|0;c[b][d]=O[(P+1)*3+(R+1)],c[x][d]=0,a[b]=I}}var N=this.jpoint(null,null,null),B=this._wnafT4;for(u=f;u>=0;u--){for(var F=0;u>=0;){var L=!0;for(d=0;d<n;d++)B[d]=c[d][u]|0,B[d]!==0&&(L=!1);if(!L)break;F++,u--}if(u>=0&&F++,N=N.dblp(F),u<0)break;for(d=0;d<n;d++){var C=B[d];C!==0&&(C>0?g=a[d][C-1>>1]:C<0&&(g=a[d][-C-1>>1].neg()),g.type==="affine"?N=N.mixedAdd(g):N=N.add(g))}}for(u=0;u<n;u++)a[u]=null;return s?N:N.toP()};function nr(t,e){this.curve=t,this.type=e,this.precomputed=null}mi.BasePoint=nr,nr.prototype.eq=function(){throw new Error("Not implemented")},nr.prototype.validate=function(){return this.curve.validate(this)},mi.prototype.decodePoint=function(e,r){e=xs.toArray(e,r);var i=this.p.byteLength();if((e[0]===4||e[0]===6||e[0]===7)&&e.length-1===2*i){e[0]===6?Yo(e[e.length-1]%2===0):e[0]===7&&Yo(e[e.length-1]%2===1);var n=this.point(e.slice(1,1+i),e.slice(1+i,1+2*i));return n}else if((e[0]===2||e[0]===3)&&e.length-1===i)return this.pointFromX(e.slice(1,1+i),e[0]===3);throw new Error("Unknown point format")},nr.prototype.encodeCompressed=function(e){return this.encode(e,!0)},nr.prototype._encode=function(e){var r=this.curve.p.byteLength(),i=this.getX().toArray("be",r);return e?[this.getY().isEven()?2:3].concat(i):[4].concat(i,this.getY().toArray("be",r))},nr.prototype.encode=function(e,r){return xs.encode(this._encode(r),e)},nr.prototype.precompute=function(e){if(this.precomputed)return this;var r={doubles:null,naf:null,beta:null};return r.naf=this._getNAFPoints(8),r.doubles=this._getDoubles(4,e),r.beta=this._getBeta(),this.precomputed=r,this},nr.prototype._hasDoubles=function(e){if(!this.precomputed)return!1;var r=this.precomputed.doubles;return r?r.points.length>=Math.ceil((e.bitLength()+1)/r.step):!1},nr.prototype._getDoubles=function(e,r){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s<r;s+=e){for(var o=0;o<e;o++)n=n.dbl();i.push(n)}return{step:e,points:i}},nr.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var r=[this],i=(1<<e)-1,n=i===1?null:this.dbl(),s=1;s<i;s++)r[s]=r[s-1].add(n);return{wnd:e,points:r}},nr.prototype._getBeta=function(){return null},nr.prototype.dblp=function(e){for(var r=this,i=0;i<e;i++)r=r.dbl();return r};var Tn={exports:{}};typeof Object.create=="function"?Tn.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:Tn.exports=function(e,r){if(r){e.super_=r;var i=function(){};i.prototype=r.prototype,e.prototype=new i,e.prototype.constructor=e}};var y8=Yt,Ve=Or.exports,ff=Tn.exports,Cn=Zo,v8=y8.assert;function sr(t){Cn.call(this,"short",t),this.a=new Ve(t.a,16).toRed(this.red),this.b=new Ve(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}ff(sr,Cn);var m8=sr;sr.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var r,i;if(e.beta)r=new Ve(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);r=n[0].cmp(n[1])<0?n[0]:n[1],r=r.toRed(this.red)}if(e.lambda)i=new Ve(e.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(r))===0?i=s[0]:(i=s[1],v8(this.g.mul(i).x.cmp(this.g.x.redMul(r))===0))}var o;return e.basis?o=e.basis.map(function(a){return{a:new Ve(a.a,16),b:new Ve(a.b,16)}}):o=this._getEndoBasis(i),{beta:r,lambda:i,basis:o}}},sr.prototype._getEndoRoots=function(e){var r=e===this.p?this.red:Ve.mont(e),i=new Ve(2).toRed(r).redInvm(),n=i.redNeg(),s=new Ve(3).toRed(r).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),a=n.redSub(s).fromRed();return[o,a]},sr.prototype._getEndoBasis=function(e){for(var r=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new Ve(1),o=new Ve(0),a=new Ve(0),c=new Ve(1),f,u,d,g,m,b,x,I=0,O,$;i.cmpn(0)!==0;){var P=n.div(i);O=n.sub(P.mul(i)),$=a.sub(P.mul(s));var R=c.sub(P.mul(o));if(!d&&O.cmp(r)<0)f=x.neg(),u=s,d=O.neg(),g=$;else if(d&&++I===2)break;x=O,n=i,i=O,a=s,s=$,c=o,o=R}m=O.neg(),b=$;var N=d.sqr().add(g.sqr()),B=m.sqr().add(b.sqr());return B.cmp(N)>=0&&(m=f,b=u),d.negative&&(d=d.neg(),g=g.neg()),m.negative&&(m=m.neg(),b=b.neg()),[{a:d,b:g},{a:m,b}]},sr.prototype._endoSplit=function(e){var r=this.endo.basis,i=r[0],n=r[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),a=s.mul(i.a),c=o.mul(n.a),f=s.mul(i.b),u=o.mul(n.b),d=e.sub(a).sub(c),g=f.add(u).neg();return{k1:d,k2:g}},sr.prototype.pointFromX=function(e,r){e=new Ve(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(r&&!s||!r&&s)&&(n=n.redNeg()),this.point(e,n)},sr.prototype.validate=function(e){if(e.inf)return!0;var r=e.x,i=e.y,n=this.a.redMul(r),s=r.redSqr().redMul(r).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0},sr.prototype._endoWnafMulAdd=function(e,r,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o<e.length;o++){var a=this._endoSplit(r[o]),c=e[o],f=c._getBeta();a.k1.negative&&(a.k1.ineg(),c=c.neg(!0)),a.k2.negative&&(a.k2.ineg(),f=f.neg(!0)),n[o*2]=c,n[o*2+1]=f,s[o*2]=a.k1,s[o*2+1]=a.k2}for(var u=this._wnafMulAdd(1,n,s,o*2,i),d=0;d<o*2;d++)n[d]=null,s[d]=null;return u};function lt(t,e,r,i){Cn.BasePoint.call(this,t,"affine"),e===null&&r===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new Ve(e,16),this.y=new Ve(r,16),i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}ff(lt,Cn.BasePoint),sr.prototype.point=function(e,r,i){return new lt(this,e,r,i)},sr.prototype.pointFromJSON=function(e,r){return lt.fromJSON(this,e,r)},lt.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var r=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var i=this.curve,n=function(s){return i.point(s.x.redMul(i.endo.beta),s.y)};e.beta=r,r.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(n)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(n)}}}return r}},lt.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},lt.fromJSON=function(e,r,i){typeof r=="string"&&(r=JSON.parse(r));var n=e.point(r[0],r[1],i);if(!r[2])return n;function s(a){return e.point(a[0],a[1],i)}var o=r[2];return n.precomputed={beta:null,doubles:o.doubles&&{step:o.doubles.step,points:[n].concat(o.doubles.points.map(s))},naf:o.naf&&{wnd:o.naf.wnd,points:[n].concat(o.naf.points.map(s))}},n},lt.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},lt.prototype.isInfinity=function(){return this.inf},lt.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var r=this.y.redSub(e.y);r.cmpn(0)!==0&&(r=r.redMul(this.x.redSub(e.x).redInvm()));var i=r.redSqr().redISub(this.x).redISub(e.x),n=r.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)},lt.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var r=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(r).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),a=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},lt.prototype.getX=function(){return this.x.fromRed()},lt.prototype.getY=function(){return this.y.fromRed()},lt.prototype.mul=function(e){return e=new Ve(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},lt.prototype.mulAdd=function(e,r,i){var n=[this,r],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)},lt.prototype.jmulAdd=function(e,r,i){var n=[this,r],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)},lt.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)},lt.prototype.neg=function(e){if(this.inf)return this;var r=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};r.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return r},lt.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function xt(t,e,r,i){Cn.BasePoint.call(this,t,"jacobian"),e===null&&r===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new Ve(0)):(this.x=new Ve(e,16),this.y=new Ve(r,16),this.z=new Ve(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}ff(xt,Cn.BasePoint),sr.prototype.jpoint=function(e,r,i){return new xt(this,e,r,i)},xt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),r=e.redSqr(),i=this.x.redMul(r),n=this.y.redMul(r).redMul(e);return this.curve.point(i,n)},xt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},xt.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var r=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(r),s=e.x.redMul(i),o=this.y.redMul(r.redMul(e.z)),a=e.y.redMul(i.redMul(this.z)),c=n.redSub(s),f=o.redSub(a);if(c.cmpn(0)===0)return f.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var u=c.redSqr(),d=u.redMul(c),g=n.redMul(u),m=f.redSqr().redIAdd(d).redISub(g).redISub(g),b=f.redMul(g.redISub(m)).redISub(o.redMul(d)),x=this.z.redMul(e.z).redMul(c);return this.curve.jpoint(m,b,x)},xt.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var r=this.z.redSqr(),i=this.x,n=e.x.redMul(r),s=this.y,o=e.y.redMul(r).redMul(this.z),a=i.redSub(n),c=s.redSub(o);if(a.cmpn(0)===0)return c.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var f=a.redSqr(),u=f.redMul(a),d=i.redMul(f),g=c.redSqr().redIAdd(u).redISub(d).redISub(d),m=c.redMul(d.redISub(g)).redISub(s.redMul(u)),b=this.z.redMul(a);return this.curve.jpoint(g,m,b)},xt.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var r;if(this.curve.zeroA||this.curve.threeA){var i=this;for(r=0;r<e;r++)i=i.dbl();return i}var n=this.curve.a,s=this.curve.tinv,o=this.x,a=this.y,c=this.z,f=c.redSqr().redSqr(),u=a.redAdd(a);for(r=0;r<e;r++){var d=o.redSqr(),g=u.redSqr(),m=g.redSqr(),b=d.redAdd(d).redIAdd(d).redIAdd(n.redMul(f)),x=o.redMul(g),I=b.redSqr().redISub(x.redAdd(x)),O=x.redISub(I),$=b.redMul(O);$=$.redIAdd($).redISub(m);var P=u.redMul(c);r+1<e&&(f=f.redMul(m)),o=I,c=P,u=$}return this.curve.jpoint(o,u.redMul(s),c)},xt.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},xt.prototype._zeroDbl=function(){var e,r,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),a=this.x.redAdd(s).redSqr().redISub(n).redISub(o);a=a.redIAdd(a);var c=n.redAdd(n).redIAdd(n),f=c.redSqr().redISub(a).redISub(a),u=o.redIAdd(o);u=u.redIAdd(u),u=u.redIAdd(u),e=f,r=c.redMul(a.redISub(f)).redISub(u),i=this.y.redAdd(this.y)}else{var d=this.x.redSqr(),g=this.y.redSqr(),m=g.redSqr(),b=this.x.redAdd(g).redSqr().redISub(d).redISub(m);b=b.redIAdd(b);var x=d.redAdd(d).redIAdd(d),I=x.redSqr(),O=m.redIAdd(m);O=O.redIAdd(O),O=O.redIAdd(O),e=I.redISub(b).redISub(b),r=x.redMul(b.redISub(e)).redISub(O),i=this.y.redMul(this.z),i=i.redIAdd(i)}return this.curve.jpoint(e,r,i)},xt.prototype._threeDbl=function(){var e,r,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),a=this.x.redAdd(s).redSqr().redISub(n).redISub(o);a=a.redIAdd(a);var c=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),f=c.redSqr().redISub(a).redISub(a);e=f;var u=o.redIAdd(o);u=u.redIAdd(u),u=u.redIAdd(u),r=c.redMul(a.redISub(f)).redISub(u),i=this.y.redAdd(this.y)}else{var d=this.z.redSqr(),g=this.y.redSqr(),m=this.x.redMul(g),b=this.x.redSub(d).redMul(this.x.redAdd(d));b=b.redAdd(b).redIAdd(b);var x=m.redIAdd(m);x=x.redIAdd(x);var I=x.redAdd(x);e=b.redSqr().redISub(I),i=this.y.redAdd(this.z).redSqr().redISub(g).redISub(d);var O=g.redSqr();O=O.redIAdd(O),O=O.redIAdd(O),O=O.redIAdd(O),r=b.redMul(x.redISub(e)).redISub(O)}return this.curve.jpoint(e,r,i)},xt.prototype._dbl=function(){var e=this.curve.a,r=this.x,i=this.y,n=this.z,s=n.redSqr().redSqr(),o=r.redSqr(),a=i.redSqr(),c=o.redAdd(o).redIAdd(o).redIAdd(e.redMul(s)),f=r.redAdd(r);f=f.redIAdd(f);var u=f.redMul(a),d=c.redSqr().redISub(u.redAdd(u)),g=u.redISub(d),m=a.redSqr();m=m.redIAdd(m),m=m.redIAdd(m),m=m.redIAdd(m);var b=c.redMul(g).redISub(m),x=i.redAdd(i).redMul(n);return this.curve.jpoint(d,b,x)},xt.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),r=this.y.redSqr(),i=this.z.redSqr(),n=r.redSqr(),s=e.redAdd(e).redIAdd(e),o=s.redSqr(),a=this.x.redAdd(r).redSqr().redISub(e).redISub(n);a=a.redIAdd(a),a=a.redAdd(a).redIAdd(a),a=a.redISub(o);var c=a.redSqr(),f=n.redIAdd(n);f=f.redIAdd(f),f=f.redIAdd(f),f=f.redIAdd(f);var u=s.redIAdd(a).redSqr().redISub(o).redISub(c).redISub(f),d=r.redMul(u);d=d.redIAdd(d),d=d.redIAdd(d);var g=this.x.redMul(c).redISub(d);g=g.redIAdd(g),g=g.redIAdd(g);var m=this.y.redMul(u.redMul(f.redISub(u)).redISub(a.redMul(c)));m=m.redIAdd(m),m=m.redIAdd(m),m=m.redIAdd(m);var b=this.z.redAdd(a).redSqr().redISub(i).redISub(c);return this.curve.jpoint(g,m,b)},xt.prototype.mul=function(e,r){return e=new Ve(e,r),this.curve._wnafMul(this,e)},xt.prototype.eq=function(e){if(e.type==="affine")return this.eq(e.toJ());if(this===e)return!0;var r=this.z.redSqr(),i=e.z.redSqr();if(this.x.redMul(i).redISub(e.x.redMul(r)).cmpn(0)!==0)return!1;var n=r.redMul(this.z),s=i.redMul(e.z);return this.y.redMul(s).redISub(e.y.redMul(n)).cmpn(0)===0},xt.prototype.eqXToP=function(e){var r=this.z.redSqr(),i=e.toRed(this.curve.red).redMul(r);if(this.x.cmp(i)===0)return!0;for(var n=e.clone(),s=this.curve.redN.redMul(r);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}},xt.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},xt.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Nn=Or.exports,Ll=Tn.exports,Jo=Zo,w8=Yt;function Bn(t){Jo.call(this,"mont",t),this.a=new Nn(t.a,16).toRed(this.red),this.b=new Nn(t.b,16).toRed(this.red),this.i4=new Nn(4).toRed(this.red).redInvm(),this.two=new Nn(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}Ll(Bn,Jo);var _8=Bn;Bn.prototype.validate=function(e){var r=e.normalize().x,i=r.redSqr(),n=i.redMul(r).redAdd(i.redMul(this.a)).redAdd(r),s=n.redSqrt();return s.redSqr().cmp(n)===0};function pt(t,e,r){Jo.BasePoint.call(this,t,"projective"),e===null&&r===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new Nn(e,16),this.z=new Nn(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}Ll(pt,Jo.BasePoint),Bn.prototype.decodePoint=function(e,r){return this.point(w8.toArray(e,r),1)},Bn.prototype.point=function(e,r){return new pt(this,e,r)},Bn.prototype.pointFromJSON=function(e){return pt.fromJSON(this,e)},pt.prototype.precompute=function(){},pt.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},pt.fromJSON=function(e,r){return new pt(e,r[0],r[1]||e.one)},pt.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},pt.prototype.isInfinity=function(){return this.z.cmpn(0)===0},pt.prototype.dbl=function(){var e=this.x.redAdd(this.z),r=e.redSqr(),i=this.x.redSub(this.z),n=i.redSqr(),s=r.redSub(n),o=r.redMul(n),a=s.redMul(n.redAdd(this.curve.a24.redMul(s)));return this.curve.point(o,a)},pt.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},pt.prototype.diffAdd=function(e,r){var i=this.x.redAdd(this.z),n=this.x.redSub(this.z),s=e.x.redAdd(e.z),o=e.x.redSub(e.z),a=o.redMul(i),c=s.redMul(n),f=r.z.redMul(a.redAdd(c).redSqr()),u=r.x.redMul(a.redISub(c).redSqr());return this.curve.point(f,u)},pt.prototype.mul=function(e){for(var r=e.clone(),i=this,n=this.curve.point(null,null),s=this,o=[];r.cmpn(0)!==0;r.iushrn(1))o.push(r.andln(1));for(var a=o.length-1;a>=0;a--)o[a]===0?(i=i.diffAdd(n,s),n=n.dbl()):(n=i.diffAdd(n,s),i=i.dbl());return n},pt.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},pt.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},pt.prototype.eq=function(e){return this.getX().cmp(e.getX())===0},pt.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},pt.prototype.getX=function(){return this.normalize(),this.x.fromRed()};var x8=Yt,ei=Or.exports,ql=Tn.exports,Xo=Zo,E8=x8.assert;function Mr(t){this.twisted=(t.a|0)!==1,this.mOneA=this.twisted&&(t.a|0)===-1,this.extended=this.mOneA,Xo.call(this,"edwards",t),this.a=new ei(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new ei(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new ei(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),E8(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(t.c|0)===1}ql(Mr,Xo);var S8=Mr;Mr.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},Mr.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},Mr.prototype.jpoint=function(e,r,i,n){return this.point(e,r,i,n)},Mr.prototype.pointFromX=function(e,r){e=new ei(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=this.c2.redSub(this.a.redMul(i)),s=this.one.redSub(this.c2.redMul(this.d).redMul(i)),o=n.redMul(s.redInvm()),a=o.redSqrt();if(a.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");var c=a.fromRed().isOdd();return(r&&!c||!r&&c)&&(a=a.redNeg()),this.point(e,a)},Mr.prototype.pointFromY=function(e,r){e=new ei(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=i.redSub(this.c2),s=i.redMul(this.d).redMul(this.c2).redSub(this.a),o=n.redMul(s.redInvm());if(o.cmp(this.zero)===0){if(r)throw new Error("invalid point");return this.point(this.zero,e)}var a=o.redSqrt();if(a.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");return a.fromRed().isOdd()!==r&&(a=a.redNeg()),this.point(a,e)},Mr.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var r=e.x.redSqr(),i=e.y.redSqr(),n=r.redMul(this.a).redAdd(i),s=this.c2.redMul(this.one.redAdd(this.d.redMul(r).redMul(i)));return n.cmp(s)===0};function me(t,e,r,i,n){Xo.BasePoint.call(this,t,"projective"),e===null&&r===null&&i===null?(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 ei(e,16),this.y=new ei(r,16),this.z=i?new ei(i,16):this.curve.one,this.t=n&&new ei(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()))))}ql(me,Xo.BasePoint),Mr.prototype.pointFromJSON=function(e){return me.fromJSON(this,e)},Mr.prototype.point=function(e,r,i,n){return new me(this,e,r,i,n)},me.fromJSON=function(e,r){return new me(e,r[0],r[1],r[2])},me.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},me.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},me.prototype._extDbl=function(){var e=this.x.redSqr(),r=this.y.redSqr(),i=this.z.redSqr();i=i.redIAdd(i);var n=this.curve._mulA(e),s=this.x.redAdd(this.y).redSqr().redISub(e).redISub(r),o=n.redAdd(r),a=o.redSub(i),c=n.redSub(r),f=s.redMul(a),u=o.redMul(c),d=s.redMul(c),g=a.redMul(o);return this.curve.point(f,u,g,d)},me.prototype._projDbl=function(){var e=this.x.redAdd(this.y).redSqr(),r=this.x.redSqr(),i=this.y.redSqr(),n,s,o,a,c,f;if(this.curve.twisted){a=this.curve._mulA(r);var u=a.redAdd(i);this.zOne?(n=e.redSub(r).redSub(i).redMul(u.redSub(this.curve.two)),s=u.redMul(a.redSub(i)),o=u.redSqr().redSub(u).redSub(u)):(c=this.z.redSqr(),f=u.redSub(c).redISub(c),n=e.redSub(r).redISub(i).redMul(f),s=u.redMul(a.redSub(i)),o=u.redMul(f))}else a=r.redAdd(i),c=this.curve._mulC(this.z).redSqr(),f=a.redSub(c).redSub(c),n=this.curve._mulC(e.redISub(a)).redMul(f),s=this.curve._mulC(a).redMul(r.redISub(i)),o=a.redMul(f);return this.curve.point(n,s,o)},me.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},me.prototype._extAdd=function(e){var r=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),i=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),s=this.z.redMul(e.z.redAdd(e.z)),o=i.redSub(r),a=s.redSub(n),c=s.redAdd(n),f=i.redAdd(r),u=o.redMul(a),d=c.redMul(f),g=o.redMul(f),m=a.redMul(c);return this.curve.point(u,d,m,g)},me.prototype._projAdd=function(e){var r=this.z.redMul(e.z),i=r.redSqr(),n=this.x.redMul(e.x),s=this.y.redMul(e.y),o=this.curve.d.redMul(n).redMul(s),a=i.redSub(o),c=i.redAdd(o),f=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(n).redISub(s),u=r.redMul(a).redMul(f),d,g;return this.curve.twisted?(d=r.redMul(c).redMul(s.redSub(this.curve._mulA(n))),g=a.redMul(c)):(d=r.redMul(c).redMul(s.redSub(n)),g=this.curve._mulC(a).redMul(c)),this.curve.point(u,d,g)},me.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},me.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},me.prototype.mulAdd=function(e,r,i){return this.curve._wnafMulAdd(1,[this,r],[e,i],2,!1)},me.prototype.jmulAdd=function(e,r,i){return this.curve._wnafMulAdd(1,[this,r],[e,i],2,!0)},me.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},me.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},me.prototype.getX=function(){return this.normalize(),this.x.fromRed()},me.prototype.getY=function(){return this.normalize(),this.y.fromRed()},me.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0},me.prototype.eqXToP=function(e){var r=e.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(r)===0)return!0;for(var i=e.clone(),n=this.curve.redN.redMul(this.z);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(n),this.x.cmp(r)===0)return!0}},me.prototype.toP=me.prototype.normalize,me.prototype.mixedAdd=me.prototype.add,function(t){var e=t;e.base=Zo,e.short=m8,e.mont=_8,e.edwards=S8}(cf);var Qo={},ea={},ie={},I8=ji,A8=Tn.exports;ie.inherits=A8;function D8(t,e){return(t.charCodeAt(e)&64512)!==55296||e<0||e+1>=t.length?!1:(t.charCodeAt(e+1)&64512)===56320}function $8(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if(typeof t=="string")if(e){if(e==="hex")for(t=t.replace(/[^a-z0-9]+/ig,""),t.length%2!==0&&(t="0"+t),n=0;n<t.length;n+=2)r.push(parseInt(t[n]+t[n+1],16))}else for(var i=0,n=0;n<t.length;n++){var s=t.charCodeAt(n);s<128?r[i++]=s:s<2048?(r[i++]=s>>6|192,r[i++]=s&63|128):D8(t,n)?(s=65536+((s&1023)<<10)+(t.charCodeAt(++n)&1023),r[i++]=s>>18|240,r[i++]=s>>12&63|128,r[i++]=s>>6&63|128,r[i++]=s&63|128):(r[i++]=s>>12|224,r[i++]=s>>6&63|128,r[i++]=s&63|128)}else for(n=0;n<t.length;n++)r[n]=t[n]|0;return r}ie.toArray=$8;function O8(t){for(var e="",r=0;r<t.length;r++)e+=Ul(t[r].toString(16));return e}ie.toHex=O8;function zl(t){var e=t>>>24|t>>>8&65280|t<<8&16711680|(t&255)<<24;return e>>>0}ie.htonl=zl;function M8(t,e){for(var r="",i=0;i<t.length;i++){var n=t[i];e==="little"&&(n=zl(n)),r+=kl(n.toString(16))}return r}ie.toHex32=M8;function Ul(t){return t.length===1?"0"+t:t}ie.zero2=Ul;function kl(t){return t.length===7?"0"+t:t.length===6?"00"+t:t.length===5?"000"+t:t.length===4?"0000"+t:t.length===3?"00000"+t:t.length===2?"000000"+t:t.length===1?"0000000"+t:t}ie.zero8=kl;function P8(t,e,r,i){var n=r-e;I8(n%4===0);for(var s=new Array(n/4),o=0,a=e;o<s.length;o++,a+=4){var c;i==="big"?c=t[a]<<24|t[a+1]<<16|t[a+2]<<8|t[a+3]:c=t[a+3]<<24|t[a+2]<<16|t[a+1]<<8|t[a],s[o]=c>>>0}return s}ie.join32=P8;function R8(t,e){for(var r=new Array(t.length*4),i=0,n=0;i<t.length;i++,n+=4){var s=t[i];e==="big"?(r[n]=s>>>24,r[n+1]=s>>>16&255,r[n+2]=s>>>8&255,r[n+3]=s&255):(r[n+3]=s>>>24,r[n+2]=s>>>16&255,r[n+1]=s>>>8&255,r[n]=s&255)}return r}ie.split32=R8;function T8(t,e){return t>>>e|t<<32-e}ie.rotr32=T8;function C8(t,e){return t<<e|t>>>32-e}ie.rotl32=C8;function N8(t,e){return t+e>>>0}ie.sum32=N8;function B8(t,e,r){return t+e+r>>>0}ie.sum32_3=B8;function F8(t,e,r,i){return t+e+r+i>>>0}ie.sum32_4=F8;function L8(t,e,r,i,n){return t+e+r+i+n>>>0}ie.sum32_5=L8;function q8(t,e,r,i){var n=t[e],s=t[e+1],o=i+s>>>0,a=(o<i?1:0)+r+n;t[e]=a>>>0,t[e+1]=o}ie.sum64=q8;function z8(t,e,r,i){var n=e+i>>>0,s=(n<e?1:0)+t+r;return s>>>0}ie.sum64_hi=z8;function U8(t,e,r,i){var n=e+i;return n>>>0}ie.sum64_lo=U8;function k8(t,e,r,i,n,s,o,a){var c=0,f=e;f=f+i>>>0,c+=f<e?1:0,f=f+s>>>0,c+=f<s?1:0,f=f+a>>>0,c+=f<a?1:0;var u=t+r+n+o+c;return u>>>0}ie.sum64_4_hi=k8;function j8(t,e,r,i,n,s,o,a){var c=e+i+s+a;return c>>>0}ie.sum64_4_lo=j8;function K8(t,e,r,i,n,s,o,a,c,f){var u=0,d=e;d=d+i>>>0,u+=d<e?1:0,d=d+s>>>0,u+=d<s?1:0,d=d+a>>>0,u+=d<a?1:0,d=d+f>>>0,u+=d<f?1:0;var g=t+r+n+o+c+u;return g>>>0}ie.sum64_5_hi=K8;function V8(t,e,r,i,n,s,o,a,c,f){var u=e+i+s+a+f;return u>>>0}ie.sum64_5_lo=V8;function H8(t,e,r){var i=e<<32-r|t>>>r;return i>>>0}ie.rotr64_hi=H8;function W8(t,e,r){var i=t<<32-r|e>>>r;return i>>>0}ie.rotr64_lo=W8;function G8(t,e,r){return t>>>r}ie.shr64_hi=G8;function Y8(t,e,r){var i=t<<32-r|e>>>r;return i>>>0}ie.shr64_lo=Y8;var Fn={},jl=ie,Z8=ji;function ta(){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}Fn.BlockHash=ta,ta.prototype.update=function(e,r){if(e=jl.toArray(e,r),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var i=e.length%this._delta8;this.pending=e.slice(e.length-i,e.length),this.pending.length===0&&(this.pending=null),e=jl.join32(e,0,e.length-i,this.endian);for(var n=0;n<e.length;n+=this._delta32)this._update(e,n,n+this._delta32)}return this},ta.prototype.digest=function(e){return this.update(this._pad()),Z8(this.pending===null),this._digest(e)},ta.prototype._pad=function(){var e=this.pendingTotal,r=this._delta8,i=r-(e+this.padLength)%r,n=new Array(i+this.padLength);n[0]=128;for(var s=1;s<i;s++)n[s]=0;if(e<<=3,this.endian==="big"){for(var o=8;o<this.padLength;o++)n[s++]=0;n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=e>>>24&255,n[s++]=e>>>16&255,n[s++]=e>>>8&255,n[s++]=e&255}else for(n[s++]=e&255,n[s++]=e>>>8&255,n[s++]=e>>>16&255,n[s++]=e>>>24&255,n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=0,o=8;o<this.padLength;o++)n[s++]=0;return n};var Ln={},Pr={},J8=ie,Rr=J8.rotr32;function X8(t,e,r,i){if(t===0)return Kl(e,r,i);if(t===1||t===3)return Hl(e,r,i);if(t===2)return Vl(e,r,i)}Pr.ft_1=X8;function Kl(t,e,r){return t&e^~t&r}Pr.ch32=Kl;function Vl(t,e,r){return t&e^t&r^e&r}Pr.maj32=Vl;function Hl(t,e,r){return t^e^r}Pr.p32=Hl;function Q8(t){return Rr(t,2)^Rr(t,13)^Rr(t,22)}Pr.s0_256=Q8;function e4(t){return Rr(t,6)^Rr(t,11)^Rr(t,25)}Pr.s1_256=e4;function t4(t){return Rr(t,7)^Rr(t,18)^t>>>3}Pr.g0_256=t4;function r4(t){return Rr(t,17)^Rr(t,19)^t>>>10}Pr.g1_256=r4;var qn=ie,i4=Fn,n4=Pr,uf=qn.rotl32,Es=qn.sum32,s4=qn.sum32_5,o4=n4.ft_1,Wl=i4.BlockHash,a4=[1518500249,1859775393,2400959708,3395469782];function Tr(){if(!(this instanceof Tr))return new Tr;Wl.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}qn.inherits(Tr,Wl);var c4=Tr;Tr.blockSize=512,Tr.outSize=160,Tr.hmacStrength=80,Tr.padLength=64,Tr.prototype._update=function(e,r){for(var i=this.W,n=0;n<16;n++)i[n]=e[r+n];for(;n<i.length;n++)i[n]=uf(i[n-3]^i[n-8]^i[n-14]^i[n-16],1);var s=this.h[0],o=this.h[1],a=this.h[2],c=this.h[3],f=this.h[4];for(n=0;n<i.length;n++){var u=~~(n/20),d=s4(uf(s,5),o4(u,o,a,c),f,i[n],a4[u]);f=c,c=a,a=uf(o,30),o=s,s=d}this.h[0]=Es(this.h[0],s),this.h[1]=Es(this.h[1],o),this.h[2]=Es(this.h[2],a),this.h[3]=Es(this.h[3],c),this.h[4]=Es(this.h[4],f)},Tr.prototype._digest=function(e){return e==="hex"?qn.toHex32(this.h,"big"):qn.split32(this.h,"big")};var zn=ie,f4=Fn,Un=Pr,u4=ji,gr=zn.sum32,h4=zn.sum32_4,d4=zn.sum32_5,l4=Un.ch32,p4=Un.maj32,g4=Un.s0_256,b4=Un.s1_256,y4=Un.g0_256,v4=Un.g1_256,Gl=f4.BlockHash,m4=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function Cr(){if(!(this instanceof Cr))return new Cr;Gl.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=m4,this.W=new Array(64)}zn.inherits(Cr,Gl);var Yl=Cr;Cr.blockSize=512,Cr.outSize=256,Cr.hmacStrength=192,Cr.padLength=64,Cr.prototype._update=function(e,r){for(var i=this.W,n=0;n<16;n++)i[n]=e[r+n];for(;n<i.length;n++)i[n]=h4(v4(i[n-2]),i[n-7],y4(i[n-15]),i[n-16]);var s=this.h[0],o=this.h[1],a=this.h[2],c=this.h[3],f=this.h[4],u=this.h[5],d=this.h[6],g=this.h[7];for(u4(this.k.length===i.length),n=0;n<i.length;n++){var m=d4(g,b4(f),l4(f,u,d),this.k[n],i[n]),b=gr(g4(s),p4(s,o,a));g=d,d=u,u=f,f=gr(c,m),c=a,a=o,o=s,s=gr(m,b)}this.h[0]=gr(this.h[0],s),this.h[1]=gr(this.h[1],o),this.h[2]=gr(this.h[2],a),this.h[3]=gr(this.h[3],c),this.h[4]=gr(this.h[4],f),this.h[5]=gr(this.h[5],u),this.h[6]=gr(this.h[6],d),this.h[7]=gr(this.h[7],g)},Cr.prototype._digest=function(e){return e==="hex"?zn.toHex32(this.h,"big"):zn.split32(this.h,"big")};var hf=ie,Zl=Yl;function ti(){if(!(this instanceof ti))return new ti;Zl.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}hf.inherits(ti,Zl);var w4=ti;ti.blockSize=512,ti.outSize=224,ti.hmacStrength=192,ti.padLength=64,ti.prototype._digest=function(e){return e==="hex"?hf.toHex32(this.h.slice(0,7),"big"):hf.split32(this.h.slice(0,7),"big")};var Kt=ie,_4=Fn,x4=ji,Nr=Kt.rotr64_hi,Br=Kt.rotr64_lo,Jl=Kt.shr64_hi,Xl=Kt.shr64_lo,wi=Kt.sum64,df=Kt.sum64_hi,lf=Kt.sum64_lo,E4=Kt.sum64_4_hi,S4=Kt.sum64_4_lo,I4=Kt.sum64_5_hi,A4=Kt.sum64_5_lo,Ql=_4.BlockHash,D4=[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];function br(){if(!(this instanceof br))return new br;Ql.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=D4,this.W=new Array(160)}Kt.inherits(br,Ql);var e0=br;br.blockSize=1024,br.outSize=512,br.hmacStrength=192,br.padLength=128,br.prototype._prepareBlock=function(e,r){for(var i=this.W,n=0;n<32;n++)i[n]=e[r+n];for(;n<i.length;n+=2){var s=L4(i[n-4],i[n-3]),o=q4(i[n-4],i[n-3]),a=i[n-14],c=i[n-13],f=B4(i[n-30],i[n-29]),u=F4(i[n-30],i[n-29]),d=i[n-32],g=i[n-31];i[n]=E4(s,o,a,c,f,u,d,g),i[n+1]=S4(s,o,a,c,f,u,d,g)}},br.prototype._update=function(e,r){this._prepareBlock(e,r);var i=this.W,n=this.h[0],s=this.h[1],o=this.h[2],a=this.h[3],c=this.h[4],f=this.h[5],u=this.h[6],d=this.h[7],g=this.h[8],m=this.h[9],b=this.h[10],x=this.h[11],I=this.h[12],O=this.h[13],$=this.h[14],P=this.h[15];x4(this.k.length===i.length);for(var R=0;R<i.length;R+=2){var N=$,B=P,F=C4(g,m),L=N4(g,m),C=$4(g,m,b,x,I),W=O4(g,m,b,x,I,O),A=this.k[R],h=this.k[R+1],p=i[R],v=i[R+1],y=I4(N,B,F,L,C,W,A,h,p,v),w=A4(N,B,F,L,C,W,A,h,p,v);N=R4(n,s),B=T4(n,s),F=M4(n,s,o,a,c),L=P4(n,s,o,a,c,f);var S=df(N,B,F,L),D=lf(N,B,F,L);$=I,P=O,I=b,O=x,b=g,x=m,g=df(u,d,y,w),m=lf(d,d,y,w),u=c,d=f,c=o,f=a,o=n,a=s,n=df(y,w,S,D),s=lf(y,w,S,D)}wi(this.h,0,n,s),wi(this.h,2,o,a),wi(this.h,4,c,f),wi(this.h,6,u,d),wi(this.h,8,g,m),wi(this.h,10,b,x),wi(this.h,12,I,O),wi(this.h,14,$,P)},br.prototype._digest=function(e){return e==="hex"?Kt.toHex32(this.h,"big"):Kt.split32(this.h,"big")};function $4(t,e,r,i,n){var s=t&r^~t&n;return s<0&&(s+=4294967296),s}function O4(t,e,r,i,n,s){var o=e&i^~e&s;return o<0&&(o+=4294967296),o}function M4(t,e,r,i,n){var s=t&r^t&n^r&n;return s<0&&(s+=4294967296),s}function P4(t,e,r,i,n,s){var o=e&i^e&s^i&s;return o<0&&(o+=4294967296),o}function R4(t,e){var r=Nr(t,e,28),i=Nr(e,t,2),n=Nr(e,t,7),s=r^i^n;return s<0&&(s+=4294967296),s}function T4(t,e){var r=Br(t,e,28),i=Br(e,t,2),n=Br(e,t,7),s=r^i^n;return s<0&&(s+=4294967296),s}function C4(t,e){var r=Nr(t,e,14),i=Nr(t,e,18),n=Nr(e,t,9),s=r^i^n;return s<0&&(s+=4294967296),s}function N4(t,e){var r=Br(t,e,14),i=Br(t,e,18),n=Br(e,t,9),s=r^i^n;return s<0&&(s+=4294967296),s}function B4(t,e){var r=Nr(t,e,1),i=Nr(t,e,8),n=Jl(t,e,7),s=r^i^n;return s<0&&(s+=4294967296),s}function F4(t,e){var r=Br(t,e,1),i=Br(t,e,8),n=Xl(t,e,7),s=r^i^n;return s<0&&(s+=4294967296),s}function L4(t,e){var r=Nr(t,e,19),i=Nr(e,t,29),n=Jl(t,e,6),s=r^i^n;return s<0&&(s+=4294967296),s}function q4(t,e){var r=Br(t,e,19),i=Br(e,t,29),n=Xl(t,e,6),s=r^i^n;return s<0&&(s+=4294967296),s}var pf=ie,t0=e0;function ri(){if(!(this instanceof ri))return new ri;t0.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}pf.inherits(ri,t0);var z4=ri;ri.blockSize=1024,ri.outSize=384,ri.hmacStrength=192,ri.padLength=128,ri.prototype._digest=function(e){return e==="hex"?pf.toHex32(this.h.slice(0,12),"big"):pf.split32(this.h.slice(0,12),"big")},Ln.sha1=c4,Ln.sha224=w4,Ln.sha256=Yl,Ln.sha384=z4,Ln.sha512=e0;var r0={},Vi=ie,U4=Fn,ra=Vi.rotl32,i0=Vi.sum32,Ss=Vi.sum32_3,n0=Vi.sum32_4,s0=U4.BlockHash;function Fr(){if(!(this instanceof Fr))return new Fr;s0.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}Vi.inherits(Fr,s0),r0.ripemd160=Fr,Fr.blockSize=512,Fr.outSize=160,Fr.hmacStrength=192,Fr.padLength=64,Fr.prototype._update=function(e,r){for(var i=this.h[0],n=this.h[1],s=this.h[2],o=this.h[3],a=this.h[4],c=i,f=n,u=s,d=o,g=a,m=0;m<80;m++){var b=i0(ra(n0(i,o0(m,n,s,o),e[K4[m]+r],k4(m)),H4[m]),a);i=a,a=o,o=ra(s,10),s=n,n=b,b=i0(ra(n0(c,o0(79-m,f,u,d),e[V4[m]+r],j4(m)),W4[m]),g),c=g,g=d,d=ra(u,10),u=f,f=b}b=Ss(this.h[1],s,d),this.h[1]=Ss(this.h[2],o,g),this.h[2]=Ss(this.h[3],a,c),this.h[3]=Ss(this.h[4],i,f),this.h[4]=Ss(this.h[0],n,u),this.h[0]=b},Fr.prototype._digest=function(e){return e==="hex"?Vi.toHex32(this.h,"little"):Vi.split32(this.h,"little")};function o0(t,e,r,i){return t<=15?e^r^i:t<=31?e&r|~e&i:t<=47?(e|~r)^i:t<=63?e&i|r&~i:e^(r|~i)}function k4(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function j4(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}var K4=[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],V4=[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],H4=[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],W4=[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],G4=ie,Y4=ji;function kn(t,e,r){if(!(this instanceof kn))return new kn(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(G4.toArray(e,r))}var Z4=kn;kn.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),Y4(e.length<=this.blockSize);for(var r=e.length;r<this.blockSize;r++)e.push(0);for(r=0;r<e.length;r++)e[r]^=54;for(this.inner=new this.Hash().update(e),r=0;r<e.length;r++)e[r]^=106;this.outer=new this.Hash().update(e)},kn.prototype.update=function(e,r){return this.inner.update(e,r),this},kn.prototype.digest=function(e){return this.outer.update(this.inner.digest()),this.outer.digest(e)},function(t){var e=t;e.utils=ie,e.common=Fn,e.sha=Ln,e.ripemd=r0,e.hmac=Z4,e.sha1=e.sha.sha1,e.sha256=e.sha.sha256,e.sha224=e.sha.sha224,e.sha384=e.sha.sha384,e.sha512=e.sha.sha512,e.ripemd160=e.ripemd.ripemd160}(ea);var gf,a0;function J4(){return a0||(a0=1,gf={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}),gf}(function(t){var e=t,r=ea,i=cf,n=Yt,s=n.assert;function o(f){f.type==="short"?this.curve=new i.short(f):f.type==="edwards"?this.curve=new i.edwards(f):this.curve=new i.mont(f),this.g=this.curve.g,this.n=this.curve.n,this.hash=f.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}e.PresetCurve=o;function a(f,u){Object.defineProperty(e,f,{configurable:!0,enumerable:!0,get:function(){var d=new o(u);return Object.defineProperty(e,f,{configurable:!0,enumerable:!0,value:d}),d}})}a("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:r.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),a("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:r.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),a("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:r.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),a("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:r.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),a("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:r.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),a("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:r.sha256,gRed:!1,g:["9"]}),a("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:r.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var c;try{c=J4()}catch{c=void 0}a("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:r.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",c]})})(Qo);var X4=ea,Hi=of,c0=ji;function _i(t){if(!(this instanceof _i))return new _i(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Hi.toArray(t.entropy,t.entropyEnc||"hex"),r=Hi.toArray(t.nonce,t.nonceEnc||"hex"),i=Hi.toArray(t.pers,t.persEnc||"hex");c0(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,i)}var Q4=_i;_i.prototype._init=function(e,r,i){var n=e.concat(r).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s<this.V.length;s++)this.K[s]=0,this.V[s]=1;this._update(n),this._reseed=1,this.reseedInterval=281474976710656},_i.prototype._hmac=function(){return new X4.hmac(this.hash,this.K)},_i.prototype._update=function(e){var r=this._hmac().update(this.V).update([0]);e&&(r=r.update(e)),this.K=r.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())},_i.prototype.reseed=function(e,r,i,n){typeof r!="string"&&(n=i,i=r,r=null),e=Hi.toArray(e,r),i=Hi.toArray(i,n),c0(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1},_i.prototype.generate=function(e,r,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof r!="string"&&(n=i,i=r,r=null),i&&(i=Hi.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length<e;)this.V=this._hmac().update(this.V).digest(),s=s.concat(this.V);var o=s.slice(0,e);return this._update(i),this._reseed++,Hi.encode(o,r)};var e5=Or.exports,t5=Yt,bf=t5.assert;function Rt(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var r5=Rt;Rt.fromPublic=function(e,r,i){return r instanceof Rt?r:new Rt(e,{pub:r,pubEnc:i})},Rt.fromPrivate=function(e,r,i){return r instanceof Rt?r:new Rt(e,{priv:r,privEnc:i})},Rt.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},Rt.prototype.getPublic=function(e,r){return typeof e=="string"&&(r=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),r?this.pub.encode(r,e):this.pub},Rt.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv},Rt.prototype._importPrivate=function(e,r){this.priv=new e5(e,r||16),this.priv=this.priv.umod(this.ec.curve.n)},Rt.prototype._importPublic=function(e,r){if(e.x||e.y){this.ec.curve.type==="mont"?bf(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&bf(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,r)},Rt.prototype.derive=function(e){return e.validate()||bf(e.validate(),"public point not validated"),e.mul(this.priv).getX()},Rt.prototype.sign=function(e,r,i){return this.ec.sign(e,this,r,i)},Rt.prototype.verify=function(e,r,i){return this.ec.verify(e,r,this,void 0,i)},Rt.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var ia=Or.exports,yf=Yt,i5=yf.assert;function na(t,e){if(t instanceof na)return t;this._importDER(t,e)||(i5(t.r&&t.s,"Signature without r or s"),this.r=new ia(t.r,16),this.s=new ia(t.s,16),t.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var n5=na;function s5(){this.place=0}function vf(t,e){var r=t[e.place++];if(!(r&128))return r;var i=r&15;if(i===0||i>4||t[e.place]===0)return!1;for(var n=0,s=0,o=e.place;s<i;s++,o++)n<<=8,n|=t[o],n>>>=0;return n<=127?!1:(e.place=o,n)}function f0(t){for(var e=0,r=t.length-1;!t[e]&&!(t[e+1]&128)&&e<r;)e++;return e===0?t:t.slice(e)}na.prototype._importDER=function(e,r){e=yf.toArray(e,r);var i=new s5;if(e[i.place++]!==48)return!1;var n=vf(e,i);if(n===!1||n+i.place!==e.length||e[i.place++]!==2)return!1;var s=vf(e,i);if(s===!1||e[i.place]&128)return!1;var o=e.slice(i.place,s+i.place);if(i.place+=s,e[i.place++]!==2)return!1;var a=vf(e,i);if(a===!1||e.length!==a+i.place||e[i.place]&128)return!1;var c=e.slice(i.place,a+i.place);if(o[0]===0)if(o[1]&128)o=o.slice(1);else return!1;if(c[0]===0)if(c[1]&128)c=c.slice(1);else return!1;return this.r=new ia(o),this.s=new ia(c),this.recoveryParam=null,!0};function mf(t,e){if(e<128){t.push(e);return}var r=1+(Math.log(e)/Math.LN2>>>3);for(t.push(r|128);--r;)t.push(e>>>(r<<3)&255);t.push(e)}na.prototype.toDER=function(e){var r=this.r.toArray(),i=this.s.toArray();for(r[0]&128&&(r=[0].concat(r)),i[0]&128&&(i=[0].concat(i)),r=f0(r),i=f0(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];mf(n,r.length),n=n.concat(r),n.push(2),mf(n,i.length);var s=n.concat(i),o=[48];return mf(o,s.length),o=o.concat(s),yf.encode(o,e)};var yr=Or.exports,u0=Q4,o5=Yt,wf=Qo,a5=Wo.exports,Wi=o5.assert,_f=r5,sa=n5;function or(t){if(!(this instanceof or))return new or(t);typeof t=="string"&&(Wi(Object.prototype.hasOwnProperty.call(wf,t),"Unknown curve "+t),t=wf[t]),t instanceof wf.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}var c5=or;or.prototype.keyPair=function(e){return new _f(this,e)},or.prototype.keyFromPrivate=function(e,r){return _f.fromPrivate(this,e,r)},or.prototype.keyFromPublic=function(e,r){return _f.fromPublic(this,e,r)},or.prototype.genKeyPair=function(e){e||(e={});for(var r=new u0({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||a5(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new yr(2));;){var s=new yr(r.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}},or.prototype._truncateToN=function(e,r,i){var n;if(yr.isBN(e)||typeof e=="number")e=new yr(e,16),n=e.byteLength();else if(typeof e=="object")n=e.length,e=new yr(e,16);else{var s=e.toString();n=s.length+1>>>1,e=new yr(s,16)}typeof i!="number"&&(i=n*8);var o=i-this.n.bitLength();return o>0&&(e=e.ushrn(o)),!r&&e.cmp(this.n)>=0?e.sub(this.n):e},or.prototype.sign=function(e,r,i,n){if(typeof i=="object"&&(n=i,i=null),n||(n={}),typeof e!="string"&&typeof e!="number"&&!yr.isBN(e)){Wi(typeof e=="object"&&e&&typeof e.length=="number","Expected message to be an array-like, a hex string, or a BN instance"),Wi(e.length>>>0===e.length);for(var s=0;s<e.length;s++)Wi((e[s]&255)===e[s])}r=this.keyFromPrivate(r,i),e=this._truncateToN(e,!1,n.msgBitLength),Wi(!e.isNeg(),"Can not sign a negative message");var o=this.n.byteLength(),a=r.getPrivate().toArray("be",o),c=e.toArray("be",o);Wi(new yr(c).eq(e),"Can not sign message");for(var f=new u0({hash:this.hash,entropy:a,nonce:c,pers:n.pers,persEnc:n.persEnc||"utf8"}),u=this.n.sub(new yr(1)),d=0;;d++){var g=n.k?n.k(d):new yr(f.generate(this.n.byteLength()));if(g=this._truncateToN(g,!0),!(g.cmpn(1)<=0||g.cmp(u)>=0)){var m=this.g.mul(g);if(!m.isInfinity()){var b=m.getX(),x=b.umod(this.n);if(x.cmpn(0)!==0){var I=g.invm(this.n).mul(x.mul(r.getPrivate()).iadd(e));if(I=I.umod(this.n),I.cmpn(0)!==0){var O=(m.getY().isOdd()?1:0)|(b.cmp(x)!==0?2:0);return n.canonical&&I.cmp(this.nh)>0&&(I=this.n.sub(I),O^=1),new sa({r:x,s:I,recoveryParam:O})}}}}}},or.prototype.verify=function(e,r,i,n,s){s||(s={}),e=this._truncateToN(e,!1,s.msgBitLength),i=this.keyFromPublic(i,n),r=new sa(r,"hex");var o=r.r,a=r.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0||a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var c=a.invm(this.n),f=c.mul(e).umod(this.n),u=c.mul(o).umod(this.n),d;return this.curve._maxwellTrick?(d=this.g.jmulAdd(f,i.getPublic(),u),d.isInfinity()?!1:d.eqXToP(o)):(d=this.g.mulAdd(f,i.getPublic(),u),d.isInfinity()?!1:d.getX().umod(this.n).cmp(o)===0)},or.prototype.recoverPubKey=function(t,e,r,i){Wi((3&r)===r,"The recovery param is more than two bits"),e=new sa(e,i);var n=this.n,s=new yr(t),o=e.r,a=e.s,c=r&1,f=r>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&f)throw new Error("Unable to find sencond key candinate");f?o=this.curve.pointFromX(o.add(this.curve.n),c):o=this.curve.pointFromX(o,c);var u=e.r.invm(n),d=n.sub(s).mul(u).umod(n),g=a.mul(u).umod(n);return this.g.mulAdd(d,o,g)},or.prototype.getKeyRecoveryParam=function(t,e,r,i){if(e=new sa(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(t,e,n)}catch{continue}if(s.eq(r))return n}throw new Error("Unable to find valid recovery factor")};var Is=Yt,h0=Is.assert,d0=Is.parseBytes,jn=Is.cachedProperty;function gt(t,e){this.eddsa=t,this._secret=d0(e.secret),t.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=d0(e.pub)}gt.fromPublic=function(e,r){return r instanceof gt?r:new gt(e,{pub:r})},gt.fromSecret=function(e,r){return r instanceof gt?r:new gt(e,{secret:r})},gt.prototype.secret=function(){return this._secret},jn(gt,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),jn(gt,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),jn(gt,"privBytes",function(){var e=this.eddsa,r=this.hash(),i=e.encodingLength-1,n=r.slice(0,e.encodingLength);return n[0]&=248,n[i]&=127,n[i]|=64,n}),jn(gt,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),jn(gt,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),jn(gt,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),gt.prototype.sign=function(e){return h0(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)},gt.prototype.verify=function(e,r){return this.eddsa.verify(e,r,this)},gt.prototype.getSecret=function(e){return h0(this._secret,"KeyPair is public only"),Is.encode(this.secret(),e)},gt.prototype.getPublic=function(e){return Is.encode(this.pubBytes(),e)};var f5=gt,u5=Or.exports,oa=Yt,l0=oa.assert,aa=oa.cachedProperty,h5=oa.parseBytes;function Gi(t,e){this.eddsa=t,typeof e!="object"&&(e=h5(e)),Array.isArray(e)&&(l0(e.length===t.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,t.encodingLength),S:e.slice(t.encodingLength)}),l0(e.R&&e.S,"Signature without R or S"),t.isPoint(e.R)&&(this._R=e.R),e.S instanceof u5&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}aa(Gi,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),aa(Gi,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),aa(Gi,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),aa(Gi,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),Gi.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},Gi.prototype.toHex=function(){return oa.encode(this.toBytes(),"hex").toUpperCase()};var d5=Gi,l5=ea,p5=Qo,Kn=Yt,g5=Kn.assert,p0=Kn.parseBytes,g0=f5,b0=d5;function Vt(t){if(g5(t==="ed25519","only tested with ed25519 so far"),!(this instanceof Vt))return new Vt(t);t=p5[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=l5.sha512}var b5=Vt;Vt.prototype.sign=function(e,r){e=p0(e);var i=this.keyFromSecret(r),n=this.hashInt(i.messagePrefix(),e),s=this.g.mul(n),o=this.encodePoint(s),a=this.hashInt(o,i.pubBytes(),e).mul(i.priv()),c=n.add(a).umod(this.curve.n);return this.makeSignature({R:s,S:c,Rencoded:o})},Vt.prototype.verify=function(e,r,i){if(e=p0(e),r=this.makeSignature(r),r.S().gte(r.eddsa.curve.n)||r.S().isNeg())return!1;var n=this.keyFromPublic(i),s=this.hashInt(r.Rencoded(),n.pubBytes(),e),o=this.g.mul(r.S()),a=r.R().add(n.pub().mul(s));return a.eq(o)},Vt.prototype.hashInt=function(){for(var e=this.hash(),r=0;r<arguments.length;r++)e.update(arguments[r]);return Kn.intFromLE(e.digest()).umod(this.curve.n)},Vt.prototype.keyFromPublic=function(e){return g0.fromPublic(this,e)},Vt.prototype.keyFromSecret=function(e){return g0.fromSecret(this,e)},Vt.prototype.makeSignature=function(e){return e instanceof b0?e:new b0(this,e)},Vt.prototype.encodePoint=function(e){var r=e.getY().toArray("le",this.encodingLength);return r[this.encodingLength-1]|=e.getX().isOdd()?128:0,r},Vt.prototype.decodePoint=function(e){e=Kn.parseBytes(e);var r=e.length-1,i=e.slice(0,r).concat(e[r]&-129),n=(e[r]&128)!==0,s=Kn.intFromLE(i);return this.curve.pointFromY(s,n)},Vt.prototype.encodeInt=function(e){return e.toArray("le",this.encodingLength)},Vt.prototype.decodeInt=function(e){return Kn.intFromLE(e)},Vt.prototype.isPoint=function(e){return e instanceof this.pointClass},function(t){var e=t;e.version=l8.version,e.utils=Yt,e.rand=Wo.exports,e.curve=cf,e.curves=Qo,e.ec=c5,e.eddsa=b5}(Cl);const y5={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}},v5=":";function ca(t){const[e,r]=t.split(v5);return{namespace:e,reference:r}}function y0(t,e){return t.includes(":")?[t]:e.chains||[]}const m5="ReactNative",Zt={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},w5="js";function fa(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function xi(){return!ds()&&!!Ec()&&navigator.product===m5}function _5(){return xi()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="android"}function x5(){return xi()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="ios"}function As(){return!fa()&&!!Ec()&&!!ds()}function Ds(){return xi()?Zt.reactNative:fa()?Zt.node:As()?Zt.browser:Zt.unknown}function v0(){var t;try{return xi()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(t=global.Application)==null?void 0:t.applicationId:void 0}catch{return}}function E5(t,e){const r=new URLSearchParams(t);for(const i of Object.keys(e).sort())if(e.hasOwnProperty(i)){const n=e[i];n!==void 0&&r.set(i,n)}return r.toString()}function m0(){return ad()||{name:"",description:"",url:"",icons:[""]}}function S5(){if(Ds()===Zt.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){const{OS:r,Version:i}=global.Platform;return[r,i].join("-")}const t=Qv();if(t===null)return"unknown";const e=t.os?t.os.replace(" ","").toLowerCase():"unknown";return t.type==="browser"?[e,t.name,t.version].join("-"):[e,t.version].join("-")}function I5(){var t;const e=Ds();return e===Zt.browser?[e,((t=od())==null?void 0:t.host)||"unknown"].join(":"):e}function w0(t,e,r){const i=S5(),n=I5();return[[t,e].join("-"),[w5,r].join("-"),i,n].join("/")}function A5({protocol:t,version:e,relayUrl:r,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:a,packageName:c}){const f=r.split("?"),u=w0(t,e,i),d={auth:n,ua:u,projectId:s,useOnCloseEvent:o||void 0,packageName:c||void 0,bundleId:a||void 0},g=E5(f[1]||"",d);return f[0]+"?"+g}function Yi(t,e){return t.filter(r=>e.includes(r)).length===t.length}function xf(t){return Object.fromEntries(t.entries())}function Ef(t){return new Map(Object.entries(t))}function Zi(t=V.FIVE_MINUTES,e){const r=V.toMiliseconds(t||V.FIVE_MINUTES);let i,n,s,o;return{resolve:a=>{s&&i&&(clearTimeout(s),i(a),o=Promise.resolve(a))},reject:a=>{s&&n&&(clearTimeout(s),n(a))},done:()=>new Promise((a,c)=>{if(o)return a(o);s=setTimeout(()=>{const f=new Error(e);o=Promise.reject(f),c(f)},r),i=a,n=c})}}function Ei(t,e,r){return new Promise(async(i,n)=>{const s=setTimeout(()=>n(new Error(r)),e);try{const o=await t;i(o)}catch(o){n(o)}clearTimeout(s)})}function _0(t,e){if(typeof e=="string"&&e.startsWith(`${t}:`))return e;if(t.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(t.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${t}`)}function D5(t){return _0("topic",t)}function $5(t){return _0("id",t)}function x0(t){const[e,r]=t.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof r=="string")i.topic=r;else if(e==="id"&&Number.isInteger(Number(r)))i.id=Number(r);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${r}`);return i}function at(t,e){return V.fromMiliseconds((e||Date.now())+V.toMiliseconds(t))}function Si(t){return Date.now()>=V.toMiliseconds(t)}function ue(t,e){return`${t}${e?`:${e}`:""}`}function O5(t=[],e=[]){return[...new Set([...t,...e])]}async function M5({id:t,topic:e,wcDeepLink:r}){var i;try{if(!r)return;const n=typeof r=="string"?JSON.parse(r):r,s=n?.href;if(typeof s!="string")return;const o=P5(s,t,e),a=Ds();if(a===Zt.browser){if(!((i=ds())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}R5(o)}else a===Zt.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(n){console.error(n)}}function P5(t,e,r){const i=`requestId=${e}&sessionTopic=${r}`;t.endsWith("/")&&(t=t.slice(0,-1));let n=`${t}`;if(t.startsWith("https://t.me")){const s=t.includes("?")?"&startapp=":"?startapp=";n=`${n}${s}${B5(i,!0)}`}else n=`${n}/wc?${i}`;return n}function R5(t){let e="_self";N5()?e="_top":(C5()||t.startsWith("https://")||t.startsWith("http://"))&&(e="_blank"),window.open(t,e,"noreferrer noopener")}async function T5(t,e){let r="";try{if(As()&&(r=localStorage.getItem(e),r))return r;r=await t.getItem(e)}catch(i){console.error(i)}return r}function E0(t,e){if(!t.includes(e))return null;const r=t.split(/([&,?,=])/),i=r.indexOf(e);return r[i+2]}function S0(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function Sf(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function C5(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function N5(){try{return window.self!==window.top}catch{return!1}}function B5(t,e=!1){const r=Buffer.from(t).toString("base64");return e?r.replace(/[=]/g,""):r}function I0(t){return Buffer.from(t,"base64").toString("utf-8")}function F5(t){return new Promise(e=>setTimeout(e,t))}function $s(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function L5(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ua(t,...e){if(!L5(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function If(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");$s(t.outputLen),$s(t.blockLen)}function Vn(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function A0(t,e){ua(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const ha=BigInt(2**32-1),D0=BigInt(32);function q5(t,e=!1){return e?{h:Number(t&ha),l:Number(t>>D0&ha)}:{h:Number(t>>D0&ha)|0,l:Number(t&ha)|0}}function z5(t,e=!1){let r=new Uint32Array(t.length),i=new Uint32Array(t.length);for(let n=0;n<t.length;n++){const{h:s,l:o}=q5(t[n],e);[r[n],i[n]]=[s,o]}return[r,i]}const U5=(t,e,r)=>t<<r|e>>>32-r,k5=(t,e,r)=>e<<r|t>>>32-r,j5=(t,e,r)=>e<<r-32|t>>>64-r,K5=(t,e,r)=>t<<r-32|e>>>64-r,Hn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function V5(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Af(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Lr(t,e){return t<<32-e|t>>>e}const $0=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function H5(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function O0(t){for(let e=0;e<t.length;e++)t[e]=H5(t[e])}function W5(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function Wn(t){return typeof t=="string"&&(t=W5(t)),ua(t),t}class Df{clone(){return this._cloneInto()}}function M0(t){const e=i=>t().update(Wn(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Os(t=32){if(Hn&&typeof Hn.getRandomValues=="function")return Hn.getRandomValues(new Uint8Array(t));if(Hn&&typeof Hn.randomBytes=="function")return Hn.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const P0=[],R0=[],T0=[],G5=BigInt(0),Ms=BigInt(1),Y5=BigInt(2),Z5=BigInt(7),J5=BigInt(256),X5=BigInt(113);for(let t=0,e=Ms,r=1,i=0;t<24;t++){[r,i]=[i,(2*r+3*i)%5],P0.push(2*(5*i+r)),R0.push((t+1)*(t+2)/2%64);let n=G5;for(let s=0;s<7;s++)e=(e<<Ms^(e>>Z5)*X5)%J5,e&Y5&&(n^=Ms<<(Ms<<BigInt(s))-Ms);T0.push(n)}const[Q5,e9]=z5(T0,!0),C0=(t,e,r)=>r>32?j5(t,e,r):U5(t,e,r),N0=(t,e,r)=>r>32?K5(t,e,r):k5(t,e,r);function t9(t,e=24){const r=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)r[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,f=r[c],u=r[c+1],d=C0(f,u,1)^r[a],g=N0(f,u,1)^r[a+1];for(let m=0;m<50;m+=10)t[o+m]^=d,t[o+m+1]^=g}let n=t[2],s=t[3];for(let o=0;o<24;o++){const a=R0[o],c=C0(n,s,a),f=N0(n,s,a),u=P0[o];n=t[u],s=t[u+1],t[u]=c,t[u+1]=f}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)r[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~r[(a+2)%10]&r[(a+4)%10]}t[0]^=Q5[i],t[1]^=e9[i]}r.fill(0)}class $f extends Df{constructor(e,r,i,n=!1,s=24){if(super(),this.blockLen=e,this.suffix=r,this.outputLen=i,this.enableXOF=n,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,$s(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=V5(this.state)}keccak(){$0||O0(this.state32),t9(this.state32,this.rounds),$0||O0(this.state32),this.posOut=0,this.pos=0}update(e){Vn(this);const{blockLen:r,state:i}=this;e=Wn(e);const n=e.length;for(let s=0;s<n;){const o=Math.min(r-this.pos,n-s);for(let a=0;a<o;a++)i[this.pos++]^=e[s++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:r,pos:i,blockLen:n}=this;e[i]^=r,r&128&&i===n-1&&this.keccak(),e[n-1]^=128,this.keccak()}writeInto(e){Vn(this,!1),ua(e),this.finish();const r=this.state,{blockLen:i}=this;for(let n=0,s=e.length;n<s;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,s-n);e.set(r.subarray(this.posOut,this.posOut+o),n),this.posOut+=o,n+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return $s(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(A0(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:r,suffix:i,outputLen:n,rounds:s,enableXOF:o}=this;return e||(e=new $f(r,i,n,o,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=i,e.outputLen=n,e.enableXOF=o,e.destroyed=this.destroyed,e}}const r9=(t,e,r)=>M0(()=>new $f(e,t,r)),i9=r9(1,136,256/8),n9="https://rpc.walletconnect.org/v1";function B0(t){const e=`Ethereum Signed Message:
18
+ ${t.length}`,r=new TextEncoder().encode(e+t);return"0x"+Buffer.from(i9(r)).toString("hex")}async function s9(t,e,r,i,n,s){switch(r.t){case"eip191":return await o9(t,e,r.s);case"eip1271":return await a9(t,e,r.s,i,n,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r.t}`)}}async function o9(t,e,r){return(await Jm({hash:B0(e),signature:r})).toLowerCase()===t.toLowerCase()}async function a9(t,e,r,i,n,s){const o=ca(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{const a="0x1626ba7e",c="0000000000000000000000000000000000000000000000000000000000000040",f="0000000000000000000000000000000000000000000000000000000000000041",u=r.substring(2),d=B0(e).substring(2),g=a+d+c+f+u,m=await fetch(`${s||n9}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:c9(),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:g},"latest"]})}),{result:b}=await m.json();return b?b.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function c9(){return Date.now()+Math.floor(Math.random()*1e3)}function f9(t){const e=atob(t),r=new Uint8Array(e.length);for(let o=0;o<e.length;o++)r[o]=e.charCodeAt(o);const i=r[0];if(i===0)throw new Error("No signatures found");const n=1+i*64;if(r.length<n)throw new Error("Transaction data too short for claimed signature count");if(r.length<100)throw new Error("Transaction too short");const s=Buffer.from(t,"base64").slice(1,65);return T3.encode(s)}var u9=Object.defineProperty,h9=Object.defineProperties,d9=Object.getOwnPropertyDescriptors,F0=Object.getOwnPropertySymbols,l9=Object.prototype.hasOwnProperty,p9=Object.prototype.propertyIsEnumerable,L0=(t,e,r)=>e in t?u9(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,g9=(t,e)=>{for(var r in e||(e={}))l9.call(e,r)&&L0(t,r,e[r]);if(F0)for(var r of F0(e))p9.call(e,r)&&L0(t,r,e[r]);return t},b9=(t,e)=>h9(t,d9(e));const y9="did:pkh:",Of=t=>t?.split(":"),v9=t=>{const e=t&&Of(t);if(e)return t.includes(y9)?e[3]:e[1]},Mf=t=>{const e=t&&Of(t);if(e)return e[2]+":"+e[3]},da=t=>{const e=t&&Of(t);if(e)return e.pop()};async function q0(t){const{cacao:e,projectId:r}=t,{s:i,p:n}=e,s=z0(n,n.iss),o=da(n.iss);return await s9(o,s,i,Mf(n.iss),r)}const z0=(t,e)=>{const r=`${t.domain} wants you to sign in with your Ethereum account:`,i=da(e);if(!t.aud&&!t.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let n=t.statement||void 0;const s=`URI: ${t.aud||t.uri}`,o=`Version: ${t.version}`,a=`Chain ID: ${v9(e)}`,c=`Nonce: ${t.nonce}`,f=`Issued At: ${t.iat}`,u=t.exp?`Expiration Time: ${t.exp}`:void 0,d=t.nbf?`Not Before: ${t.nbf}`:void 0,g=t.requestId?`Request ID: ${t.requestId}`:void 0,m=t.resources?`Resources:${t.resources.map(x=>`
19
+ - ${x}`).join("")}`:void 0,b=la(t.resources);if(b){const x=Ps(b);n=D9(n,x)}return[r,i,"",n,"",s,o,a,c,f,u,d,g,m].filter(x=>x!=null).join(`
20
+ `)};function m9(t){return Buffer.from(JSON.stringify(t)).toString("base64")}function w9(t){return JSON.parse(Buffer.from(t,"base64").toString("utf-8"))}function Ji(t){if(!t)throw new Error("No recap provided, value is undefined");if(!t.att)throw new Error("No `att` property found");const e=Object.keys(t.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(r=>{const i=t.att[r];if(Array.isArray(i))throw new Error(`Resource must be an object: ${r}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${r}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${r}`);Object.keys(i).forEach(n=>{const s=i[n];if(!Array.isArray(s))throw new Error(`Ability limits ${n} must be an array of objects, found: ${s}`);if(!s.length)throw new Error(`Value of ${n} is empty array, must be an array with objects`);s.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${n}) must be an array of objects, found: ${o}`)})})})}function _9(t,e,r,i={}){return r?.sort((n,s)=>n.localeCompare(s)),{att:{[t]:x9(e,r,i)}}}function x9(t,e,r={}){e=e?.sort((n,s)=>n.localeCompare(s));const i=e.map(n=>({[`${t}/${n}`]:[r]}));return Object.assign({},...i)}function U0(t){return Ji(t),`urn:recap:${m9(t).replace(/=/g,"")}`}function Ps(t){const e=w9(t.replace("urn:recap:",""));return Ji(e),e}function E9(t,e,r){const i=_9(t,e,r);return U0(i)}function S9(t){return t&&t.includes("urn:recap:")}function I9(t,e){const r=Ps(t),i=Ps(e),n=A9(r,i);return U0(n)}function A9(t,e){Ji(t),Ji(e);const r=Object.keys(t.att).concat(Object.keys(e.att)).sort((n,s)=>n.localeCompare(s)),i={att:{}};return r.forEach(n=>{var s,o;Object.keys(((s=t.att)==null?void 0:s[n])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[n])||{})).sort((a,c)=>a.localeCompare(c)).forEach(a=>{var c,f;i.att[n]=b9(g9({},i.att[n]),{[a]:((c=t.att[n])==null?void 0:c[a])||((f=e.att[n])==null?void 0:f[a])})})}),i}function D9(t="",e){Ji(e);const r="I further authorize the stated URI to perform the following actions on my behalf: ";if(t.includes(r))return t;const i=[];let n=0;Object.keys(e.att).forEach(a=>{const c=Object.keys(e.att[a]).map(d=>({ability:d.split("/")[0],action:d.split("/")[1]}));c.sort((d,g)=>d.action.localeCompare(g.action));const f={};c.forEach(d=>{f[d.ability]||(f[d.ability]=[]),f[d.ability].push(d.action)});const u=Object.keys(f).map(d=>(n++,`(${n}) '${d}': '${f[d].join("', '")}' for '${a}'.`));i.push(u.join(", ").replace(".,","."))});const s=i.join(" "),o=`${r}${s}`;return`${t?t+" ":""}${o}`}function k0(t){var e;const r=Ps(t);Ji(r);const i=(e=r.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function j0(t){const e=Ps(t);Ji(e);const r=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(n=>{var s;(s=n?.[0])!=null&&s.chains&&r.push(n[0].chains)})}),[...new Set(r.flat())]}function la(t){if(!t)return;const e=t?.[t.length-1];return S9(e)?e:void 0}function Pf(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function K0(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Jt(t,...e){if(!K0(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function V0(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function $9(t,e){Jt(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function H0(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}const Ii=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),O9=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");function M9(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Rf(t){if(typeof t=="string")t=M9(t);else if(K0(t))t=Tf(t);else throw new Error("Uint8Array expected, got "+typeof t);return t}function P9(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function R9(t,e){if(t.length!==e.length)return!1;let r=0;for(let i=0;i<t.length;i++)r|=t[i]^e[i];return r===0}const T9=(t,e)=>{function r(i,...n){if(Jt(i),t.nonceLength!==void 0){const f=n[0];if(!f)throw new Error("nonce / iv required");t.varSizeNonce?Jt(f):Jt(f,t.nonceLength)}const s=t.tagLength;s&&n[1]!==void 0&&Jt(n[1]);const o=e(i,...n),a=(f,u)=>{if(u!==void 0){if(f!==2)throw new Error("cipher output not supported");Jt(u)}};let c=!1;return{encrypt(f,u){if(c)throw new Error("cannot encrypt() twice with same key + nonce");return c=!0,Jt(f),a(o.encrypt.length,u),o.encrypt(f,u)},decrypt(f,u){if(Jt(f),s&&f.length<s)throw new Error("invalid ciphertext length: smaller than tagLength="+s);return a(o.decrypt.length,u),o.decrypt(f,u)}}}return Object.assign(r,t),r};function W0(t,e,r=!0){if(e===void 0)return new Uint8Array(t);if(e.length!==t)throw new Error("invalid output length, expected "+t+", got: "+e.length);if(r&&!C9(e))throw new Error("invalid output, must be aligned");return e}function G0(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);const n=BigInt(32),s=BigInt(4294967295),o=Number(r>>n&s),a=Number(r&s),c=i?4:0,f=i?0:4;t.setUint32(e+c,o,i),t.setUint32(e+f,a,i)}function C9(t){return t.byteOffset%4===0}function Tf(t){return Uint8Array.from(t)}function Gn(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const Y0=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),N9=Y0("expand 16-byte k"),B9=Y0("expand 32-byte k"),F9=Ii(N9),L9=Ii(B9);function ce(t,e){return t<<e|t>>>32-e}function Cf(t){return t.byteOffset%4===0}const pa=64,q9=16,Z0=2**32-1,J0=new Uint32Array;function z9(t,e,r,i,n,s,o,a){const c=n.length,f=new Uint8Array(pa),u=Ii(f),d=Cf(n)&&Cf(s),g=d?Ii(n):J0,m=d?Ii(s):J0;for(let b=0;b<c;o++){if(t(e,r,i,u,o,a),o>=Z0)throw new Error("arx: counter overflow");const x=Math.min(pa,c-b);if(d&&x===pa){const I=b/4;if(b%4!==0)throw new Error("arx: invalid block position");for(let O=0,$;O<q9;O++)$=I+O,m[$]=g[$]^u[O];b+=pa;continue}for(let I=0,O;I<x;I++)O=b+I,s[O]=n[O]^f[I];b+=x}}function U9(t,e){const{allowShortKeys:r,extendNonceFn:i,counterLength:n,counterRight:s,rounds:o}=P9({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return Pf(n),Pf(o),H0(s),H0(r),(a,c,f,u,d=0)=>{Jt(a),Jt(c),Jt(f);const g=f.length;if(u===void 0&&(u=new Uint8Array(g)),Jt(u),Pf(d),d<0||d>=Z0)throw new Error("arx: counter overflow");if(u.length<g)throw new Error(`arx: output (${u.length}) is shorter than data (${g})`);const m=[];let b=a.length,x,I;if(b===32)m.push(x=Tf(a)),I=L9;else if(b===16&&r)x=new Uint8Array(32),x.set(a),x.set(a,16),I=F9,m.push(x);else throw new Error(`arx: invalid 32-byte key, got length=${b}`);Cf(c)||m.push(c=Tf(c));const O=Ii(x);if(i){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");i(I,O,Ii(c.subarray(0,16)),O),c=c.subarray(16)}const $=16-n;if($!==c.length)throw new Error(`arx: nonce must be ${$} or 16 bytes`);if($!==12){const R=new Uint8Array(12);R.set(c,s?0:12-c.length),c=R,m.push(c)}const P=Ii(c);return z9(t,I,O,P,f,u,d,o),Gn(...m),u}}const Et=(t,e)=>t[e++]&255|(t[e++]&255)<<8;class k9{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,e=Rf(e),Jt(e,32);const r=Et(e,0),i=Et(e,2),n=Et(e,4),s=Et(e,6),o=Et(e,8),a=Et(e,10),c=Et(e,12),f=Et(e,14);this.r[0]=r&8191,this.r[1]=(r>>>13|i<<3)&8191,this.r[2]=(i>>>10|n<<6)&7939,this.r[3]=(n>>>7|s<<9)&8191,this.r[4]=(s>>>4|o<<12)&255,this.r[5]=o>>>1&8190,this.r[6]=(o>>>14|a<<2)&8191,this.r[7]=(a>>>11|c<<5)&8065,this.r[8]=(c>>>8|f<<8)&8191,this.r[9]=f>>>5&127;for(let u=0;u<8;u++)this.pad[u]=Et(e,16+2*u)}process(e,r,i=!1){const n=i?0:2048,{h:s,r:o}=this,a=o[0],c=o[1],f=o[2],u=o[3],d=o[4],g=o[5],m=o[6],b=o[7],x=o[8],I=o[9],O=Et(e,r+0),$=Et(e,r+2),P=Et(e,r+4),R=Et(e,r+6),N=Et(e,r+8),B=Et(e,r+10),F=Et(e,r+12),L=Et(e,r+14);let C=s[0]+(O&8191),W=s[1]+((O>>>13|$<<3)&8191),A=s[2]+(($>>>10|P<<6)&8191),h=s[3]+((P>>>7|R<<9)&8191),p=s[4]+((R>>>4|N<<12)&8191),v=s[5]+(N>>>1&8191),y=s[6]+((N>>>14|B<<2)&8191),w=s[7]+((B>>>11|F<<5)&8191),S=s[8]+((F>>>8|L<<8)&8191),D=s[9]+(L>>>5|n),_=0,l=_+C*a+W*(5*I)+A*(5*x)+h*(5*b)+p*(5*m);_=l>>>13,l&=8191,l+=v*(5*g)+y*(5*d)+w*(5*u)+S*(5*f)+D*(5*c),_+=l>>>13,l&=8191;let E=_+C*c+W*a+A*(5*I)+h*(5*x)+p*(5*b);_=E>>>13,E&=8191,E+=v*(5*m)+y*(5*g)+w*(5*d)+S*(5*u)+D*(5*f),_+=E>>>13,E&=8191;let q=_+C*f+W*c+A*a+h*(5*I)+p*(5*x);_=q>>>13,q&=8191,q+=v*(5*b)+y*(5*m)+w*(5*g)+S*(5*d)+D*(5*u),_+=q>>>13,q&=8191;let z=_+C*u+W*f+A*c+h*a+p*(5*I);_=z>>>13,z&=8191,z+=v*(5*x)+y*(5*b)+w*(5*m)+S*(5*g)+D*(5*d),_+=z>>>13,z&=8191;let U=_+C*d+W*u+A*f+h*c+p*a;_=U>>>13,U&=8191,U+=v*(5*I)+y*(5*x)+w*(5*b)+S*(5*m)+D*(5*g),_+=U>>>13,U&=8191;let k=_+C*g+W*d+A*u+h*f+p*c;_=k>>>13,k&=8191,k+=v*a+y*(5*I)+w*(5*x)+S*(5*b)+D*(5*m),_+=k>>>13,k&=8191;let G=_+C*m+W*g+A*d+h*u+p*f;_=G>>>13,G&=8191,G+=v*c+y*a+w*(5*I)+S*(5*x)+D*(5*b),_+=G>>>13,G&=8191;let J=_+C*b+W*m+A*g+h*d+p*u;_=J>>>13,J&=8191,J+=v*f+y*c+w*a+S*(5*I)+D*(5*x),_+=J>>>13,J&=8191;let X=_+C*x+W*b+A*m+h*g+p*d;_=X>>>13,X&=8191,X+=v*u+y*f+w*c+S*a+D*(5*I),_+=X>>>13,X&=8191;let Z=_+C*I+W*x+A*b+h*m+p*g;_=Z>>>13,Z&=8191,Z+=v*d+y*u+w*f+S*c+D*a,_+=Z>>>13,Z&=8191,_=(_<<2)+_|0,_=_+l|0,l=_&8191,_=_>>>13,E+=_,s[0]=l,s[1]=E,s[2]=q,s[3]=z,s[4]=U,s[5]=k,s[6]=G,s[7]=J,s[8]=X,s[9]=Z}finalize(){const{h:e,pad:r}=this,i=new Uint16Array(10);let n=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=n,n=e[a]>>>13,e[a]&=8191;e[0]+=n*5,n=e[0]>>>13,e[0]&=8191,e[1]+=n,n=e[1]>>>13,e[1]&=8191,e[2]+=n,i[0]=e[0]+5,n=i[0]>>>13,i[0]&=8191;for(let a=1;a<10;a++)i[a]=e[a]+n,n=i[a]>>>13,i[a]&=8191;i[9]-=8192;let s=(n^1)-1;for(let a=0;a<10;a++)i[a]&=s;s=~s;for(let a=0;a<10;a++)e[a]=e[a]&s|i[a];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let o=e[0]+r[0];e[0]=o&65535;for(let a=1;a<8;a++)o=(e[a]+r[a]|0)+(o>>>16)|0,e[a]=o&65535;Gn(i)}update(e){V0(this);const{buffer:r,blockLen:i}=this;e=Rf(e);const n=e.length;for(let s=0;s<n;){const o=Math.min(i-this.pos,n-s);if(o===i){for(;i<=n-s;s+=i)this.process(e,s);continue}r.set(e.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===i&&(this.process(r,0,!1),this.pos=0)}return this}destroy(){Gn(this.h,this.r,this.buffer,this.pad)}digestInto(e){V0(this),$9(e,this),this.finished=!0;const{buffer:r,h:i}=this;let{pos:n}=this;if(n){for(r[n++]=1;n<16;n++)r[n]=0;this.process(r,0,!0)}this.finalize();let s=0;for(let o=0;o<8;o++)e[s++]=i[o]>>>0,e[s++]=i[o]>>>8;return e}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const i=e.slice(0,r);return this.destroy(),i}}function j9(t){const e=(i,n)=>t(n).update(Rf(i)).digest(),r=t(new Uint8Array(32));return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=i=>t(i),e}const K9=j9(t=>new k9(t));function V9(t,e,r,i,n,s=20){let o=t[0],a=t[1],c=t[2],f=t[3],u=e[0],d=e[1],g=e[2],m=e[3],b=e[4],x=e[5],I=e[6],O=e[7],$=n,P=r[0],R=r[1],N=r[2],B=o,F=a,L=c,C=f,W=u,A=d,h=g,p=m,v=b,y=x,w=I,S=O,D=$,_=P,l=R,E=N;for(let z=0;z<s;z+=2)B=B+W|0,D=ce(D^B,16),v=v+D|0,W=ce(W^v,12),B=B+W|0,D=ce(D^B,8),v=v+D|0,W=ce(W^v,7),F=F+A|0,_=ce(_^F,16),y=y+_|0,A=ce(A^y,12),F=F+A|0,_=ce(_^F,8),y=y+_|0,A=ce(A^y,7),L=L+h|0,l=ce(l^L,16),w=w+l|0,h=ce(h^w,12),L=L+h|0,l=ce(l^L,8),w=w+l|0,h=ce(h^w,7),C=C+p|0,E=ce(E^C,16),S=S+E|0,p=ce(p^S,12),C=C+p|0,E=ce(E^C,8),S=S+E|0,p=ce(p^S,7),B=B+A|0,E=ce(E^B,16),w=w+E|0,A=ce(A^w,12),B=B+A|0,E=ce(E^B,8),w=w+E|0,A=ce(A^w,7),F=F+h|0,D=ce(D^F,16),S=S+D|0,h=ce(h^S,12),F=F+h|0,D=ce(D^F,8),S=S+D|0,h=ce(h^S,7),L=L+p|0,_=ce(_^L,16),v=v+_|0,p=ce(p^v,12),L=L+p|0,_=ce(_^L,8),v=v+_|0,p=ce(p^v,7),C=C+W|0,l=ce(l^C,16),y=y+l|0,W=ce(W^y,12),C=C+W|0,l=ce(l^C,8),y=y+l|0,W=ce(W^y,7);let q=0;i[q++]=o+B|0,i[q++]=a+F|0,i[q++]=c+L|0,i[q++]=f+C|0,i[q++]=u+W|0,i[q++]=d+A|0,i[q++]=g+h|0,i[q++]=m+p|0,i[q++]=b+v|0,i[q++]=x+y|0,i[q++]=I+w|0,i[q++]=O+S|0,i[q++]=$+D|0,i[q++]=P+_|0,i[q++]=R+l|0,i[q++]=N+E|0}const H9=U9(V9,{counterRight:!1,counterLength:4,allowShortKeys:!1}),W9=new Uint8Array(16),X0=(t,e)=>{t.update(e);const r=e.length%16;r&&t.update(W9.subarray(r))},G9=new Uint8Array(32);function Q0(t,e,r,i,n){const s=t(e,r,G9),o=K9.create(s);n&&X0(o,n),X0(o,i);const a=new Uint8Array(16),c=O9(a);G0(c,0,BigInt(n?n.length:0),!0),G0(c,8,BigInt(i.length),!0),o.update(a);const f=o.digest();return Gn(s,a),f}const Y9=t=>(e,r,i)=>({encrypt(n,s){const o=n.length;s=W0(o+16,s,!1),s.set(n);const a=s.subarray(0,-16);t(e,r,a,a,1);const c=Q0(t,e,r,a,i);return s.set(c,o),Gn(c),s},decrypt(n,s){s=W0(n.length-16,s,!1);const o=n.subarray(0,-16),a=n.subarray(-16),c=Q0(t,e,r,o,i);if(!R9(a,c))throw new Error("invalid tag");return s.set(n.subarray(0,-16)),t(e,r,s,s,1),Gn(c),s}}),ep=T9({blockSize:64,nonceLength:12,tagLength:16},Y9(H9));class tp extends Df{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,If(e);const i=Wn(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const n=this.blockLen,s=new Uint8Array(n);s.set(i.length>n?e.create().update(i).digest():i);for(let o=0;o<s.length;o++)s[o]^=54;this.iHash.update(s),this.oHash=e.create();for(let o=0;o<s.length;o++)s[o]^=106;this.oHash.update(s),s.fill(0)}update(e){return Vn(this),this.iHash.update(e),this}digestInto(e){Vn(this),ua(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:r,iHash:i,finished:n,destroyed:s,blockLen:o,outputLen:a}=this;return e=e,e.finished=n,e.destroyed=s,e.blockLen=o,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=i._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Nf=(t,e,r)=>new tp(t,e).update(r).digest();Nf.create=(t,e)=>new tp(t,e);function Z9(t,e,r){return If(t),r===void 0&&(r=new Uint8Array(t.outputLen)),Nf(t,Wn(r),Wn(e))}const Bf=new Uint8Array([0]),rp=new Uint8Array;function J9(t,e,r,i=32){if(If(t),$s(i),i>255*t.outputLen)throw new Error("Length should be <= 255*HashLen");const n=Math.ceil(i/t.outputLen);r===void 0&&(r=rp);const s=new Uint8Array(n*t.outputLen),o=Nf.create(t,e),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let f=0;f<n;f++)Bf[0]=f+1,a.update(f===0?rp:c).update(r).update(Bf).digestInto(c),s.set(c,t.outputLen*f),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),Bf.fill(0),s.slice(0,i)}const X9=(t,e,r,i,n)=>J9(t,Z9(t,e,r),i,n);function Q9(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);const n=BigInt(32),s=BigInt(4294967295),o=Number(r>>n&s),a=Number(r&s),c=i?4:0,f=i?0:4;t.setUint32(e+c,o,i),t.setUint32(e+f,a,i)}function e7(t,e,r){return t&e^~t&r}function t7(t,e,r){return t&e^t&r^e&r}class r7 extends Df{constructor(e,r,i,n){super(),this.blockLen=e,this.outputLen=r,this.padOffset=i,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Af(this.buffer)}update(e){Vn(this);const{view:r,buffer:i,blockLen:n}=this;e=Wn(e);const s=e.length;for(let o=0;o<s;){const a=Math.min(n-this.pos,s-o);if(a===n){const c=Af(e);for(;n<=s-o;o+=n)this.process(c,o);continue}i.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Vn(this),A0(e,this),this.finished=!0;const{buffer:r,view:i,blockLen:n,isLE:s}=this;let{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(i,0),o=0);for(let d=o;d<n;d++)r[d]=0;Q9(i,n-8,BigInt(this.length*8),s),this.process(i,0);const a=Af(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=c/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<f;d++)a.setUint32(4*d,u[d],s)}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const i=e.slice(0,r);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:r,buffer:i,length:n,finished:s,destroyed:o,pos:a}=this;return e.length=n,e.pos=a,e.finished=s,e.destroyed=o,n%r&&e.buffer.set(i),e}}const i7=new Uint32Array([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]),Ai=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Di=new Uint32Array(64);class n7 extends r7{constructor(){super(64,32,8,!1),this.A=Ai[0]|0,this.B=Ai[1]|0,this.C=Ai[2]|0,this.D=Ai[3]|0,this.E=Ai[4]|0,this.F=Ai[5]|0,this.G=Ai[6]|0,this.H=Ai[7]|0}get(){const{A:e,B:r,C:i,D:n,E:s,F:o,G:a,H:c}=this;return[e,r,i,n,s,o,a,c]}set(e,r,i,n,s,o,a,c){this.A=e|0,this.B=r|0,this.C=i|0,this.D=n|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,r){for(let d=0;d<16;d++,r+=4)Di[d]=e.getUint32(r,!1);for(let d=16;d<64;d++){const g=Di[d-15],m=Di[d-2],b=Lr(g,7)^Lr(g,18)^g>>>3,x=Lr(m,17)^Lr(m,19)^m>>>10;Di[d]=x+Di[d-7]+b+Di[d-16]|0}let{A:i,B:n,C:s,D:o,E:a,F:c,G:f,H:u}=this;for(let d=0;d<64;d++){const g=Lr(a,6)^Lr(a,11)^Lr(a,25),m=u+g+e7(a,c,f)+i7[d]+Di[d]|0,b=(Lr(i,2)^Lr(i,13)^Lr(i,22))+t7(i,n,s)|0;u=f,f=c,c=a,a=o+m|0,o=s,s=n,n=i,i=m+b|0}i=i+this.A|0,n=n+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(i,n,s,o,a,c,f,u)}roundClean(){Di.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const ga=M0(()=>new n7);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ip=BigInt(0);function Ff(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function np(t){if(!Ff(t))throw new Error("Uint8Array expected")}const s7=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function o7(t){np(t);let e="";for(let r=0;r<t.length;r++)e+=s7[t[r]];return e}function a7(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?ip:BigInt("0x"+t)}const ii={_0:48,_9:57,A:65,F:70,a:97,f:102};function sp(t){if(t>=ii._0&&t<=ii._9)return t-ii._0;if(t>=ii.A&&t<=ii.F)return t-(ii.A-10);if(t>=ii.a&&t<=ii.f)return t-(ii.a-10)}function op(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const i=new Uint8Array(r);for(let n=0,s=0;n<r;n++,s+=2){const o=sp(t.charCodeAt(s)),a=sp(t.charCodeAt(s+1));if(o===void 0||a===void 0){const c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}i[n]=o*16+a}return i}function ap(t){return np(t),a7(o7(Uint8Array.from(t).reverse()))}function c7(t,e){return op(t.toString(16).padStart(e*2,"0"))}function f7(t,e){return c7(t,e).reverse()}function cp(t,e,r){let i;if(typeof e=="string")try{i=op(e)}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(Ff(e))i=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const n=i.length;if(typeof r=="number"&&n!==r)throw new Error(t+" of length "+r+" expected, got "+n);return i}const Lf=t=>typeof t=="bigint"&&ip<=t;function u7(t,e,r){return Lf(t)&&Lf(e)&&Lf(r)&&e<=t&&t<r}function fp(t,e,r,i){if(!u7(e,r,i))throw new Error("expected valid "+t+": "+r+" <= n < "+i+", got "+e)}const h7={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||Ff(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function d7(t,e,r={}){const i=(n,s,o)=>{const a=h7[s];if(typeof a!="function")throw new Error("invalid validator function");const c=t[n];if(!(o&&c===void 0)&&!a(c,t))throw new Error("param "+String(n)+" is invalid. Expected "+s+", got "+c)};for(const[n,s]of Object.entries(e))i(n,s,!1);for(const[n,s]of Object.entries(r))i(n,s,!0);return t}const Yn=BigInt(0),ba=BigInt(1);function up(t,e){const r=t%e;return r>=Yn?r:e+r}function l7(t,e,r){if(e<Yn)throw new Error("invalid exponent, negatives unsupported");if(r<=Yn)throw new Error("invalid modulus");if(r===ba)return Yn;let i=ba;for(;e>Yn;)e&ba&&(i=i*t%r),t=t*t%r,e>>=ba;return i}function vr(t,e,r){let i=t;for(;e-- >Yn;)i*=i,i%=r;return i}BigInt(0),BigInt(1),BigInt(0),BigInt(1),BigInt(2),BigInt(8);const Zn=BigInt(0),qf=BigInt(1);function p7(t){return d7(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function g7(t){const e=p7(t),{P:r}=e,i=$=>up($,r),n=e.montgomeryBits,s=Math.ceil(n/8),o=e.nByteLength,a=e.adjustScalarBytes||($=>$),c=e.powPminus2||($=>l7($,r-BigInt(2),r));function f($,P,R){const N=i($*(P-R));return P=i(P-N),R=i(R+N),[P,R]}const u=(e.a-BigInt(2))/BigInt(4);function d($,P){fp("u",$,Zn,r),fp("scalar",P,Zn,r);const R=P,N=$;let B=qf,F=Zn,L=$,C=qf,W=Zn,A;for(let p=BigInt(n-1);p>=Zn;p--){const v=R>>p&qf;W^=v,A=f(W,B,L),B=A[0],L=A[1],A=f(W,F,C),F=A[0],C=A[1],W=v;const y=B+F,w=i(y*y),S=B-F,D=i(S*S),_=w-D,l=L+C,E=L-C,q=i(E*y),z=i(l*S),U=q+z,k=q-z;L=i(U*U),C=i(N*i(k*k)),B=i(w*D),F=i(_*(w+i(u*_)))}A=f(W,B,L),B=A[0],L=A[1],A=f(W,F,C),F=A[0],C=A[1];const h=c(F);return i(B*h)}function g($){return f7(i($),s)}function m($){const P=cp("u coordinate",$,s);return o===32&&(P[31]&=127),ap(P)}function b($){const P=cp("scalar",$),R=P.length;if(R!==s&&R!==o){let N=""+s+" or "+o;throw new Error("invalid scalar, expected "+N+" bytes, got "+R)}return ap(a(P))}function x($,P){const R=m(P),N=b($),B=d(R,N);if(B===Zn)throw new Error("invalid private or public key received");return g(B)}const I=g(e.Gu);function O($){return x($,I)}return{scalarMult:x,scalarMultBase:O,getSharedSecret:($,P)=>x($,P),getPublicKey:$=>O($),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:I}}const zf=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const b7=BigInt(1),hp=BigInt(2),y7=BigInt(3),v7=BigInt(5);BigInt(8);function m7(t){const e=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),s=zf,o=t*t%s*t%s,a=vr(o,hp,s)*o%s,c=vr(a,b7,s)*t%s,f=vr(c,v7,s)*c%s,u=vr(f,e,s)*f%s,d=vr(u,r,s)*u%s,g=vr(d,i,s)*d%s,m=vr(g,n,s)*g%s,b=vr(m,n,s)*g%s,x=vr(b,e,s)*f%s;return{pow_p_5_8:vr(x,hp,s)*t%s,b2:o}}function w7(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const Uf=g7({P:zf,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{const e=zf,{pow_p_5_8:r,b2:i}=m7(t);return up(vr(r,y7,e)*i,e)},adjustScalarBytes:w7,randomBytes:Os}),dp="base10",Tt="base16",$i="base64pad",Rs="base64url",Ts="utf8",lp=0,ni=1,Cs=2,_7=0,pp=1,Ns=12,kf=32;function x7(){const t=Uf.utils.randomPrivateKey(),e=Uf.getPublicKey(t);return{privateKey:qt(t,Tt),publicKey:qt(e,Tt)}}function jf(){const t=Os(kf);return qt(t,Tt)}function E7(t,e){const r=Uf.getSharedSecret(ir(t,Tt),ir(e,Tt)),i=X9(ga,r,void 0,void 0,kf);return qt(i,Tt)}function ya(t){const e=ga(ir(t,Tt));return qt(e,Tt)}function qr(t){const e=ga(ir(t,Ts));return qt(e,Tt)}function gp(t){return ir(`${t}`,dp)}function Xi(t){return Number(qt(t,dp))}function S7(t){const e=gp(typeof t.type<"u"?t.type:lp);if(Xi(e)===ni&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof t.senderPublicKey<"u"?ir(t.senderPublicKey,Tt):void 0,i=typeof t.iv<"u"?ir(t.iv,Tt):Os(Ns),n=ir(t.symKey,Tt),s=ep(n,i).encrypt(ir(t.message,Ts));return bp({type:e,sealed:s,iv:i,senderPublicKey:r,encoding:t.encoding})}function I7(t){const e=ir(t.symKey,Tt),{sealed:r,iv:i}=Bs(t),n=ep(e,i).decrypt(r);if(n===null)throw new Error("Failed to decrypt");return qt(n,Ts)}function A7(t,e){const r=gp(Cs),i=Os(Ns),n=ir(t,Ts);return bp({type:r,sealed:n,iv:i,encoding:e})}function D7(t,e){const{sealed:r}=Bs({encoded:t,encoding:e});return qt(r,Ts)}function bp(t){const{encoding:e=$i}=t;if(Xi(t.type)===Cs)return qt(tf([t.type,t.sealed]),e);if(Xi(t.type)===ni){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return qt(tf([t.type,t.senderPublicKey,t.iv,t.sealed]),e)}return qt(tf([t.type,t.iv,t.sealed]),e)}function Bs(t){const{encoded:e,encoding:r=$i}=t,i=ir(e,r),n=i.slice(_7,pp),s=pp;if(Xi(n)===ni){const f=s+kf,u=f+Ns,d=i.slice(s,f),g=i.slice(f,u),m=i.slice(u);return{type:n,sealed:m,iv:g,senderPublicKey:d}}if(Xi(n)===Cs){const f=i.slice(s),u=Os(Ns);return{type:n,sealed:f,iv:u}}const o=s+Ns,a=i.slice(s,o),c=i.slice(o);return{type:n,sealed:c,iv:a}}function $7(t,e){const r=Bs({encoded:t,encoding:e?.encoding});return yp({type:Xi(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?qt(r.senderPublicKey,Tt):void 0,receiverPublicKey:e?.receiverPublicKey})}function yp(t){const e=t?.type||lp;if(e===ni){if(typeof t?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof t?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:t?.senderPublicKey,receiverPublicKey:t?.receiverPublicKey}}function vp(t){return t.type===ni&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}function mp(t){return t.type===Cs}function O7(t){return new Cl.ec("p256").keyFromPublic({x:Buffer.from(t.x,"base64").toString("hex"),y:Buffer.from(t.y,"base64").toString("hex")},"hex")}function M7(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");const r=e.length%4;return r>0&&(e+="=".repeat(4-r)),e}function P7(t){return Buffer.from(M7(t),"base64")}function R7(t,e){const[r,i,n]=t.split("."),s=P7(n);if(s.length!==64)throw new Error("Invalid signature length");const o=s.slice(0,32).toString("hex"),a=s.slice(32,64).toString("hex"),c=`${r}.${i}`,f=ga(c),u=O7(e),d=qt(f,Tt);if(!u.verify(d,{r:o,s:a}))throw new Error("Invalid signature");return xc(t).payload}const T7="irn";function va(t){return t?.relay||{protocol:T7}}function Fs(t){const e=y5[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}function C7(t,e="-"){const r={},i="relay"+e;return Object.keys(t).forEach(n=>{if(n.startsWith(i)){const s=n.replace(i,""),o=t[n];r[s]=o}}),r}function wp(t){if(!t.includes("wc:")){const f=I0(t);f!=null&&f.includes("wc:")&&(t=f)}t=t.includes("wc://")?t.replace("wc://",""):t,t=t.includes("wc:")?t.replace("wc:",""):t;const e=t.indexOf(":"),r=t.indexOf("?")!==-1?t.indexOf("?"):void 0,i=t.substring(0,e),n=t.substring(e+1,r).split("@"),s=typeof r<"u"?t.substring(r):"",o=new URLSearchParams(s),a={};o.forEach((f,u)=>{a[u]=f});const c=typeof a.methods=="string"?a.methods.split(","):void 0;return{protocol:i,topic:N7(n[0]),version:parseInt(n[1],10),symKey:a.symKey,relay:C7(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function N7(t){return t.startsWith("//")?t.substring(2):t}function B7(t,e="-"){const r="relay",i={};return Object.keys(t).forEach(n=>{const s=n,o=r+e+s;t[s]&&(i[o]=t[s])}),i}function _p(t){const e=new URLSearchParams,r=B7(t.relay);Object.keys(r).sort().forEach(n=>{e.set(n,r[n])}),e.set("symKey",t.symKey),t.expiryTimestamp&&e.set("expiryTimestamp",t.expiryTimestamp.toString()),t.methods&&e.set("methods",t.methods.join(","));const i=e.toString();return`${t.protocol}:${t.topic}@${t.version}?${i}`}function ma(t,e,r){return`${t}?wc_ev=${r}&topic=${e}`}function Jn(t){const e=[];return t.forEach(r=>{const[i,n]=r.split(":");e.push(`${i}:${n}`)}),e}function F7(t){const e=[];return Object.values(t).forEach(r=>{e.push(...Jn(r.accounts))}),e}function L7(t,e){const r=[];return Object.values(t).forEach(i=>{Jn(i.accounts).includes(e)&&r.push(...i.methods)}),r}function q7(t,e){const r=[];return Object.values(t).forEach(i=>{Jn(i.accounts).includes(e)&&r.push(...i.events)}),r}function z7(t){const e={};return t?.forEach(r=>{var i;const[n,s]=r.split(":");e[n]||(e[n]={accounts:[],chains:[],events:[],methods:[]}),e[n].accounts.push(r),(i=e[n].chains)==null||i.push(`${n}:${s}`)}),e}function xp(t,e){e=e.map(i=>i.replace("did:pkh:",""));const r=z7(e);for(const[i,n]of Object.entries(r))n.methods?n.methods=O5(n.methods,t):n.methods=t,n.events=["chainChanged","accountsChanged"];return r}const U7={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},k7={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function H(t,e){const{message:r,code:i}=k7[t];return{message:e?`${r} ${e}`:r,code:i}}function we(t,e){const{message:r,code:i}=U7[t];return{message:e?`${r} ${e}`:r,code:i}}function Ls(t,e){return Array.isArray(t)?typeof e<"u"&&t.length?t.every(e):!0:!1}function wa(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function St(t){return typeof t>"u"}function nt(t,e){return e&&St(t)?!0:typeof t=="string"&&!!t.trim().length}function Kf(t,e){return e&&St(t)?!0:typeof t=="number"&&!isNaN(t)}function j7(t,e){const{requiredNamespaces:r}=e,i=Object.keys(t.namespaces),n=Object.keys(r);let s=!0;return Yi(n,i)?(i.forEach(o=>{const{accounts:a,methods:c,events:f}=t.namespaces[o],u=Jn(a),d=r[o];(!Yi(y0(o,d),u)||!Yi(d.methods,c)||!Yi(d.events,f))&&(s=!1)}),s):!1}function _a(t){return nt(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function K7(t){if(nt(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const r=e[0]+":"+e[1];return!!e[2]&&_a(r)}}return!1}function V7(t){function e(r){try{return typeof new URL(r)<"u"}catch{return!1}}try{if(nt(t,!1)){if(e(t))return!0;const r=I0(t);return e(r)}}catch{}return!1}function H7(t){var e;return(e=t?.proposer)==null?void 0:e.publicKey}function W7(t){return t?.topic}function G7(t,e){let r=null;return nt(t?.publicKey,!1)||(r=H("MISSING_OR_INVALID",`${e} controller public key should be a string`)),r}function Ep(t){let e=!0;return Ls(t)?t.length&&(e=t.every(r=>nt(r,!1))):e=!1,e}function Y7(t,e,r){let i=null;return Ls(e)&&e.length?e.forEach(n=>{i||_a(n)||(i=we("UNSUPPORTED_CHAINS",`${r}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):_a(t)||(i=we("UNSUPPORTED_CHAINS",`${r}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}function Z7(t,e,r){let i=null;return Object.entries(t).forEach(([n,s])=>{if(i)return;const o=Y7(n,y0(n,s),`${e} ${r}`);o&&(i=o)}),i}function J7(t,e){let r=null;return Ls(t)?t.forEach(i=>{r||K7(i)||(r=we("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):r=we("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function X7(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=J7(i?.accounts,`${e} namespace`);n&&(r=n)}),r}function Q7(t,e){let r=null;return Ep(t?.methods)?Ep(t?.events)||(r=we("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):r=we("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),r}function Sp(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=Q7(i,`${e}, namespace`);n&&(r=n)}),r}function e_(t,e,r){let i=null;if(t&&wa(t)){const n=Sp(t,e);n&&(i=n);const s=Z7(t,e,r);s&&(i=s)}else i=H("MISSING_OR_INVALID",`${e}, ${r} should be an object with data`);return i}function Vf(t,e){let r=null;if(t&&wa(t)){const i=Sp(t,e);i&&(r=i);const n=X7(t,e);n&&(r=n)}else r=H("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function Ip(t){return nt(t.protocol,!0)}function t_(t,e){let r=!1;return e&&!t?r=!0:t&&Ls(t)&&t.length&&t.forEach(i=>{r=Ip(i)}),r}function r_(t){return typeof t=="number"}function Ht(t){return typeof t<"u"&&typeof t!==null}function i_(t){return!(!t||typeof t!="object"||!t.code||!Kf(t.code,!1)||!t.message||!nt(t.message,!1))}function n_(t){return!(St(t)||!nt(t.method,!1))}function s_(t){return!(St(t)||St(t.result)&&St(t.error)||!Kf(t.id,!1)||!nt(t.jsonrpc,!1))}function o_(t){return!(St(t)||!nt(t.name,!1))}function Ap(t,e){return!(!_a(e)||!F7(t).includes(e))}function a_(t,e,r){return nt(r,!1)?L7(t,e).includes(r):!1}function c_(t,e,r){return nt(r,!1)?q7(t,e).includes(r):!1}function Dp(t,e,r){let i=null;const n=f_(t),s=u_(e),o=Object.keys(n),a=Object.keys(s),c=$p(Object.keys(t)),f=$p(Object.keys(e)),u=c.filter(d=>!f.includes(d));return u.length&&(i=H("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces.
21
+ Required: ${u.toString()}
22
+ Received: ${Object.keys(e).toString()}`)),Yi(o,a)||(i=H("NON_CONFORMING_NAMESPACES",`${r} namespaces chains don't satisfy required namespaces.
27
23
  Required: ${o.toString()}
28
- Approved: ${a.toString()}`)),Object.keys(e).forEach(y=>{if(!y.includes(":")||i)return;const M=es(e[y].accounts);M.includes(y)||(i=Z("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${y}
29
- Required: ${y}
30
- Approved: ${M.toString()}`))}),o.forEach(y=>{i||(dn(n[y].methods,s[y].methods)?dn(n[y].events,s[y].events)||(i=Z("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${y}`)):i=Z("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${y}`))}),i}function L8(t){const e={};return Object.keys(t).forEach(r=>{var i;r.includes(":")?e[r]=t[r]:(i=t[r].chains)==null||i.forEach(n=>{e[n]={methods:t[r].methods,events:t[r].events}})}),e}function Hl(t){return[...new Set(t.map(e=>e.includes(":")?e.split(":")[0]:e))]}function q8(t){const e={};return Object.keys(t).forEach(r=>{r.includes(":")?e[r]=t[r]:es(t[r].accounts)?.forEach(n=>{e[n]={accounts:t[r].accounts.filter(s=>s.includes(`${n}:`)),methods:t[r].methods,events:t[r].events}})}),e}function U8(t,e){return Qf(t,!1)&&t<=e.max&&t>=e.min}function Wl(){const t=Ms();return new Promise(e=>{switch(t){case gr.browser:e(z8());break;case gr.reactNative:e(k8());break;case gr.node:e(j8());break;default:e(!0)}})}function z8(){return Ss()&&navigator?.onLine}async function k8(){return ki()&&typeof global<"u"&&global!=null&&global.NetInfo?(await(global==null?void 0:global.NetInfo.fetch()))?.isConnected:!0}function j8(){return!0}function K8(t){switch(Ms()){case gr.browser:V8(t);break;case gr.reactNative:H8(t);break}}function V8(t){!ki()&&Ss()&&(window.addEventListener("online",()=>t(!0)),window.addEventListener("offline",()=>t(!1)))}function H8(t){ki()&&typeof global<"u"&&global!=null&&global.NetInfo&&global?.NetInfo.addEventListener(e=>t(e?.isConnected))}const tc={};class Cs{static get(e){return tc[e]}static set(e,r){tc[e]=r}static delete(e){delete tc[e]}}const W8="PARSE_ERROR",G8="INVALID_REQUEST",J8="METHOD_NOT_FOUND",Y8="INVALID_PARAMS",Gl="INTERNAL_ERROR",rc="SERVER_ERROR",X8=[-32700,-32600,-32601,-32602,-32603],Bs={[W8]:{code:-32700,message:"Parse error"},[G8]:{code:-32600,message:"Invalid Request"},[J8]:{code:-32601,message:"Method not found"},[Y8]:{code:-32602,message:"Invalid params"},[Gl]:{code:-32603,message:"Internal error"},[rc]:{code:-32e3,message:"Server error"}},Jl=rc;function Z8(t){return X8.includes(t)}function Yl(t){return Object.keys(Bs).includes(t)?Bs[t]:Bs[Jl]}function Q8(t){const e=Object.values(Bs).find(r=>r.code===t);return e||Bs[Jl]}function e5(t,e,r){return t.message.includes("getaddrinfo ENOTFOUND")||t.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${e}`):t}var Xl={};/*! *****************************************************************************
24
+ Approved: ${a.toString()}`)),Object.keys(e).forEach(d=>{if(!d.includes(":")||i)return;const g=Jn(e[d].accounts);g.includes(d)||(i=H("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${d}
25
+ Required: ${d}
26
+ Approved: ${g.toString()}`))}),o.forEach(d=>{i||(Yi(n[d].methods,s[d].methods)?Yi(n[d].events,s[d].events)||(i=H("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${d}`)):i=H("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${d}`))}),i}function f_(t){const e={};return Object.keys(t).forEach(r=>{var i;r.includes(":")?e[r]=t[r]:(i=t[r].chains)==null||i.forEach(n=>{e[n]={methods:t[r].methods,events:t[r].events}})}),e}function $p(t){return[...new Set(t.map(e=>e.includes(":")?e.split(":")[0]:e))]}function u_(t){const e={};return Object.keys(t).forEach(r=>{r.includes(":")?e[r]=t[r]:Jn(t[r].accounts)?.forEach(n=>{e[n]={accounts:t[r].accounts.filter(s=>s.includes(`${n}:`)),methods:t[r].methods,events:t[r].events}})}),e}function h_(t,e){return Kf(t,!1)&&t<=e.max&&t>=e.min}function Op(){const t=Ds();return new Promise(e=>{switch(t){case Zt.browser:e(d_());break;case Zt.reactNative:e(l_());break;case Zt.node:e(p_());break;default:e(!0)}})}function d_(){return As()&&navigator?.onLine}async function l_(){return xi()&&typeof global<"u"&&global!=null&&global.NetInfo?(await(global==null?void 0:global.NetInfo.fetch()))?.isConnected:!0}function p_(){return!0}function g_(t){switch(Ds()){case Zt.browser:b_(t);break;case Zt.reactNative:y_(t);break}}function b_(t){!xi()&&As()&&(window.addEventListener("online",()=>t(!0)),window.addEventListener("offline",()=>t(!1)))}function y_(t){xi()&&typeof global<"u"&&global!=null&&global.NetInfo&&global?.NetInfo.addEventListener(e=>t(e?.isConnected))}const Hf={};class qs{static get(e){return Hf[e]}static set(e,r){Hf[e]=r}static delete(e){delete Hf[e]}}const v_="PARSE_ERROR",m_="INVALID_REQUEST",w_="METHOD_NOT_FOUND",__="INVALID_PARAMS",Mp="INTERNAL_ERROR",Wf="SERVER_ERROR",x_=[-32700,-32600,-32601,-32602,-32603],zs={[v_]:{code:-32700,message:"Parse error"},[m_]:{code:-32600,message:"Invalid Request"},[w_]:{code:-32601,message:"Method not found"},[__]:{code:-32602,message:"Invalid params"},[Mp]:{code:-32603,message:"Internal error"},[Wf]:{code:-32e3,message:"Server error"}},Pp=Wf;function E_(t){return x_.includes(t)}function Rp(t){return Object.keys(zs).includes(t)?zs[t]:zs[Pp]}function S_(t){const e=Object.values(zs).find(r=>r.code===t);return e||zs[Pp]}function I_(t,e,r){return t.message.includes("getaddrinfo ENOTFOUND")||t.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${e}`):t}var Tp={};/*! *****************************************************************************
31
27
  Copyright (c) Microsoft Corporation.
32
28
 
33
29
  Permission to use, copy, modify, and/or distribute this software for any
@@ -40,5 +36,5 @@ ${t.length}`,r=new TextEncoder().encode(e+t);return"0x"+Buffer.from(N6(r)).toStr
40
36
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
41
37
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
42
38
  PERFORMANCE OF THIS SOFTWARE.
43
- ***************************************************************************** */var ic=function(t,e){return ic=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var n in i)i.hasOwnProperty(n)&&(r[n]=i[n])},ic(t,e)};function t5(t,e){ic(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var nc=function(){return nc=Object.assign||function(e){for(var r,i=1,n=arguments.length;i<n;i++){r=arguments[i];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},nc.apply(this,arguments)};function r5(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]]);return r}function i5(t,e,r,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(n<3?o(s):n>3?o(e,r,s):o(e,r))||s);return n>3&&s&&Object.defineProperty(e,r,s),s}function n5(t,e){return function(r,i){e(r,i,t)}}function s5(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function o5(t,e,r,i){function n(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(l){try{h(i.next(l))}catch(y){o(y)}}function c(l){try{h(i.throw(l))}catch(y){o(y)}}function h(l){l.done?s(l.value):n(l.value).then(a,c)}h((i=i.apply(t,e||[])).next())})}function a5(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(h){return function(l){return c([h,l])}}function c(h){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,n&&(s=h[0]&2?n.return:h[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,h[1])).done)return s;switch(n=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return r.label++,{value:h[1],done:!1};case 5:r.label++,n=h[1],h=[0];continue;case 7:h=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){r=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){r.label=h[1];break}if(h[0]===6&&r.label<s[1]){r.label=s[1],s=h;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(h);break}s[2]&&r.ops.pop(),r.trys.pop();continue}h=e.call(t,r)}catch(l){h=[6,l],n=0}finally{i=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function f5(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}function c5(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function sc(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Zl(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var i=r.call(t),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function h5(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Zl(arguments[e]));return t}function u5(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var i=Array(t),n=0,e=0;e<r;e++)for(var s=arguments[e],o=0,a=s.length;o<a;o++,n++)i[n]=s[o];return i}function Ls(t){return this instanceof Ls?(this.v=t,this):new Ls(t)}function d5(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=r.apply(t,e||[]),n,s=[];return n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n;function o(M){i[M]&&(n[M]=function(I){return new Promise(function(S,D){s.push([M,I,S,D])>1||a(M,I)})})}function a(M,I){try{c(i[M](I))}catch(S){y(s[0][3],S)}}function c(M){M.value instanceof Ls?Promise.resolve(M.value.v).then(h,l):y(s[0][2],M)}function h(M){a("next",M)}function l(M){a("throw",M)}function y(M,I){M(I),s.shift(),s.length&&a(s[0][0],s[0][1])}}function l5(t){var e,r;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,s){e[n]=t[n]?function(o){return(r=!r)?{value:Ls(t[n](o)),done:n==="return"}:s?s(o):o}:s}}function p5(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof sc=="function"?sc(t):t[Symbol.iterator](),r={},i("next"),i("throw"),i("return"),r[Symbol.asyncIterator]=function(){return this},r);function i(s){r[s]=t[s]&&function(o){return new Promise(function(a,c){o=t[s](o),n(a,c,o.done,o.value)})}}function n(s,o,a,c){Promise.resolve(c).then(function(h){s({value:h,done:a})},o)}}function g5(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function b5(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function v5(t){return t&&t.__esModule?t:{default:t}}function y5(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function m5(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}var w5=Object.freeze({__proto__:null,__extends:t5,get __assign(){return nc},__rest:r5,__decorate:i5,__param:n5,__metadata:s5,__awaiter:o5,__generator:a5,__createBinding:f5,__exportStar:c5,__values:sc,__read:Zl,__spread:h5,__spreadArrays:u5,__await:Ls,__asyncGenerator:d5,__asyncDelegator:l5,__asyncValues:p5,__makeTemplateObject:g5,__importStar:b5,__importDefault:v5,__classPrivateFieldGet:y5,__classPrivateFieldSet:m5}),_5=ha(w5),yi={},Ql;function x5(){if(Ql)return yi;Ql=1,Object.defineProperty(yi,"__esModule",{value:!0}),yi.isBrowserCryptoAvailable=yi.getSubtleCrypto=yi.getBrowerCrypto=void 0;function t(){return Nt?.crypto||Nt?.msCrypto||{}}yi.getBrowerCrypto=t;function e(){const i=t();return i.subtle||i.webkitSubtle}yi.getSubtleCrypto=e;function r(){return!!t()&&!!e()}return yi.isBrowserCryptoAvailable=r,yi}var mi={},e0;function E5(){if(e0)return mi;e0=1,Object.defineProperty(mi,"__esModule",{value:!0}),mi.isBrowser=mi.isNode=mi.isReactNative=void 0;function t(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}mi.isReactNative=t;function e(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}mi.isNode=e;function r(){return!t()&&!e()}return mi.isBrowser=r,mi}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=_5;e.__exportStar(x5(),t),e.__exportStar(E5(),t)})(Xl);function wi(t=3){const e=Date.now()*Math.pow(10,t),r=Math.floor(Math.random()*Math.pow(10,t));return e+r}function bn(t=6){return BigInt(wi(t))}function vn(t,e,r){return{id:r||wi(),jsonrpc:"2.0",method:t,params:e}}function oc(t,e){return{id:t,jsonrpc:"2.0",result:e}}function ac(t,e,r){return{id:t,jsonrpc:"2.0",error:S5(e,r)}}function S5(t,e){return typeof t>"u"?Yl(Gl):(typeof t=="string"&&(t=Object.assign(Object.assign({},Yl(rc)),{message:t})),typeof e<"u"&&(t.data=e),Z8(t.code)&&(t=Q8(t.code)),t)}class M5{}class I5 extends M5{constructor(){super()}}class A5 extends I5{constructor(e){super()}}const D5="^wss?:";function O5(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function P5(t,e){const r=O5(t);return typeof r>"u"?!1:new RegExp(e).test(r)}function t0(t){return P5(t,D5)}function R5(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function r0(t){return typeof t=="object"&&"id"in t&&"jsonrpc"in t&&t.jsonrpc==="2.0"}function fc(t){return r0(t)&&"method"in t}function ea(t){return r0(t)&&(ii(t)||Ar(t))}function ii(t){return"result"in t}function Ar(t){return"error"in t}class $5 extends A5{constructor(e){super(e),this.events=new jt.exports.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async request(e,r){return this.requestStrict(vn(e.method,e.params||[],e.id||bn().toString()),r)}async requestStrict(e,r){return new Promise(async(i,n)=>{if(!this.connection.connected)try{await this.open()}catch(s){n(s)}this.events.on(`${e.id}`,s=>{Ar(s)?n(s.error):i(s.result)});try{await this.connection.send(e,r)}catch(s){n(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),ea(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}}const N5=()=>typeof WebSocket<"u"?WebSocket:typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),T5=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",i0=t=>t.split("?")[0],n0=10,F5=N5();class C5{constructor(e){if(this.url=e,this.events=new jt.exports.EventEmitter,this.registering=!1,!t0(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,r)=>{if(typeof this.socket>"u"){r(new Error("Connection already closed"));return}this.socket.onclose=i=>{this.onClose(i),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(tn(e))}catch(r){this.onError(e.id,r)}}register(e=this.url){if(!t0(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((i,n)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),n(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return n(new Error("WebSocket connection is missing or invalid"));i(this.socket)})})}return this.url=e,this.registering=!0,new Promise((r,i)=>{const n=Xl.isReactNative()?void 0:{rejectUnauthorized:!R5(e)},s=new F5(e,[],n);T5()?s.onerror=o=>{const a=o;i(this.emitError(a.error))}:s.on("error",o=>{i(this.emitError(o))}),s.onopen=()=>{this.onOpen(s),r(s)}})}onOpen(e){e.onmessage=r=>this.onPayload(r),e.onclose=r=>this.onClose(r),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;const r=typeof e.data=="string"?An(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const i=this.parseError(r),n=i.message||i.toString(),s=ac(e,n);this.events.emit("payload",s)}parseError(e,r=this.url){return e5(e,i0(r),"WS")}resetMaxListeners(){this.events.getMaxListeners()>n0&&this.events.setMaxListeners(n0)}emitError(e){const r=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${i0(this.url)}`));return this.events.emit("register_error",r),r}}var cc={exports:{}};(function(t,e){var r=200,i="__lodash_hash_undefined__",n=1,s=2,o=9007199254740991,a="[object Arguments]",c="[object Array]",h="[object AsyncFunction]",l="[object Boolean]",y="[object Date]",M="[object Error]",I="[object Function]",S="[object GeneratorFunction]",D="[object Map]",R="[object Number]",$="[object Null]",T="[object Object]",C="[object Promise]",L="[object Proxy]",k="[object RegExp]",j="[object Set]",G="[object String]",K="[object Symbol]",V="[object Undefined]",re="[object WeakMap]",O="[object ArrayBuffer]",g="[object DataView]",p="[object Float32Array]",f="[object Float64Array]",u="[object Int8Array]",b="[object Int16Array]",_="[object Int32Array]",E="[object Uint8Array]",w="[object Uint8ClampedArray]",d="[object Uint16Array]",m="[object Uint32Array]",v=/[\\^$.*+?()[\]{}|]/g,A=/^\[object .+?Constructor\]$/,U=/^(?:0|[1-9]\d*)$/,x={};x[p]=x[f]=x[u]=x[b]=x[_]=x[E]=x[w]=x[d]=x[m]=!0,x[a]=x[c]=x[O]=x[l]=x[g]=x[y]=x[M]=x[I]=x[D]=x[R]=x[T]=x[k]=x[j]=x[G]=x[re]=!1;var N=typeof Nt=="object"&&Nt&&Nt.Object===Object&&Nt,B=typeof self=="object"&&self&&self.Object===Object&&self,q=N||B||Function("return this")(),z=e&&!e.nodeType&&e,J=z&&!0&&t&&!t.nodeType&&t,X=J&&J.exports===z,W=X&&N.process,ne=function(){try{return W&&W.binding&&W.binding("util")}catch{}}(),Q=ne&&ne.isTypedArray;function ee(P,F){for(var H=-1,te=P==null?0:P.length,ut=0,we=[];++H<te;){var bt=P[H];F(bt,H,P)&&(we[ut++]=bt)}return we}function qe(P,F){for(var H=-1,te=F.length,ut=P.length;++H<te;)P[ut+H]=F[H];return P}function Ue(P,F){for(var H=-1,te=P==null?0:P.length;++H<te;)if(F(P[H],H,P))return!0;return!1}function he(P,F){for(var H=-1,te=Array(P);++H<P;)te[H]=F(H);return te}function Pe(P){return function(F){return P(F)}}function Re(P,F){return P.has(F)}function ae(P,F){return P?.[F]}function $e(P){var F=-1,H=Array(P.size);return P.forEach(function(te,ut){H[++F]=[ut,te]}),H}function Ne(P,F){return function(H){return P(F(H))}}function ce(P){var F=-1,H=Array(P.size);return P.forEach(function(te){H[++F]=te}),H}var Te=Array.prototype,Fe=Function.prototype,oe=Object.prototype,De=q["__core-js_shared__"],Ce=Fe.toString,ie=oe.hasOwnProperty,Ve=function(){var P=/[^.]+$/.exec(De&&De.keys&&De.keys.IE_PROTO||"");return P?"Symbol(src)_1."+P:""}(),He=oe.toString,pe=RegExp("^"+Ce.call(ie).replace(v,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),We=X?q.Buffer:void 0,Be=q.Symbol,de=q.Uint8Array,Ge=oe.propertyIsEnumerable,Xe=Te.splice,se=Be?Be.toStringTag:void 0,Je=Object.getOwnPropertySymbols,Ze=We?We.isBuffer:void 0,ge=Ne(Object.keys,Object),ze=rs(q,"DataView"),Oe=rs(q,"Map"),ue=rs(q,"Promise"),ke=rs(q,"Set"),je=rs(q,"WeakMap"),fe=rs(Object,"create"),Qe=xn(ze),et=xn(Oe),be=xn(ue),tt=xn(ke),rt=xn(je),le=Be?Be.prototype:void 0,Ke=le?le.valueOf:void 0;function Ae(P){var F=-1,H=P==null?0:P.length;for(this.clear();++F<H;){var te=P[F];this.set(te[0],te[1])}}function ve(){this.__data__=fe?fe(null):{},this.size=0}function it(P){var F=this.has(P)&&delete this.__data__[P];return this.size-=F?1:0,F}function nt(P){var F=this.__data__;if(fe){var H=F[P];return H===i?void 0:H}return ie.call(F,P)?F[P]:void 0}function ye(P){var F=this.__data__;return fe?F[P]!==void 0:ie.call(F,P)}function st(P,F){var H=this.__data__;return this.size+=this.has(P)?0:1,H[P]=fe&&F===void 0?i:F,this}Ae.prototype.clear=ve,Ae.prototype.delete=it,Ae.prototype.get=nt,Ae.prototype.has=ye,Ae.prototype.set=st;function xe(P){var F=-1,H=P==null?0:P.length;for(this.clear();++F<H;){var te=P[F];this.set(te[0],te[1])}}function Ye(){this.__data__=[],this.size=0}function ar(P){var F=this.__data__,H=sa(F,P);if(H<0)return!1;var te=F.length-1;return H==te?F.pop():Xe.call(F,H,1),--this.size,!0}function fr(P){var F=this.__data__,H=sa(F,P);return H<0?void 0:F[H][1]}function cr(P){return sa(this.__data__,P)>-1}function hr(P,F){var H=this.__data__,te=sa(H,P);return te<0?(++this.size,H.push([P,F])):H[te][1]=F,this}xe.prototype.clear=Ye,xe.prototype.delete=ar,xe.prototype.get=fr,xe.prototype.has=cr,xe.prototype.set=hr;function wt(P){var F=-1,H=P==null?0:P.length;for(this.clear();++F<H;){var te=P[F];this.set(te[0],te[1])}}function xi(){this.size=0,this.__data__={hash:new Ae,map:new(Oe||xe),string:new Ae}}function Ei(P){var F=oa(this,P).delete(P);return this.size-=F?1:0,F}function Si(P){return oa(this,P).get(P)}function Mi(P){return oa(this,P).has(P)}function Ii(P,F){var H=oa(this,P),te=H.size;return H.set(P,F),this.size+=H.size==te?0:1,this}wt.prototype.clear=xi,wt.prototype.delete=Ei,wt.prototype.get=Si,wt.prototype.has=Mi,wt.prototype.set=Ii;function Pr(P){var F=-1,H=P==null?0:P.length;for(this.__data__=new wt;++F<H;)this.add(P[F])}function Ai(P){return this.__data__.set(P,i),this}function Di(P){return this.__data__.has(P)}Pr.prototype.add=Pr.prototype.push=Ai,Pr.prototype.has=Di;function Wt(P){var F=this.__data__=new xe(P);this.size=F.size}function Oi(){this.__data__=new xe,this.size=0}function Pi(P){var F=this.__data__,H=F.delete(P);return this.size=F.size,H}function Ri(P){return this.__data__.get(P)}function Vs(P){return this.__data__.has(P)}function Hs(P,F){var H=this.__data__;if(H instanceof xe){var te=H.__data__;if(!Oe||te.length<r-1)return te.push([P,F]),this.size=++H.size,this;H=this.__data__=new wt(te)}return H.set(P,F),this.size=H.size,this}Wt.prototype.clear=Oi,Wt.prototype.delete=Pi,Wt.prototype.get=Ri,Wt.prototype.has=Vs,Wt.prototype.set=Hs;function ix(P,F){var H=aa(P),te=!H&&yx(P),ut=!H&&!te&&xc(P),we=!H&&!te&&!ut&&dp(P),bt=H||te||ut||we,$t=bt?he(P.length,String):[],zt=$t.length;for(var dt in P)(F||ie.call(P,dt))&&!(bt&&(dt=="length"||ut&&(dt=="offset"||dt=="parent")||we&&(dt=="buffer"||dt=="byteLength"||dt=="byteOffset")||lx(dt,zt)))&&$t.push(dt);return $t}function sa(P,F){for(var H=P.length;H--;)if(fp(P[H][0],F))return H;return-1}function nx(P,F,H){var te=F(P);return aa(P)?te:qe(te,H(P))}function Ws(P){return P==null?P===void 0?V:$:se&&se in Object(P)?ux(P):vx(P)}function np(P){return Gs(P)&&Ws(P)==a}function sp(P,F,H,te,ut){return P===F?!0:P==null||F==null||!Gs(P)&&!Gs(F)?P!==P&&F!==F:sx(P,F,H,te,sp,ut)}function sx(P,F,H,te,ut,we){var bt=aa(P),$t=aa(F),zt=bt?c:Ji(P),dt=$t?c:Ji(F);zt=zt==a?T:zt,dt=dt==a?T:dt;var yr=zt==T,jr=dt==T,Gt=zt==dt;if(Gt&&xc(P)){if(!xc(F))return!1;bt=!0,yr=!1}if(Gt&&!yr)return we||(we=new Wt),bt||dp(P)?op(P,F,H,te,ut,we):cx(P,F,zt,H,te,ut,we);if(!(H&n)){var Rr=yr&&ie.call(P,"__wrapped__"),$r=jr&&ie.call(F,"__wrapped__");if(Rr||$r){var Yi=Rr?P.value():P,$i=$r?F.value():F;return we||(we=new Wt),ut(Yi,$i,H,te,we)}}return Gt?(we||(we=new Wt),hx(P,F,H,te,ut,we)):!1}function ox(P){if(!up(P)||gx(P))return!1;var F=cp(P)?pe:A;return F.test(xn(P))}function ax(P){return Gs(P)&&hp(P.length)&&!!x[Ws(P)]}function fx(P){if(!bx(P))return ge(P);var F=[];for(var H in Object(P))ie.call(P,H)&&H!="constructor"&&F.push(H);return F}function op(P,F,H,te,ut,we){var bt=H&n,$t=P.length,zt=F.length;if($t!=zt&&!(bt&&zt>$t))return!1;var dt=we.get(P);if(dt&&we.get(F))return dt==F;var yr=-1,jr=!0,Gt=H&s?new Pr:void 0;for(we.set(P,F),we.set(F,P);++yr<$t;){var Rr=P[yr],$r=F[yr];if(te)var Yi=bt?te($r,Rr,yr,F,P,we):te(Rr,$r,yr,P,F,we);if(Yi!==void 0){if(Yi)continue;jr=!1;break}if(Gt){if(!Ue(F,function($i,En){if(!Re(Gt,En)&&(Rr===$i||ut(Rr,$i,H,te,we)))return Gt.push(En)})){jr=!1;break}}else if(!(Rr===$r||ut(Rr,$r,H,te,we))){jr=!1;break}}return we.delete(P),we.delete(F),jr}function cx(P,F,H,te,ut,we,bt){switch(H){case g:if(P.byteLength!=F.byteLength||P.byteOffset!=F.byteOffset)return!1;P=P.buffer,F=F.buffer;case O:return!(P.byteLength!=F.byteLength||!we(new de(P),new de(F)));case l:case y:case R:return fp(+P,+F);case M:return P.name==F.name&&P.message==F.message;case k:case G:return P==F+"";case D:var $t=$e;case j:var zt=te&n;if($t||($t=ce),P.size!=F.size&&!zt)return!1;var dt=bt.get(P);if(dt)return dt==F;te|=s,bt.set(P,F);var yr=op($t(P),$t(F),te,ut,we,bt);return bt.delete(P),yr;case K:if(Ke)return Ke.call(P)==Ke.call(F)}return!1}function hx(P,F,H,te,ut,we){var bt=H&n,$t=ap(P),zt=$t.length,dt=ap(F),yr=dt.length;if(zt!=yr&&!bt)return!1;for(var jr=zt;jr--;){var Gt=$t[jr];if(!(bt?Gt in F:ie.call(F,Gt)))return!1}var Rr=we.get(P);if(Rr&&we.get(F))return Rr==F;var $r=!0;we.set(P,F),we.set(F,P);for(var Yi=bt;++jr<zt;){Gt=$t[jr];var $i=P[Gt],En=F[Gt];if(te)var lp=bt?te(En,$i,Gt,F,P,we):te($i,En,Gt,P,F,we);if(!(lp===void 0?$i===En||ut($i,En,H,te,we):lp)){$r=!1;break}Yi||(Yi=Gt=="constructor")}if($r&&!Yi){var fa=P.constructor,ca=F.constructor;fa!=ca&&"constructor"in P&&"constructor"in F&&!(typeof fa=="function"&&fa instanceof fa&&typeof ca=="function"&&ca instanceof ca)&&($r=!1)}return we.delete(P),we.delete(F),$r}function ap(P){return nx(P,_x,dx)}function oa(P,F){var H=P.__data__;return px(F)?H[typeof F=="string"?"string":"hash"]:H.map}function rs(P,F){var H=ae(P,F);return ox(H)?H:void 0}function ux(P){var F=ie.call(P,se),H=P[se];try{P[se]=void 0;var te=!0}catch{}var ut=He.call(P);return te&&(F?P[se]=H:delete P[se]),ut}var dx=Je?function(P){return P==null?[]:(P=Object(P),ee(Je(P),function(F){return Ge.call(P,F)}))}:xx,Ji=Ws;(ze&&Ji(new ze(new ArrayBuffer(1)))!=g||Oe&&Ji(new Oe)!=D||ue&&Ji(ue.resolve())!=C||ke&&Ji(new ke)!=j||je&&Ji(new je)!=re)&&(Ji=function(P){var F=Ws(P),H=F==T?P.constructor:void 0,te=H?xn(H):"";if(te)switch(te){case Qe:return g;case et:return D;case be:return C;case tt:return j;case rt:return re}return F});function lx(P,F){return F=F??o,!!F&&(typeof P=="number"||U.test(P))&&P>-1&&P%1==0&&P<F}function px(P){var F=typeof P;return F=="string"||F=="number"||F=="symbol"||F=="boolean"?P!=="__proto__":P===null}function gx(P){return!!Ve&&Ve in P}function bx(P){var F=P&&P.constructor,H=typeof F=="function"&&F.prototype||oe;return P===H}function vx(P){return He.call(P)}function xn(P){if(P!=null){try{return Ce.call(P)}catch{}try{return P+""}catch{}}return""}function fp(P,F){return P===F||P!==P&&F!==F}var yx=np(function(){return arguments}())?np:function(P){return Gs(P)&&ie.call(P,"callee")&&!Ge.call(P,"callee")},aa=Array.isArray;function mx(P){return P!=null&&hp(P.length)&&!cp(P)}var xc=Ze||Ex;function wx(P,F){return sp(P,F)}function cp(P){if(!up(P))return!1;var F=Ws(P);return F==I||F==S||F==h||F==L}function hp(P){return typeof P=="number"&&P>-1&&P%1==0&&P<=o}function up(P){var F=typeof P;return P!=null&&(F=="object"||F=="function")}function Gs(P){return P!=null&&typeof P=="object"}var dp=Q?Pe(Q):ax;function _x(P){return mx(P)?ix(P):fx(P)}function xx(){return[]}function Ex(){return!1}t.exports=wx})(cc,cc.exports);var B5=cc.exports;const s0="wc",o0=2,ta="core",ni=`${s0}@2:${ta}:`,L5={name:ta,logger:"error"},q5={database:":memory:"},U5="crypto",a0="client_ed25519_seed",z5=Y.ONE_DAY,k5="keychain",j5="0.3",K5="messages",V5="0.3",f0=Y.SIX_HOURS,H5="publisher",c0="irn",W5="error",h0="wss://relay.walletconnect.org",G5="relayer",Pt={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},J5="_subscription",Dr={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},Y5=.1,hc="2.18.0",ht={link_mode:"link_mode",relay:"relay"},X5="0.3",Z5="WALLETCONNECT_CLIENT_ID",u0="WALLETCONNECT_LINK_MODE_APPS",vr={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},Q5="subscription",e9="0.3",t9=Y.FIVE_SECONDS*1e3,r9="pairing",i9="0.3",qs={wc_pairingDelete:{req:{ttl:Y.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:Y.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:Y.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:Y.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:Y.ONE_DAY,prompt:!1,tag:0},res:{ttl:Y.ONE_DAY,prompt:!1,tag:0}}},yn={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Ur={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},n9="history",s9="0.3",o9="expirer",Or={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},a9="0.3",f9="verify-api",c9="https://verify.walletconnect.com",d0="https://verify.walletconnect.org",Us=d0,h9=`${Us}/v3`,u9=[c9,d0],d9="echo",l9="https://echo.walletconnect.com",si={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},_i={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},zr={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},mn={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},wn={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},zs={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},p9=.1,g9="event-client",b9=86400,v9="https://pulse.walletconnect.org/batch";function y9(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=n}var a=t.length,c=t.charAt(0),h=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function y(S){if(S instanceof Uint8Array||(ArrayBuffer.isView(S)?S=new Uint8Array(S.buffer,S.byteOffset,S.byteLength):Array.isArray(S)&&(S=Uint8Array.from(S))),!(S instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(S.length===0)return"";for(var D=0,R=0,$=0,T=S.length;$!==T&&S[$]===0;)$++,D++;for(var C=(T-$)*l+1>>>0,L=new Uint8Array(C);$!==T;){for(var k=S[$],j=0,G=C-1;(k!==0||j<R)&&G!==-1;G--,j++)k+=256*L[G]>>>0,L[G]=k%a>>>0,k=k/a>>>0;if(k!==0)throw new Error("Non-zero carry");R=j,$++}for(var K=C-R;K!==C&&L[K]===0;)K++;for(var V=c.repeat(D);K<C;++K)V+=t.charAt(L[K]);return V}function M(S){if(typeof S!="string")throw new TypeError("Expected String");if(S.length===0)return new Uint8Array;var D=0;if(S[D]!==" "){for(var R=0,$=0;S[D]===c;)R++,D++;for(var T=(S.length-D)*h+1>>>0,C=new Uint8Array(T);S[D];){var L=r[S.charCodeAt(D)];if(L===255)return;for(var k=0,j=T-1;(L!==0||k<$)&&j!==-1;j--,k++)L+=a*C[j]>>>0,C[j]=L%256>>>0,L=L/256>>>0;if(L!==0)throw new Error("Non-zero carry");$=k,D++}if(S[D]!==" "){for(var G=T-$;G!==T&&C[G]===0;)G++;for(var K=new Uint8Array(R+(T-G)),V=R;G!==T;)K[V++]=C[G++];return K}}}function I(S){var D=M(S);if(D)return D;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:M,decode:I}}var m9=y9,w9=m9;const l0=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},_9=t=>new TextEncoder().encode(t),x9=t=>new TextDecoder().decode(t);class E9{constructor(e,r,i){this.name=e,this.prefix=r,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class S9{constructor(e,r,i){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return p0(this,e)}}class M9{constructor(e){this.decoders=e}or(e){return p0(this,e)}decode(e){const r=e[0],i=this.decoders[r];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const p0=(t,e)=>new M9({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class I9{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new E9(e,r,i),this.decoder=new S9(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const ra=({name:t,prefix:e,encode:r,decode:i})=>new I9(t,e,r,i),ks=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=w9(r,e);return ra({prefix:t,name:e,encode:i,decode:s=>l0(n(s))})},A9=(t,e,r,i)=>{const n={};for(let l=0;l<e.length;++l)n[e[l]]=l;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,h=0;for(let l=0;l<s;++l){const y=n[t[l]];if(y===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<r|y,a+=r,a>=8&&(a-=8,o[h++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},D9=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>r;)o-=r,s+=e[n&a>>o];if(o&&(s+=e[n&a<<r-o]),i)for(;s.length*r&7;)s+="=";return s},Ut=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>ra({prefix:e,name:t,encode(n){return D9(n,i,r)},decode(n){return A9(n,i,r,t)}}),O9=ra({prefix:"\0",name:"identity",encode:t=>x9(t),decode:t=>_9(t)});var P9=Object.freeze({__proto__:null,identity:O9});const R9=Ut({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var $9=Object.freeze({__proto__:null,base2:R9});const N9=Ut({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var T9=Object.freeze({__proto__:null,base8:N9});const F9=ks({prefix:"9",name:"base10",alphabet:"0123456789"});var C9=Object.freeze({__proto__:null,base10:F9});const B9=Ut({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),L9=Ut({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var q9=Object.freeze({__proto__:null,base16:B9,base16upper:L9});const U9=Ut({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),z9=Ut({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),k9=Ut({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),j9=Ut({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),K9=Ut({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),V9=Ut({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),H9=Ut({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),W9=Ut({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),G9=Ut({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var J9=Object.freeze({__proto__:null,base32:U9,base32upper:z9,base32pad:k9,base32padupper:j9,base32hex:K9,base32hexupper:V9,base32hexpad:H9,base32hexpadupper:W9,base32z:G9});const Y9=ks({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),X9=ks({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Z9=Object.freeze({__proto__:null,base36:Y9,base36upper:X9});const Q9=ks({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),e7=ks({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var t7=Object.freeze({__proto__:null,base58btc:Q9,base58flickr:e7});const r7=Ut({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),i7=Ut({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),n7=Ut({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),s7=Ut({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var o7=Object.freeze({__proto__:null,base64:r7,base64pad:i7,base64url:n7,base64urlpad:s7});const g0=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),a7=g0.reduce((t,e,r)=>(t[r]=e,t),[]),f7=g0.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function c7(t){return t.reduce((e,r)=>(e+=a7[r],e),"")}function h7(t){const e=[];for(const r of t){const i=f7[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const u7=ra({prefix:"\u{1F680}",name:"base256emoji",encode:c7,decode:h7});var d7=Object.freeze({__proto__:null,base256emoji:u7}),l7=v0,b0=128,p7=127,g7=~p7,b7=Math.pow(2,31);function v0(t,e,r){e=e||[],r=r||0;for(var i=r;t>=b7;)e[r++]=t&255|b0,t/=128;for(;t&g7;)e[r++]=t&255|b0,t>>>=7;return e[r]=t|0,v0.bytes=r-i+1,e}var v7=uc,y7=128,y0=127;function uc(t,i){var r=0,i=i||0,n=0,s=i,o,a=t.length;do{if(s>=a)throw uc.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=n<28?(o&y0)<<n:(o&y0)*Math.pow(2,n),n+=7}while(o>=y7);return uc.bytes=s-i,r}var m7=Math.pow(2,7),w7=Math.pow(2,14),_7=Math.pow(2,21),x7=Math.pow(2,28),E7=Math.pow(2,35),S7=Math.pow(2,42),M7=Math.pow(2,49),I7=Math.pow(2,56),A7=Math.pow(2,63),D7=function(t){return t<m7?1:t<w7?2:t<_7?3:t<x7?4:t<E7?5:t<S7?6:t<M7?7:t<I7?8:t<A7?9:10},O7={encode:l7,decode:v7,encodingLength:D7},m0=O7;const w0=(t,e,r=0)=>(m0.encode(t,e,r),e),_0=t=>m0.encodingLength(t),dc=(t,e)=>{const r=e.byteLength,i=_0(t),n=i+_0(r),s=new Uint8Array(n+r);return w0(t,s,0),w0(r,s,i),s.set(e,n),new P7(t,r,e,s)};class P7{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const x0=({name:t,code:e,encode:r})=>new R7(t,e,r);class R7{constructor(e,r,i){this.name=e,this.code=r,this.encode=i}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?dc(this.code,r):r.then(i=>dc(this.code,i))}else throw Error("Unknown type, must be binary type")}}const E0=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),$7=x0({name:"sha2-256",code:18,encode:E0("SHA-256")}),N7=x0({name:"sha2-512",code:19,encode:E0("SHA-512")});var T7=Object.freeze({__proto__:null,sha256:$7,sha512:N7});const S0=0,F7="identity",M0=l0;var C7=Object.freeze({__proto__:null,identity:{code:S0,name:F7,encode:M0,digest:t=>dc(S0,M0(t))}});new TextEncoder,new TextDecoder;const I0={...P9,...$9,...T9,...C9,...q9,...J9,...Z9,...t7,...o7,...d7};({...T7,...C7});function B7(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function A0(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const D0=A0("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),lc=A0("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=B7(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),L7={utf8:D0,"utf-8":D0,hex:I0.base16,latin1:lc,ascii:lc,binary:lc,...I0};function q7(t,e="utf8"){const r=L7[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t,"utf8"):r.decoder.decode(`${r.prefix}${t}`)}class U7{constructor(e,r){this.core=e,this.logger=r,this.keychain=new Map,this.name=k5,this.version=j5,this.initialized=!1,this.storagePrefix=ni,this.init=async()=>{if(!this.initialized){const i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}},this.has=i=>(this.isInitialized(),this.keychain.has(i)),this.set=async(i,n)=>{this.isInitialized(),this.keychain.set(i,n),await this.persist()},this.get=i=>{this.isInitialized();const n=this.keychain.get(i);if(typeof n>"u"){const{message:s}=Z("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(s)}return n},this.del=async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()},this.core=e,this.logger=Jt(r,this.name)}get context(){return tr(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,Bd(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Ld(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=Z("NOT_INITIALIZED",this.name);throw new Error(e)}}}class z7{constructor(e,r,i){this.core=e,this.logger=r,this.name=U5,this.randomSessionIdentifier=Zf(),this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=n=>(this.isInitialized(),this.keychain.has(n)),this.getClientId=async()=>{this.isInitialized();const n=await this.getClientSeed(),s=Zh(n);return Xh(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const n=X4();return this.setPrivateKey(n.publicKey,n.privateKey)},this.signJWT=async n=>{this.isInitialized();const s=await this.getClientSeed(),o=Zh(s),a=this.randomSessionIdentifier;return await oy(a,n,z5,o)},this.generateSharedKey=(n,s,o)=>{this.isInitialized();const a=this.getPrivateKey(n),c=Z4(a,s);return this.setSymKey(c,o)},this.setSymKey=async(n,s)=>{this.isInitialized();const o=s||Go(n);return await this.keychain.set(o,n),o},this.deleteKeyPair=async n=>{this.isInitialized(),await this.keychain.del(n)},this.deleteSymKey=async n=>{this.isInitialized(),await this.keychain.del(n)},this.encode=async(n,s,o)=>{this.isInitialized();const a=Fl(o),c=tn(s);if(Bl(a))return t8(c,o?.encoding);if(Cl(a)){const M=a.senderPublicKey,I=a.receiverPublicKey;n=await this.generateSharedKey(M,I)}const h=this.getSymKey(n),{type:l,senderPublicKey:y}=a;return Q4({type:l,symKey:h,message:c,senderPublicKey:y,encoding:o?.encoding})},this.decode=async(n,s,o)=>{this.isInitialized();const a=i8(s,o);if(Bl(a)){const c=r8(s,o?.encoding);return An(c)}if(Cl(a)){const c=a.receiverPublicKey,h=a.senderPublicKey;n=await this.generateSharedKey(c,h)}try{const c=this.getSymKey(n),h=e8({symKey:c,encoded:s,encoding:o?.encoding});return An(h)}catch(c){this.logger.error(`Failed to decode message from topic: '${n}', clientId: '${await this.getClientId()}'`),this.logger.error(c)}},this.getPayloadType=(n,s=Gi)=>{const o=Ts({encoded:n,encoding:s});return gn(o.type)},this.getPayloadSenderPublicKey=(n,s=Gi)=>{const o=Ts({encoded:n,encoding:s});return o.senderPublicKey?Zt(o.senderPublicKey,Ht):void 0},this.core=e,this.logger=Jt(r,this.name),this.keychain=i||new U7(this.core,this.logger)}get context(){return tr(this.logger)}async setPrivateKey(e,r){return await this.keychain.set(e,r),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(a0)}catch{e=Zf(),await this.keychain.set(a0,e)}return q7(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=Z("NOT_INITIALIZED",this.name);throw new Error(e)}}}class k7 extends ag{constructor(e,r){super(e,r),this.logger=e,this.core=r,this.messages=new Map,this.name=K5,this.version=V5,this.initialized=!1,this.storagePrefix=ni,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i)}finally{this.initialized=!0}}},this.set=async(i,n)=>{this.isInitialized();const s=vi(n);let o=this.messages.get(i);return typeof o>"u"&&(o={}),typeof o[s]<"u"||(o[s]=n,this.messages.set(i,o),await this.persist()),s},this.get=i=>{this.isInitialized();let n=this.messages.get(i);return typeof n>"u"&&(n={}),n},this.has=(i,n)=>{this.isInitialized();const s=this.get(i),o=vi(n);return typeof s[o]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()},this.logger=Jt(e,this.name),this.core=r}get context(){return tr(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,Bd(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Ld(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=Z("NOT_INITIALIZED",this.name);throw new Error(e)}}}var j7=Object.defineProperty,K7=Object.defineProperties,V7=Object.getOwnPropertyDescriptors,O0=Object.getOwnPropertySymbols,H7=Object.prototype.hasOwnProperty,W7=Object.prototype.propertyIsEnumerable,P0=(t,e,r)=>e in t?j7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,R0=(t,e)=>{for(var r in e||(e={}))H7.call(e,r)&&P0(t,r,e[r]);if(O0)for(var r of O0(e))W7.call(e,r)&&P0(t,r,e[r]);return t},$0=(t,e)=>K7(t,V7(e));class G7 extends fg{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.events=new jt.exports.EventEmitter,this.name=H5,this.queue=new Map,this.publishTimeout=Y.toMiliseconds(Y.ONE_MINUTE),this.initialPublishTimeout=Y.toMiliseconds(Y.ONE_SECOND*15),this.needsTransportRestart=!1,this.publish=async(i,n,s)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:n,opts:s}});const a=s?.ttl||f0,c=Jo(s),h=s?.prompt||!1,l=s?.tag||0,y=s?.id||bn().toString(),M={topic:i,message:n,opts:{ttl:a,relay:c,prompt:h,tag:l,id:y,attestation:s?.attestation}},I=`Failed to publish payload, please try again. id:${y} tag:${l}`;try{const S=new Promise(async D=>{const R=({id:T})=>{M.opts.id===T&&(this.removeRequestFromQueue(T),this.relayer.events.removeListener(Pt.publish,R),D(M))};this.relayer.events.on(Pt.publish,R);const $=ji(new Promise((T,C)=>{this.rpcPublish({topic:i,message:n,ttl:a,prompt:h,tag:l,id:y,attestation:s?.attestation}).then(T).catch(L=>{this.logger.warn(L,L?.message),C(L)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${y} tag:${l}`);try{await $,this.events.removeListener(Pt.publish,R)}catch(T){this.queue.set(y,$0(R0({},M),{attempt:1})),this.logger.warn(T,T?.message)}});this.logger.trace({type:"method",method:"publish",params:{id:y,topic:i,message:n,opts:s}}),await ji(S,this.publishTimeout,I)}catch(S){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(S),(o=s?.internal)!=null&&o.throwOnFailedPublish)throw S}finally{this.queue.delete(y)}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.relayer=e,this.logger=Jt(r,this.name),this.registerEventListeners()}get context(){return tr(this.logger)}async rpcPublish(e){var r,i,n,s;const{topic:o,message:a,ttl:c=f0,prompt:h,tag:l,id:y,attestation:M}=e,I={method:Fs(Jo().protocol).publish,params:{topic:o,message:a,ttl:c,prompt:h,tag:l,attestation:M},id:y};Qt((r=I.params)==null?void 0:r.prompt)&&((i=I.params)==null||delete i.prompt),Qt((n=I.params)==null?void 0:n.tag)&&((s=I.params)==null||delete s.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:I});const S=await this.relayer.request(I);return this.relayer.events.emit(Pt.publish,e),this.logger.debug("Successfully Published Payload"),S}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,r)=>{const i=e.attempt+1;this.queue.set(r,$0(R0({},e),{attempt:i}));const{topic:n,message:s,opts:o,attestation:a}=e;this.logger.warn({},`Publisher: queue->publishing: ${e.opts.id}, tag: ${e.opts.tag}, attempt: ${i}`),await this.rpcPublish({topic:n,message:s,ttl:o.ttl,prompt:o.prompt,tag:o.tag,id:o.id,attestation:a}),this.logger.warn({},`Publisher: queue->published: ${e.opts.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(In.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Pt.connection_stalled);return}this.checkQueue()}),this.relayer.on(Pt.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}class J7{constructor(){this.map=new Map,this.set=(e,r)=>{const i=this.get(e);this.exists(e,r)||this.map.set(e,[...i,r])},this.get=e=>this.map.get(e)||[],this.exists=(e,r)=>this.get(e).includes(r),this.delete=(e,r)=>{if(typeof r>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const i=this.get(e);if(!this.exists(e,r))return;const n=i.filter(s=>s!==r);if(!n.length){this.map.delete(e);return}this.map.set(e,n)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var Y7=Object.defineProperty,X7=Object.defineProperties,Z7=Object.getOwnPropertyDescriptors,N0=Object.getOwnPropertySymbols,Q7=Object.prototype.hasOwnProperty,e_=Object.prototype.propertyIsEnumerable,T0=(t,e,r)=>e in t?Y7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,js=(t,e)=>{for(var r in e||(e={}))Q7.call(e,r)&&T0(t,r,e[r]);if(N0)for(var r of N0(e))e_.call(e,r)&&T0(t,r,e[r]);return t},pc=(t,e)=>X7(t,Z7(e));class t_ extends ug{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.subscriptions=new Map,this.topicMap=new J7,this.events=new jt.exports.EventEmitter,this.name=Q5,this.version=e9,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=ni,this.subscribeTimeout=Y.toMiliseconds(Y.ONE_MINUTE),this.initialSubscribeTimeout=Y.toMiliseconds(Y.ONE_SECOND*15),this.batchSubscribeTopicsLimit=500,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId(),await this.restore()),this.initialized=!0},this.subscribe=async(i,n)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}});try{const s=Jo(n),o={topic:i,relay:s,transportType:n?.transportType};this.pending.set(i,o);const a=await this.rpcSubscribe(i,s,n);return typeof a=="string"&&(this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}})),a}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}},this.unsubscribe=async(i,n)=>{await this.restartToComplete(),this.isInitialized(),typeof n?.id<"u"?await this.unsubscribeById(i,n.id,n):await this.unsubscribeByTopic(i,n)},this.isSubscribed=async i=>{if(this.topics.includes(i))return!0;const n=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((s,o)=>{const a=new Y.Watch;a.start(n);const c=setInterval(()=>{(!this.pending.has(i)&&this.topics.includes(i)||this.cached.some(h=>h.topic===i))&&(clearInterval(c),a.stop(n),s(!0)),a.elapsed(n)>=t9&&(clearInterval(c),a.stop(n),o(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.start=async()=>{await this.onConnect()},this.stop=async()=>{await this.onDisconnect()},this.restart=async()=>{await this.restore(),await this.onRestart()},this.checkPending=async()=>{if(this.pending.size===0&&(!this.initialized||!this.relayer.connected))return;const i=[];this.pending.forEach(n=>{i.push(n)}),await this.batchSubscribe(i)},this.registerEventListeners=()=>{this.relayer.core.heartbeat.on(In.pulse,async()=>{await this.checkPending()}),this.events.on(vr.created,async i=>{const n=vr.created;this.logger.info(`Emitting ${n}`),this.logger.debug({type:"event",event:n,data:i}),await this.persist()}),this.events.on(vr.deleted,async i=>{const n=vr.deleted;this.logger.info(`Emitting ${n}`),this.logger.debug({type:"event",event:n,data:i}),await this.persist()})},this.relayer=e,this.logger=Jt(r,this.name),this.clientId=""}get context(){return tr(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,r){let i=!1;try{i=this.getSubscription(e).topic===r}catch{}return i}reset(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,r){const i=this.topicMap.get(e);await Promise.all(i.map(async n=>await this.unsubscribeById(e,n,r)))}async unsubscribeById(e,r,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:i}});try{const n=Jo(i);await this.rpcUnsubscribe(e,r,n);const s=ct("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,r,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:i}})}catch(n){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(n),n}}async rpcSubscribe(e,r,i){var n;i?.transportType===ht.relay&&await this.restartToComplete();const s={method:Fs(r.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});const o=(n=i?.internal)==null?void 0:n.throwOnFailedPublish;try{const a=this.getSubscriptionId(e);if(i?.transportType===ht.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(l=>this.logger.warn(l))},Y.toMiliseconds(Y.ONE_SECOND)),a;const c=new Promise(async l=>{const y=M=>{M.topic===e&&(this.events.removeListener(vr.created,y),l(M.id))};this.events.on(vr.created,y);try{const M=await ji(new Promise((I,S)=>{this.relayer.request(s).catch(D=>{this.logger.warn(D,D?.message),S(D)}).then(I)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(vr.created,y),l(M)}catch{}}),h=await ji(c,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!h&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return h?a:null}catch(a){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Pt.connection_stalled),o)throw a}return null}async rpcBatchSubscribe(e){if(!e.length)return;const r=e[0].relay,i={method:Fs(r.protocol).batchSubscribe,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{await await ji(new Promise(n=>{this.relayer.request(i).catch(s=>this.logger.warn(s)).then(n)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(Pt.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const r=e[0].relay,i={method:Fs(r.protocol).batchFetchMessages,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let n;try{n=await await ji(new Promise((s,o)=>{this.relayer.request(i).catch(a=>{this.logger.warn(a),o(a)}).then(s)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(Pt.connection_stalled)}return n}rpcUnsubscribe(e,r,i){const n={method:Fs(i.protocol).unsubscribe,params:{topic:e,id:r}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),this.relayer.request(n)}onSubscribe(e,r){this.setSubscription(e,pc(js({},r),{id:e})),this.pending.delete(r.topic)}onBatchSubscribe(e){e.length&&e.forEach(r=>{this.setSubscription(r.id,js({},r)),this.pending.delete(r.topic)})}async onUnsubscribe(e,r,i){this.events.removeAllListeners(r),this.hasSubscription(r,e)&&this.deleteSubscription(r,i),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,r){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:r}),this.addSubscription(e,r)}addSubscription(e,r){this.subscriptions.set(e,js({},r)),this.topicMap.set(r.topic,e),this.events.emit(vr.created,r)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const r=this.subscriptions.get(e);if(!r){const{message:i}=Z("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return r}deleteSubscription(e,r){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:r});const i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(vr.deleted,pc(js({},i),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(vr.sync)}async onRestart(){if(this.cached.length){const e=[...this.cached],r=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let i=0;i<r;i++){const n=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(n)}}this.events.emit(vr.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:r}=Z("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){e.length&&(await this.rpcBatchSubscribe(e),this.onBatchSubscribe(e.map(r=>pc(js({},r),{id:this.getSubscriptionId(r.topic)}))))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const r=await this.rpcBatchFetchMessages(e);r&&r.messages&&(await l6(Y.toMiliseconds(Y.ONE_SECOND)),await this.relayer.handleBatchMessageEvents(r.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){const{message:e}=Z("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){!this.relayer.connected&&!this.relayer.connecting&&await this.relayer.transportOpen()}getSubscriptionId(e){return vi(e+this.clientId)}}var r_=Object.defineProperty,F0=Object.getOwnPropertySymbols,i_=Object.prototype.hasOwnProperty,n_=Object.prototype.propertyIsEnumerable,C0=(t,e,r)=>e in t?r_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,B0=(t,e)=>{for(var r in e||(e={}))i_.call(e,r)&&C0(t,r,e[r]);if(F0)for(var r of F0(e))n_.call(e,r)&&C0(t,r,e[r]);return t};class s_ extends cg{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new jt.exports.EventEmitter,this.name=G5,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.hasExperiencedNetworkDisruption=!1,this.heartBeatTimeout=Y.toMiliseconds(Y.THIRTY_SECONDS+Y.FIVE_SECONDS),this.requestsInFlight=[],this.connectTimeout=Y.toMiliseconds(Y.ONE_SECOND*15),this.request=async r=>{var i,n;this.logger.debug("Publishing Request Payload");const s=r.id||bn().toString();await this.toEstablishConnection();try{this.logger.trace({id:s,method:r.method,topic:(i=r.params)==null?void 0:i.topic},"relayer.request - publishing...");const o=`${s}:${((n=r.params)==null?void 0:n.tag)||""}`;this.requestsInFlight.push(o);const a=await this.provider.request(r);return this.requestsInFlight=this.requestsInFlight.filter(c=>c!==o),a}catch(o){throw this.logger.debug(`Failed to Publish Request: ${s}`),o}},this.resetPingTimeout=()=>{if(Uo())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var r,i,n;this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),(n=(i=(r=this.provider)==null?void 0:r.connection)==null?void 0:i.socket)==null||n.terminate()},this.heartBeatTimeout)}catch(r){this.logger.warn(r,r?.message)}},this.onPayloadHandler=r=>{this.onProviderPayload(r),this.resetPingTimeout()},this.onConnectHandler=()=>{this.logger.warn({},"Relayer connected \u{1F6DC}"),this.startPingTimeout(),this.events.emit(Pt.connect)},this.onDisconnectHandler=()=>{this.logger.warn({},"Relayer disconnected \u{1F6D1}"),this.requestsInFlight=[],this.onProviderDisconnect()},this.onProviderErrorHandler=r=>{this.logger.fatal(r,`Fatal socket error: ${r?.message}`),this.events.emit(Pt.error,r),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(Dr.payload,this.onPayloadHandler),this.provider.on(Dr.connect,this.onConnectHandler),this.provider.on(Dr.disconnect,this.onDisconnectHandler),this.provider.on(Dr.error,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?Jt(e.logger,this.name):ai(Ia({level:e.logger||W5})),this.messages=new k7(this.logger,e.core),this.subscriber=new t_(this,this.logger),this.publisher=new G7(this,this.logger),this.relayUrl=e?.relayUrl||h0,this.projectId=e.projectId,Xw()?this.packageName=Td():Zw()&&(this.bundleId=Td()),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.cached.length>0)try{await this.transportOpen()}catch(e){this.logger.warn(e,e?.message)}}get context(){return tr(this.logger)}get connected(){var e,r,i;return((i=(r=(e=this.provider)==null?void 0:e.connection)==null?void 0:r.socket)==null?void 0:i.readyState)===1}get connecting(){var e,r,i;return((i=(r=(e=this.provider)==null?void 0:e.connection)==null?void 0:r.socket)==null?void 0:i.readyState)===0}async publish(e,r,i){this.isInitialized(),await this.publisher.publish(e,r,i),await this.recordMessageEvent({topic:e,message:r,publishedAt:Date.now(),transportType:ht.relay})}async subscribe(e,r){var i,n,s;this.isInitialized(),(!(r!=null&&r.transportType)||r?.transportType==="relay")&&await this.toEstablishConnection();const o=typeof((i=r?.internal)==null?void 0:i.throwOnFailedPublish)>"u"?!0:(n=r?.internal)==null?void 0:n.throwOnFailedPublish;let a=((s=this.subscriber.topicMap.get(e))==null?void 0:s[0])||"",c;const h=l=>{l.topic===e&&(this.subscriber.off(vr.created,h),c())};return await Promise.all([new Promise(l=>{c=l,this.subscriber.on(vr.created,h)}),new Promise(async(l,y)=>{a=await this.subscriber.subscribe(e,B0({internal:{throwOnFailedPublish:o}},r)).catch(M=>{o&&y(M)})||a,l()})]),a}async unsubscribe(e,r){this.isInitialized(),await this.subscriber.unsubscribe(e,r)}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await ji(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){if(this.connectPromise?(this.logger.debug({},"Waiting for existing connection attempt to resolve..."),await this.connectPromise,this.logger.debug({},"Existing connection attempt resolved")):(this.connectPromise=new Promise(async(r,i)=>{await this.connect(e).then(r).catch(i).finally(()=>{this.connectPromise=void 0})}),await this.connectPromise),!this.connected)throw new Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}async restartTransport(e){this.logger.debug({},"Restarting transport..."),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await Wl())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(e?.length===0){this.logger.trace("Batch message events is empty. Ignoring...");return}const r=e.sort((i,n)=>i.publishedAt-n.publishedAt);this.logger.debug(`Batch of ${r.length} message events sorted`);for(const i of r)try{await this.onMessageEvent(i)}catch(n){this.logger.warn(n,"Error while processing batch message event: "+n?.message)}this.logger.trace(`Batch of ${r.length} message events processed`)}async onLinkMessageEvent(e,r){const{topic:i}=e;if(!r.sessionExists){const n=Et(Y.FIVE_MINUTES),s={topic:i,expiry:n,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,s)}this.events.emit(Pt.message,e),await this.recordMessageEvent(e)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let r=1;for(;r<6;){try{this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${r}...`),await this.createProvider(),await new Promise(async(i,n)=>{const s=()=>{n(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(Dr.disconnect,s),await ji(new Promise((o,a)=>{this.provider.connect().then(o).catch(a)}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(o=>{n(o)}).finally(()=>{this.provider.off(Dr.disconnect,s),clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0}),await new Promise(async(o,a)=>{const c=()=>{a(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(Dr.disconnect,c),await this.subscriber.start().then(o).catch(a).finally(()=>{this.provider.off(Dr.disconnect,c)})}),this.hasExperiencedNetworkDisruption=!1,i()})}catch(i){await this.subscriber.stop();const n=i;this.logger.warn({},n.message),this.hasExperiencedNetworkDisruption=!0}finally{this.connectionAttemptInProgress=!1}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${r}`);break}await new Promise(i=>setTimeout(i,Y.toMiliseconds(r*1))),r++}}startPingTimeout(){var e,r,i,n,s;if(Uo())try{(r=(e=this.provider)==null?void 0:e.connection)!=null&&r.socket&&((s=(n=(i=this.provider)==null?void 0:i.connection)==null?void 0:n.socket)==null||s.on("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o,o?.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new $5(new C5(r6({sdkVersion:hc,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId,packageName:this.packageName}))),this.registerProviderListeners()}async recordMessageEvent(e){const{topic:r,message:i}=e;await this.messages.set(r,i)}async shouldIgnoreMessageEvent(e){const{topic:r,message:i}=e;if(!i||i.length===0)return this.logger.warn(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(r))return this.logger.warn(`Ignoring message for non-subscribed topic ${r}`),!0;const n=this.messages.has(r,i);return n&&this.logger.warn(`Ignoring duplicate message: ${i}`),n}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),fc(e)){if(!e.method.endsWith(J5))return;const r=e.params,{topic:i,message:n,publishedAt:s,attestation:o}=r.data,a={topic:i,message:n,publishedAt:s,transportType:ht.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(B0({type:"event",event:r.id},a)),this.events.emit(r.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else ea(e)&&this.events.emit(Pt.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Pt.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const r=oc(e.id,!0);await this.provider.connection.send(r)}unregisterProviderListeners(){this.provider.off(Dr.payload,this.onPayloadHandler),this.provider.off(Dr.connect,this.onConnectHandler),this.provider.off(Dr.disconnect,this.onDisconnectHandler),this.provider.off(Dr.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await Wl();K8(async r=>{e!==r&&(e=r,r?await this.transportOpen().catch(i=>this.logger.error(i,i?.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){await this.subscriber.stop(),clearTimeout(this.pingTimeout),this.events.emit(Pt.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||this.connectPromise||(this.reconnectTimeout=setTimeout(async()=>{clearTimeout(this.reconnectTimeout),await this.transportOpen().catch(e=>this.logger.error(e,e?.message))},Y.toMiliseconds(Y5))))}isInitialized(){if(!this.initialized){const{message:e}=Z("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&await this.transportOpen()}}var o_=Object.defineProperty,L0=Object.getOwnPropertySymbols,a_=Object.prototype.hasOwnProperty,f_=Object.prototype.propertyIsEnumerable,q0=(t,e,r)=>e in t?o_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,U0=(t,e)=>{for(var r in e||(e={}))a_.call(e,r)&&q0(t,r,e[r]);if(L0)for(var r of L0(e))f_.call(e,r)&&q0(t,r,e[r]);return t};class _n extends hg{constructor(e,r,i,n=ni,s=void 0){super(e,r,i,n),this.core=e,this.logger=r,this.name=i,this.map=new Map,this.version=X5,this.cached=[],this.initialized=!1,this.storagePrefix=ni,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!Qt(o)?this.map.set(this.getKey(o),o):_8(o)?this.map.set(o.id,o):x8(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)},this.set=async(o,a)=>{this.isInitialized(),this.map.has(o)?await this.update(o,a):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:a}),this.map.set(o,a),await this.persist())},this.get=o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o)),this.getAll=o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(c=>B5(a[c],o[c]))):this.values),this.update=async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});const c=U0(U0({},this.getData(o)),a);this.map.set(o,c),await this.persist()},this.delete=async(o,a)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:a}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())},this.logger=Jt(r,this.name),this.storagePrefix=n,this.getKey=s}get context(){return tr(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const r=this.map.get(e);if(!r){if(this.recentlyDeleted.includes(e)){const{message:n}=Z("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}const{message:i}=Z("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return r}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:r}=Z("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=Z("NOT_INITIALIZED",this.name);throw new Error(e)}}}class c_{constructor(e,r){this.core=e,this.logger=r,this.name=r9,this.version=i9,this.events=new jt.exports,this.initialized=!1,this.storagePrefix=ni,this.ignoredPayloadTypes=[bi],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]},this.create=async i=>{this.isInitialized();const n=Zf(),s=await this.core.crypto.setSymKey(n),o=Et(Y.FIVE_MINUTES),a={protocol:c0},c={topic:s,expiry:o,relay:a,active:!1,methods:i?.methods},h=ql({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:n,relay:a,expiryTimestamp:o,methods:i?.methods});return this.events.emit(yn.create,c),this.core.expirer.set(s,o),await this.pairings.set(s,c),await this.core.relayer.subscribe(s,{transportType:i?.transportType}),{topic:s,uri:h}},this.pair=async i=>{this.isInitialized();const n=this.core.eventClient.createEvent({properties:{topic:i?.uri,trace:[si.pairing_started]}});this.isValidPair(i,n);const{topic:s,symKey:o,relay:a,expiryTimestamp:c,methods:h}=Ll(i.uri);n.props.properties.topic=s,n.addTrace(si.pairing_uri_validation_success),n.addTrace(si.pairing_uri_not_expired);let l;if(this.pairings.keys.includes(s)){if(l=this.pairings.get(s),n.addTrace(si.existing_pairing),l.active)throw n.setError(_i.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);n.addTrace(si.pairing_not_expired)}const y=c||Et(Y.FIVE_MINUTES),M={topic:s,relay:a,expiry:y,active:!1,methods:h};this.core.expirer.set(s,y),await this.pairings.set(s,M),n.addTrace(si.store_new_pairing),i.activatePairing&&await this.activate({topic:s}),this.events.emit(yn.create,M),n.addTrace(si.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(o,s),n.addTrace(si.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{n.setError(_i.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:a})}catch(I){throw n.setError(_i.subscribe_pairing_topic_failure),I}return n.addTrace(si.subscribe_pairing_topic_success),M},this.activate=async({topic:i})=>{this.isInitialized();const n=Et(Y.FIVE_MINUTES);this.core.expirer.set(i,n),await this.pairings.update(i,{active:!0,expiry:n})},this.ping=async i=>{this.isInitialized(),await this.isValidPing(i),this.logger.warn("ping() is deprecated and will be removed in the next major release.");const{topic:n}=i;if(this.pairings.keys.includes(n)){const s=await this.sendRequest(n,"wc_pairingPing",{}),{done:o,resolve:a,reject:c}=ln();this.events.once(Se("pairing_ping",s),({error:h})=>{h?c(h):a()}),await o()}},this.updateExpiry=async({topic:i,expiry:n})=>{this.isInitialized(),await this.pairings.update(i,{expiry:n})},this.updateMetadata=async({topic:i,metadata:n})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:n})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async i=>{this.isInitialized(),await this.isValidDisconnect(i);const{topic:n}=i;this.pairings.keys.includes(n)&&(await this.sendRequest(n,"wc_pairingDelete",ct("USER_DISCONNECTED")),await this.deletePairing(n))},this.formatUriFromPairing=i=>{this.isInitialized();const{topic:n,relay:s,expiry:o,methods:a}=i,c=this.core.crypto.keychain.get(n);return ql({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:c,relay:s,expiryTimestamp:o,methods:a})},this.sendRequest=async(i,n,s)=>{const o=vn(n,s),a=await this.core.crypto.encode(i,o),c=qs[n].req;return this.core.history.set(i,o),this.core.relayer.publish(i,a,c),o.id},this.sendResult=async(i,n,s)=>{const o=oc(i,s),a=await this.core.crypto.encode(n,o),c=await this.core.history.get(n,i),h=qs[c.request.method].res;await this.core.relayer.publish(n,a,h),await this.core.history.resolve(o)},this.sendError=async(i,n,s)=>{const o=ac(i,s),a=await this.core.crypto.encode(n,o),c=await this.core.history.get(n,i),h=qs[c.request.method]?qs[c.request.method].res:qs.unregistered_method.res;await this.core.relayer.publish(n,a,h),await this.core.history.resolve(o)},this.deletePairing=async(i,n)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,ct("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),n?Promise.resolve():this.core.expirer.del(i)])},this.cleanup=async()=>{const i=this.pairings.getAll().filter(n=>Ki(n.expiry));await Promise.all(i.map(n=>this.deletePairing(n.topic)))},this.onRelayEventRequest=i=>{const{topic:n,payload:s}=i;switch(s.method){case"wc_pairingPing":return this.onPairingPingRequest(n,s);case"wc_pairingDelete":return this.onPairingDeleteRequest(n,s);default:return this.onUnknownRpcMethodRequest(n,s)}},this.onRelayEventResponse=async i=>{const{topic:n,payload:s}=i,o=(await this.core.history.get(n,s.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(n,s);default:return this.onUnknownRpcMethodResponse(o)}},this.onPairingPingRequest=async(i,n)=>{const{id:s}=n;try{this.isValidPing({topic:i}),await this.sendResult(s,i,!0),this.events.emit(yn.ping,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onPairingPingResponse=(i,n)=>{const{id:s}=n;setTimeout(()=>{ii(n)?this.events.emit(Se("pairing_ping",s),{}):Ar(n)&&this.events.emit(Se("pairing_ping",s),{error:n.error})},500)},this.onPairingDeleteRequest=async(i,n)=>{const{id:s}=n;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(yn.delete,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onUnknownRpcMethodRequest=async(i,n)=>{const{id:s,method:o}=n;try{if(this.registeredMethods.includes(o))return;const a=ct("WC_METHOD_UNSUPPORTED",o);await this.sendError(s,i,a),this.logger.error(a)}catch(a){await this.sendError(s,i,a),this.logger.error(a)}},this.onUnknownRpcMethodResponse=i=>{this.registeredMethods.includes(i)||this.logger.error(ct("WC_METHOD_UNSUPPORTED",i))},this.isValidPair=(i,n)=>{var s;if(!or(i)){const{message:a}=Z("MISSING_OR_INVALID",`pair() params: ${i}`);throw n.setError(_i.malformed_pairing_uri),new Error(a)}if(!w8(i.uri)){const{message:a}=Z("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw n.setError(_i.malformed_pairing_uri),new Error(a)}const o=Ll(i?.uri);if(!((s=o?.relay)!=null&&s.protocol)){const{message:a}=Z("MISSING_OR_INVALID","pair() uri#relay-protocol");throw n.setError(_i.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){const{message:a}=Z("MISSING_OR_INVALID","pair() uri#symKey");throw n.setError(_i.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&Y.toMiliseconds(o?.expiryTimestamp)<Date.now()){n.setError(_i.pairing_expired);const{message:a}=Z("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(a)}},this.isValidPing=async i=>{if(!or(i)){const{message:s}=Z("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidDisconnect=async i=>{if(!or(i)){const{message:s}=Z("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidPairingTopic=async i=>{if(!mt(i,!1)){const{message:n}=Z("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){const{message:n}=Z("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(Ki(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:n}=Z("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}},this.core=e,this.logger=Jt(r,this.name),this.pairings=new _n(this.core,this.logger,this.name,this.storagePrefix)}get context(){return tr(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=Z("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Pt.message,async e=>{const{topic:r,message:i,transportType:n}=e;if(!this.pairings.keys.includes(r)||n===ht.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;const s=await this.core.crypto.decode(r,i);try{fc(s)?(this.core.history.set(r,s),this.onRelayEventRequest({topic:r,payload:s})):ea(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:r,payload:s}),this.core.history.delete(r,s.id))}catch(o){this.logger.error(o)}})}registerExpirerEvents(){this.core.expirer.on(Or.expired,async e=>{const{topic:r}=Ud(e.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit(yn.expire,{topic:r}))})}}class h_ extends og{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.records=new Map,this.events=new jt.exports.EventEmitter,this.name=n9,this.version=s9,this.cached=[],this.initialized=!1,this.storagePrefix=ni,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(i,n,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:n,chainId:s}),this.records.has(n.id))return;const o={id:n.id,topic:i,request:{method:n.method,params:n.params||null},chainId:s,expiry:Et(Y.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(Ur.created,o)},this.resolve=async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;const n=await this.getRecord(i.id);typeof n.response>"u"&&(n.response=Ar(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.persist(),this.events.emit(Ur.updated,n))},this.get=async(i,n)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:n}),await this.getRecord(n)),this.delete=(i,n)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:n}),this.values.forEach(s=>{if(s.topic===i){if(typeof n<"u"&&s.id!==n)return;this.records.delete(s.id),this.events.emit(Ur.deleted,s)}}),this.persist()},this.exists=async(i,n)=>(this.isInitialized(),this.records.has(n)?(await this.getRecord(n)).topic===i:!1),this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=Jt(r,this.name)}get context(){return tr(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(r=>{if(typeof r.response<"u")return;const i={topic:r.topic,request:vn(r.request.method,r.request.params,r.id),chainId:r.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const r=this.records.get(e);if(!r){const{message:i}=Z("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Ur.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:r}=Z("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(Ur.created,e=>{const r=Ur.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(Ur.updated,e=>{const r=Ur.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(Ur.deleted,e=>{const r=Ur.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.core.heartbeat.on(In.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(r=>{Y.toMiliseconds(r.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${r.id}`),this.records.delete(r.id),this.events.emit(Ur.deleted,r,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=Z("NOT_INITIALIZED",this.name);throw new Error(e)}}}class u_ extends dg{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.expirations=new Map,this.events=new jt.exports.EventEmitter,this.name=o9,this.version=a9,this.cached=[],this.initialized=!1,this.storagePrefix=ni,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=i=>{try{const n=this.formatTarget(i);return typeof this.getExpiration(n)<"u"}catch{return!1}},this.set=(i,n)=>{this.isInitialized();const s=this.formatTarget(i),o={target:s,expiry:n};this.expirations.set(s,o),this.checkExpiry(s,o),this.events.emit(Or.created,{target:s,expiration:o})},this.get=i=>{this.isInitialized();const n=this.formatTarget(i);return this.getExpiration(n)},this.del=i=>{if(this.isInitialized(),this.has(i)){const n=this.formatTarget(i),s=this.getExpiration(n);this.expirations.delete(n),this.events.emit(Or.deleted,{target:n,expiration:s})}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=Jt(r,this.name)}get context(){return tr(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return i6(e);if(typeof e=="number")return n6(e);const{message:r}=Z("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(r)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Or.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:r}=Z("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const r=this.expirations.get(e);if(!r){const{message:i}=Z("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return r}checkExpiry(e,r){const{expiry:i}=r;Y.toMiliseconds(i)-Date.now()<=0&&this.expire(e,r)}expire(e,r){this.expirations.delete(e),this.events.emit(Or.expired,{target:e,expiration:r})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,r)=>this.checkExpiry(r,e))}registerEventListeners(){this.core.heartbeat.on(In.pulse,()=>this.checkExpirations()),this.events.on(Or.created,e=>{const r=Or.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(Or.expired,e=>{const r=Or.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(Or.deleted,e=>{const r=Or.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=Z("NOT_INITIALIZED",this.name);throw new Error(e)}}}class d_ extends lg{constructor(e,r,i){super(e,r,i),this.core=e,this.logger=r,this.store=i,this.name=f9,this.verifyUrlV3=h9,this.storagePrefix=ni,this.version=o0,this.init=async()=>{var n;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&Y.toMiliseconds((n=this.publicKey)==null?void 0:n.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))},this.register=async n=>{if(!Ss()||this.isDevEnv)return;const s=window.location.origin,{id:o,decryptedId:a}=n,c=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${s}&id=${o}&decryptedId=${a}`;try{const h=ds(),l=this.startAbortTimer(Y.ONE_SECOND*5),y=await new Promise((M,I)=>{const S=()=>{window.removeEventListener("message",R),h.body.removeChild(D),I("attestation aborted")};this.abortController.signal.addEventListener("abort",S);const D=h.createElement("iframe");D.src=c,D.style.display="none",D.addEventListener("error",S,{signal:this.abortController.signal});const R=$=>{if($.data&&typeof $.data=="string")try{const T=JSON.parse($.data);if(T.type==="verify_attestation"){if(Wa(T.attestation).payload.id!==o)return;clearInterval(l),h.body.removeChild(D),this.abortController.signal.removeEventListener("abort",S),window.removeEventListener("message",R),M(T.attestation===null?"":T.attestation)}}catch(T){this.logger.warn(T)}};h.body.appendChild(D),window.addEventListener("message",R,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",y),y}catch(h){this.logger.warn(h)}return""},this.resolve=async n=>{if(this.isDevEnv)return"";const{attestationId:s,hash:o,encryptedId:a}=n;if(s===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(s){if(Wa(s).payload.id!==a)return;const h=await this.isValidJwtAttestation(s);if(h){if(!h.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return h}}if(!o)return;const c=this.getVerifyUrl(n?.verifyUrl);return this.fetchAttestation(o,c)},this.fetchAttestation=async(n,s)=>{this.logger.debug(`resolving attestation: ${n} from url: ${s}`);const o=this.startAbortTimer(Y.ONE_SECOND*5),a=await fetch(`${s}/attestation/${n}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?await a.json():void 0},this.getVerifyUrl=n=>{let s=n||Us;return u9.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${Us}`),s=Us),s},this.fetchPublicKey=async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const n=this.startAbortTimer(Y.FIVE_SECONDS),s=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(n),await s.json()}catch(n){this.logger.warn(n)}},this.persistPublicKey=async n=>{this.logger.debug("persisting public key to local storage",n),await this.store.setItem(this.storeKey,n),this.publicKey=n},this.removePublicKey=async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0},this.isValidJwtAttestation=async n=>{const s=await this.getPublicKey();try{if(s)return this.validateAttestation(n,s)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}const o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(n,o)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}},this.getPublicKey=async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey(),this.fetchAndPersistPublicKey=async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async s=>{const o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),s(o))});const n=await this.fetchPromise;return this.fetchPromise=void 0,n},this.validateAttestation=(n,s)=>{const o=a8(n,s.publicKey),a={hasExpired:Y.toMiliseconds(o.exp)<Date.now(),payload:o};if(a.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:a.payload.origin,isScam:a.payload.isScam,isVerified:a.payload.isVerified}},this.logger=Jt(r,this.name),this.abortController=new AbortController,this.isDevEnv=Nf(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return tr(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),Y.toMiliseconds(e))}}class l_ extends pg{constructor(e,r){super(e,r),this.projectId=e,this.logger=r,this.context=d9,this.registerDeviceToken=async i=>{const{clientId:n,token:s,notificationType:o,enableEncrypted:a=!1}=i,c=`${l9}/${this.projectId}/clients`;await fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:n,type:o,token:s,always_raw:a})})},this.logger=Jt(r,this.context)}}var p_=Object.defineProperty,z0=Object.getOwnPropertySymbols,g_=Object.prototype.hasOwnProperty,b_=Object.prototype.propertyIsEnumerable,k0=(t,e,r)=>e in t?p_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ks=(t,e)=>{for(var r in e||(e={}))g_.call(e,r)&&k0(t,r,e[r]);if(z0)for(var r of z0(e))b_.call(e,r)&&k0(t,r,e[r]);return t};class v_ extends gg{constructor(e,r,i=!0){super(e,r,i),this.core=e,this.logger=r,this.context=g9,this.storagePrefix=ni,this.storageVersion=p9,this.events=new Map,this.shouldPersist=!1,this.init=async()=>{if(!Nf())try{const n={eventId:kd(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:Cd(this.core.relayer.protocol,this.core.relayer.version,hc)}}};await this.sendEvent([n])}catch(n){this.logger.warn(n)}},this.createEvent=n=>{const{event:s="ERROR",type:o="",properties:{topic:a,trace:c}}=n,h=kd(),l=this.core.projectId||"",y=Date.now(),M=Ks({eventId:h,timestamp:y,props:{event:s,type:o,properties:{topic:a,trace:c}},bundleId:l,domain:this.getAppDomain()},this.setMethods(h));return this.telemetryEnabled&&(this.events.set(h,M),this.shouldPersist=!0),M},this.getEvent=n=>{const{eventId:s,topic:o}=n;if(s)return this.events.get(s);const a=Array.from(this.events.values()).find(c=>c.props.properties.topic===o);if(a)return Ks(Ks({},a),this.setMethods(a.eventId))},this.deleteEvent=n=>{const{eventId:s}=n;this.events.delete(s),this.shouldPersist=!0},this.setEventListeners=()=>{this.core.heartbeat.on(In.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(n=>{Y.fromMiliseconds(Date.now())-Y.fromMiliseconds(n.timestamp)>b9&&(this.events.delete(n.eventId),this.shouldPersist=!0)})})},this.setMethods=n=>({addTrace:s=>this.addTrace(n,s),setError:s=>this.setError(n,s)}),this.addTrace=(n,s)=>{const o=this.events.get(n);o&&(o.props.properties.trace.push(s),this.events.set(n,o),this.shouldPersist=!0)},this.setError=(n,s)=>{const o=this.events.get(n);o&&(o.props.type=s,o.timestamp=Date.now(),this.events.set(n,o),this.shouldPersist=!0)},this.persist=async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1},this.restore=async()=>{try{const n=await this.core.storage.getItem(this.storageKey)||[];if(!n.length)return;n.forEach(s=>{this.events.set(s.eventId,Ks(Ks({},s),this.setMethods(s.eventId)))})}catch(n){this.logger.warn(n)}},this.submit=async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const n=[];for(const[s,o]of this.events)o.props.type&&n.push(o);if(n.length!==0)try{if((await this.sendEvent(n)).ok)for(const s of n)this.events.delete(s.eventId),this.shouldPersist=!0}catch(s){this.logger.warn(s)}},this.sendEvent=async n=>{const s=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${v9}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${hc}${s}`,{method:"POST",body:JSON.stringify(n)})},this.getAppDomain=()=>Fd().url,this.logger=Jt(r,this.context),this.telemetryEnabled=i,i?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var y_=Object.defineProperty,j0=Object.getOwnPropertySymbols,m_=Object.prototype.hasOwnProperty,w_=Object.prototype.propertyIsEnumerable,K0=(t,e,r)=>e in t?y_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,V0=(t,e)=>{for(var r in e||(e={}))m_.call(e,r)&&K0(t,r,e[r]);if(j0)for(var r of j0(e))w_.call(e,r)&&K0(t,r,e[r]);return t};class gc extends sg{constructor(e){var r;super(e),this.protocol=s0,this.version=o0,this.name=ta,this.events=new jt.exports.EventEmitter,this.initialized=!1,this.on=(o,a)=>this.events.on(o,a),this.once=(o,a)=>this.events.once(o,a),this.off=(o,a)=>this.events.off(o,a),this.removeListener=(o,a)=>this.events.removeListener(o,a),this.dispatchEnvelope=({topic:o,message:a,sessionExists:c})=>{if(!o||!a)return;const h={topic:o,message:a,publishedAt:Date.now(),transportType:ht.link_mode};this.relayer.onLinkMessageEvent(h,{sessionExists:c})},this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||h0,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=Ia({level:typeof e?.logger=="string"&&e.logger?e.logger:L5.logger,name:ta}),{logger:n,chunkLoggerController:s}=ng({opts:i,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=s,(r=this.logChunkController)!=null&&r.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var o,a;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((a=this.logChunkController)==null||a.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=Jt(n,this.name),this.heartbeat=new ma,this.crypto=new z7(this,this.logger,e?.keychain),this.history=new h_(this,this.logger),this.expirer=new u_(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new P1(V0(V0({},q5),e?.storageOptions)),this.relayer=new s_({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new c_(this,this.logger),this.verify=new d_(this,this.logger,this.storage),this.echoClient=new l_(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new v_(this,this.logger,e?.telemetryEnabled)}static async init(e){const r=new gc(e);await r.initialize();const i=await r.crypto.getClientId();return await r.storage.setItem(Z5,i),r}get context(){return tr(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(u0,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.linkModeSupportedApps=await this.storage.getItem(u0)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}}const bc=gc,H0="wc",W0=2,G0="client",vc=`${H0}@${W0}:${G0}:`,yc={name:G0,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"},J0="WALLETCONNECT_DEEPLINK_CHOICE",__="proposal",x_="Proposal expired",E_="session",ts=Y.SEVEN_DAYS,S_="engine",Rt={wc_sessionPropose:{req:{ttl:Y.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:Y.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:Y.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:Y.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:Y.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:Y.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:Y.ONE_DAY,prompt:!1,tag:1104},res:{ttl:Y.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:Y.ONE_DAY,prompt:!1,tag:1106},res:{ttl:Y.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:Y.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:Y.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:Y.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:Y.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:Y.ONE_DAY,prompt:!1,tag:1112},res:{ttl:Y.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:Y.ONE_DAY,prompt:!1,tag:1114},res:{ttl:Y.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:Y.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:Y.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:Y.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:Y.FIVE_MINUTES,prompt:!1,tag:1119}}},mc={min:Y.FIVE_MINUTES,max:Y.SEVEN_DAYS},oi={idle:"IDLE",active:"ACTIVE"},M_="request",I_=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],A_="wc",D_="auth",O_="authKeys",P_="pairingTopics",R_="requests",ia=`${A_}@${1.5}:${D_}:`,na=`${ia}:PUB_KEY`;var $_=Object.defineProperty,N_=Object.defineProperties,T_=Object.getOwnPropertyDescriptors,Y0=Object.getOwnPropertySymbols,F_=Object.prototype.hasOwnProperty,C_=Object.prototype.propertyIsEnumerable,X0=(t,e,r)=>e in t?$_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,gt=(t,e)=>{for(var r in e||(e={}))F_.call(e,r)&&X0(t,r,e[r]);if(Y0)for(var r of Y0(e))C_.call(e,r)&&X0(t,r,e[r]);return t},kr=(t,e)=>N_(t,T_(e));class B_ extends vg{constructor(e){super(e),this.name=S_,this.events=new jt.exports,this.initialized=!1,this.requestQueue={state:oi.idle,queue:[]},this.sessionRequestQueue={state:oi.idle,queue:[]},this.requestQueueDelay=Y.ONE_SECOND,this.expectedPairingMethodMap=new Map,this.recentlyDeletedMap=new Map,this.recentlyDeletedLimit=200,this.relayMessageCache=[],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(Rt)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},Y.toMiliseconds(this.requestQueueDelay)))},this.connect=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const i=kr(gt({},r),{requiredNamespaces:r.requiredNamespaces||{},optionalNamespaces:r.optionalNamespaces||{}});await this.isValidConnect(i);const{pairingTopic:n,requiredNamespaces:s,optionalNamespaces:o,sessionProperties:a,relays:c}=i;let h=n,l,y=!1;try{if(h){const L=this.client.core.pairing.pairings.get(h);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),y=L.active}}catch(L){throw this.client.logger.error(`connect() -> pairing.get(${h}) failed`),L}if(!h||!y){const{topic:L,uri:k}=await this.client.core.pairing.create();h=L,l=k}if(!h){const{message:L}=Z("NO_MATCHING_KEY",`connect() pairing topic: ${h}`);throw new Error(L)}const M=await this.client.core.crypto.generateKeyPair(),I=Rt.wc_sessionPropose.req.ttl||Y.FIVE_MINUTES,S=Et(I),D=gt({requiredNamespaces:s,optionalNamespaces:o,relays:c??[{protocol:c0}],proposer:{publicKey:M,metadata:this.client.metadata},expiryTimestamp:S,pairingTopic:h},a&&{sessionProperties:a}),{reject:R,resolve:$,done:T}=ln(I,x_);this.events.once(Se("session_connect"),async({error:L,session:k})=>{if(L)R(L);else if(k){k.self.publicKey=M;const j=kr(gt({},k),{pairingTopic:D.pairingTopic,requiredNamespaces:D.requiredNamespaces,optionalNamespaces:D.optionalNamespaces,transportType:ht.relay});await this.client.session.set(k.topic,j),await this.setExpiry(k.topic,k.expiry),h&&await this.client.core.pairing.updateMetadata({topic:h,metadata:k.peer.metadata}),this.cleanupDuplicatePairings(j),$(j)}});const C=await this.sendRequest({topic:h,method:"wc_sessionPropose",params:D,throwOnFailedPublish:!0});return await this.setProposal(C,gt({id:C},D)),{uri:l,approval:T}},this.pair=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(r)}catch(i){throw this.client.logger.error("pair() failed"),i}},this.approve=async r=>{var i,n,s;const o=this.client.core.eventClient.createEvent({properties:{topic:(i=r?.id)==null?void 0:i.toString(),trace:[zr.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(K){throw o.setError(mn.no_internet_connection),K}try{await this.isValidProposalId(r?.id)}catch(K){throw this.client.logger.error(`approve() -> proposal.get(${r?.id}) failed`),o.setError(mn.proposal_not_found),K}try{await this.isValidApprove(r)}catch(K){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(mn.session_approve_namespace_validation_failure),K}const{id:a,relayProtocol:c,namespaces:h,sessionProperties:l,sessionConfig:y}=r,M=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:o.eventId});const{pairingTopic:I,proposer:S,requiredNamespaces:D,optionalNamespaces:R}=M;let $=(n=this.client.core.eventClient)==null?void 0:n.getEvent({topic:I});$||($=(s=this.client.core.eventClient)==null?void 0:s.createEvent({type:zr.session_approve_started,properties:{topic:I,trace:[zr.session_approve_started,zr.session_namespaces_validation_success]}}));const T=await this.client.core.crypto.generateKeyPair(),C=S.publicKey,L=await this.client.core.crypto.generateSharedKey(T,C),k=gt(gt({relay:{protocol:c??"irn"},namespaces:h,controller:{publicKey:T,metadata:this.client.metadata},expiry:Et(ts)},l&&{sessionProperties:l}),y&&{sessionConfig:y}),j=ht.relay;$.addTrace(zr.subscribing_session_topic);try{await this.client.core.relayer.subscribe(L,{transportType:j})}catch(K){throw $.setError(mn.subscribe_session_topic_failure),K}$.addTrace(zr.subscribe_session_topic_success);const G=kr(gt({},k),{topic:L,requiredNamespaces:D,optionalNamespaces:R,pairingTopic:I,acknowledged:!1,self:k.controller,peer:{publicKey:S.publicKey,metadata:S.metadata},controller:T,transportType:ht.relay});await this.client.session.set(L,G),$.addTrace(zr.store_session);try{$.addTrace(zr.publishing_session_settle),await this.sendRequest({topic:L,method:"wc_sessionSettle",params:k,throwOnFailedPublish:!0}).catch(K=>{throw $?.setError(mn.session_settle_publish_failure),K}),$.addTrace(zr.session_settle_publish_success),$.addTrace(zr.publishing_session_approve),await this.sendResult({id:a,topic:I,result:{relay:{protocol:c??"irn"},responderPublicKey:T},throwOnFailedPublish:!0}).catch(K=>{throw $?.setError(mn.session_approve_publish_failure),K}),$.addTrace(zr.session_approve_publish_success)}catch(K){throw this.client.logger.error(K),this.client.session.delete(L,ct("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(L),K}return this.client.core.eventClient.deleteEvent({eventId:$.eventId}),await this.client.core.pairing.updateMetadata({topic:I,metadata:S.metadata}),await this.client.proposal.delete(a,ct("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:I}),await this.setExpiry(L,Et(ts)),{topic:L,acknowledged:()=>Promise.resolve(this.client.session.get(L))}},this.reject=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(r)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}const{id:i,reason:n}=r;let s;try{s=this.client.proposal.get(i).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),o}s&&(await this.sendError({id:i,topic:s,error:n,rpcOpts:Rt.wc_sessionPropose.reject}),await this.client.proposal.delete(i,ct("USER_DISCONNECTED")))},this.update=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(r)}catch(y){throw this.client.logger.error("update() -> isValidUpdate() failed"),y}const{topic:i,namespaces:n}=r,{done:s,resolve:o,reject:a}=ln(),c=wi(),h=bn().toString(),l=this.client.session.get(i).namespaces;return this.events.once(Se("session_update",c),({error:y})=>{y?a(y):o()}),await this.client.session.update(i,{namespaces:n}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:n},throwOnFailedPublish:!0,clientRpcId:c,relayRpcId:h}).catch(y=>{this.client.logger.error(y),this.client.session.update(i,{namespaces:l}),a(y)}),{acknowledged:s}},this.extend=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(r)}catch(c){throw this.client.logger.error("extend() -> isValidExtend() failed"),c}const{topic:i}=r,n=wi(),{done:s,resolve:o,reject:a}=ln();return this.events.once(Se("session_extend",n),({error:c})=>{c?a(c):o()}),await this.setExpiry(i,Et(ts)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(c=>{a(c)}),{acknowledged:s}},this.request=async r=>{this.isInitialized();try{await this.isValidRequest(r)}catch(S){throw this.client.logger.error("request() -> isValidRequest() failed"),S}const{chainId:i,request:n,topic:s,expiry:o=Rt.wc_sessionRequest.req.ttl}=r,a=this.client.session.get(s);a?.transportType===ht.relay&&await this.confirmOnlineStateOrThrow();const c=wi(),h=bn().toString(),{done:l,resolve:y,reject:M}=ln(o,"Request expired. Please try again.");this.events.once(Se("session_request",c),({error:S,result:D})=>{S?M(S):y(D)});const I=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);return I?(await this.sendRequest({clientRpcId:c,relayRpcId:h,topic:s,method:"wc_sessionRequest",params:{request:kr(gt({},n),{expiryTimestamp:Et(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0,appLink:I}).catch(S=>M(S)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:c}),await l()):await Promise.all([new Promise(async S=>{await this.sendRequest({clientRpcId:c,relayRpcId:h,topic:s,method:"wc_sessionRequest",params:{request:kr(gt({},n),{expiryTimestamp:Et(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0}).catch(D=>M(D)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:c}),S()}),new Promise(async S=>{var D;if(!((D=a.sessionConfig)!=null&&D.disableDeepLink)){const R=await c6(this.client.core.storage,J0);await o6({id:c,topic:s,wcDeepLink:R})}S()}),l()]).then(S=>S[2])},this.respond=async r=>{this.isInitialized(),await this.isValidRespond(r);const{topic:i,response:n}=r,{id:s}=n,o=this.client.session.get(i);o.transportType===ht.relay&&await this.confirmOnlineStateOrThrow();const a=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);ii(n)?await this.sendResult({id:s,topic:i,result:n.result,throwOnFailedPublish:!0,appLink:a}):Ar(n)&&await this.sendError({id:s,topic:i,error:n.error,appLink:a}),this.cleanupAfterResponse(r)},this.ping=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(r)}catch(n){throw this.client.logger.error("ping() -> isValidPing() failed"),n}const{topic:i}=r;if(this.client.session.keys.includes(i)){const n=wi(),s=bn().toString(),{done:o,resolve:a,reject:c}=ln();this.events.once(Se("session_ping",n),({error:h})=>{h?c(h):a()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:n,relayRpcId:s}),o()])}else this.client.core.pairing.pairings.keys.includes(i)&&(this.client.logger.warn("ping() on pairing topic is deprecated and will be removed in the next major release."),await this.client.core.pairing.ping({topic:i}))},this.emit=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(r);const{topic:i,event:n,chainId:s}=r,o=bn().toString(),a=wi();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:n,chainId:s},throwOnFailedPublish:!0,relayRpcId:o,clientRpcId:a})},this.disconnect=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(r);const{topic:i}=r;if(this.client.session.keys.includes(i))await this.sendRequest({topic:i,method:"wc_sessionDelete",params:ct("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:i,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(i))await this.client.core.pairing.disconnect({topic:i});else{const{message:n}=Z("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(n)}},this.find=r=>(this.isInitialized(),this.client.session.getAll().filter(i=>y8(i,r))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async(r,i)=>{var n;this.isInitialized(),this.isValidAuthenticate(r);const s=i&&this.client.core.linkModeSupportedApps.includes(i)&&((n=this.client.metadata.redirect)==null?void 0:n.linkMode),o=s?ht.link_mode:ht.relay;o===ht.relay&&await this.confirmOnlineStateOrThrow();const{chains:a,statement:c="",uri:h,domain:l,nonce:y,type:M,exp:I,nbf:S,methods:D=[],expiry:R}=r,$=[...r.resources||[]],{topic:T,uri:C}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:T,uri:C}});const L=await this.client.core.crypto.generateKeyPair(),k=Go(L);if(await Promise.all([this.client.auth.authKeys.set(na,{responseTopic:k,publicKey:L}),this.client.auth.pairingTopics.set(k,{topic:k,pairingTopic:T})]),await this.client.core.relayer.subscribe(k,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${T}`),D.length>0){const{namespace:E}=qo(a[0]);let w=Z6(E,"request",D);Ko($)&&(w=e4(w,$.pop())),$.push(w)}const j=R&&R>Rt.wc_sessionAuthenticate.req.ttl?R:Rt.wc_sessionAuthenticate.req.ttl,G={authPayload:{type:M??"caip122",chains:a,statement:c,aud:h,domain:l,version:"1",nonce:y,iat:new Date().toISOString(),exp:I,nbf:S,resources:$},requester:{publicKey:L,metadata:this.client.metadata},expiryTimestamp:Et(j)},K={eip155:{chains:a,methods:[...new Set(["personal_sign",...D])],events:["chainChanged","accountsChanged"]}},V={requiredNamespaces:{},optionalNamespaces:K,relays:[{protocol:"irn"}],pairingTopic:T,proposer:{publicKey:L,metadata:this.client.metadata},expiryTimestamp:Et(Rt.wc_sessionPropose.req.ttl)},{done:re,resolve:O,reject:g}=ln(j,"Request expired"),p=async({error:E,session:w})=>{if(this.events.off(Se("session_request",u),f),E)g(E);else if(w){w.self.publicKey=L,await this.client.session.set(w.topic,w),await this.setExpiry(w.topic,w.expiry),T&&await this.client.core.pairing.updateMetadata({topic:T,metadata:w.peer.metadata});const d=this.client.session.get(w.topic);await this.deleteProposal(b),O({session:d})}},f=async E=>{var w,d,m;if(await this.deletePendingAuthRequest(u,{message:"fulfilled",code:0}),E.error){const q=ct("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return E.error.code===q.code?void 0:(this.events.off(Se("session_connect"),p),g(E.error.message))}await this.deleteProposal(b),this.events.off(Se("session_connect"),p);const{cacaos:v,responder:A}=E.result,U=[],x=[];for(const q of v){await il({cacao:q,projectId:this.client.core.projectId})||(this.client.logger.error(q,"Signature verification failed"),g(ct("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:z}=q,J=Ko(z.resources),X=[qf(z.iss)],W=jo(z.iss);if(J){const ne=ol(J),Q=al(J);U.push(...ne),X.push(...Q)}for(const ne of X)x.push(`${ne}:${W}`)}const N=await this.client.core.crypto.generateSharedKey(L,A.publicKey);let B;U.length>0&&(B={topic:N,acknowledged:!0,self:{publicKey:L,metadata:this.client.metadata},peer:A,controller:A.publicKey,expiry:Et(ts),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:T,namespaces:Ul([...new Set(U)],[...new Set(x)]),transportType:o},await this.client.core.relayer.subscribe(N,{transportType:o}),await this.client.session.set(N,B),T&&await this.client.core.pairing.updateMetadata({topic:T,metadata:A.metadata}),B=this.client.session.get(N)),(w=this.client.metadata.redirect)!=null&&w.linkMode&&(d=A.metadata.redirect)!=null&&d.linkMode&&(m=A.metadata.redirect)!=null&&m.universal&&i&&(this.client.core.addLinkModeSupportedApp(A.metadata.redirect.universal),this.client.session.update(N,{transportType:ht.link_mode})),O({auths:v,session:B})},u=wi(),b=wi();this.events.once(Se("session_connect"),p),this.events.once(Se("session_request",u),f);let _;try{if(s){const E=vn("wc_sessionAuthenticate",G,u);this.client.core.history.set(T,E);const w=await this.client.core.crypto.encode("",E,{type:$s,encoding:Ps});_=Yo(i,T,w)}else await Promise.all([this.sendRequest({topic:T,method:"wc_sessionAuthenticate",params:G,expiry:r.expiry,throwOnFailedPublish:!0,clientRpcId:u}),this.sendRequest({topic:T,method:"wc_sessionPropose",params:V,expiry:Rt.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:b})])}catch(E){throw this.events.off(Se("session_connect"),p),this.events.off(Se("session_request",u),f),E}return await this.setProposal(b,gt({id:b},V)),await this.setAuthRequest(u,{request:kr(gt({},G),{verifyContext:{}}),pairingTopic:T,transportType:o}),{uri:_??C,response:re}},this.approveSessionAuthenticate=async r=>{const{id:i,auths:n}=r,s=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[wn.authenticated_session_approve_started]}});try{this.isInitialized()}catch(R){throw s.setError(zs.no_internet_connection),R}const o=this.getPendingAuthRequest(i);if(!o)throw s.setError(zs.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);const a=o.transportType||ht.relay;a===ht.relay&&await this.confirmOnlineStateOrThrow();const c=o.requester.publicKey,h=await this.client.core.crypto.generateKeyPair(),l=Go(c),y={type:bi,receiverPublicKey:c,senderPublicKey:h},M=[],I=[];for(const R of n){if(!await il({cacao:R,projectId:this.client.core.projectId})){s.setError(zs.invalid_cacao);const k=ct("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:l,error:k,encodeOpts:y}),new Error(k.message)}s.addTrace(wn.cacaos_verified);const{p:$}=R,T=Ko($.resources),C=[qf($.iss)],L=jo($.iss);if(T){const k=ol(T),j=al(T);M.push(...k),C.push(...j)}for(const k of C)I.push(`${k}:${L}`)}const S=await this.client.core.crypto.generateSharedKey(h,c);s.addTrace(wn.create_authenticated_session_topic);let D;if(M?.length>0){D={topic:S,acknowledged:!0,self:{publicKey:h,metadata:this.client.metadata},peer:{publicKey:c,metadata:o.requester.metadata},controller:c,expiry:Et(ts),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:Ul([...new Set(M)],[...new Set(I)]),transportType:a},s.addTrace(wn.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(S,{transportType:a})}catch(R){throw s.setError(zs.subscribe_authenticated_session_topic_failure),R}s.addTrace(wn.subscribe_authenticated_session_topic_success),await this.client.session.set(S,D),s.addTrace(wn.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}s.addTrace(wn.publishing_authenticated_session_approve);try{await this.sendResult({topic:l,id:i,result:{cacaos:n,responder:{publicKey:h,metadata:this.client.metadata}},encodeOpts:y,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,a)})}catch(R){throw s.setError(zs.authenticated_session_approve_publish_failure),R}return await this.client.auth.requests.delete(i,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:s.eventId}),{session:D}},this.rejectSessionAuthenticate=async r=>{this.isInitialized();const{id:i,reason:n}=r,s=this.getPendingAuthRequest(i);if(!s)throw new Error(`Could not find pending auth request with id ${i}`);s.transportType===ht.relay&&await this.confirmOnlineStateOrThrow();const o=s.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),c=Go(o),h={type:bi,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:i,topic:c,error:n,encodeOpts:h,rpcOpts:Rt.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(s.requester.metadata,s.transportType)}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.client.proposal.delete(i,ct("USER_DISCONNECTED"))},this.formatAuthMessage=r=>{this.isInitialized();const{request:i,iss:n}=r;return nl(i,n)},this.processRelayMessageCache=()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{const r=this.relayMessageCache.shift();r&&await this.onRelayMessage(r)}catch(r){this.client.logger.error(r)}},50)},this.cleanupDuplicatePairings=async r=>{if(r.pairingTopic)try{const i=this.client.core.pairing.pairings.get(r.pairingTopic),n=this.client.core.pairing.pairings.getAll().filter(s=>{var o,a;return((o=s.peerMetadata)==null?void 0:o.url)&&((a=s.peerMetadata)==null?void 0:a.url)===r.peer.metadata.url&&s.topic&&s.topic!==i.topic});if(n.length===0)return;this.client.logger.info(`Cleaning up ${n.length} duplicate pairing(s)`),await Promise.all(n.map(s=>this.client.core.pairing.disconnect({topic:s.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(i){this.client.logger.error(i)}},this.deleteSession=async r=>{var i;const{topic:n,expirerHasDeleted:s=!1,emitEvent:o=!0,id:a=0}=r,{self:c}=this.client.session.get(n);await this.client.core.relayer.unsubscribe(n),await this.client.session.delete(n,ct("USER_DISCONNECTED")),this.addToRecentlyDeleted(n,"session"),this.client.core.crypto.keychain.has(c.publicKey)&&await this.client.core.crypto.deleteKeyPair(c.publicKey),this.client.core.crypto.keychain.has(n)&&await this.client.core.crypto.deleteSymKey(n),s||this.client.core.expirer.del(n),this.client.core.storage.removeItem(J0).catch(h=>this.client.logger.warn(h)),this.getPendingSessionRequests().forEach(h=>{h.topic===n&&this.deletePendingSessionRequest(h.id,ct("USER_DISCONNECTED"))}),n===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=oi.idle),o&&this.client.events.emit("session_delete",{id:a,topic:n})},this.deleteProposal=async(r,i)=>{if(i)try{const n=this.client.proposal.get(r);this.client.core.eventClient.getEvent({topic:n.pairingTopic})?.setError(mn.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(r,ct("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"proposal")},this.deletePendingSessionRequest=async(r,i,n=!1)=>{await Promise.all([this.client.pendingRequest.delete(r,i),n?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(s=>s.id!==r),n&&(this.sessionRequestQueue.state=oi.idle,this.client.events.emit("session_request_expire",{id:r}))},this.deletePendingAuthRequest=async(r,i,n=!1)=>{await Promise.all([this.client.auth.requests.delete(r,i),n?Promise.resolve():this.client.core.expirer.del(r)])},this.setExpiry=async(r,i)=>{this.client.session.keys.includes(r)&&(this.client.core.expirer.set(r,i),await this.client.session.update(r,{expiry:i}))},this.setProposal=async(r,i)=>{this.client.core.expirer.set(r,Et(Rt.wc_sessionPropose.req.ttl)),await this.client.proposal.set(r,i)},this.setAuthRequest=async(r,i)=>{const{request:n,pairingTopic:s,transportType:o=ht.relay}=i;this.client.core.expirer.set(r,n.expiryTimestamp),await this.client.auth.requests.set(r,{authPayload:n.authPayload,requester:n.requester,expiryTimestamp:n.expiryTimestamp,id:r,pairingTopic:s,verifyContext:n.verifyContext,transportType:o})},this.setPendingSessionRequest=async r=>{const{id:i,topic:n,params:s,verifyContext:o}=r,a=s.request.expiryTimestamp||Et(Rt.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,a),await this.client.pendingRequest.set(i,{id:i,topic:n,params:s,verifyContext:o})},this.sendRequest=async r=>{const{topic:i,method:n,params:s,expiry:o,relayRpcId:a,clientRpcId:c,throwOnFailedPublish:h,appLink:l}=r,y=vn(n,s,c);let M;const I=!!l;try{const R=I?Ps:Gi;M=await this.client.core.crypto.encode(i,y,{encoding:R})}catch(R){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),R}let S;if(I_.includes(n)){const R=vi(JSON.stringify(y)),$=vi(M);S=await this.client.core.verify.register({id:$,decryptedId:R})}const D=Rt[n].req;if(D.attestation=S,o&&(D.ttl=o),a&&(D.id=a),this.client.core.history.set(i,y),I){const R=Yo(l,i,M);await global.Linking.openURL(R,this.client.name)}else{const R=Rt[n].req;o&&(R.ttl=o),a&&(R.id=a),h?(R.internal=kr(gt({},R.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,M,R)):this.client.core.relayer.publish(i,M,R).catch($=>this.client.logger.error($))}return y.id},this.sendResult=async r=>{const{id:i,topic:n,result:s,throwOnFailedPublish:o,encodeOpts:a,appLink:c}=r,h=oc(i,s);let l;const y=c&&typeof(global==null?void 0:global.Linking)<"u";try{const I=y?Ps:Gi;l=await this.client.core.crypto.encode(n,h,kr(gt({},a||{}),{encoding:I}))}catch(I){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${n} failed`),I}let M;try{M=await this.client.core.history.get(n,i)}catch(I){throw this.client.logger.error(`sendResult() -> history.get(${n}, ${i}) failed`),I}if(y){const I=Yo(c,n,l);await global.Linking.openURL(I,this.client.name)}else{const I=Rt[M.request.method].res;o?(I.internal=kr(gt({},I.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,l,I)):this.client.core.relayer.publish(n,l,I).catch(S=>this.client.logger.error(S))}await this.client.core.history.resolve(h)},this.sendError=async r=>{const{id:i,topic:n,error:s,encodeOpts:o,rpcOpts:a,appLink:c}=r,h=ac(i,s);let l;const y=c&&typeof(global==null?void 0:global.Linking)<"u";try{const I=y?Ps:Gi;l=await this.client.core.crypto.encode(n,h,kr(gt({},o||{}),{encoding:I}))}catch(I){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`),I}let M;try{M=await this.client.core.history.get(n,i)}catch(I){throw this.client.logger.error(`sendError() -> history.get(${n}, ${i}) failed`),I}if(y){const I=Yo(c,n,l);await global.Linking.openURL(I,this.client.name)}else{const I=a||Rt[M.request.method].res;this.client.core.relayer.publish(n,l,I)}await this.client.core.history.resolve(h)},this.cleanup=async()=>{const r=[],i=[];this.client.session.getAll().forEach(n=>{let s=!1;Ki(n.expiry)&&(s=!0),this.client.core.crypto.keychain.has(n.topic)||(s=!0),s&&r.push(n.topic)}),this.client.proposal.getAll().forEach(n=>{Ki(n.expiryTimestamp)&&i.push(n.id)}),await Promise.all([...r.map(n=>this.deleteSession({topic:n})),...i.map(n=>this.deleteProposal(n))])},this.onRelayEventRequest=async r=>{this.requestQueue.queue.push(r),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===oi.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=oi.active;const r=this.requestQueue.queue.shift();if(r)try{await this.processRequest(r)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=oi.idle},this.processRequest=async r=>{const{topic:i,payload:n,attestation:s,transportType:o,encryptedId:a}=r,c=n.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:c}))switch(c){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:n,attestation:s,encryptedId:a});case"wc_sessionSettle":return await this.onSessionSettleRequest(i,n);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(i,n);case"wc_sessionExtend":return await this.onSessionExtendRequest(i,n);case"wc_sessionPing":return await this.onSessionPingRequest(i,n);case"wc_sessionDelete":return await this.onSessionDeleteRequest(i,n);case"wc_sessionRequest":return await this.onSessionRequest({topic:i,payload:n,attestation:s,encryptedId:a,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(i,n);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:i,payload:n,attestation:s,encryptedId:a,transportType:o});default:return this.client.logger.info(`Unsupported request method ${c}`)}},this.onRelayEventResponse=async r=>{const{topic:i,payload:n,transportType:s}=r,o=(await this.client.core.history.get(i,n.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(i,n,s);case"wc_sessionSettle":return this.onSessionSettleResponse(i,n);case"wc_sessionUpdate":return this.onSessionUpdateResponse(i,n);case"wc_sessionExtend":return this.onSessionExtendResponse(i,n);case"wc_sessionPing":return this.onSessionPingResponse(i,n);case"wc_sessionRequest":return this.onSessionRequestResponse(i,n);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(i,n);default:return this.client.logger.info(`Unsupported response method ${o}`)}},this.onRelayEventUnknownPayload=r=>{const{topic:i}=r,{message:n}=Z("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(n)},this.shouldIgnorePairingRequest=r=>{const{topic:i,requestMethod:n}=r,s=this.expectedPairingMethodMap.get(i);return!s||s.includes(n)?!1:!!(s.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)},this.onSessionProposeRequest=async r=>{const{topic:i,payload:n,attestation:s,encryptedId:o}=r,{params:a,id:c}=n;try{const h=this.client.core.eventClient.getEvent({topic:i});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),h?.setError(_i.proposal_listener_not_found)),this.isValidConnect(gt({},n.params));const l=a.expiryTimestamp||Et(Rt.wc_sessionPropose.req.ttl),y=gt({id:c,pairingTopic:i,expiryTimestamp:l},a);await this.setProposal(c,y);const M=await this.getVerifyContext({attestationId:s,hash:vi(JSON.stringify(n)),encryptedId:o,metadata:y.proposer.metadata});h?.addTrace(si.emit_session_proposal),this.client.events.emit("session_proposal",{id:c,params:y,verifyContext:M})}catch(h){await this.sendError({id:c,topic:i,error:h,rpcOpts:Rt.wc_sessionPropose.autoReject}),this.client.logger.error(h)}},this.onSessionProposeResponse=async(r,i,n)=>{const{id:s}=i;if(ii(i)){const{result:o}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});const a=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:a});const c=a.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:c});const h=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:h});const l=await this.client.core.crypto.generateSharedKey(c,h);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:l});const y=await this.client.core.relayer.subscribe(l,{transportType:n});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:y}),await this.client.core.pairing.activate({topic:r})}else if(Ar(i)){await this.client.proposal.delete(s,ct("USER_DISCONNECTED"));const o=Se("session_connect");if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(Se("session_connect"),{error:i.error})}},this.onSessionSettleRequest=async(r,i)=>{const{id:n,params:s}=i;try{this.isValidSessionSettleRequest(s);const{relay:o,controller:a,expiry:c,namespaces:h,sessionProperties:l,sessionConfig:y}=i.params,M=kr(gt(gt({topic:r,relay:o,expiry:c,namespaces:h,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:a.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:a.publicKey,metadata:a.metadata}},l&&{sessionProperties:l}),y&&{sessionConfig:y}),{transportType:ht.relay}),I=Se("session_connect");if(this.events.listenerCount(I)===0)throw new Error(`emitting ${I} without any listeners 997`);this.events.emit(Se("session_connect"),{session:M}),await this.sendResult({id:i.id,topic:r,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:n,topic:r,error:o}),this.client.logger.error(o)}},this.onSessionSettleResponse=async(r,i)=>{const{id:n}=i;ii(i)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(Se("session_approve",n),{})):Ar(i)&&(await this.client.session.delete(r,ct("USER_DISCONNECTED")),this.events.emit(Se("session_approve",n),{error:i.error}))},this.onSessionUpdateRequest=async(r,i)=>{const{params:n,id:s}=i;try{const o=`${r}_session_update`,a=Cs.get(o);if(a&&this.isRequestOutOfSync(a,s)){this.client.logger.warn(`Discarding out of sync request - ${s}`),this.sendError({id:s,topic:r,error:ct("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(gt({topic:r},n));try{Cs.set(o,s),await this.client.session.update(r,{namespaces:n.namespaces}),await this.sendResult({id:s,topic:r,result:!0,throwOnFailedPublish:!0})}catch(c){throw Cs.delete(o),c}this.client.events.emit("session_update",{id:s,topic:r,params:n})}catch(o){await this.sendError({id:s,topic:r,error:o}),this.client.logger.error(o)}},this.isRequestOutOfSync=(r,i)=>i.toString().slice(0,-3)<r.toString().slice(0,-3),this.onSessionUpdateResponse=(r,i)=>{const{id:n}=i,s=Se("session_update",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);ii(i)?this.events.emit(Se("session_update",n),{}):Ar(i)&&this.events.emit(Se("session_update",n),{error:i.error})},this.onSessionExtendRequest=async(r,i)=>{const{id:n}=i;try{this.isValidExtend({topic:r}),await this.setExpiry(r,Et(ts)),await this.sendResult({id:n,topic:r,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:n,topic:r})}catch(s){await this.sendError({id:n,topic:r,error:s}),this.client.logger.error(s)}},this.onSessionExtendResponse=(r,i)=>{const{id:n}=i,s=Se("session_extend",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);ii(i)?this.events.emit(Se("session_extend",n),{}):Ar(i)&&this.events.emit(Se("session_extend",n),{error:i.error})},this.onSessionPingRequest=async(r,i)=>{const{id:n}=i;try{this.isValidPing({topic:r}),await this.sendResult({id:n,topic:r,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:n,topic:r})}catch(s){await this.sendError({id:n,topic:r,error:s}),this.client.logger.error(s)}},this.onSessionPingResponse=(r,i)=>{const{id:n}=i,s=Se("session_ping",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);setTimeout(()=>{ii(i)?this.events.emit(Se("session_ping",n),{}):Ar(i)&&this.events.emit(Se("session_ping",n),{error:i.error})},500)},this.onSessionDeleteRequest=async(r,i)=>{const{id:n}=i;try{this.isValidDisconnect({topic:r,reason:i.params}),Promise.all([new Promise(s=>{this.client.core.relayer.once(Pt.publish,async()=>{s(await this.deleteSession({topic:r,id:n}))})}),this.sendResult({id:n,topic:r,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:r,error:ct("USER_DISCONNECTED")})]).catch(s=>this.client.logger.error(s))}catch(s){this.client.logger.error(s)}},this.onSessionRequest=async r=>{var i,n,s;const{topic:o,payload:a,attestation:c,encryptedId:h,transportType:l}=r,{id:y,params:M}=a;try{await this.isValidRequest(gt({topic:o},M));const I=this.client.session.get(o),S=await this.getVerifyContext({attestationId:c,hash:vi(JSON.stringify(vn("wc_sessionRequest",M,y))),encryptedId:h,metadata:I.peer.metadata,transportType:l}),D={id:y,topic:o,params:M,verifyContext:S};await this.setPendingSessionRequest(D),l===ht.link_mode&&(i=I.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((n=I.peer.metadata.redirect)==null?void 0:n.universal),(s=this.client.signConfig)!=null&&s.disableRequestQueue?this.emitSessionRequest(D):(this.addSessionRequestToSessionRequestQueue(D),this.processSessionRequestQueue())}catch(I){await this.sendError({id:y,topic:o,error:I}),this.client.logger.error(I)}},this.onSessionRequestResponse=(r,i)=>{const{id:n}=i,s=Se("session_request",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);ii(i)?this.events.emit(Se("session_request",n),{result:i.result}):Ar(i)&&this.events.emit(Se("session_request",n),{error:i.error})},this.onSessionEventRequest=async(r,i)=>{const{id:n,params:s}=i;try{const o=`${r}_session_event_${s.event.name}`,a=Cs.get(o);if(a&&this.isRequestOutOfSync(a,n)){this.client.logger.info(`Discarding out of sync request - ${n}`);return}this.isValidEmit(gt({topic:r},s)),this.client.events.emit("session_event",{id:n,topic:r,params:s}),Cs.set(o,n)}catch(o){await this.sendError({id:n,topic:r,error:o}),this.client.logger.error(o)}},this.onSessionAuthenticateResponse=(r,i)=>{const{id:n}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:r,payload:i}),ii(i)?this.events.emit(Se("session_request",n),{result:i.result}):Ar(i)&&this.events.emit(Se("session_request",n),{error:i.error})},this.onSessionAuthenticateRequest=async r=>{var i;const{topic:n,payload:s,attestation:o,encryptedId:a,transportType:c}=r;try{const{requester:h,authPayload:l,expiryTimestamp:y}=s.params,M=await this.getVerifyContext({attestationId:o,hash:vi(JSON.stringify(s)),encryptedId:a,metadata:h.metadata,transportType:c}),I={requester:h,pairingTopic:n,id:s.id,authPayload:l,verifyContext:M,expiryTimestamp:y};await this.setAuthRequest(s.id,{request:I,pairingTopic:n,transportType:c}),c===ht.link_mode&&(i=h.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(h.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:n,params:s.params,id:s.id,verifyContext:M})}catch(h){this.client.logger.error(h);const l=s.params.requester.publicKey,y=await this.client.core.crypto.generateKeyPair(),M=this.getAppLinkIfEnabled(s.params.requester.metadata,c),I={type:bi,receiverPublicKey:l,senderPublicKey:y};await this.sendError({id:s.id,topic:n,error:h,encodeOpts:I,rpcOpts:Rt.wc_sessionAuthenticate.autoReject,appLink:M})}},this.addSessionRequestToSessionRequestQueue=r=>{this.sessionRequestQueue.queue.push(r)},this.cleanupAfterResponse=r=>{this.deletePendingSessionRequest(r.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=oi.idle,this.processSessionRequestQueue()},Y.toMiliseconds(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:r,error:i})=>{const n=this.client.core.history.pending;n.length>0&&n.filter(s=>s.topic===r&&s.request.method==="wc_sessionRequest").forEach(s=>{const o=s.request.id,a=Se("session_request",o);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);this.events.emit(Se("session_request",s.request.id),{error:i})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===oi.active){this.client.logger.info("session request queue is already active.");return}const r=this.sessionRequestQueue.queue[0];if(!r){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=oi.active,this.emitSessionRequest(r)}catch(i){this.client.logger.error(i)}},this.emitSessionRequest=r=>{this.client.events.emit("session_request",r)},this.onPairingCreated=r=>{if(r.methods&&this.expectedPairingMethodMap.set(r.topic,r.methods),r.active)return;const i=this.client.proposal.getAll().find(n=>n.pairingTopic===r.topic);i&&this.onSessionProposeRequest({topic:r.topic,payload:vn("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id)})},this.isValidConnect=async r=>{if(!or(r)){const{message:c}=Z("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(c)}const{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:s,sessionProperties:o,relays:a}=r;if(Qt(i)||await this.isValidPairingTopic(i),!P8(a,!0)){const{message:c}=Z("MISSING_OR_INVALID",`connect() relays: ${a}`);throw new Error(c)}!Qt(n)&&Zo(n)!==0&&this.validateNamespaces(n,"requiredNamespaces"),!Qt(s)&&Zo(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),Qt(o)||this.validateSessionProps(o,"sessionProperties")},this.validateNamespaces=(r,i)=>{const n=O8(r,"connect()",i);if(n)throw new Error(n.message)},this.isValidApprove=async r=>{if(!or(r))throw new Error(Z("MISSING_OR_INVALID",`approve() params: ${r}`).message);const{id:i,namespaces:n,relayProtocol:s,sessionProperties:o}=r;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);const a=this.client.proposal.get(i),c=ec(n,"approve()");if(c)throw new Error(c.message);const h=Vl(a.requiredNamespaces,n,"approve()");if(h)throw new Error(h.message);if(!mt(s,!0)){const{message:l}=Z("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(l)}Qt(o)||this.validateSessionProps(o,"sessionProperties")},this.isValidReject=async r=>{if(!or(r)){const{message:s}=Z("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(s)}const{id:i,reason:n}=r;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!$8(n)){const{message:s}=Z("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(s)}},this.isValidSessionSettleRequest=r=>{if(!or(r)){const{message:h}=Z("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(h)}const{relay:i,controller:n,namespaces:s,expiry:o}=r;if(!jl(i)){const{message:h}=Z("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(h)}const a=E8(n,"onSessionSettleRequest()");if(a)throw new Error(a.message);const c=ec(s,"onSessionSettleRequest()");if(c)throw new Error(c.message);if(Ki(o)){const{message:h}=Z("EXPIRED","onSessionSettleRequest()");throw new Error(h)}},this.isValidUpdate=async r=>{if(!or(r)){const{message:c}=Z("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(c)}const{topic:i,namespaces:n}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const s=this.client.session.get(i),o=ec(n,"update()");if(o)throw new Error(o.message);const a=Vl(s.requiredNamespaces,n,"update()");if(a)throw new Error(a.message)},this.isValidExtend=async r=>{if(!or(r)){const{message:n}=Z("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(n)}const{topic:i}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)},this.isValidRequest=async r=>{if(!or(r)){const{message:c}=Z("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(c)}const{topic:i,request:n,chainId:s,expiry:o}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const{namespaces:a}=this.client.session.get(i);if(!Kl(a,s)){const{message:c}=Z("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(c)}if(!N8(n)){const{message:c}=Z("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(c)}if(!C8(a,s,n.method)){const{message:c}=Z("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(c)}if(o&&!U8(o,mc)){const{message:c}=Z("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${mc.min} and ${mc.max}`);throw new Error(c)}},this.isValidRespond=async r=>{var i;if(!or(r)){const{message:o}=Z("MISSING_OR_INVALID",`respond() params: ${r}`);throw new Error(o)}const{topic:n,response:s}=r;try{await this.isValidSessionTopic(n)}catch(o){throw(i=r?.response)!=null&&i.id&&this.cleanupAfterResponse(r),o}if(!T8(s)){const{message:o}=Z("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(o)}},this.isValidPing=async r=>{if(!or(r)){const{message:n}=Z("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)},this.isValidEmit=async r=>{if(!or(r)){const{message:a}=Z("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(a)}const{topic:i,event:n,chainId:s}=r;await this.isValidSessionTopic(i);const{namespaces:o}=this.client.session.get(i);if(!Kl(o,s)){const{message:a}=Z("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(a)}if(!F8(n)){const{message:a}=Z("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}if(!B8(o,s,n.name)){const{message:a}=Z("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}},this.isValidDisconnect=async r=>{if(!or(r)){const{message:n}=Z("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)},this.isValidAuthenticate=r=>{const{chains:i,uri:n,domain:s,nonce:o}=r;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!mt(n,!1))throw new Error("uri is required parameter");if(!mt(s,!1))throw new Error("domain is required parameter");if(!mt(o,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(c=>qo(c).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:a}=qo(i[0]);if(a!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async r=>{const{attestationId:i,hash:n,encryptedId:s,metadata:o,transportType:a}=r,c={verified:{verifyUrl:o.verifyUrl||Us,validation:"UNKNOWN",origin:o.url||""}};try{if(a===ht.link_mode){const l=this.getAppLinkIfEnabled(o,a);return c.verified.validation=l&&new URL(l).origin===new URL(o.url).origin?"VALID":"INVALID",c}const h=await this.client.core.verify.resolve({attestationId:i,hash:n,encryptedId:s,verifyUrl:o.verifyUrl});h&&(c.verified.origin=h.origin,c.verified.isScam=h.isScam,c.verified.validation=h.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(h){this.client.logger.warn(h)}return this.client.logger.debug(`Verify context: ${JSON.stringify(c)}`),c},this.validateSessionProps=(r,i)=>{Object.values(r).forEach(n=>{if(!mt(n,!1)){const{message:s}=Z("MISSING_OR_INVALID",`${i} must be in Record<string, string> format. Received: ${JSON.stringify(n)}`);throw new Error(s)}})},this.getPendingAuthRequest=r=>{const i=this.client.auth.requests.get(r);return typeof i=="object"?i:void 0},this.addToRecentlyDeleted=(r,i)=>{if(this.recentlyDeletedMap.set(r,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let n=0;const s=this.recentlyDeletedLimit/2;for(const o of this.recentlyDeletedMap.keys()){if(n++>=s)break;this.recentlyDeletedMap.delete(o)}}},this.checkRecentlyDeleted=r=>{const i=this.recentlyDeletedMap.get(r);if(i){const{message:n}=Z("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${r}`);throw new Error(n)}},this.isLinkModeEnabled=(r,i)=>{var n,s,o,a,c,h,l,y,M;return!r||i!==ht.link_mode?!1:((s=(n=this.client.metadata)==null?void 0:n.redirect)==null?void 0:s.linkMode)===!0&&((a=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:a.universal)!==void 0&&((h=(c=this.client.metadata)==null?void 0:c.redirect)==null?void 0:h.universal)!==""&&((l=r?.redirect)==null?void 0:l.universal)!==void 0&&((y=r?.redirect)==null?void 0:y.universal)!==""&&((M=r?.redirect)==null?void 0:M.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(r.redirect.universal)&&typeof(global==null?void 0:global.Linking)<"u"},this.getAppLinkIfEnabled=(r,i)=>{var n;return this.isLinkModeEnabled(r,i)?(n=r?.redirect)==null?void 0:n.universal:void 0},this.handleLinkModeMessage=({url:r})=>{if(!r||!r.includes("wc_ev")||!r.includes("topic"))return;const i=zd(r,"topic")||"",n=decodeURIComponent(zd(r,"wc_ev")||""),s=this.client.session.keys.includes(i);s&&this.client.session.update(i,{transportType:ht.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:n,sessionExists:s})},this.registerLinkModeListeners=async()=>{var r;if(Nf()||ki()&&(r=this.client.metadata.redirect)!=null&&r.linkMode){const i=global==null?void 0:global.Linking;if(typeof i<"u"){i.addEventListener("url",this.handleLinkModeMessage,this.client.name);const n=await i.getInitialURL();n&&setTimeout(()=>{this.handleLinkModeMessage({url:n})},50)}}}}isInitialized(){if(!this.initialized){const{message:e}=Z("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Pt.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){const{topic:r,message:i,attestation:n,transportType:s}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(na)?this.client.auth.authKeys.get(na):{responseTopic:void 0,publicKey:void 0},a=await this.client.core.crypto.decode(r,i,{receiverPublicKey:o,encoding:s===ht.link_mode?Ps:Gi});try{fc(a)?(this.client.core.history.set(r,a),this.onRelayEventRequest({topic:r,payload:a,attestation:n,transportType:s,encryptedId:vi(i)})):ea(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:r,payload:a,transportType:s}),this.client.core.history.delete(r,a.id)):this.onRelayEventUnknownPayload({topic:r,payload:a,transportType:s})}catch(c){this.client.logger.error(c)}}registerExpirerEvents(){this.client.core.expirer.on(Or.expired,async e=>{const{topic:r,id:i}=Ud(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,Z("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,Z("EXPIRED"),!0);r?this.client.session.keys.includes(r)&&(await this.deleteSession({topic:r,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:r})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))})}registerPairingEvents(){this.client.core.pairing.events.on(yn.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(yn.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!mt(e,!1)){const{message:r}=Z("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(r)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:r}=Z("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(r)}if(Ki(this.client.core.pairing.pairings.get(e).expiry)){const{message:r}=Z("EXPIRED",`pairing topic: ${e}`);throw new Error(r)}}async isValidSessionTopic(e){if(!mt(e,!1)){const{message:r}=Z("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(r)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:r}=Z("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(r)}if(Ki(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:r}=Z("EXPIRED",`session topic: ${e}`);throw new Error(r)}if(!this.client.core.crypto.keychain.has(e)){const{message:r}=Z("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(r)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(mt(e,!1)){const{message:r}=Z("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(r)}else{const{message:r}=Z("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(r)}}async isValidProposalId(e){if(!R8(e)){const{message:r}=Z("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(r)}if(!this.client.proposal.keys.includes(e)){const{message:r}=Z("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(r)}if(Ki(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:r}=Z("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}}class L_ extends _n{constructor(e,r){super(e,r,__,vc),this.core=e,this.logger=r}}class Z0 extends _n{constructor(e,r){super(e,r,E_,vc),this.core=e,this.logger=r}}class q_ extends _n{constructor(e,r){super(e,r,M_,vc,i=>i.id),this.core=e,this.logger=r}}class U_ extends _n{constructor(e,r){super(e,r,O_,ia,()=>na),this.core=e,this.logger=r}}class z_ extends _n{constructor(e,r){super(e,r,P_,ia),this.core=e,this.logger=r}}class k_ extends _n{constructor(e,r){super(e,r,R_,ia,i=>i.id),this.core=e,this.logger=r}}class j_{constructor(e,r){this.core=e,this.logger=r,this.authKeys=new U_(this.core,this.logger),this.pairingTopics=new z_(this.core,this.logger),this.requests=new k_(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}class wc extends bg{constructor(e){super(e),this.protocol=H0,this.version=W0,this.name=yc.name,this.events=new jt.exports.EventEmitter,this.on=(i,n)=>this.events.on(i,n),this.once=(i,n)=>this.events.once(i,n),this.off=(i,n)=>this.events.off(i,n),this.removeListener=(i,n)=>this.events.removeListener(i,n),this.removeAllListeners=i=>this.events.removeAllListeners(i),this.connect=async i=>{try{return await this.engine.connect(i)}catch(n){throw this.logger.error(n.message),n}},this.pair=async i=>{try{return await this.engine.pair(i)}catch(n){throw this.logger.error(n.message),n}},this.approve=async i=>{try{return await this.engine.approve(i)}catch(n){throw this.logger.error(n.message),n}},this.reject=async i=>{try{return await this.engine.reject(i)}catch(n){throw this.logger.error(n.message),n}},this.update=async i=>{try{return await this.engine.update(i)}catch(n){throw this.logger.error(n.message),n}},this.extend=async i=>{try{return await this.engine.extend(i)}catch(n){throw this.logger.error(n.message),n}},this.request=async i=>{try{return await this.engine.request(i)}catch(n){throw this.logger.error(n.message),n}},this.respond=async i=>{try{return await this.engine.respond(i)}catch(n){throw this.logger.error(n.message),n}},this.ping=async i=>{try{return await this.engine.ping(i)}catch(n){throw this.logger.error(n.message),n}},this.emit=async i=>{try{return await this.engine.emit(i)}catch(n){throw this.logger.error(n.message),n}},this.disconnect=async i=>{try{return await this.engine.disconnect(i)}catch(n){throw this.logger.error(n.message),n}},this.find=i=>{try{return this.engine.find(i)}catch(n){throw this.logger.error(n.message),n}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}},this.authenticate=async(i,n)=>{try{return await this.engine.authenticate(i,n)}catch(s){throw this.logger.error(s.message),s}},this.formatAuthMessage=i=>{try{return this.engine.formatAuthMessage(i)}catch(n){throw this.logger.error(n.message),n}},this.approveSessionAuthenticate=async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.rejectSessionAuthenticate=async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.name=e?.name||yc.name,this.metadata=e?.metadata||Fd(),this.signConfig=e?.signConfig;const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:ai(Ia({level:e?.logger||yc.logger}));this.core=e?.core||new bc(e),this.logger=Jt(r,this.name),this.session=new Z0(this.core,this.logger),this.proposal=new L_(this.core,this.logger),this.pendingRequest=new q_(this.core,this.logger),this.engine=new B_(this),this.auth=new j_(this.core,this.logger)}static async init(e){const r=new wc(e);return await r.initialize(),r}get context(){return tr(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),setTimeout(()=>{this.engine.processRelayMessageCache()},Y.toMiliseconds(Y.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}const K_=Z0,V_=wc;class H_ extends jt.exports{constructor(){super()}}class Q0{constructor(e){this.opts=e}}class ep{constructor(e){this.client=e}}var W_=Object.defineProperty,G_=Object.defineProperties,J_=Object.getOwnPropertyDescriptors,tp=Object.getOwnPropertySymbols,Y_=Object.prototype.hasOwnProperty,X_=Object.prototype.propertyIsEnumerable,rp=(t,e,r)=>e in t?W_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Z_=(t,e)=>{for(var r in e||(e={}))Y_.call(e,r)&&rp(t,r,e[r]);if(tp)for(var r of tp(e))X_.call(e,r)&&rp(t,r,e[r]);return t},Q_=(t,e)=>G_(t,J_(e));class ex extends ep{constructor(e){super(e),this.init=async()=>{this.signClient=await V_.init({core:this.client.core,metadata:this.client.metadata,signConfig:this.client.signConfig}),this.signClient.core.eventClient.init().catch(r=>{this.client.logger.warn(r)})},this.pair=async r=>{await this.client.core.pairing.pair(r)},this.approveSession=async r=>{const{topic:i,acknowledged:n}=await this.signClient.approve(Q_(Z_({},r),{id:r.id,namespaces:r.namespaces,sessionProperties:r.sessionProperties,sessionConfig:r.sessionConfig}));return await n(),this.signClient.session.get(i)},this.rejectSession=async r=>await this.signClient.reject(r),this.updateSession=async r=>await this.signClient.update(r),this.extendSession=async r=>await this.signClient.extend(r),this.respondSessionRequest=async r=>await this.signClient.respond(r),this.disconnectSession=async r=>await this.signClient.disconnect(r),this.emitSessionEvent=async r=>await this.signClient.emit(r),this.getActiveSessions=()=>this.signClient.session.getAll().reduce((r,i)=>(r[i.topic]=i,r),{}),this.getPendingSessionProposals=()=>this.signClient.proposal.getAll(),this.getPendingSessionRequests=()=>this.signClient.getPendingSessionRequests(),this.approveSessionAuthenticate=async r=>await this.signClient.approveSessionAuthenticate(r),this.rejectSessionAuthenticate=async r=>await this.signClient.rejectSessionAuthenticate(r),this.formatAuthMessage=r=>this.signClient.formatAuthMessage(r),this.registerDeviceToken=r=>this.client.core.echoClient.registerDeviceToken(r),this.on=(r,i)=>(this.setEvent(r,"off"),this.setEvent(r,"on"),this.client.events.on(r,i)),this.once=(r,i)=>(this.setEvent(r,"off"),this.setEvent(r,"once"),this.client.events.once(r,i)),this.off=(r,i)=>(this.setEvent(r,"off"),this.client.events.off(r,i)),this.removeListener=(r,i)=>(this.setEvent(r,"removeListener"),this.client.events.removeListener(r,i)),this.onSessionRequest=r=>{this.client.events.emit("session_request",r)},this.onSessionProposal=r=>{this.client.events.emit("session_proposal",r)},this.onSessionDelete=r=>{this.client.events.emit("session_delete",r)},this.onProposalExpire=r=>{this.client.events.emit("proposal_expire",r)},this.onSessionRequestExpire=r=>{this.client.events.emit("session_request_expire",r)},this.onSessionRequestAuthenticate=r=>{this.client.events.emit("session_authenticate",r)},this.setEvent=(r,i)=>{switch(r){case"session_request":this.signClient.events[i]("session_request",this.onSessionRequest);break;case"session_proposal":this.signClient.events[i]("session_proposal",this.onSessionProposal);break;case"session_delete":this.signClient.events[i]("session_delete",this.onSessionDelete);break;case"proposal_expire":this.signClient.events[i]("proposal_expire",this.onProposalExpire);break;case"session_request_expire":this.signClient.events[i]("session_request_expire",this.onSessionRequestExpire);break;case"session_authenticate":this.signClient.events[i]("session_authenticate",this.onSessionRequestAuthenticate);break}},this.signClient={}}}const tx={decryptMessage:async t=>{const e={core:new bc({storageOptions:t.storageOptions,storage:t.storage})};await e.core.crypto.init();const r=e.core.crypto.decode(t.topic,t.encryptedMessage);return e.core=null,r},getMetadata:async t=>{const e={core:new bc({storageOptions:t.storageOptions,storage:t.storage}),sessionStore:null};e.sessionStore=new K_(e.core,e.core.logger),await e.sessionStore.init();const r=e.sessionStore.get(t.topic),i=r?.peer.metadata;return e.core=null,e.sessionStore=null,i}},ip=class extends Q0{constructor(t){super(t),this.events=new jt.exports,this.on=(e,r)=>this.engine.on(e,r),this.once=(e,r)=>this.engine.once(e,r),this.off=(e,r)=>this.engine.off(e,r),this.removeListener=(e,r)=>this.engine.removeListener(e,r),this.pair=async e=>{try{return await this.engine.pair(e)}catch(r){throw this.logger.error(r.message),r}},this.approveSession=async e=>{try{return await this.engine.approveSession(e)}catch(r){throw this.logger.error(r.message),r}},this.rejectSession=async e=>{try{return await this.engine.rejectSession(e)}catch(r){throw this.logger.error(r.message),r}},this.updateSession=async e=>{try{return await this.engine.updateSession(e)}catch(r){throw this.logger.error(r.message),r}},this.extendSession=async e=>{try{return await this.engine.extendSession(e)}catch(r){throw this.logger.error(r.message),r}},this.respondSessionRequest=async e=>{try{return await this.engine.respondSessionRequest(e)}catch(r){throw this.logger.error(r.message),r}},this.disconnectSession=async e=>{try{return await this.engine.disconnectSession(e)}catch(r){throw this.logger.error(r.message),r}},this.emitSessionEvent=async e=>{try{return await this.engine.emitSessionEvent(e)}catch(r){throw this.logger.error(r.message),r}},this.getActiveSessions=()=>{try{return this.engine.getActiveSessions()}catch(e){throw this.logger.error(e.message),e}},this.getPendingSessionProposals=()=>{try{return this.engine.getPendingSessionProposals()}catch(e){throw this.logger.error(e.message),e}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(e){throw this.logger.error(e.message),e}},this.registerDeviceToken=e=>{try{return this.engine.registerDeviceToken(e)}catch(r){throw this.logger.error(r.message),r}},this.approveSessionAuthenticate=e=>{try{return this.engine.approveSessionAuthenticate(e)}catch(r){throw this.logger.error(r.message),r}},this.rejectSessionAuthenticate=e=>{try{return this.engine.rejectSessionAuthenticate(e)}catch(r){throw this.logger.error(r.message),r}},this.formatAuthMessage=e=>{try{return this.engine.formatAuthMessage(e)}catch(r){throw this.logger.error(r.message),r}},this.metadata=t.metadata,this.name=t.name||ua,this.signConfig=t.signConfig,this.core=t.core,this.logger=this.core.logger,this.engine=new ex(this)}static async init(t){const e=new ip(t);return await e.initialize(),e}async initialize(){this.logger.trace("Initialized");try{await this.engine.init(),this.logger.info("WalletKit Initialization Success")}catch(t){throw this.logger.info("WalletKit Initialization Failure"),this.logger.error(t.message),t}}};let _c=ip;_c.notifications=tx;const rx=_c;kt.CLIENT_CONTEXT=ua,kt.CLIENT_STORAGE_OPTIONS=xp,kt.CLIENT_STORAGE_PREFIX=_p,kt.IWalletKit=Q0,kt.IWalletKitEngine=ep,kt.IWalletKitEvents=H_,kt.PROTOCOL=Nc,kt.PROTOCOL_VERSION=wp,kt.REQUEST_CONTEXT=Ep,kt.WalletKit=rx,kt.default=_c,Object.defineProperty(kt,"__esModule",{value:!0})});
39
+ ***************************************************************************** */var Gf=function(t,e){return Gf=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var n in i)i.hasOwnProperty(n)&&(r[n]=i[n])},Gf(t,e)};function A_(t,e){Gf(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var Yf=function(){return Yf=Object.assign||function(e){for(var r,i=1,n=arguments.length;i<n;i++){r=arguments[i];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Yf.apply(this,arguments)};function D_(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]]);return r}function $_(t,e,r,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(n<3?o(s):n>3?o(e,r,s):o(e,r))||s);return n>3&&s&&Object.defineProperty(e,r,s),s}function O_(t,e){return function(r,i){e(r,i,t)}}function M_(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function P_(t,e,r,i){function n(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(u){try{f(i.next(u))}catch(d){o(d)}}function c(u){try{f(i.throw(u))}catch(d){o(d)}}function f(u){u.done?s(u.value):n(u.value).then(a,c)}f((i=i.apply(t,e||[])).next())})}function R_(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(f){return function(u){return c([f,u])}}function c(f){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,n&&(s=f[0]&2?n.return:f[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,f[1])).done)return s;switch(n=0,s&&(f=[f[0]&2,s.value]),f[0]){case 0:case 1:s=f;break;case 4:return r.label++,{value:f[1],done:!1};case 5:r.label++,n=f[1],f=[0];continue;case 7:f=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(f[0]===6||f[0]===2)){r=0;continue}if(f[0]===3&&(!s||f[1]>s[0]&&f[1]<s[3])){r.label=f[1];break}if(f[0]===6&&r.label<s[1]){r.label=s[1],s=f;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(f);break}s[2]&&r.ops.pop(),r.trys.pop();continue}f=e.call(t,r)}catch(u){f=[6,u],n=0}finally{i=s=0}if(f[0]&5)throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}}function T_(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}function C_(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function Zf(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Cp(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var i=r.call(t),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function N_(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Cp(arguments[e]));return t}function B_(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var i=Array(t),n=0,e=0;e<r;e++)for(var s=arguments[e],o=0,a=s.length;o<a;o++,n++)i[n]=s[o];return i}function Us(t){return this instanceof Us?(this.v=t,this):new Us(t)}function F_(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=r.apply(t,e||[]),n,s=[];return n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n;function o(g){i[g]&&(n[g]=function(m){return new Promise(function(b,x){s.push([g,m,b,x])>1||a(g,m)})})}function a(g,m){try{c(i[g](m))}catch(b){d(s[0][3],b)}}function c(g){g.value instanceof Us?Promise.resolve(g.value.v).then(f,u):d(s[0][2],g)}function f(g){a("next",g)}function u(g){a("throw",g)}function d(g,m){g(m),s.shift(),s.length&&a(s[0][0],s[0][1])}}function L_(t){var e,r;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,s){e[n]=t[n]?function(o){return(r=!r)?{value:Us(t[n](o)),done:n==="return"}:s?s(o):o}:s}}function q_(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof Zf=="function"?Zf(t):t[Symbol.iterator](),r={},i("next"),i("throw"),i("return"),r[Symbol.asyncIterator]=function(){return this},r);function i(s){r[s]=t[s]&&function(o){return new Promise(function(a,c){o=t[s](o),n(a,c,o.done,o.value)})}}function n(s,o,a,c){Promise.resolve(c).then(function(f){s({value:f,done:a})},o)}}function z_(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function U_(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function k_(t){return t&&t.__esModule?t:{default:t}}function j_(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function K_(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}var V_=Object.freeze({__proto__:null,__extends:A_,get __assign(){return Yf},__rest:D_,__decorate:$_,__param:O_,__metadata:M_,__awaiter:P_,__generator:R_,__createBinding:T_,__exportStar:C_,__values:Zf,__read:Cp,__spread:N_,__spreadArrays:B_,__await:Us,__asyncGenerator:F_,__asyncDelegator:L_,__asyncValues:q_,__makeTemplateObject:z_,__importStar:U_,__importDefault:k_,__classPrivateFieldGet:j_,__classPrivateFieldSet:K_}),H_=qa(V_),si={},Np;function W_(){if(Np)return si;Np=1,Object.defineProperty(si,"__esModule",{value:!0}),si.isBrowserCryptoAvailable=si.getSubtleCrypto=si.getBrowerCrypto=void 0;function t(){return Bt?.crypto||Bt?.msCrypto||{}}si.getBrowerCrypto=t;function e(){const i=t();return i.subtle||i.webkitSubtle}si.getSubtleCrypto=e;function r(){return!!t()&&!!e()}return si.isBrowserCryptoAvailable=r,si}var oi={},Bp;function G_(){if(Bp)return oi;Bp=1,Object.defineProperty(oi,"__esModule",{value:!0}),oi.isBrowser=oi.isNode=oi.isReactNative=void 0;function t(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}oi.isReactNative=t;function e(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}oi.isNode=e;function r(){return!t()&&!e()}return oi.isBrowser=r,oi}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=H_;e.__exportStar(W_(),t),e.__exportStar(G_(),t)})(Tp);function zr(t=3){const e=Date.now()*Math.pow(10,t),r=Math.floor(Math.random()*Math.pow(10,t));return e+r}function Qi(t=6){return BigInt(zr(t))}function en(t,e,r){return{id:r||zr(),jsonrpc:"2.0",method:t,params:e}}function Jf(t,e){return{id:t,jsonrpc:"2.0",result:e}}function Xf(t,e,r){return{id:t,jsonrpc:"2.0",error:Y_(e,r)}}function Y_(t,e){return typeof t>"u"?Rp(Mp):(typeof t=="string"&&(t=Object.assign(Object.assign({},Rp(Wf)),{message:t})),typeof e<"u"&&(t.data=e),E_(t.code)&&(t=S_(t.code)),t)}class Z_{}class J_ extends Z_{constructor(){super()}}class X_ extends J_{constructor(e){super()}}const Q_="^wss?:";function ex(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function tx(t,e){const r=ex(t);return typeof r>"u"?!1:new RegExp(e).test(r)}function Fp(t){return tx(t,Q_)}function rx(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function Lp(t){return typeof t=="object"&&"id"in t&&"jsonrpc"in t&&t.jsonrpc==="2.0"}function Qf(t){return Lp(t)&&"method"in t}function xa(t){return Lp(t)&&(Ur(t)||ar(t))}function Ur(t){return"result"in t}function ar(t){return"error"in t}class ix extends X_{constructor(e){super(e),this.events=new Mt.exports.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async request(e,r){return this.requestStrict(en(e.method,e.params||[],e.id||Qi().toString()),r)}async requestStrict(e,r){return new Promise(async(i,n)=>{if(!this.connection.connected)try{await this.open()}catch(s){n(s)}this.events.on(`${e.id}`,s=>{ar(s)?n(s.error):i(s.result)});try{await this.connection.send(e,r)}catch(s){n(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),xa(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}}const nx=()=>typeof WebSocket<"u"?WebSocket:typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),sx=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",qp=t=>t.split("?")[0],zp=10,ox=nx();class ax{constructor(e){if(this.url=e,this.events=new Mt.exports.EventEmitter,this.registering=!1,!Fp(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,r)=>{if(typeof this.socket>"u"){r(new Error("Connection already closed"));return}this.socket.onclose=i=>{this.onClose(i),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(Fi(e))}catch(r){this.onError(e.id,r)}}register(e=this.url){if(!Fp(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((i,n)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),n(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return n(new Error("WebSocket connection is missing or invalid"));i(this.socket)})})}return this.url=e,this.registering=!0,new Promise((r,i)=>{const n=Tp.isReactNative()?void 0:{rejectUnauthorized:!rx(e)},s=new ox(e,[],n);sx()?s.onerror=o=>{const a=o;i(this.emitError(a.error))}:s.on("error",o=>{i(this.emitError(o))}),s.onopen=()=>{this.onOpen(s),r(s)}})}onOpen(e){e.onmessage=r=>this.onPayload(r),e.onclose=r=>this.onClose(r),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;const r=typeof e.data=="string"?bn(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const i=this.parseError(r),n=i.message||i.toString(),s=Xf(e,n);this.events.emit("payload",s)}parseError(e,r=this.url){return I_(e,qp(r),"WS")}resetMaxListeners(){this.events.getMaxListeners()>zp&&this.events.setMaxListeners(zp)}emitError(e){const r=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${qp(this.url)}`));return this.events.emit("register_error",r),r}}var eu={exports:{}};(function(t,e){var r=200,i="__lodash_hash_undefined__",n=1,s=2,o=9007199254740991,a="[object Arguments]",c="[object Array]",f="[object AsyncFunction]",u="[object Boolean]",d="[object Date]",g="[object Error]",m="[object Function]",b="[object GeneratorFunction]",x="[object Map]",I="[object Number]",O="[object Null]",$="[object Object]",P="[object Promise]",R="[object Proxy]",N="[object RegExp]",B="[object Set]",F="[object String]",L="[object Symbol]",C="[object Undefined]",W="[object WeakMap]",A="[object ArrayBuffer]",h="[object DataView]",p="[object Float32Array]",v="[object Float64Array]",y="[object Int8Array]",w="[object Int16Array]",S="[object Int32Array]",D="[object Uint8Array]",_="[object Uint8ClampedArray]",l="[object Uint16Array]",E="[object Uint32Array]",q=/[\\^$.*+?()[\]{}|]/g,z=/^\[object .+?Constructor\]$/,U=/^(?:0|[1-9]\d*)$/,k={};k[p]=k[v]=k[y]=k[w]=k[S]=k[D]=k[_]=k[l]=k[E]=!0,k[a]=k[c]=k[A]=k[u]=k[h]=k[d]=k[g]=k[m]=k[x]=k[I]=k[$]=k[N]=k[B]=k[F]=k[W]=!1;var G=typeof Bt=="object"&&Bt&&Bt.Object===Object&&Bt,J=typeof self=="object"&&self&&self.Object===Object&&self,X=G||J||Function("return this")(),Z=e&&!e.nodeType&&e,Q=Z&&!0&&t&&!t.nodeType&&t,Fe=Q&&Q.exports===Z,re=Fe&&G.process,oe=function(){try{return re&&re.binding&&re.binding("util")}catch{}}(),ct=oe&&oe.isTypedArray;function he(M,T){for(var j=-1,Y=M==null?0:M.length,Me=0,ee=[];++j<Y;){var tt=M[j];T(tt,j,M)&&(ee[Me++]=tt)}return ee}function Pe(M,T){for(var j=-1,Y=T.length,Me=M.length;++j<Y;)M[Me+j]=T[j];return M}function es(M,T){for(var j=-1,Y=M==null?0:M.length;++j<Y;)if(T(M[j],j,M))return!0;return!1}function Re(M,T){for(var j=-1,Y=Array(M);++j<M;)Y[j]=T(j);return Y}function Ae(M){return function(T){return M(T)}}function on(M,T){return M.has(T)}function xe(M,T){return M?.[T]}function De(M){var T=-1,j=Array(M.size);return M.forEach(function(Y,Me){j[++T]=[Me,Y]}),j}function an(M,T){return function(j){return M(T(j))}}function $e(M){var T=-1,j=Array(M.size);return M.forEach(function(Y){j[++T]=Y}),j}var Oe=Array.prototype,cn=Function.prototype,ye=Object.prototype,Ee=X["__core-js_shared__"],fn=cn.toString,ae=ye.hasOwnProperty,Le=function(){var M=/[^.]+$/.exec(Ee&&Ee.keys&&Ee.keys.IE_PROTO||"");return M?"Symbol(src)_1."+M:""}(),Gs=ye.toString,He=RegExp("^"+fn.call(ae).replace(q,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),qe=Fe?X.Buffer:void 0,un=X.Symbol,ze=X.Uint8Array,Ue=ye.propertyIsEnumerable,Oa=Oe.splice,pe=un?un.toStringTag:void 0,ke=Object.getOwnPropertySymbols,Ma=qe?qe.isBuffer:void 0,We=an(Object.keys,Object),Te=rs(X,"DataView"),Oi=rs(X,"Map"),Ce=rs(X,"Promise"),Ne=rs(X,"Set"),ts=rs(X,"WeakMap"),Se=rs(Object,"create"),Ge=hn(Te),Pa=hn(Oi),Ye=hn(Ce),Ze=hn(Ne),Ra=hn(ts),je=un?un.prototype:void 0,Be=je?je.valueOf:void 0;function Hr(M){var T=-1,j=M==null?0:M.length;for(this.clear();++T<j;){var Y=M[T];this.set(Y[0],Y[1])}}function Je(){this.__data__=Se?Se(null):{},this.size=0}function Xe(M){var T=this.has(M)&&delete this.__data__[M];return this.size-=T?1:0,T}function Ta(M){var T=this.__data__;if(Se){var j=T[M];return j===i?void 0:j}return ae.call(T,M)?T[M]:void 0}function Qe(M){var T=this.__data__;return Se?T[M]!==void 0:ae.call(T,M)}function et(M,T){var j=this.__data__;return this.size+=this.has(M)?0:1,j[M]=Se&&T===void 0?i:T,this}Hr.prototype.clear=Je,Hr.prototype.delete=Xe,Hr.prototype.get=Ta,Hr.prototype.has=Qe,Hr.prototype.set=et;function er(M){var T=-1,j=M==null?0:M.length;for(this.clear();++T<j;){var Y=M[T];this.set(Y[0],Y[1])}}function Ys(){this.__data__=[],this.size=0}function Zs(M){var T=this.__data__,j=Ca(T,M);if(j<0)return!1;var Y=T.length-1;return j==Y?T.pop():Oa.call(T,j,1),--this.size,!0}function Js(M){var T=this.__data__,j=Ca(T,M);return j<0?void 0:T[j][1]}function Xs(M){return Ca(this.__data__,M)>-1}function Qs(M,T){var j=this.__data__,Y=Ca(j,M);return Y<0?(++this.size,j.push([M,T])):j[Y][1]=T,this}er.prototype.clear=Ys,er.prototype.delete=Zs,er.prototype.get=Js,er.prototype.has=Xs,er.prototype.set=Qs;function xr(M){var T=-1,j=M==null?0:M.length;for(this.clear();++T<j;){var Y=M[T];this.set(Y[0],Y[1])}}function eo(){this.size=0,this.__data__={hash:new Hr,map:new(Oi||er),string:new Hr}}function to(M){var T=Na(this,M).delete(M);return this.size-=T?1:0,T}function ro(M){return Na(this,M).get(M)}function io(M){return Na(this,M).has(M)}function no(M,T){var j=Na(this,M),Y=j.size;return j.set(M,T),this.size+=j.size==Y?0:1,this}xr.prototype.clear=eo,xr.prototype.delete=to,xr.prototype.get=ro,xr.prototype.has=io,xr.prototype.set=no;function Mi(M){var T=-1,j=M==null?0:M.length;for(this.__data__=new xr;++T<j;)this.add(M[T])}function so(M){return this.__data__.set(M,i),this}function oo(M){return this.__data__.has(M)}Mi.prototype.add=Mi.prototype.push=so,Mi.prototype.has=oo;function ur(M){var T=this.__data__=new er(M);this.size=T.size}function ao(){this.__data__=new er,this.size=0}function co(M){var T=this.__data__,j=T.delete(M);return this.size=T.size,j}function fo(M){return this.__data__.get(M)}function QI(M){return this.__data__.has(M)}function eA(M,T){var j=this.__data__;if(j instanceof er){var Y=j.__data__;if(!Oi||Y.length<r-1)return Y.push([M,T]),this.size=++j.size,this;j=this.__data__=new xr(Y)}return j.set(M,T),this.size=j.size,this}ur.prototype.clear=ao,ur.prototype.delete=co,ur.prototype.get=fo,ur.prototype.has=QI,ur.prototype.set=eA;function tA(M,T){var j=Ba(M),Y=!j&&bA(M),Me=!j&&!Y&&Eu(M),ee=!j&&!Y&&!Me&&j1(M),tt=j||Y||Me||ee,mt=tt?Re(M.length,String):[],$t=mt.length;for(var Ke in M)(T||ae.call(M,Ke))&&!(tt&&(Ke=="length"||Me&&(Ke=="offset"||Ke=="parent")||ee&&(Ke=="buffer"||Ke=="byteLength"||Ke=="byteOffset")||hA(Ke,$t)))&&mt.push(Ke);return mt}function Ca(M,T){for(var j=M.length;j--;)if(q1(M[j][0],T))return j;return-1}function rA(M,T,j){var Y=T(M);return Ba(M)?Y:Pe(Y,j(M))}function uo(M){return M==null?M===void 0?C:O:pe&&pe in Object(M)?fA(M):gA(M)}function N1(M){return ho(M)&&uo(M)==a}function B1(M,T,j,Y,Me){return M===T?!0:M==null||T==null||!ho(M)&&!ho(T)?M!==M&&T!==T:iA(M,T,j,Y,B1,Me)}function iA(M,T,j,Y,Me,ee){var tt=Ba(M),mt=Ba(T),$t=tt?c:Pi(M),Ke=mt?c:Pi(T);$t=$t==a?$:$t,Ke=Ke==a?$:Ke;var tr=$t==$,Er=Ke==$,Nt=$t==Ke;if(Nt&&Eu(M)){if(!Eu(T))return!1;tt=!0,tr=!1}if(Nt&&!tr)return ee||(ee=new ur),tt||j1(M)?F1(M,T,j,Y,Me,ee):aA(M,T,$t,j,Y,Me,ee);if(!(j&n)){var hr=tr&&ae.call(M,"__wrapped__"),dr=Er&&ae.call(T,"__wrapped__");if(hr||dr){var Ri=hr?M.value():M,ci=dr?T.value():T;return ee||(ee=new ur),Me(Ri,ci,j,Y,ee)}}return Nt?(ee||(ee=new ur),cA(M,T,j,Y,Me,ee)):!1}function nA(M){if(!k1(M)||lA(M))return!1;var T=z1(M)?He:z;return T.test(hn(M))}function sA(M){return ho(M)&&U1(M.length)&&!!k[uo(M)]}function oA(M){if(!pA(M))return We(M);var T=[];for(var j in Object(M))ae.call(M,j)&&j!="constructor"&&T.push(j);return T}function F1(M,T,j,Y,Me,ee){var tt=j&n,mt=M.length,$t=T.length;if(mt!=$t&&!(tt&&$t>mt))return!1;var Ke=ee.get(M);if(Ke&&ee.get(T))return Ke==T;var tr=-1,Er=!0,Nt=j&s?new Mi:void 0;for(ee.set(M,T),ee.set(T,M);++tr<mt;){var hr=M[tr],dr=T[tr];if(Y)var Ri=tt?Y(dr,hr,tr,T,M,ee):Y(hr,dr,tr,M,T,ee);if(Ri!==void 0){if(Ri)continue;Er=!1;break}if(Nt){if(!es(T,function(ci,dn){if(!on(Nt,dn)&&(hr===ci||Me(hr,ci,j,Y,ee)))return Nt.push(dn)})){Er=!1;break}}else if(!(hr===dr||Me(hr,dr,j,Y,ee))){Er=!1;break}}return ee.delete(M),ee.delete(T),Er}function aA(M,T,j,Y,Me,ee,tt){switch(j){case h:if(M.byteLength!=T.byteLength||M.byteOffset!=T.byteOffset)return!1;M=M.buffer,T=T.buffer;case A:return!(M.byteLength!=T.byteLength||!ee(new ze(M),new ze(T)));case u:case d:case I:return q1(+M,+T);case g:return M.name==T.name&&M.message==T.message;case N:case F:return M==T+"";case x:var mt=De;case B:var $t=Y&n;if(mt||(mt=$e),M.size!=T.size&&!$t)return!1;var Ke=tt.get(M);if(Ke)return Ke==T;Y|=s,tt.set(M,T);var tr=F1(mt(M),mt(T),Y,Me,ee,tt);return tt.delete(M),tr;case L:if(Be)return Be.call(M)==Be.call(T)}return!1}function cA(M,T,j,Y,Me,ee){var tt=j&n,mt=L1(M),$t=mt.length,Ke=L1(T),tr=Ke.length;if($t!=tr&&!tt)return!1;for(var Er=$t;Er--;){var Nt=mt[Er];if(!(tt?Nt in T:ae.call(T,Nt)))return!1}var hr=ee.get(M);if(hr&&ee.get(T))return hr==T;var dr=!0;ee.set(M,T),ee.set(T,M);for(var Ri=tt;++Er<$t;){Nt=mt[Er];var ci=M[Nt],dn=T[Nt];if(Y)var K1=tt?Y(dn,ci,Nt,T,M,ee):Y(ci,dn,Nt,M,T,ee);if(!(K1===void 0?ci===dn||Me(ci,dn,j,Y,ee):K1)){dr=!1;break}Ri||(Ri=Nt=="constructor")}if(dr&&!Ri){var Fa=M.constructor,La=T.constructor;Fa!=La&&"constructor"in M&&"constructor"in T&&!(typeof Fa=="function"&&Fa instanceof Fa&&typeof La=="function"&&La instanceof La)&&(dr=!1)}return ee.delete(M),ee.delete(T),dr}function L1(M){return rA(M,mA,uA)}function Na(M,T){var j=M.__data__;return dA(T)?j[typeof T=="string"?"string":"hash"]:j.map}function rs(M,T){var j=xe(M,T);return nA(j)?j:void 0}function fA(M){var T=ae.call(M,pe),j=M[pe];try{M[pe]=void 0;var Y=!0}catch{}var Me=Gs.call(M);return Y&&(T?M[pe]=j:delete M[pe]),Me}var uA=ke?function(M){return M==null?[]:(M=Object(M),he(ke(M),function(T){return Ue.call(M,T)}))}:wA,Pi=uo;(Te&&Pi(new Te(new ArrayBuffer(1)))!=h||Oi&&Pi(new Oi)!=x||Ce&&Pi(Ce.resolve())!=P||Ne&&Pi(new Ne)!=B||ts&&Pi(new ts)!=W)&&(Pi=function(M){var T=uo(M),j=T==$?M.constructor:void 0,Y=j?hn(j):"";if(Y)switch(Y){case Ge:return h;case Pa:return x;case Ye:return P;case Ze:return B;case Ra:return W}return T});function hA(M,T){return T=T??o,!!T&&(typeof M=="number"||U.test(M))&&M>-1&&M%1==0&&M<T}function dA(M){var T=typeof M;return T=="string"||T=="number"||T=="symbol"||T=="boolean"?M!=="__proto__":M===null}function lA(M){return!!Le&&Le in M}function pA(M){var T=M&&M.constructor,j=typeof T=="function"&&T.prototype||ye;return M===j}function gA(M){return Gs.call(M)}function hn(M){if(M!=null){try{return fn.call(M)}catch{}try{return M+""}catch{}}return""}function q1(M,T){return M===T||M!==M&&T!==T}var bA=N1(function(){return arguments}())?N1:function(M){return ho(M)&&ae.call(M,"callee")&&!Ue.call(M,"callee")},Ba=Array.isArray;function yA(M){return M!=null&&U1(M.length)&&!z1(M)}var Eu=Ma||_A;function vA(M,T){return B1(M,T)}function z1(M){if(!k1(M))return!1;var T=uo(M);return T==m||T==b||T==f||T==R}function U1(M){return typeof M=="number"&&M>-1&&M%1==0&&M<=o}function k1(M){var T=typeof M;return M!=null&&(T=="object"||T=="function")}function ho(M){return M!=null&&typeof M=="object"}var j1=ct?Ae(ct):sA;function mA(M){return yA(M)?tA(M):oA(M)}function wA(){return[]}function _A(){return!1}t.exports=vA})(eu,eu.exports);var cx=eu.exports;const Up="wc",kp=2,Ea="core",kr=`${Up}@2:${Ea}:`,fx={name:Ea,logger:"error"},ux={database:":memory:"},hx="crypto",jp="client_ed25519_seed",dx=V.ONE_DAY,lx="keychain",px="0.3",gx="messages",bx="0.3",Kp=V.SIX_HOURS,yx="publisher",Vp="irn",vx="error",Hp="wss://relay.walletconnect.org",mx="relayer",bt={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},wx="_subscription",cr={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},_x=.1,tu="2.19.0-canary-sign-msgs-1",Ie={link_mode:"link_mode",relay:"relay"},Sa={inbound:"inbound",outbound:"outbound"},xx="0.3",Ex="WALLETCONNECT_CLIENT_ID",Wp="WALLETCONNECT_LINK_MODE_APPS",Xt={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},Sx="subscription",Ix="0.3",Ax="pairing",Dx="0.3",ks={wc_pairingDelete:{req:{ttl:V.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:V.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:V.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:V.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:V.ONE_DAY,prompt:!1,tag:0},res:{ttl:V.ONE_DAY,prompt:!1,tag:0}}},tn={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},mr={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},$x="history",Ox="0.3",Mx="expirer",fr={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},Px="0.3",Rx="verify-api",Tx="https://verify.walletconnect.com",Gp="https://verify.walletconnect.org",js=Gp,Cx=`${js}/v3`,Nx=[Tx,Gp],Bx="echo",Fx="https://echo.walletconnect.com",jr={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},ai={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},wr={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},rn={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},nn={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},Ks={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},Lx=.1,qx="event-client",zx=86400,Ux="https://pulse.walletconnect.org/batch";function kx(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=n}var a=t.length,c=t.charAt(0),f=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function d(b){if(b instanceof Uint8Array||(ArrayBuffer.isView(b)?b=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):Array.isArray(b)&&(b=Uint8Array.from(b))),!(b instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(b.length===0)return"";for(var x=0,I=0,O=0,$=b.length;O!==$&&b[O]===0;)O++,x++;for(var P=($-O)*u+1>>>0,R=new Uint8Array(P);O!==$;){for(var N=b[O],B=0,F=P-1;(N!==0||B<I)&&F!==-1;F--,B++)N+=256*R[F]>>>0,R[F]=N%a>>>0,N=N/a>>>0;if(N!==0)throw new Error("Non-zero carry");I=B,O++}for(var L=P-I;L!==P&&R[L]===0;)L++;for(var C=c.repeat(x);L<P;++L)C+=t.charAt(R[L]);return C}function g(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;var x=0;if(b[x]!==" "){for(var I=0,O=0;b[x]===c;)I++,x++;for(var $=(b.length-x)*f+1>>>0,P=new Uint8Array($);b[x];){var R=r[b.charCodeAt(x)];if(R===255)return;for(var N=0,B=$-1;(R!==0||N<O)&&B!==-1;B--,N++)R+=a*P[B]>>>0,P[B]=R%256>>>0,R=R/256>>>0;if(R!==0)throw new Error("Non-zero carry");O=N,x++}if(b[x]!==" "){for(var F=$-O;F!==$&&P[F]===0;)F++;for(var L=new Uint8Array(I+($-F)),C=I;F!==$;)L[C++]=P[F++];return L}}}function m(b){var x=g(b);if(x)return x;throw new Error(`Non-${e} character`)}return{encode:d,decodeUnsafe:g,decode:m}}var jx=kx,Kx=jx;const Yp=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},Vx=t=>new TextEncoder().encode(t),Hx=t=>new TextDecoder().decode(t);class Wx{constructor(e,r,i){this.name=e,this.prefix=r,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class Gx{constructor(e,r,i){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Zp(this,e)}}class Yx{constructor(e){this.decoders=e}or(e){return Zp(this,e)}decode(e){const r=e[0],i=this.decoders[r];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Zp=(t,e)=>new Yx({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class Zx{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new Wx(e,r,i),this.decoder=new Gx(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Ia=({name:t,prefix:e,encode:r,decode:i})=>new Zx(t,e,r,i),Vs=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=Kx(r,e);return Ia({prefix:t,name:e,encode:i,decode:s=>Yp(n(s))})},Jx=(t,e,r,i)=>{const n={};for(let u=0;u<e.length;++u)n[e[u]]=u;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,f=0;for(let u=0;u<s;++u){const d=n[t[u]];if(d===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<r|d,a+=r,a>=8&&(a-=8,o[f++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},Xx=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>r;)o-=r,s+=e[n&a>>o];if(o&&(s+=e[n&a<<r-o]),i)for(;s.length*r&7;)s+="=";return s},It=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>Ia({prefix:e,name:t,encode(n){return Xx(n,i,r)},decode(n){return Jx(n,i,r,t)}}),Qx=Ia({prefix:"\0",name:"identity",encode:t=>Hx(t),decode:t=>Vx(t)});var eE=Object.freeze({__proto__:null,identity:Qx});const tE=It({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var rE=Object.freeze({__proto__:null,base2:tE});const iE=It({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var nE=Object.freeze({__proto__:null,base8:iE});const sE=Vs({prefix:"9",name:"base10",alphabet:"0123456789"});var oE=Object.freeze({__proto__:null,base10:sE});const aE=It({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),cE=It({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var fE=Object.freeze({__proto__:null,base16:aE,base16upper:cE});const uE=It({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),hE=It({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),dE=It({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),lE=It({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),pE=It({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),gE=It({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),bE=It({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),yE=It({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),vE=It({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var mE=Object.freeze({__proto__:null,base32:uE,base32upper:hE,base32pad:dE,base32padupper:lE,base32hex:pE,base32hexupper:gE,base32hexpad:bE,base32hexpadupper:yE,base32z:vE});const wE=Vs({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),_E=Vs({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var xE=Object.freeze({__proto__:null,base36:wE,base36upper:_E});const EE=Vs({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),SE=Vs({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var IE=Object.freeze({__proto__:null,base58btc:EE,base58flickr:SE});const AE=It({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),DE=It({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),$E=It({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),OE=It({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var ME=Object.freeze({__proto__:null,base64:AE,base64pad:DE,base64url:$E,base64urlpad:OE});const Jp=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),PE=Jp.reduce((t,e,r)=>(t[r]=e,t),[]),RE=Jp.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function TE(t){return t.reduce((e,r)=>(e+=PE[r],e),"")}function CE(t){const e=[];for(const r of t){const i=RE[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const NE=Ia({prefix:"\u{1F680}",name:"base256emoji",encode:TE,decode:CE});var BE=Object.freeze({__proto__:null,base256emoji:NE}),FE=Qp,Xp=128,LE=127,qE=~LE,zE=Math.pow(2,31);function Qp(t,e,r){e=e||[],r=r||0;for(var i=r;t>=zE;)e[r++]=t&255|Xp,t/=128;for(;t&qE;)e[r++]=t&255|Xp,t>>>=7;return e[r]=t|0,Qp.bytes=r-i+1,e}var UE=ru,kE=128,e1=127;function ru(t,i){var r=0,i=i||0,n=0,s=i,o,a=t.length;do{if(s>=a)throw ru.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=n<28?(o&e1)<<n:(o&e1)*Math.pow(2,n),n+=7}while(o>=kE);return ru.bytes=s-i,r}var jE=Math.pow(2,7),KE=Math.pow(2,14),VE=Math.pow(2,21),HE=Math.pow(2,28),WE=Math.pow(2,35),GE=Math.pow(2,42),YE=Math.pow(2,49),ZE=Math.pow(2,56),JE=Math.pow(2,63),XE=function(t){return t<jE?1:t<KE?2:t<VE?3:t<HE?4:t<WE?5:t<GE?6:t<YE?7:t<ZE?8:t<JE?9:10},QE={encode:FE,decode:UE,encodingLength:XE},t1=QE;const r1=(t,e,r=0)=>(t1.encode(t,e,r),e),i1=t=>t1.encodingLength(t),iu=(t,e)=>{const r=e.byteLength,i=i1(t),n=i+i1(r),s=new Uint8Array(n+r);return r1(t,s,0),r1(r,s,i),s.set(e,n),new eS(t,r,e,s)};class eS{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const n1=({name:t,code:e,encode:r})=>new tS(t,e,r);class tS{constructor(e,r,i){this.name=e,this.code=r,this.encode=i}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?iu(this.code,r):r.then(i=>iu(this.code,i))}else throw Error("Unknown type, must be binary type")}}const s1=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),rS=n1({name:"sha2-256",code:18,encode:s1("SHA-256")}),iS=n1({name:"sha2-512",code:19,encode:s1("SHA-512")});var nS=Object.freeze({__proto__:null,sha256:rS,sha512:iS});const o1=0,sS="identity",a1=Yp;var oS=Object.freeze({__proto__:null,identity:{code:o1,name:sS,encode:a1,digest:t=>iu(o1,a1(t))}});new TextEncoder,new TextDecoder;const c1={...eE,...rE,...nE,...oE,...fE,...mE,...xE,...IE,...ME,...BE};({...nS,...oS});function aS(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function f1(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const u1=f1("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),nu=f1("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=aS(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),cS={utf8:u1,"utf-8":u1,hex:c1.base16,latin1:nu,ascii:nu,binary:nu,...c1};function fS(t,e="utf8"){const r=cS[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t,"utf8"):r.decoder.decode(`${r.prefix}${t}`)}var uS=Object.defineProperty,hS=(t,e,r)=>e in t?uS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Kr=(t,e,r)=>hS(t,typeof e!="symbol"?e+"":e,r);class dS{constructor(e,r){this.core=e,this.logger=r,Kr(this,"keychain",new Map),Kr(this,"name",lx),Kr(this,"version",px),Kr(this,"initialized",!1),Kr(this,"storagePrefix",kr),Kr(this,"init",async()=>{if(!this.initialized){const i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}}),Kr(this,"has",i=>(this.isInitialized(),this.keychain.has(i))),Kr(this,"set",async(i,n)=>{this.isInitialized(),this.keychain.set(i,n),await this.persist()}),Kr(this,"get",i=>{this.isInitialized();const n=this.keychain.get(i);if(typeof n>"u"){const{message:s}=H("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(s)}return n}),Kr(this,"del",async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()}),this.core=e,this.logger=Ft(r,this.name)}get context(){return kt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,xf(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Ef(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=H("NOT_INITIALIZED",this.name);throw new Error(e)}}}var lS=Object.defineProperty,pS=(t,e,r)=>e in t?lS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,At=(t,e,r)=>pS(t,typeof e!="symbol"?e+"":e,r);class gS{constructor(e,r,i){this.core=e,this.logger=r,At(this,"name",hx),At(this,"keychain"),At(this,"randomSessionIdentifier",jf()),At(this,"initialized",!1),At(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)}),At(this,"hasKeys",n=>(this.isInitialized(),this.keychain.has(n))),At(this,"getClientId",async()=>{this.isInitialized();const n=await this.getClientSeed(),s=td(n);return ed(s.publicKey)}),At(this,"generateKeyPair",()=>{this.isInitialized();const n=x7();return this.setPrivateKey(n.publicKey,n.privateKey)}),At(this,"signJWT",async n=>{this.isInitialized();const s=await this.getClientSeed(),o=td(s),a=this.randomSessionIdentifier;return await Kv(a,n,dx,o)}),At(this,"generateSharedKey",(n,s,o)=>{this.isInitialized();const a=this.getPrivateKey(n),c=E7(a,s);return this.setSymKey(c,o)}),At(this,"setSymKey",async(n,s)=>{this.isInitialized();const o=s||ya(n);return await this.keychain.set(o,n),o}),At(this,"deleteKeyPair",async n=>{this.isInitialized(),await this.keychain.del(n)}),At(this,"deleteSymKey",async n=>{this.isInitialized(),await this.keychain.del(n)}),At(this,"encode",async(n,s,o)=>{this.isInitialized();const a=yp(o),c=Fi(s);if(mp(a))return A7(c,o?.encoding);if(vp(a)){const g=a.senderPublicKey,m=a.receiverPublicKey;n=await this.generateSharedKey(g,m)}const f=this.getSymKey(n),{type:u,senderPublicKey:d}=a;return S7({type:u,symKey:f,message:c,senderPublicKey:d,encoding:o?.encoding})}),At(this,"decode",async(n,s,o)=>{this.isInitialized();const a=$7(s,o);if(mp(a)){const c=D7(s,o?.encoding);return bn(c)}if(vp(a)){const c=a.receiverPublicKey,f=a.senderPublicKey;n=await this.generateSharedKey(c,f)}try{const c=this.getSymKey(n),f=I7({symKey:c,encoded:s,encoding:o?.encoding});return bn(f)}catch(c){this.logger.error(`Failed to decode message from topic: '${n}', clientId: '${await this.getClientId()}'`),this.logger.error(c)}}),At(this,"getPayloadType",(n,s=$i)=>{const o=Bs({encoded:n,encoding:s});return Xi(o.type)}),At(this,"getPayloadSenderPublicKey",(n,s=$i)=>{const o=Bs({encoded:n,encoding:s});return o.senderPublicKey?qt(o.senderPublicKey,Tt):void 0}),this.core=e,this.logger=Ft(r,this.name),this.keychain=i||new dS(this.core,this.logger)}get context(){return kt(this.logger)}async setPrivateKey(e,r){return await this.keychain.set(e,r),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(jp)}catch{e=jf(),await this.keychain.set(jp,e)}return fS(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=H("NOT_INITIALIZED",this.name);throw new Error(e)}}}var bS=Object.defineProperty,yS=Object.defineProperties,vS=Object.getOwnPropertyDescriptors,h1=Object.getOwnPropertySymbols,mS=Object.prototype.hasOwnProperty,wS=Object.prototype.propertyIsEnumerable,su=(t,e,r)=>e in t?bS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,_S=(t,e)=>{for(var r in e||(e={}))mS.call(e,r)&&su(t,r,e[r]);if(h1)for(var r of h1(e))wS.call(e,r)&&su(t,r,e[r]);return t},xS=(t,e)=>yS(t,vS(e)),Qt=(t,e,r)=>su(t,typeof e!="symbol"?e+"":e,r);class ES extends jb{constructor(e,r){super(e,r),this.logger=e,this.core=r,Qt(this,"messages",new Map),Qt(this,"messagesWithoutClientAck",new Map),Qt(this,"name",gx),Qt(this,"version",bx),Qt(this,"initialized",!1),Qt(this,"storagePrefix",kr),Qt(this,"init",async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i);const n=await this.getRelayerMessagesWithoutClientAck();typeof n<"u"&&(this.messagesWithoutClientAck=n),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i)}finally{this.initialized=!0}}}),Qt(this,"set",async(i,n,s)=>{this.isInitialized();const o=qr(n);let a=this.messages.get(i);if(typeof a>"u"&&(a={}),typeof a[o]<"u")return o;if(a[o]=n,this.messages.set(i,a),s===Sa.inbound){const c=this.messagesWithoutClientAck.get(i)||{};this.messagesWithoutClientAck.set(i,xS(_S({},c),{[o]:n}))}return await this.persist(),o}),Qt(this,"get",i=>{this.isInitialized();let n=this.messages.get(i);return typeof n>"u"&&(n={}),n}),Qt(this,"getWithoutAck",i=>{this.isInitialized();const n={};for(const s of i){const o=this.messagesWithoutClientAck.get(s)||{};n[s]=Object.values(o)}return n}),Qt(this,"has",(i,n)=>{this.isInitialized();const s=this.get(i),o=qr(n);return typeof s[o]<"u"}),Qt(this,"ack",async(i,n)=>{this.isInitialized();const s=this.messagesWithoutClientAck.get(i);if(typeof s>"u")return;const o=qr(n);delete s[o],Object.keys(s).length===0?this.messagesWithoutClientAck.delete(i):this.messagesWithoutClientAck.set(i,s),await this.persist()}),Qt(this,"del",async i=>{this.isInitialized(),this.messages.delete(i),this.messagesWithoutClientAck.delete(i),await this.persist()}),this.logger=Ft(e,this.name),this.core=r}get context(){return kt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get storageKeyWithoutClientAck(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name+"_withoutClientAck"}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,xf(e))}async setRelayerMessagesWithoutClientAck(e){await this.core.storage.setItem(this.storageKeyWithoutClientAck,xf(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Ef(e):void 0}async getRelayerMessagesWithoutClientAck(){const e=await this.core.storage.getItem(this.storageKeyWithoutClientAck);return typeof e<"u"?Ef(e):void 0}async persist(){await this.setRelayerMessages(this.messages),await this.setRelayerMessagesWithoutClientAck(this.messagesWithoutClientAck)}isInitialized(){if(!this.initialized){const{message:e}=H("NOT_INITIALIZED",this.name);throw new Error(e)}}}var SS=Object.defineProperty,IS=Object.defineProperties,AS=Object.getOwnPropertyDescriptors,d1=Object.getOwnPropertySymbols,DS=Object.prototype.hasOwnProperty,$S=Object.prototype.propertyIsEnumerable,ou=(t,e,r)=>e in t?SS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Aa=(t,e)=>{for(var r in e||(e={}))DS.call(e,r)&&ou(t,r,e[r]);if(d1)for(var r of d1(e))$S.call(e,r)&&ou(t,r,e[r]);return t},au=(t,e)=>IS(t,AS(e)),_r=(t,e,r)=>ou(t,typeof e!="symbol"?e+"":e,r);class OS extends Kb{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,_r(this,"events",new Mt.exports.EventEmitter),_r(this,"name",yx),_r(this,"queue",new Map),_r(this,"publishTimeout",V.toMiliseconds(V.ONE_MINUTE)),_r(this,"initialPublishTimeout",V.toMiliseconds(V.ONE_SECOND*15)),_r(this,"needsTransportRestart",!1),_r(this,"publish",async(i,n,s)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:n,opts:s}});const a=s?.ttl||Kp,c=va(s),f=s?.prompt||!1,u=s?.tag||0,d=s?.id||Qi().toString(),g={topic:i,message:n,opts:{ttl:a,relay:c,prompt:f,tag:u,id:d,attestation:s?.attestation,tvf:s?.tvf}},m=`Failed to publish payload, please try again. id:${d} tag:${u}`;try{const b=new Promise(async x=>{const I=({id:$})=>{g.opts.id===$&&(this.removeRequestFromQueue($),this.relayer.events.removeListener(bt.publish,I),x(g))};this.relayer.events.on(bt.publish,I);const O=Ei(new Promise(($,P)=>{this.rpcPublish({topic:i,message:n,ttl:a,prompt:f,tag:u,id:d,attestation:s?.attestation,tvf:s?.tvf}).then($).catch(R=>{this.logger.warn(R,R?.message),P(R)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${d} tag:${u}`);try{await O,this.events.removeListener(bt.publish,I)}catch($){this.queue.set(d,au(Aa({},g),{attempt:1})),this.logger.warn($,$?.message)}});this.logger.trace({type:"method",method:"publish",params:{id:d,topic:i,message:n,opts:s}}),await Ei(b,this.publishTimeout,m)}catch(b){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(b),(o=s?.internal)!=null&&o.throwOnFailedPublish)throw b}finally{this.queue.delete(d)}}),_r(this,"on",(i,n)=>{this.events.on(i,n)}),_r(this,"once",(i,n)=>{this.events.once(i,n)}),_r(this,"off",(i,n)=>{this.events.off(i,n)}),_r(this,"removeListener",(i,n)=>{this.events.removeListener(i,n)}),this.relayer=e,this.logger=Ft(r,this.name),this.registerEventListeners()}get context(){return kt(this.logger)}async rpcPublish(e){var r,i,n,s;const{topic:o,message:a,ttl:c=Kp,prompt:f,tag:u,id:d,attestation:g,tvf:m}=e,b={method:Fs(va().protocol).publish,params:Aa({topic:o,message:a,ttl:c,prompt:f,tag:u,attestation:g},m),id:d};St((r=b.params)==null?void 0:r.prompt)&&((i=b.params)==null||delete i.prompt),St((n=b.params)==null?void 0:n.tag)&&((s=b.params)==null||delete s.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:b});const x=await this.relayer.request(b);return this.relayer.events.emit(bt.publish,e),this.logger.debug("Successfully Published Payload"),x}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,r)=>{const i=e.attempt+1;this.queue.set(r,au(Aa({},e),{attempt:i}));const{topic:n,message:s,opts:o,attestation:a}=e;this.logger.warn({},`Publisher: queue->publishing: ${e.opts.id}, tag: ${e.opts.tag}, attempt: ${i}`),await this.rpcPublish(au(Aa({},e),{topic:n,message:s,ttl:o.ttl,prompt:o.prompt,tag:o.tag,id:o.id,attestation:a,tvf:o.tvf})),this.logger.warn({},`Publisher: queue->published: ${e.opts.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(gn.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(bt.connection_stalled);return}this.checkQueue()}),this.relayer.on(bt.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}var MS=Object.defineProperty,PS=(t,e,r)=>e in t?MS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Xn=(t,e,r)=>PS(t,typeof e!="symbol"?e+"":e,r);class RS{constructor(){Xn(this,"map",new Map),Xn(this,"set",(e,r)=>{const i=this.get(e);this.exists(e,r)||this.map.set(e,[...i,r])}),Xn(this,"get",e=>this.map.get(e)||[]),Xn(this,"exists",(e,r)=>this.get(e).includes(r)),Xn(this,"delete",(e,r)=>{if(typeof r>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const i=this.get(e);if(!this.exists(e,r))return;const n=i.filter(s=>s!==r);if(!n.length){this.map.delete(e);return}this.map.set(e,n)}),Xn(this,"clear",()=>{this.map.clear()})}get topics(){return Array.from(this.map.keys())}}var TS=Object.defineProperty,CS=Object.defineProperties,NS=Object.getOwnPropertyDescriptors,l1=Object.getOwnPropertySymbols,BS=Object.prototype.hasOwnProperty,FS=Object.prototype.propertyIsEnumerable,cu=(t,e,r)=>e in t?TS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Hs=(t,e)=>{for(var r in e||(e={}))BS.call(e,r)&&cu(t,r,e[r]);if(l1)for(var r of l1(e))FS.call(e,r)&&cu(t,r,e[r]);return t},fu=(t,e)=>CS(t,NS(e)),ge=(t,e,r)=>cu(t,typeof e!="symbol"?e+"":e,r);class LS extends Wb{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,ge(this,"subscriptions",new Map),ge(this,"topicMap",new RS),ge(this,"events",new Mt.exports.EventEmitter),ge(this,"name",Sx),ge(this,"version",Ix),ge(this,"pending",new Map),ge(this,"cached",[]),ge(this,"initialized",!1),ge(this,"storagePrefix",kr),ge(this,"subscribeTimeout",V.toMiliseconds(V.ONE_MINUTE)),ge(this,"initialSubscribeTimeout",V.toMiliseconds(V.ONE_SECOND*15)),ge(this,"clientId"),ge(this,"batchSubscribeTopicsLimit",500),ge(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0}),ge(this,"subscribe",async(i,n)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}});try{const s=va(n),o={topic:i,relay:s,transportType:n?.transportType};this.pending.set(i,o);const a=await this.rpcSubscribe(i,s,n);return typeof a=="string"&&(this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}})),a}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}}),ge(this,"unsubscribe",async(i,n)=>{this.isInitialized(),typeof n?.id<"u"?await this.unsubscribeById(i,n.id,n):await this.unsubscribeByTopic(i,n)}),ge(this,"isSubscribed",i=>new Promise(n=>{n(this.topicMap.topics.includes(i))})),ge(this,"isKnownTopic",i=>new Promise(n=>{n(this.topicMap.topics.includes(i)||this.pending.has(i)||this.cached.some(s=>s.topic===i))})),ge(this,"on",(i,n)=>{this.events.on(i,n)}),ge(this,"once",(i,n)=>{this.events.once(i,n)}),ge(this,"off",(i,n)=>{this.events.off(i,n)}),ge(this,"removeListener",(i,n)=>{this.events.removeListener(i,n)}),ge(this,"start",async()=>{await this.onConnect()}),ge(this,"stop",async()=>{await this.onDisconnect()}),ge(this,"restart",async()=>{await this.restore(),await this.onRestart()}),ge(this,"checkPending",async()=>{if(this.pending.size===0&&(!this.initialized||!this.relayer.connected))return;const i=[];this.pending.forEach(n=>{i.push(n)}),await this.batchSubscribe(i)}),ge(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(gn.pulse,async()=>{await this.checkPending()}),this.events.on(Xt.created,async i=>{const n=Xt.created;this.logger.info(`Emitting ${n}`),this.logger.debug({type:"event",event:n,data:i}),await this.persist()}),this.events.on(Xt.deleted,async i=>{const n=Xt.deleted;this.logger.info(`Emitting ${n}`),this.logger.debug({type:"event",event:n,data:i}),await this.persist()})}),this.relayer=e,this.logger=Ft(r,this.name),this.clientId=""}get context(){return kt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}get hasAnyTopics(){return this.topicMap.topics.length>0||this.pending.size>0||this.cached.length>0||this.subscriptions.size>0}hasSubscription(e,r){let i=!1;try{i=this.getSubscription(e).topic===r}catch{}return i}reset(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,r){const i=this.topicMap.get(e);await Promise.all(i.map(async n=>await this.unsubscribeById(e,n,r)))}async unsubscribeById(e,r,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:i}});try{const n=va(i);await this.restartToComplete({topic:e,id:r,relay:n}),await this.rpcUnsubscribe(e,r,n);const s=we("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,r,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:i}})}catch(n){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(n),n}}async rpcSubscribe(e,r,i){var n;(!i||i?.transportType===Ie.relay)&&await this.restartToComplete({topic:e,id:e,relay:r});const s={method:Fs(r.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});const o=(n=i?.internal)==null?void 0:n.throwOnFailedPublish;try{const a=await this.getSubscriptionId(e);if(i?.transportType===Ie.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(u=>this.logger.warn(u))},V.toMiliseconds(V.ONE_SECOND)),a;const c=new Promise(async u=>{const d=g=>{g.topic===e&&(this.events.removeListener(Xt.created,d),u(g.id))};this.events.on(Xt.created,d);try{const g=await Ei(new Promise((m,b)=>{this.relayer.request(s).catch(x=>{this.logger.warn(x,x?.message),b(x)}).then(m)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(Xt.created,d),u(g)}catch{}}),f=await Ei(c,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!f&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return f?a:null}catch(a){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(bt.connection_stalled),o)throw a}return null}async rpcBatchSubscribe(e){if(!e.length)return;const r=e[0].relay,i={method:Fs(r.protocol).batchSubscribe,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{await await Ei(new Promise(n=>{this.relayer.request(i).catch(s=>this.logger.warn(s)).then(n)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(bt.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const r=e[0].relay,i={method:Fs(r.protocol).batchFetchMessages,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let n;try{n=await await Ei(new Promise((s,o)=>{this.relayer.request(i).catch(a=>{this.logger.warn(a),o(a)}).then(s)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(bt.connection_stalled)}return n}rpcUnsubscribe(e,r,i){const n={method:Fs(i.protocol).unsubscribe,params:{topic:e,id:r}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),this.relayer.request(n)}onSubscribe(e,r){this.setSubscription(e,fu(Hs({},r),{id:e})),this.pending.delete(r.topic)}onBatchSubscribe(e){e.length&&e.forEach(r=>{this.setSubscription(r.id,Hs({},r)),this.pending.delete(r.topic)})}async onUnsubscribe(e,r,i){this.events.removeAllListeners(r),this.hasSubscription(r,e)&&this.deleteSubscription(r,i),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,r){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:r}),this.addSubscription(e,r)}addSubscription(e,r){this.subscriptions.set(e,Hs({},r)),this.topicMap.set(r.topic,e),this.events.emit(Xt.created,r)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const r=this.subscriptions.get(e);if(!r){const{message:i}=H("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return r}deleteSubscription(e,r){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:r});const i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(Xt.deleted,fu(Hs({},i),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Xt.sync)}async onRestart(){if(this.cached.length){const e=[...this.cached],r=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let i=0;i<r;i++){const n=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(n)}}this.events.emit(Xt.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:r}=H("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){e.length&&(await this.rpcBatchSubscribe(e),this.onBatchSubscribe(await Promise.all(e.map(async r=>fu(Hs({},r),{id:await this.getSubscriptionId(r.topic)})))))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const r=await this.rpcBatchFetchMessages(e);r&&r.messages&&(await F5(V.toMiliseconds(V.ONE_SECOND)),await this.relayer.handleBatchMessageEvents(r.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){const{message:e}=H("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(e){!this.relayer.connected&&!this.relayer.connecting&&(this.cached.push(e),await this.relayer.transportOpen())}async getClientId(){return this.clientId||(this.clientId=await this.relayer.core.crypto.getClientId()),this.clientId}async getSubscriptionId(e){return qr(e+await this.getClientId())}}var qS=Object.defineProperty,p1=Object.getOwnPropertySymbols,zS=Object.prototype.hasOwnProperty,US=Object.prototype.propertyIsEnumerable,uu=(t,e,r)=>e in t?qS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,g1=(t,e)=>{for(var r in e||(e={}))zS.call(e,r)&&uu(t,r,e[r]);if(p1)for(var r of p1(e))US.call(e,r)&&uu(t,r,e[r]);return t},fe=(t,e,r)=>uu(t,typeof e!="symbol"?e+"":e,r);class kS extends Vb{constructor(e){super(e),fe(this,"protocol","wc"),fe(this,"version",2),fe(this,"core"),fe(this,"logger"),fe(this,"events",new Mt.exports.EventEmitter),fe(this,"provider"),fe(this,"messages"),fe(this,"subscriber"),fe(this,"publisher"),fe(this,"name",mx),fe(this,"transportExplicitlyClosed",!1),fe(this,"initialized",!1),fe(this,"connectionAttemptInProgress",!1),fe(this,"relayUrl"),fe(this,"projectId"),fe(this,"packageName"),fe(this,"bundleId"),fe(this,"hasExperiencedNetworkDisruption",!1),fe(this,"pingTimeout"),fe(this,"heartBeatTimeout",V.toMiliseconds(V.THIRTY_SECONDS+V.FIVE_SECONDS)),fe(this,"reconnectTimeout"),fe(this,"connectPromise"),fe(this,"reconnectInProgress",!1),fe(this,"requestsInFlight",[]),fe(this,"connectTimeout",V.toMiliseconds(V.ONE_SECOND*15)),fe(this,"request",async r=>{var i,n;this.logger.debug("Publishing Request Payload");const s=r.id||Qi().toString();await this.toEstablishConnection();try{this.logger.trace({id:s,method:r.method,topic:(i=r.params)==null?void 0:i.topic},"relayer.request - publishing...");const o=`${s}:${((n=r.params)==null?void 0:n.tag)||""}`;this.requestsInFlight.push(o);const a=await this.provider.request(r);return this.requestsInFlight=this.requestsInFlight.filter(c=>c!==o),a}catch(o){throw this.logger.debug(`Failed to Publish Request: ${s}`),o}}),fe(this,"resetPingTimeout",()=>{if(fa())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var r,i,n;this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),(n=(i=(r=this.provider)==null?void 0:r.connection)==null?void 0:i.socket)==null||n.terminate()},this.heartBeatTimeout)}catch(r){this.logger.warn(r,r?.message)}}),fe(this,"onPayloadHandler",r=>{this.onProviderPayload(r),this.resetPingTimeout()}),fe(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected \u{1F6DC}"),this.startPingTimeout(),this.events.emit(bt.connect)}),fe(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected \u{1F6D1}"),this.requestsInFlight=[],this.onProviderDisconnect()}),fe(this,"onProviderErrorHandler",r=>{this.logger.fatal(`Fatal socket error: ${r.message}`),this.events.emit(bt.error,r),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()}),fe(this,"registerProviderListeners",()=>{this.provider.on(cr.payload,this.onPayloadHandler),this.provider.on(cr.connect,this.onConnectHandler),this.provider.on(cr.disconnect,this.onDisconnectHandler),this.provider.on(cr.error,this.onProviderErrorHandler)}),this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?Ft(e.logger,this.name):Wr(tc({level:e.logger||vx})),this.messages=new ES(this.logger,e.core),this.subscriber=new LS(this,this.logger),this.publisher=new OS(this,this.logger),this.relayUrl=e?.relayUrl||Hp,this.projectId=e.projectId,_5()?this.packageName=v0():x5()&&(this.bundleId=v0()),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.hasAnyTopics)try{await this.transportOpen()}catch(e){this.logger.warn(e,e?.message)}}get context(){return kt(this.logger)}get connected(){var e,r,i;return((i=(r=(e=this.provider)==null?void 0:e.connection)==null?void 0:r.socket)==null?void 0:i.readyState)===1||!1}get connecting(){var e,r,i;return((i=(r=(e=this.provider)==null?void 0:e.connection)==null?void 0:r.socket)==null?void 0:i.readyState)===0||this.connectPromise!==void 0||!1}async publish(e,r,i){this.isInitialized(),await this.publisher.publish(e,r,i),await this.recordMessageEvent({topic:e,message:r,publishedAt:Date.now(),transportType:Ie.relay},Sa.outbound)}async subscribe(e,r){var i,n,s;this.isInitialized(),(!(r!=null&&r.transportType)||r?.transportType==="relay")&&await this.toEstablishConnection();const o=typeof((i=r?.internal)==null?void 0:i.throwOnFailedPublish)>"u"?!0:(n=r?.internal)==null?void 0:n.throwOnFailedPublish;let a=((s=this.subscriber.topicMap.get(e))==null?void 0:s[0])||"",c;const f=u=>{u.topic===e&&(this.subscriber.off(Xt.created,f),c())};return await Promise.all([new Promise(u=>{c=u,this.subscriber.on(Xt.created,f)}),new Promise(async(u,d)=>{a=await this.subscriber.subscribe(e,g1({internal:{throwOnFailedPublish:o}},r)).catch(g=>{o&&d(g)})||a,u()})]),a}async unsubscribe(e,r){this.isInitialized(),await this.subscriber.unsubscribe(e,r)}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await Ei(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){if(!this.subscriber.hasAnyTopics){this.logger.warn("Starting WS connection skipped because the client has no topics to work with.");return}if(this.connectPromise?(this.logger.debug({},"Waiting for existing connection attempt to resolve..."),await this.connectPromise,this.logger.debug({},"Existing connection attempt resolved")):(this.connectPromise=new Promise(async(r,i)=>{await this.connect(e).then(r).catch(i).finally(()=>{this.connectPromise=void 0})}),await this.connectPromise),!this.connected)throw new Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}async restartTransport(e){this.logger.debug({},"Restarting transport..."),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await Op())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(e?.length===0){this.logger.trace("Batch message events is empty. Ignoring...");return}const r=e.sort((i,n)=>i.publishedAt-n.publishedAt);this.logger.debug(`Batch of ${r.length} message events sorted`);for(const i of r)try{await this.onMessageEvent(i)}catch(n){this.logger.warn(n,"Error while processing batch message event: "+n?.message)}this.logger.trace(`Batch of ${r.length} message events processed`)}async onLinkMessageEvent(e,r){const{topic:i}=e;if(!r.sessionExists){const n=at(V.FIVE_MINUTES),s={topic:i,expiry:n,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,s)}this.events.emit(bt.message,e),await this.recordMessageEvent(e,Sa.inbound)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let r=1;for(;r<6;){try{if(this.transportExplicitlyClosed)break;this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${r}...`),await this.createProvider(),await new Promise(async(i,n)=>{const s=()=>{n(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(cr.disconnect,s),await Ei(new Promise((o,a)=>{this.provider.connect().then(o).catch(a)}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(o=>{n(o)}).finally(()=>{this.provider.off(cr.disconnect,s),clearTimeout(this.reconnectTimeout)}),await new Promise(async(o,a)=>{const c=()=>{a(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(cr.disconnect,c),await this.subscriber.start().then(o).catch(a).finally(()=>{this.provider.off(cr.disconnect,c)})}),this.hasExperiencedNetworkDisruption=!1,i()})}catch(i){await this.subscriber.stop();const n=i;this.logger.warn({},n.message),this.hasExperiencedNetworkDisruption=!0}finally{this.connectionAttemptInProgress=!1}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${r}`);break}await new Promise(i=>setTimeout(i,V.toMiliseconds(r*1))),r++}}startPingTimeout(){var e,r,i,n,s;if(fa())try{(r=(e=this.provider)==null?void 0:e.connection)!=null&&r.socket&&((s=(n=(i=this.provider)==null?void 0:i.connection)==null?void 0:n.socket)==null||s.on("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o,o?.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new ix(new ax(A5({sdkVersion:tu,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId,packageName:this.packageName}))),this.registerProviderListeners()}async recordMessageEvent(e,r){const{topic:i,message:n}=e;await this.messages.set(i,n,r)}async shouldIgnoreMessageEvent(e){const{topic:r,message:i}=e;if(!i||i.length===0)return this.logger.warn(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isKnownTopic(r))return this.logger.warn(`Ignoring message for unknown topic ${r}`),!0;const n=this.messages.has(r,i);return n&&this.logger.warn(`Ignoring duplicate message: ${i}`),n}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Qf(e)){if(!e.method.endsWith(wx))return;const r=e.params,{topic:i,message:n,publishedAt:s,attestation:o}=r.data,a={topic:i,message:n,publishedAt:s,transportType:Ie.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(g1({type:"event",event:r.id},a)),this.events.emit(r.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else xa(e)&&this.events.emit(bt.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(await this.recordMessageEvent(e,Sa.inbound),this.events.emit(bt.message,e))}async acknowledgePayload(e){const r=Jf(e.id,!0);await this.provider.connection.send(r)}unregisterProviderListeners(){this.provider.off(cr.payload,this.onPayloadHandler),this.provider.off(cr.connect,this.onConnectHandler),this.provider.off(cr.disconnect,this.onDisconnectHandler),this.provider.off(cr.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await Op();g_(async r=>{e!==r&&(e=r,r?await this.transportOpen().catch(i=>this.logger.error(i,i?.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){clearTimeout(this.pingTimeout),this.events.emit(bt.disconnect),this.connectionAttemptInProgress=!1,!this.reconnectInProgress&&(this.reconnectInProgress=!0,await this.subscriber.stop(),this.subscriber.hasAnyTopics&&(this.transportExplicitlyClosed||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e,e?.message)),this.reconnectTimeout=void 0,this.reconnectInProgress=!1},V.toMiliseconds(_x)))))}isInitialized(){if(!this.initialized){const{message:e}=H("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&await this.connect()}}var jS=Object.defineProperty,b1=Object.getOwnPropertySymbols,KS=Object.prototype.hasOwnProperty,VS=Object.prototype.propertyIsEnumerable,hu=(t,e,r)=>e in t?jS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,y1=(t,e)=>{for(var r in e||(e={}))KS.call(e,r)&&hu(t,r,e[r]);if(b1)for(var r of b1(e))VS.call(e,r)&&hu(t,r,e[r]);return t},Wt=(t,e,r)=>hu(t,typeof e!="symbol"?e+"":e,r);class sn extends Hb{constructor(e,r,i,n=kr,s=void 0){super(e,r,i,n),this.core=e,this.logger=r,this.name=i,Wt(this,"map",new Map),Wt(this,"version",xx),Wt(this,"cached",[]),Wt(this,"initialized",!1),Wt(this,"getKey"),Wt(this,"storagePrefix",kr),Wt(this,"recentlyDeleted",[]),Wt(this,"recentlyDeletedLimit",200),Wt(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!St(o)?this.map.set(this.getKey(o),o):H7(o)?this.map.set(o.id,o):W7(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)}),Wt(this,"set",async(o,a)=>{this.isInitialized(),this.map.has(o)?await this.update(o,a):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:a}),this.map.set(o,a),await this.persist())}),Wt(this,"get",o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o))),Wt(this,"getAll",o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(c=>cx(a[c],o[c]))):this.values)),Wt(this,"update",async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});const c=y1(y1({},this.getData(o)),a);this.map.set(o,c),await this.persist()}),Wt(this,"delete",async(o,a)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:a}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())}),this.logger=Ft(r,this.name),this.storagePrefix=n,this.getKey=s}get context(){return kt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const r=this.map.get(e);if(!r){if(this.recentlyDeleted.includes(e)){const{message:n}=H("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}const{message:i}=H("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return r}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:r}=H("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=H("NOT_INITIALIZED",this.name);throw new Error(e)}}}var HS=Object.defineProperty,WS=(t,e,r)=>e in t?HS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ne=(t,e,r)=>WS(t,typeof e!="symbol"?e+"":e,r);class GS{constructor(e,r){this.core=e,this.logger=r,ne(this,"name",Ax),ne(this,"version",Dx),ne(this,"events",new Mt.exports),ne(this,"pairings"),ne(this,"initialized",!1),ne(this,"storagePrefix",kr),ne(this,"ignoredPayloadTypes",[ni]),ne(this,"registeredMethods",[]),ne(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))}),ne(this,"register",({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]}),ne(this,"create",async i=>{this.isInitialized();const n=jf(),s=await this.core.crypto.setSymKey(n),o=at(V.FIVE_MINUTES),a={protocol:Vp},c={topic:s,expiry:o,relay:a,active:!1,methods:i?.methods},f=_p({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:n,relay:a,expiryTimestamp:o,methods:i?.methods});return this.events.emit(tn.create,c),this.core.expirer.set(s,o),await this.pairings.set(s,c),await this.core.relayer.subscribe(s,{transportType:i?.transportType}),{topic:s,uri:f}}),ne(this,"pair",async i=>{this.isInitialized();const n=this.core.eventClient.createEvent({properties:{topic:i?.uri,trace:[jr.pairing_started]}});this.isValidPair(i,n);const{topic:s,symKey:o,relay:a,expiryTimestamp:c,methods:f}=wp(i.uri);n.props.properties.topic=s,n.addTrace(jr.pairing_uri_validation_success),n.addTrace(jr.pairing_uri_not_expired);let u;if(this.pairings.keys.includes(s)){if(u=this.pairings.get(s),n.addTrace(jr.existing_pairing),u.active)throw n.setError(ai.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);n.addTrace(jr.pairing_not_expired)}const d=c||at(V.FIVE_MINUTES),g={topic:s,relay:a,expiry:d,active:!1,methods:f};this.core.expirer.set(s,d),await this.pairings.set(s,g),n.addTrace(jr.store_new_pairing),i.activatePairing&&await this.activate({topic:s}),this.events.emit(tn.create,g),n.addTrace(jr.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(o,s),n.addTrace(jr.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{n.setError(ai.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:a})}catch(m){throw n.setError(ai.subscribe_pairing_topic_failure),m}return n.addTrace(jr.subscribe_pairing_topic_success),g}),ne(this,"activate",async({topic:i})=>{this.isInitialized();const n=at(V.FIVE_MINUTES);this.core.expirer.set(i,n),await this.pairings.update(i,{active:!0,expiry:n})}),ne(this,"ping",async i=>{this.isInitialized(),await this.isValidPing(i),this.logger.warn("ping() is deprecated and will be removed in the next major release.");const{topic:n}=i;if(this.pairings.keys.includes(n)){const s=await this.sendRequest(n,"wc_pairingPing",{}),{done:o,resolve:a,reject:c}=Zi();this.events.once(ue("pairing_ping",s),({error:f})=>{f?c(f):a()}),await o()}}),ne(this,"updateExpiry",async({topic:i,expiry:n})=>{this.isInitialized(),await this.pairings.update(i,{expiry:n})}),ne(this,"updateMetadata",async({topic:i,metadata:n})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:n})}),ne(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),ne(this,"disconnect",async i=>{this.isInitialized(),await this.isValidDisconnect(i);const{topic:n}=i;this.pairings.keys.includes(n)&&(await this.sendRequest(n,"wc_pairingDelete",we("USER_DISCONNECTED")),await this.deletePairing(n))}),ne(this,"formatUriFromPairing",i=>{this.isInitialized();const{topic:n,relay:s,expiry:o,methods:a}=i,c=this.core.crypto.keychain.get(n);return _p({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:c,relay:s,expiryTimestamp:o,methods:a})}),ne(this,"sendRequest",async(i,n,s)=>{const o=en(n,s),a=await this.core.crypto.encode(i,o),c=ks[n].req;return this.core.history.set(i,o),this.core.relayer.publish(i,a,c),o.id}),ne(this,"sendResult",async(i,n,s)=>{const o=Jf(i,s),a=await this.core.crypto.encode(n,o),c=(await this.core.history.get(n,i)).request.method,f=ks[c].res;await this.core.relayer.publish(n,a,f),await this.core.history.resolve(o)}),ne(this,"sendError",async(i,n,s)=>{const o=Xf(i,s),a=await this.core.crypto.encode(n,o),c=(await this.core.history.get(n,i)).request.method,f=ks[c]?ks[c].res:ks.unregistered_method.res;await this.core.relayer.publish(n,a,f),await this.core.history.resolve(o)}),ne(this,"deletePairing",async(i,n)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,we("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),n?Promise.resolve():this.core.expirer.del(i)])}),ne(this,"cleanup",async()=>{const i=this.pairings.getAll().filter(n=>Si(n.expiry));await Promise.all(i.map(n=>this.deletePairing(n.topic)))}),ne(this,"onRelayEventRequest",async i=>{const{topic:n,payload:s}=i;switch(s.method){case"wc_pairingPing":return await this.onPairingPingRequest(n,s);case"wc_pairingDelete":return await this.onPairingDeleteRequest(n,s);default:return await this.onUnknownRpcMethodRequest(n,s)}}),ne(this,"onRelayEventResponse",async i=>{const{topic:n,payload:s}=i,o=(await this.core.history.get(n,s.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(n,s);default:return this.onUnknownRpcMethodResponse(o)}}),ne(this,"onPairingPingRequest",async(i,n)=>{const{id:s}=n;try{this.isValidPing({topic:i}),await this.sendResult(s,i,!0),this.events.emit(tn.ping,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}}),ne(this,"onPairingPingResponse",(i,n)=>{const{id:s}=n;setTimeout(()=>{Ur(n)?this.events.emit(ue("pairing_ping",s),{}):ar(n)&&this.events.emit(ue("pairing_ping",s),{error:n.error})},500)}),ne(this,"onPairingDeleteRequest",async(i,n)=>{const{id:s}=n;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(tn.delete,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}}),ne(this,"onUnknownRpcMethodRequest",async(i,n)=>{const{id:s,method:o}=n;try{if(this.registeredMethods.includes(o))return;const a=we("WC_METHOD_UNSUPPORTED",o);await this.sendError(s,i,a),this.logger.error(a)}catch(a){await this.sendError(s,i,a),this.logger.error(a)}}),ne(this,"onUnknownRpcMethodResponse",i=>{this.registeredMethods.includes(i)||this.logger.error(we("WC_METHOD_UNSUPPORTED",i))}),ne(this,"isValidPair",(i,n)=>{var s;if(!Ht(i)){const{message:a}=H("MISSING_OR_INVALID",`pair() params: ${i}`);throw n.setError(ai.malformed_pairing_uri),new Error(a)}if(!V7(i.uri)){const{message:a}=H("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw n.setError(ai.malformed_pairing_uri),new Error(a)}const o=wp(i?.uri);if(!((s=o?.relay)!=null&&s.protocol)){const{message:a}=H("MISSING_OR_INVALID","pair() uri#relay-protocol");throw n.setError(ai.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){const{message:a}=H("MISSING_OR_INVALID","pair() uri#symKey");throw n.setError(ai.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&V.toMiliseconds(o?.expiryTimestamp)<Date.now()){n.setError(ai.pairing_expired);const{message:a}=H("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(a)}}),ne(this,"isValidPing",async i=>{if(!Ht(i)){const{message:s}=H("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)}),ne(this,"isValidDisconnect",async i=>{if(!Ht(i)){const{message:s}=H("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)}),ne(this,"isValidPairingTopic",async i=>{if(!nt(i,!1)){const{message:n}=H("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){const{message:n}=H("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(Si(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:n}=H("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}}),this.core=e,this.logger=Ft(r,this.name),this.pairings=new sn(this.core,this.logger,this.name,this.storagePrefix)}get context(){return kt(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=H("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(bt.message,async e=>{const{topic:r,message:i,transportType:n}=e;if(this.pairings.keys.includes(r)&&n!==Ie.link_mode&&!this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))try{const s=await this.core.crypto.decode(r,i);Qf(s)?(this.core.history.set(r,s),await this.onRelayEventRequest({topic:r,payload:s})):xa(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:r,payload:s}),this.core.history.delete(r,s.id)),await this.core.relayer.messages.ack(r,i)}catch(s){this.logger.error(s)}})}registerExpirerEvents(){this.core.expirer.on(fr.expired,async e=>{const{topic:r}=x0(e.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit(tn.expire,{topic:r}))})}}var YS=Object.defineProperty,ZS=(t,e,r)=>e in t?YS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Dt=(t,e,r)=>ZS(t,typeof e!="symbol"?e+"":e,r);class JS extends kb{constructor(e,r){super(e,r),this.core=e,this.logger=r,Dt(this,"records",new Map),Dt(this,"events",new Mt.exports.EventEmitter),Dt(this,"name",$x),Dt(this,"version",Ox),Dt(this,"cached",[]),Dt(this,"initialized",!1),Dt(this,"storagePrefix",kr),Dt(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),Dt(this,"set",(i,n,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:n,chainId:s}),this.records.has(n.id))return;const o={id:n.id,topic:i,request:{method:n.method,params:n.params||null},chainId:s,expiry:at(V.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(mr.created,o)}),Dt(this,"resolve",async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;const n=await this.getRecord(i.id);typeof n.response>"u"&&(n.response=ar(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.persist(),this.events.emit(mr.updated,n))}),Dt(this,"get",async(i,n)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:n}),await this.getRecord(n))),Dt(this,"delete",(i,n)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:n}),this.values.forEach(s=>{if(s.topic===i){if(typeof n<"u"&&s.id!==n)return;this.records.delete(s.id),this.events.emit(mr.deleted,s)}}),this.persist()}),Dt(this,"exists",async(i,n)=>(this.isInitialized(),this.records.has(n)?(await this.getRecord(n)).topic===i:!1)),Dt(this,"on",(i,n)=>{this.events.on(i,n)}),Dt(this,"once",(i,n)=>{this.events.once(i,n)}),Dt(this,"off",(i,n)=>{this.events.off(i,n)}),Dt(this,"removeListener",(i,n)=>{this.events.removeListener(i,n)}),this.logger=Ft(r,this.name)}get context(){return kt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(r=>{if(typeof r.response<"u")return;const i={topic:r.topic,request:en(r.request.method,r.request.params,r.id),chainId:r.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const r=this.records.get(e);if(!r){const{message:i}=H("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(mr.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:r}=H("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(mr.created,e=>{const r=mr.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(mr.updated,e=>{const r=mr.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(mr.deleted,e=>{const r=mr.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.core.heartbeat.on(gn.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(r=>{V.toMiliseconds(r.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${r.id}`),this.records.delete(r.id),this.events.emit(mr.deleted,r,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=H("NOT_INITIALIZED",this.name);throw new Error(e)}}}var XS=Object.defineProperty,QS=(t,e,r)=>e in t?XS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ct=(t,e,r)=>QS(t,typeof e!="symbol"?e+"":e,r);class eI extends Gb{constructor(e,r){super(e,r),this.core=e,this.logger=r,Ct(this,"expirations",new Map),Ct(this,"events",new Mt.exports.EventEmitter),Ct(this,"name",Mx),Ct(this,"version",Px),Ct(this,"cached",[]),Ct(this,"initialized",!1),Ct(this,"storagePrefix",kr),Ct(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),Ct(this,"has",i=>{try{const n=this.formatTarget(i);return typeof this.getExpiration(n)<"u"}catch{return!1}}),Ct(this,"set",(i,n)=>{this.isInitialized();const s=this.formatTarget(i),o={target:s,expiry:n};this.expirations.set(s,o),this.checkExpiry(s,o),this.events.emit(fr.created,{target:s,expiration:o})}),Ct(this,"get",i=>{this.isInitialized();const n=this.formatTarget(i);return this.getExpiration(n)}),Ct(this,"del",i=>{if(this.isInitialized(),this.has(i)){const n=this.formatTarget(i),s=this.getExpiration(n);this.expirations.delete(n),this.events.emit(fr.deleted,{target:n,expiration:s})}}),Ct(this,"on",(i,n)=>{this.events.on(i,n)}),Ct(this,"once",(i,n)=>{this.events.once(i,n)}),Ct(this,"off",(i,n)=>{this.events.off(i,n)}),Ct(this,"removeListener",(i,n)=>{this.events.removeListener(i,n)}),this.logger=Ft(r,this.name)}get context(){return kt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return D5(e);if(typeof e=="number")return $5(e);const{message:r}=H("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(r)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(fr.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:r}=H("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const r=this.expirations.get(e);if(!r){const{message:i}=H("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return r}checkExpiry(e,r){const{expiry:i}=r;V.toMiliseconds(i)-Date.now()<=0&&this.expire(e,r)}expire(e,r){this.expirations.delete(e),this.events.emit(fr.expired,{target:e,expiration:r})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,r)=>this.checkExpiry(r,e))}registerEventListeners(){this.core.heartbeat.on(gn.pulse,()=>this.checkExpirations()),this.events.on(fr.created,e=>{const r=fr.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(fr.expired,e=>{const r=fr.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(fr.deleted,e=>{const r=fr.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=H("NOT_INITIALIZED",this.name);throw new Error(e)}}}var tI=Object.defineProperty,rI=(t,e,r)=>e in t?tI(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,st=(t,e,r)=>rI(t,typeof e!="symbol"?e+"":e,r);class iI extends Yb{constructor(e,r,i){super(e,r,i),this.core=e,this.logger=r,this.store=i,st(this,"name",Rx),st(this,"abortController"),st(this,"isDevEnv"),st(this,"verifyUrlV3",Cx),st(this,"storagePrefix",kr),st(this,"version",kp),st(this,"publicKey"),st(this,"fetchPromise"),st(this,"init",async()=>{var n;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&V.toMiliseconds((n=this.publicKey)==null?void 0:n.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))}),st(this,"register",async n=>{if(!As()||this.isDevEnv)return;const s=window.location.origin,{id:o,decryptedId:a}=n,c=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${s}&id=${o}&decryptedId=${a}`;try{const f=ds(),u=this.startAbortTimer(V.ONE_SECOND*5),d=await new Promise((g,m)=>{const b=()=>{window.removeEventListener("message",I),f.body.removeChild(x),m("attestation aborted")};this.abortController.signal.addEventListener("abort",b);const x=f.createElement("iframe");x.src=c,x.style.display="none",x.addEventListener("error",b,{signal:this.abortController.signal});const I=O=>{if(O.data&&typeof O.data=="string")try{const $=JSON.parse(O.data);if($.type==="verify_attestation"){if(xc($.attestation).payload.id!==o)return;clearInterval(u),f.body.removeChild(x),this.abortController.signal.removeEventListener("abort",b),window.removeEventListener("message",I),g($.attestation===null?"":$.attestation)}}catch($){this.logger.warn($)}};f.body.appendChild(x),window.addEventListener("message",I,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",d),d}catch(f){this.logger.warn(f)}return""}),st(this,"resolve",async n=>{if(this.isDevEnv)return"";const{attestationId:s,hash:o,encryptedId:a}=n;if(s===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(s){if(xc(s).payload.id!==a)return;const f=await this.isValidJwtAttestation(s);if(f){if(!f.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return f}}if(!o)return;const c=this.getVerifyUrl(n?.verifyUrl);return this.fetchAttestation(o,c)}),st(this,"fetchAttestation",async(n,s)=>{this.logger.debug(`resolving attestation: ${n} from url: ${s}`);const o=this.startAbortTimer(V.ONE_SECOND*5),a=await fetch(`${s}/attestation/${n}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?await a.json():void 0}),st(this,"getVerifyUrl",n=>{let s=n||js;return Nx.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${js}`),s=js),s}),st(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const n=this.startAbortTimer(V.FIVE_SECONDS),s=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(n),await s.json()}catch(n){this.logger.warn(n)}}),st(this,"persistPublicKey",async n=>{this.logger.debug("persisting public key to local storage",n),await this.store.setItem(this.storeKey,n),this.publicKey=n}),st(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0}),st(this,"isValidJwtAttestation",async n=>{const s=await this.getPublicKey();try{if(s)return this.validateAttestation(n,s)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}const o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(n,o)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}}),st(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),st(this,"fetchAndPersistPublicKey",async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async s=>{const o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),s(o))});const n=await this.fetchPromise;return this.fetchPromise=void 0,n}),st(this,"validateAttestation",(n,s)=>{const o=R7(n,s.publicKey),a={hasExpired:V.toMiliseconds(o.exp)<Date.now(),payload:o};if(a.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:a.payload.origin,isScam:a.payload.isScam,isVerified:a.payload.isVerified}}),this.logger=Ft(r,this.name),this.abortController=new AbortController,this.isDevEnv=Sf(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return kt(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),V.toMiliseconds(e))}}var nI=Object.defineProperty,sI=(t,e,r)=>e in t?nI(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,v1=(t,e,r)=>sI(t,typeof e!="symbol"?e+"":e,r);class oI extends Zb{constructor(e,r){super(e,r),this.projectId=e,this.logger=r,v1(this,"context",Bx),v1(this,"registerDeviceToken",async i=>{const{clientId:n,token:s,notificationType:o,enableEncrypted:a=!1}=i,c=`${Fx}/${this.projectId}/clients`;await fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:n,type:o,token:s,always_raw:a})})}),this.logger=Ft(r,this.context)}}var aI=Object.defineProperty,m1=Object.getOwnPropertySymbols,cI=Object.prototype.hasOwnProperty,fI=Object.prototype.propertyIsEnumerable,du=(t,e,r)=>e in t?aI(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ws=(t,e)=>{for(var r in e||(e={}))cI.call(e,r)&&du(t,r,e[r]);if(m1)for(var r of m1(e))fI.call(e,r)&&du(t,r,e[r]);return t},yt=(t,e,r)=>du(t,typeof e!="symbol"?e+"":e,r);class uI extends Jb{constructor(e,r,i=!0){super(e,r,i),this.core=e,this.logger=r,yt(this,"context",qx),yt(this,"storagePrefix",kr),yt(this,"storageVersion",Lx),yt(this,"events",new Map),yt(this,"shouldPersist",!1),yt(this,"init",async()=>{if(!Sf())try{const n={eventId:S0(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:w0(this.core.relayer.protocol,this.core.relayer.version,tu)}}};await this.sendEvent([n])}catch(n){this.logger.warn(n)}}),yt(this,"createEvent",n=>{const{event:s="ERROR",type:o="",properties:{topic:a,trace:c}}=n,f=S0(),u=this.core.projectId||"",d=Date.now(),g=Ws({eventId:f,timestamp:d,props:{event:s,type:o,properties:{topic:a,trace:c}},bundleId:u,domain:this.getAppDomain()},this.setMethods(f));return this.telemetryEnabled&&(this.events.set(f,g),this.shouldPersist=!0),g}),yt(this,"getEvent",n=>{const{eventId:s,topic:o}=n;if(s)return this.events.get(s);const a=Array.from(this.events.values()).find(c=>c.props.properties.topic===o);if(a)return Ws(Ws({},a),this.setMethods(a.eventId))}),yt(this,"deleteEvent",n=>{const{eventId:s}=n;this.events.delete(s),this.shouldPersist=!0}),yt(this,"setEventListeners",()=>{this.core.heartbeat.on(gn.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(n=>{V.fromMiliseconds(Date.now())-V.fromMiliseconds(n.timestamp)>zx&&(this.events.delete(n.eventId),this.shouldPersist=!0)})})}),yt(this,"setMethods",n=>({addTrace:s=>this.addTrace(n,s),setError:s=>this.setError(n,s)})),yt(this,"addTrace",(n,s)=>{const o=this.events.get(n);o&&(o.props.properties.trace.push(s),this.events.set(n,o),this.shouldPersist=!0)}),yt(this,"setError",(n,s)=>{const o=this.events.get(n);o&&(o.props.type=s,o.timestamp=Date.now(),this.events.set(n,o),this.shouldPersist=!0)}),yt(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1}),yt(this,"restore",async()=>{try{const n=await this.core.storage.getItem(this.storageKey)||[];if(!n.length)return;n.forEach(s=>{this.events.set(s.eventId,Ws(Ws({},s),this.setMethods(s.eventId)))})}catch(n){this.logger.warn(n)}}),yt(this,"submit",async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const n=[];for(const[s,o]of this.events)o.props.type&&n.push(o);if(n.length!==0)try{if((await this.sendEvent(n)).ok)for(const s of n)this.events.delete(s.eventId),this.shouldPersist=!0}catch(s){this.logger.warn(s)}}),yt(this,"sendEvent",async n=>{const s=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${Ux}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${tu}${s}`,{method:"POST",body:JSON.stringify(n)})}),yt(this,"getAppDomain",()=>m0().url),this.logger=Ft(r,this.context),this.telemetryEnabled=i,i?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var hI=Object.defineProperty,w1=Object.getOwnPropertySymbols,dI=Object.prototype.hasOwnProperty,lI=Object.prototype.propertyIsEnumerable,lu=(t,e,r)=>e in t?hI(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,_1=(t,e)=>{for(var r in e||(e={}))dI.call(e,r)&&lu(t,r,e[r]);if(w1)for(var r of w1(e))lI.call(e,r)&&lu(t,r,e[r]);return t},_e=(t,e,r)=>lu(t,typeof e!="symbol"?e+"":e,r);class pu extends Lb{constructor(e){var r;super(e),_e(this,"protocol",Up),_e(this,"version",kp),_e(this,"name",Ea),_e(this,"relayUrl"),_e(this,"projectId"),_e(this,"customStoragePrefix"),_e(this,"events",new Mt.exports.EventEmitter),_e(this,"logger"),_e(this,"heartbeat"),_e(this,"relayer"),_e(this,"crypto"),_e(this,"storage"),_e(this,"history"),_e(this,"expirer"),_e(this,"pairing"),_e(this,"verify"),_e(this,"echoClient"),_e(this,"linkModeSupportedApps"),_e(this,"eventClient"),_e(this,"initialized",!1),_e(this,"logChunkController"),_e(this,"on",(o,a)=>this.events.on(o,a)),_e(this,"once",(o,a)=>this.events.once(o,a)),_e(this,"off",(o,a)=>this.events.off(o,a)),_e(this,"removeListener",(o,a)=>this.events.removeListener(o,a)),_e(this,"dispatchEnvelope",({topic:o,message:a,sessionExists:c})=>{if(!o||!a)return;const f={topic:o,message:a,publishedAt:Date.now(),transportType:Ie.link_mode};this.relayer.onLinkMessageEvent(f,{sessionExists:c})}),this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||Hp,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=tc({level:typeof e?.logger=="string"&&e.logger?e.logger:fx.logger,name:Ea}),{logger:n,chunkLoggerController:s}=Nb({opts:i,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=s,(r=this.logChunkController)!=null&&r.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var o,a;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((a=this.logChunkController)==null||a.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=Ft(n,this.name),this.heartbeat=new Ga,this.crypto=new gS(this,this.logger,e?.keychain),this.history=new JS(this,this.logger),this.expirer=new eI(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new ab(_1(_1({},ux),e?.storageOptions)),this.relayer=new kS({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new GS(this,this.logger),this.verify=new iI(this,this.logger,this.storage),this.echoClient=new oI(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new uI(this,this.logger,e?.telemetryEnabled)}static async init(e){const r=new pu(e);await r.initialize();const i=await r.crypto.getClientId();return await r.storage.setItem(Ex,i),r}get context(){return kt(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(Wp,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.linkModeSupportedApps=await this.storage.getItem(Wp)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}}const gu=pu,x1="wc",E1=2,S1="client",bu=`${x1}@${E1}:${S1}:`,yu={name:S1,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"},I1="WALLETCONNECT_DEEPLINK_CHOICE",pI="proposal",A1="Proposal expired",gI="session",Qn=V.SEVEN_DAYS,bI="engine",vt={wc_sessionPropose:{req:{ttl:V.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:V.ONE_DAY,prompt:!1,tag:1104},res:{ttl:V.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:V.ONE_DAY,prompt:!1,tag:1106},res:{ttl:V.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:V.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:V.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:V.ONE_DAY,prompt:!1,tag:1112},res:{ttl:V.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:V.ONE_DAY,prompt:!1,tag:1114},res:{ttl:V.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:V.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:V.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:V.FIVE_MINUTES,prompt:!1,tag:1119}}},vu={min:V.FIVE_MINUTES,max:V.SEVEN_DAYS},Vr={idle:"IDLE",active:"ACTIVE"},D1={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"}},yI="request",vI=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],mI="wc",wI="auth",_I="authKeys",xI="pairingTopics",EI="requests",Da=`${mI}@${1.5}:${wI}:`,$a=`${Da}:PUB_KEY`;var SI=Object.defineProperty,II=Object.defineProperties,AI=Object.getOwnPropertyDescriptors,$1=Object.getOwnPropertySymbols,DI=Object.prototype.hasOwnProperty,$I=Object.prototype.propertyIsEnumerable,mu=(t,e,r)=>e in t?SI(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,be=(t,e)=>{for(var r in e||(e={}))DI.call(e,r)&&mu(t,r,e[r]);if($1)for(var r of $1(e))$I.call(e,r)&&mu(t,r,e[r]);return t},zt=(t,e)=>II(t,AI(e)),K=(t,e,r)=>mu(t,typeof e!="symbol"?e+"":e,r);class OI extends ty{constructor(e){super(e),K(this,"name",bI),K(this,"events",new Mt.exports),K(this,"initialized",!1),K(this,"requestQueue",{state:Vr.idle,queue:[]}),K(this,"sessionRequestQueue",{state:Vr.idle,queue:[]}),K(this,"requestQueueDelay",V.ONE_SECOND),K(this,"expectedPairingMethodMap",new Map),K(this,"recentlyDeletedMap",new Map),K(this,"recentlyDeletedLimit",200),K(this,"relayMessageCache",[]),K(this,"pendingSessions",new Map),K(this,"init",async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(vt)}),this.initialized=!0,setTimeout(async()=>{await this.processPendingMessageEvents(),this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},V.toMiliseconds(this.requestQueueDelay)))}),K(this,"connect",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const i=zt(be({},r),{requiredNamespaces:r.requiredNamespaces||{},optionalNamespaces:r.optionalNamespaces||{}});await this.isValidConnect(i);const{pairingTopic:n,requiredNamespaces:s,optionalNamespaces:o,sessionProperties:a,scopedProperties:c,relays:f}=i;let u=n,d,g=!1;try{if(u){const B=this.client.core.pairing.pairings.get(u);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),g=B.active}}catch(B){throw this.client.logger.error(`connect() -> pairing.get(${u}) failed`),B}if(!u||!g){const{topic:B,uri:F}=await this.client.core.pairing.create();u=B,d=F}if(!u){const{message:B}=H("NO_MATCHING_KEY",`connect() pairing topic: ${u}`);throw new Error(B)}const m=await this.client.core.crypto.generateKeyPair(),b=vt.wc_sessionPropose.req.ttl||V.FIVE_MINUTES,x=at(b),I=zt(be(be({requiredNamespaces:s,optionalNamespaces:o,relays:f??[{protocol:Vp}],proposer:{publicKey:m,metadata:this.client.metadata},expiryTimestamp:x,pairingTopic:u},a&&{sessionProperties:a}),c&&{scopedProperties:c}),{id:zr()}),O=ue("session_connect",I.id),{reject:$,resolve:P,done:R}=Zi(b,A1),N=({id:B})=>{B===I.id&&(this.client.events.off("proposal_expire",N),this.pendingSessions.delete(I.id),this.events.emit(O,{error:{message:A1,code:0}}))};return this.client.events.on("proposal_expire",N),this.events.once(O,({error:B,session:F})=>{this.client.events.off("proposal_expire",N),B?$(B):F&&P(F)}),await this.sendRequest({topic:u,method:"wc_sessionPropose",params:I,throwOnFailedPublish:!0,clientRpcId:I.id}),await this.setProposal(I.id,I),{uri:d,approval:R}}),K(this,"pair",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(r)}catch(i){throw this.client.logger.error("pair() failed"),i}}),K(this,"approve",async r=>{var i,n,s;const o=this.client.core.eventClient.createEvent({properties:{topic:(i=r?.id)==null?void 0:i.toString(),trace:[wr.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(C){throw o.setError(rn.no_internet_connection),C}try{await this.isValidProposalId(r?.id)}catch(C){throw this.client.logger.error(`approve() -> proposal.get(${r?.id}) failed`),o.setError(rn.proposal_not_found),C}try{await this.isValidApprove(r)}catch(C){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(rn.session_approve_namespace_validation_failure),C}const{id:a,relayProtocol:c,namespaces:f,sessionProperties:u,scopedProperties:d,sessionConfig:g}=r,m=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:o.eventId});const{pairingTopic:b,proposer:x,requiredNamespaces:I,optionalNamespaces:O}=m;let $=(n=this.client.core.eventClient)==null?void 0:n.getEvent({topic:b});$||($=(s=this.client.core.eventClient)==null?void 0:s.createEvent({type:wr.session_approve_started,properties:{topic:b,trace:[wr.session_approve_started,wr.session_namespaces_validation_success]}}));const P=await this.client.core.crypto.generateKeyPair(),R=x.publicKey,N=await this.client.core.crypto.generateSharedKey(P,R),B=be(be(be({relay:{protocol:c??"irn"},namespaces:f,controller:{publicKey:P,metadata:this.client.metadata},expiry:at(Qn)},u&&{sessionProperties:u}),d&&{scopedProperties:d}),g&&{sessionConfig:g}),F=Ie.relay;$.addTrace(wr.subscribing_session_topic);try{await this.client.core.relayer.subscribe(N,{transportType:F})}catch(C){throw $.setError(rn.subscribe_session_topic_failure),C}$.addTrace(wr.subscribe_session_topic_success);const L=zt(be({},B),{topic:N,requiredNamespaces:I,optionalNamespaces:O,pairingTopic:b,acknowledged:!1,self:B.controller,peer:{publicKey:x.publicKey,metadata:x.metadata},controller:P,transportType:Ie.relay});await this.client.session.set(N,L),$.addTrace(wr.store_session);try{$.addTrace(wr.publishing_session_settle),await this.sendRequest({topic:N,method:"wc_sessionSettle",params:B,throwOnFailedPublish:!0}).catch(C=>{throw $?.setError(rn.session_settle_publish_failure),C}),$.addTrace(wr.session_settle_publish_success),$.addTrace(wr.publishing_session_approve),await this.sendResult({id:a,topic:b,result:{relay:{protocol:c??"irn"},responderPublicKey:P},throwOnFailedPublish:!0}).catch(C=>{throw $?.setError(rn.session_approve_publish_failure),C}),$.addTrace(wr.session_approve_publish_success)}catch(C){throw this.client.logger.error(C),this.client.session.delete(N,we("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(N),C}return this.client.core.eventClient.deleteEvent({eventId:$.eventId}),await this.client.core.pairing.updateMetadata({topic:b,metadata:x.metadata}),await this.client.proposal.delete(a,we("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:b}),await this.setExpiry(N,at(Qn)),{topic:N,acknowledged:()=>Promise.resolve(this.client.session.get(N))}}),K(this,"reject",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(r)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}const{id:i,reason:n}=r;let s;try{s=this.client.proposal.get(i).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),o}s&&(await this.sendError({id:i,topic:s,error:n,rpcOpts:vt.wc_sessionPropose.reject}),await this.client.proposal.delete(i,we("USER_DISCONNECTED")))}),K(this,"update",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(r)}catch(d){throw this.client.logger.error("update() -> isValidUpdate() failed"),d}const{topic:i,namespaces:n}=r,{done:s,resolve:o,reject:a}=Zi(),c=zr(),f=Qi().toString(),u=this.client.session.get(i).namespaces;return this.events.once(ue("session_update",c),({error:d})=>{d?a(d):o()}),await this.client.session.update(i,{namespaces:n}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:n},throwOnFailedPublish:!0,clientRpcId:c,relayRpcId:f}).catch(d=>{this.client.logger.error(d),this.client.session.update(i,{namespaces:u}),a(d)}),{acknowledged:s}}),K(this,"extend",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(r)}catch(c){throw this.client.logger.error("extend() -> isValidExtend() failed"),c}const{topic:i}=r,n=zr(),{done:s,resolve:o,reject:a}=Zi();return this.events.once(ue("session_extend",n),({error:c})=>{c?a(c):o()}),await this.setExpiry(i,at(Qn)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(c=>{a(c)}),{acknowledged:s}}),K(this,"request",async r=>{this.isInitialized();try{await this.isValidRequest(r)}catch(O){throw this.client.logger.error("request() -> isValidRequest() failed"),O}const{chainId:i,request:n,topic:s,expiry:o=vt.wc_sessionRequest.req.ttl}=r,a=this.client.session.get(s);a?.transportType===Ie.relay&&await this.confirmOnlineStateOrThrow();const c=zr(),f=Qi().toString(),{done:u,resolve:d,reject:g}=Zi(o,"Request expired. Please try again.");this.events.once(ue("session_request",c),({error:O,result:$})=>{O?g(O):d($)});const m="wc_sessionRequest",b=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);if(b)return await this.sendRequest({clientRpcId:c,relayRpcId:f,topic:s,method:m,params:{request:zt(be({},n),{expiryTimestamp:at(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0,appLink:b}).catch(O=>g(O)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:c}),await u();const x={request:zt(be({},n),{expiryTimestamp:at(o)}),chainId:i},I=this.shouldSetTVF(m,x);return await Promise.all([new Promise(async O=>{await this.sendRequest(be({clientRpcId:c,relayRpcId:f,topic:s,method:m,params:x,expiry:o,throwOnFailedPublish:!0},I&&{tvf:this.getTVFParams(c,x)})).catch($=>g($)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:c}),O()}),new Promise(async O=>{var $;if(!(($=a.sessionConfig)!=null&&$.disableDeepLink)){const P=await T5(this.client.core.storage,I1);await M5({id:c,topic:s,wcDeepLink:P})}O()}),u()]).then(O=>O[2])}),K(this,"respond",async r=>{this.isInitialized(),await this.isValidRespond(r);const{topic:i,response:n}=r,{id:s}=n,o=this.client.session.get(i);o.transportType===Ie.relay&&await this.confirmOnlineStateOrThrow();const a=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);Ur(n)?await this.sendResult({id:s,topic:i,result:n.result,throwOnFailedPublish:!0,appLink:a}):ar(n)&&await this.sendError({id:s,topic:i,error:n.error,appLink:a}),this.cleanupAfterResponse(r)}),K(this,"ping",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(r)}catch(n){throw this.client.logger.error("ping() -> isValidPing() failed"),n}const{topic:i}=r;if(this.client.session.keys.includes(i)){const n=zr(),s=Qi().toString(),{done:o,resolve:a,reject:c}=Zi();this.events.once(ue("session_ping",n),({error:f})=>{f?c(f):a()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:n,relayRpcId:s}),o()])}else this.client.core.pairing.pairings.keys.includes(i)&&(this.client.logger.warn("ping() on pairing topic is deprecated and will be removed in the next major release."),await this.client.core.pairing.ping({topic:i}))}),K(this,"emit",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(r);const{topic:i,event:n,chainId:s}=r,o=Qi().toString(),a=zr();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:n,chainId:s},throwOnFailedPublish:!0,relayRpcId:o,clientRpcId:a})}),K(this,"disconnect",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(r);const{topic:i}=r;if(this.client.session.keys.includes(i))await this.sendRequest({topic:i,method:"wc_sessionDelete",params:we("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:i,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(i))await this.client.core.pairing.disconnect({topic:i});else{const{message:n}=H("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(n)}}),K(this,"find",r=>(this.isInitialized(),this.client.session.getAll().filter(i=>j7(i,r)))),K(this,"getPendingSessionRequests",()=>this.client.pendingRequest.getAll()),K(this,"authenticate",async(r,i)=>{var n;this.isInitialized(),this.isValidAuthenticate(r);const s=i&&this.client.core.linkModeSupportedApps.includes(i)&&((n=this.client.metadata.redirect)==null?void 0:n.linkMode),o=s?Ie.link_mode:Ie.relay;o===Ie.relay&&await this.confirmOnlineStateOrThrow();const{chains:a,statement:c="",uri:f,domain:u,nonce:d,type:g,exp:m,nbf:b,methods:x=[],expiry:I}=r,O=[...r.resources||[]],{topic:$,uri:P}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:$,uri:P}});const R=await this.client.core.crypto.generateKeyPair(),N=ya(R);if(await Promise.all([this.client.auth.authKeys.set($a,{responseTopic:N,publicKey:R}),this.client.auth.pairingTopics.set(N,{topic:N,pairingTopic:$})]),await this.client.core.relayer.subscribe(N,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${$}`),x.length>0){const{namespace:_}=ca(a[0]);let l=E9(_,"request",x);la(O)&&(l=I9(l,O.pop())),O.push(l)}const B=I&&I>vt.wc_sessionAuthenticate.req.ttl?I:vt.wc_sessionAuthenticate.req.ttl,F={authPayload:{type:g??"caip122",chains:a,statement:c,aud:f,domain:u,version:"1",nonce:d,iat:new Date().toISOString(),exp:m,nbf:b,resources:O},requester:{publicKey:R,metadata:this.client.metadata},expiryTimestamp:at(B)},L={eip155:{chains:a,methods:[...new Set(["personal_sign",...x])],events:["chainChanged","accountsChanged"]}},C={requiredNamespaces:{},optionalNamespaces:L,relays:[{protocol:"irn"}],pairingTopic:$,proposer:{publicKey:R,metadata:this.client.metadata},expiryTimestamp:at(vt.wc_sessionPropose.req.ttl),id:zr()},{done:W,resolve:A,reject:h}=Zi(B,"Request expired"),p=zr(),v=ue("session_connect",C.id),y=ue("session_request",p),w=async({error:_,session:l})=>{this.events.off(y,S),_?h(_):l&&A({session:l})},S=async _=>{var l,E,q;if(await this.deletePendingAuthRequest(p,{message:"fulfilled",code:0}),_.error){const Z=we("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return _.error.code===Z.code?void 0:(this.events.off(v,w),h(_.error.message))}await this.deleteProposal(C.id),this.events.off(v,w);const{cacaos:z,responder:U}=_.result,k=[],G=[];for(const Z of z){await q0({cacao:Z,projectId:this.client.core.projectId})||(this.client.logger.error(Z,"Signature verification failed"),h(we("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:Q}=Z,Fe=la(Q.resources),re=[Mf(Q.iss)],oe=da(Q.iss);if(Fe){const ct=k0(Fe),he=j0(Fe);k.push(...ct),re.push(...he)}for(const ct of re)G.push(`${ct}:${oe}`)}const J=await this.client.core.crypto.generateSharedKey(R,U.publicKey);let X;k.length>0&&(X={topic:J,acknowledged:!0,self:{publicKey:R,metadata:this.client.metadata},peer:U,controller:U.publicKey,expiry:at(Qn),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:$,namespaces:xp([...new Set(k)],[...new Set(G)]),transportType:o},await this.client.core.relayer.subscribe(J,{transportType:o}),await this.client.session.set(J,X),$&&await this.client.core.pairing.updateMetadata({topic:$,metadata:U.metadata}),X=this.client.session.get(J)),(l=this.client.metadata.redirect)!=null&&l.linkMode&&(E=U.metadata.redirect)!=null&&E.linkMode&&(q=U.metadata.redirect)!=null&&q.universal&&i&&(this.client.core.addLinkModeSupportedApp(U.metadata.redirect.universal),this.client.session.update(J,{transportType:Ie.link_mode})),A({auths:z,session:X})};this.events.once(v,w),this.events.once(y,S);let D;try{if(s){const _=en("wc_sessionAuthenticate",F,p);this.client.core.history.set($,_);const l=await this.client.core.crypto.encode("",_,{type:Cs,encoding:Rs});D=ma(i,$,l)}else await Promise.all([this.sendRequest({topic:$,method:"wc_sessionAuthenticate",params:F,expiry:r.expiry,throwOnFailedPublish:!0,clientRpcId:p}),this.sendRequest({topic:$,method:"wc_sessionPropose",params:C,expiry:vt.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:C.id})])}catch(_){throw this.events.off(v,w),this.events.off(y,S),_}return await this.setProposal(C.id,C),await this.setAuthRequest(p,{request:zt(be({},F),{verifyContext:{}}),pairingTopic:$,transportType:o}),{uri:D??P,response:W}}),K(this,"approveSessionAuthenticate",async r=>{const{id:i,auths:n}=r,s=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[nn.authenticated_session_approve_started]}});try{this.isInitialized()}catch(I){throw s.setError(Ks.no_internet_connection),I}const o=this.getPendingAuthRequest(i);if(!o)throw s.setError(Ks.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);const a=o.transportType||Ie.relay;a===Ie.relay&&await this.confirmOnlineStateOrThrow();const c=o.requester.publicKey,f=await this.client.core.crypto.generateKeyPair(),u=ya(c),d={type:ni,receiverPublicKey:c,senderPublicKey:f},g=[],m=[];for(const I of n){if(!await q0({cacao:I,projectId:this.client.core.projectId})){s.setError(Ks.invalid_cacao);const N=we("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:u,error:N,encodeOpts:d}),new Error(N.message)}s.addTrace(nn.cacaos_verified);const{p:O}=I,$=la(O.resources),P=[Mf(O.iss)],R=da(O.iss);if($){const N=k0($),B=j0($);g.push(...N),P.push(...B)}for(const N of P)m.push(`${N}:${R}`)}const b=await this.client.core.crypto.generateSharedKey(f,c);s.addTrace(nn.create_authenticated_session_topic);let x;if(g?.length>0){x={topic:b,acknowledged:!0,self:{publicKey:f,metadata:this.client.metadata},peer:{publicKey:c,metadata:o.requester.metadata},controller:c,expiry:at(Qn),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:xp([...new Set(g)],[...new Set(m)]),transportType:a},s.addTrace(nn.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(b,{transportType:a})}catch(I){throw s.setError(Ks.subscribe_authenticated_session_topic_failure),I}s.addTrace(nn.subscribe_authenticated_session_topic_success),await this.client.session.set(b,x),s.addTrace(nn.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}s.addTrace(nn.publishing_authenticated_session_approve);try{await this.sendResult({topic:u,id:i,result:{cacaos:n,responder:{publicKey:f,metadata:this.client.metadata}},encodeOpts:d,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,a)})}catch(I){throw s.setError(Ks.authenticated_session_approve_publish_failure),I}return await this.client.auth.requests.delete(i,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:s.eventId}),{session:x}}),K(this,"rejectSessionAuthenticate",async r=>{this.isInitialized();const{id:i,reason:n}=r,s=this.getPendingAuthRequest(i);if(!s)throw new Error(`Could not find pending auth request with id ${i}`);s.transportType===Ie.relay&&await this.confirmOnlineStateOrThrow();const o=s.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),c=ya(o),f={type:ni,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:i,topic:c,error:n,encodeOpts:f,rpcOpts:vt.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(s.requester.metadata,s.transportType)}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.client.proposal.delete(i,we("USER_DISCONNECTED"))}),K(this,"formatAuthMessage",r=>{this.isInitialized();const{request:i,iss:n}=r;return z0(i,n)}),K(this,"processRelayMessageCache",()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{const r=this.relayMessageCache.shift();r&&await this.onRelayMessage(r)}catch(r){this.client.logger.error(r)}},50)}),K(this,"cleanupDuplicatePairings",async r=>{if(r.pairingTopic)try{const i=this.client.core.pairing.pairings.get(r.pairingTopic),n=this.client.core.pairing.pairings.getAll().filter(s=>{var o,a;return((o=s.peerMetadata)==null?void 0:o.url)&&((a=s.peerMetadata)==null?void 0:a.url)===r.peer.metadata.url&&s.topic&&s.topic!==i.topic});if(n.length===0)return;this.client.logger.info(`Cleaning up ${n.length} duplicate pairing(s)`),await Promise.all(n.map(s=>this.client.core.pairing.disconnect({topic:s.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(i){this.client.logger.error(i)}}),K(this,"deleteSession",async r=>{var i;const{topic:n,expirerHasDeleted:s=!1,emitEvent:o=!0,id:a=0}=r,{self:c}=this.client.session.get(n);await this.client.core.relayer.unsubscribe(n),await this.client.session.delete(n,we("USER_DISCONNECTED")),this.addToRecentlyDeleted(n,"session"),this.client.core.crypto.keychain.has(c.publicKey)&&await this.client.core.crypto.deleteKeyPair(c.publicKey),this.client.core.crypto.keychain.has(n)&&await this.client.core.crypto.deleteSymKey(n),s||this.client.core.expirer.del(n),this.client.core.storage.removeItem(I1).catch(f=>this.client.logger.warn(f)),this.getPendingSessionRequests().forEach(f=>{f.topic===n&&this.deletePendingSessionRequest(f.id,we("USER_DISCONNECTED"))}),n===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=Vr.idle),o&&this.client.events.emit("session_delete",{id:a,topic:n})}),K(this,"deleteProposal",async(r,i)=>{if(i)try{const n=this.client.proposal.get(r);this.client.core.eventClient.getEvent({topic:n.pairingTopic})?.setError(rn.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(r,we("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"proposal")}),K(this,"deletePendingSessionRequest",async(r,i,n=!1)=>{await Promise.all([this.client.pendingRequest.delete(r,i),n?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(s=>s.id!==r),n&&(this.sessionRequestQueue.state=Vr.idle,this.client.events.emit("session_request_expire",{id:r}))}),K(this,"deletePendingAuthRequest",async(r,i,n=!1)=>{await Promise.all([this.client.auth.requests.delete(r,i),n?Promise.resolve():this.client.core.expirer.del(r)])}),K(this,"setExpiry",async(r,i)=>{this.client.session.keys.includes(r)&&(this.client.core.expirer.set(r,i),await this.client.session.update(r,{expiry:i}))}),K(this,"setProposal",async(r,i)=>{this.client.core.expirer.set(r,at(vt.wc_sessionPropose.req.ttl)),await this.client.proposal.set(r,i)}),K(this,"setAuthRequest",async(r,i)=>{const{request:n,pairingTopic:s,transportType:o=Ie.relay}=i;this.client.core.expirer.set(r,n.expiryTimestamp),await this.client.auth.requests.set(r,{authPayload:n.authPayload,requester:n.requester,expiryTimestamp:n.expiryTimestamp,id:r,pairingTopic:s,verifyContext:n.verifyContext,transportType:o})}),K(this,"setPendingSessionRequest",async r=>{const{id:i,topic:n,params:s,verifyContext:o}=r,a=s.request.expiryTimestamp||at(vt.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,a),await this.client.pendingRequest.set(i,{id:i,topic:n,params:s,verifyContext:o})}),K(this,"sendRequest",async r=>{const{topic:i,method:n,params:s,expiry:o,relayRpcId:a,clientRpcId:c,throwOnFailedPublish:f,appLink:u,tvf:d}=r,g=en(n,s,c);let m;const b=!!u;try{const O=b?Rs:$i;m=await this.client.core.crypto.encode(i,g,{encoding:O})}catch(O){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),O}let x;if(vI.includes(n)){const O=qr(JSON.stringify(g)),$=qr(m);x=await this.client.core.verify.register({id:$,decryptedId:O})}const I=vt[n].req;if(I.attestation=x,o&&(I.ttl=o),a&&(I.id=a),this.client.core.history.set(i,g),b){const O=ma(u,i,m);await global.Linking.openURL(O,this.client.name)}else{const O=vt[n].req;o&&(O.ttl=o),a&&(O.id=a),O.tvf=zt(be({},d),{correlationId:g.id}),f?(O.internal=zt(be({},O.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,m,O)):this.client.core.relayer.publish(i,m,O).catch($=>this.client.logger.error($))}return g.id}),K(this,"sendResult",async r=>{const{id:i,topic:n,result:s,throwOnFailedPublish:o,encodeOpts:a,appLink:c}=r,f=Jf(i,s);let u;const d=c&&typeof(global==null?void 0:global.Linking)<"u";try{const b=d?Rs:$i;u=await this.client.core.crypto.encode(n,f,zt(be({},a||{}),{encoding:b}))}catch(b){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${n} failed`),b}let g,m;try{g=await this.client.core.history.get(n,i);const b=g.request;try{this.shouldSetTVF(b.method,b.params)&&(m=this.getTVFParams(i,b.params,s))}catch(x){this.client.logger.warn("sendResult() -> getTVFParams() failed",x)}}catch(b){throw this.client.logger.error(`sendResult() -> history.get(${n}, ${i}) failed`),b}if(d){const b=ma(c,n,u);await global.Linking.openURL(b,this.client.name)}else{const b=g.request.method,x=vt[b].res;x.tvf=zt(be({},m),{correlationId:i}),o?(x.internal=zt(be({},x.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,u,x)):this.client.core.relayer.publish(n,u,x).catch(I=>this.client.logger.error(I))}await this.client.core.history.resolve(f)}),K(this,"sendError",async r=>{const{id:i,topic:n,error:s,encodeOpts:o,rpcOpts:a,appLink:c}=r,f=Xf(i,s);let u;const d=c&&typeof(global==null?void 0:global.Linking)<"u";try{const m=d?Rs:$i;u=await this.client.core.crypto.encode(n,f,zt(be({},o||{}),{encoding:m}))}catch(m){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`),m}let g;try{g=await this.client.core.history.get(n,i)}catch(m){throw this.client.logger.error(`sendError() -> history.get(${n}, ${i}) failed`),m}if(d){const m=ma(c,n,u);await global.Linking.openURL(m,this.client.name)}else{const m=g.request.method,b=a||vt[m].res;this.client.core.relayer.publish(n,u,b)}await this.client.core.history.resolve(f)}),K(this,"cleanup",async()=>{const r=[],i=[];this.client.session.getAll().forEach(n=>{let s=!1;Si(n.expiry)&&(s=!0),this.client.core.crypto.keychain.has(n.topic)||(s=!0),s&&r.push(n.topic)}),this.client.proposal.getAll().forEach(n=>{Si(n.expiryTimestamp)&&i.push(n.id)}),await Promise.all([...r.map(n=>this.deleteSession({topic:n})),...i.map(n=>this.deleteProposal(n))])}),K(this,"onProviderMessageEvent",async r=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(r):await this.onRelayMessage(r)}),K(this,"onRelayEventRequest",async r=>{this.requestQueue.queue.push(r),await this.processRequestsQueue()}),K(this,"processRequestsQueue",async()=>{if(this.requestQueue.state===Vr.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=Vr.active;const r=this.requestQueue.queue.shift();if(r)try{await this.processRequest(r)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=Vr.idle}),K(this,"processRequest",async r=>{const{topic:i,payload:n,attestation:s,transportType:o,encryptedId:a}=r,c=n.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:c}))switch(c){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:n,attestation:s,encryptedId:a});case"wc_sessionSettle":return await this.onSessionSettleRequest(i,n);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(i,n);case"wc_sessionExtend":return await this.onSessionExtendRequest(i,n);case"wc_sessionPing":return await this.onSessionPingRequest(i,n);case"wc_sessionDelete":return await this.onSessionDeleteRequest(i,n);case"wc_sessionRequest":return await this.onSessionRequest({topic:i,payload:n,attestation:s,encryptedId:a,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(i,n);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:i,payload:n,attestation:s,encryptedId:a,transportType:o});default:return this.client.logger.info(`Unsupported request method ${c}`)}}),K(this,"onRelayEventResponse",async r=>{const{topic:i,payload:n,transportType:s}=r,o=(await this.client.core.history.get(i,n.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(i,n,s);case"wc_sessionSettle":return this.onSessionSettleResponse(i,n);case"wc_sessionUpdate":return this.onSessionUpdateResponse(i,n);case"wc_sessionExtend":return this.onSessionExtendResponse(i,n);case"wc_sessionPing":return this.onSessionPingResponse(i,n);case"wc_sessionRequest":return this.onSessionRequestResponse(i,n);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(i,n);default:return this.client.logger.info(`Unsupported response method ${o}`)}}),K(this,"onRelayEventUnknownPayload",r=>{const{topic:i}=r,{message:n}=H("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(n)}),K(this,"shouldIgnorePairingRequest",r=>{const{topic:i,requestMethod:n}=r,s=this.expectedPairingMethodMap.get(i);return!s||s.includes(n)?!1:!!(s.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)}),K(this,"onSessionProposeRequest",async r=>{const{topic:i,payload:n,attestation:s,encryptedId:o}=r,{params:a,id:c}=n;try{const f=this.client.core.eventClient.getEvent({topic:i});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),f?.setError(ai.proposal_listener_not_found)),this.isValidConnect(be({},n.params));const u=a.expiryTimestamp||at(vt.wc_sessionPropose.req.ttl),d=be({id:c,pairingTopic:i,expiryTimestamp:u},a);await this.setProposal(c,d);const g=await this.getVerifyContext({attestationId:s,hash:qr(JSON.stringify(n)),encryptedId:o,metadata:d.proposer.metadata});f?.addTrace(jr.emit_session_proposal),this.client.events.emit("session_proposal",{id:c,params:d,verifyContext:g})}catch(f){await this.sendError({id:c,topic:i,error:f,rpcOpts:vt.wc_sessionPropose.autoReject}),this.client.logger.error(f)}}),K(this,"onSessionProposeResponse",async(r,i,n)=>{const{id:s}=i;if(Ur(i)){const{result:o}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});const a=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:a});const c=a.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:c});const f=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:f});const u=await this.client.core.crypto.generateSharedKey(c,f);this.pendingSessions.set(s,{sessionTopic:u,pairingTopic:r,proposalId:s,publicKey:c});const d=await this.client.core.relayer.subscribe(u,{transportType:n});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:d}),await this.client.core.pairing.activate({topic:r})}else if(ar(i)){await this.client.proposal.delete(s,we("USER_DISCONNECTED"));const o=ue("session_connect",s);if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(o,{error:i.error})}}),K(this,"onSessionSettleRequest",async(r,i)=>{const{id:n,params:s}=i;try{this.isValidSessionSettleRequest(s);const{relay:o,controller:a,expiry:c,namespaces:f,sessionProperties:u,scopedProperties:d,sessionConfig:g}=i.params,m=[...this.pendingSessions.values()].find(I=>I.sessionTopic===r);if(!m)return this.client.logger.error(`Pending session not found for topic ${r}`);const b=this.client.proposal.get(m.proposalId),x=zt(be(be(be({topic:r,relay:o,expiry:c,namespaces:f,acknowledged:!0,pairingTopic:m.pairingTopic,requiredNamespaces:b.requiredNamespaces,optionalNamespaces:b.optionalNamespaces,controller:a.publicKey,self:{publicKey:m.publicKey,metadata:this.client.metadata},peer:{publicKey:a.publicKey,metadata:a.metadata}},u&&{sessionProperties:u}),d&&{scopedProperties:d}),g&&{sessionConfig:g}),{transportType:Ie.relay});await this.client.session.set(x.topic,x),await this.setExpiry(x.topic,x.expiry),await this.client.core.pairing.updateMetadata({topic:m.pairingTopic,metadata:x.peer.metadata}),this.client.events.emit("session_connect",{session:x}),this.events.emit(ue("session_connect",m.proposalId),{session:x}),this.pendingSessions.delete(m.proposalId),this.deleteProposal(m.proposalId,!1),this.cleanupDuplicatePairings(x),await this.sendResult({id:i.id,topic:r,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:n,topic:r,error:o}),this.client.logger.error(o)}}),K(this,"onSessionSettleResponse",async(r,i)=>{const{id:n}=i;Ur(i)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(ue("session_approve",n),{})):ar(i)&&(await this.client.session.delete(r,we("USER_DISCONNECTED")),this.events.emit(ue("session_approve",n),{error:i.error}))}),K(this,"onSessionUpdateRequest",async(r,i)=>{const{params:n,id:s}=i;try{const o=`${r}_session_update`,a=qs.get(o);if(a&&this.isRequestOutOfSync(a,s)){this.client.logger.warn(`Discarding out of sync request - ${s}`),this.sendError({id:s,topic:r,error:we("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(be({topic:r},n));try{qs.set(o,s),await this.client.session.update(r,{namespaces:n.namespaces}),await this.sendResult({id:s,topic:r,result:!0,throwOnFailedPublish:!0})}catch(c){throw qs.delete(o),c}this.client.events.emit("session_update",{id:s,topic:r,params:n})}catch(o){await this.sendError({id:s,topic:r,error:o}),this.client.logger.error(o)}}),K(this,"isRequestOutOfSync",(r,i)=>i.toString().slice(0,-3)<r.toString().slice(0,-3)),K(this,"onSessionUpdateResponse",(r,i)=>{const{id:n}=i,s=ue("session_update",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Ur(i)?this.events.emit(ue("session_update",n),{}):ar(i)&&this.events.emit(ue("session_update",n),{error:i.error})}),K(this,"onSessionExtendRequest",async(r,i)=>{const{id:n}=i;try{this.isValidExtend({topic:r}),await this.setExpiry(r,at(Qn)),await this.sendResult({id:n,topic:r,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:n,topic:r})}catch(s){await this.sendError({id:n,topic:r,error:s}),this.client.logger.error(s)}}),K(this,"onSessionExtendResponse",(r,i)=>{const{id:n}=i,s=ue("session_extend",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Ur(i)?this.events.emit(ue("session_extend",n),{}):ar(i)&&this.events.emit(ue("session_extend",n),{error:i.error})}),K(this,"onSessionPingRequest",async(r,i)=>{const{id:n}=i;try{this.isValidPing({topic:r}),await this.sendResult({id:n,topic:r,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:n,topic:r})}catch(s){await this.sendError({id:n,topic:r,error:s}),this.client.logger.error(s)}}),K(this,"onSessionPingResponse",(r,i)=>{const{id:n}=i,s=ue("session_ping",n);setTimeout(()=>{if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners 2176`);Ur(i)?this.events.emit(ue("session_ping",n),{}):ar(i)&&this.events.emit(ue("session_ping",n),{error:i.error})},500)}),K(this,"onSessionDeleteRequest",async(r,i)=>{const{id:n}=i;try{this.isValidDisconnect({topic:r,reason:i.params}),Promise.all([new Promise(s=>{this.client.core.relayer.once(bt.publish,async()=>{s(await this.deleteSession({topic:r,id:n}))})}),this.sendResult({id:n,topic:r,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:r,error:we("USER_DISCONNECTED")})]).catch(s=>this.client.logger.error(s))}catch(s){this.client.logger.error(s)}}),K(this,"onSessionRequest",async r=>{var i,n,s;const{topic:o,payload:a,attestation:c,encryptedId:f,transportType:u}=r,{id:d,params:g}=a;try{await this.isValidRequest(be({topic:o},g));const m=this.client.session.get(o),b=await this.getVerifyContext({attestationId:c,hash:qr(JSON.stringify(en("wc_sessionRequest",g,d))),encryptedId:f,metadata:m.peer.metadata,transportType:u}),x={id:d,topic:o,params:g,verifyContext:b};await this.setPendingSessionRequest(x),u===Ie.link_mode&&(i=m.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((n=m.peer.metadata.redirect)==null?void 0:n.universal),(s=this.client.signConfig)!=null&&s.disableRequestQueue?this.emitSessionRequest(x):(this.addSessionRequestToSessionRequestQueue(x),this.processSessionRequestQueue())}catch(m){await this.sendError({id:d,topic:o,error:m}),this.client.logger.error(m)}}),K(this,"onSessionRequestResponse",(r,i)=>{const{id:n}=i,s=ue("session_request",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Ur(i)?this.events.emit(ue("session_request",n),{result:i.result}):ar(i)&&this.events.emit(ue("session_request",n),{error:i.error})}),K(this,"onSessionEventRequest",async(r,i)=>{const{id:n,params:s}=i;try{const o=`${r}_session_event_${s.event.name}`,a=qs.get(o);if(a&&this.isRequestOutOfSync(a,n)){this.client.logger.info(`Discarding out of sync request - ${n}`);return}this.isValidEmit(be({topic:r},s)),this.client.events.emit("session_event",{id:n,topic:r,params:s}),qs.set(o,n)}catch(o){await this.sendError({id:n,topic:r,error:o}),this.client.logger.error(o)}}),K(this,"onSessionAuthenticateResponse",(r,i)=>{const{id:n}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:r,payload:i}),Ur(i)?this.events.emit(ue("session_request",n),{result:i.result}):ar(i)&&this.events.emit(ue("session_request",n),{error:i.error})}),K(this,"onSessionAuthenticateRequest",async r=>{var i;const{topic:n,payload:s,attestation:o,encryptedId:a,transportType:c}=r;try{const{requester:f,authPayload:u,expiryTimestamp:d}=s.params,g=await this.getVerifyContext({attestationId:o,hash:qr(JSON.stringify(s)),encryptedId:a,metadata:f.metadata,transportType:c}),m={requester:f,pairingTopic:n,id:s.id,authPayload:u,verifyContext:g,expiryTimestamp:d};await this.setAuthRequest(s.id,{request:m,pairingTopic:n,transportType:c}),c===Ie.link_mode&&(i=f.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(f.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:n,params:s.params,id:s.id,verifyContext:g})}catch(f){this.client.logger.error(f);const u=s.params.requester.publicKey,d=await this.client.core.crypto.generateKeyPair(),g=this.getAppLinkIfEnabled(s.params.requester.metadata,c),m={type:ni,receiverPublicKey:u,senderPublicKey:d};await this.sendError({id:s.id,topic:n,error:f,encodeOpts:m,rpcOpts:vt.wc_sessionAuthenticate.autoReject,appLink:g})}}),K(this,"addSessionRequestToSessionRequestQueue",r=>{this.sessionRequestQueue.queue.push(r)}),K(this,"cleanupAfterResponse",r=>{this.deletePendingSessionRequest(r.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=Vr.idle,this.processSessionRequestQueue()},V.toMiliseconds(this.requestQueueDelay))}),K(this,"cleanupPendingSentRequestsForTopic",({topic:r,error:i})=>{const n=this.client.core.history.pending;n.length>0&&n.filter(s=>s.topic===r&&s.request.method==="wc_sessionRequest").forEach(s=>{const o=s.request.id,a=ue("session_request",o);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);this.events.emit(ue("session_request",s.request.id),{error:i})})}),K(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===Vr.active){this.client.logger.info("session request queue is already active.");return}const r=this.sessionRequestQueue.queue[0];if(!r){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=Vr.active,this.emitSessionRequest(r)}catch(i){this.client.logger.error(i)}}),K(this,"emitSessionRequest",r=>{this.client.events.emit("session_request",r)}),K(this,"onPairingCreated",r=>{if(r.methods&&this.expectedPairingMethodMap.set(r.topic,r.methods),r.active)return;const i=this.client.proposal.getAll().find(n=>n.pairingTopic===r.topic);i&&this.onSessionProposeRequest({topic:r.topic,payload:en("wc_sessionPropose",zt(be({},i),{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties,scopedProperties:i.scopedProperties}),i.id)})}),K(this,"isValidConnect",async r=>{if(!Ht(r)){const{message:f}=H("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(f)}const{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:s,sessionProperties:o,scopedProperties:a,relays:c}=r;if(St(i)||await this.isValidPairingTopic(i),!t_(c,!0)){const{message:f}=H("MISSING_OR_INVALID",`connect() relays: ${c}`);throw new Error(f)}if(!St(n)&&wa(n)!==0&&this.validateNamespaces(n,"requiredNamespaces"),!St(s)&&wa(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),St(o)||this.validateSessionProps(o,"sessionProperties"),!St(a)){this.validateSessionProps(a,"scopedProperties");const f=Object.keys(n||{}).concat(Object.keys(s||{}));if(!Object.keys(a).every(u=>f.includes(u)))throw new Error(`Scoped properties must be a subset of required/optional namespaces, received: ${JSON.stringify(a)}, required/optional namespaces: ${JSON.stringify(f)}`)}}),K(this,"validateNamespaces",(r,i)=>{const n=e_(r,"connect()",i);if(n)throw new Error(n.message)}),K(this,"isValidApprove",async r=>{if(!Ht(r))throw new Error(H("MISSING_OR_INVALID",`approve() params: ${r}`).message);const{id:i,namespaces:n,relayProtocol:s,sessionProperties:o,scopedProperties:a}=r;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);const c=this.client.proposal.get(i),f=Vf(n,"approve()");if(f)throw new Error(f.message);const u=Dp(c.requiredNamespaces,n,"approve()");if(u)throw new Error(u.message);if(!nt(s,!0)){const{message:d}=H("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(d)}if(St(o)||this.validateSessionProps(o,"sessionProperties"),!St(a)){this.validateSessionProps(a,"scopedProperties");const d=new Set(Object.keys(n));if(!Object.keys(a).every(g=>d.has(g)))throw new Error(`Scoped properties must be a subset of approved namespaces, received: ${JSON.stringify(a)}, approved namespaces: ${Array.from(d).join(", ")}`)}}),K(this,"isValidReject",async r=>{if(!Ht(r)){const{message:s}=H("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(s)}const{id:i,reason:n}=r;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!i_(n)){const{message:s}=H("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(s)}}),K(this,"isValidSessionSettleRequest",r=>{if(!Ht(r)){const{message:f}=H("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(f)}const{relay:i,controller:n,namespaces:s,expiry:o}=r;if(!Ip(i)){const{message:f}=H("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(f)}const a=G7(n,"onSessionSettleRequest()");if(a)throw new Error(a.message);const c=Vf(s,"onSessionSettleRequest()");if(c)throw new Error(c.message);if(Si(o)){const{message:f}=H("EXPIRED","onSessionSettleRequest()");throw new Error(f)}}),K(this,"isValidUpdate",async r=>{if(!Ht(r)){const{message:c}=H("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(c)}const{topic:i,namespaces:n}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const s=this.client.session.get(i),o=Vf(n,"update()");if(o)throw new Error(o.message);const a=Dp(s.requiredNamespaces,n,"update()");if(a)throw new Error(a.message)}),K(this,"isValidExtend",async r=>{if(!Ht(r)){const{message:n}=H("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(n)}const{topic:i}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)}),K(this,"isValidRequest",async r=>{if(!Ht(r)){const{message:c}=H("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(c)}const{topic:i,request:n,chainId:s,expiry:o}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const{namespaces:a}=this.client.session.get(i);if(!Ap(a,s)){const{message:c}=H("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(c)}if(!n_(n)){const{message:c}=H("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(c)}if(!a_(a,s,n.method)){const{message:c}=H("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(c)}if(o&&!h_(o,vu)){const{message:c}=H("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${vu.min} and ${vu.max}`);throw new Error(c)}}),K(this,"isValidRespond",async r=>{var i;if(!Ht(r)){const{message:o}=H("MISSING_OR_INVALID",`respond() params: ${r}`);throw new Error(o)}const{topic:n,response:s}=r;try{await this.isValidSessionTopic(n)}catch(o){throw(i=r?.response)!=null&&i.id&&this.cleanupAfterResponse(r),o}if(!s_(s)){const{message:o}=H("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(o)}}),K(this,"isValidPing",async r=>{if(!Ht(r)){const{message:n}=H("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)}),K(this,"isValidEmit",async r=>{if(!Ht(r)){const{message:a}=H("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(a)}const{topic:i,event:n,chainId:s}=r;await this.isValidSessionTopic(i);const{namespaces:o}=this.client.session.get(i);if(!Ap(o,s)){const{message:a}=H("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(a)}if(!o_(n)){const{message:a}=H("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}if(!c_(o,s,n.name)){const{message:a}=H("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}}),K(this,"isValidDisconnect",async r=>{if(!Ht(r)){const{message:n}=H("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)}),K(this,"isValidAuthenticate",r=>{const{chains:i,uri:n,domain:s,nonce:o}=r;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!nt(n,!1))throw new Error("uri is required parameter");if(!nt(s,!1))throw new Error("domain is required parameter");if(!nt(o,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(c=>ca(c).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:a}=ca(i[0]);if(a!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),K(this,"getVerifyContext",async r=>{const{attestationId:i,hash:n,encryptedId:s,metadata:o,transportType:a}=r,c={verified:{verifyUrl:o.verifyUrl||js,validation:"UNKNOWN",origin:o.url||""}};try{if(a===Ie.link_mode){const u=this.getAppLinkIfEnabled(o,a);return c.verified.validation=u&&new URL(u).origin===new URL(o.url).origin?"VALID":"INVALID",c}const f=await this.client.core.verify.resolve({attestationId:i,hash:n,encryptedId:s,verifyUrl:o.verifyUrl});f&&(c.verified.origin=f.origin,c.verified.isScam=f.isScam,c.verified.validation=f.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(f){this.client.logger.warn(f)}return this.client.logger.debug(`Verify context: ${JSON.stringify(c)}`),c}),K(this,"validateSessionProps",(r,i)=>{Object.values(r).forEach((n,s)=>{if(n==null){const{message:o}=H("MISSING_OR_INVALID",`${i} must contain an existing value for each key. Received: ${n} for key ${Object.keys(r)[s]}`);throw new Error(o)}})}),K(this,"getPendingAuthRequest",r=>{const i=this.client.auth.requests.get(r);return typeof i=="object"?i:void 0}),K(this,"addToRecentlyDeleted",(r,i)=>{if(this.recentlyDeletedMap.set(r,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let n=0;const s=this.recentlyDeletedLimit/2;for(const o of this.recentlyDeletedMap.keys()){if(n++>=s)break;this.recentlyDeletedMap.delete(o)}}}),K(this,"checkRecentlyDeleted",r=>{const i=this.recentlyDeletedMap.get(r);if(i){const{message:n}=H("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${r}`);throw new Error(n)}}),K(this,"isLinkModeEnabled",(r,i)=>{var n,s,o,a,c,f,u,d,g;return!r||i!==Ie.link_mode?!1:((s=(n=this.client.metadata)==null?void 0:n.redirect)==null?void 0:s.linkMode)===!0&&((a=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:a.universal)!==void 0&&((f=(c=this.client.metadata)==null?void 0:c.redirect)==null?void 0:f.universal)!==""&&((u=r?.redirect)==null?void 0:u.universal)!==void 0&&((d=r?.redirect)==null?void 0:d.universal)!==""&&((g=r?.redirect)==null?void 0:g.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(r.redirect.universal)&&typeof(global==null?void 0:global.Linking)<"u"}),K(this,"getAppLinkIfEnabled",(r,i)=>{var n;return this.isLinkModeEnabled(r,i)?(n=r?.redirect)==null?void 0:n.universal:void 0}),K(this,"handleLinkModeMessage",({url:r})=>{if(!r||!r.includes("wc_ev")||!r.includes("topic"))return;const i=E0(r,"topic")||"",n=decodeURIComponent(E0(r,"wc_ev")||""),s=this.client.session.keys.includes(i);s&&this.client.session.update(i,{transportType:Ie.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:n,sessionExists:s})}),K(this,"registerLinkModeListeners",async()=>{var r;if(Sf()||xi()&&(r=this.client.metadata.redirect)!=null&&r.linkMode){const i=global==null?void 0:global.Linking;if(typeof i<"u"){i.addEventListener("url",this.handleLinkModeMessage,this.client.name);const n=await i.getInitialURL();n&&setTimeout(()=>{this.handleLinkModeMessage({url:n})},50)}}}),K(this,"shouldSetTVF",(r,i)=>{if(!i||r!=="wc_sessionRequest")return!1;const{request:n}=i;return Object.keys(D1).includes(n.method)}),K(this,"getTVFParams",(r,i,n)=>{var s,o;try{const a=i.request.method,c=this.extractTxHashesFromResult(a,n);return zt(be({correlationId:r,rpcMethods:[a],chainId:i.chainId},this.isValidContractData(i.request.params)&&{contractAddresses:[(o=(s=i.request.params)==null?void 0:s[0])==null?void 0:o.to]}),{txHashes:c})}catch(a){this.client.logger.warn("Error getting TVF params",a)}return{}}),K(this,"isValidContractData",r=>{var i;if(!r)return!1;try{const n=r?.data||((i=r?.[0])==null?void 0:i.data);if(!n.startsWith("0x"))return!1;const s=n.slice(2);return/^[0-9a-fA-F]*$/.test(s)?s.length%2===0:!1}catch{}return!1}),K(this,"extractTxHashesFromResult",(r,i)=>{try{const n=D1[r];if(typeof i=="string")return[i];const s=i[n.key];if(Ls(s))return r==="solana_signAllTransactions"?s.map(o=>f9(o)):s;if(typeof s=="string")return[s]}catch(n){this.client.logger.warn("Error extracting tx hashes from result",n)}return[]})}async processPendingMessageEvents(){try{const e=this.client.session.keys,r=this.client.core.relayer.messages.getWithoutAck(e);for(const[i,n]of Object.entries(r))for(const s of n)try{await this.onProviderMessageEvent({topic:i,message:s,publishedAt:Date.now()})}catch{this.client.logger.warn(`Error processing pending message event for topic: ${i}, message: ${s}`)}}catch(e){this.client.logger.warn("processPendingMessageEvents failed",e)}}isInitialized(){if(!this.initialized){const{message:e}=H("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(bt.message,e=>{this.onProviderMessageEvent(e)})}async onRelayMessage(e){const{topic:r,message:i,attestation:n,transportType:s}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes($a)?this.client.auth.authKeys.get($a):{responseTopic:void 0,publicKey:void 0};try{const a=await this.client.core.crypto.decode(r,i,{receiverPublicKey:o,encoding:s===Ie.link_mode?Rs:$i});Qf(a)?(this.client.core.history.set(r,a),await this.onRelayEventRequest({topic:r,payload:a,attestation:n,transportType:s,encryptedId:qr(i)})):xa(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:r,payload:a,transportType:s}),this.client.core.history.delete(r,a.id)):await this.onRelayEventUnknownPayload({topic:r,payload:a,transportType:s}),await this.client.core.relayer.messages.ack(r,i)}catch(a){this.client.logger.error(a)}}registerExpirerEvents(){this.client.core.expirer.on(fr.expired,async e=>{const{topic:r,id:i}=x0(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,H("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,H("EXPIRED"),!0);r?this.client.session.keys.includes(r)&&(await this.deleteSession({topic:r,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:r})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))})}registerPairingEvents(){this.client.core.pairing.events.on(tn.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(tn.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!nt(e,!1)){const{message:r}=H("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(r)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:r}=H("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(r)}if(Si(this.client.core.pairing.pairings.get(e).expiry)){const{message:r}=H("EXPIRED",`pairing topic: ${e}`);throw new Error(r)}}async isValidSessionTopic(e){if(!nt(e,!1)){const{message:r}=H("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(r)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:r}=H("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(r)}if(Si(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:r}=H("EXPIRED",`session topic: ${e}`);throw new Error(r)}if(!this.client.core.crypto.keychain.has(e)){const{message:r}=H("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(r)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(nt(e,!1)){const{message:r}=H("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(r)}else{const{message:r}=H("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(r)}}async isValidProposalId(e){if(!r_(e)){const{message:r}=H("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(r)}if(!this.client.proposal.keys.includes(e)){const{message:r}=H("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(r)}if(Si(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:r}=H("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}}class MI extends sn{constructor(e,r){super(e,r,pI,bu),this.core=e,this.logger=r}}class O1 extends sn{constructor(e,r){super(e,r,gI,bu),this.core=e,this.logger=r}}class PI extends sn{constructor(e,r){super(e,r,yI,bu,i=>i.id),this.core=e,this.logger=r}}class RI extends sn{constructor(e,r){super(e,r,_I,Da,()=>$a),this.core=e,this.logger=r}}class TI extends sn{constructor(e,r){super(e,r,xI,Da),this.core=e,this.logger=r}}class CI extends sn{constructor(e,r){super(e,r,EI,Da,i=>i.id),this.core=e,this.logger=r}}var NI=Object.defineProperty,BI=(t,e,r)=>e in t?NI(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,wu=(t,e,r)=>BI(t,typeof e!="symbol"?e+"":e,r);class FI{constructor(e,r){this.core=e,this.logger=r,wu(this,"authKeys"),wu(this,"pairingTopics"),wu(this,"requests"),this.authKeys=new RI(this.core,this.logger),this.pairingTopics=new TI(this.core,this.logger),this.requests=new CI(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}var LI=Object.defineProperty,qI=(t,e,r)=>e in t?LI(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,se=(t,e,r)=>qI(t,typeof e!="symbol"?e+"":e,r);class _u extends ey{constructor(e){super(e),se(this,"protocol",x1),se(this,"version",E1),se(this,"name",yu.name),se(this,"metadata"),se(this,"core"),se(this,"logger"),se(this,"events",new Mt.exports.EventEmitter),se(this,"engine"),se(this,"session"),se(this,"proposal"),se(this,"pendingRequest"),se(this,"auth"),se(this,"signConfig"),se(this,"on",(i,n)=>this.events.on(i,n)),se(this,"once",(i,n)=>this.events.once(i,n)),se(this,"off",(i,n)=>this.events.off(i,n)),se(this,"removeListener",(i,n)=>this.events.removeListener(i,n)),se(this,"removeAllListeners",i=>this.events.removeAllListeners(i)),se(this,"connect",async i=>{try{return await this.engine.connect(i)}catch(n){throw this.logger.error(n.message),n}}),se(this,"pair",async i=>{try{return await this.engine.pair(i)}catch(n){throw this.logger.error(n.message),n}}),se(this,"approve",async i=>{try{return await this.engine.approve(i)}catch(n){throw this.logger.error(n.message),n}}),se(this,"reject",async i=>{try{return await this.engine.reject(i)}catch(n){throw this.logger.error(n.message),n}}),se(this,"update",async i=>{try{return await this.engine.update(i)}catch(n){throw this.logger.error(n.message),n}}),se(this,"extend",async i=>{try{return await this.engine.extend(i)}catch(n){throw this.logger.error(n.message),n}}),se(this,"request",async i=>{try{return await this.engine.request(i)}catch(n){throw this.logger.error(n.message),n}}),se(this,"respond",async i=>{try{return await this.engine.respond(i)}catch(n){throw this.logger.error(n.message),n}}),se(this,"ping",async i=>{try{return await this.engine.ping(i)}catch(n){throw this.logger.error(n.message),n}}),se(this,"emit",async i=>{try{return await this.engine.emit(i)}catch(n){throw this.logger.error(n.message),n}}),se(this,"disconnect",async i=>{try{return await this.engine.disconnect(i)}catch(n){throw this.logger.error(n.message),n}}),se(this,"find",i=>{try{return this.engine.find(i)}catch(n){throw this.logger.error(n.message),n}}),se(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}}),se(this,"authenticate",async(i,n)=>{try{return await this.engine.authenticate(i,n)}catch(s){throw this.logger.error(s.message),s}}),se(this,"formatAuthMessage",i=>{try{return this.engine.formatAuthMessage(i)}catch(n){throw this.logger.error(n.message),n}}),se(this,"approveSessionAuthenticate",async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}}),se(this,"rejectSessionAuthenticate",async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}}),this.name=e?.name||yu.name,this.metadata=e?.metadata||m0(),this.signConfig=e?.signConfig;const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:Wr(tc({level:e?.logger||yu.logger}));this.core=e?.core||new gu(e),this.logger=Ft(r,this.name),this.session=new O1(this.core,this.logger),this.proposal=new MI(this.core,this.logger),this.pendingRequest=new PI(this.core,this.logger),this.engine=new OI(this),this.auth=new FI(this.core,this.logger)}static async init(e){const r=new _u(e);return await r.initialize(),r}get context(){return kt(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),setTimeout(()=>{this.engine.processRelayMessageCache()},V.toMiliseconds(V.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}const zI=O1,UI=_u;class kI extends Mt.exports{constructor(){super()}}class M1{constructor(e){this.opts=e}}class P1{constructor(e){this.client=e}}var jI=Object.defineProperty,KI=Object.defineProperties,VI=Object.getOwnPropertyDescriptors,R1=Object.getOwnPropertySymbols,HI=Object.prototype.hasOwnProperty,WI=Object.prototype.propertyIsEnumerable,T1=(t,e,r)=>e in t?jI(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,GI=(t,e)=>{for(var r in e||(e={}))HI.call(e,r)&&T1(t,r,e[r]);if(R1)for(var r of R1(e))WI.call(e,r)&&T1(t,r,e[r]);return t},YI=(t,e)=>KI(t,VI(e));class ZI extends P1{constructor(e){super(e),this.init=async()=>{this.signClient=await UI.init({core:this.client.core,metadata:this.client.metadata,signConfig:this.client.signConfig}),this.signClient.core.eventClient.init().catch(r=>{this.client.logger.warn(r)})},this.pair=async r=>{await this.client.core.pairing.pair(r)},this.approveSession=async r=>{const{topic:i,acknowledged:n}=await this.signClient.approve(YI(GI({},r),{id:r.id,namespaces:r.namespaces,sessionProperties:r.sessionProperties,sessionConfig:r.sessionConfig}));return await n(),this.signClient.session.get(i)},this.rejectSession=async r=>await this.signClient.reject(r),this.updateSession=async r=>await this.signClient.update(r),this.extendSession=async r=>await this.signClient.extend(r),this.respondSessionRequest=async r=>await this.signClient.respond(r),this.disconnectSession=async r=>await this.signClient.disconnect(r),this.emitSessionEvent=async r=>await this.signClient.emit(r),this.getActiveSessions=()=>this.signClient.session.getAll().reduce((r,i)=>(r[i.topic]=i,r),{}),this.getPendingSessionProposals=()=>this.signClient.proposal.getAll(),this.getPendingSessionRequests=()=>this.signClient.getPendingSessionRequests(),this.approveSessionAuthenticate=async r=>await this.signClient.approveSessionAuthenticate(r),this.rejectSessionAuthenticate=async r=>await this.signClient.rejectSessionAuthenticate(r),this.formatAuthMessage=r=>this.signClient.formatAuthMessage(r),this.registerDeviceToken=r=>this.client.core.echoClient.registerDeviceToken(r),this.on=(r,i)=>(this.setEvent(r,"off"),this.setEvent(r,"on"),this.client.events.on(r,i)),this.once=(r,i)=>(this.setEvent(r,"off"),this.setEvent(r,"once"),this.client.events.once(r,i)),this.off=(r,i)=>(this.setEvent(r,"off"),this.client.events.off(r,i)),this.removeListener=(r,i)=>(this.setEvent(r,"removeListener"),this.client.events.removeListener(r,i)),this.onSessionRequest=r=>{this.client.events.emit("session_request",r)},this.onSessionProposal=r=>{this.client.events.emit("session_proposal",r)},this.onSessionDelete=r=>{this.client.events.emit("session_delete",r)},this.onProposalExpire=r=>{this.client.events.emit("proposal_expire",r)},this.onSessionRequestExpire=r=>{this.client.events.emit("session_request_expire",r)},this.onSessionRequestAuthenticate=r=>{this.client.events.emit("session_authenticate",r)},this.setEvent=(r,i)=>{switch(r){case"session_request":this.signClient.events[i]("session_request",this.onSessionRequest);break;case"session_proposal":this.signClient.events[i]("session_proposal",this.onSessionProposal);break;case"session_delete":this.signClient.events[i]("session_delete",this.onSessionDelete);break;case"proposal_expire":this.signClient.events[i]("proposal_expire",this.onProposalExpire);break;case"session_request_expire":this.signClient.events[i]("session_request_expire",this.onSessionRequestExpire);break;case"session_authenticate":this.signClient.events[i]("session_authenticate",this.onSessionRequestAuthenticate);break}},this.signClient={}}}const JI={decryptMessage:async t=>{const e={core:new gu({storageOptions:t.storageOptions,storage:t.storage})};await e.core.crypto.init();const r=e.core.crypto.decode(t.topic,t.encryptedMessage);return e.core=null,r},getMetadata:async t=>{const e={core:new gu({storageOptions:t.storageOptions,storage:t.storage}),sessionStore:null};e.sessionStore=new zI(e.core,e.core.logger),await e.sessionStore.init();const r=e.sessionStore.get(t.topic),i=r?.peer.metadata;return e.core=null,e.sessionStore=null,i}},C1=class extends M1{constructor(t){super(t),this.events=new Mt.exports,this.on=(e,r)=>this.engine.on(e,r),this.once=(e,r)=>this.engine.once(e,r),this.off=(e,r)=>this.engine.off(e,r),this.removeListener=(e,r)=>this.engine.removeListener(e,r),this.pair=async e=>{try{return await this.engine.pair(e)}catch(r){throw this.logger.error(r.message),r}},this.approveSession=async e=>{try{return await this.engine.approveSession(e)}catch(r){throw this.logger.error(r.message),r}},this.rejectSession=async e=>{try{return await this.engine.rejectSession(e)}catch(r){throw this.logger.error(r.message),r}},this.updateSession=async e=>{try{return await this.engine.updateSession(e)}catch(r){throw this.logger.error(r.message),r}},this.extendSession=async e=>{try{return await this.engine.extendSession(e)}catch(r){throw this.logger.error(r.message),r}},this.respondSessionRequest=async e=>{try{return await this.engine.respondSessionRequest(e)}catch(r){throw this.logger.error(r.message),r}},this.disconnectSession=async e=>{try{return await this.engine.disconnectSession(e)}catch(r){throw this.logger.error(r.message),r}},this.emitSessionEvent=async e=>{try{return await this.engine.emitSessionEvent(e)}catch(r){throw this.logger.error(r.message),r}},this.getActiveSessions=()=>{try{return this.engine.getActiveSessions()}catch(e){throw this.logger.error(e.message),e}},this.getPendingSessionProposals=()=>{try{return this.engine.getPendingSessionProposals()}catch(e){throw this.logger.error(e.message),e}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(e){throw this.logger.error(e.message),e}},this.registerDeviceToken=e=>{try{return this.engine.registerDeviceToken(e)}catch(r){throw this.logger.error(r.message),r}},this.approveSessionAuthenticate=e=>{try{return this.engine.approveSessionAuthenticate(e)}catch(r){throw this.logger.error(r.message),r}},this.rejectSessionAuthenticate=e=>{try{return this.engine.rejectSessionAuthenticate(e)}catch(r){throw this.logger.error(r.message),r}},this.formatAuthMessage=e=>{try{return this.engine.formatAuthMessage(e)}catch(r){throw this.logger.error(r.message),r}},this.metadata=t.metadata,this.name=t.name||za,this.signConfig=t.signConfig,this.core=t.core,this.logger=this.core.logger,this.engine=new ZI(this)}static async init(t){const e=new C1(t);return await e.initialize(),e}async initialize(){this.logger.trace("Initialized");try{await this.engine.init(),this.logger.info("WalletKit Initialization Success")}catch(t){throw this.logger.info("WalletKit Initialization Failure"),this.logger.error(t.message),t}}};let xu=C1;xu.notifications=JI;const XI=xu;Ot.CLIENT_CONTEXT=za,Ot.CLIENT_STORAGE_OPTIONS=Q1,Ot.CLIENT_STORAGE_PREFIX=X1,Ot.IWalletKit=M1,Ot.IWalletKitEngine=P1,Ot.IWalletKitEvents=kI,Ot.PROTOCOL=Cu,Ot.PROTOCOL_VERSION=J1,Ot.REQUEST_CONTEXT=eg,Ot.WalletKit=XI,Ot.default=xu,Object.defineProperty(Ot,"__esModule",{value:!0})});
44
40
  //# sourceMappingURL=index.umd.js.map