@reown/walletkit 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.umd.js +9 -9
- package/dist/index.umd.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
package/dist/index.umd.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
(function(Bt,Kt){typeof exports=="object"&&typeof module<"u"?Kt(exports):typeof define=="function"&&define.amd?define(["exports"],Kt):(Bt=typeof globalThis<"u"?globalThis:Bt||self,Kt(Bt["@reown/walletkit"]={}))})(this,function(Bt){"use strict";var Kt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function co(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 qt={exports:{}},_n=typeof Reflect=="object"?Reflect:null,of=_n&&typeof _n.apply=="function"?_n.apply:function(e,r,i){return Function.prototype.apply.call(e,r,i)},Ys;_n&&typeof _n.ownKeys=="function"?Ys=_n.ownKeys:Object.getOwnPropertySymbols?Ys=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Ys=function(e){return Object.getOwnPropertyNames(e)};function Ml(t){console&&console.warn&&console.warn(t)}var cf=Number.isNaN||function(e){return e!==e};function st(){st.init.call(this)}qt.exports=st,qt.exports.once=Rl,st.EventEmitter=st,st.prototype._events=void 0,st.prototype._eventsCount=0,st.prototype._maxListeners=void 0;var ff=10;function Js(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(st,"defaultMaxListeners",{enumerable:!0,get:function(){return ff},set:function(t){if(typeof t!="number"||t<0||cf(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");ff=t}}),st.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},st.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||cf(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 hf(t){return t._maxListeners===void 0?st.defaultMaxListeners:t._maxListeners}st.prototype.getMaxListeners=function(){return hf(this)},st.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 c=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw c.context=o,c}var l=s[e];if(l===void 0)return!1;if(typeof l=="function")of(l,this,r);else for(var u=l.length,b=gf(l,u),i=0;i<u;++i)of(b[i],this,r);return!0};function uf(t,e,r,i){var n,s,o;if(Js(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=hf(t),n>0&&o.length>n&&!o.warned){o.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=o.length,Ml(c)}return t}st.prototype.addListener=function(e,r){return uf(this,e,r,!1)},st.prototype.on=st.prototype.addListener,st.prototype.prependListener=function(e,r){return uf(this,e,r,!0)};function Il(){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 df(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},n=Il.bind(i);return n.listener=r,i.wrapFn=n,n}st.prototype.once=function(e,r){return Js(r),this.on(e,df(this,e,r)),this},st.prototype.prependOnceListener=function(e,r){return Js(r),this.prependListener(e,df(this,e,r)),this},st.prototype.removeListener=function(e,r){var i,n,s,o,c;if(Js(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){c=i[o].listener,s=o;break}if(s<0)return this;s===0?i.shift():Dl(i,s),i.length===1&&(n[e]=i[0]),n.removeListener!==void 0&&this.emit("removeListener",e,c||r)}return this},st.prototype.off=st.prototype.removeListener,st.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 lf(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?Ol(n):gf(n,n.length)}st.prototype.listeners=function(e){return lf(this,e,!0)},st.prototype.rawListeners=function(e){return lf(this,e,!1)},st.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):pf.call(t,e)},st.prototype.listenerCount=pf;function pf(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}st.prototype.eventNames=function(){return this._eventsCount>0?Ys(this._events):[]};function gf(t,e){for(var r=new Array(e),i=0;i<e;++i)r[i]=t[i];return r}function Dl(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function Ol(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function Rl(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))}bf(t,e,s,{once:!0}),e!=="error"&&Nl(t,n,{once:!0})})}function Nl(t,e,r){typeof t.on=="function"&&bf(t,"error",e,r)}function bf(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 vf="wc",Pl=2,fo="WalletKit",Tl=`${vf}@2:${fo}:`,Cl={database:":memory:"},Fl="request",Ll=/"(?:_|\\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*:/,Bl=/"(?: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*:/,ql=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function Ul(t,e){if(t==="__proto__"||t==="constructor"&&e&&typeof e=="object"&&"prototype"in e){zl(t);return}return e}function zl(t){console.warn(`[destr] Dropping "${t}" key to prevent prototype pollution.`)}function Qs(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(!ql.test(t)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return t}try{if(Ll.test(t)||Bl.test(t)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(t,Ul)}return JSON.parse(t)}catch(i){if(e.strict)throw i;return t}}function kl(t){return!t||typeof t.then!="function"?Promise.resolve(t):t}function At(t,...e){try{return kl(t(...e))}catch(r){return Promise.reject(r)}}function $l(t){const e=typeof t;return t===null||e!=="object"&&e!=="function"}function jl(t){const e=Object.getPrototypeOf(t);return!e||e.isPrototypeOf(Object)}function Xs(t){if($l(t))return String(t);if(jl(t)||Array.isArray(t))return JSON.stringify(t);if(typeof t.toJSON=="function")return Xs(t.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function mf(){if(typeof Buffer>"u")throw new TypeError("[unstorage] Buffer is not supported!")}const ho="base64:";function Kl(t){if(typeof t=="string")return t;mf();const e=Buffer.from(t).toString("base64");return ho+e}function Hl(t){return typeof t!="string"||!t.startsWith(ho)?t:(mf(),Buffer.from(t.slice(ho.length),"base64"))}function Qt(t){return t?t.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function Vl(...t){return Qt(t.join(":"))}function Zs(t){return t=Qt(t),t?t+":":""}function W9(t){return t}const Gl="memory",Wl=()=>{const t=new Map;return{name:Gl,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 Yl(t={}){const e={mounts:{"":t.driver||Wl()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},r=u=>{for(const b of e.mountpoints)if(u.startsWith(b))return{base:b,relativeKey:u.slice(b.length),driver:e.mounts[b]};return{base:"",relativeKey:u,driver:e.mounts[""]}},i=(u,b)=>e.mountpoints.filter(m=>m.startsWith(u)||b&&u.startsWith(m)).map(m=>({relativeBase:u.length>m.length?u.slice(m.length):void 0,mountpoint:m,driver:e.mounts[m]})),n=(u,b)=>{if(e.watching){b=Qt(b);for(const m of e.watchListeners)m(u,b)}},s=async()=>{if(!e.watching){e.watching=!0;for(const u in e.mounts)e.unwatch[u]=await yf(e.mounts[u],n,u)}},o=async()=>{if(e.watching){for(const u in e.unwatch)await e.unwatch[u]();e.unwatch={},e.watching=!1}},c=(u,b,m)=>{const M=new Map,S=I=>{let F=M.get(I.base);return F||(F={driver:I.driver,base:I.base,items:[]},M.set(I.base,F)),F};for(const I of u){const F=typeof I=="string",k=Qt(F?I:I.key),j=F?void 0:I.value,C=F||!I.options?b:{...b,...I.options},$=r(k);S($).items.push({key:k,value:j,relativeKey:$.relativeKey,options:C})}return Promise.all([...M.values()].map(I=>m(I))).then(I=>I.flat())},l={hasItem(u,b={}){u=Qt(u);const{relativeKey:m,driver:M}=r(u);return At(M.hasItem,m,b)},getItem(u,b={}){u=Qt(u);const{relativeKey:m,driver:M}=r(u);return At(M.getItem,m,b).then(S=>Qs(S))},getItems(u,b){return c(u,b,m=>m.driver.getItems?At(m.driver.getItems,m.items.map(M=>({key:M.relativeKey,options:M.options})),b).then(M=>M.map(S=>({key:Vl(m.base,S.key),value:Qs(S.value)}))):Promise.all(m.items.map(M=>At(m.driver.getItem,M.relativeKey,M.options).then(S=>({key:M.key,value:Qs(S)})))))},getItemRaw(u,b={}){u=Qt(u);const{relativeKey:m,driver:M}=r(u);return M.getItemRaw?At(M.getItemRaw,m,b):At(M.getItem,m,b).then(S=>Hl(S))},async setItem(u,b,m={}){if(b===void 0)return l.removeItem(u);u=Qt(u);const{relativeKey:M,driver:S}=r(u);S.setItem&&(await At(S.setItem,M,Xs(b),m),S.watch||n("update",u))},async setItems(u,b){await c(u,b,async m=>{if(m.driver.setItems)return At(m.driver.setItems,m.items.map(M=>({key:M.relativeKey,value:Xs(M.value),options:M.options})),b);m.driver.setItem&&await Promise.all(m.items.map(M=>At(m.driver.setItem,M.relativeKey,Xs(M.value),M.options)))})},async setItemRaw(u,b,m={}){if(b===void 0)return l.removeItem(u,m);u=Qt(u);const{relativeKey:M,driver:S}=r(u);if(S.setItemRaw)await At(S.setItemRaw,M,b,m);else if(S.setItem)await At(S.setItem,M,Kl(b),m);else return;S.watch||n("update",u)},async removeItem(u,b={}){typeof b=="boolean"&&(b={removeMeta:b}),u=Qt(u);const{relativeKey:m,driver:M}=r(u);M.removeItem&&(await At(M.removeItem,m,b),(b.removeMeta||b.removeMata)&&await At(M.removeItem,m+"$",b),M.watch||n("remove",u))},async getMeta(u,b={}){typeof b=="boolean"&&(b={nativeOnly:b}),u=Qt(u);const{relativeKey:m,driver:M}=r(u),S=Object.create(null);if(M.getMeta&&Object.assign(S,await At(M.getMeta,m,b)),!b.nativeOnly){const I=await At(M.getItem,m+"$",b).then(F=>Qs(F));I&&typeof I=="object"&&(typeof I.atime=="string"&&(I.atime=new Date(I.atime)),typeof I.mtime=="string"&&(I.mtime=new Date(I.mtime)),Object.assign(S,I))}return S},setMeta(u,b,m={}){return this.setItem(u+"$",b,m)},removeMeta(u,b={}){return this.removeItem(u+"$",b)},async getKeys(u,b={}){u=Zs(u);const m=i(u,!0);let M=[];const S=[];for(const I of m){const F=await At(I.driver.getKeys,I.relativeBase,b);for(const k of F){const j=I.mountpoint+Qt(k);M.some(C=>j.startsWith(C))||S.push(j)}M=[I.mountpoint,...M.filter(k=>!k.startsWith(I.mountpoint))]}return u?S.filter(I=>I.startsWith(u)&&I[I.length-1]!=="$"):S.filter(I=>I[I.length-1]!=="$")},async clear(u,b={}){u=Zs(u),await Promise.all(i(u,!1).map(async m=>{if(m.driver.clear)return At(m.driver.clear,m.relativeBase,b);if(m.driver.removeItem){const M=await m.driver.getKeys(m.relativeBase||"",b);return Promise.all(M.map(S=>m.driver.removeItem(S,b)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(u=>wf(u)))},async watch(u){return await s(),e.watchListeners.push(u),async()=>{e.watchListeners=e.watchListeners.filter(b=>b!==u),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(u,b){if(u=Zs(u),u&&e.mounts[u])throw new Error(`already mounted at ${u}`);return u&&(e.mountpoints.push(u),e.mountpoints.sort((m,M)=>M.length-m.length)),e.mounts[u]=b,e.watching&&Promise.resolve(yf(b,n,u)).then(m=>{e.unwatch[u]=m}).catch(console.error),l},async unmount(u,b=!0){u=Zs(u),!(!u||!e.mounts[u])&&(e.watching&&u in e.unwatch&&(e.unwatch[u](),delete e.unwatch[u]),b&&await wf(e.mounts[u]),e.mountpoints=e.mountpoints.filter(m=>m!==u),delete e.mounts[u])},getMount(u=""){u=Qt(u)+":";const b=r(u);return{driver:b.driver,base:b.base}},getMounts(u="",b={}){return u=Qt(u),i(u,b.parents).map(M=>({driver:M.driver,base:M.mountpoint}))},keys:(u,b={})=>l.getKeys(u,b),get:(u,b={})=>l.getItem(u,b),set:(u,b,m={})=>l.setItem(u,b,m),has:(u,b={})=>l.hasItem(u,b),del:(u,b={})=>l.removeItem(u,b),remove:(u,b={})=>l.removeItem(u,b)};return l}function yf(t,e,r){return t.watch?t.watch((i,n)=>e(i,r+n)):()=>{}}async function wf(t){typeof t.dispose=="function"&&await At(t.dispose)}function Wi(t){return new Promise((e,r)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>r(t.error)})}function _f(t,e){const r=indexedDB.open(t);r.onupgradeneeded=()=>r.result.createObjectStore(e);const i=Wi(r);return(n,s)=>i.then(o=>s(o.transaction(e,n).objectStore(e)))}let uo;function ns(){return uo||(uo=_f("keyval-store","keyval")),uo}function Af(t,e=ns()){return e("readonly",r=>Wi(r.get(t)))}function Jl(t,e,r=ns()){return r("readwrite",i=>(i.put(e,t),Wi(i.transaction)))}function Ql(t,e=ns()){return e("readwrite",r=>(r.delete(t),Wi(r.transaction)))}function Xl(t=ns()){return t("readwrite",e=>(e.clear(),Wi(e.transaction)))}function Zl(t,e){return t.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},Wi(t.transaction)}function e1(t=ns()){return t("readonly",e=>{if(e.getAllKeys)return Wi(e.getAllKeys());const r=[];return Zl(e,i=>r.push(i.key)).then(()=>r)})}const t1=t=>JSON.stringify(t,(e,r)=>typeof r=="bigint"?r.toString()+"n":r),r1=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 r1(t)}catch{return t}}function Yi(t){return typeof t=="string"?t:t1(t)||""}const i1="idb-keyval";var n1=(t={})=>{const e=t.base&&t.base.length>0?`${t.base}:`:"",r=n=>e+n;let i;return t.dbName&&t.storeName&&(i=_f(t.dbName,t.storeName)),{name:i1,options:t,async hasItem(n){return!(typeof await Af(r(n),i)>"u")},async getItem(n){return await Af(r(n),i)??null},setItem(n,s){return Jl(r(n),s,i)},removeItem(n){return Ql(r(n),i)},getKeys(){return e1(i)},clear(){return Xl(i)}}};const s1="WALLET_CONNECT_V2_INDEXED_DB",a1="keyvaluestorage";class o1{constructor(){this.indexedDb=Yl({driver:n1({dbName:s1,storeName:a1})})}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,Yi(r))}async removeItem(e){await this.indexedDb.removeItem(e)}}var lo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},ea={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 lo<"u"&&lo.localStorage?ea.exports=lo.localStorage:typeof window<"u"&&window.localStorage?ea.exports=window.localStorage:ea.exports=new e})();function c1(t){var e;return[t[0],An((e=t[1])!=null?e:"")]}class f1{constructor(){this.localStorage=ea.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(c1)}async getItem(e){const r=this.localStorage.getItem(e);if(r!==null)return An(r)}async setItem(e,r){this.localStorage.setItem(e,Yi(r))}async removeItem(e){this.localStorage.removeItem(e)}}const h1="wc_storage_version",Ef=1,u1=async(t,e,r)=>{const i=h1,n=await e.getItem(i);if(n&&n>=Ef){r(e);return}const s=await t.getKeys();if(!s.length){r(e);return}const o=[];for(;s.length;){const c=s.shift();if(!c)continue;const l=c.toLowerCase();if(l.includes("wc@")||l.includes("walletconnect")||l.includes("wc_")||l.includes("wallet_connect")){const u=await t.getItem(c);await e.setItem(c,u),o.push(c)}}await e.setItem(i,Ef),r(e),d1(t,o)},d1=async(t,e)=>{e.length&&e.forEach(async r=>{await t.removeItem(r)})};class l1{constructor(){this.initialized=!1,this.setInitialized=r=>{this.storage=r,this.initialized=!0};const e=new f1;this.storage=e;try{const r=new o1;u1(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)})}}var oe={};/*! *****************************************************************************
|
1
|
+
(function(Bt,Kt){typeof exports=="object"&&typeof module<"u"?Kt(exports):typeof define=="function"&&define.amd?define(["exports"],Kt):(Bt=typeof globalThis<"u"?globalThis:Bt||self,Kt(Bt["@reown/walletkit"]={}))})(this,function(Bt){"use strict";var Kt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function co(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 qt={exports:{}},An=typeof Reflect=="object"?Reflect:null,of=An&&typeof An.apply=="function"?An.apply:function(e,r,i){return Function.prototype.apply.call(e,r,i)},Ys;An&&typeof An.ownKeys=="function"?Ys=An.ownKeys:Object.getOwnPropertySymbols?Ys=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Ys=function(e){return Object.getOwnPropertyNames(e)};function Dl(t){console&&console.warn&&console.warn(t)}var cf=Number.isNaN||function(e){return e!==e};function st(){st.init.call(this)}qt.exports=st,qt.exports.once=Pl,st.EventEmitter=st,st.prototype._events=void 0,st.prototype._eventsCount=0,st.prototype._maxListeners=void 0;var ff=10;function Js(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(st,"defaultMaxListeners",{enumerable:!0,get:function(){return ff},set:function(t){if(typeof t!="number"||t<0||cf(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");ff=t}}),st.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},st.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||cf(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 hf(t){return t._maxListeners===void 0?st.defaultMaxListeners:t._maxListeners}st.prototype.getMaxListeners=function(){return hf(this)},st.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 c=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw c.context=o,c}var l=s[e];if(l===void 0)return!1;if(typeof l=="function")of(l,this,r);else for(var u=l.length,b=gf(l,u),i=0;i<u;++i)of(b[i],this,r);return!0};function uf(t,e,r,i){var n,s,o;if(Js(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=hf(t),n>0&&o.length>n&&!o.warned){o.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=o.length,Dl(c)}return t}st.prototype.addListener=function(e,r){return uf(this,e,r,!1)},st.prototype.on=st.prototype.addListener,st.prototype.prependListener=function(e,r){return uf(this,e,r,!0)};function Ol(){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 df(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},n=Ol.bind(i);return n.listener=r,i.wrapFn=n,n}st.prototype.once=function(e,r){return Js(r),this.on(e,df(this,e,r)),this},st.prototype.prependOnceListener=function(e,r){return Js(r),this.prependListener(e,df(this,e,r)),this},st.prototype.removeListener=function(e,r){var i,n,s,o,c;if(Js(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){c=i[o].listener,s=o;break}if(s<0)return this;s===0?i.shift():Rl(i,s),i.length===1&&(n[e]=i[0]),n.removeListener!==void 0&&this.emit("removeListener",e,c||r)}return this},st.prototype.off=st.prototype.removeListener,st.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 lf(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?Nl(n):gf(n,n.length)}st.prototype.listeners=function(e){return lf(this,e,!0)},st.prototype.rawListeners=function(e){return lf(this,e,!1)},st.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):pf.call(t,e)},st.prototype.listenerCount=pf;function pf(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}st.prototype.eventNames=function(){return this._eventsCount>0?Ys(this._events):[]};function gf(t,e){for(var r=new Array(e),i=0;i<e;++i)r[i]=t[i];return r}function Rl(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function Nl(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function Pl(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))}bf(t,e,s,{once:!0}),e!=="error"&&Tl(t,n,{once:!0})})}function Tl(t,e,r){typeof t.on=="function"&&bf(t,"error",e,r)}function bf(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 vf="wc",Cl=2,fo="WalletKit",Fl=`${vf}@2:${fo}:`,Ll={database:":memory:"},Bl="request";var oe={};/*! *****************************************************************************
|
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,23 @@
|
|
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 po=function(t,e){return po=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])},po(t,e)};function p1(t,e){po(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var go=function(){return go=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},go.apply(this,arguments)};function g1(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 b1(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 c=t.length-1;c>=0;c--)(o=t[c])&&(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 v1(t,e){return function(r,i){e(r,i,t)}}function m1(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function y1(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 c(b){try{u(i.next(b))}catch(m){o(m)}}function l(b){try{u(i.throw(b))}catch(m){o(m)}}function u(b){b.done?s(b.value):n(b.value).then(c,l)}u((i=i.apply(t,e||[])).next())})}function w1(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:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(u){return function(b){return l([u,b])}}function l(u){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,n&&(s=u[0]&2?n.return:u[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,u[1])).done)return s;switch(n=0,s&&(u=[u[0]&2,s.value]),u[0]){case 0:case 1:s=u;break;case 4:return r.label++,{value:u[1],done:!1};case 5:r.label++,n=u[1],u=[0];continue;case 7:u=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){r=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]<s[3])){r.label=u[1];break}if(u[0]===6&&r.label<s[1]){r.label=s[1],s=u;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(u);break}s[2]&&r.ops.pop(),r.trys.pop();continue}u=e.call(t,r)}catch(b){u=[6,b],n=0}finally{i=s=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function _1(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}function A1(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function bo(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 xf(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(c){o={error:c}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function E1(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(xf(arguments[e]));return t}function x1(){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,c=s.length;o<c;o++,n++)i[n]=s[o];return i}function ss(t){return this instanceof ss?(this.v=t,this):new ss(t)}function S1(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(S){return new Promise(function(I,F){s.push([M,S,I,F])>1||c(M,S)})})}function c(M,S){try{l(i[M](S))}catch(I){m(s[0][3],I)}}function l(M){M.value instanceof ss?Promise.resolve(M.value.v).then(u,b):m(s[0][2],M)}function u(M){c("next",M)}function b(M){c("throw",M)}function m(M,S){M(S),s.shift(),s.length&&c(s[0][0],s[0][1])}}function M1(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:ss(t[n](o)),done:n==="return"}:s?s(o):o}:s}}function I1(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 bo=="function"?bo(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(c,l){o=t[s](o),n(c,l,o.done,o.value)})}}function n(s,o,c,l){Promise.resolve(l).then(function(u){s({value:u,done:c})},o)}}function D1(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function O1(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 R1(t){return t&&t.__esModule?t:{default:t}}function N1(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function P1(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 T1=Object.freeze({__proto__:null,__extends:p1,get __assign(){return go},__rest:g1,__decorate:b1,__param:v1,__metadata:m1,__awaiter:y1,__generator:w1,__createBinding:_1,__exportStar:A1,__values:bo,__read:xf,__spread:E1,__spreadArrays:x1,__await:ss,__asyncGenerator:S1,__asyncDelegator:M1,__asyncValues:I1,__makeTemplateObject:D1,__importStar:O1,__importDefault:R1,__classPrivateFieldGet:N1,__classPrivateFieldSet:P1}),ta=co(T1),vo={},as={},Sf;function C1(){if(Sf)return as;Sf=1,Object.defineProperty(as,"__esModule",{value:!0}),as.delay=void 0;function t(e){return new Promise(r=>{setTimeout(()=>{r(!0)},e)})}return as.delay=t,as}var Ji={},mo={},Qi={},Mf;function F1(){return Mf||(Mf=1,Object.defineProperty(Qi,"__esModule",{value:!0}),Qi.ONE_THOUSAND=Qi.ONE_HUNDRED=void 0,Qi.ONE_HUNDRED=100,Qi.ONE_THOUSAND=1e3),Qi}var yo={},If;function L1(){return If||(If=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}(yo)),yo}var Df;function Of(){return Df||(Df=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=ta;e.__exportStar(F1(),t),e.__exportStar(L1(),t)}(mo)),mo}var Rf;function B1(){if(Rf)return Ji;Rf=1,Object.defineProperty(Ji,"__esModule",{value:!0}),Ji.fromMiliseconds=Ji.toMiliseconds=void 0;const t=Of();function e(i){return i*t.ONE_THOUSAND}Ji.toMiliseconds=e;function r(i){return Math.floor(i/t.ONE_THOUSAND)}return Ji.fromMiliseconds=r,Ji}var Nf;function q1(){return Nf||(Nf=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=ta;e.__exportStar(C1(),t),e.__exportStar(B1(),t)}(vo)),vo}var En={},Pf;function U1(){if(Pf)return En;Pf=1,Object.defineProperty(En,"__esModule",{value:!0}),En.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 En.Watch=t,En.default=t,En}var wo={},os={},Tf;function z1(){if(Tf)return os;Tf=1,Object.defineProperty(os,"__esModule",{value:!0}),os.IWatch=void 0;class t{}return os.IWatch=t,os}var Cf;function k1(){return Cf||(Cf=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),ta.__exportStar(z1(),t)}(wo)),wo}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=ta;e.__exportStar(q1(),t),e.__exportStar(U1(),t),e.__exportStar(k1(),t),e.__exportStar(Of(),t)})(oe);class Xi{}class $1 extends Xi{constructor(e){super()}}const Ff=oe.FIVE_SECONDS,xn={pulse:"heartbeat_pulse"};class _o extends $1{constructor(e){super(e),this.events=new qt.exports.EventEmitter,this.interval=Ff,this.interval=e?.interval||Ff}static async init(e){const r=new _o(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(),oe.toMiliseconds(this.interval))}pulse(){this.events.emit(xn.pulse)}}function j1(t){try{return JSON.stringify(t)}catch{return'"[Circular]"'}}var K1=H1;function H1(t,e,r){var i=r&&r.stringify||j1,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 c=1;c<s;c++)o[c]=i(e[c]);return o.join(" ")}if(typeof t!="string")return t;var l=e.length;if(l===0)return t;for(var u="",b=1-n,m=-1,M=t&&t.length||0,S=0;S<M;){if(t.charCodeAt(S)===37&&S+1<M){switch(m=m>-1?m:0,t.charCodeAt(S+1)){case 100:case 102:if(b>=l||e[b]==null)break;m<S&&(u+=t.slice(m,S)),u+=Number(e[b]),m=S+2,S++;break;case 105:if(b>=l||e[b]==null)break;m<S&&(u+=t.slice(m,S)),u+=Math.floor(Number(e[b])),m=S+2,S++;break;case 79:case 111:case 106:if(b>=l||e[b]===void 0)break;m<S&&(u+=t.slice(m,S));var I=typeof e[b];if(I==="string"){u+="'"+e[b]+"'",m=S+2,S++;break}if(I==="function"){u+=e[b].name||"<anonymous>",m=S+2,S++;break}u+=i(e[b]),m=S+2,S++;break;case 115:if(b>=l)break;m<S&&(u+=t.slice(m,S)),u+=String(e[b]),m=S+2,S++;break;case 37:m<S&&(u+=t.slice(m,S)),u+="%",m=S+2,S++,b--;break}++b}++S}return m===-1?t:(m<M&&(u+=t.slice(m)),u)}const Lf=K1;var hi=qr;const cs=tp().console||{},V1={mapHttpRequest:ia,mapHttpResponse:ia,wrapRequestSerializer:Eo,wrapResponseSerializer:Eo,wrapErrorSerializer:Eo,req:ia,res:ia,err:Q1};function G1(t,e){return Array.isArray(t)?t.filter(function(i){return i!=="!stdSerializers.err"}):t===!0?Object.keys(e):!1}function qr(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||cs;t.browser.write&&(t.browser.asObject=!0);const i=t.serializers||{},n=G1(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 c=t.level||"info",l=Object.create(r);l.log||(l.log=fs),Object.defineProperty(l,"levelVal",{get:b}),Object.defineProperty(l,"level",{get:m,set:M});const u={transmit:e,serialize:n,asObject:t.browser.asObject,levels:o,timestamp:X1(t)};l.levels=qr.levels,l.level=c,l.setMaxListeners=l.getMaxListeners=l.emit=l.addListener=l.on=l.prependListener=l.once=l.prependOnceListener=l.removeListener=l.removeAllListeners=l.listeners=l.listenerCount=l.eventNames=l.write=l.flush=fs,l.serializers=i,l._serialize=n,l._stdErrSerialize=s,l.child=S,e&&(l._logEvent=Ao());function b(){return this.level==="silent"?1/0:this.levels.values[this.level]}function m(){return this._level}function M(I){if(I!=="silent"&&!this.levels.values[I])throw Error("unknown level "+I);this._level=I,Sn(u,l,"error","log"),Sn(u,l,"fatal","error"),Sn(u,l,"warn","error"),Sn(u,l,"info","log"),Sn(u,l,"debug","log"),Sn(u,l,"trace","log")}function S(I,F){if(!I)throw new Error("missing bindings for child Pino");F=F||{},n&&I.serializers&&(F.serializers=I.serializers);const k=F.serializers;if(n&&k){var j=Object.assign({},i,k),C=t.browser.serialize===!0?Object.keys(j):n;delete I.serializers,ra([I],C,j,this._stdErrSerialize)}function $(P){this._childLevel=(P._childLevel|0)+1,this.error=Mn(P,I,"error"),this.fatal=Mn(P,I,"fatal"),this.warn=Mn(P,I,"warn"),this.info=Mn(P,I,"info"),this.debug=Mn(P,I,"debug"),this.trace=Mn(P,I,"trace"),j&&(this.serializers=j,this._serialize=C),e&&(this._logEvent=Ao([].concat(P._logEvent.bindings,I)))}return $.prototype=this,new $(this)}return l}qr.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"}},qr.stdSerializers=V1,qr.stdTimeFunctions=Object.assign({},{nullTime:Bf,epochTime:qf,unixTime:Z1,isoTime:ep});function Sn(t,e,r,i){const n=Object.getPrototypeOf(e);e[r]=e.levelVal>e.levels.values[r]?fs:n[r]?n[r]:cs[r]||cs[i]||fs,W1(t,e,r)}function W1(t,e,r){!t.transmit&&e[r]===fs||(e[r]=function(i){return function(){const s=t.timestamp(),o=new Array(arguments.length),c=Object.getPrototypeOf&&Object.getPrototypeOf(this)===cs?cs:this;for(var l=0;l<o.length;l++)o[l]=arguments[l];if(t.serialize&&!t.asObject&&ra(o,this._serialize,this.serializers,this._stdErrSerialize),t.asObject?i.call(c,Y1(this,r,o,s)):i.apply(c,o),t.transmit){const u=t.transmit.level||e.level,b=qr.levels.values[u],m=qr.levels.values[r];if(m<b)return;J1(this,{ts:s,methodLevel:r,methodValue:m,transmitLevel:u,transmitValue:qr.levels.values[t.transmit.level||e.level],send:t.transmit.send,val:e.levelVal},o)}}}(e[r]))}function Y1(t,e,r,i){t._serialize&&ra(r,t._serialize,t.serializers,t._stdErrSerialize);const n=r.slice();let s=n[0];const o={};i&&(o.time=i),o.level=qr.levels.values[e];let c=(t._childLevel|0)+1;if(c<1&&(c=1),s!==null&&typeof s=="object"){for(;c--&&typeof n[0]=="object";)Object.assign(o,n.shift());s=n.length?Lf(n.shift(),n):void 0}else typeof s=="string"&&(s=Lf(n.shift(),n));return s!==void 0&&(o.msg=s),o}function ra(t,e,r,i){for(const n in t)if(i&&t[n]instanceof Error)t[n]=qr.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 Mn(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 J1(t,e,r){const i=e.send,n=e.ts,s=e.methodLevel,o=e.methodValue,c=e.val,l=t._logEvent.bindings;ra(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(u){return l.indexOf(u)===-1}),t._logEvent.level.label=s,t._logEvent.level.value=o,i(s,t._logEvent,c),t._logEvent=Ao(l)}function Ao(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 X1(t){return typeof t.timestamp=="function"?t.timestamp:t.timestamp===!1?Bf:qf}function ia(){return{}}function Eo(t){return t}function fs(){}function Bf(){return!1}function qf(){return Date.now()}function Z1(){return Math.round(Date.now()/1e3)}function ep(){return new Date(Date.now()).toISOString()}function tp(){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 rp={level:"info"},hs="custom_context",xo=1e3*1024;class ip{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 Uf{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){const r=new ip(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 zf{constructor(e,r=xo){this.level=e??"error",this.levelValue=hi.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=r,this.logs=new Uf(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,r){r===hi.levels.values.error?console.error(e):r===hi.levels.values.warn?console.warn(e):r===hi.levels.values.debug?console.debug(e):r===hi.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(Yi({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 Uf(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const r=this.getLogArray();return r.push(Yi({extraMetadata:e})),new Blob(r,{type:"application/json"})}}class np{constructor(e,r=xo){this.baseChunkLogger=new zf(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 sp{constructor(e,r=xo){this.baseChunkLogger=new zf(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 ap=Object.defineProperty,op=Object.defineProperties,cp=Object.getOwnPropertyDescriptors,kf=Object.getOwnPropertySymbols,fp=Object.prototype.hasOwnProperty,hp=Object.prototype.propertyIsEnumerable,$f=(t,e,r)=>e in t?ap(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,na=(t,e)=>{for(var r in e||(e={}))fp.call(e,r)&&$f(t,r,e[r]);if(kf)for(var r of kf(e))hp.call(e,r)&&$f(t,r,e[r]);return t},sa=(t,e)=>op(t,cp(e));function So(t){return sa(na({},t),{level:t?.level||rp.level})}function up(t,e=hs){return t[e]||""}function dp(t,e,r=hs){return t[r]=e,t}function Xt(t,e=hs){let r="";return typeof t.bindings>"u"?r=up(t,e):r=t.bindings().context||"",r}function lp(t,e,r=hs){const i=Xt(t,r);return i.trim()?`${i}/${e}`:e}function Ht(t,e,r=hs){const i=lp(t,e,r),n=t.child({context:i});return dp(n,i,r)}function pp(t){var e,r;const i=new np((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:hi(sa(na({},t.opts),{level:"trace",browser:sa(na({},(r=t.opts)==null?void 0:r.browser),{write:n=>i.write(n)})})),chunkLoggerController:i}}function gp(t){var e;const r=new sp((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:hi(sa(na({},t.opts),{level:"trace"})),chunkLoggerController:r}}function bp(t){return typeof t.loggerOverride<"u"&&typeof t.loggerOverride!="string"?{logger:t.loggerOverride,chunkLoggerController:null}:typeof window<"u"?pp(t):gp(t)}class vp extends Xi{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}class mp extends Xi{constructor(e,r){super(),this.core=e,this.logger=r,this.records=new Map}}class yp{constructor(e,r){this.logger=e,this.core=r}}class wp extends Xi{constructor(e,r){super(),this.relayer=e,this.logger=r}}class _p extends Xi{constructor(e){super()}}class Ap{constructor(e,r,i,n){this.core=e,this.logger=r,this.name=i}}class Ep extends Xi{constructor(e,r){super(),this.relayer=e,this.logger=r}}class xp extends Xi{constructor(e,r){super(),this.core=e,this.logger=r}}class Sp{constructor(e,r,i){this.core=e,this.logger=r,this.store=i}}class Mp{constructor(e,r){this.projectId=e,this.logger=r}}class Ip{constructor(e,r,i){this.core=e,this.logger=r,this.telemetryEnabled=i}}class Dp{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}class Op{constructor(e){this.client=e}}var Mo={},Ci={},aa={},oa={};Object.defineProperty(oa,"__esModule",{value:!0}),oa.BrowserRandomSource=void 0;const jf=65536;class Rp{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const e=typeof self<"u"?self.crypto||self.msCrypto:null;e&&e.getRandomValues!==void 0&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");const r=new Uint8Array(e);for(let i=0;i<r.length;i+=jf)this._crypto.getRandomValues(r.subarray(i,i+Math.min(r.length-i,jf)));return r}}oa.BrowserRandomSource=Rp;function Np(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ca={},fr={};Object.defineProperty(fr,"__esModule",{value:!0});function Pp(t){for(var e=0;e<t.length;e++)t[e]=0;return t}fr.wipe=Pp;var Tp={},Cp=Object.freeze({__proto__:null,default:Tp}),Io=co(Cp);Object.defineProperty(ca,"__esModule",{value:!0}),ca.NodeRandomSource=void 0;const Fp=fr;class Lp{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof Np<"u"){const e=Io;e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let r=this._crypto.randomBytes(e);if(r.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");const i=new Uint8Array(e);for(let n=0;n<i.length;n++)i[n]=r[n];return(0,Fp.wipe)(r),i}}ca.NodeRandomSource=Lp,Object.defineProperty(aa,"__esModule",{value:!0}),aa.SystemRandomSource=void 0;const Bp=oa,qp=ca;class Up{constructor(){if(this.isAvailable=!1,this.name="",this._source=new Bp.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new qp.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}}aa.SystemRandomSource=Up;var Ke={},Kf={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});function e(c,l){var u=c>>>16&65535,b=c&65535,m=l>>>16&65535,M=l&65535;return b*M+(u*M+b*m<<16>>>0)|0}t.mul=Math.imul||e;function r(c,l){return c+l|0}t.add=r;function i(c,l){return c-l|0}t.sub=i;function n(c,l){return c<<l|c>>>32-l}t.rotl=n;function s(c,l){return c<<32-l|c>>>l}t.rotr=s;function o(c){return typeof c=="number"&&isFinite(c)&&Math.floor(c)===c}t.isInteger=Number.isInteger||o,t.MAX_SAFE_INTEGER=9007199254740991,t.isSafeInteger=function(c){return t.isInteger(c)&&c>=-t.MAX_SAFE_INTEGER&&c<=t.MAX_SAFE_INTEGER}})(Kf),Object.defineProperty(Ke,"__esModule",{value:!0});var Hf=Kf;function zp(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])<<16>>16}Ke.readInt16BE=zp;function kp(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])>>>0}Ke.readUint16BE=kp;function $p(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])<<16>>16}Ke.readInt16LE=$p;function jp(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])>>>0}Ke.readUint16LE=jp;function Vf(t,e,r){return e===void 0&&(e=new Uint8Array(2)),r===void 0&&(r=0),e[r+0]=t>>>8,e[r+1]=t>>>0,e}Ke.writeUint16BE=Vf,Ke.writeInt16BE=Vf;function Gf(t,e,r){return e===void 0&&(e=new Uint8Array(2)),r===void 0&&(r=0),e[r+0]=t>>>0,e[r+1]=t>>>8,e}Ke.writeUint16LE=Gf,Ke.writeInt16LE=Gf;function Do(t,e){return e===void 0&&(e=0),t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}Ke.readInt32BE=Do;function Oo(t,e){return e===void 0&&(e=0),(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}Ke.readUint32BE=Oo;function Ro(t,e){return e===void 0&&(e=0),t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}Ke.readInt32LE=Ro;function No(t,e){return e===void 0&&(e=0),(t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e])>>>0}Ke.readUint32LE=No;function fa(t,e,r){return e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0),e[r+0]=t>>>24,e[r+1]=t>>>16,e[r+2]=t>>>8,e[r+3]=t>>>0,e}Ke.writeUint32BE=fa,Ke.writeInt32BE=fa;function ha(t,e,r){return e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0),e[r+0]=t>>>0,e[r+1]=t>>>8,e[r+2]=t>>>16,e[r+3]=t>>>24,e}Ke.writeUint32LE=ha,Ke.writeInt32LE=ha;function Kp(t,e){e===void 0&&(e=0);var r=Do(t,e),i=Do(t,e+4);return r*4294967296+i-(i>>31)*4294967296}Ke.readInt64BE=Kp;function Hp(t,e){e===void 0&&(e=0);var r=Oo(t,e),i=Oo(t,e+4);return r*4294967296+i}Ke.readUint64BE=Hp;function Vp(t,e){e===void 0&&(e=0);var r=Ro(t,e),i=Ro(t,e+4);return i*4294967296+r-(r>>31)*4294967296}Ke.readInt64LE=Vp;function Gp(t,e){e===void 0&&(e=0);var r=No(t,e),i=No(t,e+4);return i*4294967296+r}Ke.readUint64LE=Gp;function Wf(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),fa(t/4294967296>>>0,e,r),fa(t>>>0,e,r+4),e}Ke.writeUint64BE=Wf,Ke.writeInt64BE=Wf;function Yf(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),ha(t>>>0,e,r),ha(t/4294967296>>>0,e,r+4),e}Ke.writeUint64LE=Yf,Ke.writeInt64LE=Yf;function Wp(t,e,r){if(r===void 0&&(r=0),t%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(t/8>e.length-r)throw new Error("readUintBE: array is too short for the given bitLength");for(var i=0,n=1,s=t/8+r-1;s>=r;s--)i+=e[s]*n,n*=256;return i}Ke.readUintBE=Wp;function Yp(t,e,r){if(r===void 0&&(r=0),t%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(t/8>e.length-r)throw new Error("readUintLE: array is too short for the given bitLength");for(var i=0,n=1,s=r;s<r+t/8;s++)i+=e[s]*n,n*=256;return i}Ke.readUintLE=Yp;function Jp(t,e,r,i){if(r===void 0&&(r=new Uint8Array(t/8)),i===void 0&&(i=0),t%8!==0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!Hf.isSafeInteger(e))throw new Error("writeUintBE value must be an integer");for(var n=1,s=t/8+i-1;s>=i;s--)r[s]=e/n&255,n*=256;return r}Ke.writeUintBE=Jp;function Qp(t,e,r,i){if(r===void 0&&(r=new Uint8Array(t/8)),i===void 0&&(i=0),t%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!Hf.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var n=1,s=i;s<i+t/8;s++)r[s]=e/n&255,n*=256;return r}Ke.writeUintLE=Qp;function Xp(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat32(e)}Ke.readFloat32BE=Xp;function Zp(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat32(e,!0)}Ke.readFloat32LE=Zp;function eg(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat64(e)}Ke.readFloat64BE=eg;function tg(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat64(e,!0)}Ke.readFloat64LE=tg;function rg(t,e,r){e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat32(r,t),e}Ke.writeFloat32BE=rg;function ig(t,e,r){e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat32(r,t,!0),e}Ke.writeFloat32LE=ig;function ng(t,e,r){e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat64(r,t),e}Ke.writeFloat64BE=ng;function sg(t,e,r){e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat64(r,t,!0),e}Ke.writeFloat64LE=sg,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.randomStringForEntropy=t.randomString=t.randomUint32=t.randomBytes=t.defaultRandomSource=void 0;const e=aa,r=Ke,i=fr;t.defaultRandomSource=new e.SystemRandomSource;function n(u,b=t.defaultRandomSource){return b.randomBytes(u)}t.randomBytes=n;function s(u=t.defaultRandomSource){const b=n(4,u),m=(0,r.readUint32LE)(b);return(0,i.wipe)(b),m}t.randomUint32=s;const o="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function c(u,b=o,m=t.defaultRandomSource){if(b.length<2)throw new Error("randomString charset is too short");if(b.length>256)throw new Error("randomString charset is too long");let M="";const S=b.length,I=256-256%S;for(;u>0;){const F=n(Math.ceil(u*256/I),m);for(let k=0;k<F.length&&u>0;k++){const j=F[k];j<I&&(M+=b.charAt(j%S),u--)}(0,i.wipe)(F)}return M}t.randomString=c;function l(u,b=o,m=t.defaultRandomSource){const M=Math.ceil(u/(Math.log(b.length)/Math.LN2));return c(M,b,m)}t.randomStringForEntropy=l}(Ci);var Jf={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Ke,r=fr;t.DIGEST_LENGTH=64,t.BLOCK_SIZE=128;var i=function(){function c(){this.digestLength=t.DIGEST_LENGTH,this.blockSize=t.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return c.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},c.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},c.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._tempHi),r.wipe(this._tempLo),this.reset()},c.prototype.update=function(l,u){if(u===void 0&&(u=l.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var b=0;if(this._bytesHashed+=u,this._bufferLength>0){for(;this._bufferLength<t.BLOCK_SIZE&&u>0;)this._buffer[this._bufferLength++]=l[b++],u--;this._bufferLength===this.blockSize&&(s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(u>=this.blockSize&&(b=s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,l,b,u),u%=this.blockSize);u>0;)this._buffer[this._bufferLength++]=l[b++],u--;return this},c.prototype.finish=function(l){if(!this._finished){var u=this._bytesHashed,b=this._bufferLength,m=u/536870912|0,M=u<<3,S=u%128<112?128:256;this._buffer[b]=128;for(var I=b+1;I<S-8;I++)this._buffer[I]=0;e.writeUint32BE(m,this._buffer,S-8),e.writeUint32BE(M,this._buffer,S-4),s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,S),this._finished=!0}for(var I=0;I<this.digestLength/8;I++)e.writeUint32BE(this._stateHi[I],l,I*8),e.writeUint32BE(this._stateLo[I],l,I*8+4);return this},c.prototype.digest=function(){var l=new Uint8Array(this.digestLength);return this.finish(l),l},c.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{stateHi:new Int32Array(this._stateHi),stateLo:new Int32Array(this._stateLo),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},c.prototype.restoreState=function(l){return this._stateHi.set(l.stateHi),this._stateLo.set(l.stateLo),this._bufferLength=l.bufferLength,l.buffer&&this._buffer.set(l.buffer),this._bytesHashed=l.bytesHashed,this._finished=!1,this},c.prototype.cleanSavedState=function(l){r.wipe(l.stateHi),r.wipe(l.stateLo),l.buffer&&r.wipe(l.buffer),l.bufferLength=0,l.bytesHashed=0},c}();t.SHA512=i;var n=new Int32Array([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 s(c,l,u,b,m,M,S){for(var I=u[0],F=u[1],k=u[2],j=u[3],C=u[4],$=u[5],P=u[6],B=u[7],U=b[0],y=b[1],O=b[2],Y=b[3],Q=b[4],N=b[5],g=b[6],a=b[7],f,p,w,A,x,_,h,d;S>=128;){for(var D=0;D<16;D++){var K=8*D+M;c[D]=e.readUint32BE(m,K),l[D]=e.readUint32BE(m,K+4)}for(var D=0;D<80;D++){var G=I,E=F,H=k,R=j,L=C,q=$,v=P,T=B,W=U,J=y,X=O,se=Y,ne=Q,Me=N,Ce=g,ue=a;if(f=B,p=a,x=p&65535,_=p>>>16,h=f&65535,d=f>>>16,f=(C>>>14|Q<<32-14)^(C>>>18|Q<<32-18)^(Q>>>41-32|C<<32-(41-32)),p=(Q>>>14|C<<32-14)^(Q>>>18|C<<32-18)^(C>>>41-32|Q<<32-(41-32)),x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,f=C&$^~C&P,p=Q&N^~Q&g,x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,f=n[D*2],p=n[D*2+1],x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,f=c[D%16],p=l[D%16],x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,_+=x>>>16,h+=_>>>16,d+=h>>>16,w=h&65535|d<<16,A=x&65535|_<<16,f=w,p=A,x=p&65535,_=p>>>16,h=f&65535,d=f>>>16,f=(I>>>28|U<<32-28)^(U>>>34-32|I<<32-(34-32))^(U>>>39-32|I<<32-(39-32)),p=(U>>>28|I<<32-28)^(I>>>34-32|U<<32-(34-32))^(I>>>39-32|U<<32-(39-32)),x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,f=I&F^I&k^F&k,p=U&y^U&O^y&O,x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,_+=x>>>16,h+=_>>>16,d+=h>>>16,T=h&65535|d<<16,ue=x&65535|_<<16,f=R,p=se,x=p&65535,_=p>>>16,h=f&65535,d=f>>>16,f=w,p=A,x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,_+=x>>>16,h+=_>>>16,d+=h>>>16,R=h&65535|d<<16,se=x&65535|_<<16,F=G,k=E,j=H,C=R,$=L,P=q,B=v,I=T,y=W,O=J,Y=X,Q=se,N=ne,g=Me,a=Ce,U=ue,D%16===15)for(var K=0;K<16;K++)f=c[K],p=l[K],x=p&65535,_=p>>>16,h=f&65535,d=f>>>16,f=c[(K+9)%16],p=l[(K+9)%16],x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,w=c[(K+1)%16],A=l[(K+1)%16],f=(w>>>1|A<<32-1)^(w>>>8|A<<32-8)^w>>>7,p=(A>>>1|w<<32-1)^(A>>>8|w<<32-8)^(A>>>7|w<<32-7),x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,w=c[(K+14)%16],A=l[(K+14)%16],f=(w>>>19|A<<32-19)^(A>>>61-32|w<<32-(61-32))^w>>>6,p=(A>>>19|w<<32-19)^(w>>>61-32|A<<32-(61-32))^(A>>>6|w<<32-6),x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,_+=x>>>16,h+=_>>>16,d+=h>>>16,c[K]=h&65535|d<<16,l[K]=x&65535|_<<16}f=I,p=U,x=p&65535,_=p>>>16,h=f&65535,d=f>>>16,f=u[0],p=b[0],x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,_+=x>>>16,h+=_>>>16,d+=h>>>16,u[0]=I=h&65535|d<<16,b[0]=U=x&65535|_<<16,f=F,p=y,x=p&65535,_=p>>>16,h=f&65535,d=f>>>16,f=u[1],p=b[1],x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,_+=x>>>16,h+=_>>>16,d+=h>>>16,u[1]=F=h&65535|d<<16,b[1]=y=x&65535|_<<16,f=k,p=O,x=p&65535,_=p>>>16,h=f&65535,d=f>>>16,f=u[2],p=b[2],x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,_+=x>>>16,h+=_>>>16,d+=h>>>16,u[2]=k=h&65535|d<<16,b[2]=O=x&65535|_<<16,f=j,p=Y,x=p&65535,_=p>>>16,h=f&65535,d=f>>>16,f=u[3],p=b[3],x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,_+=x>>>16,h+=_>>>16,d+=h>>>16,u[3]=j=h&65535|d<<16,b[3]=Y=x&65535|_<<16,f=C,p=Q,x=p&65535,_=p>>>16,h=f&65535,d=f>>>16,f=u[4],p=b[4],x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,_+=x>>>16,h+=_>>>16,d+=h>>>16,u[4]=C=h&65535|d<<16,b[4]=Q=x&65535|_<<16,f=$,p=N,x=p&65535,_=p>>>16,h=f&65535,d=f>>>16,f=u[5],p=b[5],x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,_+=x>>>16,h+=_>>>16,d+=h>>>16,u[5]=$=h&65535|d<<16,b[5]=N=x&65535|_<<16,f=P,p=g,x=p&65535,_=p>>>16,h=f&65535,d=f>>>16,f=u[6],p=b[6],x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,_+=x>>>16,h+=_>>>16,d+=h>>>16,u[6]=P=h&65535|d<<16,b[6]=g=x&65535|_<<16,f=B,p=a,x=p&65535,_=p>>>16,h=f&65535,d=f>>>16,f=u[7],p=b[7],x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,_+=x>>>16,h+=_>>>16,d+=h>>>16,u[7]=B=h&65535|d<<16,b[7]=a=x&65535|_<<16,M+=128,S-=128}return M}function o(c){var l=new i;l.update(c);var u=l.digest();return l.clean(),u}t.hash=o})(Jf),function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.convertSecretKeyToX25519=t.convertPublicKeyToX25519=t.verify=t.sign=t.extractPublicKeyFromSecretKey=t.generateKeyPair=t.generateKeyPairFromSeed=t.SEED_LENGTH=t.SECRET_KEY_LENGTH=t.PUBLIC_KEY_LENGTH=t.SIGNATURE_LENGTH=void 0;const e=Ci,r=Jf,i=fr;t.SIGNATURE_LENGTH=64,t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=64,t.SEED_LENGTH=32;function n(R){const L=new Float64Array(16);if(R)for(let q=0;q<R.length;q++)L[q]=R[q];return L}const s=new Uint8Array(32);s[0]=9;const o=n(),c=n([1]),l=n([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),u=n([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),b=n([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),m=n([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),M=n([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function S(R,L){for(let q=0;q<16;q++)R[q]=L[q]|0}function I(R){let L=1;for(let q=0;q<16;q++){let v=R[q]+L+65535;L=Math.floor(v/65536),R[q]=v-L*65536}R[0]+=L-1+37*(L-1)}function F(R,L,q){const v=~(q-1);for(let T=0;T<16;T++){const W=v&(R[T]^L[T]);R[T]^=W,L[T]^=W}}function k(R,L){const q=n(),v=n();for(let T=0;T<16;T++)v[T]=L[T];I(v),I(v),I(v);for(let T=0;T<2;T++){q[0]=v[0]-65517;for(let J=1;J<15;J++)q[J]=v[J]-65535-(q[J-1]>>16&1),q[J-1]&=65535;q[15]=v[15]-32767-(q[14]>>16&1);const W=q[15]>>16&1;q[14]&=65535,F(v,q,1-W)}for(let T=0;T<16;T++)R[2*T]=v[T]&255,R[2*T+1]=v[T]>>8}function j(R,L){let q=0;for(let v=0;v<32;v++)q|=R[v]^L[v];return(1&q-1>>>8)-1}function C(R,L){const q=new Uint8Array(32),v=new Uint8Array(32);return k(q,R),k(v,L),j(q,v)}function $(R){const L=new Uint8Array(32);return k(L,R),L[0]&1}function P(R,L){for(let q=0;q<16;q++)R[q]=L[2*q]+(L[2*q+1]<<8);R[15]&=32767}function B(R,L,q){for(let v=0;v<16;v++)R[v]=L[v]+q[v]}function U(R,L,q){for(let v=0;v<16;v++)R[v]=L[v]-q[v]}function y(R,L,q){let v,T,W=0,J=0,X=0,se=0,ne=0,Me=0,Ce=0,ue=0,xe=0,Ae=0,re=0,ve=0,le=0,ee=0,de=0,fe=0,te=0,Ee=0,he=0,ae=0,Se=0,De=0,ce=0,Ie=0,We=0,Oe=0,Qe=0,He=0,Re=0,tt=0,rt=0,pe=q[0],Pe=q[1],Fe=q[2],ge=q[3],Le=q[4],Te=q[5],ye=q[6],Ue=q[7],ze=q[8],we=q[9],ke=q[10],Be=q[11],be=q[12],Ne=q[13],$e=q[14],_e=q[15];v=L[0],W+=v*pe,J+=v*Pe,X+=v*Fe,se+=v*ge,ne+=v*Le,Me+=v*Te,Ce+=v*ye,ue+=v*Ue,xe+=v*ze,Ae+=v*we,re+=v*ke,ve+=v*Be,le+=v*be,ee+=v*Ne,de+=v*$e,fe+=v*_e,v=L[1],J+=v*pe,X+=v*Pe,se+=v*Fe,ne+=v*ge,Me+=v*Le,Ce+=v*Te,ue+=v*ye,xe+=v*Ue,Ae+=v*ze,re+=v*we,ve+=v*ke,le+=v*Be,ee+=v*be,de+=v*Ne,fe+=v*$e,te+=v*_e,v=L[2],X+=v*pe,se+=v*Pe,ne+=v*Fe,Me+=v*ge,Ce+=v*Le,ue+=v*Te,xe+=v*ye,Ae+=v*Ue,re+=v*ze,ve+=v*we,le+=v*ke,ee+=v*Be,de+=v*be,fe+=v*Ne,te+=v*$e,Ee+=v*_e,v=L[3],se+=v*pe,ne+=v*Pe,Me+=v*Fe,Ce+=v*ge,ue+=v*Le,xe+=v*Te,Ae+=v*ye,re+=v*Ue,ve+=v*ze,le+=v*we,ee+=v*ke,de+=v*Be,fe+=v*be,te+=v*Ne,Ee+=v*$e,he+=v*_e,v=L[4],ne+=v*pe,Me+=v*Pe,Ce+=v*Fe,ue+=v*ge,xe+=v*Le,Ae+=v*Te,re+=v*ye,ve+=v*Ue,le+=v*ze,ee+=v*we,de+=v*ke,fe+=v*Be,te+=v*be,Ee+=v*Ne,he+=v*$e,ae+=v*_e,v=L[5],Me+=v*pe,Ce+=v*Pe,ue+=v*Fe,xe+=v*ge,Ae+=v*Le,re+=v*Te,ve+=v*ye,le+=v*Ue,ee+=v*ze,de+=v*we,fe+=v*ke,te+=v*Be,Ee+=v*be,he+=v*Ne,ae+=v*$e,Se+=v*_e,v=L[6],Ce+=v*pe,ue+=v*Pe,xe+=v*Fe,Ae+=v*ge,re+=v*Le,ve+=v*Te,le+=v*ye,ee+=v*Ue,de+=v*ze,fe+=v*we,te+=v*ke,Ee+=v*Be,he+=v*be,ae+=v*Ne,Se+=v*$e,De+=v*_e,v=L[7],ue+=v*pe,xe+=v*Pe,Ae+=v*Fe,re+=v*ge,ve+=v*Le,le+=v*Te,ee+=v*ye,de+=v*Ue,fe+=v*ze,te+=v*we,Ee+=v*ke,he+=v*Be,ae+=v*be,Se+=v*Ne,De+=v*$e,ce+=v*_e,v=L[8],xe+=v*pe,Ae+=v*Pe,re+=v*Fe,ve+=v*ge,le+=v*Le,ee+=v*Te,de+=v*ye,fe+=v*Ue,te+=v*ze,Ee+=v*we,he+=v*ke,ae+=v*Be,Se+=v*be,De+=v*Ne,ce+=v*$e,Ie+=v*_e,v=L[9],Ae+=v*pe,re+=v*Pe,ve+=v*Fe,le+=v*ge,ee+=v*Le,de+=v*Te,fe+=v*ye,te+=v*Ue,Ee+=v*ze,he+=v*we,ae+=v*ke,Se+=v*Be,De+=v*be,ce+=v*Ne,Ie+=v*$e,We+=v*_e,v=L[10],re+=v*pe,ve+=v*Pe,le+=v*Fe,ee+=v*ge,de+=v*Le,fe+=v*Te,te+=v*ye,Ee+=v*Ue,he+=v*ze,ae+=v*we,Se+=v*ke,De+=v*Be,ce+=v*be,Ie+=v*Ne,We+=v*$e,Oe+=v*_e,v=L[11],ve+=v*pe,le+=v*Pe,ee+=v*Fe,de+=v*ge,fe+=v*Le,te+=v*Te,Ee+=v*ye,he+=v*Ue,ae+=v*ze,Se+=v*we,De+=v*ke,ce+=v*Be,Ie+=v*be,We+=v*Ne,Oe+=v*$e,Qe+=v*_e,v=L[12],le+=v*pe,ee+=v*Pe,de+=v*Fe,fe+=v*ge,te+=v*Le,Ee+=v*Te,he+=v*ye,ae+=v*Ue,Se+=v*ze,De+=v*we,ce+=v*ke,Ie+=v*Be,We+=v*be,Oe+=v*Ne,Qe+=v*$e,He+=v*_e,v=L[13],ee+=v*pe,de+=v*Pe,fe+=v*Fe,te+=v*ge,Ee+=v*Le,he+=v*Te,ae+=v*ye,Se+=v*Ue,De+=v*ze,ce+=v*we,Ie+=v*ke,We+=v*Be,Oe+=v*be,Qe+=v*Ne,He+=v*$e,Re+=v*_e,v=L[14],de+=v*pe,fe+=v*Pe,te+=v*Fe,Ee+=v*ge,he+=v*Le,ae+=v*Te,Se+=v*ye,De+=v*Ue,ce+=v*ze,Ie+=v*we,We+=v*ke,Oe+=v*Be,Qe+=v*be,He+=v*Ne,Re+=v*$e,tt+=v*_e,v=L[15],fe+=v*pe,te+=v*Pe,Ee+=v*Fe,he+=v*ge,ae+=v*Le,Se+=v*Te,De+=v*ye,ce+=v*Ue,Ie+=v*ze,We+=v*we,Oe+=v*ke,Qe+=v*Be,He+=v*be,Re+=v*Ne,tt+=v*$e,rt+=v*_e,W+=38*te,J+=38*Ee,X+=38*he,se+=38*ae,ne+=38*Se,Me+=38*De,Ce+=38*ce,ue+=38*Ie,xe+=38*We,Ae+=38*Oe,re+=38*Qe,ve+=38*He,le+=38*Re,ee+=38*tt,de+=38*rt,T=1,v=W+T+65535,T=Math.floor(v/65536),W=v-T*65536,v=J+T+65535,T=Math.floor(v/65536),J=v-T*65536,v=X+T+65535,T=Math.floor(v/65536),X=v-T*65536,v=se+T+65535,T=Math.floor(v/65536),se=v-T*65536,v=ne+T+65535,T=Math.floor(v/65536),ne=v-T*65536,v=Me+T+65535,T=Math.floor(v/65536),Me=v-T*65536,v=Ce+T+65535,T=Math.floor(v/65536),Ce=v-T*65536,v=ue+T+65535,T=Math.floor(v/65536),ue=v-T*65536,v=xe+T+65535,T=Math.floor(v/65536),xe=v-T*65536,v=Ae+T+65535,T=Math.floor(v/65536),Ae=v-T*65536,v=re+T+65535,T=Math.floor(v/65536),re=v-T*65536,v=ve+T+65535,T=Math.floor(v/65536),ve=v-T*65536,v=le+T+65535,T=Math.floor(v/65536),le=v-T*65536,v=ee+T+65535,T=Math.floor(v/65536),ee=v-T*65536,v=de+T+65535,T=Math.floor(v/65536),de=v-T*65536,v=fe+T+65535,T=Math.floor(v/65536),fe=v-T*65536,W+=T-1+37*(T-1),T=1,v=W+T+65535,T=Math.floor(v/65536),W=v-T*65536,v=J+T+65535,T=Math.floor(v/65536),J=v-T*65536,v=X+T+65535,T=Math.floor(v/65536),X=v-T*65536,v=se+T+65535,T=Math.floor(v/65536),se=v-T*65536,v=ne+T+65535,T=Math.floor(v/65536),ne=v-T*65536,v=Me+T+65535,T=Math.floor(v/65536),Me=v-T*65536,v=Ce+T+65535,T=Math.floor(v/65536),Ce=v-T*65536,v=ue+T+65535,T=Math.floor(v/65536),ue=v-T*65536,v=xe+T+65535,T=Math.floor(v/65536),xe=v-T*65536,v=Ae+T+65535,T=Math.floor(v/65536),Ae=v-T*65536,v=re+T+65535,T=Math.floor(v/65536),re=v-T*65536,v=ve+T+65535,T=Math.floor(v/65536),ve=v-T*65536,v=le+T+65535,T=Math.floor(v/65536),le=v-T*65536,v=ee+T+65535,T=Math.floor(v/65536),ee=v-T*65536,v=de+T+65535,T=Math.floor(v/65536),de=v-T*65536,v=fe+T+65535,T=Math.floor(v/65536),fe=v-T*65536,W+=T-1+37*(T-1),R[0]=W,R[1]=J,R[2]=X,R[3]=se,R[4]=ne,R[5]=Me,R[6]=Ce,R[7]=ue,R[8]=xe,R[9]=Ae,R[10]=re,R[11]=ve,R[12]=le,R[13]=ee,R[14]=de,R[15]=fe}function O(R,L){y(R,L,L)}function Y(R,L){const q=n();let v;for(v=0;v<16;v++)q[v]=L[v];for(v=253;v>=0;v--)O(q,q),v!==2&&v!==4&&y(q,q,L);for(v=0;v<16;v++)R[v]=q[v]}function Q(R,L){const q=n();let v;for(v=0;v<16;v++)q[v]=L[v];for(v=250;v>=0;v--)O(q,q),v!==1&&y(q,q,L);for(v=0;v<16;v++)R[v]=q[v]}function N(R,L){const q=n(),v=n(),T=n(),W=n(),J=n(),X=n(),se=n(),ne=n(),Me=n();U(q,R[1],R[0]),U(Me,L[1],L[0]),y(q,q,Me),B(v,R[0],R[1]),B(Me,L[0],L[1]),y(v,v,Me),y(T,R[3],L[3]),y(T,T,u),y(W,R[2],L[2]),B(W,W,W),U(J,v,q),U(X,W,T),B(se,W,T),B(ne,v,q),y(R[0],J,X),y(R[1],ne,se),y(R[2],se,X),y(R[3],J,ne)}function g(R,L,q){for(let v=0;v<4;v++)F(R[v],L[v],q)}function a(R,L){const q=n(),v=n(),T=n();Y(T,L[2]),y(q,L[0],T),y(v,L[1],T),k(R,v),R[31]^=$(q)<<7}function f(R,L,q){S(R[0],o),S(R[1],c),S(R[2],c),S(R[3],o);for(let v=255;v>=0;--v){const T=q[v/8|0]>>(v&7)&1;g(R,L,T),N(L,R),N(R,R),g(R,L,T)}}function p(R,L){const q=[n(),n(),n(),n()];S(q[0],b),S(q[1],m),S(q[2],c),y(q[3],b,m),f(R,q,L)}function w(R){if(R.length!==t.SEED_LENGTH)throw new Error(`ed25519: seed must be ${t.SEED_LENGTH} bytes`);const L=(0,r.hash)(R);L[0]&=248,L[31]&=127,L[31]|=64;const q=new Uint8Array(32),v=[n(),n(),n(),n()];p(v,L),a(q,v);const T=new Uint8Array(64);return T.set(R),T.set(q,32),{publicKey:q,secretKey:T}}t.generateKeyPairFromSeed=w;function A(R){const L=(0,e.randomBytes)(32,R),q=w(L);return(0,i.wipe)(L),q}t.generateKeyPair=A;function x(R){if(R.length!==t.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${t.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(R.subarray(32))}t.extractPublicKeyFromSecretKey=x;const _=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function h(R,L){let q,v,T,W;for(v=63;v>=32;--v){for(q=0,T=v-32,W=v-12;T<W;++T)L[T]+=q-16*L[v]*_[T-(v-32)],q=Math.floor((L[T]+128)/256),L[T]-=q*256;L[T]+=q,L[v]=0}for(q=0,T=0;T<32;T++)L[T]+=q-(L[31]>>4)*_[T],q=L[T]>>8,L[T]&=255;for(T=0;T<32;T++)L[T]-=q*_[T];for(v=0;v<32;v++)L[v+1]+=L[v]>>8,R[v]=L[v]&255}function d(R){const L=new Float64Array(64);for(let q=0;q<64;q++)L[q]=R[q];for(let q=0;q<64;q++)R[q]=0;h(R,L)}function D(R,L){const q=new Float64Array(64),v=[n(),n(),n(),n()],T=(0,r.hash)(R.subarray(0,32));T[0]&=248,T[31]&=127,T[31]|=64;const W=new Uint8Array(64);W.set(T.subarray(32),32);const J=new r.SHA512;J.update(W.subarray(32)),J.update(L);const X=J.digest();J.clean(),d(X),p(v,X),a(W,v),J.reset(),J.update(W.subarray(0,32)),J.update(R.subarray(32)),J.update(L);const se=J.digest();d(se);for(let ne=0;ne<32;ne++)q[ne]=X[ne];for(let ne=0;ne<32;ne++)for(let Me=0;Me<32;Me++)q[ne+Me]+=se[ne]*T[Me];return h(W.subarray(32),q),W}t.sign=D;function K(R,L){const q=n(),v=n(),T=n(),W=n(),J=n(),X=n(),se=n();return S(R[2],c),P(R[1],L),O(T,R[1]),y(W,T,l),U(T,T,R[2]),B(W,R[2],W),O(J,W),O(X,J),y(se,X,J),y(q,se,T),y(q,q,W),Q(q,q),y(q,q,T),y(q,q,W),y(q,q,W),y(R[0],q,W),O(v,R[0]),y(v,v,W),C(v,T)&&y(R[0],R[0],M),O(v,R[0]),y(v,v,W),C(v,T)?-1:($(R[0])===L[31]>>7&&U(R[0],o,R[0]),y(R[3],R[0],R[1]),0)}function G(R,L,q){const v=new Uint8Array(32),T=[n(),n(),n(),n()],W=[n(),n(),n(),n()];if(q.length!==t.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${t.SIGNATURE_LENGTH} bytes`);if(K(W,R))return!1;const J=new r.SHA512;J.update(q.subarray(0,32)),J.update(R),J.update(L);const X=J.digest();return d(X),f(T,W,X),p(W,q.subarray(32)),N(T,W),a(v,T),!j(q,v)}t.verify=G;function E(R){let L=[n(),n(),n(),n()];if(K(L,R))throw new Error("Ed25519: invalid public key");let q=n(),v=n(),T=L[1];B(q,c,T),U(v,c,T),Y(v,v),y(q,q,v);let W=new Uint8Array(32);return k(W,q),W}t.convertPublicKeyToX25519=E;function H(R){const L=(0,r.hash)(R.subarray(0,32));L[0]&=248,L[31]&=127,L[31]|=64;const q=new Uint8Array(L.subarray(0,32));return(0,i.wipe)(L),q}t.convertSecretKeyToX25519=H}(Mo);const ag="EdDSA",og="JWT",ua=".",da="base64url",Qf="utf8",Xf="utf8",cg=":",fg="did",hg="key",Zf="base58btc",ug="z",dg="K36",lg=32;function eh(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function la(t,e){e||(e=t.reduce((n,s)=>n+s.length,0));const r=eh(e);let i=0;for(const n of t)r.set(n,i),i+=n.length;return r}function pg(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 c=t.length,l=t.charAt(0),u=Math.log(c)/Math.log(256),b=Math.log(256)/Math.log(c);function m(I){if(I instanceof Uint8Array||(ArrayBuffer.isView(I)?I=new Uint8Array(I.buffer,I.byteOffset,I.byteLength):Array.isArray(I)&&(I=Uint8Array.from(I))),!(I instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(I.length===0)return"";for(var F=0,k=0,j=0,C=I.length;j!==C&&I[j]===0;)j++,F++;for(var $=(C-j)*b+1>>>0,P=new Uint8Array($);j!==C;){for(var B=I[j],U=0,y=$-1;(B!==0||U<k)&&y!==-1;y--,U++)B+=256*P[y]>>>0,P[y]=B%c>>>0,B=B/c>>>0;if(B!==0)throw new Error("Non-zero carry");k=U,j++}for(var O=$-k;O!==$&&P[O]===0;)O++;for(var Y=l.repeat(F);O<$;++O)Y+=t.charAt(P[O]);return Y}function M(I){if(typeof I!="string")throw new TypeError("Expected String");if(I.length===0)return new Uint8Array;var F=0;if(I[F]!==" "){for(var k=0,j=0;I[F]===l;)k++,F++;for(var C=(I.length-F)*u+1>>>0,$=new Uint8Array(C);I[F];){var P=r[I.charCodeAt(F)];if(P===255)return;for(var B=0,U=C-1;(P!==0||B<j)&&U!==-1;U--,B++)P+=c*$[U]>>>0,$[U]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");j=B,F++}if(I[F]!==" "){for(var y=C-j;y!==C&&$[y]===0;)y++;for(var O=new Uint8Array(k+(C-y)),Y=k;y!==C;)O[Y++]=$[y++];return O}}}function S(I){var F=M(I);if(F)return F;throw new Error(`Non-${e} character`)}return{encode:m,decodeUnsafe:M,decode:S}}var gg=pg,bg=gg;const th=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")},vg=t=>new TextEncoder().encode(t),mg=t=>new TextDecoder().decode(t);class yg{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 wg{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 rh(this,e)}}class _g{constructor(e){this.decoders=e}or(e){return rh(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 rh=(t,e)=>new _g({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class Ag{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new yg(e,r,i),this.decoder=new wg(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const pa=({name:t,prefix:e,encode:r,decode:i})=>new Ag(t,e,r,i),us=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=bg(r,e);return pa({prefix:t,name:e,encode:i,decode:s=>th(n(s))})},Eg=(t,e,r,i)=>{const n={};for(let b=0;b<e.length;++b)n[e[b]]=b;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let c=0,l=0,u=0;for(let b=0;b<s;++b){const m=n[t[b]];if(m===void 0)throw new SyntaxError(`Non-${i} character`);l=l<<r|m,c+=r,c>=8&&(c-=8,o[u++]=255&l>>c)}if(c>=r||255&l<<8-c)throw new SyntaxError("Unexpected end of data");return o},xg=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",o=0,c=0;for(let l=0;l<t.length;++l)for(c=c<<8|t[l],o+=8;o>r;)o-=r,s+=e[n&c>>o];if(o&&(s+=e[n&c<<r-o]),i)for(;s.length*r&7;)s+="=";return s},Nt=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>pa({prefix:e,name:t,encode(n){return xg(n,i,r)},decode(n){return Eg(n,i,r,t)}}),Sg=pa({prefix:"\0",name:"identity",encode:t=>mg(t),decode:t=>vg(t)});var Mg=Object.freeze({__proto__:null,identity:Sg});const Ig=Nt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Dg=Object.freeze({__proto__:null,base2:Ig});const Og=Nt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Rg=Object.freeze({__proto__:null,base8:Og});const Ng=us({prefix:"9",name:"base10",alphabet:"0123456789"});var Pg=Object.freeze({__proto__:null,base10:Ng});const Tg=Nt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Cg=Nt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Fg=Object.freeze({__proto__:null,base16:Tg,base16upper:Cg});const Lg=Nt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Bg=Nt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),qg=Nt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ug=Nt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),zg=Nt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),kg=Nt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),$g=Nt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),jg=Nt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Kg=Nt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Hg=Object.freeze({__proto__:null,base32:Lg,base32upper:Bg,base32pad:qg,base32padupper:Ug,base32hex:zg,base32hexupper:kg,base32hexpad:$g,base32hexpadupper:jg,base32z:Kg});const Vg=us({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Gg=us({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Wg=Object.freeze({__proto__:null,base36:Vg,base36upper:Gg});const Yg=us({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Jg=us({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Qg=Object.freeze({__proto__:null,base58btc:Yg,base58flickr:Jg});const Xg=Nt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Zg=Nt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),eb=Nt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),tb=Nt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var rb=Object.freeze({__proto__:null,base64:Xg,base64pad:Zg,base64url:eb,base64urlpad:tb});const ih=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}"),ib=ih.reduce((t,e,r)=>(t[r]=e,t),[]),nb=ih.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function sb(t){return t.reduce((e,r)=>(e+=ib[r],e),"")}function ab(t){const e=[];for(const r of t){const i=nb[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const ob=pa({prefix:"\u{1F680}",name:"base256emoji",encode:sb,decode:ab});var cb=Object.freeze({__proto__:null,base256emoji:ob}),fb=sh,nh=128,hb=127,ub=~hb,db=Math.pow(2,31);function sh(t,e,r){e=e||[],r=r||0;for(var i=r;t>=db;)e[r++]=t&255|nh,t/=128;for(;t&ub;)e[r++]=t&255|nh,t>>>=7;return e[r]=t|0,sh.bytes=r-i+1,e}var lb=Po,pb=128,ah=127;function Po(t,i){var r=0,i=i||0,n=0,s=i,o,c=t.length;do{if(s>=c)throw Po.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=n<28?(o&ah)<<n:(o&ah)*Math.pow(2,n),n+=7}while(o>=pb);return Po.bytes=s-i,r}var gb=Math.pow(2,7),bb=Math.pow(2,14),vb=Math.pow(2,21),mb=Math.pow(2,28),yb=Math.pow(2,35),wb=Math.pow(2,42),_b=Math.pow(2,49),Ab=Math.pow(2,56),Eb=Math.pow(2,63),xb=function(t){return t<gb?1:t<bb?2:t<vb?3:t<mb?4:t<yb?5:t<wb?6:t<_b?7:t<Ab?8:t<Eb?9:10},Sb={encode:fb,decode:lb,encodingLength:xb},oh=Sb;const ch=(t,e,r=0)=>(oh.encode(t,e,r),e),fh=t=>oh.encodingLength(t),To=(t,e)=>{const r=e.byteLength,i=fh(t),n=i+fh(r),s=new Uint8Array(n+r);return ch(t,s,0),ch(r,s,i),s.set(e,n),new Mb(t,r,e,s)};class Mb{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const hh=({name:t,code:e,encode:r})=>new Ib(t,e,r);class Ib{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?To(this.code,r):r.then(i=>To(this.code,i))}else throw Error("Unknown type, must be binary type")}}const uh=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Db=hh({name:"sha2-256",code:18,encode:uh("SHA-256")}),Ob=hh({name:"sha2-512",code:19,encode:uh("SHA-512")});var Rb=Object.freeze({__proto__:null,sha256:Db,sha512:Ob});const dh=0,Nb="identity",lh=th;var Pb=Object.freeze({__proto__:null,identity:{code:dh,name:Nb,encode:lh,digest:t=>To(dh,lh(t))}});new TextEncoder,new TextDecoder;const ph={...Mg,...Dg,...Rg,...Pg,...Fg,...Hg,...Wg,...Qg,...rb,...cb};({...Rb,...Pb});function gh(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const bh=gh("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Co=gh("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=eh(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),vh={utf8:bh,"utf-8":bh,hex:ph.base16,latin1:Co,ascii:Co,binary:Co,...ph};function Et(t,e="utf8"){const r=vh[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 xt(t,e="utf8"){const r=vh[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 mh(t){return An(Et(xt(t,da),Qf))}function ga(t){return Et(xt(Yi(t),Qf),da)}function yh(t){const e=xt(dg,Zf),r=ug+Et(la([e,t]),Zf);return[fg,hg,r].join(cg)}function Tb(t){return Et(t,da)}function Cb(t){return xt(t,da)}function Fb(t){return xt([ga(t.header),ga(t.payload)].join(ua),Xf)}function Lb(t){return[ga(t.header),ga(t.payload),Tb(t.signature)].join(ua)}function Fo(t){const e=t.split(ua),r=mh(e[0]),i=mh(e[1]),n=Cb(e[2]),s=xt(e.slice(0,2).join(ua),Xf);return{header:r,payload:i,signature:n,data:s}}function wh(t=Ci.randomBytes(lg)){return Mo.generateKeyPairFromSeed(t)}async function Bb(t,e,r,i,n=oe.fromMiliseconds(Date.now())){const s={alg:ag,typ:og},o=yh(i.publicKey),c=n+r,l={iss:o,sub:t,aud:e,iat:n,exp:c},u=Fb({header:s,payload:l}),b=Mo.sign(i.secretKey,u);return Lb({header:s,payload:l,signature:b})}var _h=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))},qb=function(){function t(e,r,i){this.name=e,this.version=r,this.os=i,this.type="browser"}return t}(),Ub=function(){function t(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return t}(),zb=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}(),kb=function(){function t(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return t}(),$b=function(){function t(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return t}(),jb=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,Kb=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Ah=3,Hb=[["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",jb]],Eh=[["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 Vb(t){return t?xh(t):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new $b:typeof navigator<"u"?xh(navigator.userAgent):Yb()}function Gb(t){return t!==""&&Hb.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 xh(t){var e=Gb(t);if(!e)return null;var r=e[0],i=e[1];if(r==="searchbot")return new kb;var n=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);n?n.length<Ah&&(n=_h(_h([],n,!0),Jb(Ah-n.length),!0)):n=[];var s=n.join("."),o=Wb(t),c=Kb.exec(t);return c&&c[1]?new zb(r,s,o,c[1]):new qb(r,s,o)}function Wb(t){for(var e=0,r=Eh.length;e<r;e++){var i=Eh[e],n=i[0],s=i[1],o=s.exec(t);if(o)return n}return null}function Yb(){var t=typeof process<"u"&&process.version;return t?new Ub(process.version.slice(1)):null}function Jb(t){for(var e=[],r=0;r<t;r++)e.push("0");return e}var ot={};Object.defineProperty(ot,"__esModule",{value:!0}),ot.getLocalStorage=ot.getLocalStorageOrThrow=ot.getCrypto=ot.getCryptoOrThrow=Sh=ot.getLocation=ot.getLocationOrThrow=Lo=ot.getNavigator=ot.getNavigatorOrThrow=ba=ot.getDocument=ot.getDocumentOrThrow=ot.getFromWindowOrThrow=ot.getFromWindow=void 0;function Zi(t){let e;return typeof window<"u"&&typeof window[t]<"u"&&(e=window[t]),e}ot.getFromWindow=Zi;function In(t){const e=Zi(t);if(!e)throw new Error(`${t} is not defined in Window`);return e}ot.getFromWindowOrThrow=In;function Qb(){return In("document")}ot.getDocumentOrThrow=Qb;function Xb(){return Zi("document")}var ba=ot.getDocument=Xb;function Zb(){return In("navigator")}ot.getNavigatorOrThrow=Zb;function e2(){return Zi("navigator")}var Lo=ot.getNavigator=e2;function t2(){return In("location")}ot.getLocationOrThrow=t2;function r2(){return Zi("location")}var Sh=ot.getLocation=r2;function i2(){return In("crypto")}ot.getCryptoOrThrow=i2;function n2(){return Zi("crypto")}ot.getCrypto=n2;function s2(){return In("localStorage")}ot.getLocalStorageOrThrow=s2;function a2(){return Zi("localStorage")}ot.getLocalStorage=a2;var Bo={};Object.defineProperty(Bo,"__esModule",{value:!0});var Mh=Bo.getWindowMetadata=void 0;const Ih=ot;function o2(){let t,e;try{t=Ih.getDocumentOrThrow(),e=Ih.getLocationOrThrow()}catch{return null}function r(){const m=t.getElementsByTagName("link"),M=[];for(let S=0;S<m.length;S++){const I=m[S],F=I.getAttribute("rel");if(F&&F.toLowerCase().indexOf("icon")>-1){const k=I.getAttribute("href");if(k)if(k.toLowerCase().indexOf("https:")===-1&&k.toLowerCase().indexOf("http:")===-1&&k.indexOf("//")!==0){let j=e.protocol+"//"+e.host;if(k.indexOf("/")===0)j+=k;else{const C=e.pathname.split("/");C.pop();const $=C.join("/");j+=$+"/"+k}M.push(j)}else if(k.indexOf("//")===0){const j=e.protocol+k;M.push(j)}else M.push(k)}}return M}function i(...m){const M=t.getElementsByTagName("meta");for(let S=0;S<M.length;S++){const I=M[S],F=["itemprop","property","name"].map(k=>I.getAttribute(k)).filter(k=>k?m.includes(k):!1);if(F.length&&F){const k=I.getAttribute("content");if(k)return k}}return""}function n(){let m=i("name","og:site_name","og:title","twitter:title");return m||(m=t.title),m}function s(){return i("description","og:description","twitter:description","keywords")}const o=n(),c=s(),l=e.origin,u=r();return{description:c,url:l,icons:u,name:o}}Mh=Bo.getWindowMetadata=o2;var ds={},c2=t=>encodeURIComponent(t).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),Dh="%[a-f0-9]{2}",Oh=new RegExp("("+Dh+")|([^%]+?)","gi"),Rh=new RegExp("("+Dh+")+","gi");function qo(t,e){try{return[decodeURIComponent(t.join(""))]}catch{}if(t.length===1)return t;e=e||1;var r=t.slice(0,e),i=t.slice(e);return Array.prototype.concat.call([],qo(r),qo(i))}function f2(t){try{return decodeURIComponent(t)}catch{for(var e=t.match(Oh)||[],r=1;r<e.length;r++)t=qo(e,r).join(""),e=t.match(Oh)||[];return t}}function h2(t){for(var e={"%FE%FF":"\uFFFD\uFFFD","%FF%FE":"\uFFFD\uFFFD"},r=Rh.exec(t);r;){try{e[r[0]]=decodeURIComponent(r[0])}catch{var i=f2(r[0]);i!==r[0]&&(e[r[0]]=i)}r=Rh.exec(t)}e["%C2"]="\uFFFD";for(var n=Object.keys(e),s=0;s<n.length;s++){var o=n[s];t=t.replace(new RegExp(o,"g"),e[o])}return t}var u2=function(t){if(typeof t!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof t+"`");try{return t=t.replace(/\+/g," "),decodeURIComponent(t)}catch{return h2(t)}},d2=(t,e)=>{if(!(typeof t=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[t];const r=t.indexOf(e);return r===-1?[t]:[t.slice(0,r),t.slice(r+e.length)]},l2=function(t,e){for(var r={},i=Object.keys(t),n=Array.isArray(e),s=0;s<i.length;s++){var o=i[s],c=t[o];(n?e.indexOf(o)!==-1:e(o,c,t))&&(r[o]=c)}return r};(function(t){const e=c2,r=u2,i=d2,n=l2,s=C=>C==null,o=Symbol("encodeFragmentIdentifier");function c(C){switch(C.arrayFormat){case"index":return $=>(P,B)=>{const U=P.length;return B===void 0||C.skipNull&&B===null||C.skipEmptyString&&B===""?P:B===null?[...P,[b($,C),"[",U,"]"].join("")]:[...P,[b($,C),"[",b(U,C),"]=",b(B,C)].join("")]};case"bracket":return $=>(P,B)=>B===void 0||C.skipNull&&B===null||C.skipEmptyString&&B===""?P:B===null?[...P,[b($,C),"[]"].join("")]:[...P,[b($,C),"[]=",b(B,C)].join("")];case"colon-list-separator":return $=>(P,B)=>B===void 0||C.skipNull&&B===null||C.skipEmptyString&&B===""?P:B===null?[...P,[b($,C),":list="].join("")]:[...P,[b($,C),":list=",b(B,C)].join("")];case"comma":case"separator":case"bracket-separator":{const $=C.arrayFormat==="bracket-separator"?"[]=":"=";return P=>(B,U)=>U===void 0||C.skipNull&&U===null||C.skipEmptyString&&U===""?B:(U=U===null?"":U,B.length===0?[[b(P,C),$,b(U,C)].join("")]:[[B,b(U,C)].join(C.arrayFormatSeparator)])}default:return $=>(P,B)=>B===void 0||C.skipNull&&B===null||C.skipEmptyString&&B===""?P:B===null?[...P,b($,C)]:[...P,[b($,C),"=",b(B,C)].join("")]}}function l(C){let $;switch(C.arrayFormat){case"index":return(P,B,U)=>{if($=/\[(\d*)\]$/.exec(P),P=P.replace(/\[\d*\]$/,""),!$){U[P]=B;return}U[P]===void 0&&(U[P]={}),U[P][$[1]]=B};case"bracket":return(P,B,U)=>{if($=/(\[\])$/.exec(P),P=P.replace(/\[\]$/,""),!$){U[P]=B;return}if(U[P]===void 0){U[P]=[B];return}U[P]=[].concat(U[P],B)};case"colon-list-separator":return(P,B,U)=>{if($=/(:list)$/.exec(P),P=P.replace(/:list$/,""),!$){U[P]=B;return}if(U[P]===void 0){U[P]=[B];return}U[P]=[].concat(U[P],B)};case"comma":case"separator":return(P,B,U)=>{const y=typeof B=="string"&&B.includes(C.arrayFormatSeparator),O=typeof B=="string"&&!y&&m(B,C).includes(C.arrayFormatSeparator);B=O?m(B,C):B;const Y=y||O?B.split(C.arrayFormatSeparator).map(Q=>m(Q,C)):B===null?B:m(B,C);U[P]=Y};case"bracket-separator":return(P,B,U)=>{const y=/(\[\])$/.test(P);if(P=P.replace(/\[\]$/,""),!y){U[P]=B&&m(B,C);return}const O=B===null?[]:B.split(C.arrayFormatSeparator).map(Y=>m(Y,C));if(U[P]===void 0){U[P]=O;return}U[P]=[].concat(U[P],O)};default:return(P,B,U)=>{if(U[P]===void 0){U[P]=B;return}U[P]=[].concat(U[P],B)}}}function u(C){if(typeof C!="string"||C.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function b(C,$){return $.encode?$.strict?e(C):encodeURIComponent(C):C}function m(C,$){return $.decode?r(C):C}function M(C){return Array.isArray(C)?C.sort():typeof C=="object"?M(Object.keys(C)).sort(($,P)=>Number($)-Number(P)).map($=>C[$]):C}function S(C){const $=C.indexOf("#");return $!==-1&&(C=C.slice(0,$)),C}function I(C){let $="";const P=C.indexOf("#");return P!==-1&&($=C.slice(P)),$}function F(C){C=S(C);const $=C.indexOf("?");return $===-1?"":C.slice($+1)}function k(C,$){return $.parseNumbers&&!Number.isNaN(Number(C))&&typeof C=="string"&&C.trim()!==""?C=Number(C):$.parseBooleans&&C!==null&&(C.toLowerCase()==="true"||C.toLowerCase()==="false")&&(C=C.toLowerCase()==="true"),C}function j(C,$){$=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},$),u($.arrayFormatSeparator);const P=l($),B=Object.create(null);if(typeof C!="string"||(C=C.trim().replace(/^[?#&]/,""),!C))return B;for(const U of C.split("&")){if(U==="")continue;let[y,O]=i($.decode?U.replace(/\+/g," "):U,"=");O=O===void 0?null:["comma","separator","bracket-separator"].includes($.arrayFormat)?O:m(O,$),P(m(y,$),O,B)}for(const U of Object.keys(B)){const y=B[U];if(typeof y=="object"&&y!==null)for(const O of Object.keys(y))y[O]=k(y[O],$);else B[U]=k(y,$)}return $.sort===!1?B:($.sort===!0?Object.keys(B).sort():Object.keys(B).sort($.sort)).reduce((U,y)=>{const O=B[y];return O&&typeof O=="object"&&!Array.isArray(O)?U[y]=M(O):U[y]=O,U},Object.create(null))}t.extract=F,t.parse=j,t.stringify=(C,$)=>{if(!C)return"";$=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},$),u($.arrayFormatSeparator);const P=O=>$.skipNull&&s(C[O])||$.skipEmptyString&&C[O]==="",B=c($),U={};for(const O of Object.keys(C))P(O)||(U[O]=C[O]);const y=Object.keys(U);return $.sort!==!1&&y.sort($.sort),y.map(O=>{const Y=C[O];return Y===void 0?"":Y===null?b(O,$):Array.isArray(Y)?Y.length===0&&$.arrayFormat==="bracket-separator"?b(O,$)+"[]":Y.reduce(B(O),[]).join("&"):b(O,$)+"="+b(Y,$)}).filter(O=>O.length>0).join("&")},t.parseUrl=(C,$)=>{$=Object.assign({decode:!0},$);const[P,B]=i(C,"#");return Object.assign({url:P.split("?")[0]||"",query:j(F(C),$)},$&&$.parseFragmentIdentifier&&B?{fragmentIdentifier:m(B,$)}:{})},t.stringifyUrl=(C,$)=>{$=Object.assign({encode:!0,strict:!0,[o]:!0},$);const P=S(C.url).split("?")[0]||"",B=t.extract(C.url),U=t.parse(B,{sort:!1}),y=Object.assign(U,C.query);let O=t.stringify(y,$);O&&(O=`?${O}`);let Y=I(C.url);return C.fragmentIdentifier&&(Y=`#${$[o]?b(C.fragmentIdentifier,$):C.fragmentIdentifier}`),`${P}${O}${Y}`},t.pick=(C,$,P)=>{P=Object.assign({parseFragmentIdentifier:!0,[o]:!1},P);const{url:B,query:U,fragmentIdentifier:y}=t.parseUrl(C,P);return t.stringifyUrl({url:B,query:n(U,$),fragmentIdentifier:y},P)},t.exclude=(C,$,P)=>{const B=Array.isArray($)?U=>!$.includes(U):(U,y)=>!$(U,y);return t.pick(C,B,P)}})(ds);var Uo={},va={};Object.defineProperty(va,"__esModule",{value:!0});var Ut=Ke,zo=fr,p2=20;function g2(t,e,r){for(var i=1634760805,n=857760878,s=2036477234,o=1797285236,c=r[3]<<24|r[2]<<16|r[1]<<8|r[0],l=r[7]<<24|r[6]<<16|r[5]<<8|r[4],u=r[11]<<24|r[10]<<16|r[9]<<8|r[8],b=r[15]<<24|r[14]<<16|r[13]<<8|r[12],m=r[19]<<24|r[18]<<16|r[17]<<8|r[16],M=r[23]<<24|r[22]<<16|r[21]<<8|r[20],S=r[27]<<24|r[26]<<16|r[25]<<8|r[24],I=r[31]<<24|r[30]<<16|r[29]<<8|r[28],F=e[3]<<24|e[2]<<16|e[1]<<8|e[0],k=e[7]<<24|e[6]<<16|e[5]<<8|e[4],j=e[11]<<24|e[10]<<16|e[9]<<8|e[8],C=e[15]<<24|e[14]<<16|e[13]<<8|e[12],$=i,P=n,B=s,U=o,y=c,O=l,Y=u,Q=b,N=m,g=M,a=S,f=I,p=F,w=k,A=j,x=C,_=0;_<p2;_+=2)$=$+y|0,p^=$,p=p>>>32-16|p<<16,N=N+p|0,y^=N,y=y>>>32-12|y<<12,P=P+O|0,w^=P,w=w>>>32-16|w<<16,g=g+w|0,O^=g,O=O>>>32-12|O<<12,B=B+Y|0,A^=B,A=A>>>32-16|A<<16,a=a+A|0,Y^=a,Y=Y>>>32-12|Y<<12,U=U+Q|0,x^=U,x=x>>>32-16|x<<16,f=f+x|0,Q^=f,Q=Q>>>32-12|Q<<12,B=B+Y|0,A^=B,A=A>>>32-8|A<<8,a=a+A|0,Y^=a,Y=Y>>>32-7|Y<<7,U=U+Q|0,x^=U,x=x>>>32-8|x<<8,f=f+x|0,Q^=f,Q=Q>>>32-7|Q<<7,P=P+O|0,w^=P,w=w>>>32-8|w<<8,g=g+w|0,O^=g,O=O>>>32-7|O<<7,$=$+y|0,p^=$,p=p>>>32-8|p<<8,N=N+p|0,y^=N,y=y>>>32-7|y<<7,$=$+O|0,x^=$,x=x>>>32-16|x<<16,a=a+x|0,O^=a,O=O>>>32-12|O<<12,P=P+Y|0,p^=P,p=p>>>32-16|p<<16,f=f+p|0,Y^=f,Y=Y>>>32-12|Y<<12,B=B+Q|0,w^=B,w=w>>>32-16|w<<16,N=N+w|0,Q^=N,Q=Q>>>32-12|Q<<12,U=U+y|0,A^=U,A=A>>>32-16|A<<16,g=g+A|0,y^=g,y=y>>>32-12|y<<12,B=B+Q|0,w^=B,w=w>>>32-8|w<<8,N=N+w|0,Q^=N,Q=Q>>>32-7|Q<<7,U=U+y|0,A^=U,A=A>>>32-8|A<<8,g=g+A|0,y^=g,y=y>>>32-7|y<<7,P=P+Y|0,p^=P,p=p>>>32-8|p<<8,f=f+p|0,Y^=f,Y=Y>>>32-7|Y<<7,$=$+O|0,x^=$,x=x>>>32-8|x<<8,a=a+x|0,O^=a,O=O>>>32-7|O<<7;Ut.writeUint32LE($+i|0,t,0),Ut.writeUint32LE(P+n|0,t,4),Ut.writeUint32LE(B+s|0,t,8),Ut.writeUint32LE(U+o|0,t,12),Ut.writeUint32LE(y+c|0,t,16),Ut.writeUint32LE(O+l|0,t,20),Ut.writeUint32LE(Y+u|0,t,24),Ut.writeUint32LE(Q+b|0,t,28),Ut.writeUint32LE(N+m|0,t,32),Ut.writeUint32LE(g+M|0,t,36),Ut.writeUint32LE(a+S|0,t,40),Ut.writeUint32LE(f+I|0,t,44),Ut.writeUint32LE(p+F|0,t,48),Ut.writeUint32LE(w+k|0,t,52),Ut.writeUint32LE(A+j|0,t,56),Ut.writeUint32LE(x+C|0,t,60)}function Nh(t,e,r,i,n){if(n===void 0&&(n=0),t.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(i.length<r.length)throw new Error("ChaCha: destination is shorter than source");var s,o;if(n===0){if(e.length!==8&&e.length!==12)throw new Error("ChaCha nonce must be 8 or 12 bytes");s=new Uint8Array(16),o=s.length-e.length,s.set(e,o)}else{if(e.length!==16)throw new Error("ChaCha nonce with counter must be 16 bytes");s=e,o=n}for(var c=new Uint8Array(64),l=0;l<r.length;l+=64){g2(c,s,t);for(var u=l;u<l+64&&u<r.length;u++)i[u]=r[u]^c[u-l];v2(s,0,o)}return zo.wipe(c),n===0&&zo.wipe(s),i}va.streamXOR=Nh;function b2(t,e,r,i){return i===void 0&&(i=0),zo.wipe(r),Nh(t,e,r,r,i)}va.stream=b2;function v2(t,e,r){for(var i=1;r--;)i=i+(t[e]&255)|0,t[e]=i&255,i>>>=8,e++;if(i>0)throw new Error("ChaCha: counter overflow")}var Ph={},Fi={};Object.defineProperty(Fi,"__esModule",{value:!0});function m2(t,e,r){return~(t-1)&e|t-1&r}Fi.select=m2;function y2(t,e){return(t|0)-(e|0)-1>>>31&1}Fi.lessOrEqual=y2;function Th(t,e){if(t.length!==e.length)return 0;for(var r=0,i=0;i<t.length;i++)r|=t[i]^e[i];return 1&r-1>>>8}Fi.compare=Th;function w2(t,e){return t.length===0||e.length===0?!1:Th(t,e)!==0}Fi.equal=w2,function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Fi,r=fr;t.DIGEST_LENGTH=16;var i=function(){function o(c){this.digestLength=t.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var l=c[0]|c[1]<<8;this._r[0]=l&8191;var u=c[2]|c[3]<<8;this._r[1]=(l>>>13|u<<3)&8191;var b=c[4]|c[5]<<8;this._r[2]=(u>>>10|b<<6)&7939;var m=c[6]|c[7]<<8;this._r[3]=(b>>>7|m<<9)&8191;var M=c[8]|c[9]<<8;this._r[4]=(m>>>4|M<<12)&255,this._r[5]=M>>>1&8190;var S=c[10]|c[11]<<8;this._r[6]=(M>>>14|S<<2)&8191;var I=c[12]|c[13]<<8;this._r[7]=(S>>>11|I<<5)&8065;var F=c[14]|c[15]<<8;this._r[8]=(I>>>8|F<<8)&8191,this._r[9]=F>>>5&127,this._pad[0]=c[16]|c[17]<<8,this._pad[1]=c[18]|c[19]<<8,this._pad[2]=c[20]|c[21]<<8,this._pad[3]=c[22]|c[23]<<8,this._pad[4]=c[24]|c[25]<<8,this._pad[5]=c[26]|c[27]<<8,this._pad[6]=c[28]|c[29]<<8,this._pad[7]=c[30]|c[31]<<8}return o.prototype._blocks=function(c,l,u){for(var b=this._fin?0:2048,m=this._h[0],M=this._h[1],S=this._h[2],I=this._h[3],F=this._h[4],k=this._h[5],j=this._h[6],C=this._h[7],$=this._h[8],P=this._h[9],B=this._r[0],U=this._r[1],y=this._r[2],O=this._r[3],Y=this._r[4],Q=this._r[5],N=this._r[6],g=this._r[7],a=this._r[8],f=this._r[9];u>=16;){var p=c[l+0]|c[l+1]<<8;m+=p&8191;var w=c[l+2]|c[l+3]<<8;M+=(p>>>13|w<<3)&8191;var A=c[l+4]|c[l+5]<<8;S+=(w>>>10|A<<6)&8191;var x=c[l+6]|c[l+7]<<8;I+=(A>>>7|x<<9)&8191;var _=c[l+8]|c[l+9]<<8;F+=(x>>>4|_<<12)&8191,k+=_>>>1&8191;var h=c[l+10]|c[l+11]<<8;j+=(_>>>14|h<<2)&8191;var d=c[l+12]|c[l+13]<<8;C+=(h>>>11|d<<5)&8191;var D=c[l+14]|c[l+15]<<8;$+=(d>>>8|D<<8)&8191,P+=D>>>5|b;var K=0,G=K;G+=m*B,G+=M*(5*f),G+=S*(5*a),G+=I*(5*g),G+=F*(5*N),K=G>>>13,G&=8191,G+=k*(5*Q),G+=j*(5*Y),G+=C*(5*O),G+=$*(5*y),G+=P*(5*U),K+=G>>>13,G&=8191;var E=K;E+=m*U,E+=M*B,E+=S*(5*f),E+=I*(5*a),E+=F*(5*g),K=E>>>13,E&=8191,E+=k*(5*N),E+=j*(5*Q),E+=C*(5*Y),E+=$*(5*O),E+=P*(5*y),K+=E>>>13,E&=8191;var H=K;H+=m*y,H+=M*U,H+=S*B,H+=I*(5*f),H+=F*(5*a),K=H>>>13,H&=8191,H+=k*(5*g),H+=j*(5*N),H+=C*(5*Q),H+=$*(5*Y),H+=P*(5*O),K+=H>>>13,H&=8191;var R=K;R+=m*O,R+=M*y,R+=S*U,R+=I*B,R+=F*(5*f),K=R>>>13,R&=8191,R+=k*(5*a),R+=j*(5*g),R+=C*(5*N),R+=$*(5*Q),R+=P*(5*Y),K+=R>>>13,R&=8191;var L=K;L+=m*Y,L+=M*O,L+=S*y,L+=I*U,L+=F*B,K=L>>>13,L&=8191,L+=k*(5*f),L+=j*(5*a),L+=C*(5*g),L+=$*(5*N),L+=P*(5*Q),K+=L>>>13,L&=8191;var q=K;q+=m*Q,q+=M*Y,q+=S*O,q+=I*y,q+=F*U,K=q>>>13,q&=8191,q+=k*B,q+=j*(5*f),q+=C*(5*a),q+=$*(5*g),q+=P*(5*N),K+=q>>>13,q&=8191;var v=K;v+=m*N,v+=M*Q,v+=S*Y,v+=I*O,v+=F*y,K=v>>>13,v&=8191,v+=k*U,v+=j*B,v+=C*(5*f),v+=$*(5*a),v+=P*(5*g),K+=v>>>13,v&=8191;var T=K;T+=m*g,T+=M*N,T+=S*Q,T+=I*Y,T+=F*O,K=T>>>13,T&=8191,T+=k*y,T+=j*U,T+=C*B,T+=$*(5*f),T+=P*(5*a),K+=T>>>13,T&=8191;var W=K;W+=m*a,W+=M*g,W+=S*N,W+=I*Q,W+=F*Y,K=W>>>13,W&=8191,W+=k*O,W+=j*y,W+=C*U,W+=$*B,W+=P*(5*f),K+=W>>>13,W&=8191;var J=K;J+=m*f,J+=M*a,J+=S*g,J+=I*N,J+=F*Q,K=J>>>13,J&=8191,J+=k*Y,J+=j*O,J+=C*y,J+=$*U,J+=P*B,K+=J>>>13,J&=8191,K=(K<<2)+K|0,K=K+G|0,G=K&8191,K=K>>>13,E+=K,m=G,M=E,S=H,I=R,F=L,k=q,j=v,C=T,$=W,P=J,l+=16,u-=16}this._h[0]=m,this._h[1]=M,this._h[2]=S,this._h[3]=I,this._h[4]=F,this._h[5]=k,this._h[6]=j,this._h[7]=C,this._h[8]=$,this._h[9]=P},o.prototype.finish=function(c,l){l===void 0&&(l=0);var u=new Uint16Array(10),b,m,M,S;if(this._leftover){for(S=this._leftover,this._buffer[S++]=1;S<16;S++)this._buffer[S]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(b=this._h[1]>>>13,this._h[1]&=8191,S=2;S<10;S++)this._h[S]+=b,b=this._h[S]>>>13,this._h[S]&=8191;for(this._h[0]+=b*5,b=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=b,b=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=b,u[0]=this._h[0]+5,b=u[0]>>>13,u[0]&=8191,S=1;S<10;S++)u[S]=this._h[S]+b,b=u[S]>>>13,u[S]&=8191;for(u[9]-=8192,m=(b^1)-1,S=0;S<10;S++)u[S]&=m;for(m=~m,S=0;S<10;S++)this._h[S]=this._h[S]&m|u[S];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,M=this._h[0]+this._pad[0],this._h[0]=M&65535,S=1;S<8;S++)M=(this._h[S]+this._pad[S]|0)+(M>>>16)|0,this._h[S]=M&65535;return c[l+0]=this._h[0]>>>0,c[l+1]=this._h[0]>>>8,c[l+2]=this._h[1]>>>0,c[l+3]=this._h[1]>>>8,c[l+4]=this._h[2]>>>0,c[l+5]=this._h[2]>>>8,c[l+6]=this._h[3]>>>0,c[l+7]=this._h[3]>>>8,c[l+8]=this._h[4]>>>0,c[l+9]=this._h[4]>>>8,c[l+10]=this._h[5]>>>0,c[l+11]=this._h[5]>>>8,c[l+12]=this._h[6]>>>0,c[l+13]=this._h[6]>>>8,c[l+14]=this._h[7]>>>0,c[l+15]=this._h[7]>>>8,this._finished=!0,this},o.prototype.update=function(c){var l=0,u=c.length,b;if(this._leftover){b=16-this._leftover,b>u&&(b=u);for(var m=0;m<b;m++)this._buffer[this._leftover+m]=c[l+m];if(u-=b,l+=b,this._leftover+=b,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(u>=16&&(b=u-u%16,this._blocks(c,l,b),l+=b,u-=b),u){for(var m=0;m<u;m++)this._buffer[this._leftover+m]=c[l+m];this._leftover+=u}return this},o.prototype.digest=function(){if(this._finished)throw new Error("Poly1305 was finished");var c=new Uint8Array(16);return this.finish(c),c},o.prototype.clean=function(){return r.wipe(this._buffer),r.wipe(this._r),r.wipe(this._h),r.wipe(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this},o}();t.Poly1305=i;function n(o,c){var l=new i(o);l.update(c);var u=l.digest();return l.clean(),u}t.oneTimeAuth=n;function s(o,c){return o.length!==t.DIGEST_LENGTH||c.length!==t.DIGEST_LENGTH?!1:e.equal(o,c)}t.equal=s}(Ph),function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=va,r=Ph,i=fr,n=Ke,s=Fi;t.KEY_LENGTH=32,t.NONCE_LENGTH=12,t.TAG_LENGTH=16;var o=new Uint8Array(16),c=function(){function l(u){if(this.nonceLength=t.NONCE_LENGTH,this.tagLength=t.TAG_LENGTH,u.length!==t.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(u)}return l.prototype.seal=function(u,b,m,M){if(u.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var S=new Uint8Array(16);S.set(u,S.length-u.length);var I=new Uint8Array(32);e.stream(this._key,S,I,4);var F=b.length+this.tagLength,k;if(M){if(M.length!==F)throw new Error("ChaCha20Poly1305: incorrect destination length");k=M}else k=new Uint8Array(F);return e.streamXOR(this._key,S,b,k,4),this._authenticate(k.subarray(k.length-this.tagLength,k.length),I,k.subarray(0,k.length-this.tagLength),m),i.wipe(S),k},l.prototype.open=function(u,b,m,M){if(u.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(b.length<this.tagLength)return null;var S=new Uint8Array(16);S.set(u,S.length-u.length);var I=new Uint8Array(32);e.stream(this._key,S,I,4);var F=new Uint8Array(this.tagLength);if(this._authenticate(F,I,b.subarray(0,b.length-this.tagLength),m),!s.equal(F,b.subarray(b.length-this.tagLength,b.length)))return null;var k=b.length-this.tagLength,j;if(M){if(M.length!==k)throw new Error("ChaCha20Poly1305: incorrect destination length");j=M}else j=new Uint8Array(k);return e.streamXOR(this._key,S,b.subarray(0,b.length-this.tagLength),j,4),i.wipe(S),j},l.prototype.clean=function(){return i.wipe(this._key),this},l.prototype._authenticate=function(u,b,m,M){var S=new r.Poly1305(b);M&&(S.update(M),M.length%16>0&&S.update(o.subarray(M.length%16))),S.update(m),m.length%16>0&&S.update(o.subarray(m.length%16));var I=new Uint8Array(8);M&&n.writeUint64LE(M.length,I),S.update(I),n.writeUint64LE(m.length,I),S.update(I);for(var F=S.digest(),k=0;k<F.length;k++)u[k]=F[k];S.clean(),i.wipe(F),i.wipe(I)},l}();t.ChaCha20Poly1305=c}(Uo);var Ch={},ls={},ko={};Object.defineProperty(ko,"__esModule",{value:!0});function _2(t){return typeof t.saveState<"u"&&typeof t.restoreState<"u"&&typeof t.cleanSavedState<"u"}ko.isSerializableHash=_2,Object.defineProperty(ls,"__esModule",{value:!0});var Ur=ko,A2=Fi,E2=fr,Fh=function(){function t(e,r){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var i=new Uint8Array(this.blockSize);r.length>this.blockSize?this._inner.update(r).finish(i).clean():i.set(r);for(var n=0;n<i.length;n++)i[n]^=54;this._inner.update(i);for(var n=0;n<i.length;n++)i[n]^=106;this._outer.update(i),Ur.isSerializableHash(this._inner)&&Ur.isSerializableHash(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),E2.wipe(i)}return t.prototype.reset=function(){if(!Ur.isSerializableHash(this._inner)||!Ur.isSerializableHash(this._outer))throw new Error("hmac: can't reset() because hash doesn't implement restoreState()");return this._inner.restoreState(this._innerKeyedState),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},t.prototype.clean=function(){Ur.isSerializableHash(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),Ur.isSerializableHash(this._outer)&&this._outer.cleanSavedState(this._outerKeyedState),this._inner.clean(),this._outer.clean()},t.prototype.update=function(e){return this._inner.update(e),this},t.prototype.finish=function(e){return this._finished?(this._outer.finish(e),this):(this._inner.finish(e),this._outer.update(e.subarray(0,this.digestLength)).finish(e),this._finished=!0,this)},t.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},t.prototype.saveState=function(){if(!Ur.isSerializableHash(this._inner))throw new Error("hmac: can't saveState() because hash doesn't implement it");return this._inner.saveState()},t.prototype.restoreState=function(e){if(!Ur.isSerializableHash(this._inner)||!Ur.isSerializableHash(this._outer))throw new Error("hmac: can't restoreState() because hash doesn't implement it");return this._inner.restoreState(e),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},t.prototype.cleanSavedState=function(e){if(!Ur.isSerializableHash(this._inner))throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it");this._inner.cleanSavedState(e)},t}();ls.HMAC=Fh;function x2(t,e,r){var i=new Fh(t,e);i.update(r);var n=i.digest();return i.clean(),n}ls.hmac=x2,ls.equal=A2.equal,Object.defineProperty(Ch,"__esModule",{value:!0});var Lh=ls,Bh=fr,S2=function(){function t(e,r,i,n){i===void 0&&(i=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=n;var s=Lh.hmac(this._hash,i,r);this._hmac=new Lh.HMAC(e,s),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return t.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(e===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},t.prototype.expand=function(e){for(var r=new Uint8Array(e),i=0;i<r.length;i++)this._bufpos===this._buffer.length&&this._fillBuffer(),r[i]=this._buffer[this._bufpos++];return r},t.prototype.clean=function(){this._hmac.clean(),Bh.wipe(this._buffer),Bh.wipe(this._counter),this._bufpos=0},t}(),M2=Ch.HKDF=S2,ps={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Ke,r=fr;t.DIGEST_LENGTH=32,t.BLOCK_SIZE=64;var i=function(){function c(){this.digestLength=t.DIGEST_LENGTH,this.blockSize=t.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return c.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},c.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},c.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._temp),this.reset()},c.prototype.update=function(l,u){if(u===void 0&&(u=l.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var b=0;if(this._bytesHashed+=u,this._bufferLength>0){for(;this._bufferLength<this.blockSize&&u>0;)this._buffer[this._bufferLength++]=l[b++],u--;this._bufferLength===this.blockSize&&(s(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(u>=this.blockSize&&(b=s(this._temp,this._state,l,b,u),u%=this.blockSize);u>0;)this._buffer[this._bufferLength++]=l[b++],u--;return this},c.prototype.finish=function(l){if(!this._finished){var u=this._bytesHashed,b=this._bufferLength,m=u/536870912|0,M=u<<3,S=u%64<56?64:128;this._buffer[b]=128;for(var I=b+1;I<S-8;I++)this._buffer[I]=0;e.writeUint32BE(m,this._buffer,S-8),e.writeUint32BE(M,this._buffer,S-4),s(this._temp,this._state,this._buffer,0,S),this._finished=!0}for(var I=0;I<this.digestLength/4;I++)e.writeUint32BE(this._state[I],l,I*4);return this},c.prototype.digest=function(){var l=new Uint8Array(this.digestLength);return this.finish(l),l},c.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{state:new Int32Array(this._state),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},c.prototype.restoreState=function(l){return this._state.set(l.state),this._bufferLength=l.bufferLength,l.buffer&&this._buffer.set(l.buffer),this._bytesHashed=l.bytesHashed,this._finished=!1,this},c.prototype.cleanSavedState=function(l){r.wipe(l.state),l.buffer&&r.wipe(l.buffer),l.bufferLength=0,l.bytesHashed=0},c}();t.SHA256=i;var n=new Int32Array([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 s(c,l,u,b,m){for(;m>=64;){for(var M=l[0],S=l[1],I=l[2],F=l[3],k=l[4],j=l[5],C=l[6],$=l[7],P=0;P<16;P++){var B=b+P*4;c[P]=e.readUint32BE(u,B)}for(var P=16;P<64;P++){var U=c[P-2],y=(U>>>17|U<<32-17)^(U>>>19|U<<32-19)^U>>>10;U=c[P-15];var O=(U>>>7|U<<32-7)^(U>>>18|U<<32-18)^U>>>3;c[P]=(y+c[P-7]|0)+(O+c[P-16]|0)}for(var P=0;P<64;P++){var y=(((k>>>6|k<<26)^(k>>>11|k<<21)^(k>>>25|k<<7))+(k&j^~k&C)|0)+($+(n[P]+c[P]|0)|0)|0,O=((M>>>2|M<<32-2)^(M>>>13|M<<32-13)^(M>>>22|M<<32-22))+(M&S^M&I^S&I)|0;$=C,C=j,j=k,k=F+y|0,F=I,I=S,S=M,M=y+O|0}l[0]+=M,l[1]+=S,l[2]+=I,l[3]+=F,l[4]+=k,l[5]+=j,l[6]+=C,l[7]+=$,b+=64,m-=64}return b}function o(c){var l=new i;l.update(c);var u=l.digest();return l.clean(),u}t.hash=o})(ps);var $o={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.sharedKey=t.generateKeyPair=t.generateKeyPairFromSeed=t.scalarMultBase=t.scalarMult=t.SHARED_KEY_LENGTH=t.SECRET_KEY_LENGTH=t.PUBLIC_KEY_LENGTH=void 0;const e=Ci,r=fr;t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=32,t.SHARED_KEY_LENGTH=32;function i(P){const B=new Float64Array(16);if(P)for(let U=0;U<P.length;U++)B[U]=P[U];return B}const n=new Uint8Array(32);n[0]=9;const s=i([56129,1]);function o(P){let B=1;for(let U=0;U<16;U++){let y=P[U]+B+65535;B=Math.floor(y/65536),P[U]=y-B*65536}P[0]+=B-1+37*(B-1)}function c(P,B,U){const y=~(U-1);for(let O=0;O<16;O++){const Y=y&(P[O]^B[O]);P[O]^=Y,B[O]^=Y}}function l(P,B){const U=i(),y=i();for(let O=0;O<16;O++)y[O]=B[O];o(y),o(y),o(y);for(let O=0;O<2;O++){U[0]=y[0]-65517;for(let Q=1;Q<15;Q++)U[Q]=y[Q]-65535-(U[Q-1]>>16&1),U[Q-1]&=65535;U[15]=y[15]-32767-(U[14]>>16&1);const Y=U[15]>>16&1;U[14]&=65535,c(y,U,1-Y)}for(let O=0;O<16;O++)P[2*O]=y[O]&255,P[2*O+1]=y[O]>>8}function u(P,B){for(let U=0;U<16;U++)P[U]=B[2*U]+(B[2*U+1]<<8);P[15]&=32767}function b(P,B,U){for(let y=0;y<16;y++)P[y]=B[y]+U[y]}function m(P,B,U){for(let y=0;y<16;y++)P[y]=B[y]-U[y]}function M(P,B,U){let y,O,Y=0,Q=0,N=0,g=0,a=0,f=0,p=0,w=0,A=0,x=0,_=0,h=0,d=0,D=0,K=0,G=0,E=0,H=0,R=0,L=0,q=0,v=0,T=0,W=0,J=0,X=0,se=0,ne=0,Me=0,Ce=0,ue=0,xe=U[0],Ae=U[1],re=U[2],ve=U[3],le=U[4],ee=U[5],de=U[6],fe=U[7],te=U[8],Ee=U[9],he=U[10],ae=U[11],Se=U[12],De=U[13],ce=U[14],Ie=U[15];y=B[0],Y+=y*xe,Q+=y*Ae,N+=y*re,g+=y*ve,a+=y*le,f+=y*ee,p+=y*de,w+=y*fe,A+=y*te,x+=y*Ee,_+=y*he,h+=y*ae,d+=y*Se,D+=y*De,K+=y*ce,G+=y*Ie,y=B[1],Q+=y*xe,N+=y*Ae,g+=y*re,a+=y*ve,f+=y*le,p+=y*ee,w+=y*de,A+=y*fe,x+=y*te,_+=y*Ee,h+=y*he,d+=y*ae,D+=y*Se,K+=y*De,G+=y*ce,E+=y*Ie,y=B[2],N+=y*xe,g+=y*Ae,a+=y*re,f+=y*ve,p+=y*le,w+=y*ee,A+=y*de,x+=y*fe,_+=y*te,h+=y*Ee,d+=y*he,D+=y*ae,K+=y*Se,G+=y*De,E+=y*ce,H+=y*Ie,y=B[3],g+=y*xe,a+=y*Ae,f+=y*re,p+=y*ve,w+=y*le,A+=y*ee,x+=y*de,_+=y*fe,h+=y*te,d+=y*Ee,D+=y*he,K+=y*ae,G+=y*Se,E+=y*De,H+=y*ce,R+=y*Ie,y=B[4],a+=y*xe,f+=y*Ae,p+=y*re,w+=y*ve,A+=y*le,x+=y*ee,_+=y*de,h+=y*fe,d+=y*te,D+=y*Ee,K+=y*he,G+=y*ae,E+=y*Se,H+=y*De,R+=y*ce,L+=y*Ie,y=B[5],f+=y*xe,p+=y*Ae,w+=y*re,A+=y*ve,x+=y*le,_+=y*ee,h+=y*de,d+=y*fe,D+=y*te,K+=y*Ee,G+=y*he,E+=y*ae,H+=y*Se,R+=y*De,L+=y*ce,q+=y*Ie,y=B[6],p+=y*xe,w+=y*Ae,A+=y*re,x+=y*ve,_+=y*le,h+=y*ee,d+=y*de,D+=y*fe,K+=y*te,G+=y*Ee,E+=y*he,H+=y*ae,R+=y*Se,L+=y*De,q+=y*ce,v+=y*Ie,y=B[7],w+=y*xe,A+=y*Ae,x+=y*re,_+=y*ve,h+=y*le,d+=y*ee,D+=y*de,K+=y*fe,G+=y*te,E+=y*Ee,H+=y*he,R+=y*ae,L+=y*Se,q+=y*De,v+=y*ce,T+=y*Ie,y=B[8],A+=y*xe,x+=y*Ae,_+=y*re,h+=y*ve,d+=y*le,D+=y*ee,K+=y*de,G+=y*fe,E+=y*te,H+=y*Ee,R+=y*he,L+=y*ae,q+=y*Se,v+=y*De,T+=y*ce,W+=y*Ie,y=B[9],x+=y*xe,_+=y*Ae,h+=y*re,d+=y*ve,D+=y*le,K+=y*ee,G+=y*de,E+=y*fe,H+=y*te,R+=y*Ee,L+=y*he,q+=y*ae,v+=y*Se,T+=y*De,W+=y*ce,J+=y*Ie,y=B[10],_+=y*xe,h+=y*Ae,d+=y*re,D+=y*ve,K+=y*le,G+=y*ee,E+=y*de,H+=y*fe,R+=y*te,L+=y*Ee,q+=y*he,v+=y*ae,T+=y*Se,W+=y*De,J+=y*ce,X+=y*Ie,y=B[11],h+=y*xe,d+=y*Ae,D+=y*re,K+=y*ve,G+=y*le,E+=y*ee,H+=y*de,R+=y*fe,L+=y*te,q+=y*Ee,v+=y*he,T+=y*ae,W+=y*Se,J+=y*De,X+=y*ce,se+=y*Ie,y=B[12],d+=y*xe,D+=y*Ae,K+=y*re,G+=y*ve,E+=y*le,H+=y*ee,R+=y*de,L+=y*fe,q+=y*te,v+=y*Ee,T+=y*he,W+=y*ae,J+=y*Se,X+=y*De,se+=y*ce,ne+=y*Ie,y=B[13],D+=y*xe,K+=y*Ae,G+=y*re,E+=y*ve,H+=y*le,R+=y*ee,L+=y*de,q+=y*fe,v+=y*te,T+=y*Ee,W+=y*he,J+=y*ae,X+=y*Se,se+=y*De,ne+=y*ce,Me+=y*Ie,y=B[14],K+=y*xe,G+=y*Ae,E+=y*re,H+=y*ve,R+=y*le,L+=y*ee,q+=y*de,v+=y*fe,T+=y*te,W+=y*Ee,J+=y*he,X+=y*ae,se+=y*Se,ne+=y*De,Me+=y*ce,Ce+=y*Ie,y=B[15],G+=y*xe,E+=y*Ae,H+=y*re,R+=y*ve,L+=y*le,q+=y*ee,v+=y*de,T+=y*fe,W+=y*te,J+=y*Ee,X+=y*he,se+=y*ae,ne+=y*Se,Me+=y*De,Ce+=y*ce,ue+=y*Ie,Y+=38*E,Q+=38*H,N+=38*R,g+=38*L,a+=38*q,f+=38*v,p+=38*T,w+=38*W,A+=38*J,x+=38*X,_+=38*se,h+=38*ne,d+=38*Me,D+=38*Ce,K+=38*ue,O=1,y=Y+O+65535,O=Math.floor(y/65536),Y=y-O*65536,y=Q+O+65535,O=Math.floor(y/65536),Q=y-O*65536,y=N+O+65535,O=Math.floor(y/65536),N=y-O*65536,y=g+O+65535,O=Math.floor(y/65536),g=y-O*65536,y=a+O+65535,O=Math.floor(y/65536),a=y-O*65536,y=f+O+65535,O=Math.floor(y/65536),f=y-O*65536,y=p+O+65535,O=Math.floor(y/65536),p=y-O*65536,y=w+O+65535,O=Math.floor(y/65536),w=y-O*65536,y=A+O+65535,O=Math.floor(y/65536),A=y-O*65536,y=x+O+65535,O=Math.floor(y/65536),x=y-O*65536,y=_+O+65535,O=Math.floor(y/65536),_=y-O*65536,y=h+O+65535,O=Math.floor(y/65536),h=y-O*65536,y=d+O+65535,O=Math.floor(y/65536),d=y-O*65536,y=D+O+65535,O=Math.floor(y/65536),D=y-O*65536,y=K+O+65535,O=Math.floor(y/65536),K=y-O*65536,y=G+O+65535,O=Math.floor(y/65536),G=y-O*65536,Y+=O-1+37*(O-1),O=1,y=Y+O+65535,O=Math.floor(y/65536),Y=y-O*65536,y=Q+O+65535,O=Math.floor(y/65536),Q=y-O*65536,y=N+O+65535,O=Math.floor(y/65536),N=y-O*65536,y=g+O+65535,O=Math.floor(y/65536),g=y-O*65536,y=a+O+65535,O=Math.floor(y/65536),a=y-O*65536,y=f+O+65535,O=Math.floor(y/65536),f=y-O*65536,y=p+O+65535,O=Math.floor(y/65536),p=y-O*65536,y=w+O+65535,O=Math.floor(y/65536),w=y-O*65536,y=A+O+65535,O=Math.floor(y/65536),A=y-O*65536,y=x+O+65535,O=Math.floor(y/65536),x=y-O*65536,y=_+O+65535,O=Math.floor(y/65536),_=y-O*65536,y=h+O+65535,O=Math.floor(y/65536),h=y-O*65536,y=d+O+65535,O=Math.floor(y/65536),d=y-O*65536,y=D+O+65535,O=Math.floor(y/65536),D=y-O*65536,y=K+O+65535,O=Math.floor(y/65536),K=y-O*65536,y=G+O+65535,O=Math.floor(y/65536),G=y-O*65536,Y+=O-1+37*(O-1),P[0]=Y,P[1]=Q,P[2]=N,P[3]=g,P[4]=a,P[5]=f,P[6]=p,P[7]=w,P[8]=A,P[9]=x,P[10]=_,P[11]=h,P[12]=d,P[13]=D,P[14]=K,P[15]=G}function S(P,B){M(P,B,B)}function I(P,B){const U=i();for(let y=0;y<16;y++)U[y]=B[y];for(let y=253;y>=0;y--)S(U,U),y!==2&&y!==4&&M(U,U,B);for(let y=0;y<16;y++)P[y]=U[y]}function F(P,B){const U=new Uint8Array(32),y=new Float64Array(80),O=i(),Y=i(),Q=i(),N=i(),g=i(),a=i();for(let A=0;A<31;A++)U[A]=P[A];U[31]=P[31]&127|64,U[0]&=248,u(y,B);for(let A=0;A<16;A++)Y[A]=y[A];O[0]=N[0]=1;for(let A=254;A>=0;--A){const x=U[A>>>3]>>>(A&7)&1;c(O,Y,x),c(Q,N,x),b(g,O,Q),m(O,O,Q),b(Q,Y,N),m(Y,Y,N),S(N,g),S(a,O),M(O,Q,O),M(Q,Y,g),b(g,O,Q),m(O,O,Q),S(Y,O),m(Q,N,a),M(O,Q,s),b(O,O,N),M(Q,Q,O),M(O,N,a),M(N,Y,y),S(Y,g),c(O,Y,x),c(Q,N,x)}for(let A=0;A<16;A++)y[A+16]=O[A],y[A+32]=Q[A],y[A+48]=Y[A],y[A+64]=N[A];const f=y.subarray(32),p=y.subarray(16);I(f,f),M(p,p,f);const w=new Uint8Array(32);return l(w,p),w}t.scalarMult=F;function k(P){return F(P,n)}t.scalarMultBase=k;function j(P){if(P.length!==t.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${t.SECRET_KEY_LENGTH} bytes`);const B=new Uint8Array(P);return{publicKey:k(B),secretKey:B}}t.generateKeyPairFromSeed=j;function C(P){const B=(0,e.randomBytes)(32,P),U=j(B);return(0,r.wipe)(B),U}t.generateKeyPair=C;function $(P,B,U=!1){if(P.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(B.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");const y=F(P,B);if(U){let O=0;for(let Y=0;Y<y.length;Y++)O|=y[Y];if(O===0)throw new Error("X25519: invalid shared key")}return y}t.sharedKey=$})($o);var qh={},I2="elliptic",D2="6.5.7",O2="EC cryptography",R2="lib/elliptic.js",N2=["lib"],P2={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/"},T2={type:"git",url:"git@github.com:indutny/elliptic"},C2=["EC","Elliptic","curve","Cryptography"],F2="Fedor Indutny <fedor@indutny.com>",L2="MIT",B2={url:"https://github.com/indutny/elliptic/issues"},q2="https://github.com/indutny/elliptic",U2={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"},z2={"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"},k2={name:I2,version:D2,description:O2,main:R2,files:N2,scripts:P2,repository:T2,keywords:C2,author:F2,license:L2,bugs:B2,homepage:q2,devDependencies:U2,dependencies:z2},hr={},zr={exports:{}};(function(t){(function(e,r){function i(N,g){if(!N)throw new Error(g||"Assertion failed")}function n(N,g){N.super_=g;var a=function(){};a.prototype=g.prototype,N.prototype=new a,N.prototype.constructor=N}function s(N,g,a){if(s.isBN(N))return N;this.negative=0,this.words=null,this.length=0,this.red=null,N!==null&&((g==="le"||g==="be")&&(a=g,g=10),this._init(N||0,g||10,a||"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=Io.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,a){return g.cmp(a)>0?g:a},s.min=function(g,a){return g.cmp(a)<0?g:a},s.prototype._init=function(g,a,f){if(typeof g=="number")return this._initNumber(g,a,f);if(typeof g=="object")return this._initArray(g,a,f);a==="hex"&&(a=16),i(a===(a|0)&&a>=2&&a<=36),g=g.toString().replace(/\s+/g,"");var p=0;g[0]==="-"&&(p++,this.negative=1),p<g.length&&(a===16?this._parseHex(g,p,f):(this._parseBase(g,a,p),f==="le"&&this._initArray(this.toArray(),a,f)))},s.prototype._initNumber=function(g,a,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(),a,f)},s.prototype._initArray=function(g,a,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 p=0;p<this.length;p++)this.words[p]=0;var w,A,x=0;if(f==="be")for(p=g.length-1,w=0;p>=0;p-=3)A=g[p]|g[p-1]<<8|g[p-2]<<16,this.words[w]|=A<<x&67108863,this.words[w+1]=A>>>26-x&67108863,x+=24,x>=26&&(x-=26,w++);else if(f==="le")for(p=0,w=0;p<g.length;p+=3)A=g[p]|g[p+1]<<8|g[p+2]<<16,this.words[w]|=A<<x&67108863,this.words[w+1]=A>>>26-x&67108863,x+=24,x>=26&&(x-=26,w++);return this.strip()};function c(N,g){var a=N.charCodeAt(g);return a>=65&&a<=70?a-55:a>=97&&a<=102?a-87:a-48&15}function l(N,g,a){var f=c(N,a);return a-1>=g&&(f|=c(N,a-1)<<4),f}s.prototype._parseHex=function(g,a,f){this.length=Math.ceil((g.length-a)/6),this.words=new Array(this.length);for(var p=0;p<this.length;p++)this.words[p]=0;var w=0,A=0,x;if(f==="be")for(p=g.length-1;p>=a;p-=2)x=l(g,a,p)<<w,this.words[A]|=x&67108863,w>=18?(w-=18,A+=1,this.words[A]|=x>>>26):w+=8;else{var _=g.length-a;for(p=_%2===0?a+1:a;p<g.length;p+=2)x=l(g,a,p)<<w,this.words[A]|=x&67108863,w>=18?(w-=18,A+=1,this.words[A]|=x>>>26):w+=8}this.strip()};function u(N,g,a,f){for(var p=0,w=Math.min(N.length,a),A=g;A<w;A++){var x=N.charCodeAt(A)-48;p*=f,x>=49?p+=x-49+10:x>=17?p+=x-17+10:p+=x}return p}s.prototype._parseBase=function(g,a,f){this.words=[0],this.length=1;for(var p=0,w=1;w<=67108863;w*=a)p++;p--,w=w/a|0;for(var A=g.length-f,x=A%p,_=Math.min(A,A-x)+f,h=0,d=f;d<_;d+=p)h=u(g,d,d+p,a),this.imuln(w),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h);if(x!==0){var D=1;for(h=u(g,d,g.length,a),d=0;d<x;d++)D*=a;this.imuln(D),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h)}this.strip()},s.prototype.copy=function(g){g.words=new Array(this.length);for(var a=0;a<this.length;a++)g.words[a]=this.words[a];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 b=["","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"],m=[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,a){g=g||10,a=a|0||1;var f;if(g===16||g==="hex"){f="";for(var p=0,w=0,A=0;A<this.length;A++){var x=this.words[A],_=((x<<p|w)&16777215).toString(16);w=x>>>24-p&16777215,w!==0||A!==this.length-1?f=b[6-_.length]+_+f:f=_+f,p+=2,p>=26&&(p-=26,A--)}for(w!==0&&(f=w.toString(16)+f);f.length%a!==0;)f="0"+f;return this.negative!==0&&(f="-"+f),f}if(g===(g|0)&&g>=2&&g<=36){var h=m[g],d=M[g];f="";var D=this.clone();for(D.negative=0;!D.isZero();){var K=D.modn(d).toString(g);D=D.idivn(d),D.isZero()?f=K+f:f=b[h-K.length]+K+f}for(this.isZero()&&(f="0"+f);f.length%a!==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,a){return i(typeof o<"u"),this.toArrayLike(o,g,a)},s.prototype.toArray=function(g,a){return this.toArrayLike(Array,g,a)},s.prototype.toArrayLike=function(g,a,f){var p=this.byteLength(),w=f||Math.max(1,p);i(p<=w,"byte array longer than desired length"),i(w>0,"Requested array length <= 0"),this.strip();var A=a==="le",x=new g(w),_,h,d=this.clone();if(A){for(h=0;!d.isZero();h++)_=d.andln(255),d.iushrn(8),x[h]=_;for(;h<w;h++)x[h]=0}else{for(h=0;h<w-p;h++)x[h]=0;for(h=0;!d.isZero();h++)_=d.andln(255),d.iushrn(8),x[w-h-1]=_}return x},Math.clz32?s.prototype._countBits=function(g){return 32-Math.clz32(g)}:s.prototype._countBits=function(g){var a=g,f=0;return a>=4096&&(f+=13,a>>>=13),a>=64&&(f+=7,a>>>=7),a>=8&&(f+=4,a>>>=4),a>=2&&(f+=2,a>>>=2),f+a},s.prototype._zeroBits=function(g){if(g===0)return 26;var a=g,f=0;return a&8191||(f+=13,a>>>=13),a&127||(f+=7,a>>>=7),a&15||(f+=4,a>>>=4),a&3||(f+=2,a>>>=2),a&1||f++,f},s.prototype.bitLength=function(){var g=this.words[this.length-1],a=this._countBits(g);return(this.length-1)*26+a};function S(N){for(var g=new Array(N.bitLength()),a=0;a<g.length;a++){var f=a/26|0,p=a%26;g[a]=(N.words[f]&1<<p)>>>p}return g}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var g=0,a=0;a<this.length;a++){var f=this._zeroBits(this.words[a]);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 a=0;a<g.length;a++)this.words[a]=this.words[a]|g.words[a];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 a;this.length>g.length?a=g:a=this;for(var f=0;f<a.length;f++)this.words[f]=this.words[f]&g.words[f];return this.length=a.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 a,f;this.length>g.length?(a=this,f=g):(a=g,f=this);for(var p=0;p<f.length;p++)this.words[p]=a.words[p]^f.words[p];if(this!==a)for(;p<a.length;p++)this.words[p]=a.words[p];return this.length=a.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 a=Math.ceil(g/26)|0,f=g%26;this._expand(a),f>0&&a--;for(var p=0;p<a;p++)this.words[p]=~this.words[p]&67108863;return f>0&&(this.words[p]=~this.words[p]&67108863>>26-f),this.strip()},s.prototype.notn=function(g){return this.clone().inotn(g)},s.prototype.setn=function(g,a){i(typeof g=="number"&&g>=0);var f=g/26|0,p=g%26;return this._expand(f+1),a?this.words[f]=this.words[f]|1<<p:this.words[f]=this.words[f]&~(1<<p),this.strip()},s.prototype.iadd=function(g){var a;if(this.negative!==0&&g.negative===0)return this.negative=0,a=this.isub(g),this.negative^=1,this._normSign();if(this.negative===0&&g.negative!==0)return g.negative=0,a=this.isub(g),g.negative=1,a._normSign();var f,p;this.length>g.length?(f=this,p=g):(f=g,p=this);for(var w=0,A=0;A<p.length;A++)a=(f.words[A]|0)+(p.words[A]|0)+w,this.words[A]=a&67108863,w=a>>>26;for(;w!==0&&A<f.length;A++)a=(f.words[A]|0)+w,this.words[A]=a&67108863,w=a>>>26;if(this.length=f.length,w!==0)this.words[this.length]=w,this.length++;else if(f!==this)for(;A<f.length;A++)this.words[A]=f.words[A];return this},s.prototype.add=function(g){var a;return g.negative!==0&&this.negative===0?(g.negative=0,a=this.sub(g),g.negative^=1,a):g.negative===0&&this.negative!==0?(this.negative=0,a=g.sub(this),this.negative=1,a):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 a=this.iadd(g);return g.negative=1,a._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 p,w;f>0?(p=this,w=g):(p=g,w=this);for(var A=0,x=0;x<w.length;x++)a=(p.words[x]|0)-(w.words[x]|0)+A,A=a>>26,this.words[x]=a&67108863;for(;A!==0&&x<p.length;x++)a=(p.words[x]|0)+A,A=a>>26,this.words[x]=a&67108863;if(A===0&&x<p.length&&p!==this)for(;x<p.length;x++)this.words[x]=p.words[x];return this.length=Math.max(this.length,x),p!==this&&(this.negative=1),this.strip()},s.prototype.sub=function(g){return this.clone().isub(g)};function I(N,g,a){a.negative=g.negative^N.negative;var f=N.length+g.length|0;a.length=f,f=f-1|0;var p=N.words[0]|0,w=g.words[0]|0,A=p*w,x=A&67108863,_=A/67108864|0;a.words[0]=x;for(var h=1;h<f;h++){for(var d=_>>>26,D=_&67108863,K=Math.min(h,g.length-1),G=Math.max(0,h-N.length+1);G<=K;G++){var E=h-G|0;p=N.words[E]|0,w=g.words[G]|0,A=p*w+D,d+=A/67108864|0,D=A&67108863}a.words[h]=D|0,_=d|0}return _!==0?a.words[h]=_|0:a.length--,a.strip()}var F=function(g,a,f){var p=g.words,w=a.words,A=f.words,x=0,_,h,d,D=p[0]|0,K=D&8191,G=D>>>13,E=p[1]|0,H=E&8191,R=E>>>13,L=p[2]|0,q=L&8191,v=L>>>13,T=p[3]|0,W=T&8191,J=T>>>13,X=p[4]|0,se=X&8191,ne=X>>>13,Me=p[5]|0,Ce=Me&8191,ue=Me>>>13,xe=p[6]|0,Ae=xe&8191,re=xe>>>13,ve=p[7]|0,le=ve&8191,ee=ve>>>13,de=p[8]|0,fe=de&8191,te=de>>>13,Ee=p[9]|0,he=Ee&8191,ae=Ee>>>13,Se=w[0]|0,De=Se&8191,ce=Se>>>13,Ie=w[1]|0,We=Ie&8191,Oe=Ie>>>13,Qe=w[2]|0,He=Qe&8191,Re=Qe>>>13,tt=w[3]|0,rt=tt&8191,pe=tt>>>13,Pe=w[4]|0,Fe=Pe&8191,ge=Pe>>>13,Le=w[5]|0,Te=Le&8191,ye=Le>>>13,Ue=w[6]|0,ze=Ue&8191,we=Ue>>>13,ke=w[7]|0,Be=ke&8191,be=ke>>>13,Ne=w[8]|0,$e=Ne&8191,_e=Ne>>>13,it=w[9]|0,nt=it&8191,qe=it>>>13;f.negative=g.negative^a.negative,f.length=19,_=Math.imul(K,De),h=Math.imul(K,ce),h=h+Math.imul(G,De)|0,d=Math.imul(G,ce);var Ye=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(Ye>>>26)|0,Ye&=67108863,_=Math.imul(H,De),h=Math.imul(H,ce),h=h+Math.imul(R,De)|0,d=Math.imul(R,ce),_=_+Math.imul(K,We)|0,h=h+Math.imul(K,Oe)|0,h=h+Math.imul(G,We)|0,d=d+Math.imul(G,Oe)|0;var nr=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(nr>>>26)|0,nr&=67108863,_=Math.imul(q,De),h=Math.imul(q,ce),h=h+Math.imul(v,De)|0,d=Math.imul(v,ce),_=_+Math.imul(H,We)|0,h=h+Math.imul(H,Oe)|0,h=h+Math.imul(R,We)|0,d=d+Math.imul(R,Oe)|0,_=_+Math.imul(K,He)|0,h=h+Math.imul(K,Re)|0,h=h+Math.imul(G,He)|0,d=d+Math.imul(G,Re)|0;var sr=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(sr>>>26)|0,sr&=67108863,_=Math.imul(W,De),h=Math.imul(W,ce),h=h+Math.imul(J,De)|0,d=Math.imul(J,ce),_=_+Math.imul(q,We)|0,h=h+Math.imul(q,Oe)|0,h=h+Math.imul(v,We)|0,d=d+Math.imul(v,Oe)|0,_=_+Math.imul(H,He)|0,h=h+Math.imul(H,Re)|0,h=h+Math.imul(R,He)|0,d=d+Math.imul(R,Re)|0,_=_+Math.imul(K,rt)|0,h=h+Math.imul(K,pe)|0,h=h+Math.imul(G,rt)|0,d=d+Math.imul(G,pe)|0;var ar=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(ar>>>26)|0,ar&=67108863,_=Math.imul(se,De),h=Math.imul(se,ce),h=h+Math.imul(ne,De)|0,d=Math.imul(ne,ce),_=_+Math.imul(W,We)|0,h=h+Math.imul(W,Oe)|0,h=h+Math.imul(J,We)|0,d=d+Math.imul(J,Oe)|0,_=_+Math.imul(q,He)|0,h=h+Math.imul(q,Re)|0,h=h+Math.imul(v,He)|0,d=d+Math.imul(v,Re)|0,_=_+Math.imul(H,rt)|0,h=h+Math.imul(H,pe)|0,h=h+Math.imul(R,rt)|0,d=d+Math.imul(R,pe)|0,_=_+Math.imul(K,Fe)|0,h=h+Math.imul(K,ge)|0,h=h+Math.imul(G,Fe)|0,d=d+Math.imul(G,ge)|0;var or=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(or>>>26)|0,or&=67108863,_=Math.imul(Ce,De),h=Math.imul(Ce,ce),h=h+Math.imul(ue,De)|0,d=Math.imul(ue,ce),_=_+Math.imul(se,We)|0,h=h+Math.imul(se,Oe)|0,h=h+Math.imul(ne,We)|0,d=d+Math.imul(ne,Oe)|0,_=_+Math.imul(W,He)|0,h=h+Math.imul(W,Re)|0,h=h+Math.imul(J,He)|0,d=d+Math.imul(J,Re)|0,_=_+Math.imul(q,rt)|0,h=h+Math.imul(q,pe)|0,h=h+Math.imul(v,rt)|0,d=d+Math.imul(v,pe)|0,_=_+Math.imul(H,Fe)|0,h=h+Math.imul(H,ge)|0,h=h+Math.imul(R,Fe)|0,d=d+Math.imul(R,ge)|0,_=_+Math.imul(K,Te)|0,h=h+Math.imul(K,ye)|0,h=h+Math.imul(G,Te)|0,d=d+Math.imul(G,ye)|0;var cr=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(cr>>>26)|0,cr&=67108863,_=Math.imul(Ae,De),h=Math.imul(Ae,ce),h=h+Math.imul(re,De)|0,d=Math.imul(re,ce),_=_+Math.imul(Ce,We)|0,h=h+Math.imul(Ce,Oe)|0,h=h+Math.imul(ue,We)|0,d=d+Math.imul(ue,Oe)|0,_=_+Math.imul(se,He)|0,h=h+Math.imul(se,Re)|0,h=h+Math.imul(ne,He)|0,d=d+Math.imul(ne,Re)|0,_=_+Math.imul(W,rt)|0,h=h+Math.imul(W,pe)|0,h=h+Math.imul(J,rt)|0,d=d+Math.imul(J,pe)|0,_=_+Math.imul(q,Fe)|0,h=h+Math.imul(q,ge)|0,h=h+Math.imul(v,Fe)|0,d=d+Math.imul(v,ge)|0,_=_+Math.imul(H,Te)|0,h=h+Math.imul(H,ye)|0,h=h+Math.imul(R,Te)|0,d=d+Math.imul(R,ye)|0,_=_+Math.imul(K,ze)|0,h=h+Math.imul(K,we)|0,h=h+Math.imul(G,ze)|0,d=d+Math.imul(G,we)|0;var wt=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(wt>>>26)|0,wt&=67108863,_=Math.imul(le,De),h=Math.imul(le,ce),h=h+Math.imul(ee,De)|0,d=Math.imul(ee,ce),_=_+Math.imul(Ae,We)|0,h=h+Math.imul(Ae,Oe)|0,h=h+Math.imul(re,We)|0,d=d+Math.imul(re,Oe)|0,_=_+Math.imul(Ce,He)|0,h=h+Math.imul(Ce,Re)|0,h=h+Math.imul(ue,He)|0,d=d+Math.imul(ue,Re)|0,_=_+Math.imul(se,rt)|0,h=h+Math.imul(se,pe)|0,h=h+Math.imul(ne,rt)|0,d=d+Math.imul(ne,pe)|0,_=_+Math.imul(W,Fe)|0,h=h+Math.imul(W,ge)|0,h=h+Math.imul(J,Fe)|0,d=d+Math.imul(J,ge)|0,_=_+Math.imul(q,Te)|0,h=h+Math.imul(q,ye)|0,h=h+Math.imul(v,Te)|0,d=d+Math.imul(v,ye)|0,_=_+Math.imul(H,ze)|0,h=h+Math.imul(H,we)|0,h=h+Math.imul(R,ze)|0,d=d+Math.imul(R,we)|0,_=_+Math.imul(K,Be)|0,h=h+Math.imul(K,be)|0,h=h+Math.imul(G,Be)|0,d=d+Math.imul(G,be)|0;var Ei=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(Ei>>>26)|0,Ei&=67108863,_=Math.imul(fe,De),h=Math.imul(fe,ce),h=h+Math.imul(te,De)|0,d=Math.imul(te,ce),_=_+Math.imul(le,We)|0,h=h+Math.imul(le,Oe)|0,h=h+Math.imul(ee,We)|0,d=d+Math.imul(ee,Oe)|0,_=_+Math.imul(Ae,He)|0,h=h+Math.imul(Ae,Re)|0,h=h+Math.imul(re,He)|0,d=d+Math.imul(re,Re)|0,_=_+Math.imul(Ce,rt)|0,h=h+Math.imul(Ce,pe)|0,h=h+Math.imul(ue,rt)|0,d=d+Math.imul(ue,pe)|0,_=_+Math.imul(se,Fe)|0,h=h+Math.imul(se,ge)|0,h=h+Math.imul(ne,Fe)|0,d=d+Math.imul(ne,ge)|0,_=_+Math.imul(W,Te)|0,h=h+Math.imul(W,ye)|0,h=h+Math.imul(J,Te)|0,d=d+Math.imul(J,ye)|0,_=_+Math.imul(q,ze)|0,h=h+Math.imul(q,we)|0,h=h+Math.imul(v,ze)|0,d=d+Math.imul(v,we)|0,_=_+Math.imul(H,Be)|0,h=h+Math.imul(H,be)|0,h=h+Math.imul(R,Be)|0,d=d+Math.imul(R,be)|0,_=_+Math.imul(K,$e)|0,h=h+Math.imul(K,_e)|0,h=h+Math.imul(G,$e)|0,d=d+Math.imul(G,_e)|0;var xi=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(xi>>>26)|0,xi&=67108863,_=Math.imul(he,De),h=Math.imul(he,ce),h=h+Math.imul(ae,De)|0,d=Math.imul(ae,ce),_=_+Math.imul(fe,We)|0,h=h+Math.imul(fe,Oe)|0,h=h+Math.imul(te,We)|0,d=d+Math.imul(te,Oe)|0,_=_+Math.imul(le,He)|0,h=h+Math.imul(le,Re)|0,h=h+Math.imul(ee,He)|0,d=d+Math.imul(ee,Re)|0,_=_+Math.imul(Ae,rt)|0,h=h+Math.imul(Ae,pe)|0,h=h+Math.imul(re,rt)|0,d=d+Math.imul(re,pe)|0,_=_+Math.imul(Ce,Fe)|0,h=h+Math.imul(Ce,ge)|0,h=h+Math.imul(ue,Fe)|0,d=d+Math.imul(ue,ge)|0,_=_+Math.imul(se,Te)|0,h=h+Math.imul(se,ye)|0,h=h+Math.imul(ne,Te)|0,d=d+Math.imul(ne,ye)|0,_=_+Math.imul(W,ze)|0,h=h+Math.imul(W,we)|0,h=h+Math.imul(J,ze)|0,d=d+Math.imul(J,we)|0,_=_+Math.imul(q,Be)|0,h=h+Math.imul(q,be)|0,h=h+Math.imul(v,Be)|0,d=d+Math.imul(v,be)|0,_=_+Math.imul(H,$e)|0,h=h+Math.imul(H,_e)|0,h=h+Math.imul(R,$e)|0,d=d+Math.imul(R,_e)|0,_=_+Math.imul(K,nt)|0,h=h+Math.imul(K,qe)|0,h=h+Math.imul(G,nt)|0,d=d+Math.imul(G,qe)|0;var Si=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(Si>>>26)|0,Si&=67108863,_=Math.imul(he,We),h=Math.imul(he,Oe),h=h+Math.imul(ae,We)|0,d=Math.imul(ae,Oe),_=_+Math.imul(fe,He)|0,h=h+Math.imul(fe,Re)|0,h=h+Math.imul(te,He)|0,d=d+Math.imul(te,Re)|0,_=_+Math.imul(le,rt)|0,h=h+Math.imul(le,pe)|0,h=h+Math.imul(ee,rt)|0,d=d+Math.imul(ee,pe)|0,_=_+Math.imul(Ae,Fe)|0,h=h+Math.imul(Ae,ge)|0,h=h+Math.imul(re,Fe)|0,d=d+Math.imul(re,ge)|0,_=_+Math.imul(Ce,Te)|0,h=h+Math.imul(Ce,ye)|0,h=h+Math.imul(ue,Te)|0,d=d+Math.imul(ue,ye)|0,_=_+Math.imul(se,ze)|0,h=h+Math.imul(se,we)|0,h=h+Math.imul(ne,ze)|0,d=d+Math.imul(ne,we)|0,_=_+Math.imul(W,Be)|0,h=h+Math.imul(W,be)|0,h=h+Math.imul(J,Be)|0,d=d+Math.imul(J,be)|0,_=_+Math.imul(q,$e)|0,h=h+Math.imul(q,_e)|0,h=h+Math.imul(v,$e)|0,d=d+Math.imul(v,_e)|0,_=_+Math.imul(H,nt)|0,h=h+Math.imul(H,qe)|0,h=h+Math.imul(R,nt)|0,d=d+Math.imul(R,qe)|0;var Mi=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(Mi>>>26)|0,Mi&=67108863,_=Math.imul(he,He),h=Math.imul(he,Re),h=h+Math.imul(ae,He)|0,d=Math.imul(ae,Re),_=_+Math.imul(fe,rt)|0,h=h+Math.imul(fe,pe)|0,h=h+Math.imul(te,rt)|0,d=d+Math.imul(te,pe)|0,_=_+Math.imul(le,Fe)|0,h=h+Math.imul(le,ge)|0,h=h+Math.imul(ee,Fe)|0,d=d+Math.imul(ee,ge)|0,_=_+Math.imul(Ae,Te)|0,h=h+Math.imul(Ae,ye)|0,h=h+Math.imul(re,Te)|0,d=d+Math.imul(re,ye)|0,_=_+Math.imul(Ce,ze)|0,h=h+Math.imul(Ce,we)|0,h=h+Math.imul(ue,ze)|0,d=d+Math.imul(ue,we)|0,_=_+Math.imul(se,Be)|0,h=h+Math.imul(se,be)|0,h=h+Math.imul(ne,Be)|0,d=d+Math.imul(ne,be)|0,_=_+Math.imul(W,$e)|0,h=h+Math.imul(W,_e)|0,h=h+Math.imul(J,$e)|0,d=d+Math.imul(J,_e)|0,_=_+Math.imul(q,nt)|0,h=h+Math.imul(q,qe)|0,h=h+Math.imul(v,nt)|0,d=d+Math.imul(v,qe)|0;var Ii=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(Ii>>>26)|0,Ii&=67108863,_=Math.imul(he,rt),h=Math.imul(he,pe),h=h+Math.imul(ae,rt)|0,d=Math.imul(ae,pe),_=_+Math.imul(fe,Fe)|0,h=h+Math.imul(fe,ge)|0,h=h+Math.imul(te,Fe)|0,d=d+Math.imul(te,ge)|0,_=_+Math.imul(le,Te)|0,h=h+Math.imul(le,ye)|0,h=h+Math.imul(ee,Te)|0,d=d+Math.imul(ee,ye)|0,_=_+Math.imul(Ae,ze)|0,h=h+Math.imul(Ae,we)|0,h=h+Math.imul(re,ze)|0,d=d+Math.imul(re,we)|0,_=_+Math.imul(Ce,Be)|0,h=h+Math.imul(Ce,be)|0,h=h+Math.imul(ue,Be)|0,d=d+Math.imul(ue,be)|0,_=_+Math.imul(se,$e)|0,h=h+Math.imul(se,_e)|0,h=h+Math.imul(ne,$e)|0,d=d+Math.imul(ne,_e)|0,_=_+Math.imul(W,nt)|0,h=h+Math.imul(W,qe)|0,h=h+Math.imul(J,nt)|0,d=d+Math.imul(J,qe)|0;var Sr=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(Sr>>>26)|0,Sr&=67108863,_=Math.imul(he,Fe),h=Math.imul(he,ge),h=h+Math.imul(ae,Fe)|0,d=Math.imul(ae,ge),_=_+Math.imul(fe,Te)|0,h=h+Math.imul(fe,ye)|0,h=h+Math.imul(te,Te)|0,d=d+Math.imul(te,ye)|0,_=_+Math.imul(le,ze)|0,h=h+Math.imul(le,we)|0,h=h+Math.imul(ee,ze)|0,d=d+Math.imul(ee,we)|0,_=_+Math.imul(Ae,Be)|0,h=h+Math.imul(Ae,be)|0,h=h+Math.imul(re,Be)|0,d=d+Math.imul(re,be)|0,_=_+Math.imul(Ce,$e)|0,h=h+Math.imul(Ce,_e)|0,h=h+Math.imul(ue,$e)|0,d=d+Math.imul(ue,_e)|0,_=_+Math.imul(se,nt)|0,h=h+Math.imul(se,qe)|0,h=h+Math.imul(ne,nt)|0,d=d+Math.imul(ne,qe)|0;var Di=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(Di>>>26)|0,Di&=67108863,_=Math.imul(he,Te),h=Math.imul(he,ye),h=h+Math.imul(ae,Te)|0,d=Math.imul(ae,ye),_=_+Math.imul(fe,ze)|0,h=h+Math.imul(fe,we)|0,h=h+Math.imul(te,ze)|0,d=d+Math.imul(te,we)|0,_=_+Math.imul(le,Be)|0,h=h+Math.imul(le,be)|0,h=h+Math.imul(ee,Be)|0,d=d+Math.imul(ee,be)|0,_=_+Math.imul(Ae,$e)|0,h=h+Math.imul(Ae,_e)|0,h=h+Math.imul(re,$e)|0,d=d+Math.imul(re,_e)|0,_=_+Math.imul(Ce,nt)|0,h=h+Math.imul(Ce,qe)|0,h=h+Math.imul(ue,nt)|0,d=d+Math.imul(ue,qe)|0;var Oi=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(Oi>>>26)|0,Oi&=67108863,_=Math.imul(he,ze),h=Math.imul(he,we),h=h+Math.imul(ae,ze)|0,d=Math.imul(ae,we),_=_+Math.imul(fe,Be)|0,h=h+Math.imul(fe,be)|0,h=h+Math.imul(te,Be)|0,d=d+Math.imul(te,be)|0,_=_+Math.imul(le,$e)|0,h=h+Math.imul(le,_e)|0,h=h+Math.imul(ee,$e)|0,d=d+Math.imul(ee,_e)|0,_=_+Math.imul(Ae,nt)|0,h=h+Math.imul(Ae,qe)|0,h=h+Math.imul(re,nt)|0,d=d+Math.imul(re,qe)|0;var $t=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+($t>>>26)|0,$t&=67108863,_=Math.imul(he,Be),h=Math.imul(he,be),h=h+Math.imul(ae,Be)|0,d=Math.imul(ae,be),_=_+Math.imul(fe,$e)|0,h=h+Math.imul(fe,_e)|0,h=h+Math.imul(te,$e)|0,d=d+Math.imul(te,_e)|0,_=_+Math.imul(le,nt)|0,h=h+Math.imul(le,qe)|0,h=h+Math.imul(ee,nt)|0,d=d+Math.imul(ee,qe)|0;var Ri=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(Ri>>>26)|0,Ri&=67108863,_=Math.imul(he,$e),h=Math.imul(he,_e),h=h+Math.imul(ae,$e)|0,d=Math.imul(ae,_e),_=_+Math.imul(fe,nt)|0,h=h+Math.imul(fe,qe)|0,h=h+Math.imul(te,nt)|0,d=d+Math.imul(te,qe)|0;var Ni=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(Ni>>>26)|0,Ni&=67108863,_=Math.imul(he,nt),h=Math.imul(he,qe),h=h+Math.imul(ae,nt)|0,d=Math.imul(ae,qe);var Pi=(x+_|0)+((h&8191)<<13)|0;return x=(d+(h>>>13)|0)+(Pi>>>26)|0,Pi&=67108863,A[0]=Ye,A[1]=nr,A[2]=sr,A[3]=ar,A[4]=or,A[5]=cr,A[6]=wt,A[7]=Ei,A[8]=xi,A[9]=Si,A[10]=Mi,A[11]=Ii,A[12]=Sr,A[13]=Di,A[14]=Oi,A[15]=$t,A[16]=Ri,A[17]=Ni,A[18]=Pi,x!==0&&(A[19]=x,f.length++),f};Math.imul||(F=I);function k(N,g,a){a.negative=g.negative^N.negative,a.length=N.length+g.length;for(var f=0,p=0,w=0;w<a.length-1;w++){var A=p;p=0;for(var x=f&67108863,_=Math.min(w,g.length-1),h=Math.max(0,w-N.length+1);h<=_;h++){var d=w-h,D=N.words[d]|0,K=g.words[h]|0,G=D*K,E=G&67108863;A=A+(G/67108864|0)|0,E=E+x|0,x=E&67108863,A=A+(E>>>26)|0,p+=A>>>26,A&=67108863}a.words[w]=x,f=A,A=p}return f!==0?a.words[w]=f:a.length--,a.strip()}function j(N,g,a){var f=new C;return f.mulp(N,g,a)}s.prototype.mulTo=function(g,a){var f,p=this.length+g.length;return this.length===10&&g.length===10?f=F(this,g,a):p<63?f=I(this,g,a):p<1024?f=k(this,g,a):f=j(this,g,a),f};function C(N,g){this.x=N,this.y=g}C.prototype.makeRBT=function(g){for(var a=new Array(g),f=s.prototype._countBits(g)-1,p=0;p<g;p++)a[p]=this.revBin(p,f,g);return a},C.prototype.revBin=function(g,a,f){if(g===0||g===f-1)return g;for(var p=0,w=0;w<a;w++)p|=(g&1)<<a-w-1,g>>=1;return p},C.prototype.permute=function(g,a,f,p,w,A){for(var x=0;x<A;x++)p[x]=a[g[x]],w[x]=f[g[x]]},C.prototype.transform=function(g,a,f,p,w,A){this.permute(A,g,a,f,p,w);for(var x=1;x<w;x<<=1)for(var _=x<<1,h=Math.cos(2*Math.PI/_),d=Math.sin(2*Math.PI/_),D=0;D<w;D+=_)for(var K=h,G=d,E=0;E<x;E++){var H=f[D+E],R=p[D+E],L=f[D+E+x],q=p[D+E+x],v=K*L-G*q;q=K*q+G*L,L=v,f[D+E]=H+L,p[D+E]=R+q,f[D+E+x]=H-L,p[D+E+x]=R-q,E!==_&&(v=h*K-d*G,G=h*G+d*K,K=v)}},C.prototype.guessLen13b=function(g,a){var f=Math.max(a,g)|1,p=f&1,w=0;for(f=f/2|0;f;f=f>>>1)w++;return 1<<w+1+p},C.prototype.conjugate=function(g,a,f){if(!(f<=1))for(var p=0;p<f/2;p++){var w=g[p];g[p]=g[f-p-1],g[f-p-1]=w,w=a[p],a[p]=-a[f-p-1],a[f-p-1]=-w}},C.prototype.normalize13b=function(g,a){for(var f=0,p=0;p<a/2;p++){var w=Math.round(g[2*p+1]/a)*8192+Math.round(g[2*p]/a)+f;g[p]=w&67108863,w<67108864?f=0:f=w/67108864|0}return g},C.prototype.convert13b=function(g,a,f,p){for(var w=0,A=0;A<a;A++)w=w+(g[A]|0),f[2*A]=w&8191,w=w>>>13,f[2*A+1]=w&8191,w=w>>>13;for(A=2*a;A<p;++A)f[A]=0;i(w===0),i((w&-8192)===0)},C.prototype.stub=function(g){for(var a=new Array(g),f=0;f<g;f++)a[f]=0;return a},C.prototype.mulp=function(g,a,f){var p=2*this.guessLen13b(g.length,a.length),w=this.makeRBT(p),A=this.stub(p),x=new Array(p),_=new Array(p),h=new Array(p),d=new Array(p),D=new Array(p),K=new Array(p),G=f.words;G.length=p,this.convert13b(g.words,g.length,x,p),this.convert13b(a.words,a.length,d,p),this.transform(x,A,_,h,p,w),this.transform(d,A,D,K,p,w);for(var E=0;E<p;E++){var H=_[E]*D[E]-h[E]*K[E];h[E]=_[E]*K[E]+h[E]*D[E],_[E]=H}return this.conjugate(_,h,p),this.transform(_,h,G,A,p,w),this.conjugate(G,A,p),this.normalize13b(G,p),f.negative=g.negative^a.negative,f.length=g.length+a.length,f.strip()},s.prototype.mul=function(g){var a=new s(null);return a.words=new Array(this.length+g.length),this.mulTo(g,a)},s.prototype.mulf=function(g){var a=new s(null);return a.words=new Array(this.length+g.length),j(this,g,a)},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 a=0,f=0;f<this.length;f++){var p=(this.words[f]|0)*g,w=(p&67108863)+(a&67108863);a>>=26,a+=p/67108864|0,a+=w>>>26,this.words[f]=w&67108863}return a!==0&&(this.words[f]=a,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 a=S(g);if(a.length===0)return new s(1);for(var f=this,p=0;p<a.length&&a[p]===0;p++,f=f.sqr());if(++p<a.length)for(var w=f.sqr();p<a.length;p++,w=w.sqr())a[p]!==0&&(f=f.mul(w));return f},s.prototype.iushln=function(g){i(typeof g=="number"&&g>=0);var a=g%26,f=(g-a)/26,p=67108863>>>26-a<<26-a,w;if(a!==0){var A=0;for(w=0;w<this.length;w++){var x=this.words[w]&p,_=(this.words[w]|0)-x<<a;this.words[w]=_|A,A=x>>>26-a}A&&(this.words[w]=A,this.length++)}if(f!==0){for(w=this.length-1;w>=0;w--)this.words[w+f]=this.words[w];for(w=0;w<f;w++)this.words[w]=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,a,f){i(typeof g=="number"&&g>=0);var p;a?p=(a-a%26)/26:p=0;var w=g%26,A=Math.min((g-w)/26,this.length),x=67108863^67108863>>>w<<w,_=f;if(p-=A,p=Math.max(0,p),_){for(var h=0;h<A;h++)_.words[h]=this.words[h];_.length=A}if(A!==0)if(this.length>A)for(this.length-=A,h=0;h<this.length;h++)this.words[h]=this.words[h+A];else this.words[0]=0,this.length=1;var d=0;for(h=this.length-1;h>=0&&(d!==0||h>=p);h--){var D=this.words[h]|0;this.words[h]=d<<26-w|D>>>w,d=D&x}return _&&d!==0&&(_.words[_.length++]=d),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(g,a,f){return i(this.negative===0),this.iushrn(g,a,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 a=g%26,f=(g-a)/26,p=1<<a;if(this.length<=f)return!1;var w=this.words[f];return!!(w&p)},s.prototype.imaskn=function(g){i(typeof g=="number"&&g>=0);var a=g%26,f=(g-a)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=f)return this;if(a!==0&&f++,this.length=Math.min(f,this.length),a!==0){var p=67108863^67108863>>>a<<a;this.words[this.length-1]&=p}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 a=0;a<this.length&&this.words[a]>=67108864;a++)this.words[a]-=67108864,a===this.length-1?this.words[a+1]=1:this.words[a+1]++;return this.length=Math.max(this.length,a+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 a=0;a<this.length&&this.words[a]<0;a++)this.words[a]+=67108864,this.words[a+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,a,f){var p=g.length+f,w;this._expand(p);var A,x=0;for(w=0;w<g.length;w++){A=(this.words[w+f]|0)+x;var _=(g.words[w]|0)*a;A-=_&67108863,x=(A>>26)-(_/67108864|0),this.words[w+f]=A&67108863}for(;w<this.length-f;w++)A=(this.words[w+f]|0)+x,x=A>>26,this.words[w+f]=A&67108863;if(x===0)return this.strip();for(i(x===-1),x=0,w=0;w<this.length;w++)A=-(this.words[w]|0)+x,x=A>>26,this.words[w]=A&67108863;return this.negative=1,this.strip()},s.prototype._wordDiv=function(g,a){var f=this.length-g.length,p=this.clone(),w=g,A=w.words[w.length-1]|0,x=this._countBits(A);f=26-x,f!==0&&(w=w.ushln(f),p.iushln(f),A=w.words[w.length-1]|0);var _=p.length-w.length,h;if(a!=="mod"){h=new s(null),h.length=_+1,h.words=new Array(h.length);for(var d=0;d<h.length;d++)h.words[d]=0}var D=p.clone()._ishlnsubmul(w,1,_);D.negative===0&&(p=D,h&&(h.words[_]=1));for(var K=_-1;K>=0;K--){var G=(p.words[w.length+K]|0)*67108864+(p.words[w.length+K-1]|0);for(G=Math.min(G/A|0,67108863),p._ishlnsubmul(w,G,K);p.negative!==0;)G--,p.negative=0,p._ishlnsubmul(w,1,K),p.isZero()||(p.negative^=1);h&&(h.words[K]=G)}return h&&h.strip(),p.strip(),a!=="div"&&f!==0&&p.iushrn(f),{div:h||null,mod:p}},s.prototype.divmod=function(g,a,f){if(i(!g.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var p,w,A;return this.negative!==0&&g.negative===0?(A=this.neg().divmod(g,a),a!=="mod"&&(p=A.div.neg()),a!=="div"&&(w=A.mod.neg(),f&&w.negative!==0&&w.iadd(g)),{div:p,mod:w}):this.negative===0&&g.negative!==0?(A=this.divmod(g.neg(),a),a!=="mod"&&(p=A.div.neg()),{div:p,mod:A.mod}):this.negative&g.negative?(A=this.neg().divmod(g.neg(),a),a!=="div"&&(w=A.mod.neg(),f&&w.negative!==0&&w.isub(g)),{div:A.div,mod:w}):g.length>this.length||this.cmp(g)<0?{div:new s(0),mod:this}:g.length===1?a==="div"?{div:this.divn(g.words[0]),mod:null}:a==="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,a)},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 a=this.divmod(g);if(a.mod.isZero())return a.div;var f=a.div.negative!==0?a.mod.isub(g):a.mod,p=g.ushrn(1),w=g.andln(1),A=f.cmp(p);return A<0||w===1&&A===0?a.div:a.div.negative!==0?a.div.isubn(1):a.div.iaddn(1)},s.prototype.modn=function(g){i(g<=67108863);for(var a=(1<<26)%g,f=0,p=this.length-1;p>=0;p--)f=(a*f+(this.words[p]|0))%g;return f},s.prototype.idivn=function(g){i(g<=67108863);for(var a=0,f=this.length-1;f>=0;f--){var p=(this.words[f]|0)+a*67108864;this.words[f]=p/g|0,a=p%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 a=this,f=g.clone();a.negative!==0?a=a.umod(g):a=a.clone();for(var p=new s(1),w=new s(0),A=new s(0),x=new s(1),_=0;a.isEven()&&f.isEven();)a.iushrn(1),f.iushrn(1),++_;for(var h=f.clone(),d=a.clone();!a.isZero();){for(var D=0,K=1;!(a.words[0]&K)&&D<26;++D,K<<=1);if(D>0)for(a.iushrn(D);D-- >0;)(p.isOdd()||w.isOdd())&&(p.iadd(h),w.isub(d)),p.iushrn(1),w.iushrn(1);for(var G=0,E=1;!(f.words[0]&E)&&G<26;++G,E<<=1);if(G>0)for(f.iushrn(G);G-- >0;)(A.isOdd()||x.isOdd())&&(A.iadd(h),x.isub(d)),A.iushrn(1),x.iushrn(1);a.cmp(f)>=0?(a.isub(f),p.isub(A),w.isub(x)):(f.isub(a),A.isub(p),x.isub(w))}return{a:A,b:x,gcd:f.iushln(_)}},s.prototype._invmp=function(g){i(g.negative===0),i(!g.isZero());var a=this,f=g.clone();a.negative!==0?a=a.umod(g):a=a.clone();for(var p=new s(1),w=new s(0),A=f.clone();a.cmpn(1)>0&&f.cmpn(1)>0;){for(var x=0,_=1;!(a.words[0]&_)&&x<26;++x,_<<=1);if(x>0)for(a.iushrn(x);x-- >0;)p.isOdd()&&p.iadd(A),p.iushrn(1);for(var h=0,d=1;!(f.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(f.iushrn(h);h-- >0;)w.isOdd()&&w.iadd(A),w.iushrn(1);a.cmp(f)>=0?(a.isub(f),p.isub(w)):(f.isub(a),w.isub(p))}var D;return a.cmpn(1)===0?D=p:D=w,D.cmpn(0)<0&&D.iadd(g),D},s.prototype.gcd=function(g){if(this.isZero())return g.abs();if(g.isZero())return this.abs();var a=this.clone(),f=g.clone();a.negative=0,f.negative=0;for(var p=0;a.isEven()&&f.isEven();p++)a.iushrn(1),f.iushrn(1);do{for(;a.isEven();)a.iushrn(1);for(;f.isEven();)f.iushrn(1);var w=a.cmp(f);if(w<0){var A=a;a=f,f=A}else if(w===0||f.cmpn(1)===0)break;a.isub(f)}while(!0);return f.iushln(p)},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 a=g%26,f=(g-a)/26,p=1<<a;if(this.length<=f)return this._expand(f+1),this.words[f]|=p,this;for(var w=p,A=f;w!==0&&A<this.length;A++){var x=this.words[A]|0;x+=w,w=x>>>26,x&=67108863,this.words[A]=x}return w!==0&&(this.words[A]=w,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(g){var a=g<0;if(this.negative!==0&&!a)return-1;if(this.negative===0&&a)return 1;this.strip();var f;if(this.length>1)f=1;else{a&&(g=-g),i(g<=67108863,"Number is too big");var p=this.words[0]|0;f=p===g?0:p<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 a=this.ucmp(g);return this.negative!==0?-a|0:a},s.prototype.ucmp=function(g){if(this.length>g.length)return 1;if(this.length<g.length)return-1;for(var a=0,f=this.length-1;f>=0;f--){var p=this.words[f]|0,w=g.words[f]|0;if(p!==w){p<w?a=-1:p>w&&(a=1);break}}return a},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 Y(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 $={k256:null,p224:null,p192:null,p25519:null};function P(N,g){this.name=N,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()}P.prototype._tmp=function(){var g=new s(null);return g.words=new Array(Math.ceil(this.n/13)),g},P.prototype.ireduce=function(g){var a=g,f;do this.split(a,this.tmp),a=this.imulK(a),a=a.iadd(this.tmp),f=a.bitLength();while(f>this.n);var p=f<this.n?-1:a.ucmp(this.p);return p===0?(a.words[0]=0,a.length=1):p>0?a.isub(this.p):a.strip!==void 0?a.strip():a._strip(),a},P.prototype.split=function(g,a){g.iushrn(this.n,0,a)},P.prototype.imulK=function(g){return g.imul(this.k)};function B(){P.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(B,P),B.prototype.split=function(g,a){for(var f=4194303,p=Math.min(g.length,9),w=0;w<p;w++)a.words[w]=g.words[w];if(a.length=p,g.length<=9){g.words[0]=0,g.length=1;return}var A=g.words[9];for(a.words[a.length++]=A&f,w=10;w<g.length;w++){var x=g.words[w]|0;g.words[w-10]=(x&f)<<4|A>>>22,A=x}A>>>=22,g.words[w-10]=A,A===0&&g.length>10?g.length-=10:g.length-=9},B.prototype.imulK=function(g){g.words[g.length]=0,g.words[g.length+1]=0,g.length+=2;for(var a=0,f=0;f<g.length;f++){var p=g.words[f]|0;a+=p*977,g.words[f]=a&67108863,a=p*64+(a/67108864|0)}return g.words[g.length-1]===0&&(g.length--,g.words[g.length-1]===0&&g.length--),g};function U(){P.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(U,P);function y(){P.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(y,P);function O(){P.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(O,P),O.prototype.imulK=function(g){for(var a=0,f=0;f<g.length;f++){var p=(g.words[f]|0)*19+a,w=p&67108863;p>>>=26,g.words[f]=w,a=p}return a!==0&&(g.words[g.length++]=a),g},s._prime=function(g){if($[g])return $[g];var a;if(g==="k256")a=new B;else if(g==="p224")a=new U;else if(g==="p192")a=new y;else if(g==="p25519")a=new O;else throw new Error("Unknown prime "+g);return $[g]=a,a};function Y(N){if(typeof N=="string"){var g=s._prime(N);this.m=g.p,this.prime=g}else i(N.gtn(1),"modulus must be greater than 1"),this.m=N,this.prime=null}Y.prototype._verify1=function(g){i(g.negative===0,"red works only with positives"),i(g.red,"red works only with red numbers")},Y.prototype._verify2=function(g,a){i((g.negative|a.negative)===0,"red works only with positives"),i(g.red&&g.red===a.red,"red works only with red numbers")},Y.prototype.imod=function(g){return this.prime?this.prime.ireduce(g)._forceRed(this):g.umod(this.m)._forceRed(this)},Y.prototype.neg=function(g){return g.isZero()?g.clone():this.m.sub(g)._forceRed(this)},Y.prototype.add=function(g,a){this._verify2(g,a);var f=g.add(a);return f.cmp(this.m)>=0&&f.isub(this.m),f._forceRed(this)},Y.prototype.iadd=function(g,a){this._verify2(g,a);var f=g.iadd(a);return f.cmp(this.m)>=0&&f.isub(this.m),f},Y.prototype.sub=function(g,a){this._verify2(g,a);var f=g.sub(a);return f.cmpn(0)<0&&f.iadd(this.m),f._forceRed(this)},Y.prototype.isub=function(g,a){this._verify2(g,a);var f=g.isub(a);return f.cmpn(0)<0&&f.iadd(this.m),f},Y.prototype.shl=function(g,a){return this._verify1(g),this.imod(g.ushln(a))},Y.prototype.imul=function(g,a){return this._verify2(g,a),this.imod(g.imul(a))},Y.prototype.mul=function(g,a){return this._verify2(g,a),this.imod(g.mul(a))},Y.prototype.isqr=function(g){return this.imul(g,g.clone())},Y.prototype.sqr=function(g){return this.mul(g,g)},Y.prototype.sqrt=function(g){if(g.isZero())return g.clone();var a=this.m.andln(3);if(i(a%2===1),a===3){var f=this.m.add(new s(1)).iushrn(2);return this.pow(g,f)}for(var p=this.m.subn(1),w=0;!p.isZero()&&p.andln(1)===0;)w++,p.iushrn(1);i(!p.isZero());var A=new s(1).toRed(this),x=A.redNeg(),_=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new s(2*h*h).toRed(this);this.pow(h,_).cmp(x)!==0;)h.redIAdd(x);for(var d=this.pow(h,p),D=this.pow(g,p.addn(1).iushrn(1)),K=this.pow(g,p),G=w;K.cmp(A)!==0;){for(var E=K,H=0;E.cmp(A)!==0;H++)E=E.redSqr();i(H<G);var R=this.pow(d,new s(1).iushln(G-H-1));D=D.redMul(R),d=R.redSqr(),K=K.redMul(d),G=H}return D},Y.prototype.invm=function(g){var a=g._invmp(this.m);return a.negative!==0?(a.negative=0,this.imod(a).redNeg()):this.imod(a)},Y.prototype.pow=function(g,a){if(a.isZero())return new s(1).toRed(this);if(a.cmpn(1)===0)return g.clone();var f=4,p=new Array(1<<f);p[0]=new s(1).toRed(this),p[1]=g;for(var w=2;w<p.length;w++)p[w]=this.mul(p[w-1],g);var A=p[0],x=0,_=0,h=a.bitLength()%26;for(h===0&&(h=26),w=a.length-1;w>=0;w--){for(var d=a.words[w],D=h-1;D>=0;D--){var K=d>>D&1;if(A!==p[0]&&(A=this.sqr(A)),K===0&&x===0){_=0;continue}x<<=1,x|=K,_++,!(_!==f&&(w!==0||D!==0))&&(A=this.mul(A,p[x]),_=0,x=0)}h=26}return A},Y.prototype.convertTo=function(g){var a=g.umod(this.m);return a===g?a.clone():a},Y.prototype.convertFrom=function(g){var a=g.clone();return a.red=null,a},s.mont=function(g){return new Q(g)};function Q(N){Y.call(this,N),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(Q,Y),Q.prototype.convertTo=function(g){return this.imod(g.ushln(this.shift))},Q.prototype.convertFrom=function(g){var a=this.imod(g.mul(this.rinv));return a.red=null,a},Q.prototype.imul=function(g,a){if(g.isZero()||a.isZero())return g.words[0]=0,g.length=1,g;var f=g.imul(a),p=f.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),w=f.isub(p).iushrn(this.shift),A=w;return w.cmp(this.m)>=0?A=w.isub(this.m):w.cmpn(0)<0&&(A=w.iadd(this.m)),A._forceRed(this)},Q.prototype.mul=function(g,a){if(g.isZero()||a.isZero())return new s(0)._forceRed(this);var f=g.mul(a),p=f.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),w=f.isub(p).iushrn(this.shift),A=w;return w.cmp(this.m)>=0?A=w.isub(this.m):w.cmpn(0)<0&&(A=w.iadd(this.m)),A._forceRed(this)},Q.prototype.invm=function(g){var a=this.imod(g._invmp(this.m).mul(this.r2));return a._forceRed(this)}})(t,Kt)})(zr);var en=Uh;function Uh(t,e){if(!t)throw new Error(e||"Assertion failed")}Uh.equal=function(e,r,i){if(e!=r)throw new Error(i||"Assertion failed: "+e+" != "+r)};var jo={};(function(t){var e=t;function r(s,o){if(Array.isArray(s))return s.slice();if(!s)return[];var c=[];if(typeof s!="string"){for(var l=0;l<s.length;l++)c[l]=s[l]|0;return c}if(o==="hex"){s=s.replace(/[^a-z0-9]+/ig,""),s.length%2!==0&&(s="0"+s);for(var l=0;l<s.length;l+=2)c.push(parseInt(s[l]+s[l+1],16))}else for(var l=0;l<s.length;l++){var u=s.charCodeAt(l),b=u>>8,m=u&255;b?c.push(b,m):c.push(m)}return c}e.toArray=r;function i(s){return s.length===1?"0"+s:s}e.zero2=i;function n(s){for(var o="",c=0;c<s.length;c++)o+=i(s[c].toString(16));return o}e.toHex=n,e.encode=function(o,c){return c==="hex"?n(o):o}})(jo),function(t){var e=t,r=zr.exports,i=en,n=jo;e.assert=i,e.toArray=n.toArray,e.zero2=n.zero2,e.toHex=n.toHex,e.encode=n.encode;function s(b,m,M){var S=new Array(Math.max(b.bitLength(),M)+1),I;for(I=0;I<S.length;I+=1)S[I]=0;var F=1<<m+1,k=b.clone();for(I=0;I<S.length;I++){var j,C=k.andln(F-1);k.isOdd()?(C>(F>>1)-1?j=(F>>1)-C:j=C,k.isubn(j)):j=0,S[I]=j,k.iushrn(1)}return S}e.getNAF=s;function o(b,m){var M=[[],[]];b=b.clone(),m=m.clone();for(var S=0,I=0,F;b.cmpn(-S)>0||m.cmpn(-I)>0;){var k=b.andln(3)+S&3,j=m.andln(3)+I&3;k===3&&(k=-1),j===3&&(j=-1);var C;k&1?(F=b.andln(7)+S&7,(F===3||F===5)&&j===2?C=-k:C=k):C=0,M[0].push(C);var $;j&1?(F=m.andln(7)+I&7,(F===3||F===5)&&k===2?$=-j:$=j):$=0,M[1].push($),2*S===C+1&&(S=1-S),2*I===$+1&&(I=1-I),b.iushrn(1),m.iushrn(1)}return M}e.getJSF=o;function c(b,m,M){var S="_"+m;b.prototype[m]=function(){return this[S]!==void 0?this[S]:this[S]=M.call(this)}}e.cachedProperty=c;function l(b){return typeof b=="string"?e.toArray(b,"hex"):b}e.parseBytes=l;function u(b){return new r(b,"hex","le")}e.intFromLE=u}(hr);var ma={exports:{}},Ko;ma.exports=function(e){return Ko||(Ko=new Li(null)),Ko.generate(e)};function Li(t){this.rand=t}if(ma.exports.Rand=Li,Li.prototype.generate=function(e){return this._rand(e)},Li.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?Li.prototype._rand=function(e){var r=new Uint8Array(e);return self.crypto.getRandomValues(r),r}:self.msCrypto&&self.msCrypto.getRandomValues?Li.prototype._rand=function(e){var r=new Uint8Array(e);return self.msCrypto.getRandomValues(r),r}:typeof window=="object"&&(Li.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var zh=Io;if(typeof zh.randomBytes!="function")throw new Error("Not supported");Li.prototype._rand=function(e){return zh.randomBytes(e)}}catch{}var Ho={},tn=zr.exports,gs=hr,ya=gs.getNAF,$2=gs.getJSF,wa=gs.assert;function Bi(t,e){this.type=t,this.p=new tn(e.p,16),this.red=e.prime?tn.red(e.prime):tn.mont(this.p),this.zero=new tn(0).toRed(this.red),this.one=new tn(1).toRed(this.red),this.two=new tn(2).toRed(this.red),this.n=e.n&&new tn(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 _a=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){wa(e.precomputed);var i=e._getDoubles(),n=ya(r,1,this._bitLength),s=(1<<i.step+1)-(i.step%2===0?2:1);s/=3;var o=[],c,l;for(c=0;c<n.length;c+=i.step){l=0;for(var u=c+i.step-1;u>=c;u--)l=(l<<1)+n[u];o.push(l)}for(var b=this.jpoint(null,null,null),m=this.jpoint(null,null,null),M=s;M>0;M--){for(c=0;c<o.length;c++)l=o[c],l===M?m=m.mixedAdd(i.points[c]):l===-M&&(m=m.mixedAdd(i.points[c].neg()));b=b.add(m)}return b.toP()},Bi.prototype._wnafMul=function(e,r){var i=4,n=e._getNAFPoints(i);i=n.wnd;for(var s=n.points,o=ya(r,i,this._bitLength),c=this.jpoint(null,null,null),l=o.length-1;l>=0;l--){for(var u=0;l>=0&&o[l]===0;l--)u++;if(l>=0&&u++,c=c.dblp(u),l<0)break;var b=o[l];wa(b!==0),e.type==="affine"?b>0?c=c.mixedAdd(s[b-1>>1]):c=c.mixedAdd(s[-b-1>>1].neg()):b>0?c=c.add(s[b-1>>1]):c=c.add(s[-b-1>>1].neg())}return e.type==="affine"?c.toP():c},Bi.prototype._wnafMulAdd=function(e,r,i,n,s){var o=this._wnafT1,c=this._wnafT2,l=this._wnafT3,u=0,b,m,M;for(b=0;b<n;b++){M=r[b];var S=M._getNAFPoints(e);o[b]=S.wnd,c[b]=S.points}for(b=n-1;b>=1;b-=2){var I=b-1,F=b;if(o[I]!==1||o[F]!==1){l[I]=ya(i[I],o[I],this._bitLength),l[F]=ya(i[F],o[F],this._bitLength),u=Math.max(l[I].length,u),u=Math.max(l[F].length,u);continue}var k=[r[I],null,null,r[F]];r[I].y.cmp(r[F].y)===0?(k[1]=r[I].add(r[F]),k[2]=r[I].toJ().mixedAdd(r[F].neg())):r[I].y.cmp(r[F].y.redNeg())===0?(k[1]=r[I].toJ().mixedAdd(r[F]),k[2]=r[I].add(r[F].neg())):(k[1]=r[I].toJ().mixedAdd(r[F]),k[2]=r[I].toJ().mixedAdd(r[F].neg()));var j=[-3,-1,-5,-7,0,7,5,1,3],C=$2(i[I],i[F]);for(u=Math.max(C[0].length,u),l[I]=new Array(u),l[F]=new Array(u),m=0;m<u;m++){var $=C[0][m]|0,P=C[1][m]|0;l[I][m]=j[($+1)*3+(P+1)],l[F][m]=0,c[I]=k}}var B=this.jpoint(null,null,null),U=this._wnafT4;for(b=u;b>=0;b--){for(var y=0;b>=0;){var O=!0;for(m=0;m<n;m++)U[m]=l[m][b]|0,U[m]!==0&&(O=!1);if(!O)break;y++,b--}if(b>=0&&y++,B=B.dblp(y),b<0)break;for(m=0;m<n;m++){var Y=U[m];Y!==0&&(Y>0?M=c[m][Y-1>>1]:Y<0&&(M=c[m][-Y-1>>1].neg()),M.type==="affine"?B=B.mixedAdd(M):B=B.add(M))}}for(b=0;b<n;b++)c[b]=null;return s?B:B.toP()};function gr(t,e){this.curve=t,this.type=e,this.precomputed=null}Bi.BasePoint=gr,gr.prototype.eq=function(){throw new Error("Not implemented")},gr.prototype.validate=function(){return this.curve.validate(this)},Bi.prototype.decodePoint=function(e,r){e=gs.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?wa(e[e.length-1]%2===0):e[0]===7&&wa(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")},gr.prototype.encodeCompressed=function(e){return this.encode(e,!0)},gr.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))},gr.prototype.encode=function(e,r){return gs.encode(this._encode(r),e)},gr.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},gr.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},gr.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}},gr.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}},gr.prototype._getBeta=function(){return null},gr.prototype.dblp=function(e){for(var r=this,i=0;i<e;i++)r=r.dbl();return r};var Dn={exports:{}};typeof Object.create=="function"?Dn.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:Dn.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 j2=hr,pt=zr.exports,Vo=Dn.exports,On=_a,K2=j2.assert;function br(t){On.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)}Vo(br,On);var H2=br;br.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],K2(this.g.mul(i).x.cmp(this.g.x.redMul(r))===0))}var o;return e.basis?o=e.basis.map(function(c){return{a:new pt(c.a,16),b:new pt(c.b,16)}}):o=this._getEndoBasis(i),{beta:r,lambda:i,basis:o}}},br.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(),c=n.redSub(s).fromRed();return[o,c]},br.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),c=new pt(0),l=new pt(1),u,b,m,M,S,I,F,k=0,j,C;i.cmpn(0)!==0;){var $=n.div(i);j=n.sub($.mul(i)),C=c.sub($.mul(s));var P=l.sub($.mul(o));if(!m&&j.cmp(r)<0)u=F.neg(),b=s,m=j.neg(),M=C;else if(m&&++k===2)break;F=j,n=i,i=j,c=s,s=C,l=o,o=P}S=j.neg(),I=C;var B=m.sqr().add(M.sqr()),U=S.sqr().add(I.sqr());return U.cmp(B)>=0&&(S=u,I=b),m.negative&&(m=m.neg(),M=M.neg()),S.negative&&(S=S.neg(),I=I.neg()),[{a:m,b:M},{a:S,b:I}]},br.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),c=s.mul(i.a),l=o.mul(n.a),u=s.mul(i.b),b=o.mul(n.b),m=e.sub(c).sub(l),M=u.add(b).neg();return{k1:m,k2:M}},br.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)},br.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},br.prototype._endoWnafMulAdd=function(e,r,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o<e.length;o++){var c=this._endoSplit(r[o]),l=e[o],u=l._getBeta();c.k1.negative&&(c.k1.ineg(),l=l.neg(!0)),c.k2.negative&&(c.k2.ineg(),u=u.neg(!0)),n[o*2]=l,n[o*2+1]=u,s[o*2]=c.k1,s[o*2+1]=c.k2}for(var b=this._wnafMulAdd(1,n,s,o*2,i),m=0;m<o*2;m++)n[m]=null,s[m]=null;return b};function St(t,e,r,i){On.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)}Vo(St,On.BasePoint),br.prototype.point=function(e,r,i){return new St(this,e,r,i)},br.prototype.pointFromJSON=function(e,r){return St.fromJSON(this,e,r)},St.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}},St.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]},St.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(c){return e.point(c[0],c[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},St.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)+">"},St.prototype.isInfinity=function(){return this.inf},St.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)},St.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)),c=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,c)},St.prototype.getX=function(){return this.x.fromRed()},St.prototype.getY=function(){return this.y.fromRed()},St.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)},St.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)},St.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)},St.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)},St.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},St.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 Pt(t,e,r,i){On.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}Vo(Pt,On.BasePoint),br.prototype.jpoint=function(e,r,i){return new Pt(this,e,r,i)},Pt.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)},Pt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Pt.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)),c=e.y.redMul(i.redMul(this.z)),l=n.redSub(s),u=o.redSub(c);if(l.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var b=l.redSqr(),m=b.redMul(l),M=n.redMul(b),S=u.redSqr().redIAdd(m).redISub(M).redISub(M),I=u.redMul(M.redISub(S)).redISub(o.redMul(m)),F=this.z.redMul(e.z).redMul(l);return this.curve.jpoint(S,I,F)},Pt.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),c=i.redSub(n),l=s.redSub(o);if(c.cmpn(0)===0)return l.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var u=c.redSqr(),b=u.redMul(c),m=i.redMul(u),M=l.redSqr().redIAdd(b).redISub(m).redISub(m),S=l.redMul(m.redISub(M)).redISub(s.redMul(b)),I=this.z.redMul(c);return this.curve.jpoint(M,S,I)},Pt.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,c=this.y,l=this.z,u=l.redSqr().redSqr(),b=c.redAdd(c);for(r=0;r<e;r++){var m=o.redSqr(),M=b.redSqr(),S=M.redSqr(),I=m.redAdd(m).redIAdd(m).redIAdd(n.redMul(u)),F=o.redMul(M),k=I.redSqr().redISub(F.redAdd(F)),j=F.redISub(k),C=I.redMul(j);C=C.redIAdd(C).redISub(S);var $=b.redMul(l);r+1<e&&(u=u.redMul(S)),o=k,l=$,b=C}return this.curve.jpoint(o,b.redMul(s),l)},Pt.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},Pt.prototype._zeroDbl=function(){var e,r,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),c=this.x.redAdd(s).redSqr().redISub(n).redISub(o);c=c.redIAdd(c);var l=n.redAdd(n).redIAdd(n),u=l.redSqr().redISub(c).redISub(c),b=o.redIAdd(o);b=b.redIAdd(b),b=b.redIAdd(b),e=u,r=l.redMul(c.redISub(u)).redISub(b),i=this.y.redAdd(this.y)}else{var m=this.x.redSqr(),M=this.y.redSqr(),S=M.redSqr(),I=this.x.redAdd(M).redSqr().redISub(m).redISub(S);I=I.redIAdd(I);var F=m.redAdd(m).redIAdd(m),k=F.redSqr(),j=S.redIAdd(S);j=j.redIAdd(j),j=j.redIAdd(j),e=k.redISub(I).redISub(I),r=F.redMul(I.redISub(e)).redISub(j),i=this.y.redMul(this.z),i=i.redIAdd(i)}return this.curve.jpoint(e,r,i)},Pt.prototype._threeDbl=function(){var e,r,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),c=this.x.redAdd(s).redSqr().redISub(n).redISub(o);c=c.redIAdd(c);var l=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),u=l.redSqr().redISub(c).redISub(c);e=u;var b=o.redIAdd(o);b=b.redIAdd(b),b=b.redIAdd(b),r=l.redMul(c.redISub(u)).redISub(b),i=this.y.redAdd(this.y)}else{var m=this.z.redSqr(),M=this.y.redSqr(),S=this.x.redMul(M),I=this.x.redSub(m).redMul(this.x.redAdd(m));I=I.redAdd(I).redIAdd(I);var F=S.redIAdd(S);F=F.redIAdd(F);var k=F.redAdd(F);e=I.redSqr().redISub(k),i=this.y.redAdd(this.z).redSqr().redISub(M).redISub(m);var j=M.redSqr();j=j.redIAdd(j),j=j.redIAdd(j),j=j.redIAdd(j),r=I.redMul(F.redISub(e)).redISub(j)}return this.curve.jpoint(e,r,i)},Pt.prototype._dbl=function(){var e=this.curve.a,r=this.x,i=this.y,n=this.z,s=n.redSqr().redSqr(),o=r.redSqr(),c=i.redSqr(),l=o.redAdd(o).redIAdd(o).redIAdd(e.redMul(s)),u=r.redAdd(r);u=u.redIAdd(u);var b=u.redMul(c),m=l.redSqr().redISub(b.redAdd(b)),M=b.redISub(m),S=c.redSqr();S=S.redIAdd(S),S=S.redIAdd(S),S=S.redIAdd(S);var I=l.redMul(M).redISub(S),F=i.redAdd(i).redMul(n);return this.curve.jpoint(m,I,F)},Pt.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(),c=this.x.redAdd(r).redSqr().redISub(e).redISub(n);c=c.redIAdd(c),c=c.redAdd(c).redIAdd(c),c=c.redISub(o);var l=c.redSqr(),u=n.redIAdd(n);u=u.redIAdd(u),u=u.redIAdd(u),u=u.redIAdd(u);var b=s.redIAdd(c).redSqr().redISub(o).redISub(l).redISub(u),m=r.redMul(b);m=m.redIAdd(m),m=m.redIAdd(m);var M=this.x.redMul(l).redISub(m);M=M.redIAdd(M),M=M.redIAdd(M);var S=this.y.redMul(b.redMul(u.redISub(b)).redISub(c.redMul(l)));S=S.redIAdd(S),S=S.redIAdd(S),S=S.redIAdd(S);var I=this.z.redAdd(c).redSqr().redISub(i).redISub(l);return this.curve.jpoint(M,S,I)},Pt.prototype.mul=function(e,r){return e=new pt(e,r),this.curve._wnafMul(this,e)},Pt.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},Pt.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}},Pt.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)+">"},Pt.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Rn=zr.exports,kh=Dn.exports,Aa=_a,V2=hr;function Nn(t){Aa.call(this,"mont",t),this.a=new Rn(t.a,16).toRed(this.red),this.b=new Rn(t.b,16).toRed(this.red),this.i4=new Rn(4).toRed(this.red).redInvm(),this.two=new Rn(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}kh(Nn,Aa);var G2=Nn;Nn.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 Mt(t,e,r){Aa.BasePoint.call(this,t,"projective"),e===null&&r===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new Rn(e,16),this.z=new Rn(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}kh(Mt,Aa.BasePoint),Nn.prototype.decodePoint=function(e,r){return this.point(V2.toArray(e,r),1)},Nn.prototype.point=function(e,r){return new Mt(this,e,r)},Nn.prototype.pointFromJSON=function(e){return Mt.fromJSON(this,e)},Mt.prototype.precompute=function(){},Mt.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},Mt.fromJSON=function(e,r){return new Mt(e,r[0],r[1]||e.one)},Mt.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)+">"},Mt.prototype.isInfinity=function(){return this.z.cmpn(0)===0},Mt.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),c=s.redMul(n.redAdd(this.curve.a24.redMul(s)));return this.curve.point(o,c)},Mt.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Mt.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),c=o.redMul(i),l=s.redMul(n),u=r.z.redMul(c.redAdd(l).redSqr()),b=r.x.redMul(c.redISub(l).redSqr());return this.curve.point(u,b)},Mt.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 c=o.length-1;c>=0;c--)o[c]===0?(i=i.diffAdd(n,s),n=n.dbl()):(n=i.diffAdd(n,s),i=i.dbl());return n},Mt.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Mt.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},Mt.prototype.eq=function(e){return this.getX().cmp(e.getX())===0},Mt.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Mt.prototype.getX=function(){return this.normalize(),this.x.fromRed()};var W2=hr,ui=zr.exports,$h=Dn.exports,Ea=_a,Y2=W2.assert;function kr(t){this.twisted=(t.a|0)!==1,this.mOneA=this.twisted&&(t.a|0)===-1,this.extended=this.mOneA,Ea.call(this,"edwards",t),this.a=new ui(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new ui(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new ui(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),Y2(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(t.c|0)===1}$h(kr,Ea);var J2=kr;kr.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},kr.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},kr.prototype.jpoint=function(e,r,i,n){return this.point(e,r,i,n)},kr.prototype.pointFromX=function(e,r){e=new ui(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()),c=o.redSqrt();if(c.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");var l=c.fromRed().isOdd();return(r&&!l||!r&&l)&&(c=c.redNeg()),this.point(e,c)},kr.prototype.pointFromY=function(e,r){e=new ui(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 c=o.redSqrt();if(c.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");return c.fromRed().isOdd()!==r&&(c=c.redNeg()),this.point(c,e)},kr.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 ct(t,e,r,i,n){Ea.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 ui(e,16),this.y=new ui(r,16),this.z=i?new ui(i,16):this.curve.one,this.t=n&&new ui(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()))))}$h(ct,Ea.BasePoint),kr.prototype.pointFromJSON=function(e){return ct.fromJSON(this,e)},kr.prototype.point=function(e,r,i,n){return new ct(this,e,r,i,n)},ct.fromJSON=function(e,r){return new ct(e,r[0],r[1],r[2])},ct.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)+">"},ct.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},ct.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),c=o.redSub(i),l=n.redSub(r),u=s.redMul(c),b=o.redMul(l),m=s.redMul(l),M=c.redMul(o);return this.curve.point(u,b,M,m)},ct.prototype._projDbl=function(){var e=this.x.redAdd(this.y).redSqr(),r=this.x.redSqr(),i=this.y.redSqr(),n,s,o,c,l,u;if(this.curve.twisted){c=this.curve._mulA(r);var b=c.redAdd(i);this.zOne?(n=e.redSub(r).redSub(i).redMul(b.redSub(this.curve.two)),s=b.redMul(c.redSub(i)),o=b.redSqr().redSub(b).redSub(b)):(l=this.z.redSqr(),u=b.redSub(l).redISub(l),n=e.redSub(r).redISub(i).redMul(u),s=b.redMul(c.redSub(i)),o=b.redMul(u))}else c=r.redAdd(i),l=this.curve._mulC(this.z).redSqr(),u=c.redSub(l).redSub(l),n=this.curve._mulC(e.redISub(c)).redMul(u),s=this.curve._mulC(c).redMul(r.redISub(i)),o=c.redMul(u);return this.curve.point(n,s,o)},ct.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},ct.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),c=s.redSub(n),l=s.redAdd(n),u=i.redAdd(r),b=o.redMul(c),m=l.redMul(u),M=o.redMul(u),S=c.redMul(l);return this.curve.point(b,m,S,M)},ct.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),c=i.redSub(o),l=i.redAdd(o),u=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(n).redISub(s),b=r.redMul(c).redMul(u),m,M;return this.curve.twisted?(m=r.redMul(l).redMul(s.redSub(this.curve._mulA(n))),M=c.redMul(l)):(m=r.redMul(l).redMul(s.redSub(n)),M=this.curve._mulC(c).redMul(l)),this.curve.point(b,m,M)},ct.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},ct.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},ct.prototype.mulAdd=function(e,r,i){return this.curve._wnafMulAdd(1,[this,r],[e,i],2,!1)},ct.prototype.jmulAdd=function(e,r,i){return this.curve._wnafMulAdd(1,[this,r],[e,i],2,!0)},ct.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},ct.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},ct.prototype.getX=function(){return this.normalize(),this.x.fromRed()},ct.prototype.getY=function(){return this.normalize(),this.y.fromRed()},ct.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0},ct.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}},ct.prototype.toP=ct.prototype.normalize,ct.prototype.mixedAdd=ct.prototype.add,function(t){var e=t;e.base=_a,e.short=H2,e.mont=G2,e.edwards=J2}(Ho);var xa={},Sa={},Xe={},Q2=en,X2=Dn.exports;Xe.inherits=X2;function Z2(t,e){return(t.charCodeAt(e)&64512)!==55296||e<0||e+1>=t.length?!1:(t.charCodeAt(e+1)&64512)===56320}function e3(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):Z2(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}Xe.toArray=e3;function t3(t){for(var e="",r=0;r<t.length;r++)e+=Kh(t[r].toString(16));return e}Xe.toHex=t3;function jh(t){var e=t>>>24|t>>>8&65280|t<<8&16711680|(t&255)<<24;return e>>>0}Xe.htonl=jh;function r3(t,e){for(var r="",i=0;i<t.length;i++){var n=t[i];e==="little"&&(n=jh(n)),r+=Hh(n.toString(16))}return r}Xe.toHex32=r3;function Kh(t){return t.length===1?"0"+t:t}Xe.zero2=Kh;function Hh(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}Xe.zero8=Hh;function i3(t,e,r,i){var n=r-e;Q2(n%4===0);for(var s=new Array(n/4),o=0,c=e;o<s.length;o++,c+=4){var l;i==="big"?l=t[c]<<24|t[c+1]<<16|t[c+2]<<8|t[c+3]:l=t[c+3]<<24|t[c+2]<<16|t[c+1]<<8|t[c],s[o]=l>>>0}return s}Xe.join32=i3;function n3(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}Xe.split32=n3;function s3(t,e){return t>>>e|t<<32-e}Xe.rotr32=s3;function a3(t,e){return t<<e|t>>>32-e}Xe.rotl32=a3;function o3(t,e){return t+e>>>0}Xe.sum32=o3;function c3(t,e,r){return t+e+r>>>0}Xe.sum32_3=c3;function f3(t,e,r,i){return t+e+r+i>>>0}Xe.sum32_4=f3;function h3(t,e,r,i,n){return t+e+r+i+n>>>0}Xe.sum32_5=h3;function u3(t,e,r,i){var n=t[e],s=t[e+1],o=i+s>>>0,c=(o<i?1:0)+r+n;t[e]=c>>>0,t[e+1]=o}Xe.sum64=u3;function d3(t,e,r,i){var n=e+i>>>0,s=(n<e?1:0)+t+r;return s>>>0}Xe.sum64_hi=d3;function l3(t,e,r,i){var n=e+i;return n>>>0}Xe.sum64_lo=l3;function p3(t,e,r,i,n,s,o,c){var l=0,u=e;u=u+i>>>0,l+=u<e?1:0,u=u+s>>>0,l+=u<s?1:0,u=u+c>>>0,l+=u<c?1:0;var b=t+r+n+o+l;return b>>>0}Xe.sum64_4_hi=p3;function g3(t,e,r,i,n,s,o,c){var l=e+i+s+c;return l>>>0}Xe.sum64_4_lo=g3;function b3(t,e,r,i,n,s,o,c,l,u){var b=0,m=e;m=m+i>>>0,b+=m<e?1:0,m=m+s>>>0,b+=m<s?1:0,m=m+c>>>0,b+=m<c?1:0,m=m+u>>>0,b+=m<u?1:0;var M=t+r+n+o+l+b;return M>>>0}Xe.sum64_5_hi=b3;function v3(t,e,r,i,n,s,o,c,l,u){var b=e+i+s+c+u;return b>>>0}Xe.sum64_5_lo=v3;function m3(t,e,r){var i=e<<32-r|t>>>r;return i>>>0}Xe.rotr64_hi=m3;function y3(t,e,r){var i=t<<32-r|e>>>r;return i>>>0}Xe.rotr64_lo=y3;function w3(t,e,r){return t>>>r}Xe.shr64_hi=w3;function _3(t,e,r){var i=t<<32-r|e>>>r;return i>>>0}Xe.shr64_lo=_3;var Pn={},Vh=Xe,A3=en;function Ma(){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}Pn.BlockHash=Ma,Ma.prototype.update=function(e,r){if(e=Vh.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=Vh.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},Ma.prototype.digest=function(e){return this.update(this._pad()),A3(this.pending===null),this._digest(e)},Ma.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 Tn={},$r={},E3=Xe,jr=E3.rotr32;function x3(t,e,r,i){if(t===0)return Gh(e,r,i);if(t===1||t===3)return Yh(e,r,i);if(t===2)return Wh(e,r,i)}$r.ft_1=x3;function Gh(t,e,r){return t&e^~t&r}$r.ch32=Gh;function Wh(t,e,r){return t&e^t&r^e&r}$r.maj32=Wh;function Yh(t,e,r){return t^e^r}$r.p32=Yh;function S3(t){return jr(t,2)^jr(t,13)^jr(t,22)}$r.s0_256=S3;function M3(t){return jr(t,6)^jr(t,11)^jr(t,25)}$r.s1_256=M3;function I3(t){return jr(t,7)^jr(t,18)^t>>>3}$r.g0_256=I3;function D3(t){return jr(t,17)^jr(t,19)^t>>>10}$r.g1_256=D3;var Cn=Xe,O3=Pn,R3=$r,Go=Cn.rotl32,bs=Cn.sum32,N3=Cn.sum32_5,P3=R3.ft_1,Jh=O3.BlockHash,T3=[1518500249,1859775393,2400959708,3395469782];function Kr(){if(!(this instanceof Kr))return new Kr;Jh.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Cn.inherits(Kr,Jh);var C3=Kr;Kr.blockSize=512,Kr.outSize=160,Kr.hmacStrength=80,Kr.padLength=64,Kr.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]=Go(i[n-3]^i[n-8]^i[n-14]^i[n-16],1);var s=this.h[0],o=this.h[1],c=this.h[2],l=this.h[3],u=this.h[4];for(n=0;n<i.length;n++){var b=~~(n/20),m=N3(Go(s,5),P3(b,o,c,l),u,i[n],T3[b]);u=l,l=c,c=Go(o,30),o=s,s=m}this.h[0]=bs(this.h[0],s),this.h[1]=bs(this.h[1],o),this.h[2]=bs(this.h[2],c),this.h[3]=bs(this.h[3],l),this.h[4]=bs(this.h[4],u)},Kr.prototype._digest=function(e){return e==="hex"?Cn.toHex32(this.h,"big"):Cn.split32(this.h,"big")};var Fn=Xe,F3=Pn,Ln=$r,L3=en,Dr=Fn.sum32,B3=Fn.sum32_4,q3=Fn.sum32_5,U3=Ln.ch32,z3=Ln.maj32,k3=Ln.s0_256,$3=Ln.s1_256,j3=Ln.g0_256,K3=Ln.g1_256,Qh=F3.BlockHash,H3=[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 Hr(){if(!(this instanceof Hr))return new Hr;Qh.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=H3,this.W=new Array(64)}Fn.inherits(Hr,Qh);var Xh=Hr;Hr.blockSize=512,Hr.outSize=256,Hr.hmacStrength=192,Hr.padLength=64,Hr.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]=B3(K3(i[n-2]),i[n-7],j3(i[n-15]),i[n-16]);var s=this.h[0],o=this.h[1],c=this.h[2],l=this.h[3],u=this.h[4],b=this.h[5],m=this.h[6],M=this.h[7];for(L3(this.k.length===i.length),n=0;n<i.length;n++){var S=q3(M,$3(u),U3(u,b,m),this.k[n],i[n]),I=Dr(k3(s),z3(s,o,c));M=m,m=b,b=u,u=Dr(l,S),l=c,c=o,o=s,s=Dr(S,I)}this.h[0]=Dr(this.h[0],s),this.h[1]=Dr(this.h[1],o),this.h[2]=Dr(this.h[2],c),this.h[3]=Dr(this.h[3],l),this.h[4]=Dr(this.h[4],u),this.h[5]=Dr(this.h[5],b),this.h[6]=Dr(this.h[6],m),this.h[7]=Dr(this.h[7],M)},Hr.prototype._digest=function(e){return e==="hex"?Fn.toHex32(this.h,"big"):Fn.split32(this.h,"big")};var Wo=Xe,Zh=Xh;function di(){if(!(this instanceof di))return new di;Zh.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}Wo.inherits(di,Zh);var V3=di;di.blockSize=512,di.outSize=224,di.hmacStrength=192,di.padLength=64,di.prototype._digest=function(e){return e==="hex"?Wo.toHex32(this.h.slice(0,7),"big"):Wo.split32(this.h.slice(0,7),"big")};var Zt=Xe,G3=Pn,W3=en,Vr=Zt.rotr64_hi,Gr=Zt.rotr64_lo,eu=Zt.shr64_hi,tu=Zt.shr64_lo,qi=Zt.sum64,Yo=Zt.sum64_hi,Jo=Zt.sum64_lo,Y3=Zt.sum64_4_hi,J3=Zt.sum64_4_lo,Q3=Zt.sum64_5_hi,X3=Zt.sum64_5_lo,ru=G3.BlockHash,Z3=[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 Or(){if(!(this instanceof Or))return new Or;ru.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=Z3,this.W=new Array(160)}Zt.inherits(Or,ru);var iu=Or;Or.blockSize=1024,Or.outSize=512,Or.hmacStrength=192,Or.padLength=128,Or.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=hv(i[n-4],i[n-3]),o=uv(i[n-4],i[n-3]),c=i[n-14],l=i[n-13],u=cv(i[n-30],i[n-29]),b=fv(i[n-30],i[n-29]),m=i[n-32],M=i[n-31];i[n]=Y3(s,o,c,l,u,b,m,M),i[n+1]=J3(s,o,c,l,u,b,m,M)}},Or.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],c=this.h[3],l=this.h[4],u=this.h[5],b=this.h[6],m=this.h[7],M=this.h[8],S=this.h[9],I=this.h[10],F=this.h[11],k=this.h[12],j=this.h[13],C=this.h[14],$=this.h[15];W3(this.k.length===i.length);for(var P=0;P<i.length;P+=2){var B=C,U=$,y=av(M,S),O=ov(M,S),Y=ev(M,S,I,F,k),Q=tv(M,S,I,F,k,j),N=this.k[P],g=this.k[P+1],a=i[P],f=i[P+1],p=Q3(B,U,y,O,Y,Q,N,g,a,f),w=X3(B,U,y,O,Y,Q,N,g,a,f);B=nv(n,s),U=sv(n,s),y=rv(n,s,o,c,l),O=iv(n,s,o,c,l,u);var A=Yo(B,U,y,O),x=Jo(B,U,y,O);C=k,$=j,k=I,j=F,I=M,F=S,M=Yo(b,m,p,w),S=Jo(m,m,p,w),b=l,m=u,l=o,u=c,o=n,c=s,n=Yo(p,w,A,x),s=Jo(p,w,A,x)}qi(this.h,0,n,s),qi(this.h,2,o,c),qi(this.h,4,l,u),qi(this.h,6,b,m),qi(this.h,8,M,S),qi(this.h,10,I,F),qi(this.h,12,k,j),qi(this.h,14,C,$)},Or.prototype._digest=function(e){return e==="hex"?Zt.toHex32(this.h,"big"):Zt.split32(this.h,"big")};function ev(t,e,r,i,n){var s=t&r^~t&n;return s<0&&(s+=4294967296),s}function tv(t,e,r,i,n,s){var o=e&i^~e&s;return o<0&&(o+=4294967296),o}function rv(t,e,r,i,n){var s=t&r^t&n^r&n;return s<0&&(s+=4294967296),s}function iv(t,e,r,i,n,s){var o=e&i^e&s^i&s;return o<0&&(o+=4294967296),o}function nv(t,e){var r=Vr(t,e,28),i=Vr(e,t,2),n=Vr(e,t,7),s=r^i^n;return s<0&&(s+=4294967296),s}function sv(t,e){var r=Gr(t,e,28),i=Gr(e,t,2),n=Gr(e,t,7),s=r^i^n;return s<0&&(s+=4294967296),s}function av(t,e){var r=Vr(t,e,14),i=Vr(t,e,18),n=Vr(e,t,9),s=r^i^n;return s<0&&(s+=4294967296),s}function ov(t,e){var r=Gr(t,e,14),i=Gr(t,e,18),n=Gr(e,t,9),s=r^i^n;return s<0&&(s+=4294967296),s}function cv(t,e){var r=Vr(t,e,1),i=Vr(t,e,8),n=eu(t,e,7),s=r^i^n;return s<0&&(s+=4294967296),s}function fv(t,e){var r=Gr(t,e,1),i=Gr(t,e,8),n=tu(t,e,7),s=r^i^n;return s<0&&(s+=4294967296),s}function hv(t,e){var r=Vr(t,e,19),i=Vr(e,t,29),n=eu(t,e,6),s=r^i^n;return s<0&&(s+=4294967296),s}function uv(t,e){var r=Gr(t,e,19),i=Gr(e,t,29),n=tu(t,e,6),s=r^i^n;return s<0&&(s+=4294967296),s}var Qo=Xe,nu=iu;function li(){if(!(this instanceof li))return new li;nu.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Qo.inherits(li,nu);var dv=li;li.blockSize=1024,li.outSize=384,li.hmacStrength=192,li.padLength=128,li.prototype._digest=function(e){return e==="hex"?Qo.toHex32(this.h.slice(0,12),"big"):Qo.split32(this.h.slice(0,12),"big")},Tn.sha1=C3,Tn.sha224=V3,Tn.sha256=Xh,Tn.sha384=dv,Tn.sha512=iu;var su={},rn=Xe,lv=Pn,Ia=rn.rotl32,au=rn.sum32,vs=rn.sum32_3,ou=rn.sum32_4,cu=lv.BlockHash;function Wr(){if(!(this instanceof Wr))return new Wr;cu.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}rn.inherits(Wr,cu),su.ripemd160=Wr,Wr.blockSize=512,Wr.outSize=160,Wr.hmacStrength=192,Wr.padLength=64,Wr.prototype._update=function(e,r){for(var i=this.h[0],n=this.h[1],s=this.h[2],o=this.h[3],c=this.h[4],l=i,u=n,b=s,m=o,M=c,S=0;S<80;S++){var I=au(Ia(ou(i,fu(S,n,s,o),e[bv[S]+r],pv(S)),mv[S]),c);i=c,c=o,o=Ia(s,10),s=n,n=I,I=au(Ia(ou(l,fu(79-S,u,b,m),e[vv[S]+r],gv(S)),yv[S]),M),l=M,M=m,m=Ia(b,10),b=u,u=I}I=vs(this.h[1],s,m),this.h[1]=vs(this.h[2],o,M),this.h[2]=vs(this.h[3],c,l),this.h[3]=vs(this.h[4],i,u),this.h[4]=vs(this.h[0],n,b),this.h[0]=I},Wr.prototype._digest=function(e){return e==="hex"?rn.toHex32(this.h,"little"):rn.split32(this.h,"little")};function fu(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 pv(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function gv(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}var bv=[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],vv=[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],mv=[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],yv=[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],wv=Xe,_v=en;function Bn(t,e,r){if(!(this instanceof Bn))return new Bn(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(wv.toArray(e,r))}var Av=Bn;Bn.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),_v(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)},Bn.prototype.update=function(e,r){return this.inner.update(e,r),this},Bn.prototype.digest=function(e){return this.outer.update(this.inner.digest()),this.outer.digest(e)},function(t){var e=t;e.utils=Xe,e.common=Pn,e.sha=Tn,e.ripemd=su,e.hmac=Av,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}(Sa);var Xo,hu;function Ev(){return hu||(hu=1,Xo={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"]]}}),Xo}(function(t){var e=t,r=Sa,i=Ho,n=hr,s=n.assert;function o(u){u.type==="short"?this.curve=new i.short(u):u.type==="edwards"?this.curve=new i.edwards(u):this.curve=new i.mont(u),this.g=this.curve.g,this.n=this.curve.n,this.hash=u.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}e.PresetCurve=o;function c(u,b){Object.defineProperty(e,u,{configurable:!0,enumerable:!0,get:function(){var m=new o(b);return Object.defineProperty(e,u,{configurable:!0,enumerable:!0,value:m}),m}})}c("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"]}),c("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"]}),c("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"]}),c("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"]}),c("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"]}),c("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"]}),c("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 l;try{l=Ev()}catch{l=void 0}c("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",l]})})(xa);var xv=Sa,nn=jo,uu=en;function Ui(t){if(!(this instanceof Ui))return new Ui(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=nn.toArray(t.entropy,t.entropyEnc||"hex"),r=nn.toArray(t.nonce,t.nonceEnc||"hex"),i=nn.toArray(t.pers,t.persEnc||"hex");uu(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,i)}var Sv=Ui;Ui.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},Ui.prototype._hmac=function(){return new xv.hmac(this.hash,this.K)},Ui.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())},Ui.prototype.reseed=function(e,r,i,n){typeof r!="string"&&(n=i,i=r,r=null),e=nn.toArray(e,r),i=nn.toArray(i,n),uu(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1},Ui.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=nn.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++,nn.encode(o,r)};var Mv=zr.exports,Iv=hr,Zo=Iv.assert;function zt(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 Dv=zt;zt.fromPublic=function(e,r,i){return r instanceof zt?r:new zt(e,{pub:r,pubEnc:i})},zt.fromPrivate=function(e,r,i){return r instanceof zt?r:new zt(e,{priv:r,privEnc:i})},zt.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"}},zt.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},zt.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv},zt.prototype._importPrivate=function(e,r){this.priv=new Mv(e,r||16),this.priv=this.priv.umod(this.ec.curve.n)},zt.prototype._importPublic=function(e,r){if(e.x||e.y){this.ec.curve.type==="mont"?Zo(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&Zo(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)},zt.prototype.derive=function(e){return e.validate()||Zo(e.validate(),"public point not validated"),e.mul(this.priv).getX()},zt.prototype.sign=function(e,r,i){return this.ec.sign(e,this,r,i)},zt.prototype.verify=function(e,r){return this.ec.verify(e,r,this)},zt.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var Da=zr.exports,ec=hr,Ov=ec.assert;function Oa(t,e){if(t instanceof Oa)return t;this._importDER(t,e)||(Ov(t.r&&t.s,"Signature without r or s"),this.r=new Da(t.r,16),this.s=new Da(t.s,16),t.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var Rv=Oa;function Nv(){this.place=0}function tc(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 du(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)}Oa.prototype._importDER=function(e,r){e=ec.toArray(e,r);var i=new Nv;if(e[i.place++]!==48)return!1;var n=tc(e,i);if(n===!1||n+i.place!==e.length||e[i.place++]!==2)return!1;var s=tc(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 c=tc(e,i);if(c===!1||e.length!==c+i.place||e[i.place]&128)return!1;var l=e.slice(i.place,c+i.place);if(o[0]===0)if(o[1]&128)o=o.slice(1);else return!1;if(l[0]===0)if(l[1]&128)l=l.slice(1);else return!1;return this.r=new Da(o),this.s=new Da(l),this.recoveryParam=null,!0};function rc(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)}Oa.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=du(r),i=du(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];rc(n,r.length),n=n.concat(r),n.push(2),rc(n,i.length);var s=n.concat(i),o=[48];return rc(o,s.length),o=o.concat(s),ec.encode(o,e)};var sn=zr.exports,lu=Sv,Pv=hr,ic=xa,Tv=ma.exports,pu=Pv.assert,nc=Dv,Ra=Rv;function vr(t){if(!(this instanceof vr))return new vr(t);typeof t=="string"&&(pu(Object.prototype.hasOwnProperty.call(ic,t),"Unknown curve "+t),t=ic[t]),t instanceof ic.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 Cv=vr;vr.prototype.keyPair=function(e){return new nc(this,e)},vr.prototype.keyFromPrivate=function(e,r){return nc.fromPrivate(this,e,r)},vr.prototype.keyFromPublic=function(e,r){return nc.fromPublic(this,e,r)},vr.prototype.genKeyPair=function(e){e||(e={});for(var r=new lu({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||Tv(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new sn(2));;){var s=new sn(r.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}},vr.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},vr.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 sn(e,16));for(var s=this.n.byteLength(),o=r.getPrivate().toArray("be",s),c=e.toArray("be",s),l=new lu({hash:this.hash,entropy:o,nonce:c,pers:n.pers,persEnc:n.persEnc||"utf8"}),u=this.n.sub(new sn(1)),b=0;;b++){var m=n.k?n.k(b):new sn(l.generate(this.n.byteLength()));if(m=this._truncateToN(m,!0),!(m.cmpn(1)<=0||m.cmp(u)>=0)){var M=this.g.mul(m);if(!M.isInfinity()){var S=M.getX(),I=S.umod(this.n);if(I.cmpn(0)!==0){var F=m.invm(this.n).mul(I.mul(r.getPrivate()).iadd(e));if(F=F.umod(this.n),F.cmpn(0)!==0){var k=(M.getY().isOdd()?1:0)|(S.cmp(I)!==0?2:0);return n.canonical&&F.cmp(this.nh)>0&&(F=this.n.sub(F),k^=1),new Ra({r:I,s:F,recoveryParam:k})}}}}}},vr.prototype.verify=function(e,r,i,n){e=this._truncateToN(new sn(e,16)),i=this.keyFromPublic(i,n),r=new Ra(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 c=o.invm(this.n),l=c.mul(e).umod(this.n),u=c.mul(s).umod(this.n),b;return this.curve._maxwellTrick?(b=this.g.jmulAdd(l,i.getPublic(),u),b.isInfinity()?!1:b.eqXToP(s)):(b=this.g.mulAdd(l,i.getPublic(),u),b.isInfinity()?!1:b.getX().umod(this.n).cmp(s)===0)},vr.prototype.recoverPubKey=function(t,e,r,i){pu((3&r)===r,"The recovery param is more than two bits"),e=new Ra(e,i);var n=this.n,s=new sn(t),o=e.r,c=e.s,l=r&1,u=r>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");u?o=this.curve.pointFromX(o.add(this.curve.n),l):o=this.curve.pointFromX(o,l);var b=e.r.invm(n),m=n.sub(s).mul(b).umod(n),M=c.mul(b).umod(n);return this.g.mulAdd(m,o,M)},vr.prototype.getKeyRecoveryParam=function(t,e,r,i){if(e=new Ra(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 ms=hr,gu=ms.assert,bu=ms.parseBytes,qn=ms.cachedProperty;function It(t,e){this.eddsa=t,this._secret=bu(e.secret),t.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=bu(e.pub)}It.fromPublic=function(e,r){return r instanceof It?r:new It(e,{pub:r})},It.fromSecret=function(e,r){return r instanceof It?r:new It(e,{secret:r})},It.prototype.secret=function(){return this._secret},qn(It,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),qn(It,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),qn(It,"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}),qn(It,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),qn(It,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),qn(It,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),It.prototype.sign=function(e){return gu(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)},It.prototype.verify=function(e,r){return this.eddsa.verify(e,r,this)},It.prototype.getSecret=function(e){return gu(this._secret,"KeyPair is public only"),ms.encode(this.secret(),e)},It.prototype.getPublic=function(e){return ms.encode(this.pubBytes(),e)};var Fv=It,Lv=zr.exports,Na=hr,vu=Na.assert,Pa=Na.cachedProperty,Bv=Na.parseBytes;function an(t,e){this.eddsa=t,typeof e!="object"&&(e=Bv(e)),Array.isArray(e)&&(vu(e.length===t.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,t.encodingLength),S:e.slice(t.encodingLength)}),vu(e.R&&e.S,"Signature without R or S"),t.isPoint(e.R)&&(this._R=e.R),e.S instanceof Lv&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}Pa(an,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),Pa(an,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),Pa(an,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),Pa(an,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),an.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},an.prototype.toHex=function(){return Na.encode(this.toBytes(),"hex").toUpperCase()};var qv=an,Uv=Sa,zv=xa,Un=hr,kv=Un.assert,mu=Un.parseBytes,yu=Fv,wu=qv;function er(t){if(kv(t==="ed25519","only tested with ed25519 so far"),!(this instanceof er))return new er(t);t=zv[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=Uv.sha512}var $v=er;er.prototype.sign=function(e,r){e=mu(e);var i=this.keyFromSecret(r),n=this.hashInt(i.messagePrefix(),e),s=this.g.mul(n),o=this.encodePoint(s),c=this.hashInt(o,i.pubBytes(),e).mul(i.priv()),l=n.add(c).umod(this.curve.n);return this.makeSignature({R:s,S:l,Rencoded:o})},er.prototype.verify=function(e,r,i){if(e=mu(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()),c=r.R().add(n.pub().mul(s));return c.eq(o)},er.prototype.hashInt=function(){for(var e=this.hash(),r=0;r<arguments.length;r++)e.update(arguments[r]);return Un.intFromLE(e.digest()).umod(this.curve.n)},er.prototype.keyFromPublic=function(e){return yu.fromPublic(this,e)},er.prototype.keyFromSecret=function(e){return yu.fromSecret(this,e)},er.prototype.makeSignature=function(e){return e instanceof wu?e:new wu(this,e)},er.prototype.encodePoint=function(e){var r=e.getY().toArray("le",this.encodingLength);return r[this.encodingLength-1]|=e.getX().isOdd()?128:0,r},er.prototype.decodePoint=function(e){e=Un.parseBytes(e);var r=e.length-1,i=e.slice(0,r).concat(e[r]&-129),n=(e[r]&128)!==0,s=Un.intFromLE(i);return this.curve.pointFromY(s,n)},er.prototype.encodeInt=function(e){return e.toArray("le",this.encodingLength)},er.prototype.decodeInt=function(e){return Un.intFromLE(e)},er.prototype.isPoint=function(e){return e instanceof this.pointClass},function(t){var e=t;e.version=k2.version,e.utils=hr,e.rand=ma.exports,e.curve=Ho,e.curves=xa,e.ec=Cv,e.eddsa=$v}(qh);const jv={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"}},Kv=":";function sc(t){const[e,r]=t.split(Kv);return{namespace:e,reference:r}}function _u(t,e){return t.includes(":")?[t]:e.chains||[]}var Hv=Object.defineProperty,Au=Object.getOwnPropertySymbols,Vv=Object.prototype.hasOwnProperty,Gv=Object.prototype.propertyIsEnumerable,Eu=(t,e,r)=>e in t?Hv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,xu=(t,e)=>{for(var r in e||(e={}))Vv.call(e,r)&&Eu(t,r,e[r]);if(Au)for(var r of Au(e))Gv.call(e,r)&&Eu(t,r,e[r]);return t};const Wv="ReactNative",ur={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},Yv="js";function Ta(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function zn(){return!ba()&&!!Lo()&&navigator.product===Wv}function ys(){return!Ta()&&!!Lo()&&!!ba()}function ws(){return zn()?ur.reactNative:Ta()?ur.node:ys()?ur.browser:ur.unknown}function Jv(){var t;try{return zn()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(t=global.Application)==null?void 0:t.applicationId:void 0}catch{return}}function Qv(t,e){let r=ds.parse(t);return r=xu(xu({},r),e),t=ds.stringify(r),t}function Su(){return Mh()||{name:"",description:"",url:"",icons:[""]}}function Xv(){if(ws()===ur.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=Vb();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 Zv(){var t;const e=ws();return e===ur.browser?[e,((t=Sh())==null?void 0:t.host)||"unknown"].join(":"):e}function Mu(t,e,r){const i=Xv(),n=Zv();return[[t,e].join("-"),[Yv,r].join("-"),i,n].join("/")}function e6({protocol:t,version:e,relayUrl:r,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:c}){const l=r.split("?"),u=Mu(t,e,i),b={auth:n,ua:u,projectId:s,useOnCloseEvent:o||void 0,origin:c||void 0},m=Qv(l[1]||"",b);return l[0]+"?"+m}function on(t,e){return t.filter(r=>e.includes(r)).length===t.length}function Iu(t){return Object.fromEntries(t.entries())}function Du(t){return new Map(Object.entries(t))}function cn(t=oe.FIVE_MINUTES,e){const r=oe.toMiliseconds(t||oe.FIVE_MINUTES);let i,n,s;return{resolve:o=>{s&&i&&(clearTimeout(s),i(o))},reject:o=>{s&&n&&(clearTimeout(s),n(o))},done:()=>new Promise((o,c)=>{s=setTimeout(()=>{c(new Error(e))},r),i=o,n=c})}}function kn(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 Ou(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 t6(t){return Ou("topic",t)}function r6(t){return Ou("id",t)}function Ru(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 _t(t,e){return oe.fromMiliseconds((e||Date.now())+oe.toMiliseconds(t))}function zi(t){return Date.now()>=oe.toMiliseconds(t)}function Je(t,e){return`${t}${e?`:${e}`:""}`}function i6(t=[],e=[]){return[...new Set([...t,...e])]}async function n6({id:t,topic:e,wcDeepLink:r}){var i;try{if(!r)return;let s=(typeof r=="string"?JSON.parse(r):r)?.href;if(typeof s!="string")return;s.endsWith("/")&&(s=s.slice(0,-1));const o=`${s}/wc?requestId=${t}&sessionTopic=${e}`,c=ws();if(c===ur.browser){if(!((i=ba())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}o.startsWith("https://")||o.startsWith("http://")?window.open(o,"_blank","noreferrer noopener"):window.open(o,"_self","noreferrer noopener")}else c===ur.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(n){console.error(n)}}async function s6(t,e){try{return await t.getItem(e)||(ys()?localStorage.getItem(e):void 0)}catch(r){console.error(r)}}function Nu(t,e){if(!t.includes(e))return null;const r=t.split(/([&,?,=])/),i=r.indexOf(e);return r[i+2]}function Pu(){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 ac(){return typeof process<"u"&&process.env.IS_VITEST==="true"}var Tu=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function a6(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 Cu={exports:{}};/**
|
14
|
+
***************************************************************************** */var ho=function(t,e){return ho=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])},ho(t,e)};function ql(t,e){ho(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var uo=function(){return uo=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},uo.apply(this,arguments)};function Ul(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 zl(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 c=t.length-1;c>=0;c--)(o=t[c])&&(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 kl(t,e){return function(r,i){e(r,i,t)}}function $l(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function jl(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 c(b){try{u(i.next(b))}catch(m){o(m)}}function l(b){try{u(i.throw(b))}catch(m){o(m)}}function u(b){b.done?s(b.value):n(b.value).then(c,l)}u((i=i.apply(t,e||[])).next())})}function Kl(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:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(u){return function(b){return l([u,b])}}function l(u){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,n&&(s=u[0]&2?n.return:u[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,u[1])).done)return s;switch(n=0,s&&(u=[u[0]&2,s.value]),u[0]){case 0:case 1:s=u;break;case 4:return r.label++,{value:u[1],done:!1};case 5:r.label++,n=u[1],u=[0];continue;case 7:u=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){r=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]<s[3])){r.label=u[1];break}if(u[0]===6&&r.label<s[1]){r.label=s[1],s=u;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(u);break}s[2]&&r.ops.pop(),r.trys.pop();continue}u=e.call(t,r)}catch(b){u=[6,b],n=0}finally{i=s=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function Hl(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}function Vl(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function lo(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 mf(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(c){o={error:c}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function Gl(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(mf(arguments[e]));return t}function Wl(){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,c=s.length;o<c;o++,n++)i[n]=s[o];return i}function ns(t){return this instanceof ns?(this.v=t,this):new ns(t)}function Yl(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(S){return new Promise(function(I,F){s.push([M,S,I,F])>1||c(M,S)})})}function c(M,S){try{l(i[M](S))}catch(I){m(s[0][3],I)}}function l(M){M.value instanceof ns?Promise.resolve(M.value.v).then(u,b):m(s[0][2],M)}function u(M){c("next",M)}function b(M){c("throw",M)}function m(M,S){M(S),s.shift(),s.length&&c(s[0][0],s[0][1])}}function Jl(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:ns(t[n](o)),done:n==="return"}:s?s(o):o}:s}}function Ql(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 lo=="function"?lo(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(c,l){o=t[s](o),n(c,l,o.done,o.value)})}}function n(s,o,c,l){Promise.resolve(l).then(function(u){s({value:u,done:c})},o)}}function Xl(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function Zl(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 e1(t){return t&&t.__esModule?t:{default:t}}function t1(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function r1(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 i1=Object.freeze({__proto__:null,__extends:ql,get __assign(){return uo},__rest:Ul,__decorate:zl,__param:kl,__metadata:$l,__awaiter:jl,__generator:Kl,__createBinding:Hl,__exportStar:Vl,__values:lo,__read:mf,__spread:Gl,__spreadArrays:Wl,__await:ns,__asyncGenerator:Yl,__asyncDelegator:Jl,__asyncValues:Ql,__makeTemplateObject:Xl,__importStar:Zl,__importDefault:e1,__classPrivateFieldGet:t1,__classPrivateFieldSet:r1}),Qs=co(i1),po={},ss={},yf;function n1(){if(yf)return ss;yf=1,Object.defineProperty(ss,"__esModule",{value:!0}),ss.delay=void 0;function t(e){return new Promise(r=>{setTimeout(()=>{r(!0)},e)})}return ss.delay=t,ss}var Wi={},go={},Yi={},wf;function s1(){return wf||(wf=1,Object.defineProperty(Yi,"__esModule",{value:!0}),Yi.ONE_THOUSAND=Yi.ONE_HUNDRED=void 0,Yi.ONE_HUNDRED=100,Yi.ONE_THOUSAND=1e3),Yi}var bo={},_f;function a1(){return _f||(_f=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}(bo)),bo}var Af;function Ef(){return Af||(Af=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Qs;e.__exportStar(s1(),t),e.__exportStar(a1(),t)}(go)),go}var xf;function o1(){if(xf)return Wi;xf=1,Object.defineProperty(Wi,"__esModule",{value:!0}),Wi.fromMiliseconds=Wi.toMiliseconds=void 0;const t=Ef();function e(i){return i*t.ONE_THOUSAND}Wi.toMiliseconds=e;function r(i){return Math.floor(i/t.ONE_THOUSAND)}return Wi.fromMiliseconds=r,Wi}var Sf;function c1(){return Sf||(Sf=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Qs;e.__exportStar(n1(),t),e.__exportStar(o1(),t)}(po)),po}var En={},Mf;function f1(){if(Mf)return En;Mf=1,Object.defineProperty(En,"__esModule",{value:!0}),En.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 En.Watch=t,En.default=t,En}var vo={},as={},If;function h1(){if(If)return as;If=1,Object.defineProperty(as,"__esModule",{value:!0}),as.IWatch=void 0;class t{}return as.IWatch=t,as}var Df;function u1(){return Df||(Df=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),Qs.__exportStar(h1(),t)}(vo)),vo}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Qs;e.__exportStar(c1(),t),e.__exportStar(f1(),t),e.__exportStar(u1(),t),e.__exportStar(Ef(),t)})(oe);class Ji{}class d1 extends Ji{constructor(e){super()}}const Of=oe.FIVE_SECONDS,xn={pulse:"heartbeat_pulse"};class mo extends d1{constructor(e){super(e),this.events=new qt.exports.EventEmitter,this.interval=Of,this.interval=e?.interval||Of}static async init(e){const r=new mo(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(),oe.toMiliseconds(this.interval))}pulse(){this.events.emit(xn.pulse)}}const l1=/"(?:_|\\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*:/,p1=/"(?: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*:/,g1=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function b1(t,e){if(t==="__proto__"||t==="constructor"&&e&&typeof e=="object"&&"prototype"in e){v1(t);return}return e}function v1(t){console.warn(`[destr] Dropping "${t}" key to prevent prototype pollution.`)}function Xs(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(!g1.test(t)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return t}try{if(l1.test(t)||p1.test(t)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(t,b1)}return JSON.parse(t)}catch(i){if(e.strict)throw i;return t}}function m1(t){return!t||typeof t.then!="function"?Promise.resolve(t):t}function At(t,...e){try{return m1(t(...e))}catch(r){return Promise.reject(r)}}function y1(t){const e=typeof t;return t===null||e!=="object"&&e!=="function"}function w1(t){const e=Object.getPrototypeOf(t);return!e||e.isPrototypeOf(Object)}function Zs(t){if(y1(t))return String(t);if(w1(t)||Array.isArray(t))return JSON.stringify(t);if(typeof t.toJSON=="function")return Zs(t.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function Rf(){if(typeof Buffer>"u")throw new TypeError("[unstorage] Buffer is not supported!")}const yo="base64:";function _1(t){if(typeof t=="string")return t;Rf();const e=Buffer.from(t).toString("base64");return yo+e}function A1(t){return typeof t!="string"||!t.startsWith(yo)?t:(Rf(),Buffer.from(t.slice(yo.length),"base64"))}function Qt(t){return t?t.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function E1(...t){return Qt(t.join(":"))}function ea(t){return t=Qt(t),t?t+":":""}function X9(t){return t}const x1="memory",S1=()=>{const t=new Map;return{name:x1,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 M1(t={}){const e={mounts:{"":t.driver||S1()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},r=u=>{for(const b of e.mountpoints)if(u.startsWith(b))return{base:b,relativeKey:u.slice(b.length),driver:e.mounts[b]};return{base:"",relativeKey:u,driver:e.mounts[""]}},i=(u,b)=>e.mountpoints.filter(m=>m.startsWith(u)||b&&u.startsWith(m)).map(m=>({relativeBase:u.length>m.length?u.slice(m.length):void 0,mountpoint:m,driver:e.mounts[m]})),n=(u,b)=>{if(e.watching){b=Qt(b);for(const m of e.watchListeners)m(u,b)}},s=async()=>{if(!e.watching){e.watching=!0;for(const u in e.mounts)e.unwatch[u]=await Nf(e.mounts[u],n,u)}},o=async()=>{if(e.watching){for(const u in e.unwatch)await e.unwatch[u]();e.unwatch={},e.watching=!1}},c=(u,b,m)=>{const M=new Map,S=I=>{let F=M.get(I.base);return F||(F={driver:I.driver,base:I.base,items:[]},M.set(I.base,F)),F};for(const I of u){const F=typeof I=="string",k=Qt(F?I:I.key),j=F?void 0:I.value,C=F||!I.options?b:{...b,...I.options},$=r(k);S($).items.push({key:k,value:j,relativeKey:$.relativeKey,options:C})}return Promise.all([...M.values()].map(I=>m(I))).then(I=>I.flat())},l={hasItem(u,b={}){u=Qt(u);const{relativeKey:m,driver:M}=r(u);return At(M.hasItem,m,b)},getItem(u,b={}){u=Qt(u);const{relativeKey:m,driver:M}=r(u);return At(M.getItem,m,b).then(S=>Xs(S))},getItems(u,b){return c(u,b,m=>m.driver.getItems?At(m.driver.getItems,m.items.map(M=>({key:M.relativeKey,options:M.options})),b).then(M=>M.map(S=>({key:E1(m.base,S.key),value:Xs(S.value)}))):Promise.all(m.items.map(M=>At(m.driver.getItem,M.relativeKey,M.options).then(S=>({key:M.key,value:Xs(S)})))))},getItemRaw(u,b={}){u=Qt(u);const{relativeKey:m,driver:M}=r(u);return M.getItemRaw?At(M.getItemRaw,m,b):At(M.getItem,m,b).then(S=>A1(S))},async setItem(u,b,m={}){if(b===void 0)return l.removeItem(u);u=Qt(u);const{relativeKey:M,driver:S}=r(u);S.setItem&&(await At(S.setItem,M,Zs(b),m),S.watch||n("update",u))},async setItems(u,b){await c(u,b,async m=>{if(m.driver.setItems)return At(m.driver.setItems,m.items.map(M=>({key:M.relativeKey,value:Zs(M.value),options:M.options})),b);m.driver.setItem&&await Promise.all(m.items.map(M=>At(m.driver.setItem,M.relativeKey,Zs(M.value),M.options)))})},async setItemRaw(u,b,m={}){if(b===void 0)return l.removeItem(u,m);u=Qt(u);const{relativeKey:M,driver:S}=r(u);if(S.setItemRaw)await At(S.setItemRaw,M,b,m);else if(S.setItem)await At(S.setItem,M,_1(b),m);else return;S.watch||n("update",u)},async removeItem(u,b={}){typeof b=="boolean"&&(b={removeMeta:b}),u=Qt(u);const{relativeKey:m,driver:M}=r(u);M.removeItem&&(await At(M.removeItem,m,b),(b.removeMeta||b.removeMata)&&await At(M.removeItem,m+"$",b),M.watch||n("remove",u))},async getMeta(u,b={}){typeof b=="boolean"&&(b={nativeOnly:b}),u=Qt(u);const{relativeKey:m,driver:M}=r(u),S=Object.create(null);if(M.getMeta&&Object.assign(S,await At(M.getMeta,m,b)),!b.nativeOnly){const I=await At(M.getItem,m+"$",b).then(F=>Xs(F));I&&typeof I=="object"&&(typeof I.atime=="string"&&(I.atime=new Date(I.atime)),typeof I.mtime=="string"&&(I.mtime=new Date(I.mtime)),Object.assign(S,I))}return S},setMeta(u,b,m={}){return this.setItem(u+"$",b,m)},removeMeta(u,b={}){return this.removeItem(u+"$",b)},async getKeys(u,b={}){u=ea(u);const m=i(u,!0);let M=[];const S=[];for(const I of m){const F=await At(I.driver.getKeys,I.relativeBase,b);for(const k of F){const j=I.mountpoint+Qt(k);M.some(C=>j.startsWith(C))||S.push(j)}M=[I.mountpoint,...M.filter(k=>!k.startsWith(I.mountpoint))]}return u?S.filter(I=>I.startsWith(u)&&I[I.length-1]!=="$"):S.filter(I=>I[I.length-1]!=="$")},async clear(u,b={}){u=ea(u),await Promise.all(i(u,!1).map(async m=>{if(m.driver.clear)return At(m.driver.clear,m.relativeBase,b);if(m.driver.removeItem){const M=await m.driver.getKeys(m.relativeBase||"",b);return Promise.all(M.map(S=>m.driver.removeItem(S,b)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(u=>Pf(u)))},async watch(u){return await s(),e.watchListeners.push(u),async()=>{e.watchListeners=e.watchListeners.filter(b=>b!==u),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(u,b){if(u=ea(u),u&&e.mounts[u])throw new Error(`already mounted at ${u}`);return u&&(e.mountpoints.push(u),e.mountpoints.sort((m,M)=>M.length-m.length)),e.mounts[u]=b,e.watching&&Promise.resolve(Nf(b,n,u)).then(m=>{e.unwatch[u]=m}).catch(console.error),l},async unmount(u,b=!0){u=ea(u),!(!u||!e.mounts[u])&&(e.watching&&u in e.unwatch&&(e.unwatch[u](),delete e.unwatch[u]),b&&await Pf(e.mounts[u]),e.mountpoints=e.mountpoints.filter(m=>m!==u),delete e.mounts[u])},getMount(u=""){u=Qt(u)+":";const b=r(u);return{driver:b.driver,base:b.base}},getMounts(u="",b={}){return u=Qt(u),i(u,b.parents).map(M=>({driver:M.driver,base:M.mountpoint}))},keys:(u,b={})=>l.getKeys(u,b),get:(u,b={})=>l.getItem(u,b),set:(u,b,m={})=>l.setItem(u,b,m),has:(u,b={})=>l.hasItem(u,b),del:(u,b={})=>l.removeItem(u,b),remove:(u,b={})=>l.removeItem(u,b)};return l}function Nf(t,e,r){return t.watch?t.watch((i,n)=>e(i,r+n)):()=>{}}async function Pf(t){typeof t.dispose=="function"&&await At(t.dispose)}function Qi(t){return new Promise((e,r)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>r(t.error)})}function Tf(t,e){const r=indexedDB.open(t);r.onupgradeneeded=()=>r.result.createObjectStore(e);const i=Qi(r);return(n,s)=>i.then(o=>s(o.transaction(e,n).objectStore(e)))}let wo;function os(){return wo||(wo=Tf("keyval-store","keyval")),wo}function Cf(t,e=os()){return e("readonly",r=>Qi(r.get(t)))}function I1(t,e,r=os()){return r("readwrite",i=>(i.put(e,t),Qi(i.transaction)))}function D1(t,e=os()){return e("readwrite",r=>(r.delete(t),Qi(r.transaction)))}function O1(t=os()){return t("readwrite",e=>(e.clear(),Qi(e.transaction)))}function R1(t,e){return t.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},Qi(t.transaction)}function N1(t=os()){return t("readonly",e=>{if(e.getAllKeys)return Qi(e.getAllKeys());const r=[];return R1(e,i=>r.push(i.key)).then(()=>r)})}const P1=t=>JSON.stringify(t,(e,r)=>typeof r=="bigint"?r.toString()+"n":r),T1=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 Sn(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return T1(t)}catch{return t}}function Xi(t){return typeof t=="string"?t:P1(t)||""}const C1="idb-keyval";var F1=(t={})=>{const e=t.base&&t.base.length>0?`${t.base}:`:"",r=n=>e+n;let i;return t.dbName&&t.storeName&&(i=Tf(t.dbName,t.storeName)),{name:C1,options:t,async hasItem(n){return!(typeof await Cf(r(n),i)>"u")},async getItem(n){return await Cf(r(n),i)??null},setItem(n,s){return I1(r(n),s,i)},removeItem(n){return D1(r(n),i)},getKeys(){return N1(i)},clear(){return O1(i)}}};const L1="WALLET_CONNECT_V2_INDEXED_DB",B1="keyvaluestorage";class q1{constructor(){this.indexedDb=M1({driver:F1({dbName:L1,storeName:B1})})}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,Xi(r))}async removeItem(e){await this.indexedDb.removeItem(e)}}var _o=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},ta={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 _o<"u"&&_o.localStorage?ta.exports=_o.localStorage:typeof window<"u"&&window.localStorage?ta.exports=window.localStorage:ta.exports=new e})();function U1(t){var e;return[t[0],Sn((e=t[1])!=null?e:"")]}class z1{constructor(){this.localStorage=ta.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(U1)}async getItem(e){const r=this.localStorage.getItem(e);if(r!==null)return Sn(r)}async setItem(e,r){this.localStorage.setItem(e,Xi(r))}async removeItem(e){this.localStorage.removeItem(e)}}const k1="wc_storage_version",Ff=1,$1=async(t,e,r)=>{const i=k1,n=await e.getItem(i);if(n&&n>=Ff){r(e);return}const s=await t.getKeys();if(!s.length){r(e);return}const o=[];for(;s.length;){const c=s.shift();if(!c)continue;const l=c.toLowerCase();if(l.includes("wc@")||l.includes("walletconnect")||l.includes("wc_")||l.includes("wallet_connect")){const u=await t.getItem(c);await e.setItem(c,u),o.push(c)}}await e.setItem(i,Ff),r(e),j1(t,o)},j1=async(t,e)=>{e.length&&e.forEach(async r=>{await t.removeItem(r)})};class K1{constructor(){this.initialized=!1,this.setInitialized=r=>{this.storage=r,this.initialized=!0};const e=new z1;this.storage=e;try{const r=new q1;$1(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 H1(t){try{return JSON.stringify(t)}catch{return'"[Circular]"'}}var V1=G1;function G1(t,e,r){var i=r&&r.stringify||H1,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 c=1;c<s;c++)o[c]=i(e[c]);return o.join(" ")}if(typeof t!="string")return t;var l=e.length;if(l===0)return t;for(var u="",b=1-n,m=-1,M=t&&t.length||0,S=0;S<M;){if(t.charCodeAt(S)===37&&S+1<M){switch(m=m>-1?m:0,t.charCodeAt(S+1)){case 100:case 102:if(b>=l||e[b]==null)break;m<S&&(u+=t.slice(m,S)),u+=Number(e[b]),m=S+2,S++;break;case 105:if(b>=l||e[b]==null)break;m<S&&(u+=t.slice(m,S)),u+=Math.floor(Number(e[b])),m=S+2,S++;break;case 79:case 111:case 106:if(b>=l||e[b]===void 0)break;m<S&&(u+=t.slice(m,S));var I=typeof e[b];if(I==="string"){u+="'"+e[b]+"'",m=S+2,S++;break}if(I==="function"){u+=e[b].name||"<anonymous>",m=S+2,S++;break}u+=i(e[b]),m=S+2,S++;break;case 115:if(b>=l)break;m<S&&(u+=t.slice(m,S)),u+=String(e[b]),m=S+2,S++;break;case 37:m<S&&(u+=t.slice(m,S)),u+="%",m=S+2,S++,b--;break}++b}++S}return m===-1?t:(m<M&&(u+=t.slice(m)),u)}const Lf=V1;var hi=qr;const cs=ip().console||{},W1={mapHttpRequest:ia,mapHttpResponse:ia,wrapRequestSerializer:Eo,wrapResponseSerializer:Eo,wrapErrorSerializer:Eo,req:ia,res:ia,err:Z1};function Y1(t,e){return Array.isArray(t)?t.filter(function(i){return i!=="!stdSerializers.err"}):t===!0?Object.keys(e):!1}function qr(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||cs;t.browser.write&&(t.browser.asObject=!0);const i=t.serializers||{},n=Y1(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 c=t.level||"info",l=Object.create(r);l.log||(l.log=fs),Object.defineProperty(l,"levelVal",{get:b}),Object.defineProperty(l,"level",{get:m,set:M});const u={transmit:e,serialize:n,asObject:t.browser.asObject,levels:o,timestamp:ep(t)};l.levels=qr.levels,l.level=c,l.setMaxListeners=l.getMaxListeners=l.emit=l.addListener=l.on=l.prependListener=l.once=l.prependOnceListener=l.removeListener=l.removeAllListeners=l.listeners=l.listenerCount=l.eventNames=l.write=l.flush=fs,l.serializers=i,l._serialize=n,l._stdErrSerialize=s,l.child=S,e&&(l._logEvent=Ao());function b(){return this.level==="silent"?1/0:this.levels.values[this.level]}function m(){return this._level}function M(I){if(I!=="silent"&&!this.levels.values[I])throw Error("unknown level "+I);this._level=I,Mn(u,l,"error","log"),Mn(u,l,"fatal","error"),Mn(u,l,"warn","error"),Mn(u,l,"info","log"),Mn(u,l,"debug","log"),Mn(u,l,"trace","log")}function S(I,F){if(!I)throw new Error("missing bindings for child Pino");F=F||{},n&&I.serializers&&(F.serializers=I.serializers);const k=F.serializers;if(n&&k){var j=Object.assign({},i,k),C=t.browser.serialize===!0?Object.keys(j):n;delete I.serializers,ra([I],C,j,this._stdErrSerialize)}function $(P){this._childLevel=(P._childLevel|0)+1,this.error=In(P,I,"error"),this.fatal=In(P,I,"fatal"),this.warn=In(P,I,"warn"),this.info=In(P,I,"info"),this.debug=In(P,I,"debug"),this.trace=In(P,I,"trace"),j&&(this.serializers=j,this._serialize=C),e&&(this._logEvent=Ao([].concat(P._logEvent.bindings,I)))}return $.prototype=this,new $(this)}return l}qr.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"}},qr.stdSerializers=W1,qr.stdTimeFunctions=Object.assign({},{nullTime:Bf,epochTime:qf,unixTime:tp,isoTime:rp});function Mn(t,e,r,i){const n=Object.getPrototypeOf(e);e[r]=e.levelVal>e.levels.values[r]?fs:n[r]?n[r]:cs[r]||cs[i]||fs,J1(t,e,r)}function J1(t,e,r){!t.transmit&&e[r]===fs||(e[r]=function(i){return function(){const s=t.timestamp(),o=new Array(arguments.length),c=Object.getPrototypeOf&&Object.getPrototypeOf(this)===cs?cs:this;for(var l=0;l<o.length;l++)o[l]=arguments[l];if(t.serialize&&!t.asObject&&ra(o,this._serialize,this.serializers,this._stdErrSerialize),t.asObject?i.call(c,Q1(this,r,o,s)):i.apply(c,o),t.transmit){const u=t.transmit.level||e.level,b=qr.levels.values[u],m=qr.levels.values[r];if(m<b)return;X1(this,{ts:s,methodLevel:r,methodValue:m,transmitLevel:u,transmitValue:qr.levels.values[t.transmit.level||e.level],send:t.transmit.send,val:e.levelVal},o)}}}(e[r]))}function Q1(t,e,r,i){t._serialize&&ra(r,t._serialize,t.serializers,t._stdErrSerialize);const n=r.slice();let s=n[0];const o={};i&&(o.time=i),o.level=qr.levels.values[e];let c=(t._childLevel|0)+1;if(c<1&&(c=1),s!==null&&typeof s=="object"){for(;c--&&typeof n[0]=="object";)Object.assign(o,n.shift());s=n.length?Lf(n.shift(),n):void 0}else typeof s=="string"&&(s=Lf(n.shift(),n));return s!==void 0&&(o.msg=s),o}function ra(t,e,r,i){for(const n in t)if(i&&t[n]instanceof Error)t[n]=qr.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 In(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 X1(t,e,r){const i=e.send,n=e.ts,s=e.methodLevel,o=e.methodValue,c=e.val,l=t._logEvent.bindings;ra(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(u){return l.indexOf(u)===-1}),t._logEvent.level.label=s,t._logEvent.level.value=o,i(s,t._logEvent,c),t._logEvent=Ao(l)}function Ao(t){return{ts:0,messages:[],bindings:t||[],level:{label:"",value:0}}}function Z1(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 ep(t){return typeof t.timestamp=="function"?t.timestamp:t.timestamp===!1?Bf:qf}function ia(){return{}}function Eo(t){return t}function fs(){}function Bf(){return!1}function qf(){return Date.now()}function tp(){return Math.round(Date.now()/1e3)}function rp(){return new Date(Date.now()).toISOString()}function ip(){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 np={level:"info"},hs="custom_context",xo=1e3*1024;class sp{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 Uf{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){const r=new sp(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 zf{constructor(e,r=xo){this.level=e??"error",this.levelValue=hi.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=r,this.logs=new Uf(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,r){r===hi.levels.values.error?console.error(e):r===hi.levels.values.warn?console.warn(e):r===hi.levels.values.debug?console.debug(e):r===hi.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(Xi({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 Uf(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const r=this.getLogArray();return r.push(Xi({extraMetadata:e})),new Blob(r,{type:"application/json"})}}class ap{constructor(e,r=xo){this.baseChunkLogger=new zf(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 op{constructor(e,r=xo){this.baseChunkLogger=new zf(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 cp=Object.defineProperty,fp=Object.defineProperties,hp=Object.getOwnPropertyDescriptors,kf=Object.getOwnPropertySymbols,up=Object.prototype.hasOwnProperty,dp=Object.prototype.propertyIsEnumerable,$f=(t,e,r)=>e in t?cp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,na=(t,e)=>{for(var r in e||(e={}))up.call(e,r)&&$f(t,r,e[r]);if(kf)for(var r of kf(e))dp.call(e,r)&&$f(t,r,e[r]);return t},sa=(t,e)=>fp(t,hp(e));function So(t){return sa(na({},t),{level:t?.level||np.level})}function lp(t,e=hs){return t[e]||""}function pp(t,e,r=hs){return t[r]=e,t}function Xt(t,e=hs){let r="";return typeof t.bindings>"u"?r=lp(t,e):r=t.bindings().context||"",r}function gp(t,e,r=hs){const i=Xt(t,r);return i.trim()?`${i}/${e}`:e}function Ht(t,e,r=hs){const i=gp(t,e,r),n=t.child({context:i});return pp(n,i,r)}function bp(t){var e,r;const i=new ap((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:hi(sa(na({},t.opts),{level:"trace",browser:sa(na({},(r=t.opts)==null?void 0:r.browser),{write:n=>i.write(n)})})),chunkLoggerController:i}}function vp(t){var e;const r=new op((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:hi(sa(na({},t.opts),{level:"trace"})),chunkLoggerController:r}}function mp(t){return typeof t.loggerOverride<"u"&&typeof t.loggerOverride!="string"?{logger:t.loggerOverride,chunkLoggerController:null}:typeof window<"u"?bp(t):vp(t)}class yp extends Ji{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}class wp extends Ji{constructor(e,r){super(),this.core=e,this.logger=r,this.records=new Map}}class _p{constructor(e,r){this.logger=e,this.core=r}}class Ap extends Ji{constructor(e,r){super(),this.relayer=e,this.logger=r}}class Ep extends Ji{constructor(e){super()}}class xp{constructor(e,r,i,n){this.core=e,this.logger=r,this.name=i}}class Sp extends Ji{constructor(e,r){super(),this.relayer=e,this.logger=r}}class Mp extends Ji{constructor(e,r){super(),this.core=e,this.logger=r}}class Ip{constructor(e,r,i){this.core=e,this.logger=r,this.store=i}}class Dp{constructor(e,r){this.projectId=e,this.logger=r}}class Op{constructor(e,r,i){this.core=e,this.logger=r,this.telemetryEnabled=i}}class Rp{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}class Np{constructor(e){this.client=e}}var Mo={},Ci={},aa={},oa={};Object.defineProperty(oa,"__esModule",{value:!0}),oa.BrowserRandomSource=void 0;const jf=65536;class Pp{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const e=typeof self<"u"?self.crypto||self.msCrypto:null;e&&e.getRandomValues!==void 0&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");const r=new Uint8Array(e);for(let i=0;i<r.length;i+=jf)this._crypto.getRandomValues(r.subarray(i,i+Math.min(r.length-i,jf)));return r}}oa.BrowserRandomSource=Pp;function Tp(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ca={},fr={};Object.defineProperty(fr,"__esModule",{value:!0});function Cp(t){for(var e=0;e<t.length;e++)t[e]=0;return t}fr.wipe=Cp;var Fp={},Lp=Object.freeze({__proto__:null,default:Fp}),Io=co(Lp);Object.defineProperty(ca,"__esModule",{value:!0}),ca.NodeRandomSource=void 0;const Bp=fr;class qp{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof Tp<"u"){const e=Io;e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let r=this._crypto.randomBytes(e);if(r.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");const i=new Uint8Array(e);for(let n=0;n<i.length;n++)i[n]=r[n];return(0,Bp.wipe)(r),i}}ca.NodeRandomSource=qp,Object.defineProperty(aa,"__esModule",{value:!0}),aa.SystemRandomSource=void 0;const Up=oa,zp=ca;class kp{constructor(){if(this.isAvailable=!1,this.name="",this._source=new Up.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new zp.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}}aa.SystemRandomSource=kp;var Ke={},Kf={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});function e(c,l){var u=c>>>16&65535,b=c&65535,m=l>>>16&65535,M=l&65535;return b*M+(u*M+b*m<<16>>>0)|0}t.mul=Math.imul||e;function r(c,l){return c+l|0}t.add=r;function i(c,l){return c-l|0}t.sub=i;function n(c,l){return c<<l|c>>>32-l}t.rotl=n;function s(c,l){return c<<32-l|c>>>l}t.rotr=s;function o(c){return typeof c=="number"&&isFinite(c)&&Math.floor(c)===c}t.isInteger=Number.isInteger||o,t.MAX_SAFE_INTEGER=9007199254740991,t.isSafeInteger=function(c){return t.isInteger(c)&&c>=-t.MAX_SAFE_INTEGER&&c<=t.MAX_SAFE_INTEGER}})(Kf),Object.defineProperty(Ke,"__esModule",{value:!0});var Hf=Kf;function $p(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])<<16>>16}Ke.readInt16BE=$p;function jp(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])>>>0}Ke.readUint16BE=jp;function Kp(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])<<16>>16}Ke.readInt16LE=Kp;function Hp(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])>>>0}Ke.readUint16LE=Hp;function Vf(t,e,r){return e===void 0&&(e=new Uint8Array(2)),r===void 0&&(r=0),e[r+0]=t>>>8,e[r+1]=t>>>0,e}Ke.writeUint16BE=Vf,Ke.writeInt16BE=Vf;function Gf(t,e,r){return e===void 0&&(e=new Uint8Array(2)),r===void 0&&(r=0),e[r+0]=t>>>0,e[r+1]=t>>>8,e}Ke.writeUint16LE=Gf,Ke.writeInt16LE=Gf;function Do(t,e){return e===void 0&&(e=0),t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}Ke.readInt32BE=Do;function Oo(t,e){return e===void 0&&(e=0),(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}Ke.readUint32BE=Oo;function Ro(t,e){return e===void 0&&(e=0),t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}Ke.readInt32LE=Ro;function No(t,e){return e===void 0&&(e=0),(t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e])>>>0}Ke.readUint32LE=No;function fa(t,e,r){return e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0),e[r+0]=t>>>24,e[r+1]=t>>>16,e[r+2]=t>>>8,e[r+3]=t>>>0,e}Ke.writeUint32BE=fa,Ke.writeInt32BE=fa;function ha(t,e,r){return e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0),e[r+0]=t>>>0,e[r+1]=t>>>8,e[r+2]=t>>>16,e[r+3]=t>>>24,e}Ke.writeUint32LE=ha,Ke.writeInt32LE=ha;function Vp(t,e){e===void 0&&(e=0);var r=Do(t,e),i=Do(t,e+4);return r*4294967296+i-(i>>31)*4294967296}Ke.readInt64BE=Vp;function Gp(t,e){e===void 0&&(e=0);var r=Oo(t,e),i=Oo(t,e+4);return r*4294967296+i}Ke.readUint64BE=Gp;function Wp(t,e){e===void 0&&(e=0);var r=Ro(t,e),i=Ro(t,e+4);return i*4294967296+r-(r>>31)*4294967296}Ke.readInt64LE=Wp;function Yp(t,e){e===void 0&&(e=0);var r=No(t,e),i=No(t,e+4);return i*4294967296+r}Ke.readUint64LE=Yp;function Wf(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),fa(t/4294967296>>>0,e,r),fa(t>>>0,e,r+4),e}Ke.writeUint64BE=Wf,Ke.writeInt64BE=Wf;function Yf(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),ha(t>>>0,e,r),ha(t/4294967296>>>0,e,r+4),e}Ke.writeUint64LE=Yf,Ke.writeInt64LE=Yf;function Jp(t,e,r){if(r===void 0&&(r=0),t%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(t/8>e.length-r)throw new Error("readUintBE: array is too short for the given bitLength");for(var i=0,n=1,s=t/8+r-1;s>=r;s--)i+=e[s]*n,n*=256;return i}Ke.readUintBE=Jp;function Qp(t,e,r){if(r===void 0&&(r=0),t%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(t/8>e.length-r)throw new Error("readUintLE: array is too short for the given bitLength");for(var i=0,n=1,s=r;s<r+t/8;s++)i+=e[s]*n,n*=256;return i}Ke.readUintLE=Qp;function Xp(t,e,r,i){if(r===void 0&&(r=new Uint8Array(t/8)),i===void 0&&(i=0),t%8!==0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!Hf.isSafeInteger(e))throw new Error("writeUintBE value must be an integer");for(var n=1,s=t/8+i-1;s>=i;s--)r[s]=e/n&255,n*=256;return r}Ke.writeUintBE=Xp;function Zp(t,e,r,i){if(r===void 0&&(r=new Uint8Array(t/8)),i===void 0&&(i=0),t%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!Hf.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var n=1,s=i;s<i+t/8;s++)r[s]=e/n&255,n*=256;return r}Ke.writeUintLE=Zp;function eg(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat32(e)}Ke.readFloat32BE=eg;function tg(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat32(e,!0)}Ke.readFloat32LE=tg;function rg(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat64(e)}Ke.readFloat64BE=rg;function ig(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat64(e,!0)}Ke.readFloat64LE=ig;function ng(t,e,r){e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat32(r,t),e}Ke.writeFloat32BE=ng;function sg(t,e,r){e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat32(r,t,!0),e}Ke.writeFloat32LE=sg;function ag(t,e,r){e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat64(r,t),e}Ke.writeFloat64BE=ag;function og(t,e,r){e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat64(r,t,!0),e}Ke.writeFloat64LE=og,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.randomStringForEntropy=t.randomString=t.randomUint32=t.randomBytes=t.defaultRandomSource=void 0;const e=aa,r=Ke,i=fr;t.defaultRandomSource=new e.SystemRandomSource;function n(u,b=t.defaultRandomSource){return b.randomBytes(u)}t.randomBytes=n;function s(u=t.defaultRandomSource){const b=n(4,u),m=(0,r.readUint32LE)(b);return(0,i.wipe)(b),m}t.randomUint32=s;const o="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function c(u,b=o,m=t.defaultRandomSource){if(b.length<2)throw new Error("randomString charset is too short");if(b.length>256)throw new Error("randomString charset is too long");let M="";const S=b.length,I=256-256%S;for(;u>0;){const F=n(Math.ceil(u*256/I),m);for(let k=0;k<F.length&&u>0;k++){const j=F[k];j<I&&(M+=b.charAt(j%S),u--)}(0,i.wipe)(F)}return M}t.randomString=c;function l(u,b=o,m=t.defaultRandomSource){const M=Math.ceil(u/(Math.log(b.length)/Math.LN2));return c(M,b,m)}t.randomStringForEntropy=l}(Ci);var Jf={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Ke,r=fr;t.DIGEST_LENGTH=64,t.BLOCK_SIZE=128;var i=function(){function c(){this.digestLength=t.DIGEST_LENGTH,this.blockSize=t.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return c.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},c.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},c.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._tempHi),r.wipe(this._tempLo),this.reset()},c.prototype.update=function(l,u){if(u===void 0&&(u=l.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var b=0;if(this._bytesHashed+=u,this._bufferLength>0){for(;this._bufferLength<t.BLOCK_SIZE&&u>0;)this._buffer[this._bufferLength++]=l[b++],u--;this._bufferLength===this.blockSize&&(s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(u>=this.blockSize&&(b=s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,l,b,u),u%=this.blockSize);u>0;)this._buffer[this._bufferLength++]=l[b++],u--;return this},c.prototype.finish=function(l){if(!this._finished){var u=this._bytesHashed,b=this._bufferLength,m=u/536870912|0,M=u<<3,S=u%128<112?128:256;this._buffer[b]=128;for(var I=b+1;I<S-8;I++)this._buffer[I]=0;e.writeUint32BE(m,this._buffer,S-8),e.writeUint32BE(M,this._buffer,S-4),s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,S),this._finished=!0}for(var I=0;I<this.digestLength/8;I++)e.writeUint32BE(this._stateHi[I],l,I*8),e.writeUint32BE(this._stateLo[I],l,I*8+4);return this},c.prototype.digest=function(){var l=new Uint8Array(this.digestLength);return this.finish(l),l},c.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{stateHi:new Int32Array(this._stateHi),stateLo:new Int32Array(this._stateLo),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},c.prototype.restoreState=function(l){return this._stateHi.set(l.stateHi),this._stateLo.set(l.stateLo),this._bufferLength=l.bufferLength,l.buffer&&this._buffer.set(l.buffer),this._bytesHashed=l.bytesHashed,this._finished=!1,this},c.prototype.cleanSavedState=function(l){r.wipe(l.stateHi),r.wipe(l.stateLo),l.buffer&&r.wipe(l.buffer),l.bufferLength=0,l.bytesHashed=0},c}();t.SHA512=i;var n=new Int32Array([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 s(c,l,u,b,m,M,S){for(var I=u[0],F=u[1],k=u[2],j=u[3],C=u[4],$=u[5],P=u[6],B=u[7],U=b[0],y=b[1],O=b[2],Y=b[3],Q=b[4],N=b[5],g=b[6],a=b[7],f,p,w,A,x,_,h,d;S>=128;){for(var D=0;D<16;D++){var K=8*D+M;c[D]=e.readUint32BE(m,K),l[D]=e.readUint32BE(m,K+4)}for(var D=0;D<80;D++){var G=I,E=F,H=k,R=j,L=C,q=$,v=P,T=B,W=U,J=y,X=O,se=Y,ne=Q,Me=N,Ce=g,ue=a;if(f=B,p=a,x=p&65535,_=p>>>16,h=f&65535,d=f>>>16,f=(C>>>14|Q<<32-14)^(C>>>18|Q<<32-18)^(Q>>>41-32|C<<32-(41-32)),p=(Q>>>14|C<<32-14)^(Q>>>18|C<<32-18)^(C>>>41-32|Q<<32-(41-32)),x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,f=C&$^~C&P,p=Q&N^~Q&g,x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,f=n[D*2],p=n[D*2+1],x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,f=c[D%16],p=l[D%16],x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,_+=x>>>16,h+=_>>>16,d+=h>>>16,w=h&65535|d<<16,A=x&65535|_<<16,f=w,p=A,x=p&65535,_=p>>>16,h=f&65535,d=f>>>16,f=(I>>>28|U<<32-28)^(U>>>34-32|I<<32-(34-32))^(U>>>39-32|I<<32-(39-32)),p=(U>>>28|I<<32-28)^(I>>>34-32|U<<32-(34-32))^(I>>>39-32|U<<32-(39-32)),x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,f=I&F^I&k^F&k,p=U&y^U&O^y&O,x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,_+=x>>>16,h+=_>>>16,d+=h>>>16,T=h&65535|d<<16,ue=x&65535|_<<16,f=R,p=se,x=p&65535,_=p>>>16,h=f&65535,d=f>>>16,f=w,p=A,x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,_+=x>>>16,h+=_>>>16,d+=h>>>16,R=h&65535|d<<16,se=x&65535|_<<16,F=G,k=E,j=H,C=R,$=L,P=q,B=v,I=T,y=W,O=J,Y=X,Q=se,N=ne,g=Me,a=Ce,U=ue,D%16===15)for(var K=0;K<16;K++)f=c[K],p=l[K],x=p&65535,_=p>>>16,h=f&65535,d=f>>>16,f=c[(K+9)%16],p=l[(K+9)%16],x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,w=c[(K+1)%16],A=l[(K+1)%16],f=(w>>>1|A<<32-1)^(w>>>8|A<<32-8)^w>>>7,p=(A>>>1|w<<32-1)^(A>>>8|w<<32-8)^(A>>>7|w<<32-7),x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,w=c[(K+14)%16],A=l[(K+14)%16],f=(w>>>19|A<<32-19)^(A>>>61-32|w<<32-(61-32))^w>>>6,p=(A>>>19|w<<32-19)^(w>>>61-32|A<<32-(61-32))^(A>>>6|w<<32-6),x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,_+=x>>>16,h+=_>>>16,d+=h>>>16,c[K]=h&65535|d<<16,l[K]=x&65535|_<<16}f=I,p=U,x=p&65535,_=p>>>16,h=f&65535,d=f>>>16,f=u[0],p=b[0],x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,_+=x>>>16,h+=_>>>16,d+=h>>>16,u[0]=I=h&65535|d<<16,b[0]=U=x&65535|_<<16,f=F,p=y,x=p&65535,_=p>>>16,h=f&65535,d=f>>>16,f=u[1],p=b[1],x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,_+=x>>>16,h+=_>>>16,d+=h>>>16,u[1]=F=h&65535|d<<16,b[1]=y=x&65535|_<<16,f=k,p=O,x=p&65535,_=p>>>16,h=f&65535,d=f>>>16,f=u[2],p=b[2],x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,_+=x>>>16,h+=_>>>16,d+=h>>>16,u[2]=k=h&65535|d<<16,b[2]=O=x&65535|_<<16,f=j,p=Y,x=p&65535,_=p>>>16,h=f&65535,d=f>>>16,f=u[3],p=b[3],x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,_+=x>>>16,h+=_>>>16,d+=h>>>16,u[3]=j=h&65535|d<<16,b[3]=Y=x&65535|_<<16,f=C,p=Q,x=p&65535,_=p>>>16,h=f&65535,d=f>>>16,f=u[4],p=b[4],x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,_+=x>>>16,h+=_>>>16,d+=h>>>16,u[4]=C=h&65535|d<<16,b[4]=Q=x&65535|_<<16,f=$,p=N,x=p&65535,_=p>>>16,h=f&65535,d=f>>>16,f=u[5],p=b[5],x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,_+=x>>>16,h+=_>>>16,d+=h>>>16,u[5]=$=h&65535|d<<16,b[5]=N=x&65535|_<<16,f=P,p=g,x=p&65535,_=p>>>16,h=f&65535,d=f>>>16,f=u[6],p=b[6],x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,_+=x>>>16,h+=_>>>16,d+=h>>>16,u[6]=P=h&65535|d<<16,b[6]=g=x&65535|_<<16,f=B,p=a,x=p&65535,_=p>>>16,h=f&65535,d=f>>>16,f=u[7],p=b[7],x+=p&65535,_+=p>>>16,h+=f&65535,d+=f>>>16,_+=x>>>16,h+=_>>>16,d+=h>>>16,u[7]=B=h&65535|d<<16,b[7]=a=x&65535|_<<16,M+=128,S-=128}return M}function o(c){var l=new i;l.update(c);var u=l.digest();return l.clean(),u}t.hash=o})(Jf),function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.convertSecretKeyToX25519=t.convertPublicKeyToX25519=t.verify=t.sign=t.extractPublicKeyFromSecretKey=t.generateKeyPair=t.generateKeyPairFromSeed=t.SEED_LENGTH=t.SECRET_KEY_LENGTH=t.PUBLIC_KEY_LENGTH=t.SIGNATURE_LENGTH=void 0;const e=Ci,r=Jf,i=fr;t.SIGNATURE_LENGTH=64,t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=64,t.SEED_LENGTH=32;function n(R){const L=new Float64Array(16);if(R)for(let q=0;q<R.length;q++)L[q]=R[q];return L}const s=new Uint8Array(32);s[0]=9;const o=n(),c=n([1]),l=n([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),u=n([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),b=n([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),m=n([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),M=n([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function S(R,L){for(let q=0;q<16;q++)R[q]=L[q]|0}function I(R){let L=1;for(let q=0;q<16;q++){let v=R[q]+L+65535;L=Math.floor(v/65536),R[q]=v-L*65536}R[0]+=L-1+37*(L-1)}function F(R,L,q){const v=~(q-1);for(let T=0;T<16;T++){const W=v&(R[T]^L[T]);R[T]^=W,L[T]^=W}}function k(R,L){const q=n(),v=n();for(let T=0;T<16;T++)v[T]=L[T];I(v),I(v),I(v);for(let T=0;T<2;T++){q[0]=v[0]-65517;for(let J=1;J<15;J++)q[J]=v[J]-65535-(q[J-1]>>16&1),q[J-1]&=65535;q[15]=v[15]-32767-(q[14]>>16&1);const W=q[15]>>16&1;q[14]&=65535,F(v,q,1-W)}for(let T=0;T<16;T++)R[2*T]=v[T]&255,R[2*T+1]=v[T]>>8}function j(R,L){let q=0;for(let v=0;v<32;v++)q|=R[v]^L[v];return(1&q-1>>>8)-1}function C(R,L){const q=new Uint8Array(32),v=new Uint8Array(32);return k(q,R),k(v,L),j(q,v)}function $(R){const L=new Uint8Array(32);return k(L,R),L[0]&1}function P(R,L){for(let q=0;q<16;q++)R[q]=L[2*q]+(L[2*q+1]<<8);R[15]&=32767}function B(R,L,q){for(let v=0;v<16;v++)R[v]=L[v]+q[v]}function U(R,L,q){for(let v=0;v<16;v++)R[v]=L[v]-q[v]}function y(R,L,q){let v,T,W=0,J=0,X=0,se=0,ne=0,Me=0,Ce=0,ue=0,xe=0,Ae=0,re=0,ve=0,le=0,ee=0,de=0,fe=0,te=0,Ee=0,he=0,ae=0,Se=0,De=0,ce=0,Ie=0,We=0,Oe=0,Qe=0,He=0,Re=0,tt=0,rt=0,pe=q[0],Pe=q[1],Fe=q[2],ge=q[3],Le=q[4],Te=q[5],ye=q[6],Ue=q[7],ze=q[8],we=q[9],ke=q[10],Be=q[11],be=q[12],Ne=q[13],$e=q[14],_e=q[15];v=L[0],W+=v*pe,J+=v*Pe,X+=v*Fe,se+=v*ge,ne+=v*Le,Me+=v*Te,Ce+=v*ye,ue+=v*Ue,xe+=v*ze,Ae+=v*we,re+=v*ke,ve+=v*Be,le+=v*be,ee+=v*Ne,de+=v*$e,fe+=v*_e,v=L[1],J+=v*pe,X+=v*Pe,se+=v*Fe,ne+=v*ge,Me+=v*Le,Ce+=v*Te,ue+=v*ye,xe+=v*Ue,Ae+=v*ze,re+=v*we,ve+=v*ke,le+=v*Be,ee+=v*be,de+=v*Ne,fe+=v*$e,te+=v*_e,v=L[2],X+=v*pe,se+=v*Pe,ne+=v*Fe,Me+=v*ge,Ce+=v*Le,ue+=v*Te,xe+=v*ye,Ae+=v*Ue,re+=v*ze,ve+=v*we,le+=v*ke,ee+=v*Be,de+=v*be,fe+=v*Ne,te+=v*$e,Ee+=v*_e,v=L[3],se+=v*pe,ne+=v*Pe,Me+=v*Fe,Ce+=v*ge,ue+=v*Le,xe+=v*Te,Ae+=v*ye,re+=v*Ue,ve+=v*ze,le+=v*we,ee+=v*ke,de+=v*Be,fe+=v*be,te+=v*Ne,Ee+=v*$e,he+=v*_e,v=L[4],ne+=v*pe,Me+=v*Pe,Ce+=v*Fe,ue+=v*ge,xe+=v*Le,Ae+=v*Te,re+=v*ye,ve+=v*Ue,le+=v*ze,ee+=v*we,de+=v*ke,fe+=v*Be,te+=v*be,Ee+=v*Ne,he+=v*$e,ae+=v*_e,v=L[5],Me+=v*pe,Ce+=v*Pe,ue+=v*Fe,xe+=v*ge,Ae+=v*Le,re+=v*Te,ve+=v*ye,le+=v*Ue,ee+=v*ze,de+=v*we,fe+=v*ke,te+=v*Be,Ee+=v*be,he+=v*Ne,ae+=v*$e,Se+=v*_e,v=L[6],Ce+=v*pe,ue+=v*Pe,xe+=v*Fe,Ae+=v*ge,re+=v*Le,ve+=v*Te,le+=v*ye,ee+=v*Ue,de+=v*ze,fe+=v*we,te+=v*ke,Ee+=v*Be,he+=v*be,ae+=v*Ne,Se+=v*$e,De+=v*_e,v=L[7],ue+=v*pe,xe+=v*Pe,Ae+=v*Fe,re+=v*ge,ve+=v*Le,le+=v*Te,ee+=v*ye,de+=v*Ue,fe+=v*ze,te+=v*we,Ee+=v*ke,he+=v*Be,ae+=v*be,Se+=v*Ne,De+=v*$e,ce+=v*_e,v=L[8],xe+=v*pe,Ae+=v*Pe,re+=v*Fe,ve+=v*ge,le+=v*Le,ee+=v*Te,de+=v*ye,fe+=v*Ue,te+=v*ze,Ee+=v*we,he+=v*ke,ae+=v*Be,Se+=v*be,De+=v*Ne,ce+=v*$e,Ie+=v*_e,v=L[9],Ae+=v*pe,re+=v*Pe,ve+=v*Fe,le+=v*ge,ee+=v*Le,de+=v*Te,fe+=v*ye,te+=v*Ue,Ee+=v*ze,he+=v*we,ae+=v*ke,Se+=v*Be,De+=v*be,ce+=v*Ne,Ie+=v*$e,We+=v*_e,v=L[10],re+=v*pe,ve+=v*Pe,le+=v*Fe,ee+=v*ge,de+=v*Le,fe+=v*Te,te+=v*ye,Ee+=v*Ue,he+=v*ze,ae+=v*we,Se+=v*ke,De+=v*Be,ce+=v*be,Ie+=v*Ne,We+=v*$e,Oe+=v*_e,v=L[11],ve+=v*pe,le+=v*Pe,ee+=v*Fe,de+=v*ge,fe+=v*Le,te+=v*Te,Ee+=v*ye,he+=v*Ue,ae+=v*ze,Se+=v*we,De+=v*ke,ce+=v*Be,Ie+=v*be,We+=v*Ne,Oe+=v*$e,Qe+=v*_e,v=L[12],le+=v*pe,ee+=v*Pe,de+=v*Fe,fe+=v*ge,te+=v*Le,Ee+=v*Te,he+=v*ye,ae+=v*Ue,Se+=v*ze,De+=v*we,ce+=v*ke,Ie+=v*Be,We+=v*be,Oe+=v*Ne,Qe+=v*$e,He+=v*_e,v=L[13],ee+=v*pe,de+=v*Pe,fe+=v*Fe,te+=v*ge,Ee+=v*Le,he+=v*Te,ae+=v*ye,Se+=v*Ue,De+=v*ze,ce+=v*we,Ie+=v*ke,We+=v*Be,Oe+=v*be,Qe+=v*Ne,He+=v*$e,Re+=v*_e,v=L[14],de+=v*pe,fe+=v*Pe,te+=v*Fe,Ee+=v*ge,he+=v*Le,ae+=v*Te,Se+=v*ye,De+=v*Ue,ce+=v*ze,Ie+=v*we,We+=v*ke,Oe+=v*Be,Qe+=v*be,He+=v*Ne,Re+=v*$e,tt+=v*_e,v=L[15],fe+=v*pe,te+=v*Pe,Ee+=v*Fe,he+=v*ge,ae+=v*Le,Se+=v*Te,De+=v*ye,ce+=v*Ue,Ie+=v*ze,We+=v*we,Oe+=v*ke,Qe+=v*Be,He+=v*be,Re+=v*Ne,tt+=v*$e,rt+=v*_e,W+=38*te,J+=38*Ee,X+=38*he,se+=38*ae,ne+=38*Se,Me+=38*De,Ce+=38*ce,ue+=38*Ie,xe+=38*We,Ae+=38*Oe,re+=38*Qe,ve+=38*He,le+=38*Re,ee+=38*tt,de+=38*rt,T=1,v=W+T+65535,T=Math.floor(v/65536),W=v-T*65536,v=J+T+65535,T=Math.floor(v/65536),J=v-T*65536,v=X+T+65535,T=Math.floor(v/65536),X=v-T*65536,v=se+T+65535,T=Math.floor(v/65536),se=v-T*65536,v=ne+T+65535,T=Math.floor(v/65536),ne=v-T*65536,v=Me+T+65535,T=Math.floor(v/65536),Me=v-T*65536,v=Ce+T+65535,T=Math.floor(v/65536),Ce=v-T*65536,v=ue+T+65535,T=Math.floor(v/65536),ue=v-T*65536,v=xe+T+65535,T=Math.floor(v/65536),xe=v-T*65536,v=Ae+T+65535,T=Math.floor(v/65536),Ae=v-T*65536,v=re+T+65535,T=Math.floor(v/65536),re=v-T*65536,v=ve+T+65535,T=Math.floor(v/65536),ve=v-T*65536,v=le+T+65535,T=Math.floor(v/65536),le=v-T*65536,v=ee+T+65535,T=Math.floor(v/65536),ee=v-T*65536,v=de+T+65535,T=Math.floor(v/65536),de=v-T*65536,v=fe+T+65535,T=Math.floor(v/65536),fe=v-T*65536,W+=T-1+37*(T-1),T=1,v=W+T+65535,T=Math.floor(v/65536),W=v-T*65536,v=J+T+65535,T=Math.floor(v/65536),J=v-T*65536,v=X+T+65535,T=Math.floor(v/65536),X=v-T*65536,v=se+T+65535,T=Math.floor(v/65536),se=v-T*65536,v=ne+T+65535,T=Math.floor(v/65536),ne=v-T*65536,v=Me+T+65535,T=Math.floor(v/65536),Me=v-T*65536,v=Ce+T+65535,T=Math.floor(v/65536),Ce=v-T*65536,v=ue+T+65535,T=Math.floor(v/65536),ue=v-T*65536,v=xe+T+65535,T=Math.floor(v/65536),xe=v-T*65536,v=Ae+T+65535,T=Math.floor(v/65536),Ae=v-T*65536,v=re+T+65535,T=Math.floor(v/65536),re=v-T*65536,v=ve+T+65535,T=Math.floor(v/65536),ve=v-T*65536,v=le+T+65535,T=Math.floor(v/65536),le=v-T*65536,v=ee+T+65535,T=Math.floor(v/65536),ee=v-T*65536,v=de+T+65535,T=Math.floor(v/65536),de=v-T*65536,v=fe+T+65535,T=Math.floor(v/65536),fe=v-T*65536,W+=T-1+37*(T-1),R[0]=W,R[1]=J,R[2]=X,R[3]=se,R[4]=ne,R[5]=Me,R[6]=Ce,R[7]=ue,R[8]=xe,R[9]=Ae,R[10]=re,R[11]=ve,R[12]=le,R[13]=ee,R[14]=de,R[15]=fe}function O(R,L){y(R,L,L)}function Y(R,L){const q=n();let v;for(v=0;v<16;v++)q[v]=L[v];for(v=253;v>=0;v--)O(q,q),v!==2&&v!==4&&y(q,q,L);for(v=0;v<16;v++)R[v]=q[v]}function Q(R,L){const q=n();let v;for(v=0;v<16;v++)q[v]=L[v];for(v=250;v>=0;v--)O(q,q),v!==1&&y(q,q,L);for(v=0;v<16;v++)R[v]=q[v]}function N(R,L){const q=n(),v=n(),T=n(),W=n(),J=n(),X=n(),se=n(),ne=n(),Me=n();U(q,R[1],R[0]),U(Me,L[1],L[0]),y(q,q,Me),B(v,R[0],R[1]),B(Me,L[0],L[1]),y(v,v,Me),y(T,R[3],L[3]),y(T,T,u),y(W,R[2],L[2]),B(W,W,W),U(J,v,q),U(X,W,T),B(se,W,T),B(ne,v,q),y(R[0],J,X),y(R[1],ne,se),y(R[2],se,X),y(R[3],J,ne)}function g(R,L,q){for(let v=0;v<4;v++)F(R[v],L[v],q)}function a(R,L){const q=n(),v=n(),T=n();Y(T,L[2]),y(q,L[0],T),y(v,L[1],T),k(R,v),R[31]^=$(q)<<7}function f(R,L,q){S(R[0],o),S(R[1],c),S(R[2],c),S(R[3],o);for(let v=255;v>=0;--v){const T=q[v/8|0]>>(v&7)&1;g(R,L,T),N(L,R),N(R,R),g(R,L,T)}}function p(R,L){const q=[n(),n(),n(),n()];S(q[0],b),S(q[1],m),S(q[2],c),y(q[3],b,m),f(R,q,L)}function w(R){if(R.length!==t.SEED_LENGTH)throw new Error(`ed25519: seed must be ${t.SEED_LENGTH} bytes`);const L=(0,r.hash)(R);L[0]&=248,L[31]&=127,L[31]|=64;const q=new Uint8Array(32),v=[n(),n(),n(),n()];p(v,L),a(q,v);const T=new Uint8Array(64);return T.set(R),T.set(q,32),{publicKey:q,secretKey:T}}t.generateKeyPairFromSeed=w;function A(R){const L=(0,e.randomBytes)(32,R),q=w(L);return(0,i.wipe)(L),q}t.generateKeyPair=A;function x(R){if(R.length!==t.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${t.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(R.subarray(32))}t.extractPublicKeyFromSecretKey=x;const _=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function h(R,L){let q,v,T,W;for(v=63;v>=32;--v){for(q=0,T=v-32,W=v-12;T<W;++T)L[T]+=q-16*L[v]*_[T-(v-32)],q=Math.floor((L[T]+128)/256),L[T]-=q*256;L[T]+=q,L[v]=0}for(q=0,T=0;T<32;T++)L[T]+=q-(L[31]>>4)*_[T],q=L[T]>>8,L[T]&=255;for(T=0;T<32;T++)L[T]-=q*_[T];for(v=0;v<32;v++)L[v+1]+=L[v]>>8,R[v]=L[v]&255}function d(R){const L=new Float64Array(64);for(let q=0;q<64;q++)L[q]=R[q];for(let q=0;q<64;q++)R[q]=0;h(R,L)}function D(R,L){const q=new Float64Array(64),v=[n(),n(),n(),n()],T=(0,r.hash)(R.subarray(0,32));T[0]&=248,T[31]&=127,T[31]|=64;const W=new Uint8Array(64);W.set(T.subarray(32),32);const J=new r.SHA512;J.update(W.subarray(32)),J.update(L);const X=J.digest();J.clean(),d(X),p(v,X),a(W,v),J.reset(),J.update(W.subarray(0,32)),J.update(R.subarray(32)),J.update(L);const se=J.digest();d(se);for(let ne=0;ne<32;ne++)q[ne]=X[ne];for(let ne=0;ne<32;ne++)for(let Me=0;Me<32;Me++)q[ne+Me]+=se[ne]*T[Me];return h(W.subarray(32),q),W}t.sign=D;function K(R,L){const q=n(),v=n(),T=n(),W=n(),J=n(),X=n(),se=n();return S(R[2],c),P(R[1],L),O(T,R[1]),y(W,T,l),U(T,T,R[2]),B(W,R[2],W),O(J,W),O(X,J),y(se,X,J),y(q,se,T),y(q,q,W),Q(q,q),y(q,q,T),y(q,q,W),y(q,q,W),y(R[0],q,W),O(v,R[0]),y(v,v,W),C(v,T)&&y(R[0],R[0],M),O(v,R[0]),y(v,v,W),C(v,T)?-1:($(R[0])===L[31]>>7&&U(R[0],o,R[0]),y(R[3],R[0],R[1]),0)}function G(R,L,q){const v=new Uint8Array(32),T=[n(),n(),n(),n()],W=[n(),n(),n(),n()];if(q.length!==t.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${t.SIGNATURE_LENGTH} bytes`);if(K(W,R))return!1;const J=new r.SHA512;J.update(q.subarray(0,32)),J.update(R),J.update(L);const X=J.digest();return d(X),f(T,W,X),p(W,q.subarray(32)),N(T,W),a(v,T),!j(q,v)}t.verify=G;function E(R){let L=[n(),n(),n(),n()];if(K(L,R))throw new Error("Ed25519: invalid public key");let q=n(),v=n(),T=L[1];B(q,c,T),U(v,c,T),Y(v,v),y(q,q,v);let W=new Uint8Array(32);return k(W,q),W}t.convertPublicKeyToX25519=E;function H(R){const L=(0,r.hash)(R.subarray(0,32));L[0]&=248,L[31]&=127,L[31]|=64;const q=new Uint8Array(L.subarray(0,32));return(0,i.wipe)(L),q}t.convertSecretKeyToX25519=H}(Mo);const cg="EdDSA",fg="JWT",ua=".",da="base64url",Qf="utf8",Xf="utf8",hg=":",ug="did",dg="key",Zf="base58btc",lg="z",pg="K36",gg=32;function eh(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function la(t,e){e||(e=t.reduce((n,s)=>n+s.length,0));const r=eh(e);let i=0;for(const n of t)r.set(n,i),i+=n.length;return r}function bg(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 c=t.length,l=t.charAt(0),u=Math.log(c)/Math.log(256),b=Math.log(256)/Math.log(c);function m(I){if(I instanceof Uint8Array||(ArrayBuffer.isView(I)?I=new Uint8Array(I.buffer,I.byteOffset,I.byteLength):Array.isArray(I)&&(I=Uint8Array.from(I))),!(I instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(I.length===0)return"";for(var F=0,k=0,j=0,C=I.length;j!==C&&I[j]===0;)j++,F++;for(var $=(C-j)*b+1>>>0,P=new Uint8Array($);j!==C;){for(var B=I[j],U=0,y=$-1;(B!==0||U<k)&&y!==-1;y--,U++)B+=256*P[y]>>>0,P[y]=B%c>>>0,B=B/c>>>0;if(B!==0)throw new Error("Non-zero carry");k=U,j++}for(var O=$-k;O!==$&&P[O]===0;)O++;for(var Y=l.repeat(F);O<$;++O)Y+=t.charAt(P[O]);return Y}function M(I){if(typeof I!="string")throw new TypeError("Expected String");if(I.length===0)return new Uint8Array;var F=0;if(I[F]!==" "){for(var k=0,j=0;I[F]===l;)k++,F++;for(var C=(I.length-F)*u+1>>>0,$=new Uint8Array(C);I[F];){var P=r[I.charCodeAt(F)];if(P===255)return;for(var B=0,U=C-1;(P!==0||B<j)&&U!==-1;U--,B++)P+=c*$[U]>>>0,$[U]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");j=B,F++}if(I[F]!==" "){for(var y=C-j;y!==C&&$[y]===0;)y++;for(var O=new Uint8Array(k+(C-y)),Y=k;y!==C;)O[Y++]=$[y++];return O}}}function S(I){var F=M(I);if(F)return F;throw new Error(`Non-${e} character`)}return{encode:m,decodeUnsafe:M,decode:S}}var vg=bg,mg=vg;const th=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")},yg=t=>new TextEncoder().encode(t),wg=t=>new TextDecoder().decode(t);class _g{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 Ag{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 rh(this,e)}}class Eg{constructor(e){this.decoders=e}or(e){return rh(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 rh=(t,e)=>new Eg({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class xg{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new _g(e,r,i),this.decoder=new Ag(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const pa=({name:t,prefix:e,encode:r,decode:i})=>new xg(t,e,r,i),us=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=mg(r,e);return pa({prefix:t,name:e,encode:i,decode:s=>th(n(s))})},Sg=(t,e,r,i)=>{const n={};for(let b=0;b<e.length;++b)n[e[b]]=b;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let c=0,l=0,u=0;for(let b=0;b<s;++b){const m=n[t[b]];if(m===void 0)throw new SyntaxError(`Non-${i} character`);l=l<<r|m,c+=r,c>=8&&(c-=8,o[u++]=255&l>>c)}if(c>=r||255&l<<8-c)throw new SyntaxError("Unexpected end of data");return o},Mg=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",o=0,c=0;for(let l=0;l<t.length;++l)for(c=c<<8|t[l],o+=8;o>r;)o-=r,s+=e[n&c>>o];if(o&&(s+=e[n&c<<r-o]),i)for(;s.length*r&7;)s+="=";return s},Nt=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>pa({prefix:e,name:t,encode(n){return Mg(n,i,r)},decode(n){return Sg(n,i,r,t)}}),Ig=pa({prefix:"\0",name:"identity",encode:t=>wg(t),decode:t=>yg(t)});var Dg=Object.freeze({__proto__:null,identity:Ig});const Og=Nt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Rg=Object.freeze({__proto__:null,base2:Og});const Ng=Nt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Pg=Object.freeze({__proto__:null,base8:Ng});const Tg=us({prefix:"9",name:"base10",alphabet:"0123456789"});var Cg=Object.freeze({__proto__:null,base10:Tg});const Fg=Nt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Lg=Nt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Bg=Object.freeze({__proto__:null,base16:Fg,base16upper:Lg});const qg=Nt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ug=Nt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),zg=Nt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),kg=Nt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),$g=Nt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),jg=Nt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Kg=Nt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Hg=Nt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Vg=Nt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Gg=Object.freeze({__proto__:null,base32:qg,base32upper:Ug,base32pad:zg,base32padupper:kg,base32hex:$g,base32hexupper:jg,base32hexpad:Kg,base32hexpadupper:Hg,base32z:Vg});const Wg=us({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Yg=us({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Jg=Object.freeze({__proto__:null,base36:Wg,base36upper:Yg});const Qg=us({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Xg=us({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Zg=Object.freeze({__proto__:null,base58btc:Qg,base58flickr:Xg});const eb=Nt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),tb=Nt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),rb=Nt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ib=Nt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var nb=Object.freeze({__proto__:null,base64:eb,base64pad:tb,base64url:rb,base64urlpad:ib});const ih=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}"),sb=ih.reduce((t,e,r)=>(t[r]=e,t),[]),ab=ih.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function ob(t){return t.reduce((e,r)=>(e+=sb[r],e),"")}function cb(t){const e=[];for(const r of t){const i=ab[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const fb=pa({prefix:"\u{1F680}",name:"base256emoji",encode:ob,decode:cb});var hb=Object.freeze({__proto__:null,base256emoji:fb}),ub=sh,nh=128,db=127,lb=~db,pb=Math.pow(2,31);function sh(t,e,r){e=e||[],r=r||0;for(var i=r;t>=pb;)e[r++]=t&255|nh,t/=128;for(;t&lb;)e[r++]=t&255|nh,t>>>=7;return e[r]=t|0,sh.bytes=r-i+1,e}var gb=Po,bb=128,ah=127;function Po(t,i){var r=0,i=i||0,n=0,s=i,o,c=t.length;do{if(s>=c)throw Po.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=n<28?(o&ah)<<n:(o&ah)*Math.pow(2,n),n+=7}while(o>=bb);return Po.bytes=s-i,r}var vb=Math.pow(2,7),mb=Math.pow(2,14),yb=Math.pow(2,21),wb=Math.pow(2,28),_b=Math.pow(2,35),Ab=Math.pow(2,42),Eb=Math.pow(2,49),xb=Math.pow(2,56),Sb=Math.pow(2,63),Mb=function(t){return t<vb?1:t<mb?2:t<yb?3:t<wb?4:t<_b?5:t<Ab?6:t<Eb?7:t<xb?8:t<Sb?9:10},Ib={encode:ub,decode:gb,encodingLength:Mb},oh=Ib;const ch=(t,e,r=0)=>(oh.encode(t,e,r),e),fh=t=>oh.encodingLength(t),To=(t,e)=>{const r=e.byteLength,i=fh(t),n=i+fh(r),s=new Uint8Array(n+r);return ch(t,s,0),ch(r,s,i),s.set(e,n),new Db(t,r,e,s)};class Db{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const hh=({name:t,code:e,encode:r})=>new Ob(t,e,r);class Ob{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?To(this.code,r):r.then(i=>To(this.code,i))}else throw Error("Unknown type, must be binary type")}}const uh=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Rb=hh({name:"sha2-256",code:18,encode:uh("SHA-256")}),Nb=hh({name:"sha2-512",code:19,encode:uh("SHA-512")});var Pb=Object.freeze({__proto__:null,sha256:Rb,sha512:Nb});const dh=0,Tb="identity",lh=th;var Cb=Object.freeze({__proto__:null,identity:{code:dh,name:Tb,encode:lh,digest:t=>To(dh,lh(t))}});new TextEncoder,new TextDecoder;const ph={...Dg,...Rg,...Pg,...Cg,...Bg,...Gg,...Jg,...Zg,...nb,...hb};({...Pb,...Cb});function gh(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const bh=gh("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Co=gh("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=eh(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),vh={utf8:bh,"utf-8":bh,hex:ph.base16,latin1:Co,ascii:Co,binary:Co,...ph};function Et(t,e="utf8"){const r=vh[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 xt(t,e="utf8"){const r=vh[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 mh(t){return Sn(Et(xt(t,da),Qf))}function ga(t){return Et(xt(Xi(t),Qf),da)}function yh(t){const e=xt(pg,Zf),r=lg+Et(la([e,t]),Zf);return[ug,dg,r].join(hg)}function Fb(t){return Et(t,da)}function Lb(t){return xt(t,da)}function Bb(t){return xt([ga(t.header),ga(t.payload)].join(ua),Xf)}function qb(t){return[ga(t.header),ga(t.payload),Fb(t.signature)].join(ua)}function Fo(t){const e=t.split(ua),r=mh(e[0]),i=mh(e[1]),n=Lb(e[2]),s=xt(e.slice(0,2).join(ua),Xf);return{header:r,payload:i,signature:n,data:s}}function wh(t=Ci.randomBytes(gg)){return Mo.generateKeyPairFromSeed(t)}async function Ub(t,e,r,i,n=oe.fromMiliseconds(Date.now())){const s={alg:cg,typ:fg},o=yh(i.publicKey),c=n+r,l={iss:o,sub:t,aud:e,iat:n,exp:c},u=Bb({header:s,payload:l}),b=Mo.sign(i.secretKey,u);return qb({header:s,payload:l,signature:b})}var _h=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))},zb=function(){function t(e,r,i){this.name=e,this.version=r,this.os=i,this.type="browser"}return t}(),kb=function(){function t(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return t}(),$b=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}(),jb=function(){function t(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return t}(),Kb=function(){function t(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return t}(),Hb=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,Vb=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Ah=3,Gb=[["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",Hb]],Eh=[["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 Wb(t){return t?xh(t):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new Kb:typeof navigator<"u"?xh(navigator.userAgent):Qb()}function Yb(t){return t!==""&&Gb.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 xh(t){var e=Yb(t);if(!e)return null;var r=e[0],i=e[1];if(r==="searchbot")return new jb;var n=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);n?n.length<Ah&&(n=_h(_h([],n,!0),Xb(Ah-n.length),!0)):n=[];var s=n.join("."),o=Jb(t),c=Vb.exec(t);return c&&c[1]?new $b(r,s,o,c[1]):new zb(r,s,o)}function Jb(t){for(var e=0,r=Eh.length;e<r;e++){var i=Eh[e],n=i[0],s=i[1],o=s.exec(t);if(o)return n}return null}function Qb(){var t=typeof process<"u"&&process.version;return t?new kb(process.version.slice(1)):null}function Xb(t){for(var e=[],r=0;r<t;r++)e.push("0");return e}var ot={};Object.defineProperty(ot,"__esModule",{value:!0}),ot.getLocalStorage=ot.getLocalStorageOrThrow=ot.getCrypto=ot.getCryptoOrThrow=Sh=ot.getLocation=ot.getLocationOrThrow=Lo=ot.getNavigator=ot.getNavigatorOrThrow=ba=ot.getDocument=ot.getDocumentOrThrow=ot.getFromWindowOrThrow=ot.getFromWindow=void 0;function Zi(t){let e;return typeof window<"u"&&typeof window[t]<"u"&&(e=window[t]),e}ot.getFromWindow=Zi;function Dn(t){const e=Zi(t);if(!e)throw new Error(`${t} is not defined in Window`);return e}ot.getFromWindowOrThrow=Dn;function Zb(){return Dn("document")}ot.getDocumentOrThrow=Zb;function e2(){return Zi("document")}var ba=ot.getDocument=e2;function t2(){return Dn("navigator")}ot.getNavigatorOrThrow=t2;function r2(){return Zi("navigator")}var Lo=ot.getNavigator=r2;function i2(){return Dn("location")}ot.getLocationOrThrow=i2;function n2(){return Zi("location")}var Sh=ot.getLocation=n2;function s2(){return Dn("crypto")}ot.getCryptoOrThrow=s2;function a2(){return Zi("crypto")}ot.getCrypto=a2;function o2(){return Dn("localStorage")}ot.getLocalStorageOrThrow=o2;function c2(){return Zi("localStorage")}ot.getLocalStorage=c2;var Bo={};Object.defineProperty(Bo,"__esModule",{value:!0});var Mh=Bo.getWindowMetadata=void 0;const Ih=ot;function f2(){let t,e;try{t=Ih.getDocumentOrThrow(),e=Ih.getLocationOrThrow()}catch{return null}function r(){const m=t.getElementsByTagName("link"),M=[];for(let S=0;S<m.length;S++){const I=m[S],F=I.getAttribute("rel");if(F&&F.toLowerCase().indexOf("icon")>-1){const k=I.getAttribute("href");if(k)if(k.toLowerCase().indexOf("https:")===-1&&k.toLowerCase().indexOf("http:")===-1&&k.indexOf("//")!==0){let j=e.protocol+"//"+e.host;if(k.indexOf("/")===0)j+=k;else{const C=e.pathname.split("/");C.pop();const $=C.join("/");j+=$+"/"+k}M.push(j)}else if(k.indexOf("//")===0){const j=e.protocol+k;M.push(j)}else M.push(k)}}return M}function i(...m){const M=t.getElementsByTagName("meta");for(let S=0;S<M.length;S++){const I=M[S],F=["itemprop","property","name"].map(k=>I.getAttribute(k)).filter(k=>k?m.includes(k):!1);if(F.length&&F){const k=I.getAttribute("content");if(k)return k}}return""}function n(){let m=i("name","og:site_name","og:title","twitter:title");return m||(m=t.title),m}function s(){return i("description","og:description","twitter:description","keywords")}const o=n(),c=s(),l=e.origin,u=r();return{description:c,url:l,icons:u,name:o}}Mh=Bo.getWindowMetadata=f2;var ds={},h2=t=>encodeURIComponent(t).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),Dh="%[a-f0-9]{2}",Oh=new RegExp("("+Dh+")|([^%]+?)","gi"),Rh=new RegExp("("+Dh+")+","gi");function qo(t,e){try{return[decodeURIComponent(t.join(""))]}catch{}if(t.length===1)return t;e=e||1;var r=t.slice(0,e),i=t.slice(e);return Array.prototype.concat.call([],qo(r),qo(i))}function u2(t){try{return decodeURIComponent(t)}catch{for(var e=t.match(Oh)||[],r=1;r<e.length;r++)t=qo(e,r).join(""),e=t.match(Oh)||[];return t}}function d2(t){for(var e={"%FE%FF":"\uFFFD\uFFFD","%FF%FE":"\uFFFD\uFFFD"},r=Rh.exec(t);r;){try{e[r[0]]=decodeURIComponent(r[0])}catch{var i=u2(r[0]);i!==r[0]&&(e[r[0]]=i)}r=Rh.exec(t)}e["%C2"]="\uFFFD";for(var n=Object.keys(e),s=0;s<n.length;s++){var o=n[s];t=t.replace(new RegExp(o,"g"),e[o])}return t}var l2=function(t){if(typeof t!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof t+"`");try{return t=t.replace(/\+/g," "),decodeURIComponent(t)}catch{return d2(t)}},p2=(t,e)=>{if(!(typeof t=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[t];const r=t.indexOf(e);return r===-1?[t]:[t.slice(0,r),t.slice(r+e.length)]},g2=function(t,e){for(var r={},i=Object.keys(t),n=Array.isArray(e),s=0;s<i.length;s++){var o=i[s],c=t[o];(n?e.indexOf(o)!==-1:e(o,c,t))&&(r[o]=c)}return r};(function(t){const e=h2,r=l2,i=p2,n=g2,s=C=>C==null,o=Symbol("encodeFragmentIdentifier");function c(C){switch(C.arrayFormat){case"index":return $=>(P,B)=>{const U=P.length;return B===void 0||C.skipNull&&B===null||C.skipEmptyString&&B===""?P:B===null?[...P,[b($,C),"[",U,"]"].join("")]:[...P,[b($,C),"[",b(U,C),"]=",b(B,C)].join("")]};case"bracket":return $=>(P,B)=>B===void 0||C.skipNull&&B===null||C.skipEmptyString&&B===""?P:B===null?[...P,[b($,C),"[]"].join("")]:[...P,[b($,C),"[]=",b(B,C)].join("")];case"colon-list-separator":return $=>(P,B)=>B===void 0||C.skipNull&&B===null||C.skipEmptyString&&B===""?P:B===null?[...P,[b($,C),":list="].join("")]:[...P,[b($,C),":list=",b(B,C)].join("")];case"comma":case"separator":case"bracket-separator":{const $=C.arrayFormat==="bracket-separator"?"[]=":"=";return P=>(B,U)=>U===void 0||C.skipNull&&U===null||C.skipEmptyString&&U===""?B:(U=U===null?"":U,B.length===0?[[b(P,C),$,b(U,C)].join("")]:[[B,b(U,C)].join(C.arrayFormatSeparator)])}default:return $=>(P,B)=>B===void 0||C.skipNull&&B===null||C.skipEmptyString&&B===""?P:B===null?[...P,b($,C)]:[...P,[b($,C),"=",b(B,C)].join("")]}}function l(C){let $;switch(C.arrayFormat){case"index":return(P,B,U)=>{if($=/\[(\d*)\]$/.exec(P),P=P.replace(/\[\d*\]$/,""),!$){U[P]=B;return}U[P]===void 0&&(U[P]={}),U[P][$[1]]=B};case"bracket":return(P,B,U)=>{if($=/(\[\])$/.exec(P),P=P.replace(/\[\]$/,""),!$){U[P]=B;return}if(U[P]===void 0){U[P]=[B];return}U[P]=[].concat(U[P],B)};case"colon-list-separator":return(P,B,U)=>{if($=/(:list)$/.exec(P),P=P.replace(/:list$/,""),!$){U[P]=B;return}if(U[P]===void 0){U[P]=[B];return}U[P]=[].concat(U[P],B)};case"comma":case"separator":return(P,B,U)=>{const y=typeof B=="string"&&B.includes(C.arrayFormatSeparator),O=typeof B=="string"&&!y&&m(B,C).includes(C.arrayFormatSeparator);B=O?m(B,C):B;const Y=y||O?B.split(C.arrayFormatSeparator).map(Q=>m(Q,C)):B===null?B:m(B,C);U[P]=Y};case"bracket-separator":return(P,B,U)=>{const y=/(\[\])$/.test(P);if(P=P.replace(/\[\]$/,""),!y){U[P]=B&&m(B,C);return}const O=B===null?[]:B.split(C.arrayFormatSeparator).map(Y=>m(Y,C));if(U[P]===void 0){U[P]=O;return}U[P]=[].concat(U[P],O)};default:return(P,B,U)=>{if(U[P]===void 0){U[P]=B;return}U[P]=[].concat(U[P],B)}}}function u(C){if(typeof C!="string"||C.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function b(C,$){return $.encode?$.strict?e(C):encodeURIComponent(C):C}function m(C,$){return $.decode?r(C):C}function M(C){return Array.isArray(C)?C.sort():typeof C=="object"?M(Object.keys(C)).sort(($,P)=>Number($)-Number(P)).map($=>C[$]):C}function S(C){const $=C.indexOf("#");return $!==-1&&(C=C.slice(0,$)),C}function I(C){let $="";const P=C.indexOf("#");return P!==-1&&($=C.slice(P)),$}function F(C){C=S(C);const $=C.indexOf("?");return $===-1?"":C.slice($+1)}function k(C,$){return $.parseNumbers&&!Number.isNaN(Number(C))&&typeof C=="string"&&C.trim()!==""?C=Number(C):$.parseBooleans&&C!==null&&(C.toLowerCase()==="true"||C.toLowerCase()==="false")&&(C=C.toLowerCase()==="true"),C}function j(C,$){$=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},$),u($.arrayFormatSeparator);const P=l($),B=Object.create(null);if(typeof C!="string"||(C=C.trim().replace(/^[?#&]/,""),!C))return B;for(const U of C.split("&")){if(U==="")continue;let[y,O]=i($.decode?U.replace(/\+/g," "):U,"=");O=O===void 0?null:["comma","separator","bracket-separator"].includes($.arrayFormat)?O:m(O,$),P(m(y,$),O,B)}for(const U of Object.keys(B)){const y=B[U];if(typeof y=="object"&&y!==null)for(const O of Object.keys(y))y[O]=k(y[O],$);else B[U]=k(y,$)}return $.sort===!1?B:($.sort===!0?Object.keys(B).sort():Object.keys(B).sort($.sort)).reduce((U,y)=>{const O=B[y];return O&&typeof O=="object"&&!Array.isArray(O)?U[y]=M(O):U[y]=O,U},Object.create(null))}t.extract=F,t.parse=j,t.stringify=(C,$)=>{if(!C)return"";$=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},$),u($.arrayFormatSeparator);const P=O=>$.skipNull&&s(C[O])||$.skipEmptyString&&C[O]==="",B=c($),U={};for(const O of Object.keys(C))P(O)||(U[O]=C[O]);const y=Object.keys(U);return $.sort!==!1&&y.sort($.sort),y.map(O=>{const Y=C[O];return Y===void 0?"":Y===null?b(O,$):Array.isArray(Y)?Y.length===0&&$.arrayFormat==="bracket-separator"?b(O,$)+"[]":Y.reduce(B(O),[]).join("&"):b(O,$)+"="+b(Y,$)}).filter(O=>O.length>0).join("&")},t.parseUrl=(C,$)=>{$=Object.assign({decode:!0},$);const[P,B]=i(C,"#");return Object.assign({url:P.split("?")[0]||"",query:j(F(C),$)},$&&$.parseFragmentIdentifier&&B?{fragmentIdentifier:m(B,$)}:{})},t.stringifyUrl=(C,$)=>{$=Object.assign({encode:!0,strict:!0,[o]:!0},$);const P=S(C.url).split("?")[0]||"",B=t.extract(C.url),U=t.parse(B,{sort:!1}),y=Object.assign(U,C.query);let O=t.stringify(y,$);O&&(O=`?${O}`);let Y=I(C.url);return C.fragmentIdentifier&&(Y=`#${$[o]?b(C.fragmentIdentifier,$):C.fragmentIdentifier}`),`${P}${O}${Y}`},t.pick=(C,$,P)=>{P=Object.assign({parseFragmentIdentifier:!0,[o]:!1},P);const{url:B,query:U,fragmentIdentifier:y}=t.parseUrl(C,P);return t.stringifyUrl({url:B,query:n(U,$),fragmentIdentifier:y},P)},t.exclude=(C,$,P)=>{const B=Array.isArray($)?U=>!$.includes(U):(U,y)=>!$(U,y);return t.pick(C,B,P)}})(ds);var Uo={},va={};Object.defineProperty(va,"__esModule",{value:!0});var Ut=Ke,zo=fr,b2=20;function v2(t,e,r){for(var i=1634760805,n=857760878,s=2036477234,o=1797285236,c=r[3]<<24|r[2]<<16|r[1]<<8|r[0],l=r[7]<<24|r[6]<<16|r[5]<<8|r[4],u=r[11]<<24|r[10]<<16|r[9]<<8|r[8],b=r[15]<<24|r[14]<<16|r[13]<<8|r[12],m=r[19]<<24|r[18]<<16|r[17]<<8|r[16],M=r[23]<<24|r[22]<<16|r[21]<<8|r[20],S=r[27]<<24|r[26]<<16|r[25]<<8|r[24],I=r[31]<<24|r[30]<<16|r[29]<<8|r[28],F=e[3]<<24|e[2]<<16|e[1]<<8|e[0],k=e[7]<<24|e[6]<<16|e[5]<<8|e[4],j=e[11]<<24|e[10]<<16|e[9]<<8|e[8],C=e[15]<<24|e[14]<<16|e[13]<<8|e[12],$=i,P=n,B=s,U=o,y=c,O=l,Y=u,Q=b,N=m,g=M,a=S,f=I,p=F,w=k,A=j,x=C,_=0;_<b2;_+=2)$=$+y|0,p^=$,p=p>>>32-16|p<<16,N=N+p|0,y^=N,y=y>>>32-12|y<<12,P=P+O|0,w^=P,w=w>>>32-16|w<<16,g=g+w|0,O^=g,O=O>>>32-12|O<<12,B=B+Y|0,A^=B,A=A>>>32-16|A<<16,a=a+A|0,Y^=a,Y=Y>>>32-12|Y<<12,U=U+Q|0,x^=U,x=x>>>32-16|x<<16,f=f+x|0,Q^=f,Q=Q>>>32-12|Q<<12,B=B+Y|0,A^=B,A=A>>>32-8|A<<8,a=a+A|0,Y^=a,Y=Y>>>32-7|Y<<7,U=U+Q|0,x^=U,x=x>>>32-8|x<<8,f=f+x|0,Q^=f,Q=Q>>>32-7|Q<<7,P=P+O|0,w^=P,w=w>>>32-8|w<<8,g=g+w|0,O^=g,O=O>>>32-7|O<<7,$=$+y|0,p^=$,p=p>>>32-8|p<<8,N=N+p|0,y^=N,y=y>>>32-7|y<<7,$=$+O|0,x^=$,x=x>>>32-16|x<<16,a=a+x|0,O^=a,O=O>>>32-12|O<<12,P=P+Y|0,p^=P,p=p>>>32-16|p<<16,f=f+p|0,Y^=f,Y=Y>>>32-12|Y<<12,B=B+Q|0,w^=B,w=w>>>32-16|w<<16,N=N+w|0,Q^=N,Q=Q>>>32-12|Q<<12,U=U+y|0,A^=U,A=A>>>32-16|A<<16,g=g+A|0,y^=g,y=y>>>32-12|y<<12,B=B+Q|0,w^=B,w=w>>>32-8|w<<8,N=N+w|0,Q^=N,Q=Q>>>32-7|Q<<7,U=U+y|0,A^=U,A=A>>>32-8|A<<8,g=g+A|0,y^=g,y=y>>>32-7|y<<7,P=P+Y|0,p^=P,p=p>>>32-8|p<<8,f=f+p|0,Y^=f,Y=Y>>>32-7|Y<<7,$=$+O|0,x^=$,x=x>>>32-8|x<<8,a=a+x|0,O^=a,O=O>>>32-7|O<<7;Ut.writeUint32LE($+i|0,t,0),Ut.writeUint32LE(P+n|0,t,4),Ut.writeUint32LE(B+s|0,t,8),Ut.writeUint32LE(U+o|0,t,12),Ut.writeUint32LE(y+c|0,t,16),Ut.writeUint32LE(O+l|0,t,20),Ut.writeUint32LE(Y+u|0,t,24),Ut.writeUint32LE(Q+b|0,t,28),Ut.writeUint32LE(N+m|0,t,32),Ut.writeUint32LE(g+M|0,t,36),Ut.writeUint32LE(a+S|0,t,40),Ut.writeUint32LE(f+I|0,t,44),Ut.writeUint32LE(p+F|0,t,48),Ut.writeUint32LE(w+k|0,t,52),Ut.writeUint32LE(A+j|0,t,56),Ut.writeUint32LE(x+C|0,t,60)}function Nh(t,e,r,i,n){if(n===void 0&&(n=0),t.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(i.length<r.length)throw new Error("ChaCha: destination is shorter than source");var s,o;if(n===0){if(e.length!==8&&e.length!==12)throw new Error("ChaCha nonce must be 8 or 12 bytes");s=new Uint8Array(16),o=s.length-e.length,s.set(e,o)}else{if(e.length!==16)throw new Error("ChaCha nonce with counter must be 16 bytes");s=e,o=n}for(var c=new Uint8Array(64),l=0;l<r.length;l+=64){v2(c,s,t);for(var u=l;u<l+64&&u<r.length;u++)i[u]=r[u]^c[u-l];y2(s,0,o)}return zo.wipe(c),n===0&&zo.wipe(s),i}va.streamXOR=Nh;function m2(t,e,r,i){return i===void 0&&(i=0),zo.wipe(r),Nh(t,e,r,r,i)}va.stream=m2;function y2(t,e,r){for(var i=1;r--;)i=i+(t[e]&255)|0,t[e]=i&255,i>>>=8,e++;if(i>0)throw new Error("ChaCha: counter overflow")}var Ph={},Fi={};Object.defineProperty(Fi,"__esModule",{value:!0});function w2(t,e,r){return~(t-1)&e|t-1&r}Fi.select=w2;function _2(t,e){return(t|0)-(e|0)-1>>>31&1}Fi.lessOrEqual=_2;function Th(t,e){if(t.length!==e.length)return 0;for(var r=0,i=0;i<t.length;i++)r|=t[i]^e[i];return 1&r-1>>>8}Fi.compare=Th;function A2(t,e){return t.length===0||e.length===0?!1:Th(t,e)!==0}Fi.equal=A2,function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Fi,r=fr;t.DIGEST_LENGTH=16;var i=function(){function o(c){this.digestLength=t.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var l=c[0]|c[1]<<8;this._r[0]=l&8191;var u=c[2]|c[3]<<8;this._r[1]=(l>>>13|u<<3)&8191;var b=c[4]|c[5]<<8;this._r[2]=(u>>>10|b<<6)&7939;var m=c[6]|c[7]<<8;this._r[3]=(b>>>7|m<<9)&8191;var M=c[8]|c[9]<<8;this._r[4]=(m>>>4|M<<12)&255,this._r[5]=M>>>1&8190;var S=c[10]|c[11]<<8;this._r[6]=(M>>>14|S<<2)&8191;var I=c[12]|c[13]<<8;this._r[7]=(S>>>11|I<<5)&8065;var F=c[14]|c[15]<<8;this._r[8]=(I>>>8|F<<8)&8191,this._r[9]=F>>>5&127,this._pad[0]=c[16]|c[17]<<8,this._pad[1]=c[18]|c[19]<<8,this._pad[2]=c[20]|c[21]<<8,this._pad[3]=c[22]|c[23]<<8,this._pad[4]=c[24]|c[25]<<8,this._pad[5]=c[26]|c[27]<<8,this._pad[6]=c[28]|c[29]<<8,this._pad[7]=c[30]|c[31]<<8}return o.prototype._blocks=function(c,l,u){for(var b=this._fin?0:2048,m=this._h[0],M=this._h[1],S=this._h[2],I=this._h[3],F=this._h[4],k=this._h[5],j=this._h[6],C=this._h[7],$=this._h[8],P=this._h[9],B=this._r[0],U=this._r[1],y=this._r[2],O=this._r[3],Y=this._r[4],Q=this._r[5],N=this._r[6],g=this._r[7],a=this._r[8],f=this._r[9];u>=16;){var p=c[l+0]|c[l+1]<<8;m+=p&8191;var w=c[l+2]|c[l+3]<<8;M+=(p>>>13|w<<3)&8191;var A=c[l+4]|c[l+5]<<8;S+=(w>>>10|A<<6)&8191;var x=c[l+6]|c[l+7]<<8;I+=(A>>>7|x<<9)&8191;var _=c[l+8]|c[l+9]<<8;F+=(x>>>4|_<<12)&8191,k+=_>>>1&8191;var h=c[l+10]|c[l+11]<<8;j+=(_>>>14|h<<2)&8191;var d=c[l+12]|c[l+13]<<8;C+=(h>>>11|d<<5)&8191;var D=c[l+14]|c[l+15]<<8;$+=(d>>>8|D<<8)&8191,P+=D>>>5|b;var K=0,G=K;G+=m*B,G+=M*(5*f),G+=S*(5*a),G+=I*(5*g),G+=F*(5*N),K=G>>>13,G&=8191,G+=k*(5*Q),G+=j*(5*Y),G+=C*(5*O),G+=$*(5*y),G+=P*(5*U),K+=G>>>13,G&=8191;var E=K;E+=m*U,E+=M*B,E+=S*(5*f),E+=I*(5*a),E+=F*(5*g),K=E>>>13,E&=8191,E+=k*(5*N),E+=j*(5*Q),E+=C*(5*Y),E+=$*(5*O),E+=P*(5*y),K+=E>>>13,E&=8191;var H=K;H+=m*y,H+=M*U,H+=S*B,H+=I*(5*f),H+=F*(5*a),K=H>>>13,H&=8191,H+=k*(5*g),H+=j*(5*N),H+=C*(5*Q),H+=$*(5*Y),H+=P*(5*O),K+=H>>>13,H&=8191;var R=K;R+=m*O,R+=M*y,R+=S*U,R+=I*B,R+=F*(5*f),K=R>>>13,R&=8191,R+=k*(5*a),R+=j*(5*g),R+=C*(5*N),R+=$*(5*Q),R+=P*(5*Y),K+=R>>>13,R&=8191;var L=K;L+=m*Y,L+=M*O,L+=S*y,L+=I*U,L+=F*B,K=L>>>13,L&=8191,L+=k*(5*f),L+=j*(5*a),L+=C*(5*g),L+=$*(5*N),L+=P*(5*Q),K+=L>>>13,L&=8191;var q=K;q+=m*Q,q+=M*Y,q+=S*O,q+=I*y,q+=F*U,K=q>>>13,q&=8191,q+=k*B,q+=j*(5*f),q+=C*(5*a),q+=$*(5*g),q+=P*(5*N),K+=q>>>13,q&=8191;var v=K;v+=m*N,v+=M*Q,v+=S*Y,v+=I*O,v+=F*y,K=v>>>13,v&=8191,v+=k*U,v+=j*B,v+=C*(5*f),v+=$*(5*a),v+=P*(5*g),K+=v>>>13,v&=8191;var T=K;T+=m*g,T+=M*N,T+=S*Q,T+=I*Y,T+=F*O,K=T>>>13,T&=8191,T+=k*y,T+=j*U,T+=C*B,T+=$*(5*f),T+=P*(5*a),K+=T>>>13,T&=8191;var W=K;W+=m*a,W+=M*g,W+=S*N,W+=I*Q,W+=F*Y,K=W>>>13,W&=8191,W+=k*O,W+=j*y,W+=C*U,W+=$*B,W+=P*(5*f),K+=W>>>13,W&=8191;var J=K;J+=m*f,J+=M*a,J+=S*g,J+=I*N,J+=F*Q,K=J>>>13,J&=8191,J+=k*Y,J+=j*O,J+=C*y,J+=$*U,J+=P*B,K+=J>>>13,J&=8191,K=(K<<2)+K|0,K=K+G|0,G=K&8191,K=K>>>13,E+=K,m=G,M=E,S=H,I=R,F=L,k=q,j=v,C=T,$=W,P=J,l+=16,u-=16}this._h[0]=m,this._h[1]=M,this._h[2]=S,this._h[3]=I,this._h[4]=F,this._h[5]=k,this._h[6]=j,this._h[7]=C,this._h[8]=$,this._h[9]=P},o.prototype.finish=function(c,l){l===void 0&&(l=0);var u=new Uint16Array(10),b,m,M,S;if(this._leftover){for(S=this._leftover,this._buffer[S++]=1;S<16;S++)this._buffer[S]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(b=this._h[1]>>>13,this._h[1]&=8191,S=2;S<10;S++)this._h[S]+=b,b=this._h[S]>>>13,this._h[S]&=8191;for(this._h[0]+=b*5,b=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=b,b=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=b,u[0]=this._h[0]+5,b=u[0]>>>13,u[0]&=8191,S=1;S<10;S++)u[S]=this._h[S]+b,b=u[S]>>>13,u[S]&=8191;for(u[9]-=8192,m=(b^1)-1,S=0;S<10;S++)u[S]&=m;for(m=~m,S=0;S<10;S++)this._h[S]=this._h[S]&m|u[S];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,M=this._h[0]+this._pad[0],this._h[0]=M&65535,S=1;S<8;S++)M=(this._h[S]+this._pad[S]|0)+(M>>>16)|0,this._h[S]=M&65535;return c[l+0]=this._h[0]>>>0,c[l+1]=this._h[0]>>>8,c[l+2]=this._h[1]>>>0,c[l+3]=this._h[1]>>>8,c[l+4]=this._h[2]>>>0,c[l+5]=this._h[2]>>>8,c[l+6]=this._h[3]>>>0,c[l+7]=this._h[3]>>>8,c[l+8]=this._h[4]>>>0,c[l+9]=this._h[4]>>>8,c[l+10]=this._h[5]>>>0,c[l+11]=this._h[5]>>>8,c[l+12]=this._h[6]>>>0,c[l+13]=this._h[6]>>>8,c[l+14]=this._h[7]>>>0,c[l+15]=this._h[7]>>>8,this._finished=!0,this},o.prototype.update=function(c){var l=0,u=c.length,b;if(this._leftover){b=16-this._leftover,b>u&&(b=u);for(var m=0;m<b;m++)this._buffer[this._leftover+m]=c[l+m];if(u-=b,l+=b,this._leftover+=b,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(u>=16&&(b=u-u%16,this._blocks(c,l,b),l+=b,u-=b),u){for(var m=0;m<u;m++)this._buffer[this._leftover+m]=c[l+m];this._leftover+=u}return this},o.prototype.digest=function(){if(this._finished)throw new Error("Poly1305 was finished");var c=new Uint8Array(16);return this.finish(c),c},o.prototype.clean=function(){return r.wipe(this._buffer),r.wipe(this._r),r.wipe(this._h),r.wipe(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this},o}();t.Poly1305=i;function n(o,c){var l=new i(o);l.update(c);var u=l.digest();return l.clean(),u}t.oneTimeAuth=n;function s(o,c){return o.length!==t.DIGEST_LENGTH||c.length!==t.DIGEST_LENGTH?!1:e.equal(o,c)}t.equal=s}(Ph),function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=va,r=Ph,i=fr,n=Ke,s=Fi;t.KEY_LENGTH=32,t.NONCE_LENGTH=12,t.TAG_LENGTH=16;var o=new Uint8Array(16),c=function(){function l(u){if(this.nonceLength=t.NONCE_LENGTH,this.tagLength=t.TAG_LENGTH,u.length!==t.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(u)}return l.prototype.seal=function(u,b,m,M){if(u.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var S=new Uint8Array(16);S.set(u,S.length-u.length);var I=new Uint8Array(32);e.stream(this._key,S,I,4);var F=b.length+this.tagLength,k;if(M){if(M.length!==F)throw new Error("ChaCha20Poly1305: incorrect destination length");k=M}else k=new Uint8Array(F);return e.streamXOR(this._key,S,b,k,4),this._authenticate(k.subarray(k.length-this.tagLength,k.length),I,k.subarray(0,k.length-this.tagLength),m),i.wipe(S),k},l.prototype.open=function(u,b,m,M){if(u.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(b.length<this.tagLength)return null;var S=new Uint8Array(16);S.set(u,S.length-u.length);var I=new Uint8Array(32);e.stream(this._key,S,I,4);var F=new Uint8Array(this.tagLength);if(this._authenticate(F,I,b.subarray(0,b.length-this.tagLength),m),!s.equal(F,b.subarray(b.length-this.tagLength,b.length)))return null;var k=b.length-this.tagLength,j;if(M){if(M.length!==k)throw new Error("ChaCha20Poly1305: incorrect destination length");j=M}else j=new Uint8Array(k);return e.streamXOR(this._key,S,b.subarray(0,b.length-this.tagLength),j,4),i.wipe(S),j},l.prototype.clean=function(){return i.wipe(this._key),this},l.prototype._authenticate=function(u,b,m,M){var S=new r.Poly1305(b);M&&(S.update(M),M.length%16>0&&S.update(o.subarray(M.length%16))),S.update(m),m.length%16>0&&S.update(o.subarray(m.length%16));var I=new Uint8Array(8);M&&n.writeUint64LE(M.length,I),S.update(I),n.writeUint64LE(m.length,I),S.update(I);for(var F=S.digest(),k=0;k<F.length;k++)u[k]=F[k];S.clean(),i.wipe(F),i.wipe(I)},l}();t.ChaCha20Poly1305=c}(Uo);var Ch={},ls={},ko={};Object.defineProperty(ko,"__esModule",{value:!0});function E2(t){return typeof t.saveState<"u"&&typeof t.restoreState<"u"&&typeof t.cleanSavedState<"u"}ko.isSerializableHash=E2,Object.defineProperty(ls,"__esModule",{value:!0});var Ur=ko,x2=Fi,S2=fr,Fh=function(){function t(e,r){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var i=new Uint8Array(this.blockSize);r.length>this.blockSize?this._inner.update(r).finish(i).clean():i.set(r);for(var n=0;n<i.length;n++)i[n]^=54;this._inner.update(i);for(var n=0;n<i.length;n++)i[n]^=106;this._outer.update(i),Ur.isSerializableHash(this._inner)&&Ur.isSerializableHash(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),S2.wipe(i)}return t.prototype.reset=function(){if(!Ur.isSerializableHash(this._inner)||!Ur.isSerializableHash(this._outer))throw new Error("hmac: can't reset() because hash doesn't implement restoreState()");return this._inner.restoreState(this._innerKeyedState),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},t.prototype.clean=function(){Ur.isSerializableHash(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),Ur.isSerializableHash(this._outer)&&this._outer.cleanSavedState(this._outerKeyedState),this._inner.clean(),this._outer.clean()},t.prototype.update=function(e){return this._inner.update(e),this},t.prototype.finish=function(e){return this._finished?(this._outer.finish(e),this):(this._inner.finish(e),this._outer.update(e.subarray(0,this.digestLength)).finish(e),this._finished=!0,this)},t.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},t.prototype.saveState=function(){if(!Ur.isSerializableHash(this._inner))throw new Error("hmac: can't saveState() because hash doesn't implement it");return this._inner.saveState()},t.prototype.restoreState=function(e){if(!Ur.isSerializableHash(this._inner)||!Ur.isSerializableHash(this._outer))throw new Error("hmac: can't restoreState() because hash doesn't implement it");return this._inner.restoreState(e),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},t.prototype.cleanSavedState=function(e){if(!Ur.isSerializableHash(this._inner))throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it");this._inner.cleanSavedState(e)},t}();ls.HMAC=Fh;function M2(t,e,r){var i=new Fh(t,e);i.update(r);var n=i.digest();return i.clean(),n}ls.hmac=M2,ls.equal=x2.equal,Object.defineProperty(Ch,"__esModule",{value:!0});var Lh=ls,Bh=fr,I2=function(){function t(e,r,i,n){i===void 0&&(i=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=n;var s=Lh.hmac(this._hash,i,r);this._hmac=new Lh.HMAC(e,s),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return t.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(e===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},t.prototype.expand=function(e){for(var r=new Uint8Array(e),i=0;i<r.length;i++)this._bufpos===this._buffer.length&&this._fillBuffer(),r[i]=this._buffer[this._bufpos++];return r},t.prototype.clean=function(){this._hmac.clean(),Bh.wipe(this._buffer),Bh.wipe(this._counter),this._bufpos=0},t}(),D2=Ch.HKDF=I2,ps={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Ke,r=fr;t.DIGEST_LENGTH=32,t.BLOCK_SIZE=64;var i=function(){function c(){this.digestLength=t.DIGEST_LENGTH,this.blockSize=t.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return c.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},c.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},c.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._temp),this.reset()},c.prototype.update=function(l,u){if(u===void 0&&(u=l.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var b=0;if(this._bytesHashed+=u,this._bufferLength>0){for(;this._bufferLength<this.blockSize&&u>0;)this._buffer[this._bufferLength++]=l[b++],u--;this._bufferLength===this.blockSize&&(s(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(u>=this.blockSize&&(b=s(this._temp,this._state,l,b,u),u%=this.blockSize);u>0;)this._buffer[this._bufferLength++]=l[b++],u--;return this},c.prototype.finish=function(l){if(!this._finished){var u=this._bytesHashed,b=this._bufferLength,m=u/536870912|0,M=u<<3,S=u%64<56?64:128;this._buffer[b]=128;for(var I=b+1;I<S-8;I++)this._buffer[I]=0;e.writeUint32BE(m,this._buffer,S-8),e.writeUint32BE(M,this._buffer,S-4),s(this._temp,this._state,this._buffer,0,S),this._finished=!0}for(var I=0;I<this.digestLength/4;I++)e.writeUint32BE(this._state[I],l,I*4);return this},c.prototype.digest=function(){var l=new Uint8Array(this.digestLength);return this.finish(l),l},c.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{state:new Int32Array(this._state),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},c.prototype.restoreState=function(l){return this._state.set(l.state),this._bufferLength=l.bufferLength,l.buffer&&this._buffer.set(l.buffer),this._bytesHashed=l.bytesHashed,this._finished=!1,this},c.prototype.cleanSavedState=function(l){r.wipe(l.state),l.buffer&&r.wipe(l.buffer),l.bufferLength=0,l.bytesHashed=0},c}();t.SHA256=i;var n=new Int32Array([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 s(c,l,u,b,m){for(;m>=64;){for(var M=l[0],S=l[1],I=l[2],F=l[3],k=l[4],j=l[5],C=l[6],$=l[7],P=0;P<16;P++){var B=b+P*4;c[P]=e.readUint32BE(u,B)}for(var P=16;P<64;P++){var U=c[P-2],y=(U>>>17|U<<32-17)^(U>>>19|U<<32-19)^U>>>10;U=c[P-15];var O=(U>>>7|U<<32-7)^(U>>>18|U<<32-18)^U>>>3;c[P]=(y+c[P-7]|0)+(O+c[P-16]|0)}for(var P=0;P<64;P++){var y=(((k>>>6|k<<26)^(k>>>11|k<<21)^(k>>>25|k<<7))+(k&j^~k&C)|0)+($+(n[P]+c[P]|0)|0)|0,O=((M>>>2|M<<32-2)^(M>>>13|M<<32-13)^(M>>>22|M<<32-22))+(M&S^M&I^S&I)|0;$=C,C=j,j=k,k=F+y|0,F=I,I=S,S=M,M=y+O|0}l[0]+=M,l[1]+=S,l[2]+=I,l[3]+=F,l[4]+=k,l[5]+=j,l[6]+=C,l[7]+=$,b+=64,m-=64}return b}function o(c){var l=new i;l.update(c);var u=l.digest();return l.clean(),u}t.hash=o})(ps);var $o={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.sharedKey=t.generateKeyPair=t.generateKeyPairFromSeed=t.scalarMultBase=t.scalarMult=t.SHARED_KEY_LENGTH=t.SECRET_KEY_LENGTH=t.PUBLIC_KEY_LENGTH=void 0;const e=Ci,r=fr;t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=32,t.SHARED_KEY_LENGTH=32;function i(P){const B=new Float64Array(16);if(P)for(let U=0;U<P.length;U++)B[U]=P[U];return B}const n=new Uint8Array(32);n[0]=9;const s=i([56129,1]);function o(P){let B=1;for(let U=0;U<16;U++){let y=P[U]+B+65535;B=Math.floor(y/65536),P[U]=y-B*65536}P[0]+=B-1+37*(B-1)}function c(P,B,U){const y=~(U-1);for(let O=0;O<16;O++){const Y=y&(P[O]^B[O]);P[O]^=Y,B[O]^=Y}}function l(P,B){const U=i(),y=i();for(let O=0;O<16;O++)y[O]=B[O];o(y),o(y),o(y);for(let O=0;O<2;O++){U[0]=y[0]-65517;for(let Q=1;Q<15;Q++)U[Q]=y[Q]-65535-(U[Q-1]>>16&1),U[Q-1]&=65535;U[15]=y[15]-32767-(U[14]>>16&1);const Y=U[15]>>16&1;U[14]&=65535,c(y,U,1-Y)}for(let O=0;O<16;O++)P[2*O]=y[O]&255,P[2*O+1]=y[O]>>8}function u(P,B){for(let U=0;U<16;U++)P[U]=B[2*U]+(B[2*U+1]<<8);P[15]&=32767}function b(P,B,U){for(let y=0;y<16;y++)P[y]=B[y]+U[y]}function m(P,B,U){for(let y=0;y<16;y++)P[y]=B[y]-U[y]}function M(P,B,U){let y,O,Y=0,Q=0,N=0,g=0,a=0,f=0,p=0,w=0,A=0,x=0,_=0,h=0,d=0,D=0,K=0,G=0,E=0,H=0,R=0,L=0,q=0,v=0,T=0,W=0,J=0,X=0,se=0,ne=0,Me=0,Ce=0,ue=0,xe=U[0],Ae=U[1],re=U[2],ve=U[3],le=U[4],ee=U[5],de=U[6],fe=U[7],te=U[8],Ee=U[9],he=U[10],ae=U[11],Se=U[12],De=U[13],ce=U[14],Ie=U[15];y=B[0],Y+=y*xe,Q+=y*Ae,N+=y*re,g+=y*ve,a+=y*le,f+=y*ee,p+=y*de,w+=y*fe,A+=y*te,x+=y*Ee,_+=y*he,h+=y*ae,d+=y*Se,D+=y*De,K+=y*ce,G+=y*Ie,y=B[1],Q+=y*xe,N+=y*Ae,g+=y*re,a+=y*ve,f+=y*le,p+=y*ee,w+=y*de,A+=y*fe,x+=y*te,_+=y*Ee,h+=y*he,d+=y*ae,D+=y*Se,K+=y*De,G+=y*ce,E+=y*Ie,y=B[2],N+=y*xe,g+=y*Ae,a+=y*re,f+=y*ve,p+=y*le,w+=y*ee,A+=y*de,x+=y*fe,_+=y*te,h+=y*Ee,d+=y*he,D+=y*ae,K+=y*Se,G+=y*De,E+=y*ce,H+=y*Ie,y=B[3],g+=y*xe,a+=y*Ae,f+=y*re,p+=y*ve,w+=y*le,A+=y*ee,x+=y*de,_+=y*fe,h+=y*te,d+=y*Ee,D+=y*he,K+=y*ae,G+=y*Se,E+=y*De,H+=y*ce,R+=y*Ie,y=B[4],a+=y*xe,f+=y*Ae,p+=y*re,w+=y*ve,A+=y*le,x+=y*ee,_+=y*de,h+=y*fe,d+=y*te,D+=y*Ee,K+=y*he,G+=y*ae,E+=y*Se,H+=y*De,R+=y*ce,L+=y*Ie,y=B[5],f+=y*xe,p+=y*Ae,w+=y*re,A+=y*ve,x+=y*le,_+=y*ee,h+=y*de,d+=y*fe,D+=y*te,K+=y*Ee,G+=y*he,E+=y*ae,H+=y*Se,R+=y*De,L+=y*ce,q+=y*Ie,y=B[6],p+=y*xe,w+=y*Ae,A+=y*re,x+=y*ve,_+=y*le,h+=y*ee,d+=y*de,D+=y*fe,K+=y*te,G+=y*Ee,E+=y*he,H+=y*ae,R+=y*Se,L+=y*De,q+=y*ce,v+=y*Ie,y=B[7],w+=y*xe,A+=y*Ae,x+=y*re,_+=y*ve,h+=y*le,d+=y*ee,D+=y*de,K+=y*fe,G+=y*te,E+=y*Ee,H+=y*he,R+=y*ae,L+=y*Se,q+=y*De,v+=y*ce,T+=y*Ie,y=B[8],A+=y*xe,x+=y*Ae,_+=y*re,h+=y*ve,d+=y*le,D+=y*ee,K+=y*de,G+=y*fe,E+=y*te,H+=y*Ee,R+=y*he,L+=y*ae,q+=y*Se,v+=y*De,T+=y*ce,W+=y*Ie,y=B[9],x+=y*xe,_+=y*Ae,h+=y*re,d+=y*ve,D+=y*le,K+=y*ee,G+=y*de,E+=y*fe,H+=y*te,R+=y*Ee,L+=y*he,q+=y*ae,v+=y*Se,T+=y*De,W+=y*ce,J+=y*Ie,y=B[10],_+=y*xe,h+=y*Ae,d+=y*re,D+=y*ve,K+=y*le,G+=y*ee,E+=y*de,H+=y*fe,R+=y*te,L+=y*Ee,q+=y*he,v+=y*ae,T+=y*Se,W+=y*De,J+=y*ce,X+=y*Ie,y=B[11],h+=y*xe,d+=y*Ae,D+=y*re,K+=y*ve,G+=y*le,E+=y*ee,H+=y*de,R+=y*fe,L+=y*te,q+=y*Ee,v+=y*he,T+=y*ae,W+=y*Se,J+=y*De,X+=y*ce,se+=y*Ie,y=B[12],d+=y*xe,D+=y*Ae,K+=y*re,G+=y*ve,E+=y*le,H+=y*ee,R+=y*de,L+=y*fe,q+=y*te,v+=y*Ee,T+=y*he,W+=y*ae,J+=y*Se,X+=y*De,se+=y*ce,ne+=y*Ie,y=B[13],D+=y*xe,K+=y*Ae,G+=y*re,E+=y*ve,H+=y*le,R+=y*ee,L+=y*de,q+=y*fe,v+=y*te,T+=y*Ee,W+=y*he,J+=y*ae,X+=y*Se,se+=y*De,ne+=y*ce,Me+=y*Ie,y=B[14],K+=y*xe,G+=y*Ae,E+=y*re,H+=y*ve,R+=y*le,L+=y*ee,q+=y*de,v+=y*fe,T+=y*te,W+=y*Ee,J+=y*he,X+=y*ae,se+=y*Se,ne+=y*De,Me+=y*ce,Ce+=y*Ie,y=B[15],G+=y*xe,E+=y*Ae,H+=y*re,R+=y*ve,L+=y*le,q+=y*ee,v+=y*de,T+=y*fe,W+=y*te,J+=y*Ee,X+=y*he,se+=y*ae,ne+=y*Se,Me+=y*De,Ce+=y*ce,ue+=y*Ie,Y+=38*E,Q+=38*H,N+=38*R,g+=38*L,a+=38*q,f+=38*v,p+=38*T,w+=38*W,A+=38*J,x+=38*X,_+=38*se,h+=38*ne,d+=38*Me,D+=38*Ce,K+=38*ue,O=1,y=Y+O+65535,O=Math.floor(y/65536),Y=y-O*65536,y=Q+O+65535,O=Math.floor(y/65536),Q=y-O*65536,y=N+O+65535,O=Math.floor(y/65536),N=y-O*65536,y=g+O+65535,O=Math.floor(y/65536),g=y-O*65536,y=a+O+65535,O=Math.floor(y/65536),a=y-O*65536,y=f+O+65535,O=Math.floor(y/65536),f=y-O*65536,y=p+O+65535,O=Math.floor(y/65536),p=y-O*65536,y=w+O+65535,O=Math.floor(y/65536),w=y-O*65536,y=A+O+65535,O=Math.floor(y/65536),A=y-O*65536,y=x+O+65535,O=Math.floor(y/65536),x=y-O*65536,y=_+O+65535,O=Math.floor(y/65536),_=y-O*65536,y=h+O+65535,O=Math.floor(y/65536),h=y-O*65536,y=d+O+65535,O=Math.floor(y/65536),d=y-O*65536,y=D+O+65535,O=Math.floor(y/65536),D=y-O*65536,y=K+O+65535,O=Math.floor(y/65536),K=y-O*65536,y=G+O+65535,O=Math.floor(y/65536),G=y-O*65536,Y+=O-1+37*(O-1),O=1,y=Y+O+65535,O=Math.floor(y/65536),Y=y-O*65536,y=Q+O+65535,O=Math.floor(y/65536),Q=y-O*65536,y=N+O+65535,O=Math.floor(y/65536),N=y-O*65536,y=g+O+65535,O=Math.floor(y/65536),g=y-O*65536,y=a+O+65535,O=Math.floor(y/65536),a=y-O*65536,y=f+O+65535,O=Math.floor(y/65536),f=y-O*65536,y=p+O+65535,O=Math.floor(y/65536),p=y-O*65536,y=w+O+65535,O=Math.floor(y/65536),w=y-O*65536,y=A+O+65535,O=Math.floor(y/65536),A=y-O*65536,y=x+O+65535,O=Math.floor(y/65536),x=y-O*65536,y=_+O+65535,O=Math.floor(y/65536),_=y-O*65536,y=h+O+65535,O=Math.floor(y/65536),h=y-O*65536,y=d+O+65535,O=Math.floor(y/65536),d=y-O*65536,y=D+O+65535,O=Math.floor(y/65536),D=y-O*65536,y=K+O+65535,O=Math.floor(y/65536),K=y-O*65536,y=G+O+65535,O=Math.floor(y/65536),G=y-O*65536,Y+=O-1+37*(O-1),P[0]=Y,P[1]=Q,P[2]=N,P[3]=g,P[4]=a,P[5]=f,P[6]=p,P[7]=w,P[8]=A,P[9]=x,P[10]=_,P[11]=h,P[12]=d,P[13]=D,P[14]=K,P[15]=G}function S(P,B){M(P,B,B)}function I(P,B){const U=i();for(let y=0;y<16;y++)U[y]=B[y];for(let y=253;y>=0;y--)S(U,U),y!==2&&y!==4&&M(U,U,B);for(let y=0;y<16;y++)P[y]=U[y]}function F(P,B){const U=new Uint8Array(32),y=new Float64Array(80),O=i(),Y=i(),Q=i(),N=i(),g=i(),a=i();for(let A=0;A<31;A++)U[A]=P[A];U[31]=P[31]&127|64,U[0]&=248,u(y,B);for(let A=0;A<16;A++)Y[A]=y[A];O[0]=N[0]=1;for(let A=254;A>=0;--A){const x=U[A>>>3]>>>(A&7)&1;c(O,Y,x),c(Q,N,x),b(g,O,Q),m(O,O,Q),b(Q,Y,N),m(Y,Y,N),S(N,g),S(a,O),M(O,Q,O),M(Q,Y,g),b(g,O,Q),m(O,O,Q),S(Y,O),m(Q,N,a),M(O,Q,s),b(O,O,N),M(Q,Q,O),M(O,N,a),M(N,Y,y),S(Y,g),c(O,Y,x),c(Q,N,x)}for(let A=0;A<16;A++)y[A+16]=O[A],y[A+32]=Q[A],y[A+48]=Y[A],y[A+64]=N[A];const f=y.subarray(32),p=y.subarray(16);I(f,f),M(p,p,f);const w=new Uint8Array(32);return l(w,p),w}t.scalarMult=F;function k(P){return F(P,n)}t.scalarMultBase=k;function j(P){if(P.length!==t.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${t.SECRET_KEY_LENGTH} bytes`);const B=new Uint8Array(P);return{publicKey:k(B),secretKey:B}}t.generateKeyPairFromSeed=j;function C(P){const B=(0,e.randomBytes)(32,P),U=j(B);return(0,r.wipe)(B),U}t.generateKeyPair=C;function $(P,B,U=!1){if(P.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(B.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");const y=F(P,B);if(U){let O=0;for(let Y=0;Y<y.length;Y++)O|=y[Y];if(O===0)throw new Error("X25519: invalid shared key")}return y}t.sharedKey=$})($o);var qh={},O2="elliptic",R2="6.5.7",N2="EC cryptography",P2="lib/elliptic.js",T2=["lib"],C2={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/"},F2={type:"git",url:"git@github.com:indutny/elliptic"},L2=["EC","Elliptic","curve","Cryptography"],B2="Fedor Indutny <fedor@indutny.com>",q2="MIT",U2={url:"https://github.com/indutny/elliptic/issues"},z2="https://github.com/indutny/elliptic",k2={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"},$2={"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"},j2={name:O2,version:R2,description:N2,main:P2,files:T2,scripts:C2,repository:F2,keywords:L2,author:B2,license:q2,bugs:U2,homepage:z2,devDependencies:k2,dependencies:$2},hr={},zr={exports:{}};(function(t){(function(e,r){function i(N,g){if(!N)throw new Error(g||"Assertion failed")}function n(N,g){N.super_=g;var a=function(){};a.prototype=g.prototype,N.prototype=new a,N.prototype.constructor=N}function s(N,g,a){if(s.isBN(N))return N;this.negative=0,this.words=null,this.length=0,this.red=null,N!==null&&((g==="le"||g==="be")&&(a=g,g=10),this._init(N||0,g||10,a||"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=Io.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,a){return g.cmp(a)>0?g:a},s.min=function(g,a){return g.cmp(a)<0?g:a},s.prototype._init=function(g,a,f){if(typeof g=="number")return this._initNumber(g,a,f);if(typeof g=="object")return this._initArray(g,a,f);a==="hex"&&(a=16),i(a===(a|0)&&a>=2&&a<=36),g=g.toString().replace(/\s+/g,"");var p=0;g[0]==="-"&&(p++,this.negative=1),p<g.length&&(a===16?this._parseHex(g,p,f):(this._parseBase(g,a,p),f==="le"&&this._initArray(this.toArray(),a,f)))},s.prototype._initNumber=function(g,a,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(),a,f)},s.prototype._initArray=function(g,a,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 p=0;p<this.length;p++)this.words[p]=0;var w,A,x=0;if(f==="be")for(p=g.length-1,w=0;p>=0;p-=3)A=g[p]|g[p-1]<<8|g[p-2]<<16,this.words[w]|=A<<x&67108863,this.words[w+1]=A>>>26-x&67108863,x+=24,x>=26&&(x-=26,w++);else if(f==="le")for(p=0,w=0;p<g.length;p+=3)A=g[p]|g[p+1]<<8|g[p+2]<<16,this.words[w]|=A<<x&67108863,this.words[w+1]=A>>>26-x&67108863,x+=24,x>=26&&(x-=26,w++);return this.strip()};function c(N,g){var a=N.charCodeAt(g);return a>=65&&a<=70?a-55:a>=97&&a<=102?a-87:a-48&15}function l(N,g,a){var f=c(N,a);return a-1>=g&&(f|=c(N,a-1)<<4),f}s.prototype._parseHex=function(g,a,f){this.length=Math.ceil((g.length-a)/6),this.words=new Array(this.length);for(var p=0;p<this.length;p++)this.words[p]=0;var w=0,A=0,x;if(f==="be")for(p=g.length-1;p>=a;p-=2)x=l(g,a,p)<<w,this.words[A]|=x&67108863,w>=18?(w-=18,A+=1,this.words[A]|=x>>>26):w+=8;else{var _=g.length-a;for(p=_%2===0?a+1:a;p<g.length;p+=2)x=l(g,a,p)<<w,this.words[A]|=x&67108863,w>=18?(w-=18,A+=1,this.words[A]|=x>>>26):w+=8}this.strip()};function u(N,g,a,f){for(var p=0,w=Math.min(N.length,a),A=g;A<w;A++){var x=N.charCodeAt(A)-48;p*=f,x>=49?p+=x-49+10:x>=17?p+=x-17+10:p+=x}return p}s.prototype._parseBase=function(g,a,f){this.words=[0],this.length=1;for(var p=0,w=1;w<=67108863;w*=a)p++;p--,w=w/a|0;for(var A=g.length-f,x=A%p,_=Math.min(A,A-x)+f,h=0,d=f;d<_;d+=p)h=u(g,d,d+p,a),this.imuln(w),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h);if(x!==0){var D=1;for(h=u(g,d,g.length,a),d=0;d<x;d++)D*=a;this.imuln(D),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h)}this.strip()},s.prototype.copy=function(g){g.words=new Array(this.length);for(var a=0;a<this.length;a++)g.words[a]=this.words[a];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 b=["","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"],m=[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,a){g=g||10,a=a|0||1;var f;if(g===16||g==="hex"){f="";for(var p=0,w=0,A=0;A<this.length;A++){var x=this.words[A],_=((x<<p|w)&16777215).toString(16);w=x>>>24-p&16777215,w!==0||A!==this.length-1?f=b[6-_.length]+_+f:f=_+f,p+=2,p>=26&&(p-=26,A--)}for(w!==0&&(f=w.toString(16)+f);f.length%a!==0;)f="0"+f;return this.negative!==0&&(f="-"+f),f}if(g===(g|0)&&g>=2&&g<=36){var h=m[g],d=M[g];f="";var D=this.clone();for(D.negative=0;!D.isZero();){var K=D.modn(d).toString(g);D=D.idivn(d),D.isZero()?f=K+f:f=b[h-K.length]+K+f}for(this.isZero()&&(f="0"+f);f.length%a!==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,a){return i(typeof o<"u"),this.toArrayLike(o,g,a)},s.prototype.toArray=function(g,a){return this.toArrayLike(Array,g,a)},s.prototype.toArrayLike=function(g,a,f){var p=this.byteLength(),w=f||Math.max(1,p);i(p<=w,"byte array longer than desired length"),i(w>0,"Requested array length <= 0"),this.strip();var A=a==="le",x=new g(w),_,h,d=this.clone();if(A){for(h=0;!d.isZero();h++)_=d.andln(255),d.iushrn(8),x[h]=_;for(;h<w;h++)x[h]=0}else{for(h=0;h<w-p;h++)x[h]=0;for(h=0;!d.isZero();h++)_=d.andln(255),d.iushrn(8),x[w-h-1]=_}return x},Math.clz32?s.prototype._countBits=function(g){return 32-Math.clz32(g)}:s.prototype._countBits=function(g){var a=g,f=0;return a>=4096&&(f+=13,a>>>=13),a>=64&&(f+=7,a>>>=7),a>=8&&(f+=4,a>>>=4),a>=2&&(f+=2,a>>>=2),f+a},s.prototype._zeroBits=function(g){if(g===0)return 26;var a=g,f=0;return a&8191||(f+=13,a>>>=13),a&127||(f+=7,a>>>=7),a&15||(f+=4,a>>>=4),a&3||(f+=2,a>>>=2),a&1||f++,f},s.prototype.bitLength=function(){var g=this.words[this.length-1],a=this._countBits(g);return(this.length-1)*26+a};function S(N){for(var g=new Array(N.bitLength()),a=0;a<g.length;a++){var f=a/26|0,p=a%26;g[a]=(N.words[f]&1<<p)>>>p}return g}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var g=0,a=0;a<this.length;a++){var f=this._zeroBits(this.words[a]);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 a=0;a<g.length;a++)this.words[a]=this.words[a]|g.words[a];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 a;this.length>g.length?a=g:a=this;for(var f=0;f<a.length;f++)this.words[f]=this.words[f]&g.words[f];return this.length=a.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 a,f;this.length>g.length?(a=this,f=g):(a=g,f=this);for(var p=0;p<f.length;p++)this.words[p]=a.words[p]^f.words[p];if(this!==a)for(;p<a.length;p++)this.words[p]=a.words[p];return this.length=a.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 a=Math.ceil(g/26)|0,f=g%26;this._expand(a),f>0&&a--;for(var p=0;p<a;p++)this.words[p]=~this.words[p]&67108863;return f>0&&(this.words[p]=~this.words[p]&67108863>>26-f),this.strip()},s.prototype.notn=function(g){return this.clone().inotn(g)},s.prototype.setn=function(g,a){i(typeof g=="number"&&g>=0);var f=g/26|0,p=g%26;return this._expand(f+1),a?this.words[f]=this.words[f]|1<<p:this.words[f]=this.words[f]&~(1<<p),this.strip()},s.prototype.iadd=function(g){var a;if(this.negative!==0&&g.negative===0)return this.negative=0,a=this.isub(g),this.negative^=1,this._normSign();if(this.negative===0&&g.negative!==0)return g.negative=0,a=this.isub(g),g.negative=1,a._normSign();var f,p;this.length>g.length?(f=this,p=g):(f=g,p=this);for(var w=0,A=0;A<p.length;A++)a=(f.words[A]|0)+(p.words[A]|0)+w,this.words[A]=a&67108863,w=a>>>26;for(;w!==0&&A<f.length;A++)a=(f.words[A]|0)+w,this.words[A]=a&67108863,w=a>>>26;if(this.length=f.length,w!==0)this.words[this.length]=w,this.length++;else if(f!==this)for(;A<f.length;A++)this.words[A]=f.words[A];return this},s.prototype.add=function(g){var a;return g.negative!==0&&this.negative===0?(g.negative=0,a=this.sub(g),g.negative^=1,a):g.negative===0&&this.negative!==0?(this.negative=0,a=g.sub(this),this.negative=1,a):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 a=this.iadd(g);return g.negative=1,a._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 p,w;f>0?(p=this,w=g):(p=g,w=this);for(var A=0,x=0;x<w.length;x++)a=(p.words[x]|0)-(w.words[x]|0)+A,A=a>>26,this.words[x]=a&67108863;for(;A!==0&&x<p.length;x++)a=(p.words[x]|0)+A,A=a>>26,this.words[x]=a&67108863;if(A===0&&x<p.length&&p!==this)for(;x<p.length;x++)this.words[x]=p.words[x];return this.length=Math.max(this.length,x),p!==this&&(this.negative=1),this.strip()},s.prototype.sub=function(g){return this.clone().isub(g)};function I(N,g,a){a.negative=g.negative^N.negative;var f=N.length+g.length|0;a.length=f,f=f-1|0;var p=N.words[0]|0,w=g.words[0]|0,A=p*w,x=A&67108863,_=A/67108864|0;a.words[0]=x;for(var h=1;h<f;h++){for(var d=_>>>26,D=_&67108863,K=Math.min(h,g.length-1),G=Math.max(0,h-N.length+1);G<=K;G++){var E=h-G|0;p=N.words[E]|0,w=g.words[G]|0,A=p*w+D,d+=A/67108864|0,D=A&67108863}a.words[h]=D|0,_=d|0}return _!==0?a.words[h]=_|0:a.length--,a.strip()}var F=function(g,a,f){var p=g.words,w=a.words,A=f.words,x=0,_,h,d,D=p[0]|0,K=D&8191,G=D>>>13,E=p[1]|0,H=E&8191,R=E>>>13,L=p[2]|0,q=L&8191,v=L>>>13,T=p[3]|0,W=T&8191,J=T>>>13,X=p[4]|0,se=X&8191,ne=X>>>13,Me=p[5]|0,Ce=Me&8191,ue=Me>>>13,xe=p[6]|0,Ae=xe&8191,re=xe>>>13,ve=p[7]|0,le=ve&8191,ee=ve>>>13,de=p[8]|0,fe=de&8191,te=de>>>13,Ee=p[9]|0,he=Ee&8191,ae=Ee>>>13,Se=w[0]|0,De=Se&8191,ce=Se>>>13,Ie=w[1]|0,We=Ie&8191,Oe=Ie>>>13,Qe=w[2]|0,He=Qe&8191,Re=Qe>>>13,tt=w[3]|0,rt=tt&8191,pe=tt>>>13,Pe=w[4]|0,Fe=Pe&8191,ge=Pe>>>13,Le=w[5]|0,Te=Le&8191,ye=Le>>>13,Ue=w[6]|0,ze=Ue&8191,we=Ue>>>13,ke=w[7]|0,Be=ke&8191,be=ke>>>13,Ne=w[8]|0,$e=Ne&8191,_e=Ne>>>13,it=w[9]|0,nt=it&8191,qe=it>>>13;f.negative=g.negative^a.negative,f.length=19,_=Math.imul(K,De),h=Math.imul(K,ce),h=h+Math.imul(G,De)|0,d=Math.imul(G,ce);var Ye=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(Ye>>>26)|0,Ye&=67108863,_=Math.imul(H,De),h=Math.imul(H,ce),h=h+Math.imul(R,De)|0,d=Math.imul(R,ce),_=_+Math.imul(K,We)|0,h=h+Math.imul(K,Oe)|0,h=h+Math.imul(G,We)|0,d=d+Math.imul(G,Oe)|0;var nr=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(nr>>>26)|0,nr&=67108863,_=Math.imul(q,De),h=Math.imul(q,ce),h=h+Math.imul(v,De)|0,d=Math.imul(v,ce),_=_+Math.imul(H,We)|0,h=h+Math.imul(H,Oe)|0,h=h+Math.imul(R,We)|0,d=d+Math.imul(R,Oe)|0,_=_+Math.imul(K,He)|0,h=h+Math.imul(K,Re)|0,h=h+Math.imul(G,He)|0,d=d+Math.imul(G,Re)|0;var sr=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(sr>>>26)|0,sr&=67108863,_=Math.imul(W,De),h=Math.imul(W,ce),h=h+Math.imul(J,De)|0,d=Math.imul(J,ce),_=_+Math.imul(q,We)|0,h=h+Math.imul(q,Oe)|0,h=h+Math.imul(v,We)|0,d=d+Math.imul(v,Oe)|0,_=_+Math.imul(H,He)|0,h=h+Math.imul(H,Re)|0,h=h+Math.imul(R,He)|0,d=d+Math.imul(R,Re)|0,_=_+Math.imul(K,rt)|0,h=h+Math.imul(K,pe)|0,h=h+Math.imul(G,rt)|0,d=d+Math.imul(G,pe)|0;var ar=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(ar>>>26)|0,ar&=67108863,_=Math.imul(se,De),h=Math.imul(se,ce),h=h+Math.imul(ne,De)|0,d=Math.imul(ne,ce),_=_+Math.imul(W,We)|0,h=h+Math.imul(W,Oe)|0,h=h+Math.imul(J,We)|0,d=d+Math.imul(J,Oe)|0,_=_+Math.imul(q,He)|0,h=h+Math.imul(q,Re)|0,h=h+Math.imul(v,He)|0,d=d+Math.imul(v,Re)|0,_=_+Math.imul(H,rt)|0,h=h+Math.imul(H,pe)|0,h=h+Math.imul(R,rt)|0,d=d+Math.imul(R,pe)|0,_=_+Math.imul(K,Fe)|0,h=h+Math.imul(K,ge)|0,h=h+Math.imul(G,Fe)|0,d=d+Math.imul(G,ge)|0;var or=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(or>>>26)|0,or&=67108863,_=Math.imul(Ce,De),h=Math.imul(Ce,ce),h=h+Math.imul(ue,De)|0,d=Math.imul(ue,ce),_=_+Math.imul(se,We)|0,h=h+Math.imul(se,Oe)|0,h=h+Math.imul(ne,We)|0,d=d+Math.imul(ne,Oe)|0,_=_+Math.imul(W,He)|0,h=h+Math.imul(W,Re)|0,h=h+Math.imul(J,He)|0,d=d+Math.imul(J,Re)|0,_=_+Math.imul(q,rt)|0,h=h+Math.imul(q,pe)|0,h=h+Math.imul(v,rt)|0,d=d+Math.imul(v,pe)|0,_=_+Math.imul(H,Fe)|0,h=h+Math.imul(H,ge)|0,h=h+Math.imul(R,Fe)|0,d=d+Math.imul(R,ge)|0,_=_+Math.imul(K,Te)|0,h=h+Math.imul(K,ye)|0,h=h+Math.imul(G,Te)|0,d=d+Math.imul(G,ye)|0;var cr=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(cr>>>26)|0,cr&=67108863,_=Math.imul(Ae,De),h=Math.imul(Ae,ce),h=h+Math.imul(re,De)|0,d=Math.imul(re,ce),_=_+Math.imul(Ce,We)|0,h=h+Math.imul(Ce,Oe)|0,h=h+Math.imul(ue,We)|0,d=d+Math.imul(ue,Oe)|0,_=_+Math.imul(se,He)|0,h=h+Math.imul(se,Re)|0,h=h+Math.imul(ne,He)|0,d=d+Math.imul(ne,Re)|0,_=_+Math.imul(W,rt)|0,h=h+Math.imul(W,pe)|0,h=h+Math.imul(J,rt)|0,d=d+Math.imul(J,pe)|0,_=_+Math.imul(q,Fe)|0,h=h+Math.imul(q,ge)|0,h=h+Math.imul(v,Fe)|0,d=d+Math.imul(v,ge)|0,_=_+Math.imul(H,Te)|0,h=h+Math.imul(H,ye)|0,h=h+Math.imul(R,Te)|0,d=d+Math.imul(R,ye)|0,_=_+Math.imul(K,ze)|0,h=h+Math.imul(K,we)|0,h=h+Math.imul(G,ze)|0,d=d+Math.imul(G,we)|0;var wt=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(wt>>>26)|0,wt&=67108863,_=Math.imul(le,De),h=Math.imul(le,ce),h=h+Math.imul(ee,De)|0,d=Math.imul(ee,ce),_=_+Math.imul(Ae,We)|0,h=h+Math.imul(Ae,Oe)|0,h=h+Math.imul(re,We)|0,d=d+Math.imul(re,Oe)|0,_=_+Math.imul(Ce,He)|0,h=h+Math.imul(Ce,Re)|0,h=h+Math.imul(ue,He)|0,d=d+Math.imul(ue,Re)|0,_=_+Math.imul(se,rt)|0,h=h+Math.imul(se,pe)|0,h=h+Math.imul(ne,rt)|0,d=d+Math.imul(ne,pe)|0,_=_+Math.imul(W,Fe)|0,h=h+Math.imul(W,ge)|0,h=h+Math.imul(J,Fe)|0,d=d+Math.imul(J,ge)|0,_=_+Math.imul(q,Te)|0,h=h+Math.imul(q,ye)|0,h=h+Math.imul(v,Te)|0,d=d+Math.imul(v,ye)|0,_=_+Math.imul(H,ze)|0,h=h+Math.imul(H,we)|0,h=h+Math.imul(R,ze)|0,d=d+Math.imul(R,we)|0,_=_+Math.imul(K,Be)|0,h=h+Math.imul(K,be)|0,h=h+Math.imul(G,Be)|0,d=d+Math.imul(G,be)|0;var Ei=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(Ei>>>26)|0,Ei&=67108863,_=Math.imul(fe,De),h=Math.imul(fe,ce),h=h+Math.imul(te,De)|0,d=Math.imul(te,ce),_=_+Math.imul(le,We)|0,h=h+Math.imul(le,Oe)|0,h=h+Math.imul(ee,We)|0,d=d+Math.imul(ee,Oe)|0,_=_+Math.imul(Ae,He)|0,h=h+Math.imul(Ae,Re)|0,h=h+Math.imul(re,He)|0,d=d+Math.imul(re,Re)|0,_=_+Math.imul(Ce,rt)|0,h=h+Math.imul(Ce,pe)|0,h=h+Math.imul(ue,rt)|0,d=d+Math.imul(ue,pe)|0,_=_+Math.imul(se,Fe)|0,h=h+Math.imul(se,ge)|0,h=h+Math.imul(ne,Fe)|0,d=d+Math.imul(ne,ge)|0,_=_+Math.imul(W,Te)|0,h=h+Math.imul(W,ye)|0,h=h+Math.imul(J,Te)|0,d=d+Math.imul(J,ye)|0,_=_+Math.imul(q,ze)|0,h=h+Math.imul(q,we)|0,h=h+Math.imul(v,ze)|0,d=d+Math.imul(v,we)|0,_=_+Math.imul(H,Be)|0,h=h+Math.imul(H,be)|0,h=h+Math.imul(R,Be)|0,d=d+Math.imul(R,be)|0,_=_+Math.imul(K,$e)|0,h=h+Math.imul(K,_e)|0,h=h+Math.imul(G,$e)|0,d=d+Math.imul(G,_e)|0;var xi=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(xi>>>26)|0,xi&=67108863,_=Math.imul(he,De),h=Math.imul(he,ce),h=h+Math.imul(ae,De)|0,d=Math.imul(ae,ce),_=_+Math.imul(fe,We)|0,h=h+Math.imul(fe,Oe)|0,h=h+Math.imul(te,We)|0,d=d+Math.imul(te,Oe)|0,_=_+Math.imul(le,He)|0,h=h+Math.imul(le,Re)|0,h=h+Math.imul(ee,He)|0,d=d+Math.imul(ee,Re)|0,_=_+Math.imul(Ae,rt)|0,h=h+Math.imul(Ae,pe)|0,h=h+Math.imul(re,rt)|0,d=d+Math.imul(re,pe)|0,_=_+Math.imul(Ce,Fe)|0,h=h+Math.imul(Ce,ge)|0,h=h+Math.imul(ue,Fe)|0,d=d+Math.imul(ue,ge)|0,_=_+Math.imul(se,Te)|0,h=h+Math.imul(se,ye)|0,h=h+Math.imul(ne,Te)|0,d=d+Math.imul(ne,ye)|0,_=_+Math.imul(W,ze)|0,h=h+Math.imul(W,we)|0,h=h+Math.imul(J,ze)|0,d=d+Math.imul(J,we)|0,_=_+Math.imul(q,Be)|0,h=h+Math.imul(q,be)|0,h=h+Math.imul(v,Be)|0,d=d+Math.imul(v,be)|0,_=_+Math.imul(H,$e)|0,h=h+Math.imul(H,_e)|0,h=h+Math.imul(R,$e)|0,d=d+Math.imul(R,_e)|0,_=_+Math.imul(K,nt)|0,h=h+Math.imul(K,qe)|0,h=h+Math.imul(G,nt)|0,d=d+Math.imul(G,qe)|0;var Si=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(Si>>>26)|0,Si&=67108863,_=Math.imul(he,We),h=Math.imul(he,Oe),h=h+Math.imul(ae,We)|0,d=Math.imul(ae,Oe),_=_+Math.imul(fe,He)|0,h=h+Math.imul(fe,Re)|0,h=h+Math.imul(te,He)|0,d=d+Math.imul(te,Re)|0,_=_+Math.imul(le,rt)|0,h=h+Math.imul(le,pe)|0,h=h+Math.imul(ee,rt)|0,d=d+Math.imul(ee,pe)|0,_=_+Math.imul(Ae,Fe)|0,h=h+Math.imul(Ae,ge)|0,h=h+Math.imul(re,Fe)|0,d=d+Math.imul(re,ge)|0,_=_+Math.imul(Ce,Te)|0,h=h+Math.imul(Ce,ye)|0,h=h+Math.imul(ue,Te)|0,d=d+Math.imul(ue,ye)|0,_=_+Math.imul(se,ze)|0,h=h+Math.imul(se,we)|0,h=h+Math.imul(ne,ze)|0,d=d+Math.imul(ne,we)|0,_=_+Math.imul(W,Be)|0,h=h+Math.imul(W,be)|0,h=h+Math.imul(J,Be)|0,d=d+Math.imul(J,be)|0,_=_+Math.imul(q,$e)|0,h=h+Math.imul(q,_e)|0,h=h+Math.imul(v,$e)|0,d=d+Math.imul(v,_e)|0,_=_+Math.imul(H,nt)|0,h=h+Math.imul(H,qe)|0,h=h+Math.imul(R,nt)|0,d=d+Math.imul(R,qe)|0;var Mi=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(Mi>>>26)|0,Mi&=67108863,_=Math.imul(he,He),h=Math.imul(he,Re),h=h+Math.imul(ae,He)|0,d=Math.imul(ae,Re),_=_+Math.imul(fe,rt)|0,h=h+Math.imul(fe,pe)|0,h=h+Math.imul(te,rt)|0,d=d+Math.imul(te,pe)|0,_=_+Math.imul(le,Fe)|0,h=h+Math.imul(le,ge)|0,h=h+Math.imul(ee,Fe)|0,d=d+Math.imul(ee,ge)|0,_=_+Math.imul(Ae,Te)|0,h=h+Math.imul(Ae,ye)|0,h=h+Math.imul(re,Te)|0,d=d+Math.imul(re,ye)|0,_=_+Math.imul(Ce,ze)|0,h=h+Math.imul(Ce,we)|0,h=h+Math.imul(ue,ze)|0,d=d+Math.imul(ue,we)|0,_=_+Math.imul(se,Be)|0,h=h+Math.imul(se,be)|0,h=h+Math.imul(ne,Be)|0,d=d+Math.imul(ne,be)|0,_=_+Math.imul(W,$e)|0,h=h+Math.imul(W,_e)|0,h=h+Math.imul(J,$e)|0,d=d+Math.imul(J,_e)|0,_=_+Math.imul(q,nt)|0,h=h+Math.imul(q,qe)|0,h=h+Math.imul(v,nt)|0,d=d+Math.imul(v,qe)|0;var Ii=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(Ii>>>26)|0,Ii&=67108863,_=Math.imul(he,rt),h=Math.imul(he,pe),h=h+Math.imul(ae,rt)|0,d=Math.imul(ae,pe),_=_+Math.imul(fe,Fe)|0,h=h+Math.imul(fe,ge)|0,h=h+Math.imul(te,Fe)|0,d=d+Math.imul(te,ge)|0,_=_+Math.imul(le,Te)|0,h=h+Math.imul(le,ye)|0,h=h+Math.imul(ee,Te)|0,d=d+Math.imul(ee,ye)|0,_=_+Math.imul(Ae,ze)|0,h=h+Math.imul(Ae,we)|0,h=h+Math.imul(re,ze)|0,d=d+Math.imul(re,we)|0,_=_+Math.imul(Ce,Be)|0,h=h+Math.imul(Ce,be)|0,h=h+Math.imul(ue,Be)|0,d=d+Math.imul(ue,be)|0,_=_+Math.imul(se,$e)|0,h=h+Math.imul(se,_e)|0,h=h+Math.imul(ne,$e)|0,d=d+Math.imul(ne,_e)|0,_=_+Math.imul(W,nt)|0,h=h+Math.imul(W,qe)|0,h=h+Math.imul(J,nt)|0,d=d+Math.imul(J,qe)|0;var Sr=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(Sr>>>26)|0,Sr&=67108863,_=Math.imul(he,Fe),h=Math.imul(he,ge),h=h+Math.imul(ae,Fe)|0,d=Math.imul(ae,ge),_=_+Math.imul(fe,Te)|0,h=h+Math.imul(fe,ye)|0,h=h+Math.imul(te,Te)|0,d=d+Math.imul(te,ye)|0,_=_+Math.imul(le,ze)|0,h=h+Math.imul(le,we)|0,h=h+Math.imul(ee,ze)|0,d=d+Math.imul(ee,we)|0,_=_+Math.imul(Ae,Be)|0,h=h+Math.imul(Ae,be)|0,h=h+Math.imul(re,Be)|0,d=d+Math.imul(re,be)|0,_=_+Math.imul(Ce,$e)|0,h=h+Math.imul(Ce,_e)|0,h=h+Math.imul(ue,$e)|0,d=d+Math.imul(ue,_e)|0,_=_+Math.imul(se,nt)|0,h=h+Math.imul(se,qe)|0,h=h+Math.imul(ne,nt)|0,d=d+Math.imul(ne,qe)|0;var Di=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(Di>>>26)|0,Di&=67108863,_=Math.imul(he,Te),h=Math.imul(he,ye),h=h+Math.imul(ae,Te)|0,d=Math.imul(ae,ye),_=_+Math.imul(fe,ze)|0,h=h+Math.imul(fe,we)|0,h=h+Math.imul(te,ze)|0,d=d+Math.imul(te,we)|0,_=_+Math.imul(le,Be)|0,h=h+Math.imul(le,be)|0,h=h+Math.imul(ee,Be)|0,d=d+Math.imul(ee,be)|0,_=_+Math.imul(Ae,$e)|0,h=h+Math.imul(Ae,_e)|0,h=h+Math.imul(re,$e)|0,d=d+Math.imul(re,_e)|0,_=_+Math.imul(Ce,nt)|0,h=h+Math.imul(Ce,qe)|0,h=h+Math.imul(ue,nt)|0,d=d+Math.imul(ue,qe)|0;var Oi=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(Oi>>>26)|0,Oi&=67108863,_=Math.imul(he,ze),h=Math.imul(he,we),h=h+Math.imul(ae,ze)|0,d=Math.imul(ae,we),_=_+Math.imul(fe,Be)|0,h=h+Math.imul(fe,be)|0,h=h+Math.imul(te,Be)|0,d=d+Math.imul(te,be)|0,_=_+Math.imul(le,$e)|0,h=h+Math.imul(le,_e)|0,h=h+Math.imul(ee,$e)|0,d=d+Math.imul(ee,_e)|0,_=_+Math.imul(Ae,nt)|0,h=h+Math.imul(Ae,qe)|0,h=h+Math.imul(re,nt)|0,d=d+Math.imul(re,qe)|0;var $t=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+($t>>>26)|0,$t&=67108863,_=Math.imul(he,Be),h=Math.imul(he,be),h=h+Math.imul(ae,Be)|0,d=Math.imul(ae,be),_=_+Math.imul(fe,$e)|0,h=h+Math.imul(fe,_e)|0,h=h+Math.imul(te,$e)|0,d=d+Math.imul(te,_e)|0,_=_+Math.imul(le,nt)|0,h=h+Math.imul(le,qe)|0,h=h+Math.imul(ee,nt)|0,d=d+Math.imul(ee,qe)|0;var Ri=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(Ri>>>26)|0,Ri&=67108863,_=Math.imul(he,$e),h=Math.imul(he,_e),h=h+Math.imul(ae,$e)|0,d=Math.imul(ae,_e),_=_+Math.imul(fe,nt)|0,h=h+Math.imul(fe,qe)|0,h=h+Math.imul(te,nt)|0,d=d+Math.imul(te,qe)|0;var Ni=(x+_|0)+((h&8191)<<13)|0;x=(d+(h>>>13)|0)+(Ni>>>26)|0,Ni&=67108863,_=Math.imul(he,nt),h=Math.imul(he,qe),h=h+Math.imul(ae,nt)|0,d=Math.imul(ae,qe);var Pi=(x+_|0)+((h&8191)<<13)|0;return x=(d+(h>>>13)|0)+(Pi>>>26)|0,Pi&=67108863,A[0]=Ye,A[1]=nr,A[2]=sr,A[3]=ar,A[4]=or,A[5]=cr,A[6]=wt,A[7]=Ei,A[8]=xi,A[9]=Si,A[10]=Mi,A[11]=Ii,A[12]=Sr,A[13]=Di,A[14]=Oi,A[15]=$t,A[16]=Ri,A[17]=Ni,A[18]=Pi,x!==0&&(A[19]=x,f.length++),f};Math.imul||(F=I);function k(N,g,a){a.negative=g.negative^N.negative,a.length=N.length+g.length;for(var f=0,p=0,w=0;w<a.length-1;w++){var A=p;p=0;for(var x=f&67108863,_=Math.min(w,g.length-1),h=Math.max(0,w-N.length+1);h<=_;h++){var d=w-h,D=N.words[d]|0,K=g.words[h]|0,G=D*K,E=G&67108863;A=A+(G/67108864|0)|0,E=E+x|0,x=E&67108863,A=A+(E>>>26)|0,p+=A>>>26,A&=67108863}a.words[w]=x,f=A,A=p}return f!==0?a.words[w]=f:a.length--,a.strip()}function j(N,g,a){var f=new C;return f.mulp(N,g,a)}s.prototype.mulTo=function(g,a){var f,p=this.length+g.length;return this.length===10&&g.length===10?f=F(this,g,a):p<63?f=I(this,g,a):p<1024?f=k(this,g,a):f=j(this,g,a),f};function C(N,g){this.x=N,this.y=g}C.prototype.makeRBT=function(g){for(var a=new Array(g),f=s.prototype._countBits(g)-1,p=0;p<g;p++)a[p]=this.revBin(p,f,g);return a},C.prototype.revBin=function(g,a,f){if(g===0||g===f-1)return g;for(var p=0,w=0;w<a;w++)p|=(g&1)<<a-w-1,g>>=1;return p},C.prototype.permute=function(g,a,f,p,w,A){for(var x=0;x<A;x++)p[x]=a[g[x]],w[x]=f[g[x]]},C.prototype.transform=function(g,a,f,p,w,A){this.permute(A,g,a,f,p,w);for(var x=1;x<w;x<<=1)for(var _=x<<1,h=Math.cos(2*Math.PI/_),d=Math.sin(2*Math.PI/_),D=0;D<w;D+=_)for(var K=h,G=d,E=0;E<x;E++){var H=f[D+E],R=p[D+E],L=f[D+E+x],q=p[D+E+x],v=K*L-G*q;q=K*q+G*L,L=v,f[D+E]=H+L,p[D+E]=R+q,f[D+E+x]=H-L,p[D+E+x]=R-q,E!==_&&(v=h*K-d*G,G=h*G+d*K,K=v)}},C.prototype.guessLen13b=function(g,a){var f=Math.max(a,g)|1,p=f&1,w=0;for(f=f/2|0;f;f=f>>>1)w++;return 1<<w+1+p},C.prototype.conjugate=function(g,a,f){if(!(f<=1))for(var p=0;p<f/2;p++){var w=g[p];g[p]=g[f-p-1],g[f-p-1]=w,w=a[p],a[p]=-a[f-p-1],a[f-p-1]=-w}},C.prototype.normalize13b=function(g,a){for(var f=0,p=0;p<a/2;p++){var w=Math.round(g[2*p+1]/a)*8192+Math.round(g[2*p]/a)+f;g[p]=w&67108863,w<67108864?f=0:f=w/67108864|0}return g},C.prototype.convert13b=function(g,a,f,p){for(var w=0,A=0;A<a;A++)w=w+(g[A]|0),f[2*A]=w&8191,w=w>>>13,f[2*A+1]=w&8191,w=w>>>13;for(A=2*a;A<p;++A)f[A]=0;i(w===0),i((w&-8192)===0)},C.prototype.stub=function(g){for(var a=new Array(g),f=0;f<g;f++)a[f]=0;return a},C.prototype.mulp=function(g,a,f){var p=2*this.guessLen13b(g.length,a.length),w=this.makeRBT(p),A=this.stub(p),x=new Array(p),_=new Array(p),h=new Array(p),d=new Array(p),D=new Array(p),K=new Array(p),G=f.words;G.length=p,this.convert13b(g.words,g.length,x,p),this.convert13b(a.words,a.length,d,p),this.transform(x,A,_,h,p,w),this.transform(d,A,D,K,p,w);for(var E=0;E<p;E++){var H=_[E]*D[E]-h[E]*K[E];h[E]=_[E]*K[E]+h[E]*D[E],_[E]=H}return this.conjugate(_,h,p),this.transform(_,h,G,A,p,w),this.conjugate(G,A,p),this.normalize13b(G,p),f.negative=g.negative^a.negative,f.length=g.length+a.length,f.strip()},s.prototype.mul=function(g){var a=new s(null);return a.words=new Array(this.length+g.length),this.mulTo(g,a)},s.prototype.mulf=function(g){var a=new s(null);return a.words=new Array(this.length+g.length),j(this,g,a)},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 a=0,f=0;f<this.length;f++){var p=(this.words[f]|0)*g,w=(p&67108863)+(a&67108863);a>>=26,a+=p/67108864|0,a+=w>>>26,this.words[f]=w&67108863}return a!==0&&(this.words[f]=a,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 a=S(g);if(a.length===0)return new s(1);for(var f=this,p=0;p<a.length&&a[p]===0;p++,f=f.sqr());if(++p<a.length)for(var w=f.sqr();p<a.length;p++,w=w.sqr())a[p]!==0&&(f=f.mul(w));return f},s.prototype.iushln=function(g){i(typeof g=="number"&&g>=0);var a=g%26,f=(g-a)/26,p=67108863>>>26-a<<26-a,w;if(a!==0){var A=0;for(w=0;w<this.length;w++){var x=this.words[w]&p,_=(this.words[w]|0)-x<<a;this.words[w]=_|A,A=x>>>26-a}A&&(this.words[w]=A,this.length++)}if(f!==0){for(w=this.length-1;w>=0;w--)this.words[w+f]=this.words[w];for(w=0;w<f;w++)this.words[w]=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,a,f){i(typeof g=="number"&&g>=0);var p;a?p=(a-a%26)/26:p=0;var w=g%26,A=Math.min((g-w)/26,this.length),x=67108863^67108863>>>w<<w,_=f;if(p-=A,p=Math.max(0,p),_){for(var h=0;h<A;h++)_.words[h]=this.words[h];_.length=A}if(A!==0)if(this.length>A)for(this.length-=A,h=0;h<this.length;h++)this.words[h]=this.words[h+A];else this.words[0]=0,this.length=1;var d=0;for(h=this.length-1;h>=0&&(d!==0||h>=p);h--){var D=this.words[h]|0;this.words[h]=d<<26-w|D>>>w,d=D&x}return _&&d!==0&&(_.words[_.length++]=d),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(g,a,f){return i(this.negative===0),this.iushrn(g,a,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 a=g%26,f=(g-a)/26,p=1<<a;if(this.length<=f)return!1;var w=this.words[f];return!!(w&p)},s.prototype.imaskn=function(g){i(typeof g=="number"&&g>=0);var a=g%26,f=(g-a)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=f)return this;if(a!==0&&f++,this.length=Math.min(f,this.length),a!==0){var p=67108863^67108863>>>a<<a;this.words[this.length-1]&=p}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 a=0;a<this.length&&this.words[a]>=67108864;a++)this.words[a]-=67108864,a===this.length-1?this.words[a+1]=1:this.words[a+1]++;return this.length=Math.max(this.length,a+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 a=0;a<this.length&&this.words[a]<0;a++)this.words[a]+=67108864,this.words[a+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,a,f){var p=g.length+f,w;this._expand(p);var A,x=0;for(w=0;w<g.length;w++){A=(this.words[w+f]|0)+x;var _=(g.words[w]|0)*a;A-=_&67108863,x=(A>>26)-(_/67108864|0),this.words[w+f]=A&67108863}for(;w<this.length-f;w++)A=(this.words[w+f]|0)+x,x=A>>26,this.words[w+f]=A&67108863;if(x===0)return this.strip();for(i(x===-1),x=0,w=0;w<this.length;w++)A=-(this.words[w]|0)+x,x=A>>26,this.words[w]=A&67108863;return this.negative=1,this.strip()},s.prototype._wordDiv=function(g,a){var f=this.length-g.length,p=this.clone(),w=g,A=w.words[w.length-1]|0,x=this._countBits(A);f=26-x,f!==0&&(w=w.ushln(f),p.iushln(f),A=w.words[w.length-1]|0);var _=p.length-w.length,h;if(a!=="mod"){h=new s(null),h.length=_+1,h.words=new Array(h.length);for(var d=0;d<h.length;d++)h.words[d]=0}var D=p.clone()._ishlnsubmul(w,1,_);D.negative===0&&(p=D,h&&(h.words[_]=1));for(var K=_-1;K>=0;K--){var G=(p.words[w.length+K]|0)*67108864+(p.words[w.length+K-1]|0);for(G=Math.min(G/A|0,67108863),p._ishlnsubmul(w,G,K);p.negative!==0;)G--,p.negative=0,p._ishlnsubmul(w,1,K),p.isZero()||(p.negative^=1);h&&(h.words[K]=G)}return h&&h.strip(),p.strip(),a!=="div"&&f!==0&&p.iushrn(f),{div:h||null,mod:p}},s.prototype.divmod=function(g,a,f){if(i(!g.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var p,w,A;return this.negative!==0&&g.negative===0?(A=this.neg().divmod(g,a),a!=="mod"&&(p=A.div.neg()),a!=="div"&&(w=A.mod.neg(),f&&w.negative!==0&&w.iadd(g)),{div:p,mod:w}):this.negative===0&&g.negative!==0?(A=this.divmod(g.neg(),a),a!=="mod"&&(p=A.div.neg()),{div:p,mod:A.mod}):this.negative&g.negative?(A=this.neg().divmod(g.neg(),a),a!=="div"&&(w=A.mod.neg(),f&&w.negative!==0&&w.isub(g)),{div:A.div,mod:w}):g.length>this.length||this.cmp(g)<0?{div:new s(0),mod:this}:g.length===1?a==="div"?{div:this.divn(g.words[0]),mod:null}:a==="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,a)},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 a=this.divmod(g);if(a.mod.isZero())return a.div;var f=a.div.negative!==0?a.mod.isub(g):a.mod,p=g.ushrn(1),w=g.andln(1),A=f.cmp(p);return A<0||w===1&&A===0?a.div:a.div.negative!==0?a.div.isubn(1):a.div.iaddn(1)},s.prototype.modn=function(g){i(g<=67108863);for(var a=(1<<26)%g,f=0,p=this.length-1;p>=0;p--)f=(a*f+(this.words[p]|0))%g;return f},s.prototype.idivn=function(g){i(g<=67108863);for(var a=0,f=this.length-1;f>=0;f--){var p=(this.words[f]|0)+a*67108864;this.words[f]=p/g|0,a=p%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 a=this,f=g.clone();a.negative!==0?a=a.umod(g):a=a.clone();for(var p=new s(1),w=new s(0),A=new s(0),x=new s(1),_=0;a.isEven()&&f.isEven();)a.iushrn(1),f.iushrn(1),++_;for(var h=f.clone(),d=a.clone();!a.isZero();){for(var D=0,K=1;!(a.words[0]&K)&&D<26;++D,K<<=1);if(D>0)for(a.iushrn(D);D-- >0;)(p.isOdd()||w.isOdd())&&(p.iadd(h),w.isub(d)),p.iushrn(1),w.iushrn(1);for(var G=0,E=1;!(f.words[0]&E)&&G<26;++G,E<<=1);if(G>0)for(f.iushrn(G);G-- >0;)(A.isOdd()||x.isOdd())&&(A.iadd(h),x.isub(d)),A.iushrn(1),x.iushrn(1);a.cmp(f)>=0?(a.isub(f),p.isub(A),w.isub(x)):(f.isub(a),A.isub(p),x.isub(w))}return{a:A,b:x,gcd:f.iushln(_)}},s.prototype._invmp=function(g){i(g.negative===0),i(!g.isZero());var a=this,f=g.clone();a.negative!==0?a=a.umod(g):a=a.clone();for(var p=new s(1),w=new s(0),A=f.clone();a.cmpn(1)>0&&f.cmpn(1)>0;){for(var x=0,_=1;!(a.words[0]&_)&&x<26;++x,_<<=1);if(x>0)for(a.iushrn(x);x-- >0;)p.isOdd()&&p.iadd(A),p.iushrn(1);for(var h=0,d=1;!(f.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(f.iushrn(h);h-- >0;)w.isOdd()&&w.iadd(A),w.iushrn(1);a.cmp(f)>=0?(a.isub(f),p.isub(w)):(f.isub(a),w.isub(p))}var D;return a.cmpn(1)===0?D=p:D=w,D.cmpn(0)<0&&D.iadd(g),D},s.prototype.gcd=function(g){if(this.isZero())return g.abs();if(g.isZero())return this.abs();var a=this.clone(),f=g.clone();a.negative=0,f.negative=0;for(var p=0;a.isEven()&&f.isEven();p++)a.iushrn(1),f.iushrn(1);do{for(;a.isEven();)a.iushrn(1);for(;f.isEven();)f.iushrn(1);var w=a.cmp(f);if(w<0){var A=a;a=f,f=A}else if(w===0||f.cmpn(1)===0)break;a.isub(f)}while(!0);return f.iushln(p)},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 a=g%26,f=(g-a)/26,p=1<<a;if(this.length<=f)return this._expand(f+1),this.words[f]|=p,this;for(var w=p,A=f;w!==0&&A<this.length;A++){var x=this.words[A]|0;x+=w,w=x>>>26,x&=67108863,this.words[A]=x}return w!==0&&(this.words[A]=w,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(g){var a=g<0;if(this.negative!==0&&!a)return-1;if(this.negative===0&&a)return 1;this.strip();var f;if(this.length>1)f=1;else{a&&(g=-g),i(g<=67108863,"Number is too big");var p=this.words[0]|0;f=p===g?0:p<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 a=this.ucmp(g);return this.negative!==0?-a|0:a},s.prototype.ucmp=function(g){if(this.length>g.length)return 1;if(this.length<g.length)return-1;for(var a=0,f=this.length-1;f>=0;f--){var p=this.words[f]|0,w=g.words[f]|0;if(p!==w){p<w?a=-1:p>w&&(a=1);break}}return a},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 Y(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 $={k256:null,p224:null,p192:null,p25519:null};function P(N,g){this.name=N,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()}P.prototype._tmp=function(){var g=new s(null);return g.words=new Array(Math.ceil(this.n/13)),g},P.prototype.ireduce=function(g){var a=g,f;do this.split(a,this.tmp),a=this.imulK(a),a=a.iadd(this.tmp),f=a.bitLength();while(f>this.n);var p=f<this.n?-1:a.ucmp(this.p);return p===0?(a.words[0]=0,a.length=1):p>0?a.isub(this.p):a.strip!==void 0?a.strip():a._strip(),a},P.prototype.split=function(g,a){g.iushrn(this.n,0,a)},P.prototype.imulK=function(g){return g.imul(this.k)};function B(){P.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(B,P),B.prototype.split=function(g,a){for(var f=4194303,p=Math.min(g.length,9),w=0;w<p;w++)a.words[w]=g.words[w];if(a.length=p,g.length<=9){g.words[0]=0,g.length=1;return}var A=g.words[9];for(a.words[a.length++]=A&f,w=10;w<g.length;w++){var x=g.words[w]|0;g.words[w-10]=(x&f)<<4|A>>>22,A=x}A>>>=22,g.words[w-10]=A,A===0&&g.length>10?g.length-=10:g.length-=9},B.prototype.imulK=function(g){g.words[g.length]=0,g.words[g.length+1]=0,g.length+=2;for(var a=0,f=0;f<g.length;f++){var p=g.words[f]|0;a+=p*977,g.words[f]=a&67108863,a=p*64+(a/67108864|0)}return g.words[g.length-1]===0&&(g.length--,g.words[g.length-1]===0&&g.length--),g};function U(){P.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(U,P);function y(){P.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(y,P);function O(){P.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(O,P),O.prototype.imulK=function(g){for(var a=0,f=0;f<g.length;f++){var p=(g.words[f]|0)*19+a,w=p&67108863;p>>>=26,g.words[f]=w,a=p}return a!==0&&(g.words[g.length++]=a),g},s._prime=function(g){if($[g])return $[g];var a;if(g==="k256")a=new B;else if(g==="p224")a=new U;else if(g==="p192")a=new y;else if(g==="p25519")a=new O;else throw new Error("Unknown prime "+g);return $[g]=a,a};function Y(N){if(typeof N=="string"){var g=s._prime(N);this.m=g.p,this.prime=g}else i(N.gtn(1),"modulus must be greater than 1"),this.m=N,this.prime=null}Y.prototype._verify1=function(g){i(g.negative===0,"red works only with positives"),i(g.red,"red works only with red numbers")},Y.prototype._verify2=function(g,a){i((g.negative|a.negative)===0,"red works only with positives"),i(g.red&&g.red===a.red,"red works only with red numbers")},Y.prototype.imod=function(g){return this.prime?this.prime.ireduce(g)._forceRed(this):g.umod(this.m)._forceRed(this)},Y.prototype.neg=function(g){return g.isZero()?g.clone():this.m.sub(g)._forceRed(this)},Y.prototype.add=function(g,a){this._verify2(g,a);var f=g.add(a);return f.cmp(this.m)>=0&&f.isub(this.m),f._forceRed(this)},Y.prototype.iadd=function(g,a){this._verify2(g,a);var f=g.iadd(a);return f.cmp(this.m)>=0&&f.isub(this.m),f},Y.prototype.sub=function(g,a){this._verify2(g,a);var f=g.sub(a);return f.cmpn(0)<0&&f.iadd(this.m),f._forceRed(this)},Y.prototype.isub=function(g,a){this._verify2(g,a);var f=g.isub(a);return f.cmpn(0)<0&&f.iadd(this.m),f},Y.prototype.shl=function(g,a){return this._verify1(g),this.imod(g.ushln(a))},Y.prototype.imul=function(g,a){return this._verify2(g,a),this.imod(g.imul(a))},Y.prototype.mul=function(g,a){return this._verify2(g,a),this.imod(g.mul(a))},Y.prototype.isqr=function(g){return this.imul(g,g.clone())},Y.prototype.sqr=function(g){return this.mul(g,g)},Y.prototype.sqrt=function(g){if(g.isZero())return g.clone();var a=this.m.andln(3);if(i(a%2===1),a===3){var f=this.m.add(new s(1)).iushrn(2);return this.pow(g,f)}for(var p=this.m.subn(1),w=0;!p.isZero()&&p.andln(1)===0;)w++,p.iushrn(1);i(!p.isZero());var A=new s(1).toRed(this),x=A.redNeg(),_=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new s(2*h*h).toRed(this);this.pow(h,_).cmp(x)!==0;)h.redIAdd(x);for(var d=this.pow(h,p),D=this.pow(g,p.addn(1).iushrn(1)),K=this.pow(g,p),G=w;K.cmp(A)!==0;){for(var E=K,H=0;E.cmp(A)!==0;H++)E=E.redSqr();i(H<G);var R=this.pow(d,new s(1).iushln(G-H-1));D=D.redMul(R),d=R.redSqr(),K=K.redMul(d),G=H}return D},Y.prototype.invm=function(g){var a=g._invmp(this.m);return a.negative!==0?(a.negative=0,this.imod(a).redNeg()):this.imod(a)},Y.prototype.pow=function(g,a){if(a.isZero())return new s(1).toRed(this);if(a.cmpn(1)===0)return g.clone();var f=4,p=new Array(1<<f);p[0]=new s(1).toRed(this),p[1]=g;for(var w=2;w<p.length;w++)p[w]=this.mul(p[w-1],g);var A=p[0],x=0,_=0,h=a.bitLength()%26;for(h===0&&(h=26),w=a.length-1;w>=0;w--){for(var d=a.words[w],D=h-1;D>=0;D--){var K=d>>D&1;if(A!==p[0]&&(A=this.sqr(A)),K===0&&x===0){_=0;continue}x<<=1,x|=K,_++,!(_!==f&&(w!==0||D!==0))&&(A=this.mul(A,p[x]),_=0,x=0)}h=26}return A},Y.prototype.convertTo=function(g){var a=g.umod(this.m);return a===g?a.clone():a},Y.prototype.convertFrom=function(g){var a=g.clone();return a.red=null,a},s.mont=function(g){return new Q(g)};function Q(N){Y.call(this,N),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(Q,Y),Q.prototype.convertTo=function(g){return this.imod(g.ushln(this.shift))},Q.prototype.convertFrom=function(g){var a=this.imod(g.mul(this.rinv));return a.red=null,a},Q.prototype.imul=function(g,a){if(g.isZero()||a.isZero())return g.words[0]=0,g.length=1,g;var f=g.imul(a),p=f.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),w=f.isub(p).iushrn(this.shift),A=w;return w.cmp(this.m)>=0?A=w.isub(this.m):w.cmpn(0)<0&&(A=w.iadd(this.m)),A._forceRed(this)},Q.prototype.mul=function(g,a){if(g.isZero()||a.isZero())return new s(0)._forceRed(this);var f=g.mul(a),p=f.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),w=f.isub(p).iushrn(this.shift),A=w;return w.cmp(this.m)>=0?A=w.isub(this.m):w.cmpn(0)<0&&(A=w.iadd(this.m)),A._forceRed(this)},Q.prototype.invm=function(g){var a=this.imod(g._invmp(this.m).mul(this.r2));return a._forceRed(this)}})(t,Kt)})(zr);var en=Uh;function Uh(t,e){if(!t)throw new Error(e||"Assertion failed")}Uh.equal=function(e,r,i){if(e!=r)throw new Error(i||"Assertion failed: "+e+" != "+r)};var jo={};(function(t){var e=t;function r(s,o){if(Array.isArray(s))return s.slice();if(!s)return[];var c=[];if(typeof s!="string"){for(var l=0;l<s.length;l++)c[l]=s[l]|0;return c}if(o==="hex"){s=s.replace(/[^a-z0-9]+/ig,""),s.length%2!==0&&(s="0"+s);for(var l=0;l<s.length;l+=2)c.push(parseInt(s[l]+s[l+1],16))}else for(var l=0;l<s.length;l++){var u=s.charCodeAt(l),b=u>>8,m=u&255;b?c.push(b,m):c.push(m)}return c}e.toArray=r;function i(s){return s.length===1?"0"+s:s}e.zero2=i;function n(s){for(var o="",c=0;c<s.length;c++)o+=i(s[c].toString(16));return o}e.toHex=n,e.encode=function(o,c){return c==="hex"?n(o):o}})(jo),function(t){var e=t,r=zr.exports,i=en,n=jo;e.assert=i,e.toArray=n.toArray,e.zero2=n.zero2,e.toHex=n.toHex,e.encode=n.encode;function s(b,m,M){var S=new Array(Math.max(b.bitLength(),M)+1),I;for(I=0;I<S.length;I+=1)S[I]=0;var F=1<<m+1,k=b.clone();for(I=0;I<S.length;I++){var j,C=k.andln(F-1);k.isOdd()?(C>(F>>1)-1?j=(F>>1)-C:j=C,k.isubn(j)):j=0,S[I]=j,k.iushrn(1)}return S}e.getNAF=s;function o(b,m){var M=[[],[]];b=b.clone(),m=m.clone();for(var S=0,I=0,F;b.cmpn(-S)>0||m.cmpn(-I)>0;){var k=b.andln(3)+S&3,j=m.andln(3)+I&3;k===3&&(k=-1),j===3&&(j=-1);var C;k&1?(F=b.andln(7)+S&7,(F===3||F===5)&&j===2?C=-k:C=k):C=0,M[0].push(C);var $;j&1?(F=m.andln(7)+I&7,(F===3||F===5)&&k===2?$=-j:$=j):$=0,M[1].push($),2*S===C+1&&(S=1-S),2*I===$+1&&(I=1-I),b.iushrn(1),m.iushrn(1)}return M}e.getJSF=o;function c(b,m,M){var S="_"+m;b.prototype[m]=function(){return this[S]!==void 0?this[S]:this[S]=M.call(this)}}e.cachedProperty=c;function l(b){return typeof b=="string"?e.toArray(b,"hex"):b}e.parseBytes=l;function u(b){return new r(b,"hex","le")}e.intFromLE=u}(hr);var ma={exports:{}},Ko;ma.exports=function(e){return Ko||(Ko=new Li(null)),Ko.generate(e)};function Li(t){this.rand=t}if(ma.exports.Rand=Li,Li.prototype.generate=function(e){return this._rand(e)},Li.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?Li.prototype._rand=function(e){var r=new Uint8Array(e);return self.crypto.getRandomValues(r),r}:self.msCrypto&&self.msCrypto.getRandomValues?Li.prototype._rand=function(e){var r=new Uint8Array(e);return self.msCrypto.getRandomValues(r),r}:typeof window=="object"&&(Li.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var zh=Io;if(typeof zh.randomBytes!="function")throw new Error("Not supported");Li.prototype._rand=function(e){return zh.randomBytes(e)}}catch{}var Ho={},tn=zr.exports,gs=hr,ya=gs.getNAF,K2=gs.getJSF,wa=gs.assert;function Bi(t,e){this.type=t,this.p=new tn(e.p,16),this.red=e.prime?tn.red(e.prime):tn.mont(this.p),this.zero=new tn(0).toRed(this.red),this.one=new tn(1).toRed(this.red),this.two=new tn(2).toRed(this.red),this.n=e.n&&new tn(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 _a=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){wa(e.precomputed);var i=e._getDoubles(),n=ya(r,1,this._bitLength),s=(1<<i.step+1)-(i.step%2===0?2:1);s/=3;var o=[],c,l;for(c=0;c<n.length;c+=i.step){l=0;for(var u=c+i.step-1;u>=c;u--)l=(l<<1)+n[u];o.push(l)}for(var b=this.jpoint(null,null,null),m=this.jpoint(null,null,null),M=s;M>0;M--){for(c=0;c<o.length;c++)l=o[c],l===M?m=m.mixedAdd(i.points[c]):l===-M&&(m=m.mixedAdd(i.points[c].neg()));b=b.add(m)}return b.toP()},Bi.prototype._wnafMul=function(e,r){var i=4,n=e._getNAFPoints(i);i=n.wnd;for(var s=n.points,o=ya(r,i,this._bitLength),c=this.jpoint(null,null,null),l=o.length-1;l>=0;l--){for(var u=0;l>=0&&o[l]===0;l--)u++;if(l>=0&&u++,c=c.dblp(u),l<0)break;var b=o[l];wa(b!==0),e.type==="affine"?b>0?c=c.mixedAdd(s[b-1>>1]):c=c.mixedAdd(s[-b-1>>1].neg()):b>0?c=c.add(s[b-1>>1]):c=c.add(s[-b-1>>1].neg())}return e.type==="affine"?c.toP():c},Bi.prototype._wnafMulAdd=function(e,r,i,n,s){var o=this._wnafT1,c=this._wnafT2,l=this._wnafT3,u=0,b,m,M;for(b=0;b<n;b++){M=r[b];var S=M._getNAFPoints(e);o[b]=S.wnd,c[b]=S.points}for(b=n-1;b>=1;b-=2){var I=b-1,F=b;if(o[I]!==1||o[F]!==1){l[I]=ya(i[I],o[I],this._bitLength),l[F]=ya(i[F],o[F],this._bitLength),u=Math.max(l[I].length,u),u=Math.max(l[F].length,u);continue}var k=[r[I],null,null,r[F]];r[I].y.cmp(r[F].y)===0?(k[1]=r[I].add(r[F]),k[2]=r[I].toJ().mixedAdd(r[F].neg())):r[I].y.cmp(r[F].y.redNeg())===0?(k[1]=r[I].toJ().mixedAdd(r[F]),k[2]=r[I].add(r[F].neg())):(k[1]=r[I].toJ().mixedAdd(r[F]),k[2]=r[I].toJ().mixedAdd(r[F].neg()));var j=[-3,-1,-5,-7,0,7,5,1,3],C=K2(i[I],i[F]);for(u=Math.max(C[0].length,u),l[I]=new Array(u),l[F]=new Array(u),m=0;m<u;m++){var $=C[0][m]|0,P=C[1][m]|0;l[I][m]=j[($+1)*3+(P+1)],l[F][m]=0,c[I]=k}}var B=this.jpoint(null,null,null),U=this._wnafT4;for(b=u;b>=0;b--){for(var y=0;b>=0;){var O=!0;for(m=0;m<n;m++)U[m]=l[m][b]|0,U[m]!==0&&(O=!1);if(!O)break;y++,b--}if(b>=0&&y++,B=B.dblp(y),b<0)break;for(m=0;m<n;m++){var Y=U[m];Y!==0&&(Y>0?M=c[m][Y-1>>1]:Y<0&&(M=c[m][-Y-1>>1].neg()),M.type==="affine"?B=B.mixedAdd(M):B=B.add(M))}}for(b=0;b<n;b++)c[b]=null;return s?B:B.toP()};function gr(t,e){this.curve=t,this.type=e,this.precomputed=null}Bi.BasePoint=gr,gr.prototype.eq=function(){throw new Error("Not implemented")},gr.prototype.validate=function(){return this.curve.validate(this)},Bi.prototype.decodePoint=function(e,r){e=gs.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?wa(e[e.length-1]%2===0):e[0]===7&&wa(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")},gr.prototype.encodeCompressed=function(e){return this.encode(e,!0)},gr.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))},gr.prototype.encode=function(e,r){return gs.encode(this._encode(r),e)},gr.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},gr.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},gr.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}},gr.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}},gr.prototype._getBeta=function(){return null},gr.prototype.dblp=function(e){for(var r=this,i=0;i<e;i++)r=r.dbl();return r};var On={exports:{}};typeof Object.create=="function"?On.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:On.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 H2=hr,pt=zr.exports,Vo=On.exports,Rn=_a,V2=H2.assert;function br(t){Rn.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)}Vo(br,Rn);var G2=br;br.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],V2(this.g.mul(i).x.cmp(this.g.x.redMul(r))===0))}var o;return e.basis?o=e.basis.map(function(c){return{a:new pt(c.a,16),b:new pt(c.b,16)}}):o=this._getEndoBasis(i),{beta:r,lambda:i,basis:o}}},br.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(),c=n.redSub(s).fromRed();return[o,c]},br.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),c=new pt(0),l=new pt(1),u,b,m,M,S,I,F,k=0,j,C;i.cmpn(0)!==0;){var $=n.div(i);j=n.sub($.mul(i)),C=c.sub($.mul(s));var P=l.sub($.mul(o));if(!m&&j.cmp(r)<0)u=F.neg(),b=s,m=j.neg(),M=C;else if(m&&++k===2)break;F=j,n=i,i=j,c=s,s=C,l=o,o=P}S=j.neg(),I=C;var B=m.sqr().add(M.sqr()),U=S.sqr().add(I.sqr());return U.cmp(B)>=0&&(S=u,I=b),m.negative&&(m=m.neg(),M=M.neg()),S.negative&&(S=S.neg(),I=I.neg()),[{a:m,b:M},{a:S,b:I}]},br.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),c=s.mul(i.a),l=o.mul(n.a),u=s.mul(i.b),b=o.mul(n.b),m=e.sub(c).sub(l),M=u.add(b).neg();return{k1:m,k2:M}},br.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)},br.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},br.prototype._endoWnafMulAdd=function(e,r,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o<e.length;o++){var c=this._endoSplit(r[o]),l=e[o],u=l._getBeta();c.k1.negative&&(c.k1.ineg(),l=l.neg(!0)),c.k2.negative&&(c.k2.ineg(),u=u.neg(!0)),n[o*2]=l,n[o*2+1]=u,s[o*2]=c.k1,s[o*2+1]=c.k2}for(var b=this._wnafMulAdd(1,n,s,o*2,i),m=0;m<o*2;m++)n[m]=null,s[m]=null;return b};function St(t,e,r,i){Rn.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)}Vo(St,Rn.BasePoint),br.prototype.point=function(e,r,i){return new St(this,e,r,i)},br.prototype.pointFromJSON=function(e,r){return St.fromJSON(this,e,r)},St.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}},St.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]},St.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(c){return e.point(c[0],c[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},St.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)+">"},St.prototype.isInfinity=function(){return this.inf},St.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)},St.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)),c=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,c)},St.prototype.getX=function(){return this.x.fromRed()},St.prototype.getY=function(){return this.y.fromRed()},St.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)},St.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)},St.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)},St.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)},St.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},St.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 Pt(t,e,r,i){Rn.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}Vo(Pt,Rn.BasePoint),br.prototype.jpoint=function(e,r,i){return new Pt(this,e,r,i)},Pt.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)},Pt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Pt.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)),c=e.y.redMul(i.redMul(this.z)),l=n.redSub(s),u=o.redSub(c);if(l.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var b=l.redSqr(),m=b.redMul(l),M=n.redMul(b),S=u.redSqr().redIAdd(m).redISub(M).redISub(M),I=u.redMul(M.redISub(S)).redISub(o.redMul(m)),F=this.z.redMul(e.z).redMul(l);return this.curve.jpoint(S,I,F)},Pt.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),c=i.redSub(n),l=s.redSub(o);if(c.cmpn(0)===0)return l.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var u=c.redSqr(),b=u.redMul(c),m=i.redMul(u),M=l.redSqr().redIAdd(b).redISub(m).redISub(m),S=l.redMul(m.redISub(M)).redISub(s.redMul(b)),I=this.z.redMul(c);return this.curve.jpoint(M,S,I)},Pt.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,c=this.y,l=this.z,u=l.redSqr().redSqr(),b=c.redAdd(c);for(r=0;r<e;r++){var m=o.redSqr(),M=b.redSqr(),S=M.redSqr(),I=m.redAdd(m).redIAdd(m).redIAdd(n.redMul(u)),F=o.redMul(M),k=I.redSqr().redISub(F.redAdd(F)),j=F.redISub(k),C=I.redMul(j);C=C.redIAdd(C).redISub(S);var $=b.redMul(l);r+1<e&&(u=u.redMul(S)),o=k,l=$,b=C}return this.curve.jpoint(o,b.redMul(s),l)},Pt.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},Pt.prototype._zeroDbl=function(){var e,r,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),c=this.x.redAdd(s).redSqr().redISub(n).redISub(o);c=c.redIAdd(c);var l=n.redAdd(n).redIAdd(n),u=l.redSqr().redISub(c).redISub(c),b=o.redIAdd(o);b=b.redIAdd(b),b=b.redIAdd(b),e=u,r=l.redMul(c.redISub(u)).redISub(b),i=this.y.redAdd(this.y)}else{var m=this.x.redSqr(),M=this.y.redSqr(),S=M.redSqr(),I=this.x.redAdd(M).redSqr().redISub(m).redISub(S);I=I.redIAdd(I);var F=m.redAdd(m).redIAdd(m),k=F.redSqr(),j=S.redIAdd(S);j=j.redIAdd(j),j=j.redIAdd(j),e=k.redISub(I).redISub(I),r=F.redMul(I.redISub(e)).redISub(j),i=this.y.redMul(this.z),i=i.redIAdd(i)}return this.curve.jpoint(e,r,i)},Pt.prototype._threeDbl=function(){var e,r,i;if(this.zOne){var n=this.x.redSqr(),s=this.y.redSqr(),o=s.redSqr(),c=this.x.redAdd(s).redSqr().redISub(n).redISub(o);c=c.redIAdd(c);var l=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),u=l.redSqr().redISub(c).redISub(c);e=u;var b=o.redIAdd(o);b=b.redIAdd(b),b=b.redIAdd(b),r=l.redMul(c.redISub(u)).redISub(b),i=this.y.redAdd(this.y)}else{var m=this.z.redSqr(),M=this.y.redSqr(),S=this.x.redMul(M),I=this.x.redSub(m).redMul(this.x.redAdd(m));I=I.redAdd(I).redIAdd(I);var F=S.redIAdd(S);F=F.redIAdd(F);var k=F.redAdd(F);e=I.redSqr().redISub(k),i=this.y.redAdd(this.z).redSqr().redISub(M).redISub(m);var j=M.redSqr();j=j.redIAdd(j),j=j.redIAdd(j),j=j.redIAdd(j),r=I.redMul(F.redISub(e)).redISub(j)}return this.curve.jpoint(e,r,i)},Pt.prototype._dbl=function(){var e=this.curve.a,r=this.x,i=this.y,n=this.z,s=n.redSqr().redSqr(),o=r.redSqr(),c=i.redSqr(),l=o.redAdd(o).redIAdd(o).redIAdd(e.redMul(s)),u=r.redAdd(r);u=u.redIAdd(u);var b=u.redMul(c),m=l.redSqr().redISub(b.redAdd(b)),M=b.redISub(m),S=c.redSqr();S=S.redIAdd(S),S=S.redIAdd(S),S=S.redIAdd(S);var I=l.redMul(M).redISub(S),F=i.redAdd(i).redMul(n);return this.curve.jpoint(m,I,F)},Pt.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(),c=this.x.redAdd(r).redSqr().redISub(e).redISub(n);c=c.redIAdd(c),c=c.redAdd(c).redIAdd(c),c=c.redISub(o);var l=c.redSqr(),u=n.redIAdd(n);u=u.redIAdd(u),u=u.redIAdd(u),u=u.redIAdd(u);var b=s.redIAdd(c).redSqr().redISub(o).redISub(l).redISub(u),m=r.redMul(b);m=m.redIAdd(m),m=m.redIAdd(m);var M=this.x.redMul(l).redISub(m);M=M.redIAdd(M),M=M.redIAdd(M);var S=this.y.redMul(b.redMul(u.redISub(b)).redISub(c.redMul(l)));S=S.redIAdd(S),S=S.redIAdd(S),S=S.redIAdd(S);var I=this.z.redAdd(c).redSqr().redISub(i).redISub(l);return this.curve.jpoint(M,S,I)},Pt.prototype.mul=function(e,r){return e=new pt(e,r),this.curve._wnafMul(this,e)},Pt.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},Pt.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}},Pt.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)+">"},Pt.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Nn=zr.exports,kh=On.exports,Aa=_a,W2=hr;function Pn(t){Aa.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))}kh(Pn,Aa);var Y2=Pn;Pn.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 Mt(t,e,r){Aa.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)))}kh(Mt,Aa.BasePoint),Pn.prototype.decodePoint=function(e,r){return this.point(W2.toArray(e,r),1)},Pn.prototype.point=function(e,r){return new Mt(this,e,r)},Pn.prototype.pointFromJSON=function(e){return Mt.fromJSON(this,e)},Mt.prototype.precompute=function(){},Mt.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},Mt.fromJSON=function(e,r){return new Mt(e,r[0],r[1]||e.one)},Mt.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)+">"},Mt.prototype.isInfinity=function(){return this.z.cmpn(0)===0},Mt.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),c=s.redMul(n.redAdd(this.curve.a24.redMul(s)));return this.curve.point(o,c)},Mt.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Mt.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),c=o.redMul(i),l=s.redMul(n),u=r.z.redMul(c.redAdd(l).redSqr()),b=r.x.redMul(c.redISub(l).redSqr());return this.curve.point(u,b)},Mt.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 c=o.length-1;c>=0;c--)o[c]===0?(i=i.diffAdd(n,s),n=n.dbl()):(n=i.diffAdd(n,s),i=i.dbl());return n},Mt.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Mt.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},Mt.prototype.eq=function(e){return this.getX().cmp(e.getX())===0},Mt.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Mt.prototype.getX=function(){return this.normalize(),this.x.fromRed()};var J2=hr,ui=zr.exports,$h=On.exports,Ea=_a,Q2=J2.assert;function kr(t){this.twisted=(t.a|0)!==1,this.mOneA=this.twisted&&(t.a|0)===-1,this.extended=this.mOneA,Ea.call(this,"edwards",t),this.a=new ui(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new ui(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new ui(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),Q2(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(t.c|0)===1}$h(kr,Ea);var X2=kr;kr.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},kr.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},kr.prototype.jpoint=function(e,r,i,n){return this.point(e,r,i,n)},kr.prototype.pointFromX=function(e,r){e=new ui(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()),c=o.redSqrt();if(c.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");var l=c.fromRed().isOdd();return(r&&!l||!r&&l)&&(c=c.redNeg()),this.point(e,c)},kr.prototype.pointFromY=function(e,r){e=new ui(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 c=o.redSqrt();if(c.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");return c.fromRed().isOdd()!==r&&(c=c.redNeg()),this.point(c,e)},kr.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 ct(t,e,r,i,n){Ea.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 ui(e,16),this.y=new ui(r,16),this.z=i?new ui(i,16):this.curve.one,this.t=n&&new ui(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()))))}$h(ct,Ea.BasePoint),kr.prototype.pointFromJSON=function(e){return ct.fromJSON(this,e)},kr.prototype.point=function(e,r,i,n){return new ct(this,e,r,i,n)},ct.fromJSON=function(e,r){return new ct(e,r[0],r[1],r[2])},ct.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)+">"},ct.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},ct.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),c=o.redSub(i),l=n.redSub(r),u=s.redMul(c),b=o.redMul(l),m=s.redMul(l),M=c.redMul(o);return this.curve.point(u,b,M,m)},ct.prototype._projDbl=function(){var e=this.x.redAdd(this.y).redSqr(),r=this.x.redSqr(),i=this.y.redSqr(),n,s,o,c,l,u;if(this.curve.twisted){c=this.curve._mulA(r);var b=c.redAdd(i);this.zOne?(n=e.redSub(r).redSub(i).redMul(b.redSub(this.curve.two)),s=b.redMul(c.redSub(i)),o=b.redSqr().redSub(b).redSub(b)):(l=this.z.redSqr(),u=b.redSub(l).redISub(l),n=e.redSub(r).redISub(i).redMul(u),s=b.redMul(c.redSub(i)),o=b.redMul(u))}else c=r.redAdd(i),l=this.curve._mulC(this.z).redSqr(),u=c.redSub(l).redSub(l),n=this.curve._mulC(e.redISub(c)).redMul(u),s=this.curve._mulC(c).redMul(r.redISub(i)),o=c.redMul(u);return this.curve.point(n,s,o)},ct.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},ct.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),c=s.redSub(n),l=s.redAdd(n),u=i.redAdd(r),b=o.redMul(c),m=l.redMul(u),M=o.redMul(u),S=c.redMul(l);return this.curve.point(b,m,S,M)},ct.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),c=i.redSub(o),l=i.redAdd(o),u=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(n).redISub(s),b=r.redMul(c).redMul(u),m,M;return this.curve.twisted?(m=r.redMul(l).redMul(s.redSub(this.curve._mulA(n))),M=c.redMul(l)):(m=r.redMul(l).redMul(s.redSub(n)),M=this.curve._mulC(c).redMul(l)),this.curve.point(b,m,M)},ct.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},ct.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},ct.prototype.mulAdd=function(e,r,i){return this.curve._wnafMulAdd(1,[this,r],[e,i],2,!1)},ct.prototype.jmulAdd=function(e,r,i){return this.curve._wnafMulAdd(1,[this,r],[e,i],2,!0)},ct.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},ct.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},ct.prototype.getX=function(){return this.normalize(),this.x.fromRed()},ct.prototype.getY=function(){return this.normalize(),this.y.fromRed()},ct.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0},ct.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}},ct.prototype.toP=ct.prototype.normalize,ct.prototype.mixedAdd=ct.prototype.add,function(t){var e=t;e.base=_a,e.short=G2,e.mont=Y2,e.edwards=X2}(Ho);var xa={},Sa={},Xe={},Z2=en,e3=On.exports;Xe.inherits=e3;function t3(t,e){return(t.charCodeAt(e)&64512)!==55296||e<0||e+1>=t.length?!1:(t.charCodeAt(e+1)&64512)===56320}function r3(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):t3(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}Xe.toArray=r3;function i3(t){for(var e="",r=0;r<t.length;r++)e+=Kh(t[r].toString(16));return e}Xe.toHex=i3;function jh(t){var e=t>>>24|t>>>8&65280|t<<8&16711680|(t&255)<<24;return e>>>0}Xe.htonl=jh;function n3(t,e){for(var r="",i=0;i<t.length;i++){var n=t[i];e==="little"&&(n=jh(n)),r+=Hh(n.toString(16))}return r}Xe.toHex32=n3;function Kh(t){return t.length===1?"0"+t:t}Xe.zero2=Kh;function Hh(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}Xe.zero8=Hh;function s3(t,e,r,i){var n=r-e;Z2(n%4===0);for(var s=new Array(n/4),o=0,c=e;o<s.length;o++,c+=4){var l;i==="big"?l=t[c]<<24|t[c+1]<<16|t[c+2]<<8|t[c+3]:l=t[c+3]<<24|t[c+2]<<16|t[c+1]<<8|t[c],s[o]=l>>>0}return s}Xe.join32=s3;function a3(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}Xe.split32=a3;function o3(t,e){return t>>>e|t<<32-e}Xe.rotr32=o3;function c3(t,e){return t<<e|t>>>32-e}Xe.rotl32=c3;function f3(t,e){return t+e>>>0}Xe.sum32=f3;function h3(t,e,r){return t+e+r>>>0}Xe.sum32_3=h3;function u3(t,e,r,i){return t+e+r+i>>>0}Xe.sum32_4=u3;function d3(t,e,r,i,n){return t+e+r+i+n>>>0}Xe.sum32_5=d3;function l3(t,e,r,i){var n=t[e],s=t[e+1],o=i+s>>>0,c=(o<i?1:0)+r+n;t[e]=c>>>0,t[e+1]=o}Xe.sum64=l3;function p3(t,e,r,i){var n=e+i>>>0,s=(n<e?1:0)+t+r;return s>>>0}Xe.sum64_hi=p3;function g3(t,e,r,i){var n=e+i;return n>>>0}Xe.sum64_lo=g3;function b3(t,e,r,i,n,s,o,c){var l=0,u=e;u=u+i>>>0,l+=u<e?1:0,u=u+s>>>0,l+=u<s?1:0,u=u+c>>>0,l+=u<c?1:0;var b=t+r+n+o+l;return b>>>0}Xe.sum64_4_hi=b3;function v3(t,e,r,i,n,s,o,c){var l=e+i+s+c;return l>>>0}Xe.sum64_4_lo=v3;function m3(t,e,r,i,n,s,o,c,l,u){var b=0,m=e;m=m+i>>>0,b+=m<e?1:0,m=m+s>>>0,b+=m<s?1:0,m=m+c>>>0,b+=m<c?1:0,m=m+u>>>0,b+=m<u?1:0;var M=t+r+n+o+l+b;return M>>>0}Xe.sum64_5_hi=m3;function y3(t,e,r,i,n,s,o,c,l,u){var b=e+i+s+c+u;return b>>>0}Xe.sum64_5_lo=y3;function w3(t,e,r){var i=e<<32-r|t>>>r;return i>>>0}Xe.rotr64_hi=w3;function _3(t,e,r){var i=t<<32-r|e>>>r;return i>>>0}Xe.rotr64_lo=_3;function A3(t,e,r){return t>>>r}Xe.shr64_hi=A3;function E3(t,e,r){var i=t<<32-r|e>>>r;return i>>>0}Xe.shr64_lo=E3;var Tn={},Vh=Xe,x3=en;function Ma(){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}Tn.BlockHash=Ma,Ma.prototype.update=function(e,r){if(e=Vh.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=Vh.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},Ma.prototype.digest=function(e){return this.update(this._pad()),x3(this.pending===null),this._digest(e)},Ma.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 Cn={},$r={},S3=Xe,jr=S3.rotr32;function M3(t,e,r,i){if(t===0)return Gh(e,r,i);if(t===1||t===3)return Yh(e,r,i);if(t===2)return Wh(e,r,i)}$r.ft_1=M3;function Gh(t,e,r){return t&e^~t&r}$r.ch32=Gh;function Wh(t,e,r){return t&e^t&r^e&r}$r.maj32=Wh;function Yh(t,e,r){return t^e^r}$r.p32=Yh;function I3(t){return jr(t,2)^jr(t,13)^jr(t,22)}$r.s0_256=I3;function D3(t){return jr(t,6)^jr(t,11)^jr(t,25)}$r.s1_256=D3;function O3(t){return jr(t,7)^jr(t,18)^t>>>3}$r.g0_256=O3;function R3(t){return jr(t,17)^jr(t,19)^t>>>10}$r.g1_256=R3;var Fn=Xe,N3=Tn,P3=$r,Go=Fn.rotl32,bs=Fn.sum32,T3=Fn.sum32_5,C3=P3.ft_1,Jh=N3.BlockHash,F3=[1518500249,1859775393,2400959708,3395469782];function Kr(){if(!(this instanceof Kr))return new Kr;Jh.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Fn.inherits(Kr,Jh);var L3=Kr;Kr.blockSize=512,Kr.outSize=160,Kr.hmacStrength=80,Kr.padLength=64,Kr.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]=Go(i[n-3]^i[n-8]^i[n-14]^i[n-16],1);var s=this.h[0],o=this.h[1],c=this.h[2],l=this.h[3],u=this.h[4];for(n=0;n<i.length;n++){var b=~~(n/20),m=T3(Go(s,5),C3(b,o,c,l),u,i[n],F3[b]);u=l,l=c,c=Go(o,30),o=s,s=m}this.h[0]=bs(this.h[0],s),this.h[1]=bs(this.h[1],o),this.h[2]=bs(this.h[2],c),this.h[3]=bs(this.h[3],l),this.h[4]=bs(this.h[4],u)},Kr.prototype._digest=function(e){return e==="hex"?Fn.toHex32(this.h,"big"):Fn.split32(this.h,"big")};var Ln=Xe,B3=Tn,Bn=$r,q3=en,Dr=Ln.sum32,U3=Ln.sum32_4,z3=Ln.sum32_5,k3=Bn.ch32,$3=Bn.maj32,j3=Bn.s0_256,K3=Bn.s1_256,H3=Bn.g0_256,V3=Bn.g1_256,Qh=B3.BlockHash,G3=[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 Hr(){if(!(this instanceof Hr))return new Hr;Qh.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=G3,this.W=new Array(64)}Ln.inherits(Hr,Qh);var Xh=Hr;Hr.blockSize=512,Hr.outSize=256,Hr.hmacStrength=192,Hr.padLength=64,Hr.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]=U3(V3(i[n-2]),i[n-7],H3(i[n-15]),i[n-16]);var s=this.h[0],o=this.h[1],c=this.h[2],l=this.h[3],u=this.h[4],b=this.h[5],m=this.h[6],M=this.h[7];for(q3(this.k.length===i.length),n=0;n<i.length;n++){var S=z3(M,K3(u),k3(u,b,m),this.k[n],i[n]),I=Dr(j3(s),$3(s,o,c));M=m,m=b,b=u,u=Dr(l,S),l=c,c=o,o=s,s=Dr(S,I)}this.h[0]=Dr(this.h[0],s),this.h[1]=Dr(this.h[1],o),this.h[2]=Dr(this.h[2],c),this.h[3]=Dr(this.h[3],l),this.h[4]=Dr(this.h[4],u),this.h[5]=Dr(this.h[5],b),this.h[6]=Dr(this.h[6],m),this.h[7]=Dr(this.h[7],M)},Hr.prototype._digest=function(e){return e==="hex"?Ln.toHex32(this.h,"big"):Ln.split32(this.h,"big")};var Wo=Xe,Zh=Xh;function di(){if(!(this instanceof di))return new di;Zh.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}Wo.inherits(di,Zh);var W3=di;di.blockSize=512,di.outSize=224,di.hmacStrength=192,di.padLength=64,di.prototype._digest=function(e){return e==="hex"?Wo.toHex32(this.h.slice(0,7),"big"):Wo.split32(this.h.slice(0,7),"big")};var Zt=Xe,Y3=Tn,J3=en,Vr=Zt.rotr64_hi,Gr=Zt.rotr64_lo,eu=Zt.shr64_hi,tu=Zt.shr64_lo,qi=Zt.sum64,Yo=Zt.sum64_hi,Jo=Zt.sum64_lo,Q3=Zt.sum64_4_hi,X3=Zt.sum64_4_lo,Z3=Zt.sum64_5_hi,ev=Zt.sum64_5_lo,ru=Y3.BlockHash,tv=[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 Or(){if(!(this instanceof Or))return new Or;ru.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=tv,this.W=new Array(160)}Zt.inherits(Or,ru);var iu=Or;Or.blockSize=1024,Or.outSize=512,Or.hmacStrength=192,Or.padLength=128,Or.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=dv(i[n-4],i[n-3]),o=lv(i[n-4],i[n-3]),c=i[n-14],l=i[n-13],u=hv(i[n-30],i[n-29]),b=uv(i[n-30],i[n-29]),m=i[n-32],M=i[n-31];i[n]=Q3(s,o,c,l,u,b,m,M),i[n+1]=X3(s,o,c,l,u,b,m,M)}},Or.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],c=this.h[3],l=this.h[4],u=this.h[5],b=this.h[6],m=this.h[7],M=this.h[8],S=this.h[9],I=this.h[10],F=this.h[11],k=this.h[12],j=this.h[13],C=this.h[14],$=this.h[15];J3(this.k.length===i.length);for(var P=0;P<i.length;P+=2){var B=C,U=$,y=cv(M,S),O=fv(M,S),Y=rv(M,S,I,F,k),Q=iv(M,S,I,F,k,j),N=this.k[P],g=this.k[P+1],a=i[P],f=i[P+1],p=Z3(B,U,y,O,Y,Q,N,g,a,f),w=ev(B,U,y,O,Y,Q,N,g,a,f);B=av(n,s),U=ov(n,s),y=nv(n,s,o,c,l),O=sv(n,s,o,c,l,u);var A=Yo(B,U,y,O),x=Jo(B,U,y,O);C=k,$=j,k=I,j=F,I=M,F=S,M=Yo(b,m,p,w),S=Jo(m,m,p,w),b=l,m=u,l=o,u=c,o=n,c=s,n=Yo(p,w,A,x),s=Jo(p,w,A,x)}qi(this.h,0,n,s),qi(this.h,2,o,c),qi(this.h,4,l,u),qi(this.h,6,b,m),qi(this.h,8,M,S),qi(this.h,10,I,F),qi(this.h,12,k,j),qi(this.h,14,C,$)},Or.prototype._digest=function(e){return e==="hex"?Zt.toHex32(this.h,"big"):Zt.split32(this.h,"big")};function rv(t,e,r,i,n){var s=t&r^~t&n;return s<0&&(s+=4294967296),s}function iv(t,e,r,i,n,s){var o=e&i^~e&s;return o<0&&(o+=4294967296),o}function nv(t,e,r,i,n){var s=t&r^t&n^r&n;return s<0&&(s+=4294967296),s}function sv(t,e,r,i,n,s){var o=e&i^e&s^i&s;return o<0&&(o+=4294967296),o}function av(t,e){var r=Vr(t,e,28),i=Vr(e,t,2),n=Vr(e,t,7),s=r^i^n;return s<0&&(s+=4294967296),s}function ov(t,e){var r=Gr(t,e,28),i=Gr(e,t,2),n=Gr(e,t,7),s=r^i^n;return s<0&&(s+=4294967296),s}function cv(t,e){var r=Vr(t,e,14),i=Vr(t,e,18),n=Vr(e,t,9),s=r^i^n;return s<0&&(s+=4294967296),s}function fv(t,e){var r=Gr(t,e,14),i=Gr(t,e,18),n=Gr(e,t,9),s=r^i^n;return s<0&&(s+=4294967296),s}function hv(t,e){var r=Vr(t,e,1),i=Vr(t,e,8),n=eu(t,e,7),s=r^i^n;return s<0&&(s+=4294967296),s}function uv(t,e){var r=Gr(t,e,1),i=Gr(t,e,8),n=tu(t,e,7),s=r^i^n;return s<0&&(s+=4294967296),s}function dv(t,e){var r=Vr(t,e,19),i=Vr(e,t,29),n=eu(t,e,6),s=r^i^n;return s<0&&(s+=4294967296),s}function lv(t,e){var r=Gr(t,e,19),i=Gr(e,t,29),n=tu(t,e,6),s=r^i^n;return s<0&&(s+=4294967296),s}var Qo=Xe,nu=iu;function li(){if(!(this instanceof li))return new li;nu.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Qo.inherits(li,nu);var pv=li;li.blockSize=1024,li.outSize=384,li.hmacStrength=192,li.padLength=128,li.prototype._digest=function(e){return e==="hex"?Qo.toHex32(this.h.slice(0,12),"big"):Qo.split32(this.h.slice(0,12),"big")},Cn.sha1=L3,Cn.sha224=W3,Cn.sha256=Xh,Cn.sha384=pv,Cn.sha512=iu;var su={},rn=Xe,gv=Tn,Ia=rn.rotl32,au=rn.sum32,vs=rn.sum32_3,ou=rn.sum32_4,cu=gv.BlockHash;function Wr(){if(!(this instanceof Wr))return new Wr;cu.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}rn.inherits(Wr,cu),su.ripemd160=Wr,Wr.blockSize=512,Wr.outSize=160,Wr.hmacStrength=192,Wr.padLength=64,Wr.prototype._update=function(e,r){for(var i=this.h[0],n=this.h[1],s=this.h[2],o=this.h[3],c=this.h[4],l=i,u=n,b=s,m=o,M=c,S=0;S<80;S++){var I=au(Ia(ou(i,fu(S,n,s,o),e[mv[S]+r],bv(S)),wv[S]),c);i=c,c=o,o=Ia(s,10),s=n,n=I,I=au(Ia(ou(l,fu(79-S,u,b,m),e[yv[S]+r],vv(S)),_v[S]),M),l=M,M=m,m=Ia(b,10),b=u,u=I}I=vs(this.h[1],s,m),this.h[1]=vs(this.h[2],o,M),this.h[2]=vs(this.h[3],c,l),this.h[3]=vs(this.h[4],i,u),this.h[4]=vs(this.h[0],n,b),this.h[0]=I},Wr.prototype._digest=function(e){return e==="hex"?rn.toHex32(this.h,"little"):rn.split32(this.h,"little")};function fu(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 bv(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function vv(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}var mv=[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],yv=[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],wv=[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],_v=[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],Av=Xe,Ev=en;function qn(t,e,r){if(!(this instanceof qn))return new qn(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(Av.toArray(e,r))}var xv=qn;qn.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),Ev(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)},qn.prototype.update=function(e,r){return this.inner.update(e,r),this},qn.prototype.digest=function(e){return this.outer.update(this.inner.digest()),this.outer.digest(e)},function(t){var e=t;e.utils=Xe,e.common=Tn,e.sha=Cn,e.ripemd=su,e.hmac=xv,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}(Sa);var Xo,hu;function Sv(){return hu||(hu=1,Xo={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"]]}}),Xo}(function(t){var e=t,r=Sa,i=Ho,n=hr,s=n.assert;function o(u){u.type==="short"?this.curve=new i.short(u):u.type==="edwards"?this.curve=new i.edwards(u):this.curve=new i.mont(u),this.g=this.curve.g,this.n=this.curve.n,this.hash=u.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}e.PresetCurve=o;function c(u,b){Object.defineProperty(e,u,{configurable:!0,enumerable:!0,get:function(){var m=new o(b);return Object.defineProperty(e,u,{configurable:!0,enumerable:!0,value:m}),m}})}c("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"]}),c("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"]}),c("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"]}),c("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"]}),c("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"]}),c("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"]}),c("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 l;try{l=Sv()}catch{l=void 0}c("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",l]})})(xa);var Mv=Sa,nn=jo,uu=en;function Ui(t){if(!(this instanceof Ui))return new Ui(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=nn.toArray(t.entropy,t.entropyEnc||"hex"),r=nn.toArray(t.nonce,t.nonceEnc||"hex"),i=nn.toArray(t.pers,t.persEnc||"hex");uu(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,i)}var Iv=Ui;Ui.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},Ui.prototype._hmac=function(){return new Mv.hmac(this.hash,this.K)},Ui.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())},Ui.prototype.reseed=function(e,r,i,n){typeof r!="string"&&(n=i,i=r,r=null),e=nn.toArray(e,r),i=nn.toArray(i,n),uu(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1},Ui.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=nn.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++,nn.encode(o,r)};var Dv=zr.exports,Ov=hr,Zo=Ov.assert;function zt(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 Rv=zt;zt.fromPublic=function(e,r,i){return r instanceof zt?r:new zt(e,{pub:r,pubEnc:i})},zt.fromPrivate=function(e,r,i){return r instanceof zt?r:new zt(e,{priv:r,privEnc:i})},zt.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"}},zt.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},zt.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv},zt.prototype._importPrivate=function(e,r){this.priv=new Dv(e,r||16),this.priv=this.priv.umod(this.ec.curve.n)},zt.prototype._importPublic=function(e,r){if(e.x||e.y){this.ec.curve.type==="mont"?Zo(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&Zo(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)},zt.prototype.derive=function(e){return e.validate()||Zo(e.validate(),"public point not validated"),e.mul(this.priv).getX()},zt.prototype.sign=function(e,r,i){return this.ec.sign(e,this,r,i)},zt.prototype.verify=function(e,r){return this.ec.verify(e,r,this)},zt.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var Da=zr.exports,ec=hr,Nv=ec.assert;function Oa(t,e){if(t instanceof Oa)return t;this._importDER(t,e)||(Nv(t.r&&t.s,"Signature without r or s"),this.r=new Da(t.r,16),this.s=new Da(t.s,16),t.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var Pv=Oa;function Tv(){this.place=0}function tc(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 du(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)}Oa.prototype._importDER=function(e,r){e=ec.toArray(e,r);var i=new Tv;if(e[i.place++]!==48)return!1;var n=tc(e,i);if(n===!1||n+i.place!==e.length||e[i.place++]!==2)return!1;var s=tc(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 c=tc(e,i);if(c===!1||e.length!==c+i.place||e[i.place]&128)return!1;var l=e.slice(i.place,c+i.place);if(o[0]===0)if(o[1]&128)o=o.slice(1);else return!1;if(l[0]===0)if(l[1]&128)l=l.slice(1);else return!1;return this.r=new Da(o),this.s=new Da(l),this.recoveryParam=null,!0};function rc(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)}Oa.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=du(r),i=du(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];rc(n,r.length),n=n.concat(r),n.push(2),rc(n,i.length);var s=n.concat(i),o=[48];return rc(o,s.length),o=o.concat(s),ec.encode(o,e)};var sn=zr.exports,lu=Iv,Cv=hr,ic=xa,Fv=ma.exports,pu=Cv.assert,nc=Rv,Ra=Pv;function vr(t){if(!(this instanceof vr))return new vr(t);typeof t=="string"&&(pu(Object.prototype.hasOwnProperty.call(ic,t),"Unknown curve "+t),t=ic[t]),t instanceof ic.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 Lv=vr;vr.prototype.keyPair=function(e){return new nc(this,e)},vr.prototype.keyFromPrivate=function(e,r){return nc.fromPrivate(this,e,r)},vr.prototype.keyFromPublic=function(e,r){return nc.fromPublic(this,e,r)},vr.prototype.genKeyPair=function(e){e||(e={});for(var r=new lu({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||Fv(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new sn(2));;){var s=new sn(r.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}},vr.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},vr.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 sn(e,16));for(var s=this.n.byteLength(),o=r.getPrivate().toArray("be",s),c=e.toArray("be",s),l=new lu({hash:this.hash,entropy:o,nonce:c,pers:n.pers,persEnc:n.persEnc||"utf8"}),u=this.n.sub(new sn(1)),b=0;;b++){var m=n.k?n.k(b):new sn(l.generate(this.n.byteLength()));if(m=this._truncateToN(m,!0),!(m.cmpn(1)<=0||m.cmp(u)>=0)){var M=this.g.mul(m);if(!M.isInfinity()){var S=M.getX(),I=S.umod(this.n);if(I.cmpn(0)!==0){var F=m.invm(this.n).mul(I.mul(r.getPrivate()).iadd(e));if(F=F.umod(this.n),F.cmpn(0)!==0){var k=(M.getY().isOdd()?1:0)|(S.cmp(I)!==0?2:0);return n.canonical&&F.cmp(this.nh)>0&&(F=this.n.sub(F),k^=1),new Ra({r:I,s:F,recoveryParam:k})}}}}}},vr.prototype.verify=function(e,r,i,n){e=this._truncateToN(new sn(e,16)),i=this.keyFromPublic(i,n),r=new Ra(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 c=o.invm(this.n),l=c.mul(e).umod(this.n),u=c.mul(s).umod(this.n),b;return this.curve._maxwellTrick?(b=this.g.jmulAdd(l,i.getPublic(),u),b.isInfinity()?!1:b.eqXToP(s)):(b=this.g.mulAdd(l,i.getPublic(),u),b.isInfinity()?!1:b.getX().umod(this.n).cmp(s)===0)},vr.prototype.recoverPubKey=function(t,e,r,i){pu((3&r)===r,"The recovery param is more than two bits"),e=new Ra(e,i);var n=this.n,s=new sn(t),o=e.r,c=e.s,l=r&1,u=r>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");u?o=this.curve.pointFromX(o.add(this.curve.n),l):o=this.curve.pointFromX(o,l);var b=e.r.invm(n),m=n.sub(s).mul(b).umod(n),M=c.mul(b).umod(n);return this.g.mulAdd(m,o,M)},vr.prototype.getKeyRecoveryParam=function(t,e,r,i){if(e=new Ra(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 ms=hr,gu=ms.assert,bu=ms.parseBytes,Un=ms.cachedProperty;function It(t,e){this.eddsa=t,this._secret=bu(e.secret),t.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=bu(e.pub)}It.fromPublic=function(e,r){return r instanceof It?r:new It(e,{pub:r})},It.fromSecret=function(e,r){return r instanceof It?r:new It(e,{secret:r})},It.prototype.secret=function(){return this._secret},Un(It,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),Un(It,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),Un(It,"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}),Un(It,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),Un(It,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),Un(It,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),It.prototype.sign=function(e){return gu(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)},It.prototype.verify=function(e,r){return this.eddsa.verify(e,r,this)},It.prototype.getSecret=function(e){return gu(this._secret,"KeyPair is public only"),ms.encode(this.secret(),e)},It.prototype.getPublic=function(e){return ms.encode(this.pubBytes(),e)};var Bv=It,qv=zr.exports,Na=hr,vu=Na.assert,Pa=Na.cachedProperty,Uv=Na.parseBytes;function an(t,e){this.eddsa=t,typeof e!="object"&&(e=Uv(e)),Array.isArray(e)&&(vu(e.length===t.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,t.encodingLength),S:e.slice(t.encodingLength)}),vu(e.R&&e.S,"Signature without R or S"),t.isPoint(e.R)&&(this._R=e.R),e.S instanceof qv&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}Pa(an,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),Pa(an,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),Pa(an,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),Pa(an,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),an.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},an.prototype.toHex=function(){return Na.encode(this.toBytes(),"hex").toUpperCase()};var zv=an,kv=Sa,$v=xa,zn=hr,jv=zn.assert,mu=zn.parseBytes,yu=Bv,wu=zv;function er(t){if(jv(t==="ed25519","only tested with ed25519 so far"),!(this instanceof er))return new er(t);t=$v[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=kv.sha512}var Kv=er;er.prototype.sign=function(e,r){e=mu(e);var i=this.keyFromSecret(r),n=this.hashInt(i.messagePrefix(),e),s=this.g.mul(n),o=this.encodePoint(s),c=this.hashInt(o,i.pubBytes(),e).mul(i.priv()),l=n.add(c).umod(this.curve.n);return this.makeSignature({R:s,S:l,Rencoded:o})},er.prototype.verify=function(e,r,i){if(e=mu(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()),c=r.R().add(n.pub().mul(s));return c.eq(o)},er.prototype.hashInt=function(){for(var e=this.hash(),r=0;r<arguments.length;r++)e.update(arguments[r]);return zn.intFromLE(e.digest()).umod(this.curve.n)},er.prototype.keyFromPublic=function(e){return yu.fromPublic(this,e)},er.prototype.keyFromSecret=function(e){return yu.fromSecret(this,e)},er.prototype.makeSignature=function(e){return e instanceof wu?e:new wu(this,e)},er.prototype.encodePoint=function(e){var r=e.getY().toArray("le",this.encodingLength);return r[this.encodingLength-1]|=e.getX().isOdd()?128:0,r},er.prototype.decodePoint=function(e){e=zn.parseBytes(e);var r=e.length-1,i=e.slice(0,r).concat(e[r]&-129),n=(e[r]&128)!==0,s=zn.intFromLE(i);return this.curve.pointFromY(s,n)},er.prototype.encodeInt=function(e){return e.toArray("le",this.encodingLength)},er.prototype.decodeInt=function(e){return zn.intFromLE(e)},er.prototype.isPoint=function(e){return e instanceof this.pointClass},function(t){var e=t;e.version=j2.version,e.utils=hr,e.rand=ma.exports,e.curve=Ho,e.curves=xa,e.ec=Lv,e.eddsa=Kv}(qh);const Hv={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"}},Vv=":";function sc(t){const[e,r]=t.split(Vv);return{namespace:e,reference:r}}function _u(t,e){return t.includes(":")?[t]:e.chains||[]}var Gv=Object.defineProperty,Au=Object.getOwnPropertySymbols,Wv=Object.prototype.hasOwnProperty,Yv=Object.prototype.propertyIsEnumerable,Eu=(t,e,r)=>e in t?Gv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,xu=(t,e)=>{for(var r in e||(e={}))Wv.call(e,r)&&Eu(t,r,e[r]);if(Au)for(var r of Au(e))Yv.call(e,r)&&Eu(t,r,e[r]);return t};const Jv="ReactNative",ur={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},Qv="js";function Ta(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function kn(){return!ba()&&!!Lo()&&navigator.product===Jv}function ys(){return!Ta()&&!!Lo()&&!!ba()}function ws(){return kn()?ur.reactNative:Ta()?ur.node:ys()?ur.browser:ur.unknown}function Xv(){var t;try{return kn()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(t=global.Application)==null?void 0:t.applicationId:void 0}catch{return}}function Zv(t,e){let r=ds.parse(t);return r=xu(xu({},r),e),t=ds.stringify(r),t}function Su(){return Mh()||{name:"",description:"",url:"",icons:[""]}}function e6(){if(ws()===ur.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=Wb();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=ws();return e===ur.browser?[e,((t=Sh())==null?void 0:t.host)||"unknown"].join(":"):e}function Mu(t,e,r){const i=e6(),n=t6();return[[t,e].join("-"),[Qv,r].join("-"),i,n].join("/")}function r6({protocol:t,version:e,relayUrl:r,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:c}){const l=r.split("?"),u=Mu(t,e,i),b={auth:n,ua:u,projectId:s,useOnCloseEvent:o||void 0,origin:c||void 0},m=Zv(l[1]||"",b);return l[0]+"?"+m}function on(t,e){return t.filter(r=>e.includes(r)).length===t.length}function Iu(t){return Object.fromEntries(t.entries())}function Du(t){return new Map(Object.entries(t))}function cn(t=oe.FIVE_MINUTES,e){const r=oe.toMiliseconds(t||oe.FIVE_MINUTES);let i,n,s;return{resolve:o=>{s&&i&&(clearTimeout(s),i(o))},reject:o=>{s&&n&&(clearTimeout(s),n(o))},done:()=>new Promise((o,c)=>{s=setTimeout(()=>{c(new Error(e))},r),i=o,n=c})}}function $n(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 Ou(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 Ou("topic",t)}function n6(t){return Ou("id",t)}function Ru(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 _t(t,e){return oe.fromMiliseconds((e||Date.now())+oe.toMiliseconds(t))}function zi(t){return Date.now()>=oe.toMiliseconds(t)}function Je(t,e){return`${t}${e?`:${e}`:""}`}function s6(t=[],e=[]){return[...new Set([...t,...e])]}async function a6({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=o6(s,t,e),c=ws();if(c===ur.browser){if(!((i=ba())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}o.startsWith("https://")||o.startsWith("http://")?window.open(o,"_blank","noreferrer noopener"):window.open(o,f6()?"_blank":"_self","noreferrer noopener")}else c===ur.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(n){console.error(n)}}function o6(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}${h6(i,!0)}`}else n=`${n}/wc?${i}`;return n}async function c6(t,e){let r="";try{if(ys()&&(r=localStorage.getItem(e),r))return r;r=await t.getItem(e)}catch(i){console.error(i)}return r}function Nu(t,e){if(!t.includes(e))return null;const r=t.split(/([&,?,=])/),i=r.indexOf(e);return r[i+2]}function Pu(){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 ac(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function f6(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function h6(t,e=!1){const r=Buffer.from(t).toString("base64");return e?r.replace(/[=]/g,""):r}function Tu(t){return Buffer.from(t,"base64").toString("utf-8")}var Cu=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function u6(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 Fu={exports:{}};/**
|
15
15
|
* [js-sha3]{@link https://github.com/emn178/js-sha3}
|
16
16
|
*
|
17
17
|
* @version 0.8.0
|
18
18
|
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
19
19
|
* @copyright Chen, Yi-Cyuan 2015-2018
|
20
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=Tu:s&&(n=self);var c=!n.JS_SHA3_NO_COMMON_JS&&!0&&t.exports,l=!n.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",u="0123456789abcdef".split(""),b=[31,7936,2031616,520093696],m=[4,1024,262144,67108864],M=[1,256,65536,16777216],S=[6,1536,393216,100663296],I=[0,8,16,24],F=[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],k=[224,256,384,512],j=[128,256],C=["hex","buffer","arrayBuffer","array","digest"],$={128:168,256:136};(n.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(E){return Object.prototype.toString.call(E)==="[object Array]"}),l&&(n.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(E){return typeof E=="object"&&E.buffer&&E.buffer.constructor===ArrayBuffer});for(var P=function(E,H,R){return function(L){return new D(E,H,E).update(L)[R]()}},B=function(E,H,R){return function(L,q){return new D(E,H,q).update(L)[R]()}},U=function(E,H,R){return function(L,q,v,T){return f["cshake"+E].update(L,q,v,T)[R]()}},y=function(E,H,R){return function(L,q,v,T){return f["kmac"+E].update(L,q,v,T)[R]()}},O=function(E,H,R,L){for(var q=0;q<C.length;++q){var v=C[q];E[v]=H(R,L,v)}return E},Y=function(E,H){var R=P(E,H,"hex");return R.create=function(){return new D(E,H,E)},R.update=function(L){return R.create().update(L)},O(R,P,E,H)},Q=function(E,H){var R=B(E,H,"hex");return R.create=function(L){return new D(E,H,L)},R.update=function(L,q){return R.create(q).update(L)},O(R,B,E,H)},N=function(E,H){var R=$[E],L=U(E,H,"hex");return L.create=function(q,v,T){return!v&&!T?f["shake"+E].create(q):new D(E,H,q).bytepad([v,T],R)},L.update=function(q,v,T,W){return L.create(v,T,W).update(q)},O(L,U,E,H)},g=function(E,H){var R=$[E],L=y(E,H,"hex");return L.create=function(q,v,T){return new K(E,H,v).bytepad(["KMAC",T],R).bytepad([q],R)},L.update=function(q,v,T,W){return L.create(q,T,W).update(v)},O(L,y,E,H)},a=[{name:"keccak",padding:M,bits:k,createMethod:Y},{name:"sha3",padding:S,bits:k,createMethod:Y},{name:"shake",padding:b,bits:j,createMethod:Q},{name:"cshake",padding:m,bits:j,createMethod:N},{name:"kmac",padding:m,bits:j,createMethod:g}],f={},p=[],w=0;w<a.length;++w)for(var A=a[w],x=A.bits,_=0;_<x.length;++_){var h=A.name+"_"+x[_];if(p.push(h),f[h]=A.createMethod(x[_],A.padding),A.name!=="sha3"){var d=A.name+x[_];p.push(d),f[d]=f[h]}}function D(E,H,R){this.blocks=[],this.s=[],this.padding=H,this.outputBits=R,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(E<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=R>>5,this.extraBytes=(R&31)>>3;for(var L=0;L<50;++L)this.s[L]=0}D.prototype.update=function(E){if(this.finalized)throw new Error(r);var H,R=typeof E;if(R!=="string"){if(R==="object"){if(E===null)throw new Error(e);if(l&&E.constructor===ArrayBuffer)E=new Uint8Array(E);else if(!Array.isArray(E)&&(!l||!ArrayBuffer.isView(E)))throw new Error(e)}else throw new Error(e);H=!0}for(var L=this.blocks,q=this.byteCount,v=E.length,T=this.blockCount,W=0,J=this.s,X,se;W<v;){if(this.reset)for(this.reset=!1,L[0]=this.block,X=1;X<T+1;++X)L[X]=0;if(H)for(X=this.start;W<v&&X<q;++W)L[X>>2]|=E[W]<<I[X++&3];else for(X=this.start;W<v&&X<q;++W)se=E.charCodeAt(W),se<128?L[X>>2]|=se<<I[X++&3]:se<2048?(L[X>>2]|=(192|se>>6)<<I[X++&3],L[X>>2]|=(128|se&63)<<I[X++&3]):se<55296||se>=57344?(L[X>>2]|=(224|se>>12)<<I[X++&3],L[X>>2]|=(128|se>>6&63)<<I[X++&3],L[X>>2]|=(128|se&63)<<I[X++&3]):(se=65536+((se&1023)<<10|E.charCodeAt(++W)&1023),L[X>>2]|=(240|se>>18)<<I[X++&3],L[X>>2]|=(128|se>>12&63)<<I[X++&3],L[X>>2]|=(128|se>>6&63)<<I[X++&3],L[X>>2]|=(128|se&63)<<I[X++&3]);if(this.lastByteIndex=X,X>=q){for(this.start=X-q,this.block=L[T],X=0;X<T;++X)J[X]^=L[X];G(J),this.reset=!0}else this.start=X}return this},D.prototype.encode=function(E,H){var R=E&255,L=1,q=[R];for(E=E>>8,R=E&255;R>0;)q.unshift(R),E=E>>8,R=E&255,++L;return H?q.push(L):q.unshift(L),this.update(q),q.length},D.prototype.encodeString=function(E){var H,R=typeof E;if(R!=="string"){if(R==="object"){if(E===null)throw new Error(e);if(l&&E.constructor===ArrayBuffer)E=new Uint8Array(E);else if(!Array.isArray(E)&&(!l||!ArrayBuffer.isView(E)))throw new Error(e)}else throw new Error(e);H=!0}var L=0,q=E.length;if(H)L=q;else for(var v=0;v<E.length;++v){var T=E.charCodeAt(v);T<128?L+=1:T<2048?L+=2:T<55296||T>=57344?L+=3:(T=65536+((T&1023)<<10|E.charCodeAt(++v)&1023),L+=4)}return L+=this.encode(L*8),this.update(E),L},D.prototype.bytepad=function(E,H){for(var R=this.encode(H),L=0;L<E.length;++L)R+=this.encodeString(E[L]);var q=H-R%H,v=[];return v.length=q,this.update(v),this},D.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var E=this.blocks,H=this.lastByteIndex,R=this.blockCount,L=this.s;if(E[H>>2]|=this.padding[H&3],this.lastByteIndex===this.byteCount)for(E[0]=E[R],H=1;H<R+1;++H)E[H]=0;for(E[R-1]|=2147483648,H=0;H<R;++H)L[H]^=E[H];G(L)}},D.prototype.toString=D.prototype.hex=function(){this.finalize();for(var E=this.blockCount,H=this.s,R=this.outputBlocks,L=this.extraBytes,q=0,v=0,T="",W;v<R;){for(q=0;q<E&&v<R;++q,++v)W=H[q],T+=u[W>>4&15]+u[W&15]+u[W>>12&15]+u[W>>8&15]+u[W>>20&15]+u[W>>16&15]+u[W>>28&15]+u[W>>24&15];v%E===0&&(G(H),q=0)}return L&&(W=H[q],T+=u[W>>4&15]+u[W&15],L>1&&(T+=u[W>>12&15]+u[W>>8&15]),L>2&&(T+=u[W>>20&15]+u[W>>16&15])),T},D.prototype.arrayBuffer=function(){this.finalize();var E=this.blockCount,H=this.s,R=this.outputBlocks,L=this.extraBytes,q=0,v=0,T=this.outputBits>>3,W;L?W=new ArrayBuffer(R+1<<2):W=new ArrayBuffer(T);for(var J=new Uint32Array(W);v<R;){for(q=0;q<E&&v<R;++q,++v)J[v]=H[q];v%E===0&&G(H)}return L&&(J[q]=H[q],W=W.slice(0,T)),W},D.prototype.buffer=D.prototype.arrayBuffer,D.prototype.digest=D.prototype.array=function(){this.finalize();for(var E=this.blockCount,H=this.s,R=this.outputBlocks,L=this.extraBytes,q=0,v=0,T=[],W,J;v<R;){for(q=0;q<E&&v<R;++q,++v)W=v<<2,J=H[q],T[W]=J&255,T[W+1]=J>>8&255,T[W+2]=J>>16&255,T[W+3]=J>>24&255;v%E===0&&G(H)}return L&&(W=v<<2,J=H[q],T[W]=J&255,L>1&&(T[W+1]=J>>8&255),L>2&&(T[W+2]=J>>16&255)),T};function K(E,H,R){D.call(this,E,H,R)}K.prototype=new D,K.prototype.finalize=function(){return this.encode(this.outputBits,!0),D.prototype.finalize.call(this)};var G=function(E){var H,R,L,q,v,T,W,J,X,se,ne,Me,Ce,ue,xe,Ae,re,ve,le,ee,de,fe,te,Ee,he,ae,Se,De,ce,Ie,We,Oe,Qe,He,Re,tt,rt,pe,Pe,Fe,ge,Le,Te,ye,Ue,ze,we,ke,Be,be,Ne,$e,_e,it,nt,qe,Ye,nr,sr,ar,or,cr,wt;for(L=0;L<48;L+=2)q=E[0]^E[10]^E[20]^E[30]^E[40],v=E[1]^E[11]^E[21]^E[31]^E[41],T=E[2]^E[12]^E[22]^E[32]^E[42],W=E[3]^E[13]^E[23]^E[33]^E[43],J=E[4]^E[14]^E[24]^E[34]^E[44],X=E[5]^E[15]^E[25]^E[35]^E[45],se=E[6]^E[16]^E[26]^E[36]^E[46],ne=E[7]^E[17]^E[27]^E[37]^E[47],Me=E[8]^E[18]^E[28]^E[38]^E[48],Ce=E[9]^E[19]^E[29]^E[39]^E[49],H=Me^(T<<1|W>>>31),R=Ce^(W<<1|T>>>31),E[0]^=H,E[1]^=R,E[10]^=H,E[11]^=R,E[20]^=H,E[21]^=R,E[30]^=H,E[31]^=R,E[40]^=H,E[41]^=R,H=q^(J<<1|X>>>31),R=v^(X<<1|J>>>31),E[2]^=H,E[3]^=R,E[12]^=H,E[13]^=R,E[22]^=H,E[23]^=R,E[32]^=H,E[33]^=R,E[42]^=H,E[43]^=R,H=T^(se<<1|ne>>>31),R=W^(ne<<1|se>>>31),E[4]^=H,E[5]^=R,E[14]^=H,E[15]^=R,E[24]^=H,E[25]^=R,E[34]^=H,E[35]^=R,E[44]^=H,E[45]^=R,H=J^(Me<<1|Ce>>>31),R=X^(Ce<<1|Me>>>31),E[6]^=H,E[7]^=R,E[16]^=H,E[17]^=R,E[26]^=H,E[27]^=R,E[36]^=H,E[37]^=R,E[46]^=H,E[47]^=R,H=se^(q<<1|v>>>31),R=ne^(v<<1|q>>>31),E[8]^=H,E[9]^=R,E[18]^=H,E[19]^=R,E[28]^=H,E[29]^=R,E[38]^=H,E[39]^=R,E[48]^=H,E[49]^=R,ue=E[0],xe=E[1],ze=E[11]<<4|E[10]>>>28,we=E[10]<<4|E[11]>>>28,De=E[20]<<3|E[21]>>>29,ce=E[21]<<3|E[20]>>>29,ar=E[31]<<9|E[30]>>>23,or=E[30]<<9|E[31]>>>23,Le=E[40]<<18|E[41]>>>14,Te=E[41]<<18|E[40]>>>14,He=E[2]<<1|E[3]>>>31,Re=E[3]<<1|E[2]>>>31,Ae=E[13]<<12|E[12]>>>20,re=E[12]<<12|E[13]>>>20,ke=E[22]<<10|E[23]>>>22,Be=E[23]<<10|E[22]>>>22,Ie=E[33]<<13|E[32]>>>19,We=E[32]<<13|E[33]>>>19,cr=E[42]<<2|E[43]>>>30,wt=E[43]<<2|E[42]>>>30,it=E[5]<<30|E[4]>>>2,nt=E[4]<<30|E[5]>>>2,tt=E[14]<<6|E[15]>>>26,rt=E[15]<<6|E[14]>>>26,ve=E[25]<<11|E[24]>>>21,le=E[24]<<11|E[25]>>>21,be=E[34]<<15|E[35]>>>17,Ne=E[35]<<15|E[34]>>>17,Oe=E[45]<<29|E[44]>>>3,Qe=E[44]<<29|E[45]>>>3,Ee=E[6]<<28|E[7]>>>4,he=E[7]<<28|E[6]>>>4,qe=E[17]<<23|E[16]>>>9,Ye=E[16]<<23|E[17]>>>9,pe=E[26]<<25|E[27]>>>7,Pe=E[27]<<25|E[26]>>>7,ee=E[36]<<21|E[37]>>>11,de=E[37]<<21|E[36]>>>11,$e=E[47]<<24|E[46]>>>8,_e=E[46]<<24|E[47]>>>8,ye=E[8]<<27|E[9]>>>5,Ue=E[9]<<27|E[8]>>>5,ae=E[18]<<20|E[19]>>>12,Se=E[19]<<20|E[18]>>>12,nr=E[29]<<7|E[28]>>>25,sr=E[28]<<7|E[29]>>>25,Fe=E[38]<<8|E[39]>>>24,ge=E[39]<<8|E[38]>>>24,fe=E[48]<<14|E[49]>>>18,te=E[49]<<14|E[48]>>>18,E[0]=ue^~Ae&ve,E[1]=xe^~re&le,E[10]=Ee^~ae&De,E[11]=he^~Se&ce,E[20]=He^~tt&pe,E[21]=Re^~rt&Pe,E[30]=ye^~ze&ke,E[31]=Ue^~we&Be,E[40]=it^~qe&nr,E[41]=nt^~Ye&sr,E[2]=Ae^~ve&ee,E[3]=re^~le&de,E[12]=ae^~De&Ie,E[13]=Se^~ce&We,E[22]=tt^~pe&Fe,E[23]=rt^~Pe&ge,E[32]=ze^~ke&be,E[33]=we^~Be&Ne,E[42]=qe^~nr&ar,E[43]=Ye^~sr&or,E[4]=ve^~ee&fe,E[5]=le^~de&te,E[14]=De^~Ie&Oe,E[15]=ce^~We&Qe,E[24]=pe^~Fe&Le,E[25]=Pe^~ge&Te,E[34]=ke^~be&$e,E[35]=Be^~Ne&_e,E[44]=nr^~ar&cr,E[45]=sr^~or&wt,E[6]=ee^~fe&ue,E[7]=de^~te&xe,E[16]=Ie^~Oe&Ee,E[17]=We^~Qe&he,E[26]=Fe^~Le&He,E[27]=ge^~Te&Re,E[36]=be^~$e&ye,E[37]=Ne^~_e&Ue,E[46]=ar^~cr&it,E[47]=or^~wt&nt,E[8]=fe^~ue&Ae,E[9]=te^~xe&re,E[18]=Oe^~Ee&ae,E[19]=Qe^~he&Se,E[28]=Le^~He&tt,E[29]=Te^~Re&rt,E[38]=$e^~ye&ze,E[39]=_e^~Ue&we,E[48]=cr^~it&qe,E[49]=wt^~nt&Ye,E[0]^=F[L],E[1]^=F[L+1]};if(c)t.exports=f;else for(w=0;w<p.length;++w)n[p[w]]=f[p[w]]})()})(Cu);var o6=Cu.exports;const c6="logger/5.7.0";let Fu=!1,Lu=!1;const Ca={debug:1,default:2,info:2,warning:3,error:4,off:5};let Bu=Ca.default,oc=null;function f6(){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 qu=f6();var cc;(function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"})(cc||(cc={}));var Rr;(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"})(Rr||(Rr={}));const Uu="0123456789abcdef";class Ve{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,r){const i=e.toLowerCase();Ca[i]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(Bu>Ca[i])&&console.log.apply(console,r)}debug(...e){this._log(Ve.levels.DEBUG,e)}info(...e){this._log(Ve.levels.INFO,e)}warn(...e){this._log(Ve.levels.WARNING,e)}makeError(e,r,i){if(Lu)return this.makeError("censored error",r,{});r||(r=Ve.errors.UNKNOWN_ERROR),i||(i={});const n=[];Object.keys(i).forEach(l=>{const u=i[l];try{if(u instanceof Uint8Array){let b="";for(let m=0;m<u.length;m++)b+=Uu[u[m]>>4],b+=Uu[u[m]&15];n.push(l+"=Uint8Array(0x"+b+")")}else n.push(l+"="+JSON.stringify(u))}catch{n.push(l+"="+JSON.stringify(i[l].toString()))}}),n.push(`code=${r}`),n.push(`version=${this.version}`);const s=e;let o="";switch(r){case Rr.NUMERIC_FAULT:{o="NUMERIC_FAULT";const l=e;switch(l){case"overflow":case"underflow":case"division-by-zero":o+="-"+l;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result";break}break}case Rr.CALL_EXCEPTION:case Rr.INSUFFICIENT_FUNDS:case Rr.MISSING_NEW:case Rr.NONCE_EXPIRED:case Rr.REPLACEMENT_UNDERPRICED:case Rr.TRANSACTION_REPLACED:case Rr.UNPREDICTABLE_GAS_LIMIT:o=r;break}o&&(e+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),n.length&&(e+=" ("+n.join(", ")+")");const c=new Error(e);return c.reason=s,c.code=r,Object.keys(i).forEach(function(l){c[l]=i[l]}),c}throwError(e,r,i){throw this.makeError(e,r,i)}throwArgumentError(e,r,i){return this.throwError(e,Ve.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){qu&&this.throwError("platform missing String.prototype.normalize",Ve.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:qu})}checkSafeUint53(e,r){typeof e=="number"&&(r==null&&(r="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(r,Ve.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(r,Ve.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,Ve.errors.MISSING_ARGUMENT,{count:e,expectedCount:r}),e>r&&this.throwError("too many arguments"+i,Ve.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:r})}checkNew(e,r){(e===Object||e==null)&&this.throwError("missing new",Ve.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",Ve.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",Ve.errors.MISSING_NEW,{name:r.name})}static globalLogger(){return oc||(oc=new Ve(c6)),oc}static setCensorship(e,r){if(!e&&r&&this.globalLogger().throwError("cannot permanently disable censorship",Ve.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),Fu){if(!e)return;this.globalLogger().throwError("error censorship permanent",Ve.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Lu=!!e,Fu=!!r}static setLogLevel(e){const r=Ca[e.toLowerCase()];if(r==null){Ve.globalLogger().warn("invalid log level - "+e);return}Bu=r}static from(e){return new Ve(e)}}Ve.errors=Rr,Ve.levels=cc;const h6="bytes/5.7.0",mt=new Ve(h6);function zu(t){return!!t.toHexString}function $n(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return $n(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function u6(t){return dr(t)&&!(t.length%2)||jn(t)}function ku(t){return typeof t=="number"&&t==t&&t%1===0}function jn(t){if(t==null)return!1;if(t.constructor===Uint8Array)return!0;if(typeof t=="string"||!ku(t.length)||t.length<0)return!1;for(let e=0;e<t.length;e++){const r=t[e];if(!ku(r)||r<0||r>=256)return!1}return!0}function gt(t,e){if(e||(e={}),typeof t=="number"){mt.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),$n(new Uint8Array(r))}if(e.allowMissingPrefix&&typeof t=="string"&&t.substring(0,2)!=="0x"&&(t="0x"+t),zu(t)&&(t=t.toHexString()),dr(t)){let r=t.substring(2);r.length%2&&(e.hexPad==="left"?r="0"+r:e.hexPad==="right"?r+="0":mt.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 $n(new Uint8Array(i))}return jn(t)?$n(new Uint8Array(t)):mt.throwArgumentError("invalid arrayify value","value",t)}function d6(t){const e=t.map(n=>gt(n)),r=e.reduce((n,s)=>n+s.length,0),i=new Uint8Array(r);return e.reduce((n,s)=>(i.set(s,n),n+s.length),0),$n(i)}function l6(t,e){t=gt(t),t.length>e&&mt.throwArgumentError("value out of range","value",arguments[0]);const r=new Uint8Array(e);return r.set(t,e-t.length),$n(r)}function dr(t,e){return!(typeof t!="string"||!t.match(/^0x[0-9A-Fa-f]*$/)||e&&t.length!==2+2*e)}const fc="0123456789abcdef";function Vt(t,e){if(e||(e={}),typeof t=="number"){mt.checkSafeUint53(t,"invalid hexlify value");let r="";for(;t;)r=fc[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),zu(t))return t.toHexString();if(dr(t))return t.length%2&&(e.hexPad==="left"?t="0x0"+t.substring(2):e.hexPad==="right"?t+="0":mt.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(jn(t)){let r="0x";for(let i=0;i<t.length;i++){let n=t[i];r+=fc[(n&240)>>4]+fc[n&15]}return r}return mt.throwArgumentError("invalid hexlify value","value",t)}function p6(t){if(typeof t!="string")t=Vt(t);else if(!dr(t)||t.length%2)return null;return(t.length-2)/2}function $u(t,e,r){return typeof t!="string"?t=Vt(t):(!dr(t)||t.length%2)&&mt.throwArgumentError("invalid hexData","value",t),e=2+2*e,r!=null?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}function Yr(t,e){for(typeof t!="string"?t=Vt(t):dr(t)||mt.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&mt.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}function ju(t){const e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(u6(t)){let r=gt(t);r.length===64?(e.v=27+(r[32]>>7),r[32]&=127,e.r=Vt(r.slice(0,32)),e.s=Vt(r.slice(32,64))):r.length===65?(e.r=Vt(r.slice(0,32)),e.s=Vt(r.slice(32,64)),e.v=r[64]):mt.throwArgumentError("invalid signature string","signature",t),e.v<27&&(e.v===0||e.v===1?e.v+=27:mt.throwArgumentError("signature invalid v byte","signature",t)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(r[32]|=128),e._vs=Vt(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=l6(gt(e._vs),32);e._vs=Vt(n);const s=n[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=s:e.recoveryParam!==s&&mt.throwArgumentError("signature recoveryParam mismatch _vs","signature",t),n[0]&=127;const o=Vt(n);e.s==null?e.s=o:e.s!==o&&mt.throwArgumentError("signature v mismatch _vs","signature",t)}if(e.recoveryParam==null)e.v==null?mt.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&&mt.throwArgumentError("signature recoveryParam mismatch v","signature",t)}e.r==null||!dr(e.r)?mt.throwArgumentError("signature missing or invalid r","signature",t):e.r=Yr(e.r,32),e.s==null||!dr(e.s)?mt.throwArgumentError("signature missing or invalid s","signature",t):e.s=Yr(e.s,32);const r=gt(e.s);r[0]>=128&&mt.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(r[0]|=128);const i=Vt(r);e._vs&&(dr(e._vs)||mt.throwArgumentError("signature invalid _vs","signature",t),e._vs=Yr(e._vs,32)),e._vs==null?e._vs=i:e._vs!==i&&mt.throwArgumentError("signature _vs mismatch v and s","signature",t)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}function hc(t){return"0x"+o6.keccak_256(gt(t))}var Ku={exports:{}},g6={},b6=Object.freeze({__proto__:null,default:g6}),v6=a6(b6);(function(t){(function(e,r){function i(a,f){if(!a)throw new Error(f||"Assertion failed")}function n(a,f){a.super_=f;var p=function(){};p.prototype=f.prototype,a.prototype=new p,a.prototype.constructor=a}function s(a,f,p){if(s.isBN(a))return a;this.negative=0,this.words=null,this.length=0,this.red=null,a!==null&&((f==="le"||f==="be")&&(p=f,f=10),this._init(a||0,f||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=v6.Buffer}catch{}s.isBN=function(a){return a instanceof s?!0:a!==null&&typeof a=="object"&&a.constructor.wordSize===s.wordSize&&Array.isArray(a.words)},s.max=function(a,f){return a.cmp(f)>0?a:f},s.min=function(a,f){return a.cmp(f)<0?a:f},s.prototype._init=function(a,f,p){if(typeof a=="number")return this._initNumber(a,f,p);if(typeof a=="object")return this._initArray(a,f,p);f==="hex"&&(f=16),i(f===(f|0)&&f>=2&&f<=36),a=a.toString().replace(/\s+/g,"");var w=0;a[0]==="-"&&(w++,this.negative=1),w<a.length&&(f===16?this._parseHex(a,w,p):(this._parseBase(a,f,w),p==="le"&&this._initArray(this.toArray(),f,p)))},s.prototype._initNumber=function(a,f,p){a<0&&(this.negative=1,a=-a),a<67108864?(this.words=[a&67108863],this.length=1):a<4503599627370496?(this.words=[a&67108863,a/67108864&67108863],this.length=2):(i(a<9007199254740992),this.words=[a&67108863,a/67108864&67108863,1],this.length=3),p==="le"&&this._initArray(this.toArray(),f,p)},s.prototype._initArray=function(a,f,p){if(i(typeof a.length=="number"),a.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(a.length/3),this.words=new Array(this.length);for(var w=0;w<this.length;w++)this.words[w]=0;var A,x,_=0;if(p==="be")for(w=a.length-1,A=0;w>=0;w-=3)x=a[w]|a[w-1]<<8|a[w-2]<<16,this.words[A]|=x<<_&67108863,this.words[A+1]=x>>>26-_&67108863,_+=24,_>=26&&(_-=26,A++);else if(p==="le")for(w=0,A=0;w<a.length;w+=3)x=a[w]|a[w+1]<<8|a[w+2]<<16,this.words[A]|=x<<_&67108863,this.words[A+1]=x>>>26-_&67108863,_+=24,_>=26&&(_-=26,A++);return this._strip()};function c(a,f){var p=a.charCodeAt(f);if(p>=48&&p<=57)return p-48;if(p>=65&&p<=70)return p-55;if(p>=97&&p<=102)return p-87;i(!1,"Invalid character in "+a)}function l(a,f,p){var w=c(a,p);return p-1>=f&&(w|=c(a,p-1)<<4),w}s.prototype._parseHex=function(a,f,p){this.length=Math.ceil((a.length-f)/6),this.words=new Array(this.length);for(var w=0;w<this.length;w++)this.words[w]=0;var A=0,x=0,_;if(p==="be")for(w=a.length-1;w>=f;w-=2)_=l(a,f,w)<<A,this.words[x]|=_&67108863,A>=18?(A-=18,x+=1,this.words[x]|=_>>>26):A+=8;else{var h=a.length-f;for(w=h%2===0?f+1:f;w<a.length;w+=2)_=l(a,f,w)<<A,this.words[x]|=_&67108863,A>=18?(A-=18,x+=1,this.words[x]|=_>>>26):A+=8}this._strip()};function u(a,f,p,w){for(var A=0,x=0,_=Math.min(a.length,p),h=f;h<_;h++){var d=a.charCodeAt(h)-48;A*=w,d>=49?x=d-49+10:d>=17?x=d-17+10:x=d,i(d>=0&&x<w,"Invalid character"),A+=x}return A}s.prototype._parseBase=function(a,f,p){this.words=[0],this.length=1;for(var w=0,A=1;A<=67108863;A*=f)w++;w--,A=A/f|0;for(var x=a.length-p,_=x%w,h=Math.min(x,x-_)+p,d=0,D=p;D<h;D+=w)d=u(a,D,D+w,f),this.imuln(A),this.words[0]+d<67108864?this.words[0]+=d:this._iaddn(d);if(_!==0){var K=1;for(d=u(a,D,a.length,f),D=0;D<_;D++)K*=f;this.imuln(K),this.words[0]+d<67108864?this.words[0]+=d:this._iaddn(d)}this._strip()},s.prototype.copy=function(a){a.words=new Array(this.length);for(var f=0;f<this.length;f++)a.words[f]=this.words[f];a.length=this.length,a.negative=this.negative,a.red=this.red};function b(a,f){a.words=f.words,a.length=f.length,a.negative=f.negative,a.red=f.red}if(s.prototype._move=function(a){b(a,this)},s.prototype.clone=function(){var a=new s(null);return this.copy(a),a},s.prototype._expand=function(a){for(;this.length<a;)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")]=m}catch{s.prototype.inspect=m}else s.prototype.inspect=m;function m(){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"],S=[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],I=[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(a,f){a=a||10,f=f|0||1;var p;if(a===16||a==="hex"){p="";for(var w=0,A=0,x=0;x<this.length;x++){var _=this.words[x],h=((_<<w|A)&16777215).toString(16);A=_>>>24-w&16777215,w+=2,w>=26&&(w-=26,x--),A!==0||x!==this.length-1?p=M[6-h.length]+h+p:p=h+p}for(A!==0&&(p=A.toString(16)+p);p.length%f!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}if(a===(a|0)&&a>=2&&a<=36){var d=S[a],D=I[a];p="";var K=this.clone();for(K.negative=0;!K.isZero();){var G=K.modrn(D).toString(a);K=K.idivn(D),K.isZero()?p=G+p:p=M[d-G.length]+G+p}for(this.isZero()&&(p="0"+p);p.length%f!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}i(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var a=this.words[0];return this.length===2?a+=this.words[1]*67108864:this.length===3&&this.words[2]===1?a+=4503599627370496+this.words[1]*67108864:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-a:a},s.prototype.toJSON=function(){return this.toString(16,2)},o&&(s.prototype.toBuffer=function(a,f){return this.toArrayLike(o,a,f)}),s.prototype.toArray=function(a,f){return this.toArrayLike(Array,a,f)};var F=function(a,f){return a.allocUnsafe?a.allocUnsafe(f):new a(f)};s.prototype.toArrayLike=function(a,f,p){this._strip();var w=this.byteLength(),A=p||Math.max(1,w);i(w<=A,"byte array longer than desired length"),i(A>0,"Requested array length <= 0");var x=F(a,A),_=f==="le"?"LE":"BE";return this["_toArrayLike"+_](x,w),x},s.prototype._toArrayLikeLE=function(a,f){for(var p=0,w=0,A=0,x=0;A<this.length;A++){var _=this.words[A]<<x|w;a[p++]=_&255,p<a.length&&(a[p++]=_>>8&255),p<a.length&&(a[p++]=_>>16&255),x===6?(p<a.length&&(a[p++]=_>>24&255),w=0,x=0):(w=_>>>24,x+=2)}if(p<a.length)for(a[p++]=w;p<a.length;)a[p++]=0},s.prototype._toArrayLikeBE=function(a,f){for(var p=a.length-1,w=0,A=0,x=0;A<this.length;A++){var _=this.words[A]<<x|w;a[p--]=_&255,p>=0&&(a[p--]=_>>8&255),p>=0&&(a[p--]=_>>16&255),x===6?(p>=0&&(a[p--]=_>>24&255),w=0,x=0):(w=_>>>24,x+=2)}if(p>=0)for(a[p--]=w;p>=0;)a[p--]=0},Math.clz32?s.prototype._countBits=function(a){return 32-Math.clz32(a)}:s.prototype._countBits=function(a){var f=a,p=0;return f>=4096&&(p+=13,f>>>=13),f>=64&&(p+=7,f>>>=7),f>=8&&(p+=4,f>>>=4),f>=2&&(p+=2,f>>>=2),p+f},s.prototype._zeroBits=function(a){if(a===0)return 26;var f=a,p=0;return f&8191||(p+=13,f>>>=13),f&127||(p+=7,f>>>=7),f&15||(p+=4,f>>>=4),f&3||(p+=2,f>>>=2),f&1||p++,p},s.prototype.bitLength=function(){var a=this.words[this.length-1],f=this._countBits(a);return(this.length-1)*26+f};function k(a){for(var f=new Array(a.bitLength()),p=0;p<f.length;p++){var w=p/26|0,A=p%26;f[p]=a.words[w]>>>A&1}return f}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var a=0,f=0;f<this.length;f++){var p=this._zeroBits(this.words[f]);if(a+=p,p!==26)break}return a},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(a){return this.negative!==0?this.abs().inotn(a).iaddn(1):this.clone()},s.prototype.fromTwos=function(a){return this.testn(a-1)?this.notn(a).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(a){for(;this.length<a.length;)this.words[this.length++]=0;for(var f=0;f<a.length;f++)this.words[f]=this.words[f]|a.words[f];return this._strip()},s.prototype.ior=function(a){return i((this.negative|a.negative)===0),this.iuor(a)},s.prototype.or=function(a){return this.length>a.length?this.clone().ior(a):a.clone().ior(this)},s.prototype.uor=function(a){return this.length>a.length?this.clone().iuor(a):a.clone().iuor(this)},s.prototype.iuand=function(a){var f;this.length>a.length?f=a:f=this;for(var p=0;p<f.length;p++)this.words[p]=this.words[p]&a.words[p];return this.length=f.length,this._strip()},s.prototype.iand=function(a){return i((this.negative|a.negative)===0),this.iuand(a)},s.prototype.and=function(a){return this.length>a.length?this.clone().iand(a):a.clone().iand(this)},s.prototype.uand=function(a){return this.length>a.length?this.clone().iuand(a):a.clone().iuand(this)},s.prototype.iuxor=function(a){var f,p;this.length>a.length?(f=this,p=a):(f=a,p=this);for(var w=0;w<p.length;w++)this.words[w]=f.words[w]^p.words[w];if(this!==f)for(;w<f.length;w++)this.words[w]=f.words[w];return this.length=f.length,this._strip()},s.prototype.ixor=function(a){return i((this.negative|a.negative)===0),this.iuxor(a)},s.prototype.xor=function(a){return this.length>a.length?this.clone().ixor(a):a.clone().ixor(this)},s.prototype.uxor=function(a){return this.length>a.length?this.clone().iuxor(a):a.clone().iuxor(this)},s.prototype.inotn=function(a){i(typeof a=="number"&&a>=0);var f=Math.ceil(a/26)|0,p=a%26;this._expand(f),p>0&&f--;for(var w=0;w<f;w++)this.words[w]=~this.words[w]&67108863;return p>0&&(this.words[w]=~this.words[w]&67108863>>26-p),this._strip()},s.prototype.notn=function(a){return this.clone().inotn(a)},s.prototype.setn=function(a,f){i(typeof a=="number"&&a>=0);var p=a/26|0,w=a%26;return this._expand(p+1),f?this.words[p]=this.words[p]|1<<w:this.words[p]=this.words[p]&~(1<<w),this._strip()},s.prototype.iadd=function(a){var f;if(this.negative!==0&&a.negative===0)return this.negative=0,f=this.isub(a),this.negative^=1,this._normSign();if(this.negative===0&&a.negative!==0)return a.negative=0,f=this.isub(a),a.negative=1,f._normSign();var p,w;this.length>a.length?(p=this,w=a):(p=a,w=this);for(var A=0,x=0;x<w.length;x++)f=(p.words[x]|0)+(w.words[x]|0)+A,this.words[x]=f&67108863,A=f>>>26;for(;A!==0&&x<p.length;x++)f=(p.words[x]|0)+A,this.words[x]=f&67108863,A=f>>>26;if(this.length=p.length,A!==0)this.words[this.length]=A,this.length++;else if(p!==this)for(;x<p.length;x++)this.words[x]=p.words[x];return this},s.prototype.add=function(a){var f;return a.negative!==0&&this.negative===0?(a.negative=0,f=this.sub(a),a.negative^=1,f):a.negative===0&&this.negative!==0?(this.negative=0,f=a.sub(this),this.negative=1,f):this.length>a.length?this.clone().iadd(a):a.clone().iadd(this)},s.prototype.isub=function(a){if(a.negative!==0){a.negative=0;var f=this.iadd(a);return a.negative=1,f._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(a),this.negative=1,this._normSign();var p=this.cmp(a);if(p===0)return this.negative=0,this.length=1,this.words[0]=0,this;var w,A;p>0?(w=this,A=a):(w=a,A=this);for(var x=0,_=0;_<A.length;_++)f=(w.words[_]|0)-(A.words[_]|0)+x,x=f>>26,this.words[_]=f&67108863;for(;x!==0&&_<w.length;_++)f=(w.words[_]|0)+x,x=f>>26,this.words[_]=f&67108863;if(x===0&&_<w.length&&w!==this)for(;_<w.length;_++)this.words[_]=w.words[_];return this.length=Math.max(this.length,_),w!==this&&(this.negative=1),this._strip()},s.prototype.sub=function(a){return this.clone().isub(a)};function j(a,f,p){p.negative=f.negative^a.negative;var w=a.length+f.length|0;p.length=w,w=w-1|0;var A=a.words[0]|0,x=f.words[0]|0,_=A*x,h=_&67108863,d=_/67108864|0;p.words[0]=h;for(var D=1;D<w;D++){for(var K=d>>>26,G=d&67108863,E=Math.min(D,f.length-1),H=Math.max(0,D-a.length+1);H<=E;H++){var R=D-H|0;A=a.words[R]|0,x=f.words[H]|0,_=A*x+G,K+=_/67108864|0,G=_&67108863}p.words[D]=G|0,d=K|0}return d!==0?p.words[D]=d|0:p.length--,p._strip()}var C=function(a,f,p){var w=a.words,A=f.words,x=p.words,_=0,h,d,D,K=w[0]|0,G=K&8191,E=K>>>13,H=w[1]|0,R=H&8191,L=H>>>13,q=w[2]|0,v=q&8191,T=q>>>13,W=w[3]|0,J=W&8191,X=W>>>13,se=w[4]|0,ne=se&8191,Me=se>>>13,Ce=w[5]|0,ue=Ce&8191,xe=Ce>>>13,Ae=w[6]|0,re=Ae&8191,ve=Ae>>>13,le=w[7]|0,ee=le&8191,de=le>>>13,fe=w[8]|0,te=fe&8191,Ee=fe>>>13,he=w[9]|0,ae=he&8191,Se=he>>>13,De=A[0]|0,ce=De&8191,Ie=De>>>13,We=A[1]|0,Oe=We&8191,Qe=We>>>13,He=A[2]|0,Re=He&8191,tt=He>>>13,rt=A[3]|0,pe=rt&8191,Pe=rt>>>13,Fe=A[4]|0,ge=Fe&8191,Le=Fe>>>13,Te=A[5]|0,ye=Te&8191,Ue=Te>>>13,ze=A[6]|0,we=ze&8191,ke=ze>>>13,Be=A[7]|0,be=Be&8191,Ne=Be>>>13,$e=A[8]|0,_e=$e&8191,it=$e>>>13,nt=A[9]|0,qe=nt&8191,Ye=nt>>>13;p.negative=a.negative^f.negative,p.length=19,h=Math.imul(G,ce),d=Math.imul(G,Ie),d=d+Math.imul(E,ce)|0,D=Math.imul(E,Ie);var nr=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(nr>>>26)|0,nr&=67108863,h=Math.imul(R,ce),d=Math.imul(R,Ie),d=d+Math.imul(L,ce)|0,D=Math.imul(L,Ie),h=h+Math.imul(G,Oe)|0,d=d+Math.imul(G,Qe)|0,d=d+Math.imul(E,Oe)|0,D=D+Math.imul(E,Qe)|0;var sr=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(sr>>>26)|0,sr&=67108863,h=Math.imul(v,ce),d=Math.imul(v,Ie),d=d+Math.imul(T,ce)|0,D=Math.imul(T,Ie),h=h+Math.imul(R,Oe)|0,d=d+Math.imul(R,Qe)|0,d=d+Math.imul(L,Oe)|0,D=D+Math.imul(L,Qe)|0,h=h+Math.imul(G,Re)|0,d=d+Math.imul(G,tt)|0,d=d+Math.imul(E,Re)|0,D=D+Math.imul(E,tt)|0;var ar=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(ar>>>26)|0,ar&=67108863,h=Math.imul(J,ce),d=Math.imul(J,Ie),d=d+Math.imul(X,ce)|0,D=Math.imul(X,Ie),h=h+Math.imul(v,Oe)|0,d=d+Math.imul(v,Qe)|0,d=d+Math.imul(T,Oe)|0,D=D+Math.imul(T,Qe)|0,h=h+Math.imul(R,Re)|0,d=d+Math.imul(R,tt)|0,d=d+Math.imul(L,Re)|0,D=D+Math.imul(L,tt)|0,h=h+Math.imul(G,pe)|0,d=d+Math.imul(G,Pe)|0,d=d+Math.imul(E,pe)|0,D=D+Math.imul(E,Pe)|0;var or=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(or>>>26)|0,or&=67108863,h=Math.imul(ne,ce),d=Math.imul(ne,Ie),d=d+Math.imul(Me,ce)|0,D=Math.imul(Me,Ie),h=h+Math.imul(J,Oe)|0,d=d+Math.imul(J,Qe)|0,d=d+Math.imul(X,Oe)|0,D=D+Math.imul(X,Qe)|0,h=h+Math.imul(v,Re)|0,d=d+Math.imul(v,tt)|0,d=d+Math.imul(T,Re)|0,D=D+Math.imul(T,tt)|0,h=h+Math.imul(R,pe)|0,d=d+Math.imul(R,Pe)|0,d=d+Math.imul(L,pe)|0,D=D+Math.imul(L,Pe)|0,h=h+Math.imul(G,ge)|0,d=d+Math.imul(G,Le)|0,d=d+Math.imul(E,ge)|0,D=D+Math.imul(E,Le)|0;var cr=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(cr>>>26)|0,cr&=67108863,h=Math.imul(ue,ce),d=Math.imul(ue,Ie),d=d+Math.imul(xe,ce)|0,D=Math.imul(xe,Ie),h=h+Math.imul(ne,Oe)|0,d=d+Math.imul(ne,Qe)|0,d=d+Math.imul(Me,Oe)|0,D=D+Math.imul(Me,Qe)|0,h=h+Math.imul(J,Re)|0,d=d+Math.imul(J,tt)|0,d=d+Math.imul(X,Re)|0,D=D+Math.imul(X,tt)|0,h=h+Math.imul(v,pe)|0,d=d+Math.imul(v,Pe)|0,d=d+Math.imul(T,pe)|0,D=D+Math.imul(T,Pe)|0,h=h+Math.imul(R,ge)|0,d=d+Math.imul(R,Le)|0,d=d+Math.imul(L,ge)|0,D=D+Math.imul(L,Le)|0,h=h+Math.imul(G,ye)|0,d=d+Math.imul(G,Ue)|0,d=d+Math.imul(E,ye)|0,D=D+Math.imul(E,Ue)|0;var wt=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(wt>>>26)|0,wt&=67108863,h=Math.imul(re,ce),d=Math.imul(re,Ie),d=d+Math.imul(ve,ce)|0,D=Math.imul(ve,Ie),h=h+Math.imul(ue,Oe)|0,d=d+Math.imul(ue,Qe)|0,d=d+Math.imul(xe,Oe)|0,D=D+Math.imul(xe,Qe)|0,h=h+Math.imul(ne,Re)|0,d=d+Math.imul(ne,tt)|0,d=d+Math.imul(Me,Re)|0,D=D+Math.imul(Me,tt)|0,h=h+Math.imul(J,pe)|0,d=d+Math.imul(J,Pe)|0,d=d+Math.imul(X,pe)|0,D=D+Math.imul(X,Pe)|0,h=h+Math.imul(v,ge)|0,d=d+Math.imul(v,Le)|0,d=d+Math.imul(T,ge)|0,D=D+Math.imul(T,Le)|0,h=h+Math.imul(R,ye)|0,d=d+Math.imul(R,Ue)|0,d=d+Math.imul(L,ye)|0,D=D+Math.imul(L,Ue)|0,h=h+Math.imul(G,we)|0,d=d+Math.imul(G,ke)|0,d=d+Math.imul(E,we)|0,D=D+Math.imul(E,ke)|0;var Ei=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(Ei>>>26)|0,Ei&=67108863,h=Math.imul(ee,ce),d=Math.imul(ee,Ie),d=d+Math.imul(de,ce)|0,D=Math.imul(de,Ie),h=h+Math.imul(re,Oe)|0,d=d+Math.imul(re,Qe)|0,d=d+Math.imul(ve,Oe)|0,D=D+Math.imul(ve,Qe)|0,h=h+Math.imul(ue,Re)|0,d=d+Math.imul(ue,tt)|0,d=d+Math.imul(xe,Re)|0,D=D+Math.imul(xe,tt)|0,h=h+Math.imul(ne,pe)|0,d=d+Math.imul(ne,Pe)|0,d=d+Math.imul(Me,pe)|0,D=D+Math.imul(Me,Pe)|0,h=h+Math.imul(J,ge)|0,d=d+Math.imul(J,Le)|0,d=d+Math.imul(X,ge)|0,D=D+Math.imul(X,Le)|0,h=h+Math.imul(v,ye)|0,d=d+Math.imul(v,Ue)|0,d=d+Math.imul(T,ye)|0,D=D+Math.imul(T,Ue)|0,h=h+Math.imul(R,we)|0,d=d+Math.imul(R,ke)|0,d=d+Math.imul(L,we)|0,D=D+Math.imul(L,ke)|0,h=h+Math.imul(G,be)|0,d=d+Math.imul(G,Ne)|0,d=d+Math.imul(E,be)|0,D=D+Math.imul(E,Ne)|0;var xi=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(xi>>>26)|0,xi&=67108863,h=Math.imul(te,ce),d=Math.imul(te,Ie),d=d+Math.imul(Ee,ce)|0,D=Math.imul(Ee,Ie),h=h+Math.imul(ee,Oe)|0,d=d+Math.imul(ee,Qe)|0,d=d+Math.imul(de,Oe)|0,D=D+Math.imul(de,Qe)|0,h=h+Math.imul(re,Re)|0,d=d+Math.imul(re,tt)|0,d=d+Math.imul(ve,Re)|0,D=D+Math.imul(ve,tt)|0,h=h+Math.imul(ue,pe)|0,d=d+Math.imul(ue,Pe)|0,d=d+Math.imul(xe,pe)|0,D=D+Math.imul(xe,Pe)|0,h=h+Math.imul(ne,ge)|0,d=d+Math.imul(ne,Le)|0,d=d+Math.imul(Me,ge)|0,D=D+Math.imul(Me,Le)|0,h=h+Math.imul(J,ye)|0,d=d+Math.imul(J,Ue)|0,d=d+Math.imul(X,ye)|0,D=D+Math.imul(X,Ue)|0,h=h+Math.imul(v,we)|0,d=d+Math.imul(v,ke)|0,d=d+Math.imul(T,we)|0,D=D+Math.imul(T,ke)|0,h=h+Math.imul(R,be)|0,d=d+Math.imul(R,Ne)|0,d=d+Math.imul(L,be)|0,D=D+Math.imul(L,Ne)|0,h=h+Math.imul(G,_e)|0,d=d+Math.imul(G,it)|0,d=d+Math.imul(E,_e)|0,D=D+Math.imul(E,it)|0;var Si=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(Si>>>26)|0,Si&=67108863,h=Math.imul(ae,ce),d=Math.imul(ae,Ie),d=d+Math.imul(Se,ce)|0,D=Math.imul(Se,Ie),h=h+Math.imul(te,Oe)|0,d=d+Math.imul(te,Qe)|0,d=d+Math.imul(Ee,Oe)|0,D=D+Math.imul(Ee,Qe)|0,h=h+Math.imul(ee,Re)|0,d=d+Math.imul(ee,tt)|0,d=d+Math.imul(de,Re)|0,D=D+Math.imul(de,tt)|0,h=h+Math.imul(re,pe)|0,d=d+Math.imul(re,Pe)|0,d=d+Math.imul(ve,pe)|0,D=D+Math.imul(ve,Pe)|0,h=h+Math.imul(ue,ge)|0,d=d+Math.imul(ue,Le)|0,d=d+Math.imul(xe,ge)|0,D=D+Math.imul(xe,Le)|0,h=h+Math.imul(ne,ye)|0,d=d+Math.imul(ne,Ue)|0,d=d+Math.imul(Me,ye)|0,D=D+Math.imul(Me,Ue)|0,h=h+Math.imul(J,we)|0,d=d+Math.imul(J,ke)|0,d=d+Math.imul(X,we)|0,D=D+Math.imul(X,ke)|0,h=h+Math.imul(v,be)|0,d=d+Math.imul(v,Ne)|0,d=d+Math.imul(T,be)|0,D=D+Math.imul(T,Ne)|0,h=h+Math.imul(R,_e)|0,d=d+Math.imul(R,it)|0,d=d+Math.imul(L,_e)|0,D=D+Math.imul(L,it)|0,h=h+Math.imul(G,qe)|0,d=d+Math.imul(G,Ye)|0,d=d+Math.imul(E,qe)|0,D=D+Math.imul(E,Ye)|0;var Mi=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(Mi>>>26)|0,Mi&=67108863,h=Math.imul(ae,Oe),d=Math.imul(ae,Qe),d=d+Math.imul(Se,Oe)|0,D=Math.imul(Se,Qe),h=h+Math.imul(te,Re)|0,d=d+Math.imul(te,tt)|0,d=d+Math.imul(Ee,Re)|0,D=D+Math.imul(Ee,tt)|0,h=h+Math.imul(ee,pe)|0,d=d+Math.imul(ee,Pe)|0,d=d+Math.imul(de,pe)|0,D=D+Math.imul(de,Pe)|0,h=h+Math.imul(re,ge)|0,d=d+Math.imul(re,Le)|0,d=d+Math.imul(ve,ge)|0,D=D+Math.imul(ve,Le)|0,h=h+Math.imul(ue,ye)|0,d=d+Math.imul(ue,Ue)|0,d=d+Math.imul(xe,ye)|0,D=D+Math.imul(xe,Ue)|0,h=h+Math.imul(ne,we)|0,d=d+Math.imul(ne,ke)|0,d=d+Math.imul(Me,we)|0,D=D+Math.imul(Me,ke)|0,h=h+Math.imul(J,be)|0,d=d+Math.imul(J,Ne)|0,d=d+Math.imul(X,be)|0,D=D+Math.imul(X,Ne)|0,h=h+Math.imul(v,_e)|0,d=d+Math.imul(v,it)|0,d=d+Math.imul(T,_e)|0,D=D+Math.imul(T,it)|0,h=h+Math.imul(R,qe)|0,d=d+Math.imul(R,Ye)|0,d=d+Math.imul(L,qe)|0,D=D+Math.imul(L,Ye)|0;var Ii=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(Ii>>>26)|0,Ii&=67108863,h=Math.imul(ae,Re),d=Math.imul(ae,tt),d=d+Math.imul(Se,Re)|0,D=Math.imul(Se,tt),h=h+Math.imul(te,pe)|0,d=d+Math.imul(te,Pe)|0,d=d+Math.imul(Ee,pe)|0,D=D+Math.imul(Ee,Pe)|0,h=h+Math.imul(ee,ge)|0,d=d+Math.imul(ee,Le)|0,d=d+Math.imul(de,ge)|0,D=D+Math.imul(de,Le)|0,h=h+Math.imul(re,ye)|0,d=d+Math.imul(re,Ue)|0,d=d+Math.imul(ve,ye)|0,D=D+Math.imul(ve,Ue)|0,h=h+Math.imul(ue,we)|0,d=d+Math.imul(ue,ke)|0,d=d+Math.imul(xe,we)|0,D=D+Math.imul(xe,ke)|0,h=h+Math.imul(ne,be)|0,d=d+Math.imul(ne,Ne)|0,d=d+Math.imul(Me,be)|0,D=D+Math.imul(Me,Ne)|0,h=h+Math.imul(J,_e)|0,d=d+Math.imul(J,it)|0,d=d+Math.imul(X,_e)|0,D=D+Math.imul(X,it)|0,h=h+Math.imul(v,qe)|0,d=d+Math.imul(v,Ye)|0,d=d+Math.imul(T,qe)|0,D=D+Math.imul(T,Ye)|0;var Sr=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(Sr>>>26)|0,Sr&=67108863,h=Math.imul(ae,pe),d=Math.imul(ae,Pe),d=d+Math.imul(Se,pe)|0,D=Math.imul(Se,Pe),h=h+Math.imul(te,ge)|0,d=d+Math.imul(te,Le)|0,d=d+Math.imul(Ee,ge)|0,D=D+Math.imul(Ee,Le)|0,h=h+Math.imul(ee,ye)|0,d=d+Math.imul(ee,Ue)|0,d=d+Math.imul(de,ye)|0,D=D+Math.imul(de,Ue)|0,h=h+Math.imul(re,we)|0,d=d+Math.imul(re,ke)|0,d=d+Math.imul(ve,we)|0,D=D+Math.imul(ve,ke)|0,h=h+Math.imul(ue,be)|0,d=d+Math.imul(ue,Ne)|0,d=d+Math.imul(xe,be)|0,D=D+Math.imul(xe,Ne)|0,h=h+Math.imul(ne,_e)|0,d=d+Math.imul(ne,it)|0,d=d+Math.imul(Me,_e)|0,D=D+Math.imul(Me,it)|0,h=h+Math.imul(J,qe)|0,d=d+Math.imul(J,Ye)|0,d=d+Math.imul(X,qe)|0,D=D+Math.imul(X,Ye)|0;var Di=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(Di>>>26)|0,Di&=67108863,h=Math.imul(ae,ge),d=Math.imul(ae,Le),d=d+Math.imul(Se,ge)|0,D=Math.imul(Se,Le),h=h+Math.imul(te,ye)|0,d=d+Math.imul(te,Ue)|0,d=d+Math.imul(Ee,ye)|0,D=D+Math.imul(Ee,Ue)|0,h=h+Math.imul(ee,we)|0,d=d+Math.imul(ee,ke)|0,d=d+Math.imul(de,we)|0,D=D+Math.imul(de,ke)|0,h=h+Math.imul(re,be)|0,d=d+Math.imul(re,Ne)|0,d=d+Math.imul(ve,be)|0,D=D+Math.imul(ve,Ne)|0,h=h+Math.imul(ue,_e)|0,d=d+Math.imul(ue,it)|0,d=d+Math.imul(xe,_e)|0,D=D+Math.imul(xe,it)|0,h=h+Math.imul(ne,qe)|0,d=d+Math.imul(ne,Ye)|0,d=d+Math.imul(Me,qe)|0,D=D+Math.imul(Me,Ye)|0;var Oi=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(Oi>>>26)|0,Oi&=67108863,h=Math.imul(ae,ye),d=Math.imul(ae,Ue),d=d+Math.imul(Se,ye)|0,D=Math.imul(Se,Ue),h=h+Math.imul(te,we)|0,d=d+Math.imul(te,ke)|0,d=d+Math.imul(Ee,we)|0,D=D+Math.imul(Ee,ke)|0,h=h+Math.imul(ee,be)|0,d=d+Math.imul(ee,Ne)|0,d=d+Math.imul(de,be)|0,D=D+Math.imul(de,Ne)|0,h=h+Math.imul(re,_e)|0,d=d+Math.imul(re,it)|0,d=d+Math.imul(ve,_e)|0,D=D+Math.imul(ve,it)|0,h=h+Math.imul(ue,qe)|0,d=d+Math.imul(ue,Ye)|0,d=d+Math.imul(xe,qe)|0,D=D+Math.imul(xe,Ye)|0;var $t=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+($t>>>26)|0,$t&=67108863,h=Math.imul(ae,we),d=Math.imul(ae,ke),d=d+Math.imul(Se,we)|0,D=Math.imul(Se,ke),h=h+Math.imul(te,be)|0,d=d+Math.imul(te,Ne)|0,d=d+Math.imul(Ee,be)|0,D=D+Math.imul(Ee,Ne)|0,h=h+Math.imul(ee,_e)|0,d=d+Math.imul(ee,it)|0,d=d+Math.imul(de,_e)|0,D=D+Math.imul(de,it)|0,h=h+Math.imul(re,qe)|0,d=d+Math.imul(re,Ye)|0,d=d+Math.imul(ve,qe)|0,D=D+Math.imul(ve,Ye)|0;var Ri=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(Ri>>>26)|0,Ri&=67108863,h=Math.imul(ae,be),d=Math.imul(ae,Ne),d=d+Math.imul(Se,be)|0,D=Math.imul(Se,Ne),h=h+Math.imul(te,_e)|0,d=d+Math.imul(te,it)|0,d=d+Math.imul(Ee,_e)|0,D=D+Math.imul(Ee,it)|0,h=h+Math.imul(ee,qe)|0,d=d+Math.imul(ee,Ye)|0,d=d+Math.imul(de,qe)|0,D=D+Math.imul(de,Ye)|0;var Ni=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(Ni>>>26)|0,Ni&=67108863,h=Math.imul(ae,_e),d=Math.imul(ae,it),d=d+Math.imul(Se,_e)|0,D=Math.imul(Se,it),h=h+Math.imul(te,qe)|0,d=d+Math.imul(te,Ye)|0,d=d+Math.imul(Ee,qe)|0,D=D+Math.imul(Ee,Ye)|0;var Pi=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(Pi>>>26)|0,Pi&=67108863,h=Math.imul(ae,qe),d=Math.imul(ae,Ye),d=d+Math.imul(Se,qe)|0,D=Math.imul(Se,Ye);var Vs=(_+h|0)+((d&8191)<<13)|0;return _=(D+(d>>>13)|0)+(Vs>>>26)|0,Vs&=67108863,x[0]=nr,x[1]=sr,x[2]=ar,x[3]=or,x[4]=cr,x[5]=wt,x[6]=Ei,x[7]=xi,x[8]=Si,x[9]=Mi,x[10]=Ii,x[11]=Sr,x[12]=Di,x[13]=Oi,x[14]=$t,x[15]=Ri,x[16]=Ni,x[17]=Pi,x[18]=Vs,_!==0&&(x[19]=_,p.length++),p};Math.imul||(C=j);function $(a,f,p){p.negative=f.negative^a.negative,p.length=a.length+f.length;for(var w=0,A=0,x=0;x<p.length-1;x++){var _=A;A=0;for(var h=w&67108863,d=Math.min(x,f.length-1),D=Math.max(0,x-a.length+1);D<=d;D++){var K=x-D,G=a.words[K]|0,E=f.words[D]|0,H=G*E,R=H&67108863;_=_+(H/67108864|0)|0,R=R+h|0,h=R&67108863,_=_+(R>>>26)|0,A+=_>>>26,_&=67108863}p.words[x]=h,w=_,_=A}return w!==0?p.words[x]=w:p.length--,p._strip()}function P(a,f,p){return $(a,f,p)}s.prototype.mulTo=function(a,f){var p,w=this.length+a.length;return this.length===10&&a.length===10?p=C(this,a,f):w<63?p=j(this,a,f):w<1024?p=$(this,a,f):p=P(this,a,f),p},s.prototype.mul=function(a){var f=new s(null);return f.words=new Array(this.length+a.length),this.mulTo(a,f)},s.prototype.mulf=function(a){var f=new s(null);return f.words=new Array(this.length+a.length),P(this,a,f)},s.prototype.imul=function(a){return this.clone().mulTo(a,this)},s.prototype.imuln=function(a){var f=a<0;f&&(a=-a),i(typeof a=="number"),i(a<67108864);for(var p=0,w=0;w<this.length;w++){var A=(this.words[w]|0)*a,x=(A&67108863)+(p&67108863);p>>=26,p+=A/67108864|0,p+=x>>>26,this.words[w]=x&67108863}return p!==0&&(this.words[w]=p,this.length++),f?this.ineg():this},s.prototype.muln=function(a){return this.clone().imuln(a)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(a){var f=k(a);if(f.length===0)return new s(1);for(var p=this,w=0;w<f.length&&f[w]===0;w++,p=p.sqr());if(++w<f.length)for(var A=p.sqr();w<f.length;w++,A=A.sqr())f[w]!==0&&(p=p.mul(A));return p},s.prototype.iushln=function(a){i(typeof a=="number"&&a>=0);var f=a%26,p=(a-f)/26,w=67108863>>>26-f<<26-f,A;if(f!==0){var x=0;for(A=0;A<this.length;A++){var _=this.words[A]&w,h=(this.words[A]|0)-_<<f;this.words[A]=h|x,x=_>>>26-f}x&&(this.words[A]=x,this.length++)}if(p!==0){for(A=this.length-1;A>=0;A--)this.words[A+p]=this.words[A];for(A=0;A<p;A++)this.words[A]=0;this.length+=p}return this._strip()},s.prototype.ishln=function(a){return i(this.negative===0),this.iushln(a)},s.prototype.iushrn=function(a,f,p){i(typeof a=="number"&&a>=0);var w;f?w=(f-f%26)/26:w=0;var A=a%26,x=Math.min((a-A)/26,this.length),_=67108863^67108863>>>A<<A,h=p;if(w-=x,w=Math.max(0,w),h){for(var d=0;d<x;d++)h.words[d]=this.words[d];h.length=x}if(x!==0)if(this.length>x)for(this.length-=x,d=0;d<this.length;d++)this.words[d]=this.words[d+x];else this.words[0]=0,this.length=1;var D=0;for(d=this.length-1;d>=0&&(D!==0||d>=w);d--){var K=this.words[d]|0;this.words[d]=D<<26-A|K>>>A,D=K&_}return h&&D!==0&&(h.words[h.length++]=D),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(a,f,p){return i(this.negative===0),this.iushrn(a,f,p)},s.prototype.shln=function(a){return this.clone().ishln(a)},s.prototype.ushln=function(a){return this.clone().iushln(a)},s.prototype.shrn=function(a){return this.clone().ishrn(a)},s.prototype.ushrn=function(a){return this.clone().iushrn(a)},s.prototype.testn=function(a){i(typeof a=="number"&&a>=0);var f=a%26,p=(a-f)/26,w=1<<f;if(this.length<=p)return!1;var A=this.words[p];return!!(A&w)},s.prototype.imaskn=function(a){i(typeof a=="number"&&a>=0);var f=a%26,p=(a-f)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=p)return this;if(f!==0&&p++,this.length=Math.min(p,this.length),f!==0){var w=67108863^67108863>>>f<<f;this.words[this.length-1]&=w}return this._strip()},s.prototype.maskn=function(a){return this.clone().imaskn(a)},s.prototype.iaddn=function(a){return i(typeof a=="number"),i(a<67108864),a<0?this.isubn(-a):this.negative!==0?this.length===1&&(this.words[0]|0)<=a?(this.words[0]=a-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(a),this.negative=1,this):this._iaddn(a)},s.prototype._iaddn=function(a){this.words[0]+=a;for(var f=0;f<this.length&&this.words[f]>=67108864;f++)this.words[f]-=67108864,f===this.length-1?this.words[f+1]=1:this.words[f+1]++;return this.length=Math.max(this.length,f+1),this},s.prototype.isubn=function(a){if(i(typeof a=="number"),i(a<67108864),a<0)return this.iaddn(-a);if(this.negative!==0)return this.negative=0,this.iaddn(a),this.negative=1,this;if(this.words[0]-=a,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var f=0;f<this.length&&this.words[f]<0;f++)this.words[f]+=67108864,this.words[f+1]-=1;return this._strip()},s.prototype.addn=function(a){return this.clone().iaddn(a)},s.prototype.subn=function(a){return this.clone().isubn(a)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(a,f,p){var w=a.length+p,A;this._expand(w);var x,_=0;for(A=0;A<a.length;A++){x=(this.words[A+p]|0)+_;var h=(a.words[A]|0)*f;x-=h&67108863,_=(x>>26)-(h/67108864|0),this.words[A+p]=x&67108863}for(;A<this.length-p;A++)x=(this.words[A+p]|0)+_,_=x>>26,this.words[A+p]=x&67108863;if(_===0)return this._strip();for(i(_===-1),_=0,A=0;A<this.length;A++)x=-(this.words[A]|0)+_,_=x>>26,this.words[A]=x&67108863;return this.negative=1,this._strip()},s.prototype._wordDiv=function(a,f){var p=this.length-a.length,w=this.clone(),A=a,x=A.words[A.length-1]|0,_=this._countBits(x);p=26-_,p!==0&&(A=A.ushln(p),w.iushln(p),x=A.words[A.length-1]|0);var h=w.length-A.length,d;if(f!=="mod"){d=new s(null),d.length=h+1,d.words=new Array(d.length);for(var D=0;D<d.length;D++)d.words[D]=0}var K=w.clone()._ishlnsubmul(A,1,h);K.negative===0&&(w=K,d&&(d.words[h]=1));for(var G=h-1;G>=0;G--){var E=(w.words[A.length+G]|0)*67108864+(w.words[A.length+G-1]|0);for(E=Math.min(E/x|0,67108863),w._ishlnsubmul(A,E,G);w.negative!==0;)E--,w.negative=0,w._ishlnsubmul(A,1,G),w.isZero()||(w.negative^=1);d&&(d.words[G]=E)}return d&&d._strip(),w._strip(),f!=="div"&&p!==0&&w.iushrn(p),{div:d||null,mod:w}},s.prototype.divmod=function(a,f,p){if(i(!a.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var w,A,x;return this.negative!==0&&a.negative===0?(x=this.neg().divmod(a,f),f!=="mod"&&(w=x.div.neg()),f!=="div"&&(A=x.mod.neg(),p&&A.negative!==0&&A.iadd(a)),{div:w,mod:A}):this.negative===0&&a.negative!==0?(x=this.divmod(a.neg(),f),f!=="mod"&&(w=x.div.neg()),{div:w,mod:x.mod}):this.negative&a.negative?(x=this.neg().divmod(a.neg(),f),f!=="div"&&(A=x.mod.neg(),p&&A.negative!==0&&A.isub(a)),{div:x.div,mod:A}):a.length>this.length||this.cmp(a)<0?{div:new s(0),mod:this}:a.length===1?f==="div"?{div:this.divn(a.words[0]),mod:null}:f==="mod"?{div:null,mod:new s(this.modrn(a.words[0]))}:{div:this.divn(a.words[0]),mod:new s(this.modrn(a.words[0]))}:this._wordDiv(a,f)},s.prototype.div=function(a){return this.divmod(a,"div",!1).div},s.prototype.mod=function(a){return this.divmod(a,"mod",!1).mod},s.prototype.umod=function(a){return this.divmod(a,"mod",!0).mod},s.prototype.divRound=function(a){var f=this.divmod(a);if(f.mod.isZero())return f.div;var p=f.div.negative!==0?f.mod.isub(a):f.mod,w=a.ushrn(1),A=a.andln(1),x=p.cmp(w);return x<0||A===1&&x===0?f.div:f.div.negative!==0?f.div.isubn(1):f.div.iaddn(1)},s.prototype.modrn=function(a){var f=a<0;f&&(a=-a),i(a<=67108863);for(var p=(1<<26)%a,w=0,A=this.length-1;A>=0;A--)w=(p*w+(this.words[A]|0))%a;return f?-w:w},s.prototype.modn=function(a){return this.modrn(a)},s.prototype.idivn=function(a){var f=a<0;f&&(a=-a),i(a<=67108863);for(var p=0,w=this.length-1;w>=0;w--){var A=(this.words[w]|0)+p*67108864;this.words[w]=A/a|0,p=A%a}return this._strip(),f?this.ineg():this},s.prototype.divn=function(a){return this.clone().idivn(a)},s.prototype.egcd=function(a){i(a.negative===0),i(!a.isZero());var f=this,p=a.clone();f.negative!==0?f=f.umod(a):f=f.clone();for(var w=new s(1),A=new s(0),x=new s(0),_=new s(1),h=0;f.isEven()&&p.isEven();)f.iushrn(1),p.iushrn(1),++h;for(var d=p.clone(),D=f.clone();!f.isZero();){for(var K=0,G=1;!(f.words[0]&G)&&K<26;++K,G<<=1);if(K>0)for(f.iushrn(K);K-- >0;)(w.isOdd()||A.isOdd())&&(w.iadd(d),A.isub(D)),w.iushrn(1),A.iushrn(1);for(var E=0,H=1;!(p.words[0]&H)&&E<26;++E,H<<=1);if(E>0)for(p.iushrn(E);E-- >0;)(x.isOdd()||_.isOdd())&&(x.iadd(d),_.isub(D)),x.iushrn(1),_.iushrn(1);f.cmp(p)>=0?(f.isub(p),w.isub(x),A.isub(_)):(p.isub(f),x.isub(w),_.isub(A))}return{a:x,b:_,gcd:p.iushln(h)}},s.prototype._invmp=function(a){i(a.negative===0),i(!a.isZero());var f=this,p=a.clone();f.negative!==0?f=f.umod(a):f=f.clone();for(var w=new s(1),A=new s(0),x=p.clone();f.cmpn(1)>0&&p.cmpn(1)>0;){for(var _=0,h=1;!(f.words[0]&h)&&_<26;++_,h<<=1);if(_>0)for(f.iushrn(_);_-- >0;)w.isOdd()&&w.iadd(x),w.iushrn(1);for(var d=0,D=1;!(p.words[0]&D)&&d<26;++d,D<<=1);if(d>0)for(p.iushrn(d);d-- >0;)A.isOdd()&&A.iadd(x),A.iushrn(1);f.cmp(p)>=0?(f.isub(p),w.isub(A)):(p.isub(f),A.isub(w))}var K;return f.cmpn(1)===0?K=w:K=A,K.cmpn(0)<0&&K.iadd(a),K},s.prototype.gcd=function(a){if(this.isZero())return a.abs();if(a.isZero())return this.abs();var f=this.clone(),p=a.clone();f.negative=0,p.negative=0;for(var w=0;f.isEven()&&p.isEven();w++)f.iushrn(1),p.iushrn(1);do{for(;f.isEven();)f.iushrn(1);for(;p.isEven();)p.iushrn(1);var A=f.cmp(p);if(A<0){var x=f;f=p,p=x}else if(A===0||p.cmpn(1)===0)break;f.isub(p)}while(!0);return p.iushln(w)},s.prototype.invm=function(a){return this.egcd(a).a.umod(a)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(a){return this.words[0]&a},s.prototype.bincn=function(a){i(typeof a=="number");var f=a%26,p=(a-f)/26,w=1<<f;if(this.length<=p)return this._expand(p+1),this.words[p]|=w,this;for(var A=w,x=p;A!==0&&x<this.length;x++){var _=this.words[x]|0;_+=A,A=_>>>26,_&=67108863,this.words[x]=_}return A!==0&&(this.words[x]=A,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(a){var f=a<0;if(this.negative!==0&&!f)return-1;if(this.negative===0&&f)return 1;this._strip();var p;if(this.length>1)p=1;else{f&&(a=-a),i(a<=67108863,"Number is too big");var w=this.words[0]|0;p=w===a?0:w<a?-1:1}return this.negative!==0?-p|0:p},s.prototype.cmp=function(a){if(this.negative!==0&&a.negative===0)return-1;if(this.negative===0&&a.negative!==0)return 1;var f=this.ucmp(a);return this.negative!==0?-f|0:f},s.prototype.ucmp=function(a){if(this.length>a.length)return 1;if(this.length<a.length)return-1;for(var f=0,p=this.length-1;p>=0;p--){var w=this.words[p]|0,A=a.words[p]|0;if(w!==A){w<A?f=-1:w>A&&(f=1);break}}return f},s.prototype.gtn=function(a){return this.cmpn(a)===1},s.prototype.gt=function(a){return this.cmp(a)===1},s.prototype.gten=function(a){return this.cmpn(a)>=0},s.prototype.gte=function(a){return this.cmp(a)>=0},s.prototype.ltn=function(a){return this.cmpn(a)===-1},s.prototype.lt=function(a){return this.cmp(a)===-1},s.prototype.lten=function(a){return this.cmpn(a)<=0},s.prototype.lte=function(a){return this.cmp(a)<=0},s.prototype.eqn=function(a){return this.cmpn(a)===0},s.prototype.eq=function(a){return this.cmp(a)===0},s.red=function(a){return new N(a)},s.prototype.toRed=function(a){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),a.convertTo(this)._forceRed(a)},s.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(a){return this.red=a,this},s.prototype.forceRed=function(a){return i(!this.red,"Already a number in reduction context"),this._forceRed(a)},s.prototype.redAdd=function(a){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,a)},s.prototype.redIAdd=function(a){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,a)},s.prototype.redSub=function(a){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,a)},s.prototype.redISub=function(a){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,a)},s.prototype.redShl=function(a){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,a)},s.prototype.redMul=function(a){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.mul(this,a)},s.prototype.redIMul=function(a){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.imul(this,a)},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(a){return i(this.red&&!a.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,a)};var B={k256:null,p224:null,p192:null,p25519:null};function U(a,f){this.name=a,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()}U.prototype._tmp=function(){var a=new s(null);return a.words=new Array(Math.ceil(this.n/13)),a},U.prototype.ireduce=function(a){var f=a,p;do this.split(f,this.tmp),f=this.imulK(f),f=f.iadd(this.tmp),p=f.bitLength();while(p>this.n);var w=p<this.n?-1:f.ucmp(this.p);return w===0?(f.words[0]=0,f.length=1):w>0?f.isub(this.p):f.strip!==void 0?f.strip():f._strip(),f},U.prototype.split=function(a,f){a.iushrn(this.n,0,f)},U.prototype.imulK=function(a){return a.imul(this.k)};function y(){U.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(y,U),y.prototype.split=function(a,f){for(var p=4194303,w=Math.min(a.length,9),A=0;A<w;A++)f.words[A]=a.words[A];if(f.length=w,a.length<=9){a.words[0]=0,a.length=1;return}var x=a.words[9];for(f.words[f.length++]=x&p,A=10;A<a.length;A++){var _=a.words[A]|0;a.words[A-10]=(_&p)<<4|x>>>22,x=_}x>>>=22,a.words[A-10]=x,x===0&&a.length>10?a.length-=10:a.length-=9},y.prototype.imulK=function(a){a.words[a.length]=0,a.words[a.length+1]=0,a.length+=2;for(var f=0,p=0;p<a.length;p++){var w=a.words[p]|0;f+=w*977,a.words[p]=f&67108863,f=w*64+(f/67108864|0)}return a.words[a.length-1]===0&&(a.length--,a.words[a.length-1]===0&&a.length--),a};function O(){U.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(O,U);function Y(){U.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(Y,U);function Q(){U.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(Q,U),Q.prototype.imulK=function(a){for(var f=0,p=0;p<a.length;p++){var w=(a.words[p]|0)*19+f,A=w&67108863;w>>>=26,a.words[p]=A,f=w}return f!==0&&(a.words[a.length++]=f),a},s._prime=function(a){if(B[a])return B[a];var f;if(a==="k256")f=new y;else if(a==="p224")f=new O;else if(a==="p192")f=new Y;else if(a==="p25519")f=new Q;else throw new Error("Unknown prime "+a);return B[a]=f,f};function N(a){if(typeof a=="string"){var f=s._prime(a);this.m=f.p,this.prime=f}else i(a.gtn(1),"modulus must be greater than 1"),this.m=a,this.prime=null}N.prototype._verify1=function(a){i(a.negative===0,"red works only with positives"),i(a.red,"red works only with red numbers")},N.prototype._verify2=function(a,f){i((a.negative|f.negative)===0,"red works only with positives"),i(a.red&&a.red===f.red,"red works only with red numbers")},N.prototype.imod=function(a){return this.prime?this.prime.ireduce(a)._forceRed(this):(b(a,a.umod(this.m)._forceRed(this)),a)},N.prototype.neg=function(a){return a.isZero()?a.clone():this.m.sub(a)._forceRed(this)},N.prototype.add=function(a,f){this._verify2(a,f);var p=a.add(f);return p.cmp(this.m)>=0&&p.isub(this.m),p._forceRed(this)},N.prototype.iadd=function(a,f){this._verify2(a,f);var p=a.iadd(f);return p.cmp(this.m)>=0&&p.isub(this.m),p},N.prototype.sub=function(a,f){this._verify2(a,f);var p=a.sub(f);return p.cmpn(0)<0&&p.iadd(this.m),p._forceRed(this)},N.prototype.isub=function(a,f){this._verify2(a,f);var p=a.isub(f);return p.cmpn(0)<0&&p.iadd(this.m),p},N.prototype.shl=function(a,f){return this._verify1(a),this.imod(a.ushln(f))},N.prototype.imul=function(a,f){return this._verify2(a,f),this.imod(a.imul(f))},N.prototype.mul=function(a,f){return this._verify2(a,f),this.imod(a.mul(f))},N.prototype.isqr=function(a){return this.imul(a,a.clone())},N.prototype.sqr=function(a){return this.mul(a,a)},N.prototype.sqrt=function(a){if(a.isZero())return a.clone();var f=this.m.andln(3);if(i(f%2===1),f===3){var p=this.m.add(new s(1)).iushrn(2);return this.pow(a,p)}for(var w=this.m.subn(1),A=0;!w.isZero()&&w.andln(1)===0;)A++,w.iushrn(1);i(!w.isZero());var x=new s(1).toRed(this),_=x.redNeg(),h=this.m.subn(1).iushrn(1),d=this.m.bitLength();for(d=new s(2*d*d).toRed(this);this.pow(d,h).cmp(_)!==0;)d.redIAdd(_);for(var D=this.pow(d,w),K=this.pow(a,w.addn(1).iushrn(1)),G=this.pow(a,w),E=A;G.cmp(x)!==0;){for(var H=G,R=0;H.cmp(x)!==0;R++)H=H.redSqr();i(R<E);var L=this.pow(D,new s(1).iushln(E-R-1));K=K.redMul(L),D=L.redSqr(),G=G.redMul(D),E=R}return K},N.prototype.invm=function(a){var f=a._invmp(this.m);return f.negative!==0?(f.negative=0,this.imod(f).redNeg()):this.imod(f)},N.prototype.pow=function(a,f){if(f.isZero())return new s(1).toRed(this);if(f.cmpn(1)===0)return a.clone();var p=4,w=new Array(1<<p);w[0]=new s(1).toRed(this),w[1]=a;for(var A=2;A<w.length;A++)w[A]=this.mul(w[A-1],a);var x=w[0],_=0,h=0,d=f.bitLength()%26;for(d===0&&(d=26),A=f.length-1;A>=0;A--){for(var D=f.words[A],K=d-1;K>=0;K--){var G=D>>K&1;if(x!==w[0]&&(x=this.sqr(x)),G===0&&_===0){h=0;continue}_<<=1,_|=G,h++,!(h!==p&&(A!==0||K!==0))&&(x=this.mul(x,w[_]),h=0,_=0)}d=26}return x},N.prototype.convertTo=function(a){var f=a.umod(this.m);return f===a?f.clone():f},N.prototype.convertFrom=function(a){var f=a.clone();return f.red=null,f},s.mont=function(a){return new g(a)};function g(a){N.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(g,N),g.prototype.convertTo=function(a){return this.imod(a.ushln(this.shift))},g.prototype.convertFrom=function(a){var f=this.imod(a.mul(this.rinv));return f.red=null,f},g.prototype.imul=function(a,f){if(a.isZero()||f.isZero())return a.words[0]=0,a.length=1,a;var p=a.imul(f),w=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),A=p.isub(w).iushrn(this.shift),x=A;return A.cmp(this.m)>=0?x=A.isub(this.m):A.cmpn(0)<0&&(x=A.iadd(this.m)),x._forceRed(this)},g.prototype.mul=function(a,f){if(a.isZero()||f.isZero())return new s(0)._forceRed(this);var p=a.mul(f),w=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),A=p.isub(w).iushrn(this.shift),x=A;return A.cmp(this.m)>=0?x=A.isub(this.m):A.cmpn(0)<0&&(x=A.iadd(this.m)),x._forceRed(this)},g.prototype.invm=function(a){var f=this.imod(a._invmp(this.m).mul(this.r2));return f._forceRed(this)}})(t,Tu)})(Ku);var je=Ku.exports;const Hu="bignumber/5.7.0";var Fa=je.BN;const pi=new Ve(Hu),uc={},Vu=9007199254740991;function m6(t){return t!=null&&(ft.isBigNumber(t)||typeof t=="number"&&t%1===0||typeof t=="string"&&!!t.match(/^-?[0-9]+$/)||dr(t)||typeof t=="bigint"||jn(t))}let Gu=!1;class ft{constructor(e,r){e!==uc&&pi.throwError("cannot call constructor directly; use BigNumber.from",Ve.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=r,this._isBigNumber=!0,Object.freeze(this)}fromTwos(e){return tr(Ze(this).fromTwos(e))}toTwos(e){return tr(Ze(this).toTwos(e))}abs(){return this._hex[0]==="-"?ft.from(this._hex.substring(1)):this}add(e){return tr(Ze(this).add(Ze(e)))}sub(e){return tr(Ze(this).sub(Ze(e)))}div(e){return ft.from(e).isZero()&&mr("division-by-zero","div"),tr(Ze(this).div(Ze(e)))}mul(e){return tr(Ze(this).mul(Ze(e)))}mod(e){const r=Ze(e);return r.isNeg()&&mr("division-by-zero","mod"),tr(Ze(this).umod(r))}pow(e){const r=Ze(e);return r.isNeg()&&mr("negative-power","pow"),tr(Ze(this).pow(r))}and(e){const r=Ze(e);return(this.isNegative()||r.isNeg())&&mr("unbound-bitwise-result","and"),tr(Ze(this).and(r))}or(e){const r=Ze(e);return(this.isNegative()||r.isNeg())&&mr("unbound-bitwise-result","or"),tr(Ze(this).or(r))}xor(e){const r=Ze(e);return(this.isNegative()||r.isNeg())&&mr("unbound-bitwise-result","xor"),tr(Ze(this).xor(r))}mask(e){return(this.isNegative()||e<0)&&mr("negative-width","mask"),tr(Ze(this).maskn(e))}shl(e){return(this.isNegative()||e<0)&&mr("negative-width","shl"),tr(Ze(this).shln(e))}shr(e){return(this.isNegative()||e<0)&&mr("negative-width","shr"),tr(Ze(this).shrn(e))}eq(e){return Ze(this).eq(Ze(e))}lt(e){return Ze(this).lt(Ze(e))}lte(e){return Ze(this).lte(Ze(e))}gt(e){return Ze(this).gt(Ze(e))}gte(e){return Ze(this).gte(Ze(e))}isNegative(){return this._hex[0]==="-"}isZero(){return Ze(this).isZero()}toNumber(){try{return Ze(this).toNumber()}catch{mr("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch{}return pi.throwError("this platform does not support BigInt",Ve.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(arguments[0]===10?Gu||(Gu=!0,pi.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):arguments[0]===16?pi.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",Ve.errors.UNEXPECTED_ARGUMENT,{}):pi.throwError("BigNumber.toString does not accept parameters",Ve.errors.UNEXPECTED_ARGUMENT,{})),Ze(this).toString(10)}toHexString(){return this._hex}toJSON(e){return{type:"BigNumber",hex:this.toHexString()}}static from(e){if(e instanceof ft)return e;if(typeof e=="string")return e.match(/^-?0x[0-9a-f]+$/i)?new ft(uc,_s(e)):e.match(/^-?[0-9]+$/)?new ft(uc,_s(new Fa(e))):pi.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),ft.from(String(e));const r=e;if(typeof r=="bigint")return ft.from(r.toString());if(jn(r))return ft.from(Vt(r));if(r)if(r.toHexString){const i=r.toHexString();if(typeof i=="string")return ft.from(i)}else{let i=r._hex;if(i==null&&r.type==="BigNumber"&&(i=r.hex),typeof i=="string"&&(dr(i)||i[0]==="-"&&dr(i.substring(1))))return ft.from(i)}return pi.throwArgumentError("invalid BigNumber value","value",e)}static isBigNumber(e){return!!(e&&e._isBigNumber)}}function _s(t){if(typeof t!="string")return _s(t.toString(16));if(t[0]==="-")return t=t.substring(1),t[0]==="-"&&pi.throwArgumentError("invalid hex","value",t),t=_s(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 tr(t){return ft.from(_s(t))}function Ze(t){const e=ft.from(t).toHexString();return e[0]==="-"?new Fa("-"+e.substring(3),16):new Fa(e.substring(2),16)}function mr(t,e,r){const i={fault:t,operation:e};return r!=null&&(i.value=r),pi.throwError(t,Ve.errors.NUMERIC_FAULT,i)}function y6(t){return new Fa(t,36).toString(16)}const Gt=new Ve(Hu),As={},Wu=ft.from(0),Yu=ft.from(-1);function Ju(t,e,r,i){const n={fault:e,operation:r};return i!==void 0&&(n.value=i),Gt.throwError(t,Ve.errors.NUMERIC_FAULT,n)}let Es="0";for(;Es.length<256;)Es+=Es;function dc(t){if(typeof t!="number")try{t=ft.from(t).toNumber()}catch{}return typeof t=="number"&&t>=0&&t<=256&&!(t%1)?"1"+Es.substring(0,t):Gt.throwArgumentError("invalid decimal size","decimals",t)}function lc(t,e){e==null&&(e=0);const r=dc(e);t=ft.from(t);const i=t.lt(Wu);i&&(t=t.mul(Yu));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 gi(t,e){e==null&&(e=0);const r=dc(e);(typeof t!="string"||!t.match(/^-?[0-9.]+$/))&&Gt.throwArgumentError("invalid decimal value","value",t);const i=t.substring(0,1)==="-";i&&(t=t.substring(1)),t==="."&&Gt.throwArgumentError("missing value","value",t);const n=t.split(".");n.length>2&&Gt.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&&Ju("fractional component exceeds decimals","underflow","parseFixed"),o===""&&(o="0");o.length<r.length-1;)o+="0";const c=ft.from(s),l=ft.from(o);let u=c.mul(r).add(l);return i&&(u=u.mul(Yu)),u}class Kn{constructor(e,r,i,n){e!==As&&Gt.throwError("cannot use FixedFormat constructor; use FixedFormat.from",Ve.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=dc(n),Object.freeze(this)}static from(e){if(e instanceof Kn)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||Gt.throwArgumentError("invalid fixed format","format",e),r=s[1]!=="u",i=parseInt(s[2]),n=parseInt(s[3])}}else if(e){const s=(o,c,l)=>e[o]==null?l:(typeof e[o]!==c&&Gt.throwArgumentError("invalid fixed format ("+o+" not "+c+")","format."+o,e[o]),e[o]);r=s("signed","boolean",r),i=s("width","number",i),n=s("decimals","number",n)}return i%8&&Gt.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",i),n>80&&Gt.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",n),new Kn(As,r,i,n)}}class Tt{constructor(e,r,i,n){e!==As&&Gt.throwError("cannot use FixedNumber constructor; use FixedNumber.from",Ve.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&&Gt.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)}addUnsafe(e){this._checkFormat(e);const r=gi(this._value,this.format.decimals),i=gi(e._value,e.format.decimals);return Tt.fromValue(r.add(i),this.format.decimals,this.format)}subUnsafe(e){this._checkFormat(e);const r=gi(this._value,this.format.decimals),i=gi(e._value,e.format.decimals);return Tt.fromValue(r.sub(i),this.format.decimals,this.format)}mulUnsafe(e){this._checkFormat(e);const r=gi(this._value,this.format.decimals),i=gi(e._value,e.format.decimals);return Tt.fromValue(r.mul(i).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(e){this._checkFormat(e);const r=gi(this._value,this.format.decimals),i=gi(e._value,e.format.decimals);return Tt.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=Tt.from(e[0],this.format);const i=!e[1].match(/^(0*)$/);return this.isNegative()&&i&&(r=r.subUnsafe(Qu.toFormat(r.format))),r}ceiling(){const e=this.toString().split(".");e.length===1&&e.push("0");let r=Tt.from(e[0],this.format);const i=!e[1].match(/^(0*)$/);return!this.isNegative()&&i&&(r=r.addUnsafe(Qu.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)&&Gt.throwArgumentError("invalid decimal count","decimals",e),r[1].length<=e)return this;const i=Tt.from("1"+Es.substring(0,e),this.format),n=w6.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&&Gt.throwArgumentError("invalid byte width","width",e);const r=ft.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString();return Yr(r,e/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return Tt.fromString(this._value,e)}static fromValue(e,r,i){return i==null&&r!=null&&!m6(r)&&(i=r,r=null),r==null&&(r=0),i==null&&(i="fixed"),Tt.fromString(lc(e,r),Kn.from(i))}static fromString(e,r){r==null&&(r="fixed");const i=Kn.from(r),n=gi(e,i.decimals);!i.signed&&n.lt(Wu)&&Ju("unsigned value cannot be negative","overflow","value",e);let s=null;i.signed?s=n.toTwos(i.width).toHexString():(s=n.toHexString(),s=Yr(s,i.width/8));const o=lc(n,i.decimals);return new Tt(As,s,o,i)}static fromBytes(e,r){r==null&&(r="fixed");const i=Kn.from(r);if(gt(e).length>i.width/8)throw new Error("overflow");let n=ft.from(e);i.signed&&(n=n.fromTwos(i.width));const s=n.toTwos((i.signed?0:1)+i.width).toHexString(),o=lc(n,i.decimals);return new Tt(As,s,o,i)}static from(e,r){if(typeof e=="string")return Tt.fromString(e,r);if(jn(e))return Tt.fromBytes(e,r);try{return Tt.fromValue(e,0,r)}catch(i){if(i.code!==Ve.errors.INVALID_ARGUMENT)throw i}return Gt.throwArgumentError("invalid FixedNumber value","value",e)}static isFixedNumber(e){return!!(e&&e._isFixedNumber)}}const Qu=Tt.from(1),w6=Tt.from("0.5"),_6="strings/5.7.0",Xu=new Ve(_6);var La;(function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD"})(La||(La={}));var Hn;(function(t){t.UNEXPECTED_CONTINUE="unexpected continuation byte",t.BAD_PREFIX="bad codepoint prefix",t.OVERRUN="string overrun",t.MISSING_CONTINUE="missing continuation byte",t.OUT_OF_RANGE="out of UTF-8 range",t.UTF16_SURROGATE="UTF-16 surrogate",t.OVERLONG="overlong representation"})(Hn||(Hn={}));function A6(t,e,r,i,n){return Xu.throwArgumentError(`invalid codepoint at offset ${e}; ${t}`,"bytes",r)}function Zu(t,e,r,i,n){if(t===Hn.BAD_PREFIX||t===Hn.UNEXPECTED_CONTINUE){let s=0;for(let o=e+1;o<r.length&&r[o]>>6===2;o++)s++;return s}return t===Hn.OVERRUN?r.length-e-1:0}function E6(t,e,r,i,n){return t===Hn.OVERLONG?(i.push(n),0):(i.push(65533),Zu(t,e,r))}Object.freeze({error:A6,ignore:Zu,replace:E6});function pc(t,e=La.current){e!=La.current&&(Xu.checkNormalize(),t=t.normalize(e));let r=[];for(let i=0;i<t.length;i++){const n=t.charCodeAt(i);if(n<128)r.push(n);else if(n<2048)r.push(n>>6|192),r.push(n&63|128);else if((n&64512)==55296){i++;const s=t.charCodeAt(i);if(i>=t.length||(s&64512)!==56320)throw new Error("invalid utf-8 string");const o=65536+((n&1023)<<10)+(s&1023);r.push(o>>18|240),r.push(o>>12&63|128),r.push(o>>6&63|128),r.push(o&63|128)}else r.push(n>>12|224),r.push(n>>6&63|128),r.push(n&63|128)}return gt(r)}function x6(t){if(t.length%4!==0)throw new Error("bad data");let e=[];for(let r=0;r<t.length;r+=4)e.push(parseInt(t.substring(r,r+4),16));return e}function gc(t,e){e||(e=function(n){return[parseInt(n,16)]});let r=0,i={};return t.split(",").forEach(n=>{let s=n.split(":");r+=parseInt(s[0],16),i[r]=e(s[1])}),i}function e0(t){let e=0;return t.split(",").map(r=>{let i=r.split("-");i.length===1?i[1]="0":i[1]===""&&(i[1]="1");let n=e+parseInt(i[0],16);return e=parseInt(i[1],16),{l:n,h:e}})}e0("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),"ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(t=>parseInt(t,16)),gc("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),gc("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),gc("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",x6),e0("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001");const t0="hash/5.7.0";function S6(t){t=atob(t);const e=[];for(let r=0;r<t.length;r++)e.push(t.charCodeAt(r));return gt(e)}function r0(t,e){e==null&&(e=1);const r=[],i=r.forEach,n=function(s,o){i.call(s,function(c){o>0&&Array.isArray(c)?n(c,o-1):r.push(c)})};return n(t,e),r}function M6(t){const e={};for(let r=0;r<t.length;r++){const i=t[r];e[i[0]]=i[1]}return e}function I6(t){let e=0;function r(){return t[e++]<<8|t[e++]}let i=r(),n=1,s=[0,1];for(let B=1;B<i;B++)s.push(n+=r());let o=r(),c=e;e+=o;let l=0,u=0;function b(){return l==0&&(u=u<<8|t[e++],l=8),u>>--l&1}const m=31,M=Math.pow(2,m),S=M>>>1,I=S>>1,F=M-1;let k=0;for(let B=0;B<m;B++)k=k<<1|b();let j=[],C=0,$=M;for(;;){let B=Math.floor(((k-C+1)*n-1)/$),U=0,y=i;for(;y-U>1;){let Q=U+y>>>1;B<s[Q]?y=Q:U=Q}if(U==0)break;j.push(U);let O=C+Math.floor($*s[U]/n),Y=C+Math.floor($*s[U+1]/n)-1;for(;!((O^Y)&S);)k=k<<1&F|b(),O=O<<1&F,Y=Y<<1&F|1;for(;O&~Y&I;)k=k&S|k<<1&F>>>1|b(),O=O<<1^S,Y=(Y^S)<<1|S|1;C=O,$=1+Y-O}let P=i-4;return j.map(B=>{switch(B-P){case 3:return P+65792+(t[c++]<<16|t[c++]<<8|t[c++]);case 2:return P+256+(t[c++]<<8|t[c++]);case 1:return P+t[c++];default:return B-1}})}function D6(t){let e=0;return()=>t[e++]}function O6(t){return D6(I6(t))}function R6(t){return t&1?~t>>1:t>>1}function N6(t,e){let r=Array(t);for(let i=0;i<t;i++)r[i]=1+e();return r}function i0(t,e){let r=Array(t);for(let i=0,n=-1;i<t;i++)r[i]=n+=1+e();return r}function P6(t,e){let r=Array(t);for(let i=0,n=0;i<t;i++)r[i]=n+=R6(e());return r}function Ba(t,e){let r=i0(t(),t),i=t(),n=i0(i,t),s=N6(i,t);for(let o=0;o<i;o++)for(let c=0;c<s[o];c++)r.push(n[o]+c);return e?r.map(o=>e[o]):r}function T6(t){let e=[];for(;;){let r=t();if(r==0)break;e.push(F6(r,t))}for(;;){let r=t()-1;if(r<0)break;e.push(L6(r,t))}return M6(r0(e))}function C6(t){let e=[];for(;;){let r=t();if(r==0)break;e.push(r)}return e}function n0(t,e,r){let i=Array(t).fill(void 0).map(()=>[]);for(let n=0;n<e;n++)P6(t,r).forEach((s,o)=>i[o].push(s));return i}function F6(t,e){let r=1+e(),i=e(),n=C6(e),s=n0(n.length,1+t,e);return r0(s.map((o,c)=>{const l=o[0],u=o.slice(1);return Array(n[c]).fill(void 0).map((b,m)=>{let M=m*i;return[l+m*r,u.map(S=>S+M)]})}))}function L6(t,e){let r=1+e();return n0(r,1+t,e).map(i=>[i[0],i.slice(1)])}function B6(t){let e=Ba(t).sort((i,n)=>i-n);return r();function r(){let i=[];for(;;){let u=Ba(t,e);if(u.length==0)break;i.push({set:new Set(u),node:r()})}i.sort((u,b)=>b.set.size-u.set.size);let n=t(),s=n%3;n=n/3|0;let o=!!(n&1);n>>=1;let c=n==1,l=n==2;return{branches:i,valid:s,fe0f:o,save:c,check:l}}}function q6(){return O6(S6("AEQF2AO2DEsA2wIrAGsBRABxAN8AZwCcAEwAqgA0AGwAUgByADcATAAVAFYAIQAyACEAKAAYAFgAGwAjABQAMAAmADIAFAAfABQAKwATACoADgAbAA8AHQAYABoAGQAxADgALAAoADwAEwA9ABMAGgARAA4ADwAWABMAFgAIAA8AHgQXBYMA5BHJAS8JtAYoAe4AExozi0UAH21tAaMnBT8CrnIyhrMDhRgDygIBUAEHcoFHUPe8AXBjAewCjgDQR8IICIcEcQLwATXCDgzvHwBmBoHNAqsBdBcUAykgDhAMShskMgo8AY8jqAQfAUAfHw8BDw87MioGlCIPBwZCa4ELatMAAMspJVgsDl8AIhckSg8XAHdvTwBcIQEiDT4OPhUqbyECAEoAS34Aej8Ybx83JgT/Xw8gHxZ/7w8RICxPHA9vBw+Pfw8PHwAPFv+fAsAvCc8vEr8ivwD/EQ8Bol8OEBa/A78hrwAPCU8vESNvvwWfHwNfAVoDHr+ZAAED34YaAdJPAK7PLwSEgDLHAGo1Pz8Pvx9fUwMrpb8O/58VTzAPIBoXIyQJNF8hpwIVAT8YGAUADDNBaX3RAMomJCg9EhUeA29MABsZBTMNJipjOhc19gcIDR8bBwQHEggCWi6DIgLuAQYA+BAFCha3A5XiAEsqM7UFFgFLhAMjFTMYE1Klnw74nRVBG/ASCm0BYRN/BrsU3VoWy+S0vV8LQx+vN8gF2AC2AK5EAWwApgYDKmAAroQ0NDQ0AT+OCg7wAAIHRAbpNgVcBV0APTA5BfbPFgMLzcYL/QqqA82eBALKCjQCjqYCht0/k2+OAsXQAoP3ASTKDgDw6ACKAUYCMpIKJpRaAE4A5womABzZvs0REEKiACIQAd5QdAECAj4Ywg/wGqY2AVgAYADYvAoCGAEubA0gvAY2ALAAbpbvqpyEAGAEpgQAJgAG7gAgAEACmghUFwCqAMpAINQIwC4DthRAAPcycKgApoIdABwBfCisABoATwBqASIAvhnSBP8aH/ECeAKXAq40NjgDBTwFYQU6AXs3oABgAD4XNgmcCY1eCl5tIFZeUqGgyoNHABgAEQAaABNwWQAmABMATPMa3T34ADldyprmM1M2XociUQgLzvwAXT3xABgAEQAaABNwIGFAnADD8AAgAD4BBJWzaCcIAIEBFMAWwKoAAdq9BWAF5wLQpALEtQAKUSGkahR4GnJM+gsAwCgeFAiUAECQ0BQuL8AAIAAAADKeIheclvFqQAAETr4iAMxIARMgAMIoHhQIAn0E0pDQFC4HhznoAAAAIAI2C0/4lvFqQAAETgBJJwYCAy4ABgYAFAA8MBKYEH4eRhTkAjYeFcgACAYAeABsOqyQ5gRwDayqugEgaIIAtgoACgDmEABmBAWGme5OBJJA2m4cDeoAmITWAXwrMgOgAGwBCh6CBXYF1Tzg1wKAAFdiuABRAFwAXQBsAG8AdgBrAHYAbwCEAHEwfxQBVE5TEQADVFhTBwBDANILAqcCzgLTApQCrQL6vAAMAL8APLhNBKkE6glGKTAU4Dr4N2EYEwBCkABKk8rHAbYBmwIoAiU4Ajf/Aq4CowCAANIChzgaNBsCsTgeODcFXrgClQKdAqQBiQGYAqsCsjTsNHsfNPA0ixsAWTWiOAMFPDQSNCk2BDZHNow2TTZUNhk28Jk9VzI3QkEoAoICoQKwAqcAQAAxBV4FXbS9BW47YkIXP1ciUqs05DS/FwABUwJW11e6nHuYZmSh/RAYA8oMKvZ8KASoUAJYWAJ6ILAsAZSoqjpgA0ocBIhmDgDWAAawRDQoAAcuAj5iAHABZiR2AIgiHgCaAU68ACxuHAG0ygM8MiZIAlgBdF4GagJqAPZOHAMuBgoATkYAsABiAHgAMLoGDPj0HpKEBAAOJgAuALggTAHWAeAMEDbd20Uege0ADwAWADkAQgA9OHd+2MUQZBBhBgNNDkxxPxUQArEPqwvqERoM1irQ090ANK4H8ANYB/ADWANYB/AH8ANYB/ADWANYA1gDWBwP8B/YxRBkD00EcgWTBZAE2wiIJk4RhgctCNdUEnQjHEwDSgEBIypJITuYMxAlR0wRTQgIATZHbKx9PQNMMbBU+pCnA9AyVDlxBgMedhKlAC8PeCE1uk6DekxxpQpQT7NX9wBFBgASqwAS5gBJDSgAUCwGPQBI4zTYABNGAE2bAE3KAExdGABKaAbgAFBXAFCOAFBJABI2SWdObALDOq0//QomCZhvwHdTBkIQHCemEPgMNAG2ATwN7kvZBPIGPATKH34ZGg/OlZ0Ipi3eDO4m5C6igFsj9iqEBe5L9TzeC05RaQ9aC2YJ5DpkgU8DIgEOIowK3g06CG4Q9ArKbA3mEUYHOgPWSZsApgcCCxIdNhW2JhFirQsKOXgG/Br3C5AmsBMqev0F1BoiBk4BKhsAANAu6IWxWjJcHU9gBgQLJiPIFKlQIQ0mQLh4SRocBxYlqgKSQ3FKiFE3HpQh9zw+DWcuFFF9B/Y8BhlQC4I8n0asRQ8R0z6OPUkiSkwtBDaALDAnjAnQD4YMunxzAVoJIgmyDHITMhEYN8YIOgcaLpclJxYIIkaWYJsE+KAD9BPSAwwFQAlCBxQDthwuEy8VKgUOgSXYAvQ21i60ApBWgQEYBcwPJh/gEFFH4Q7qCJwCZgOEJewALhUiABginAhEZABgj9lTBi7MCMhqbSN1A2gU6GIRdAeSDlgHqBw0FcAc4nDJXgyGCSiksAlcAXYJmgFgBOQICjVcjKEgQmdUi1kYnCBiQUBd/QIyDGYVoES+h3kCjA9sEhwBNgF0BzoNAgJ4Ee4RbBCWCOyGBTW2M/k6JgRQIYQgEgooA1BszwsoJvoM+WoBpBJjAw00PnfvZ6xgtyUX/gcaMsZBYSHyC5NPzgydGsIYQ1QvGeUHwAP0GvQn60FYBgADpAQUOk4z7wS+C2oIjAlAAEoOpBgH2BhrCnKM0QEyjAG4mgNYkoQCcJAGOAcMAGgMiAV65gAeAqgIpAAGANADWAA6Aq4HngAaAIZCAT4DKDABIuYCkAOUCDLMAZYwAfQqBBzEDBYA+DhuSwLDsgKAa2ajBd5ZAo8CSjYBTiYEBk9IUgOwcuIA3ABMBhTgSAEWrEvMG+REAeBwLADIAPwABjYHBkIBzgH0bgC4AWALMgmjtLYBTuoqAIQAFmwB2AKKAN4ANgCA8gFUAE4FWvoF1AJQSgESMhksWGIBvAMgATQBDgB6BsyOpsoIIARuB9QCEBwV4gLvLwe2AgMi4BPOQsYCvd9WADIXUu5eZwqoCqdeaAC0YTQHMnM9UQAPH6k+yAdy/BZIiQImSwBQ5gBQQzSaNTFWSTYBpwGqKQK38AFtqwBI/wK37gK3rQK3sAK6280C0gK33AK3zxAAUEIAUD9SklKDArekArw5AEQAzAHCO147WTteO1k7XjtZO147WTteO1kDmChYI03AVU0oJqkKbV9GYewMpw3VRMk6ShPcYFJgMxPJLbgUwhXPJVcZPhq9JwYl5VUKDwUt1GYxCC00dhe9AEApaYNCY4ceMQpMHOhTklT5LRwAskujM7ANrRsWREEFSHXuYisWDwojAmSCAmJDXE6wXDchAqH4AmiZAmYKAp+FOBwMAmY8AmYnBG8EgAN/FAN+kzkHOXgYOYM6JCQCbB4CMjc4CwJtyAJtr/CLADRoRiwBaADfAOIASwYHmQyOAP8MwwAOtgJ3MAJ2o0ACeUxEAni7Hl3cRa9G9AJ8QAJ6yQJ9CgJ88UgBSH5kJQAsFklZSlwWGErNAtECAtDNSygDiFADh+dExpEzAvKiXQQDA69Lz0wuJgTQTU1NsAKLQAKK2cIcCB5EaAa4Ao44Ao5dQZiCAo7aAo5deVG1UzYLUtVUhgKT/AKTDQDqAB1VH1WwVdEHLBwplocy4nhnRTw6ApegAu+zWCKpAFomApaQApZ9nQCqWa1aCoJOADwClrYClk9cRVzSApnMApllXMtdCBoCnJw5wzqeApwXAp+cAp65iwAeEDIrEAKd8gKekwC2PmE1YfACntQCoG8BqgKeoCACnk+mY8lkKCYsAiewAiZ/AqD8AqBN2AKmMAKlzwKoAAB+AqfzaH1osgAESmodatICrOQCrK8CrWgCrQMCVx4CVd0CseLYAx9PbJgCsr4OArLpGGzhbWRtSWADJc4Ctl08QG6RAylGArhfArlIFgK5K3hwN3DiAr0aAy2zAzISAr6JcgMDM3ICvhtzI3NQAsPMAsMFc4N0TDZGdOEDPKgDPJsDPcACxX0CxkgCxhGKAshqUgLIRQLJUALJLwJkngLd03h6YniveSZL0QMYpGcDAmH1GfSVJXsMXpNevBICz2wCz20wTFTT9BSgAMeuAs90ASrrA04TfkwGAtwoAtuLAtJQA1JdA1NgAQIDVY2AikABzBfuYUZ2AILPg44C2sgC2d+EEYRKpz0DhqYAMANkD4ZyWvoAVgLfZgLeuXR4AuIw7RUB8zEoAfScAfLTiALr9ALpcXoAAur6AurlAPpIAboC7ooC652Wq5cEAu5AA4XhmHpw4XGiAvMEAGoDjheZlAL3FAORbwOSiAL3mQL52gL4Z5odmqy8OJsfA52EAv77ARwAOp8dn7QDBY4DpmsDptoA0sYDBmuhiaIGCgMMSgFgASACtgNGAJwEgLpoBgC8BGzAEowcggCEDC6kdjoAJAM0C5IKRoABZCgiAIzw3AYBLACkfng9ogigkgNmWAN6AEQCvrkEVqTGAwCsBRbAA+4iQkMCHR072jI2PTbUNsk2RjY5NvA23TZKNiU3EDcZN5I+RTxDRTBCJkK5VBYKFhZfwQCWygU3AJBRHpu+OytgNxa61A40GMsYjsn7BVwFXQVcBV0FaAVdBVwFXQVcBV0FXAVdBVwFXUsaCNyKAK4AAQUHBwKU7oICoW1e7jAEzgPxA+YDwgCkBFDAwADABKzAAOxFLhitA1UFTDeyPkM+bj51QkRCuwTQWWQ8X+0AWBYzsACNA8xwzAGm7EZ/QisoCTAbLDs6fnLfb8H2GccsbgFw13M1HAVkBW/Jxsm9CNRO8E8FDD0FBQw9FkcClOYCoMFegpDfADgcMiA2AJQACB8AsigKAIzIEAJKeBIApY5yPZQIAKQiHb4fvj5BKSRPQrZCOz0oXyxgOywfKAnGbgMClQaCAkILXgdeCD9IIGUgQj5fPoY+dT52Ao5CM0dAX9BTVG9SDzFwWTQAbxBzJF/lOEIQQglCCkKJIAls5AcClQICoKPMODEFxhi6KSAbiyfIRrMjtCgdWCAkPlFBIitCsEJRzAbMAV/OEyQzDg0OAQQEJ36i328/Mk9AybDJsQlq3tDRApUKAkFzXf1d/j9uALYP6hCoFgCTGD8kPsFKQiobrm0+zj0KSD8kPnVCRBwMDyJRTHFgMTJa5rwXQiQ2YfI/JD7BMEJEHGINTw4TOFlIRzwJO0icMQpyPyQ+wzJCRBv6DVgnKB01NgUKj2bwYzMqCoBkznBgEF+zYDIocwRIX+NgHj4HICNfh2C4CwdwFWpTG/lgUhYGAwRfv2Ts8mAaXzVgml/XYIJfuWC4HI1gUF9pYJZgMR6ilQHMAOwLAlDRefC0in4AXAEJA6PjCwc0IamOANMMCAECRQDFNRTZBgd+CwQlRA+r6+gLBDEFBnwUBXgKATIArwAGRAAHA3cDdAN2A3kDdwN9A3oDdQN7A30DfAN4A3oDfQAYEAAlAtYASwMAUAFsAHcKAHcAmgB3AHUAdQB2AHVu8UgAygDAAHcAdQB1AHYAdQALCgB3AAsAmgB3AAsCOwB3AAtu8UgAygDAAHgKAJoAdwB3AHUAdQB2AHUAeAB1AHUAdgB1bvFIAMoAwAALCgCaAHcACwB3AAsCOwB3AAtu8UgAygDAAH4ACwGgALcBpwC6AahdAu0COwLtbvFIAMoAwAALCgCaAu0ACwLtAAsCOwLtAAtu8UgAygDAA24ACwNvAAu0VsQAAzsAABCkjUIpAAsAUIusOggWcgMeBxVsGwL67U/2HlzmWOEeOgALASvuAAseAfpKUpnpGgYJDCIZM6YyARUE9ThqAD5iXQgnAJYJPnOzw0ZAEZxEKsIAkA4DhAHnTAIDxxUDK0lxCQlPYgIvIQVYJQBVqE1GakUAKGYiDToSBA1EtAYAXQJYAIF8GgMHRyAAIAjOe9YncekRAA0KACUrjwE7Ayc6AAYWAqaiKG4McEcqANoN3+Mg9TwCBhIkuCny+JwUQ29L008JluRxu3K+oAdqiHOqFH0AG5SUIfUJ5SxCGfxdipRzqTmT4V5Zb+r1Uo4Vm+NqSSEl2mNvR2JhIa8SpYO6ntdwFXHCWTCK8f2+Hxo7uiG3drDycAuKIMP5bhi06ACnqArH1rz4Rqg//lm6SgJGEVbF9xJHISaR6HxqxSnkw6shDnelHKNEfGUXSJRJ1GcsmtJw25xrZMDK9gXSm1/YMkdX4/6NKYOdtk/NQ3/NnDASjTc3fPjIjW/5sVfVObX2oTDWkr1dF9f3kxBsD3/3aQO8hPfRz+e0uEiJqt1161griu7gz8hDDwtpy+F+BWtefnKHZPAxcZoWbnznhJpy0e842j36bcNzGnIEusgGX0a8ZxsnjcSsPDZ09yZ36fCQbriHeQ72JRMILNl6ePPf2HWoVwgWAm1fb3V2sAY0+B6rAXqSwPBgseVmoqsBTSrm91+XasMYYySI8eeRxH3ZvHkMz3BQ5aJ3iUVbYPNM3/7emRtjlsMgv/9VyTsyt/mK+8fgWeT6SoFaclXqn42dAIsvAarF5vNNWHzKSkKQ/8Hfk5ZWK7r9yliOsooyBjRhfkHP4Q2DkWXQi6FG/9r/IwbmkV5T7JSopHKn1pJwm9tb5Ot0oyN1Z2mPpKXHTxx2nlK08fKk1hEYA8WgVVWL5lgx0iTv+KdojJeU23ZDjmiubXOxVXJKKi2Wjuh2HLZOFLiSC7Tls5SMh4f+Pj6xUSrNjFqLGehRNB8lC0QSLNmkJJx/wSG3MnjE9T1CkPwJI0wH2lfzwETIiVqUxg0dfu5q39Gt+hwdcxkhhNvQ4TyrBceof3Mhs/IxFci1HmHr4FMZgXEEczPiGCx0HRwzAqDq2j9AVm1kwN0mRVLWLylgtoPNapF5cY4Y1wJh/e0BBwZj44YgZrDNqvD/9Hv7GFYdUQeDJuQ3EWI4HaKqavU1XjC/n41kT4L79kqGq0kLhdTZvgP3TA3fS0ozVz+5piZsoOtIvBUFoMKbNcmBL6YxxaUAusHB38XrS8dQMnQwJfUUkpRoGr5AUeWicvBTzyK9g77+yCkf5PAysL7r/JjcZgrbvRpMW9iyaxZvKO6ceZN2EwIxKwVFPuvFuiEPGCoagbMo+SpydLrXqBzNCDGFCrO/rkcwa2xhokQZ5CdZ0AsU3JfSqJ6n5I14YA+P/uAgfhPU84Tlw7cEFfp7AEE8ey4sP12PTt4Cods1GRgDOB5xvyiR5m+Bx8O5nBCNctU8BevfV5A08x6RHd5jcwPTMDSZJOedIZ1cGQ704lxbAzqZOP05ZxaOghzSdvFBHYqomATARyAADK4elP8Ly3IrUZKfWh23Xy20uBUmLS4Pfagu9+oyVa2iPgqRP3F2CTUsvJ7+RYnN8fFZbU/HVvxvcFFDKkiTqV5UBZ3Gz54JAKByi9hkKMZJvuGgcSYXFmw08UyoQyVdfTD1/dMkCHXcTGAKeROgArsvmRrQTLUOXioOHGK2QkjHuoYFgXciZoTJd6Fs5q1QX1G+p/e26hYsEf7QZD1nnIyl/SFkNtYYmmBhpBrxl9WbY0YpHWRuw2Ll/tj9mD8P4snVzJl4F9J+1arVeTb9E5r2ILH04qStjxQNwn3m4YNqxmaNbLAqW2TN6LidwuJRqS+NXbtqxoeDXpxeGWmxzSkWxjkyCkX4NQRme6q5SAcC+M7+9ETfA/EwrzQajKakCwYyeunP6ZFlxU2oMEn1Pz31zeStW74G406ZJFCl1wAXIoUKkWotYEpOuXB1uVNxJ63dpJEqfxBeptwIHNrPz8BllZoIcBoXwgfJ+8VAUnVPvRvexnw0Ma/WiGYuJO5y8QTvEYBigFmhUxY5RqzE8OcywN/8m4UYrlaniJO75XQ6KSo9+tWHlu+hMi0UVdiKQp7NelnoZUzNaIyBPVeOwK6GNp+FfHuPOoyhaWuNvTYFkvxscMQWDh+zeFCFkgwbXftiV23ywJ4+uwRqmg9k3KzwIQpzppt8DBBOMbrqwQM5Gb05sEwdKzMiAqOloaA/lr0KA+1pr0/+HiWoiIjHA/wir2nIuS3PeU/ji3O6ZwoxcR1SZ9FhtLC5S0FIzFhbBWcGVP/KpxOPSiUoAdWUpqKH++6Scz507iCcxYI6rdMBICPJZea7OcmeFw5mObJSiqpjg2UoWNIs+cFhyDSt6geV5qgi3FunmwwDoGSMgerFOZGX1m0dMCYo5XOruxO063dwENK9DbnVM9wYFREzh4vyU1WYYJ/LRRp6oxgjqP/X5a8/4Af6p6NWkQferzBmXme0zY/4nwMJm/wd1tIqSwGz+E3xPEAOoZlJit3XddD7/BT1pllzOx+8bmQtANQ/S6fZexc6qi3W+Q2xcmXTUhuS5mpHQRvcxZUN0S5+PL9lXWUAaRZhEH8hTdAcuNMMCuVNKTEGtSUKNi3O6KhSaTzck8csZ2vWRZ+d7mW8c4IKwXIYd25S/zIftPkwPzufjEvOHWVD1m+FjpDVUTV0DGDuHj6QnaEwLu/dEgdLQOg9E1Sro9XHJ8ykLAwtPu+pxqKDuFexqON1sKQm7rwbE1E68UCfA/erovrTCG+DBSNg0l4goDQvZN6uNlbyLpcZAwj2UclycvLpIZMgv4yRlpb3YuMftozorbcGVHt/VeDV3+Fdf1TP0iuaCsPi2G4XeGhsyF1ubVDxkoJhmniQ0/jSg/eYML9KLfnCFgISWkp91eauR3IQvED0nAPXK+6hPCYs+n3+hCZbiskmVMG2da+0EsZPonUeIY8EbfusQXjsK/eFDaosbPjEfQS0RKG7yj5GG69M7MeO1HmiUYocgygJHL6M1qzUDDwUSmr99V7Sdr2F3JjQAJY+F0yH33Iv3+C9M38eML7gTgmNu/r2bUMiPvpYbZ6v1/IaESirBHNa7mPKn4dEmYg7v/+HQgPN1G79jBQ1+soydfDC2r+h2Bl/KIc5KjMK7OH6nb1jLsNf0EHVe2KBiE51ox636uyG6Lho0t3J34L5QY/ilE3mikaF4HKXG1mG1rCevT1Vv6GavltxoQe/bMrpZvRggnBxSEPEeEzkEdOxTnPXHVjUYdw8JYvjB/o7Eegc3Ma+NUxLLnsK0kJlinPmUHzHGtrk5+CAbVzFOBqpyy3QVUnzTDfC/0XD94/okH+OB+i7g9lolhWIjSnfIb+Eq43ZXOWmwvjyV/qqD+t0e+7mTEM74qP/Ozt8nmC7mRpyu63OB4KnUzFc074SqoyPUAgM+/TJGFo6T44EHnQU4X4z6qannVqgw/U7zCpwcmXV1AubIrvOmkKHazJAR55ePjp5tLBsN8vAqs3NAHdcEHOR2xQ0lsNAFzSUuxFQCFYvXLZJdOj9p4fNq6p0HBGUik2YzaI4xySy91KzhQ0+q1hjxvImRwPRf76tChlRkhRCi74NXZ9qUNeIwP+s5p+3m5nwPdNOHgSLD79n7O9m1n1uDHiMntq4nkYwV5OZ1ENbXxFd4PgrlvavZsyUO4MqYlqqn1O8W/I1dEZq5dXhrbETLaZIbC2Kj/Aa/QM+fqUOHdf0tXAQ1huZ3cmWECWSXy/43j35+Mvq9xws7JKseriZ1pEWKc8qlzNrGPUGcVgOa9cPJYIJsGnJTAUsEcDOEVULO5x0rXBijc1lgXEzQQKhROf8zIV82w8eswc78YX11KYLWQRcgHNJElBxfXr72lS2RBSl07qTKorO2uUDZr3sFhYsvnhLZn0A94KRzJ/7DEGIAhW5ZWFpL8gEwu1aLA9MuWZzNwl8Oze9Y+bX+v9gywRVnoB5I/8kXTXU3141yRLYrIOOz6SOnyHNy4SieqzkBXharjfjqq1q6tklaEbA8Qfm2DaIPs7OTq/nvJBjKfO2H9bH2cCMh1+5gspfycu8f/cuuRmtDjyqZ7uCIMyjdV3a+p3fqmXsRx4C8lujezIFHnQiVTXLXuI1XrwN3+siYYj2HHTvESUx8DlOTXpak9qFRK+L3mgJ1WsD7F4cu1aJoFoYQnu+wGDMOjJM3kiBQWHCcvhJ/HRdxodOQp45YZaOTA22Nb4XKCVxqkbwMYFhzYQYIAnCW8FW14uf98jhUG2zrKhQQ0q0CEq0t5nXyvUyvR8DvD69LU+g3i+HFWQMQ8PqZuHD+sNKAV0+M6EJC0szq7rEr7B5bQ8BcNHzvDMc9eqB5ZCQdTf80Obn4uzjwpYU7SISdtV0QGa9D3Wrh2BDQtpBKxaNFV+/Cy2P/Sv+8s7Ud0Fd74X4+o/TNztWgETUapy+majNQ68Lq3ee0ZO48VEbTZYiH1Co4OlfWef82RWeyUXo7woM03PyapGfikTnQinoNq5z5veLpeMV3HCAMTaZmA1oGLAn7XS3XYsz+XK7VMQsc4XKrmDXOLU/pSXVNUq8dIqTba///3x6LiLS6xs1xuCAYSfcQ3+rQgmu7uvf3THKt5Ooo97TqcbRqxx7EASizaQCBQllG/rYxVapMLgtLbZS64w1MDBMXX+PQpBKNwqUKOf2DDRDUXQf9EhOS0Qj4nTmlA8dzSLz/G1d+Ud8MTy/6ghhdiLpeerGY/UlDOfiuqFsMUU5/UYlP+BAmgRLuNpvrUaLlVkrqDievNVEAwF+4CoM1MZTmjxjJMsKJq+u8Zd7tNCUFy6LiyYXRJQ4VyvEQFFaCGKsxIwQkk7EzZ6LTJq2hUuPhvAW+gQnSG6J+MszC+7QCRHcnqDdyNRJ6T9xyS87A6MDutbzKGvGktpbXqtzWtXb9HsfK2cBMomjN9a4y+TaJLnXxAeX/HWzmf4cR4vALt/P4w4qgKY04ml4ZdLOinFYS6cup3G/1ie4+t1eOnpBNlqGqs75ilzkT4+DsZQxNvaSKJ//6zIbbk/M7LOhFmRc/1R+kBtz7JFGdZm/COotIdvQoXpTqP/1uqEUmCb/QWoGLMwO5ANcHzxdY48IGP5+J+zKOTBFZ4Pid+GTM+Wq12MV/H86xEJptBa6T+p3kgpwLedManBHC2GgNrFpoN2xnrMz9WFWX/8/ygSBkavq2Uv7FdCsLEYLu9LLIvAU0bNRDtzYl+/vXmjpIvuJFYjmI0im6QEYqnIeMsNjXG4vIutIGHijeAG/9EDBozKV5cldkHbLxHh25vT+ZEzbhXlqvpzKJwcEgfNwLAKFeo0/pvEE10XDB+EXRTXtSzJozQKFFAJhMxYkVaCW+E9AL7tMeU8acxidHqzb6lX4691UsDpy/LLRmT+epgW56+5Cw8tB4kMUv6s9lh3eRKbyGs+H/4mQMaYzPTf2OOdokEn+zzgvoD3FqNKk8QqGAXVsqcGdXrT62fSPkR2vROFi68A6se86UxRUk4cajfPyCC4G5wDhD+zNq4jodQ4u4n/m37Lr36n4LIAAsVr02dFi9AiwA81MYs2rm4eDlDNmdMRvEKRHfBwW5DdMNp0jPFZMeARqF/wL4XBfd+EMLBfMzpH5GH6NaW+1vrvMdg+VxDzatk3MXgO3ro3P/DpcC6+Mo4MySJhKJhSR01SGGGp5hPWmrrUgrv3lDnP+HhcI3nt3YqBoVAVTBAQT5iuhTg8nvPtd8ZeYj6w1x6RqGUBrSku7+N1+BaasZvjTk64RoIDlL8brpEcJx3OmY7jLoZsswdtmhfC/G21llXhITOwmvRDDeTTPbyASOa16cF5/A1fZAidJpqju3wYAy9avPR1ya6eNp9K8XYrrtuxlqi+bDKwlfrYdR0RRiKRVTLOH85+ZY7XSmzRpfZBJjaTa81VDcJHpZnZnSQLASGYW9l51ZV/h7eVzTi3Hv6hUsgc/51AqJRTkpbFVLXXszoBL8nBX0u/0jBLT8nH+fJePbrwURT58OY+UieRjd1vs04w0VG5VN2U6MoGZkQzKN/ptz0Q366dxoTGmj7i1NQGHi9GgnquXFYdrCfZBmeb7s0T6yrdlZH5cZuwHFyIJ/kAtGsTg0xH5taAAq44BAk1CPk9KVVbqQzrCUiFdF/6gtlPQ8bHHc1G1W92MXGZ5HEHftyLYs8mbD/9xYRUWkHmlM0zC2ilJlnNgV4bfALpQghxOUoZL7VTqtCHIaQSXm+YUMnpkXybnV+A6xlm2CVy8fn0Xlm2XRa0+zzOa21JWWmixfiPMSCZ7qA4rS93VN3pkpF1s5TonQjisHf7iU9ZGvUPOAKZcR1pbeVf/Ul7OhepGCaId9wOtqo7pJ7yLcBZ0pFkOF28y4zEI/kcUNmutBHaQpBdNM8vjCS6HZRokkeo88TBAjGyG7SR+6vUgTcyK9Imalj0kuxz0wmK+byQU11AiJFk/ya5dNduRClcnU64yGu/ieWSeOos1t3ep+RPIWQ2pyTYVbZltTbsb7NiwSi3AV+8KLWk7LxCnfZUetEM8ThnsSoGH38/nyAwFguJp8FjvlHtcWZuU4hPva0rHfr0UhOOJ/F6vS62FW7KzkmRll2HEc7oUq4fyi5T70Vl7YVIfsPHUCdHesf9Lk7WNVWO75JDkYbMI8TOW8JKVtLY9d6UJRITO8oKo0xS+o99Yy04iniGHAaGj88kEWgwv0OrHdY/nr76DOGNS59hXCGXzTKUvDl9iKpLSWYN1lxIeyywdNpTkhay74w2jFT6NS8qkjo5CxA1yfSYwp6AJIZNKIeEK5PJAW7ORgWgwp0VgzYpqovMrWxbu+DGZ6Lhie1RAqpzm8VUzKJOH3mCzWuTOLsN3VT/dv2eeYe9UjbR8YTBsLz7q60VN1sU51k+um1f8JxD5pPhbhSC8rRaB454tmh6YUWrJI3+GWY0qeWioj/tbkYITOkJaeuGt4JrJvHA+l0Gu7kY7XOaa05alMnRWVCXqFgLIwSY4uF59Ue5SU4QKuc/HamDxbr0x6csCetXGoP7Qn1Bk/J9DsynO/UD6iZ1Hyrz+jit0hDCwi/E9OjgKTbB3ZQKQ/0ZOvevfNHG0NK4Aj3Cp7NpRk07RT1i/S0EL93Ag8GRgKI9CfpajKyK6+Jj/PI1KO5/85VAwz2AwzP8FTBb075IxCXv6T9RVvWT2tUaqxDS92zrGUbWzUYk9mSs82pECH+fkqsDt93VW++4YsR/dHCYcQSYTO/KaBMDj9LSD/J/+z20Kq8XvZUAIHtm9hRPP3ItbuAu2Hm5lkPs92pd7kCxgRs0xOVBnZ13ccdA0aunrwv9SdqElJRC3g+oCu+nXyCgmXUs9yMjTMAIHfxZV+aPKcZeUBWt057Xo85Ks1Ir5gzEHCWqZEhrLZMuF11ziGtFQUds/EESajhagzcKsxamcSZxGth4UII+adPhQkUnx2WyN+4YWR+r3f8MnkyGFuR4zjzxJS8WsQYR5PTyRaD9ixa6Mh741nBHbzfjXHskGDq179xaRNrCIB1z1xRfWfjqw2pHc1zk9xlPpL8sQWAIuETZZhbnmL54rceXVNRvUiKrrqIkeogsl0XXb17ylNb0f4GA9Wd44vffEG8FSZGHEL2fbaTGRcSiCeA8PmA/f6Hz8HCS76fXUHwgwkzSwlI71ekZ7Fapmlk/KC+Hs8hUcw3N2LN5LhkVYyizYFl/uPeVP5lsoJHhhfWvvSWruCUW1ZcJOeuTbrDgywJ/qG07gZJplnTvLcYdNaH0KMYOYMGX+rB4NGPFmQsNaIwlWrfCezxre8zXBrsMT+edVLbLqN1BqB76JH4BvZTqUIMfGwPGEn+EnmTV86fPBaYbFL3DFEhjB45CewkXEAtJxk4/Ms2pPXnaRqdky0HOYdcUcE2zcXq4vaIvW2/v0nHFJH2XXe22ueDmq/18XGtELSq85j9X8q0tcNSSKJIX8FTuJF/Pf8j5PhqG2u+osvsLxYrvvfeVJL+4tkcXcr9JV7v0ERmj/X6fM3NC4j6dS1+9Umr2oPavqiAydTZPLMNRGY23LO9zAVDly7jD+70G5TPPLdhRIl4WxcYjLnM+SNcJ26FOrkrISUtPObIz5Zb3AG612krnpy15RMW+1cQjlnWFI6538qky9axd2oJmHIHP08KyP0ubGO+TQNOYuv2uh17yCIvR8VcStw7o1g0NM60sk+8Tq7YfIBJrtp53GkvzXH7OA0p8/n/u1satf/VJhtR1l8Wa6Gmaug7haSpaCaYQax6ta0mkutlb+eAOSG1aobM81D9A4iS1RRlzBBoVX6tU1S6WE2N9ORY6DfeLRC4l9Rvr5h95XDWB2mR1d4WFudpsgVYwiTwT31ljskD8ZyDOlm5DkGh9N/UB/0AI5Xvb8ZBmai2hQ4BWMqFwYnzxwB26YHSOv9WgY3JXnvoN+2R4rqGVh/LLDMtpFP+SpMGJNWvbIl5SOodbCczW2RKleksPoUeGEzrjtKHVdtZA+kfqO+rVx/iclCqwoopepvJpSTDjT+b9GWylGRF8EDbGlw6eUzmJM95Ovoz+kwLX3c2fTjFeYEsE7vUZm3mqdGJuKh2w9/QGSaqRHs99aScGOdDqkFcACoqdbBoQqqjamhH6Q9ng39JCg3lrGJwd50Qk9ovnqBTr8MME7Ps2wiVfygUmPoUBJJfJWX5Nda0nuncbFkA=="))}const qa=q6();new Set(Ba(qa)),new Set(Ba(qa)),T6(qa),B6(qa),new Ve(t0),new Uint8Array(32).fill(0);const U6=`Ethereum Signed Message:
|
22
|
-
`;function s0(t){return typeof t=="string"&&(t=pc(t)),hc(d6([pc(U6),pc(String(t.length)),t]))}const z6="rlp/5.7.0";new Ve(z6);const k6="address/5.7.0",xs=new Ve(k6);function a0(t){dr(t,20)||xs.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=gt(hc(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 $6=9007199254740991;function j6(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10}const bc={};for(let t=0;t<10;t++)bc[String(t)]=String(t);for(let t=0;t<26;t++)bc[String.fromCharCode(65+t)]=String(10+t);const o0=Math.floor(j6($6));function K6(t){t=t.toUpperCase(),t=t.substring(4)+t.substring(0,2)+"00";let e=t.split("").map(i=>bc[i]).join("");for(;e.length>=o0;){let i=e.substring(0,o0);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 H6(t){let e=null;if(typeof t!="string"&&xs.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))t.substring(0,2)!=="0x"&&(t="0x"+t),e=a0(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&xs.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)!==K6(t)&&xs.throwArgumentError("bad icap checksum","address",t),e=y6(t.substring(4));e.length<40;)e="0"+e;e=a0("0x"+e)}else xs.throwArgumentError("invalid address","address",t);return e}const V6="properties/5.7.0";new Ve(V6);function Ss(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}new Ve(t0),new Uint8Array(32).fill(0),ft.from(-1);const G6=ft.from(0),W6=ft.from(1);ft.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Yr(W6.toHexString(),32),Yr(G6.toHexString(),32);var Jr={},et={},Ms=c0;function c0(t,e){if(!t)throw new Error(e||"Assertion failed")}c0.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)};var vc={exports:{}};typeof Object.create=="function"?vc.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:vc.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}};var Y6=Ms,J6=vc.exports;et.inherits=J6;function Q6(t,e){return(t.charCodeAt(e)&64512)!==55296||e<0||e+1>=t.length?!1:(t.charCodeAt(e+1)&64512)===56320}function X6(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):Q6(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}et.toArray=X6;function Z6(t){for(var e="",r=0;r<t.length;r++)e+=h0(t[r].toString(16));return e}et.toHex=Z6;function f0(t){var e=t>>>24|t>>>8&65280|t<<8&16711680|(t&255)<<24;return e>>>0}et.htonl=f0;function em(t,e){for(var r="",i=0;i<t.length;i++){var n=t[i];e==="little"&&(n=f0(n)),r+=u0(n.toString(16))}return r}et.toHex32=em;function h0(t){return t.length===1?"0"+t:t}et.zero2=h0;function u0(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}et.zero8=u0;function tm(t,e,r,i){var n=r-e;Y6(n%4===0);for(var s=new Array(n/4),o=0,c=e;o<s.length;o++,c+=4){var l;i==="big"?l=t[c]<<24|t[c+1]<<16|t[c+2]<<8|t[c+3]:l=t[c+3]<<24|t[c+2]<<16|t[c+1]<<8|t[c],s[o]=l>>>0}return s}et.join32=tm;function rm(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}et.split32=rm;function im(t,e){return t>>>e|t<<32-e}et.rotr32=im;function nm(t,e){return t<<e|t>>>32-e}et.rotl32=nm;function sm(t,e){return t+e>>>0}et.sum32=sm;function am(t,e,r){return t+e+r>>>0}et.sum32_3=am;function om(t,e,r,i){return t+e+r+i>>>0}et.sum32_4=om;function cm(t,e,r,i,n){return t+e+r+i+n>>>0}et.sum32_5=cm;function fm(t,e,r,i){var n=t[e],s=t[e+1],o=i+s>>>0,c=(o<i?1:0)+r+n;t[e]=c>>>0,t[e+1]=o}et.sum64=fm;function hm(t,e,r,i){var n=e+i>>>0,s=(n<e?1:0)+t+r;return s>>>0}et.sum64_hi=hm;function um(t,e,r,i){var n=e+i;return n>>>0}et.sum64_lo=um;function dm(t,e,r,i,n,s,o,c){var l=0,u=e;u=u+i>>>0,l+=u<e?1:0,u=u+s>>>0,l+=u<s?1:0,u=u+c>>>0,l+=u<c?1:0;var b=t+r+n+o+l;return b>>>0}et.sum64_4_hi=dm;function lm(t,e,r,i,n,s,o,c){var l=e+i+s+c;return l>>>0}et.sum64_4_lo=lm;function pm(t,e,r,i,n,s,o,c,l,u){var b=0,m=e;m=m+i>>>0,b+=m<e?1:0,m=m+s>>>0,b+=m<s?1:0,m=m+c>>>0,b+=m<c?1:0,m=m+u>>>0,b+=m<u?1:0;var M=t+r+n+o+l+b;return M>>>0}et.sum64_5_hi=pm;function gm(t,e,r,i,n,s,o,c,l,u){var b=e+i+s+c+u;return b>>>0}et.sum64_5_lo=gm;function bm(t,e,r){var i=e<<32-r|t>>>r;return i>>>0}et.rotr64_hi=bm;function vm(t,e,r){var i=t<<32-r|e>>>r;return i>>>0}et.rotr64_lo=vm;function mm(t,e,r){return t>>>r}et.shr64_hi=mm;function ym(t,e,r){var i=t<<32-r|e>>>r;return i>>>0}et.shr64_lo=ym;var Vn={},d0=et,wm=Ms;function Ua(){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}Vn.BlockHash=Ua,Ua.prototype.update=function(t,e){if(t=d0.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){t=this.pending;var r=t.length%this._delta8;this.pending=t.slice(t.length-r,t.length),this.pending.length===0&&(this.pending=null),t=d0.join32(t,0,t.length-r,this.endian);for(var i=0;i<t.length;i+=this._delta32)this._update(t,i,i+this._delta32)}return this},Ua.prototype.digest=function(t){return this.update(this._pad()),wm(this.pending===null),this._digest(t)},Ua.prototype._pad=function(){var t=this.pendingTotal,e=this._delta8,r=e-(t+this.padLength)%e,i=new Array(r+this.padLength);i[0]=128;for(var n=1;n<r;n++)i[n]=0;if(t<<=3,this.endian==="big"){for(var s=8;s<this.padLength;s++)i[n++]=0;i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=t>>>24&255,i[n++]=t>>>16&255,i[n++]=t>>>8&255,i[n++]=t&255}else for(i[n++]=t&255,i[n++]=t>>>8&255,i[n++]=t>>>16&255,i[n++]=t>>>24&255,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,s=8;s<this.padLength;s++)i[n++]=0;return i};var Gn={},Qr={},_m=et,Xr=_m.rotr32;function Am(t,e,r,i){if(t===0)return l0(e,r,i);if(t===1||t===3)return g0(e,r,i);if(t===2)return p0(e,r,i)}Qr.ft_1=Am;function l0(t,e,r){return t&e^~t&r}Qr.ch32=l0;function p0(t,e,r){return t&e^t&r^e&r}Qr.maj32=p0;function g0(t,e,r){return t^e^r}Qr.p32=g0;function Em(t){return Xr(t,2)^Xr(t,13)^Xr(t,22)}Qr.s0_256=Em;function xm(t){return Xr(t,6)^Xr(t,11)^Xr(t,25)}Qr.s1_256=xm;function Sm(t){return Xr(t,7)^Xr(t,18)^t>>>3}Qr.g0_256=Sm;function Mm(t){return Xr(t,17)^Xr(t,19)^t>>>10}Qr.g1_256=Mm;var Wn=et,Im=Vn,Dm=Qr,mc=Wn.rotl32,Is=Wn.sum32,Om=Wn.sum32_5,Rm=Dm.ft_1,b0=Im.BlockHash,Nm=[1518500249,1859775393,2400959708,3395469782];function Zr(){if(!(this instanceof Zr))return new Zr;b0.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Wn.inherits(Zr,b0);var Pm=Zr;Zr.blockSize=512,Zr.outSize=160,Zr.hmacStrength=80,Zr.padLength=64,Zr.prototype._update=function(t,e){for(var r=this.W,i=0;i<16;i++)r[i]=t[e+i];for(;i<r.length;i++)r[i]=mc(r[i-3]^r[i-8]^r[i-14]^r[i-16],1);var n=this.h[0],s=this.h[1],o=this.h[2],c=this.h[3],l=this.h[4];for(i=0;i<r.length;i++){var u=~~(i/20),b=Om(mc(n,5),Rm(u,s,o,c),l,r[i],Nm[u]);l=c,c=o,o=mc(s,30),s=n,n=b}this.h[0]=Is(this.h[0],n),this.h[1]=Is(this.h[1],s),this.h[2]=Is(this.h[2],o),this.h[3]=Is(this.h[3],c),this.h[4]=Is(this.h[4],l)},Zr.prototype._digest=function(t){return t==="hex"?Wn.toHex32(this.h,"big"):Wn.split32(this.h,"big")};var Yn=et,Tm=Vn,Jn=Qr,Cm=Ms,Nr=Yn.sum32,Fm=Yn.sum32_4,Lm=Yn.sum32_5,Bm=Jn.ch32,qm=Jn.maj32,Um=Jn.s0_256,zm=Jn.s1_256,km=Jn.g0_256,$m=Jn.g1_256,v0=Tm.BlockHash,jm=[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 ei(){if(!(this instanceof ei))return new ei;v0.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=jm,this.W=new Array(64)}Yn.inherits(ei,v0);var m0=ei;ei.blockSize=512,ei.outSize=256,ei.hmacStrength=192,ei.padLength=64,ei.prototype._update=function(t,e){for(var r=this.W,i=0;i<16;i++)r[i]=t[e+i];for(;i<r.length;i++)r[i]=Fm($m(r[i-2]),r[i-7],km(r[i-15]),r[i-16]);var n=this.h[0],s=this.h[1],o=this.h[2],c=this.h[3],l=this.h[4],u=this.h[5],b=this.h[6],m=this.h[7];for(Cm(this.k.length===r.length),i=0;i<r.length;i++){var M=Lm(m,zm(l),Bm(l,u,b),this.k[i],r[i]),S=Nr(Um(n),qm(n,s,o));m=b,b=u,u=l,l=Nr(c,M),c=o,o=s,s=n,n=Nr(M,S)}this.h[0]=Nr(this.h[0],n),this.h[1]=Nr(this.h[1],s),this.h[2]=Nr(this.h[2],o),this.h[3]=Nr(this.h[3],c),this.h[4]=Nr(this.h[4],l),this.h[5]=Nr(this.h[5],u),this.h[6]=Nr(this.h[6],b),this.h[7]=Nr(this.h[7],m)},ei.prototype._digest=function(t){return t==="hex"?Yn.toHex32(this.h,"big"):Yn.split32(this.h,"big")};var yc=et,y0=m0;function bi(){if(!(this instanceof bi))return new bi;y0.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}yc.inherits(bi,y0);var Km=bi;bi.blockSize=512,bi.outSize=224,bi.hmacStrength=192,bi.padLength=64,bi.prototype._digest=function(t){return t==="hex"?yc.toHex32(this.h.slice(0,7),"big"):yc.split32(this.h.slice(0,7),"big")};var rr=et,Hm=Vn,Vm=Ms,ti=rr.rotr64_hi,ri=rr.rotr64_lo,w0=rr.shr64_hi,_0=rr.shr64_lo,ki=rr.sum64,wc=rr.sum64_hi,_c=rr.sum64_lo,Gm=rr.sum64_4_hi,Wm=rr.sum64_4_lo,Ym=rr.sum64_5_hi,Jm=rr.sum64_5_lo,A0=Hm.BlockHash,Qm=[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 Pr(){if(!(this instanceof Pr))return new Pr;A0.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=Qm,this.W=new Array(160)}rr.inherits(Pr,A0);var E0=Pr;Pr.blockSize=1024,Pr.outSize=512,Pr.hmacStrength=192,Pr.padLength=128,Pr.prototype._prepareBlock=function(t,e){for(var r=this.W,i=0;i<32;i++)r[i]=t[e+i];for(;i<r.length;i+=2){var n=cy(r[i-4],r[i-3]),s=fy(r[i-4],r[i-3]),o=r[i-14],c=r[i-13],l=ay(r[i-30],r[i-29]),u=oy(r[i-30],r[i-29]),b=r[i-32],m=r[i-31];r[i]=Gm(n,s,o,c,l,u,b,m),r[i+1]=Wm(n,s,o,c,l,u,b,m)}},Pr.prototype._update=function(t,e){this._prepareBlock(t,e);var r=this.W,i=this.h[0],n=this.h[1],s=this.h[2],o=this.h[3],c=this.h[4],l=this.h[5],u=this.h[6],b=this.h[7],m=this.h[8],M=this.h[9],S=this.h[10],I=this.h[11],F=this.h[12],k=this.h[13],j=this.h[14],C=this.h[15];Vm(this.k.length===r.length);for(var $=0;$<r.length;$+=2){var P=j,B=C,U=ny(m,M),y=sy(m,M),O=Xm(m,M,S,I,F),Y=Zm(m,M,S,I,F,k),Q=this.k[$],N=this.k[$+1],g=r[$],a=r[$+1],f=Ym(P,B,U,y,O,Y,Q,N,g,a),p=Jm(P,B,U,y,O,Y,Q,N,g,a);P=ry(i,n),B=iy(i,n),U=ey(i,n,s,o,c),y=ty(i,n,s,o,c,l);var w=wc(P,B,U,y),A=_c(P,B,U,y);j=F,C=k,F=S,k=I,S=m,I=M,m=wc(u,b,f,p),M=_c(b,b,f,p),u=c,b=l,c=s,l=o,s=i,o=n,i=wc(f,p,w,A),n=_c(f,p,w,A)}ki(this.h,0,i,n),ki(this.h,2,s,o),ki(this.h,4,c,l),ki(this.h,6,u,b),ki(this.h,8,m,M),ki(this.h,10,S,I),ki(this.h,12,F,k),ki(this.h,14,j,C)},Pr.prototype._digest=function(t){return t==="hex"?rr.toHex32(this.h,"big"):rr.split32(this.h,"big")};function Xm(t,e,r,i,n){var s=t&r^~t&n;return s<0&&(s+=4294967296),s}function Zm(t,e,r,i,n,s){var o=e&i^~e&s;return o<0&&(o+=4294967296),o}function ey(t,e,r,i,n){var s=t&r^t&n^r&n;return s<0&&(s+=4294967296),s}function ty(t,e,r,i,n,s){var o=e&i^e&s^i&s;return o<0&&(o+=4294967296),o}function ry(t,e){var r=ti(t,e,28),i=ti(e,t,2),n=ti(e,t,7),s=r^i^n;return s<0&&(s+=4294967296),s}function iy(t,e){var r=ri(t,e,28),i=ri(e,t,2),n=ri(e,t,7),s=r^i^n;return s<0&&(s+=4294967296),s}function ny(t,e){var r=ti(t,e,14),i=ti(t,e,18),n=ti(e,t,9),s=r^i^n;return s<0&&(s+=4294967296),s}function sy(t,e){var r=ri(t,e,14),i=ri(t,e,18),n=ri(e,t,9),s=r^i^n;return s<0&&(s+=4294967296),s}function ay(t,e){var r=ti(t,e,1),i=ti(t,e,8),n=w0(t,e,7),s=r^i^n;return s<0&&(s+=4294967296),s}function oy(t,e){var r=ri(t,e,1),i=ri(t,e,8),n=_0(t,e,7),s=r^i^n;return s<0&&(s+=4294967296),s}function cy(t,e){var r=ti(t,e,19),i=ti(e,t,29),n=w0(t,e,6),s=r^i^n;return s<0&&(s+=4294967296),s}function fy(t,e){var r=ri(t,e,19),i=ri(e,t,29),n=_0(t,e,6),s=r^i^n;return s<0&&(s+=4294967296),s}var Ac=et,x0=E0;function vi(){if(!(this instanceof vi))return new vi;x0.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Ac.inherits(vi,x0);var hy=vi;vi.blockSize=1024,vi.outSize=384,vi.hmacStrength=192,vi.padLength=128,vi.prototype._digest=function(t){return t==="hex"?Ac.toHex32(this.h.slice(0,12),"big"):Ac.split32(this.h.slice(0,12),"big")},Gn.sha1=Pm,Gn.sha224=Km,Gn.sha256=m0,Gn.sha384=hy,Gn.sha512=E0;var S0={},fn=et,uy=Vn,za=fn.rotl32,M0=fn.sum32,Ds=fn.sum32_3,I0=fn.sum32_4,D0=uy.BlockHash;function ii(){if(!(this instanceof ii))return new ii;D0.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}fn.inherits(ii,D0),S0.ripemd160=ii,ii.blockSize=512,ii.outSize=160,ii.hmacStrength=192,ii.padLength=64,ii.prototype._update=function(t,e){for(var r=this.h[0],i=this.h[1],n=this.h[2],s=this.h[3],o=this.h[4],c=r,l=i,u=n,b=s,m=o,M=0;M<80;M++){var S=M0(za(I0(r,O0(M,i,n,s),t[py[M]+e],dy(M)),by[M]),o);r=o,o=s,s=za(n,10),n=i,i=S,S=M0(za(I0(c,O0(79-M,l,u,b),t[gy[M]+e],ly(M)),vy[M]),m),c=m,m=b,b=za(u,10),u=l,l=S}S=Ds(this.h[1],n,b),this.h[1]=Ds(this.h[2],s,m),this.h[2]=Ds(this.h[3],o,c),this.h[3]=Ds(this.h[4],r,l),this.h[4]=Ds(this.h[0],i,u),this.h[0]=S},ii.prototype._digest=function(t){return t==="hex"?fn.toHex32(this.h,"little"):fn.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 dy(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function ly(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}var py=[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],gy=[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],by=[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],vy=[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],my=et,yy=Ms;function Qn(t,e,r){if(!(this instanceof Qn))return new Qn(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(my.toArray(e,r))}var wy=Qn;Qn.prototype._init=function(t){t.length>this.blockSize&&(t=new this.Hash().update(t).digest()),yy(t.length<=this.blockSize);for(var e=t.length;e<this.blockSize;e++)t.push(0);for(e=0;e<t.length;e++)t[e]^=54;for(this.inner=new this.Hash().update(t),e=0;e<t.length;e++)t[e]^=106;this.outer=new this.Hash().update(t)},Qn.prototype.update=function(t,e){return this.inner.update(t,e),this},Qn.prototype.digest=function(t){return this.outer.update(this.inner.digest()),this.outer.digest(t)},function(t){var e=t;e.utils=et,e.common=Vn,e.sha=Gn,e.ripemd=S0,e.hmac=wy,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}(Jr);function Xn(t,e,r){return r={path:e,exports:{},require:function(i,n){return _y(i,n??r.path)}},t(r,r.exports),r.exports}function _y(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var Ec=R0;function R0(t,e){if(!t)throw new Error(e||"Assertion failed")}R0.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)};var Tr=Xn(function(t,e){var r=e;function i(o,c){if(Array.isArray(o))return o.slice();if(!o)return[];var l=[];if(typeof o!="string"){for(var u=0;u<o.length;u++)l[u]=o[u]|0;return l}if(c==="hex"){o=o.replace(/[^a-z0-9]+/ig,""),o.length%2!==0&&(o="0"+o);for(var u=0;u<o.length;u+=2)l.push(parseInt(o[u]+o[u+1],16))}else for(var u=0;u<o.length;u++){var b=o.charCodeAt(u),m=b>>8,M=b&255;m?l.push(m,M):l.push(M)}return l}r.toArray=i;function n(o){return o.length===1?"0"+o:o}r.zero2=n;function s(o){for(var c="",l=0;l<o.length;l++)c+=n(o[l].toString(16));return c}r.toHex=s,r.encode=function(o,c){return c==="hex"?s(o):o}}),lr=Xn(function(t,e){var r=e;r.assert=Ec,r.toArray=Tr.toArray,r.zero2=Tr.zero2,r.toHex=Tr.toHex,r.encode=Tr.encode;function i(l,u,b){var m=new Array(Math.max(l.bitLength(),b)+1);m.fill(0);for(var M=1<<u+1,S=l.clone(),I=0;I<m.length;I++){var F,k=S.andln(M-1);S.isOdd()?(k>(M>>1)-1?F=(M>>1)-k:F=k,S.isubn(F)):F=0,m[I]=F,S.iushrn(1)}return m}r.getNAF=i;function n(l,u){var b=[[],[]];l=l.clone(),u=u.clone();for(var m=0,M=0,S;l.cmpn(-m)>0||u.cmpn(-M)>0;){var I=l.andln(3)+m&3,F=u.andln(3)+M&3;I===3&&(I=-1),F===3&&(F=-1);var k;I&1?(S=l.andln(7)+m&7,(S===3||S===5)&&F===2?k=-I:k=I):k=0,b[0].push(k);var j;F&1?(S=u.andln(7)+M&7,(S===3||S===5)&&I===2?j=-F:j=F):j=0,b[1].push(j),2*m===k+1&&(m=1-m),2*M===j+1&&(M=1-M),l.iushrn(1),u.iushrn(1)}return b}r.getJSF=n;function s(l,u,b){var m="_"+u;l.prototype[u]=function(){return this[m]!==void 0?this[m]:this[m]=b.call(this)}}r.cachedProperty=s;function o(l){return typeof l=="string"?r.toArray(l,"hex"):l}r.parseBytes=o;function c(l){return new je(l,"hex","le")}r.intFromLE=c}),ka=lr.getNAF,Ay=lr.getJSF,$a=lr.assert;function $i(t,e){this.type=t,this.p=new je(e.p,16),this.red=e.prime?je.red(e.prime):je.mont(this.p),this.zero=new je(0).toRed(this.red),this.one=new je(1).toRed(this.red),this.two=new je(2).toRed(this.red),this.n=e.n&&new je(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 hn=$i;$i.prototype.point=function(){throw new Error("Not implemented")},$i.prototype.validate=function(){throw new Error("Not implemented")},$i.prototype._fixedNafMul=function(t,e){$a(t.precomputed);var r=t._getDoubles(),i=ka(e,1,this._bitLength),n=(1<<r.step+1)-(r.step%2===0?2:1);n/=3;var s=[],o,c;for(o=0;o<i.length;o+=r.step){c=0;for(var l=o+r.step-1;l>=o;l--)c=(c<<1)+i[l];s.push(c)}for(var u=this.jpoint(null,null,null),b=this.jpoint(null,null,null),m=n;m>0;m--){for(o=0;o<s.length;o++)c=s[o],c===m?b=b.mixedAdd(r.points[o]):c===-m&&(b=b.mixedAdd(r.points[o].neg()));u=u.add(b)}return u.toP()},$i.prototype._wnafMul=function(t,e){var r=4,i=t._getNAFPoints(r);r=i.wnd;for(var n=i.points,s=ka(e,r,this._bitLength),o=this.jpoint(null,null,null),c=s.length-1;c>=0;c--){for(var l=0;c>=0&&s[c]===0;c--)l++;if(c>=0&&l++,o=o.dblp(l),c<0)break;var u=s[c];$a(u!==0),t.type==="affine"?u>0?o=o.mixedAdd(n[u-1>>1]):o=o.mixedAdd(n[-u-1>>1].neg()):u>0?o=o.add(n[u-1>>1]):o=o.add(n[-u-1>>1].neg())}return t.type==="affine"?o.toP():o},$i.prototype._wnafMulAdd=function(t,e,r,i,n){var s=this._wnafT1,o=this._wnafT2,c=this._wnafT3,l=0,u,b,m;for(u=0;u<i;u++){m=e[u];var M=m._getNAFPoints(t);s[u]=M.wnd,o[u]=M.points}for(u=i-1;u>=1;u-=2){var S=u-1,I=u;if(s[S]!==1||s[I]!==1){c[S]=ka(r[S],s[S],this._bitLength),c[I]=ka(r[I],s[I],this._bitLength),l=Math.max(c[S].length,l),l=Math.max(c[I].length,l);continue}var F=[e[S],null,null,e[I]];e[S].y.cmp(e[I].y)===0?(F[1]=e[S].add(e[I]),F[2]=e[S].toJ().mixedAdd(e[I].neg())):e[S].y.cmp(e[I].y.redNeg())===0?(F[1]=e[S].toJ().mixedAdd(e[I]),F[2]=e[S].add(e[I].neg())):(F[1]=e[S].toJ().mixedAdd(e[I]),F[2]=e[S].toJ().mixedAdd(e[I].neg()));var k=[-3,-1,-5,-7,0,7,5,1,3],j=Ay(r[S],r[I]);for(l=Math.max(j[0].length,l),c[S]=new Array(l),c[I]=new Array(l),b=0;b<l;b++){var C=j[0][b]|0,$=j[1][b]|0;c[S][b]=k[(C+1)*3+($+1)],c[I][b]=0,o[S]=F}}var P=this.jpoint(null,null,null),B=this._wnafT4;for(u=l;u>=0;u--){for(var U=0;u>=0;){var y=!0;for(b=0;b<i;b++)B[b]=c[b][u]|0,B[b]!==0&&(y=!1);if(!y)break;U++,u--}if(u>=0&&U++,P=P.dblp(U),u<0)break;for(b=0;b<i;b++){var O=B[b];O!==0&&(O>0?m=o[b][O-1>>1]:O<0&&(m=o[b][-O-1>>1].neg()),m.type==="affine"?P=P.mixedAdd(m):P=P.add(m))}}for(u=0;u<i;u++)o[u]=null;return n?P:P.toP()};function yr(t,e){this.curve=t,this.type=e,this.precomputed=null}$i.BasePoint=yr,yr.prototype.eq=function(){throw new Error("Not implemented")},yr.prototype.validate=function(){return this.curve.validate(this)},$i.prototype.decodePoint=function(t,e){t=lr.toArray(t,e);var r=this.p.byteLength();if((t[0]===4||t[0]===6||t[0]===7)&&t.length-1===2*r){t[0]===6?$a(t[t.length-1]%2===0):t[0]===7&&$a(t[t.length-1]%2===1);var i=this.point(t.slice(1,1+r),t.slice(1+r,1+2*r));return i}else if((t[0]===2||t[0]===3)&&t.length-1===r)return this.pointFromX(t.slice(1,1+r),t[0]===3);throw new Error("Unknown point format")},yr.prototype.encodeCompressed=function(t){return this.encode(t,!0)},yr.prototype._encode=function(t){var e=this.curve.p.byteLength(),r=this.getX().toArray("be",e);return t?[this.getY().isEven()?2:3].concat(r):[4].concat(r,this.getY().toArray("be",e))},yr.prototype.encode=function(t,e){return lr.encode(this._encode(e),t)},yr.prototype.precompute=function(t){if(this.precomputed)return this;var e={doubles:null,naf:null,beta:null};return e.naf=this._getNAFPoints(8),e.doubles=this._getDoubles(4,t),e.beta=this._getBeta(),this.precomputed=e,this},yr.prototype._hasDoubles=function(t){if(!this.precomputed)return!1;var e=this.precomputed.doubles;return e?e.points.length>=Math.ceil((t.bitLength()+1)/e.step):!1},yr.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],i=this,n=0;n<e;n+=t){for(var s=0;s<t;s++)i=i.dbl();r.push(i)}return{step:t,points:r}},yr.prototype._getNAFPoints=function(t){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var e=[this],r=(1<<t)-1,i=r===1?null:this.dbl(),n=1;n<r;n++)e[n]=e[n-1].add(i);return{wnd:t,points:e}},yr.prototype._getBeta=function(){return null},yr.prototype.dblp=function(t){for(var e=this,r=0;r<t;r++)e=e.dbl();return e};var xc=Xn(function(t){typeof Object.create=="function"?t.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,r){if(r){e.super_=r;var i=function(){};i.prototype=r.prototype,e.prototype=new i,e.prototype.constructor=e}}}),Ey=lr.assert;function wr(t){hn.call(this,"short",t),this.a=new je(t.a,16).toRed(this.red),this.b=new je(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)}xc(wr,hn);var xy=wr;wr.prototype._getEndomorphism=function(t){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var e,r;if(t.beta)e=new je(t.beta,16).toRed(this.red);else{var i=this._getEndoRoots(this.p);e=i[0].cmp(i[1])<0?i[0]:i[1],e=e.toRed(this.red)}if(t.lambda)r=new je(t.lambda,16);else{var n=this._getEndoRoots(this.n);this.g.mul(n[0]).x.cmp(this.g.x.redMul(e))===0?r=n[0]:(r=n[1],Ey(this.g.mul(r).x.cmp(this.g.x.redMul(e))===0))}var s;return t.basis?s=t.basis.map(function(o){return{a:new je(o.a,16),b:new je(o.b,16)}}):s=this._getEndoBasis(r),{beta:e,lambda:r,basis:s}}},wr.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:je.mont(t),r=new je(2).toRed(e).redInvm(),i=r.redNeg(),n=new je(3).toRed(e).redNeg().redSqrt().redMul(r),s=i.redAdd(n).fromRed(),o=i.redSub(n).fromRed();return[s,o]},wr.prototype._getEndoBasis=function(t){for(var e=this.n.ushrn(Math.floor(this.n.bitLength()/2)),r=t,i=this.n.clone(),n=new je(1),s=new je(0),o=new je(0),c=new je(1),l,u,b,m,M,S,I,F=0,k,j;r.cmpn(0)!==0;){var C=i.div(r);k=i.sub(C.mul(r)),j=o.sub(C.mul(n));var $=c.sub(C.mul(s));if(!b&&k.cmp(e)<0)l=I.neg(),u=n,b=k.neg(),m=j;else if(b&&++F===2)break;I=k,i=r,r=k,o=n,n=j,c=s,s=$}M=k.neg(),S=j;var P=b.sqr().add(m.sqr()),B=M.sqr().add(S.sqr());return B.cmp(P)>=0&&(M=l,S=u),b.negative&&(b=b.neg(),m=m.neg()),M.negative&&(M=M.neg(),S=S.neg()),[{a:b,b:m},{a:M,b:S}]},wr.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],i=e[1],n=i.b.mul(t).divRound(this.n),s=r.b.neg().mul(t).divRound(this.n),o=n.mul(r.a),c=s.mul(i.a),l=n.mul(r.b),u=s.mul(i.b),b=t.sub(o).sub(c),m=l.add(u).neg();return{k1:b,k2:m}},wr.prototype.pointFromX=function(t,e){t=new je(t,16),t.red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),i=r.redSqrt();if(i.redSqr().redSub(r).cmp(this.zero)!==0)throw new Error("invalid point");var n=i.fromRed().isOdd();return(e&&!n||!e&&n)&&(i=i.redNeg()),this.point(t,i)},wr.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,i=this.a.redMul(e),n=e.redSqr().redMul(e).redIAdd(i).redIAdd(this.b);return r.redSqr().redISub(n).cmpn(0)===0},wr.prototype._endoWnafMulAdd=function(t,e,r){for(var i=this._endoWnafT1,n=this._endoWnafT2,s=0;s<t.length;s++){var o=this._endoSplit(e[s]),c=t[s],l=c._getBeta();o.k1.negative&&(o.k1.ineg(),c=c.neg(!0)),o.k2.negative&&(o.k2.ineg(),l=l.neg(!0)),i[s*2]=c,i[s*2+1]=l,n[s*2]=o.k1,n[s*2+1]=o.k2}for(var u=this._wnafMulAdd(1,i,n,s*2,r),b=0;b<s*2;b++)i[b]=null,n[b]=null;return u};function Dt(t,e,r,i){hn.BasePoint.call(this,t,"affine"),e===null&&r===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new je(e,16),this.y=new je(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)}xc(Dt,hn.BasePoint),wr.prototype.point=function(t,e,r){return new Dt(this,t,e,r)},wr.prototype.pointFromJSON=function(t,e){return Dt.fromJSON(this,t,e)},Dt.prototype._getBeta=function(){if(this.curve.endo){var t=this.precomputed;if(t&&t.beta)return t.beta;var e=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(t){var r=this.curve,i=function(n){return r.point(n.x.redMul(r.endo.beta),n.y)};t.beta=e,e.precomputed={beta:null,naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(i)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(i)}}}return e}},Dt.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]},Dt.fromJSON=function(t,e,r){typeof e=="string"&&(e=JSON.parse(e));var i=t.point(e[0],e[1],r);if(!e[2])return i;function n(o){return t.point(o[0],o[1],r)}var s=e[2];return i.precomputed={beta:null,doubles:s.doubles&&{step:s.doubles.step,points:[i].concat(s.doubles.points.map(n))},naf:s.naf&&{wnd:s.naf.wnd,points:[i].concat(s.naf.points.map(n))}},i},Dt.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)+">"},Dt.prototype.isInfinity=function(){return this.inf},Dt.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(this.x.cmp(t.x)===0)return this.curve.point(null,null);var e=this.y.redSub(t.y);e.cmpn(0)!==0&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),i=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,i)},Dt.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(t.cmpn(0)===0)return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),i=t.redInvm(),n=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(i),s=n.redSqr().redISub(this.x.redAdd(this.x)),o=n.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,o)},Dt.prototype.getX=function(){return this.x.fromRed()},Dt.prototype.getY=function(){return this.y.fromRed()},Dt.prototype.mul=function(t){return t=new je(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},Dt.prototype.mulAdd=function(t,e,r){var i=[this,e],n=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n):this.curve._wnafMulAdd(1,i,n,2)},Dt.prototype.jmulAdd=function(t,e,r){var i=[this,e],n=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n,!0):this.curve._wnafMulAdd(1,i,n,2,!0)},Dt.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||this.x.cmp(t.x)===0&&this.y.cmp(t.y)===0)},Dt.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,i=function(n){return n.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(i)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(i)}}}return e},Dt.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var t=this.curve.jpoint(this.x,this.y,this.curve.one);return t};function Ct(t,e,r,i){hn.BasePoint.call(this,t,"jacobian"),e===null&&r===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new je(0)):(this.x=new je(e,16),this.y=new je(r,16),this.z=new je(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}xc(Ct,hn.BasePoint),wr.prototype.jpoint=function(t,e,r){return new Ct(this,t,e,r)},Ct.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),i=this.y.redMul(e).redMul(t);return this.curve.point(r,i)},Ct.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Ct.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),i=this.x.redMul(e),n=t.x.redMul(r),s=this.y.redMul(e.redMul(t.z)),o=t.y.redMul(r.redMul(this.z)),c=i.redSub(n),l=s.redSub(o);if(c.cmpn(0)===0)return l.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var u=c.redSqr(),b=u.redMul(c),m=i.redMul(u),M=l.redSqr().redIAdd(b).redISub(m).redISub(m),S=l.redMul(m.redISub(M)).redISub(s.redMul(b)),I=this.z.redMul(t.z).redMul(c);return this.curve.jpoint(M,S,I)},Ct.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,i=t.x.redMul(e),n=this.y,s=t.y.redMul(e).redMul(this.z),o=r.redSub(i),c=n.redSub(s);if(o.cmpn(0)===0)return c.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var l=o.redSqr(),u=l.redMul(o),b=r.redMul(l),m=c.redSqr().redIAdd(u).redISub(b).redISub(b),M=c.redMul(b.redISub(m)).redISub(n.redMul(u)),S=this.z.redMul(o);return this.curve.jpoint(m,M,S)},Ct.prototype.dblp=function(t){if(t===0)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var r=this;for(e=0;e<t;e++)r=r.dbl();return r}var i=this.curve.a,n=this.curve.tinv,s=this.x,o=this.y,c=this.z,l=c.redSqr().redSqr(),u=o.redAdd(o);for(e=0;e<t;e++){var b=s.redSqr(),m=u.redSqr(),M=m.redSqr(),S=b.redAdd(b).redIAdd(b).redIAdd(i.redMul(l)),I=s.redMul(m),F=S.redSqr().redISub(I.redAdd(I)),k=I.redISub(F),j=S.redMul(k);j=j.redIAdd(j).redISub(M);var C=u.redMul(c);e+1<t&&(l=l.redMul(M)),s=F,c=C,u=j}return this.curve.jpoint(s,u.redMul(n),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 t,e,r;if(this.zOne){var i=this.x.redSqr(),n=this.y.redSqr(),s=n.redSqr(),o=this.x.redAdd(n).redSqr().redISub(i).redISub(s);o=o.redIAdd(o);var c=i.redAdd(i).redIAdd(i),l=c.redSqr().redISub(o).redISub(o),u=s.redIAdd(s);u=u.redIAdd(u),u=u.redIAdd(u),t=l,e=c.redMul(o.redISub(l)).redISub(u),r=this.y.redAdd(this.y)}else{var b=this.x.redSqr(),m=this.y.redSqr(),M=m.redSqr(),S=this.x.redAdd(m).redSqr().redISub(b).redISub(M);S=S.redIAdd(S);var I=b.redAdd(b).redIAdd(b),F=I.redSqr(),k=M.redIAdd(M);k=k.redIAdd(k),k=k.redIAdd(k),t=F.redISub(S).redISub(S),e=I.redMul(S.redISub(t)).redISub(k),r=this.y.redMul(this.z),r=r.redIAdd(r)}return this.curve.jpoint(t,e,r)},Ct.prototype._threeDbl=function(){var t,e,r;if(this.zOne){var i=this.x.redSqr(),n=this.y.redSqr(),s=n.redSqr(),o=this.x.redAdd(n).redSqr().redISub(i).redISub(s);o=o.redIAdd(o);var c=i.redAdd(i).redIAdd(i).redIAdd(this.curve.a),l=c.redSqr().redISub(o).redISub(o);t=l;var u=s.redIAdd(s);u=u.redIAdd(u),u=u.redIAdd(u),e=c.redMul(o.redISub(l)).redISub(u),r=this.y.redAdd(this.y)}else{var b=this.z.redSqr(),m=this.y.redSqr(),M=this.x.redMul(m),S=this.x.redSub(b).redMul(this.x.redAdd(b));S=S.redAdd(S).redIAdd(S);var I=M.redIAdd(M);I=I.redIAdd(I);var F=I.redAdd(I);t=S.redSqr().redISub(F),r=this.y.redAdd(this.z).redSqr().redISub(m).redISub(b);var k=m.redSqr();k=k.redIAdd(k),k=k.redIAdd(k),k=k.redIAdd(k),e=S.redMul(I.redISub(t)).redISub(k)}return this.curve.jpoint(t,e,r)},Ct.prototype._dbl=function(){var t=this.curve.a,e=this.x,r=this.y,i=this.z,n=i.redSqr().redSqr(),s=e.redSqr(),o=r.redSqr(),c=s.redAdd(s).redIAdd(s).redIAdd(t.redMul(n)),l=e.redAdd(e);l=l.redIAdd(l);var u=l.redMul(o),b=c.redSqr().redISub(u.redAdd(u)),m=u.redISub(b),M=o.redSqr();M=M.redIAdd(M),M=M.redIAdd(M),M=M.redIAdd(M);var S=c.redMul(m).redISub(M),I=r.redAdd(r).redMul(i);return this.curve.jpoint(b,S,I)},Ct.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr(),i=e.redSqr(),n=t.redAdd(t).redIAdd(t),s=n.redSqr(),o=this.x.redAdd(e).redSqr().redISub(t).redISub(i);o=o.redIAdd(o),o=o.redAdd(o).redIAdd(o),o=o.redISub(s);var c=o.redSqr(),l=i.redIAdd(i);l=l.redIAdd(l),l=l.redIAdd(l),l=l.redIAdd(l);var u=n.redIAdd(o).redSqr().redISub(s).redISub(c).redISub(l),b=e.redMul(u);b=b.redIAdd(b),b=b.redIAdd(b);var m=this.x.redMul(c).redISub(b);m=m.redIAdd(m),m=m.redIAdd(m);var M=this.y.redMul(u.redMul(l.redISub(u)).redISub(o.redMul(c)));M=M.redIAdd(M),M=M.redIAdd(M),M=M.redIAdd(M);var S=this.z.redAdd(o).redSqr().redISub(r).redISub(c);return this.curve.jpoint(m,M,S)},Ct.prototype.mul=function(t,e){return t=new je(t,e),this.curve._wnafMul(this,t)},Ct.prototype.eq=function(t){if(t.type==="affine")return this.eq(t.toJ());if(this===t)return!0;var e=this.z.redSqr(),r=t.z.redSqr();if(this.x.redMul(r).redISub(t.x.redMul(e)).cmpn(0)!==0)return!1;var i=e.redMul(this.z),n=r.redMul(t.z);return this.y.redMul(n).redISub(t.y.redMul(i)).cmpn(0)===0},Ct.prototype.eqXToP=function(t){var e=this.z.redSqr(),r=t.toRed(this.curve.red).redMul(e);if(this.x.cmp(r)===0)return!0;for(var i=t.clone(),n=this.curve.redN.redMul(e);;){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}},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 ja=Xn(function(t,e){var r=e;r.base=hn,r.short=xy,r.mont=null,r.edwards=null}),Ka=Xn(function(t,e){var r=e,i=lr.assert;function n(c){c.type==="short"?this.curve=new ja.short(c):c.type==="edwards"?this.curve=new ja.edwards(c):this.curve=new ja.mont(c),this.g=this.curve.g,this.n=this.curve.n,this.hash=c.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}r.PresetCurve=n;function s(c,l){Object.defineProperty(r,c,{configurable:!0,enumerable:!0,get:function(){var u=new n(l);return Object.defineProperty(r,c,{configurable:!0,enumerable:!0,value:u}),u}})}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:Jr.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:Jr.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:Jr.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:Jr.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:Jr.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:Jr.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:Jr.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:Jr.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})});function ji(t){if(!(this instanceof ji))return new ji(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=Tr.toArray(t.entropy,t.entropyEnc||"hex"),r=Tr.toArray(t.nonce,t.nonceEnc||"hex"),i=Tr.toArray(t.pers,t.persEnc||"hex");Ec(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,i)}var N0=ji;ji.prototype._init=function(t,e,r){var i=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var n=0;n<this.V.length;n++)this.K[n]=0,this.V[n]=1;this._update(i),this._reseed=1,this.reseedInterval=281474976710656},ji.prototype._hmac=function(){return new Jr.hmac(this.hash,this.K)},ji.prototype._update=function(t){var e=this._hmac().update(this.V).update([0]);t&&(e=e.update(t)),this.K=e.digest(),this.V=this._hmac().update(this.V).digest(),t&&(this.K=this._hmac().update(this.V).update([1]).update(t).digest(),this.V=this._hmac().update(this.V).digest())},ji.prototype.reseed=function(t,e,r,i){typeof e!="string"&&(i=r,r=e,e=null),t=Tr.toArray(t,e),r=Tr.toArray(r,i),Ec(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},ji.prototype.generate=function(t,e,r,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof e!="string"&&(i=r,r=e,e=null),r&&(r=Tr.toArray(r,i||"hex"),this._update(r));for(var n=[];n.length<t;)this.V=this._hmac().update(this.V).digest(),n=n.concat(this.V);var s=n.slice(0,t);return this._update(r),this._reseed++,Tr.encode(s,e)};var Sc=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 Mc=kt;kt.fromPublic=function(t,e,r){return e instanceof kt?e:new kt(t,{pub:e,pubEnc:r})},kt.fromPrivate=function(t,e,r){return e instanceof kt?e:new kt(t,{priv:e,privEnc:r})},kt.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.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(t,e){return typeof t=="string"&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub},kt.prototype.getPrivate=function(t){return t==="hex"?this.priv.toString(16,2):this.priv},kt.prototype._importPrivate=function(t,e){this.priv=new je(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)},kt.prototype._importPublic=function(t,e){if(t.x||t.y){this.ec.curve.type==="mont"?Sc(t.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&Sc(t.x&&t.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(t.x,t.y);return}this.pub=this.ec.curve.decodePoint(t,e)},kt.prototype.derive=function(t){return t.validate()||Sc(t.validate(),"public point not validated"),t.mul(this.priv).getX()},kt.prototype.sign=function(t,e,r){return this.ec.sign(t,this,e,r)},kt.prototype.verify=function(t,e){return this.ec.verify(t,e,this)},kt.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var Sy=lr.assert;function Ha(t,e){if(t instanceof Ha)return t;this._importDER(t,e)||(Sy(t.r&&t.s,"Signature without r or s"),this.r=new je(t.r,16),this.s=new je(t.s,16),t.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var Va=Ha;function My(){this.place=0}function Ic(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 P0(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)}Ha.prototype._importDER=function(t,e){t=lr.toArray(t,e);var r=new My;if(t[r.place++]!==48)return!1;var i=Ic(t,r);if(i===!1||i+r.place!==t.length||t[r.place++]!==2)return!1;var n=Ic(t,r);if(n===!1)return!1;var s=t.slice(r.place,n+r.place);if(r.place+=n,t[r.place++]!==2)return!1;var o=Ic(t,r);if(o===!1||t.length!==o+r.place)return!1;var c=t.slice(r.place,o+r.place);if(s[0]===0)if(s[1]&128)s=s.slice(1);else return!1;if(c[0]===0)if(c[1]&128)c=c.slice(1);else return!1;return this.r=new je(s),this.s=new je(c),this.recoveryParam=null,!0};function Dc(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)}Ha.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(e[0]&128&&(e=[0].concat(e)),r[0]&128&&(r=[0].concat(r)),e=P0(e),r=P0(r);!r[0]&&!(r[1]&128);)r=r.slice(1);var i=[2];Dc(i,e.length),i=i.concat(e),i.push(2),Dc(i,r.length);var n=i.concat(r),s=[48];return Dc(s,n.length),s=s.concat(n),lr.encode(s,t)};var Iy=function(){throw new Error("unsupported")},T0=lr.assert;function _r(t){if(!(this instanceof _r))return new _r(t);typeof t=="string"&&(T0(Object.prototype.hasOwnProperty.call(Ka,t),"Unknown curve "+t),t=Ka[t]),t instanceof Ka.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 Dy=_r;_r.prototype.keyPair=function(t){return new Mc(this,t)},_r.prototype.keyFromPrivate=function(t,e){return Mc.fromPrivate(this,t,e)},_r.prototype.keyFromPublic=function(t,e){return Mc.fromPublic(this,t,e)},_r.prototype.genKeyPair=function(t){t||(t={});for(var e=new N0({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||Iy(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),i=this.n.sub(new je(2));;){var n=new je(e.generate(r));if(!(n.cmp(i)>0))return n.iaddn(1),this.keyFromPrivate(n)}},_r.prototype._truncateToN=function(t,e){var r=t.byteLength()*8-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},_r.prototype.sign=function(t,e,r,i){typeof r=="object"&&(i=r,r=null),i||(i={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new je(t,16));for(var n=this.n.byteLength(),s=e.getPrivate().toArray("be",n),o=t.toArray("be",n),c=new N0({hash:this.hash,entropy:s,nonce:o,pers:i.pers,persEnc:i.persEnc||"utf8"}),l=this.n.sub(new je(1)),u=0;;u++){var b=i.k?i.k(u):new je(c.generate(this.n.byteLength()));if(b=this._truncateToN(b,!0),!(b.cmpn(1)<=0||b.cmp(l)>=0)){var m=this.g.mul(b);if(!m.isInfinity()){var M=m.getX(),S=M.umod(this.n);if(S.cmpn(0)!==0){var I=b.invm(this.n).mul(S.mul(e.getPrivate()).iadd(t));if(I=I.umod(this.n),I.cmpn(0)!==0){var F=(m.getY().isOdd()?1:0)|(M.cmp(S)!==0?2:0);return i.canonical&&I.cmp(this.nh)>0&&(I=this.n.sub(I),F^=1),new Va({r:S,s:I,recoveryParam:F})}}}}}},_r.prototype.verify=function(t,e,r,i){t=this._truncateToN(new je(t,16)),r=this.keyFromPublic(r,i),e=new Va(e,"hex");var n=e.r,s=e.s;if(n.cmpn(1)<0||n.cmp(this.n)>=0||s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var o=s.invm(this.n),c=o.mul(t).umod(this.n),l=o.mul(n).umod(this.n),u;return this.curve._maxwellTrick?(u=this.g.jmulAdd(c,r.getPublic(),l),u.isInfinity()?!1:u.eqXToP(n)):(u=this.g.mulAdd(c,r.getPublic(),l),u.isInfinity()?!1:u.getX().umod(this.n).cmp(n)===0)},_r.prototype.recoverPubKey=function(t,e,r,i){T0((3&r)===r,"The recovery param is more than two bits"),e=new Va(e,i);var n=this.n,s=new je(t),o=e.r,c=e.s,l=r&1,u=r>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");u?o=this.curve.pointFromX(o.add(this.curve.n),l):o=this.curve.pointFromX(o,l);var b=e.r.invm(n),m=n.sub(s).mul(b).umod(n),M=c.mul(b).umod(n);return this.g.mulAdd(m,o,M)},_r.prototype.getKeyRecoveryParam=function(t,e,r,i){if(e=new Va(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 Oy=Xn(function(t,e){var r=e;r.version="6.5.4",r.utils=lr,r.rand=function(){throw new Error("unsupported")},r.curve=ja,r.curves=Ka,r.ec=Dy,r.eddsa=null}),Ry=Oy.ec;const Ny="signing-key/5.7.0",Oc=new Ve(Ny);let Rc=null;function ni(){return Rc||(Rc=new Ry("secp256k1")),Rc}class Py{constructor(e){Ss(this,"curve","secp256k1"),Ss(this,"privateKey",Vt(e)),p6(this.privateKey)!==32&&Oc.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const r=ni().keyFromPrivate(gt(this.privateKey));Ss(this,"publicKey","0x"+r.getPublic(!1,"hex")),Ss(this,"compressedPublicKey","0x"+r.getPublic(!0,"hex")),Ss(this,"_isSigningKey",!0)}_addPoint(e){const r=ni().keyFromPublic(gt(this.publicKey)),i=ni().keyFromPublic(gt(e));return"0x"+r.pub.add(i.pub).encodeCompressed("hex")}signDigest(e){const r=ni().keyFromPrivate(gt(this.privateKey)),i=gt(e);i.length!==32&&Oc.throwArgumentError("bad digest length","digest",e);const n=r.sign(i,{canonical:!0});return ju({recoveryParam:n.recoveryParam,r:Yr("0x"+n.r.toString(16),32),s:Yr("0x"+n.s.toString(16),32)})}computeSharedSecret(e){const r=ni().keyFromPrivate(gt(this.privateKey)),i=ni().keyFromPublic(gt(C0(e)));return Yr("0x"+r.derive(i.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}}function Ty(t,e){const r=ju(e),i={r:gt(r.r),s:gt(r.s)};return"0x"+ni().recoverPubKey(gt(t),i,r.recoveryParam).encode("hex",!1)}function C0(t,e){const r=gt(t);if(r.length===32){const i=new Py(r);return e?"0x"+ni().keyFromPrivate(r).getPublic(!0,"hex"):i.publicKey}else{if(r.length===33)return e?Vt(r):"0x"+ni().keyFromPublic(r).getPublic(!1,"hex");if(r.length===65)return e?"0x"+ni().keyFromPublic(r).getPublic(!0,"hex"):Vt(r)}return Oc.throwArgumentError("invalid public or private key","key","[REDACTED]")}const Cy="transactions/5.7.0";new Ve(Cy);var F0;(function(t){t[t.legacy=0]="legacy",t[t.eip2930=1]="eip2930",t[t.eip1559=2]="eip1559"})(F0||(F0={}));function Fy(t){const e=C0(t);return H6($u(hc($u(e,1)),12))}function Ly(t,e){return Fy(Ty(gt(t),e))}const By="https://rpc.walletconnect.com/v1";async function qy(t,e,r,i,n,s){switch(r.t){case"eip191":return Uy(t,e,r.s);case"eip1271":return await zy(t,e,r.s,i,n,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r.t}`)}}function Uy(t,e,r){return Ly(s0(e),r).toLowerCase()===t.toLowerCase()}async function zy(t,e,r,i,n,s){try{const o="0x1626ba7e",c="0000000000000000000000000000000000000000000000000000000000000040",l="0000000000000000000000000000000000000000000000000000000000000041",u=r.substring(2),b=s0(e).substring(2),m=o+b+c+l+u,M=await fetch(`${s||By}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:ky(),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:m},"latest"]})}),{result:S}=await M.json();return S?S.slice(0,o.length).toLowerCase()===o.toLowerCase():!1}catch(o){return console.error("isValidEip1271Signature: ",o),!1}}function ky(){return Date.now()+Math.floor(Math.random()*1e3)}var $y=Object.defineProperty,jy=Object.defineProperties,Ky=Object.getOwnPropertyDescriptors,L0=Object.getOwnPropertySymbols,Hy=Object.prototype.hasOwnProperty,Vy=Object.prototype.propertyIsEnumerable,B0=(t,e,r)=>e in t?$y(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Gy=(t,e)=>{for(var r in e||(e={}))Hy.call(e,r)&&B0(t,r,e[r]);if(L0)for(var r of L0(e))Vy.call(e,r)&&B0(t,r,e[r]);return t},Wy=(t,e)=>jy(t,Ky(e));const Yy="did:pkh:",Nc=t=>t?.split(":"),q0=t=>{const e=t&&Nc(t);if(e)return t.includes(Yy)?e[3]:e[1]},U0=t=>{const e=t&&Nc(t);if(e)return e[2]+":"+e[3]},Ga=t=>{const e=t&&Nc(t);if(e)return e.pop()};async function z0(t){const{cacao:e,projectId:r}=t,{s:i,p:n}=e,s=k0(n,n.iss),o=Ga(n.iss);return await qy(o,s,i,q0(n.iss),r)}const k0=(t,e)=>{const r=`${t.domain} wants you to sign in with your Ethereum account:`,i=Ga(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}`,c=`Chain ID: ${q0(e)}`,l=`Nonce: ${t.nonce}`,u=`Issued At: ${t.iat}`,b=t.exp?`Expiration Time: ${t.exp}`:void 0,m=t.nbf?`Not Before: ${t.nbf}`:void 0,M=t.requestId?`Request ID: ${t.requestId}`:void 0,S=t.resources?`Resources:${t.resources.map(F=>`
|
23
|
-
- ${F}`).join("")}`:void 0,I=Wa(t.resources);if(I){const F=Os(I);n=
|
24
|
-
`)};function Jy(t){return Buffer.from(JSON.stringify(t)).toString("base64")}function Qy(t){return JSON.parse(Buffer.from(t,"base64").toString("utf-8"))}function un(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 Xy(t,e,r,i={}){return r?.sort((n,s)=>n.localeCompare(s)),{att:{[t]:Zy(e,r,i)}}}function Zy(t,e,r={}){e=e?.sort((n,s)=>n.localeCompare(s));const i=e.map(n=>({[`${t}/${n}`]:[r]}));return Object.assign({},...i)}function $0(t){return un(t),`urn:recap:${Jy(t).replace(/=/g,"")}`}function Os(t){const e=Qy(t.replace("urn:recap:",""));return un(e),e}function e5(t,e,r){const i=Xy(t,e,r);return $0(i)}function t5(t){return t&&t.includes("urn:recap:")}function r5(t,e){const r=Os(t),i=Os(e),n=i5(r,i);return $0(n)}function i5(t,e){un(t),un(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((c,l)=>c.localeCompare(l)).forEach(c=>{var l,u;i.att[n]=Wy(Gy({},i.att[n]),{[c]:((l=t.att[n])==null?void 0:l[c])||((u=e.att[n])==null?void 0:u[c])})})}),i}function n5(t="",e){un(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(c=>{const l=Object.keys(e.att[c]).map(m=>({ability:m.split("/")[0],action:m.split("/")[1]}));l.sort((m,M)=>m.action.localeCompare(M.action));const u={};l.forEach(m=>{u[m.ability]||(u[m.ability]=[]),u[m.ability].push(m.action)});const b=Object.keys(u).map(m=>(n++,`(${n}) '${m}': '${u[m].join("', '")}' for '${c}'.`));i.push(b.join(", ").replace(".,","."))});const s=i.join(" "),o=`${r}${s}`;return`${t?t+" ":""}${o}`}function j0(t){var e;const r=Os(t);un(r);const i=(e=r.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function K0(t){const e=Os(t);un(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 Wa(t){if(!t)return;const e=t?.[t.length-1];return t5(e)?e:void 0}const H0="base10",Wt="base16",Ki="base64pad",Rs="base64url",Ns="utf8",V0=0,mi=1,Ps=2,s5=0,G0=1,Ts=12,Pc=32;function a5(){const t=$o.generateKeyPair();return{privateKey:Et(t.secretKey,Wt),publicKey:Et(t.publicKey,Wt)}}function Tc(){const t=Ci.randomBytes(Pc);return Et(t,Wt)}function o5(t,e){const r=$o.sharedKey(xt(t,Wt),xt(e,Wt),!0),i=new M2(ps.SHA256,r).expand(Pc);return Et(i,Wt)}function Ya(t){const e=ps.hash(xt(t,Wt));return Et(e,Wt)}function yi(t){const e=ps.hash(xt(t,Ns));return Et(e,Wt)}function W0(t){return xt(`${t}`,H0)}function dn(t){return Number(Et(t,H0))}function c5(t){const e=W0(typeof t.type<"u"?t.type:V0);if(dn(e)===mi&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof t.senderPublicKey<"u"?xt(t.senderPublicKey,Wt):void 0,i=typeof t.iv<"u"?xt(t.iv,Wt):Ci.randomBytes(Ts),n=new Uo.ChaCha20Poly1305(xt(t.symKey,Wt)).seal(i,xt(t.message,Ns));return Y0({type:e,sealed:n,iv:i,senderPublicKey:r,encoding:t.encoding})}function f5(t,e){const r=W0(Ps),i=Ci.randomBytes(Ts),n=xt(t,Ns);return Y0({type:r,sealed:n,iv:i,encoding:e})}function h5(t){const e=new Uo.ChaCha20Poly1305(xt(t.symKey,Wt)),{sealed:r,iv:i}=Cs({encoded:t.encoded,encoding:t?.encoding}),n=e.open(i,r);if(n===null)throw new Error("Failed to decrypt");return Et(n,Ns)}function u5(t,e){const{sealed:r}=Cs({encoded:t,encoding:e});return Et(r,Ns)}function Y0(t){const{encoding:e=Ki}=t;if(dn(t.type)===Ps)return Et(la([t.type,t.sealed]),e);if(dn(t.type)===mi){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return Et(la([t.type,t.senderPublicKey,t.iv,t.sealed]),e)}return Et(la([t.type,t.iv,t.sealed]),e)}function Cs(t){const{encoded:e,encoding:r=Ki}=t,i=xt(e,r),n=i.slice(s5,G0),s=G0;if(dn(n)===mi){const u=s+Pc,b=u+Ts,m=i.slice(s,u),M=i.slice(u,b),S=i.slice(b);return{type:n,sealed:S,iv:M,senderPublicKey:m}}if(dn(n)===Ps){const u=i.slice(s),b=Ci.randomBytes(Ts);return{type:n,sealed:u,iv:b}}const o=s+Ts,c=i.slice(s,o),l=i.slice(o);return{type:n,sealed:l,iv:c}}function d5(t,e){const r=Cs({encoded:t,encoding:e?.encoding});return J0({type:dn(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?Et(r.senderPublicKey,Wt):void 0,receiverPublicKey:e?.receiverPublicKey})}function J0(t){const e=t?.type||V0;if(e===mi){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 Q0(t){return t.type===mi&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}function X0(t){return t.type===Ps}function l5(t){return new qh.ec("p256").keyFromPublic({x:Buffer.from(t.x,"base64").toString("hex"),y:Buffer.from(t.y,"base64").toString("hex")},"hex")}function p5(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");const r=e.length%4;return r>0&&(e+="=".repeat(4-r)),e}function g5(t){return Buffer.from(p5(t),"base64")}function b5(t,e){const[r,i,n]=t.split("."),s=g5(n);if(s.length!==64)throw new Error("Invalid signature length");const o=s.slice(0,32).toString("hex"),c=s.slice(32,64).toString("hex"),l=`${r}.${i}`,u=new ps.SHA256().update(Buffer.from(l)).digest(),b=l5(e),m=Buffer.from(u).toString("hex");if(!b.verify(m,{r:o,s:c}))throw new Error("Invalid signature");return Fo(t).payload}const v5="irn";function Cc(t){return t?.relay||{protocol:v5}}function Fs(t){const e=jv[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}var m5=Object.defineProperty,y5=Object.defineProperties,w5=Object.getOwnPropertyDescriptors,Z0=Object.getOwnPropertySymbols,_5=Object.prototype.hasOwnProperty,A5=Object.prototype.propertyIsEnumerable,ed=(t,e,r)=>e in t?m5(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,td=(t,e)=>{for(var r in e||(e={}))_5.call(e,r)&&ed(t,r,e[r]);if(Z0)for(var r of Z0(e))A5.call(e,r)&&ed(t,r,e[r]);return t},E5=(t,e)=>y5(t,w5(e));function x5(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 rd(t){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=ds.parse(s),c=typeof o.methods=="string"?o.methods.split(","):void 0;return{protocol:i,topic:S5(n[0]),version:parseInt(n[1],10),symKey:o.symKey,relay:x5(o),methods:c,expiryTimestamp:o.expiryTimestamp?parseInt(o.expiryTimestamp,10):void 0}}function S5(t){return t.startsWith("//")?t.substring(2):t}function M5(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 I5(t){return`${t.protocol}:${t.topic}@${t.version}?`+ds.stringify(td(E5(td({symKey:t.symKey},M5(t.relay)),{expiryTimestamp:t.expiryTimestamp}),t.methods?{methods:t.methods.join(",")}:{}))}function Ja(t,e,r){return`${t}?wc_ev=${r}&topic=${e}`}function Zn(t){const e=[];return t.forEach(r=>{const[i,n]=r.split(":");e.push(`${i}:${n}`)}),e}function D5(t){const e=[];return Object.values(t).forEach(r=>{e.push(...Zn(r.accounts))}),e}function O5(t,e){const r=[];return Object.values(t).forEach(i=>{Zn(i.accounts).includes(e)&&r.push(...i.methods)}),r}function R5(t,e){const r=[];return Object.values(t).forEach(i=>{Zn(i.accounts).includes(e)&&r.push(...i.events)}),r}function N5(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 id(t,e){e=e.map(i=>i.replace("did:pkh:",""));const r=N5(e);for(const[i,n]of Object.entries(r))n.methods?n.methods=i6(n.methods,t):n.methods=t,n.events=["chainChanged","accountsChanged"];return r}const P5={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}},T5={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 ie(t,e){const{message:r,code:i}=T5[t];return{message:e?`${r} ${e}`:r,code:i}}function ht(t,e){const{message:r,code:i}=P5[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 Qa(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function Yt(t){return typeof t>"u"}function yt(t,e){return e&&Yt(t)?!0:typeof t=="string"&&!!t.trim().length}function Fc(t,e){return e&&Yt(t)?!0:typeof t=="number"&&!isNaN(t)}function C5(t,e){const{requiredNamespaces:r}=e,i=Object.keys(t.namespaces),n=Object.keys(r);let s=!0;return on(n,i)?(i.forEach(o=>{const{accounts:c,methods:l,events:u}=t.namespaces[o],b=Zn(c),m=r[o];(!on(_u(o,m),b)||!on(m.methods,l)||!on(m.events,u))&&(s=!1)}),s):!1}function Xa(t){return yt(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function F5(t){if(yt(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const r=e[0]+":"+e[1];return!!e[2]&&Xa(r)}}return!1}function L5(t){if(yt(t,!1))try{return typeof new URL(t)<"u"}catch{return!1}return!1}function B5(t){var e;return(e=t?.proposer)==null?void 0:e.publicKey}function q5(t){return t?.topic}function U5(t,e){let r=null;return yt(t?.publicKey,!1)||(r=ie("MISSING_OR_INVALID",`${e} controller public key should be a string`)),r}function nd(t){let e=!0;return Ls(t)?t.length&&(e=t.every(r=>yt(r,!1))):e=!1,e}function z5(t,e,r){let i=null;return Ls(e)&&e.length?e.forEach(n=>{i||Xa(n)||(i=ht("UNSUPPORTED_CHAINS",`${r}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):Xa(t)||(i=ht("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 k5(t,e,r){let i=null;return Object.entries(t).forEach(([n,s])=>{if(i)return;const o=z5(n,_u(n,s),`${e} ${r}`);o&&(i=o)}),i}function $5(t,e){let r=null;return Ls(t)?t.forEach(i=>{r||F5(i)||(r=ht("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):r=ht("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function j5(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=$5(i?.accounts,`${e} namespace`);n&&(r=n)}),r}function K5(t,e){let r=null;return nd(t?.methods)?nd(t?.events)||(r=ht("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):r=ht("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),r}function sd(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=K5(i,`${e}, namespace`);n&&(r=n)}),r}function H5(t,e,r){let i=null;if(t&&Qa(t)){const n=sd(t,e);n&&(i=n);const s=k5(t,e,r);s&&(i=s)}else i=ie("MISSING_OR_INVALID",`${e}, ${r} should be an object with data`);return i}function Lc(t,e){let r=null;if(t&&Qa(t)){const i=sd(t,e);i&&(r=i);const n=j5(t,e);n&&(r=n)}else r=ie("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function ad(t){return yt(t.protocol,!0)}function V5(t,e){let r=!1;return e&&!t?r=!0:t&&Ls(t)&&t.length&&t.forEach(i=>{r=ad(i)}),r}function G5(t){return typeof t=="number"}function ir(t){return typeof t<"u"&&typeof t!==null}function W5(t){return!(!t||typeof t!="object"||!t.code||!Fc(t.code,!1)||!t.message||!yt(t.message,!1))}function Y5(t){return!(Yt(t)||!yt(t.method,!1))}function J5(t){return!(Yt(t)||Yt(t.result)&&Yt(t.error)||!Fc(t.id,!1)||!yt(t.jsonrpc,!1))}function Q5(t){return!(Yt(t)||!yt(t.name,!1))}function od(t,e){return!(!Xa(e)||!D5(t).includes(e))}function X5(t,e,r){return yt(r,!1)?O5(t,e).includes(r):!1}function Z5(t,e,r){return yt(r,!1)?R5(t,e).includes(r):!1}function cd(t,e,r){let i=null;const n=e8(t),s=t8(e),o=Object.keys(n),c=Object.keys(s),l=fd(Object.keys(t)),u=fd(Object.keys(e)),b=l.filter(m=>!u.includes(m));return b.length&&(i=ie("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces.
|
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=Cu:s&&(n=self);var c=!n.JS_SHA3_NO_COMMON_JS&&!0&&t.exports,l=!n.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",u="0123456789abcdef".split(""),b=[31,7936,2031616,520093696],m=[4,1024,262144,67108864],M=[1,256,65536,16777216],S=[6,1536,393216,100663296],I=[0,8,16,24],F=[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],k=[224,256,384,512],j=[128,256],C=["hex","buffer","arrayBuffer","array","digest"],$={128:168,256:136};(n.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(E){return Object.prototype.toString.call(E)==="[object Array]"}),l&&(n.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(E){return typeof E=="object"&&E.buffer&&E.buffer.constructor===ArrayBuffer});for(var P=function(E,H,R){return function(L){return new D(E,H,E).update(L)[R]()}},B=function(E,H,R){return function(L,q){return new D(E,H,q).update(L)[R]()}},U=function(E,H,R){return function(L,q,v,T){return f["cshake"+E].update(L,q,v,T)[R]()}},y=function(E,H,R){return function(L,q,v,T){return f["kmac"+E].update(L,q,v,T)[R]()}},O=function(E,H,R,L){for(var q=0;q<C.length;++q){var v=C[q];E[v]=H(R,L,v)}return E},Y=function(E,H){var R=P(E,H,"hex");return R.create=function(){return new D(E,H,E)},R.update=function(L){return R.create().update(L)},O(R,P,E,H)},Q=function(E,H){var R=B(E,H,"hex");return R.create=function(L){return new D(E,H,L)},R.update=function(L,q){return R.create(q).update(L)},O(R,B,E,H)},N=function(E,H){var R=$[E],L=U(E,H,"hex");return L.create=function(q,v,T){return!v&&!T?f["shake"+E].create(q):new D(E,H,q).bytepad([v,T],R)},L.update=function(q,v,T,W){return L.create(v,T,W).update(q)},O(L,U,E,H)},g=function(E,H){var R=$[E],L=y(E,H,"hex");return L.create=function(q,v,T){return new K(E,H,v).bytepad(["KMAC",T],R).bytepad([q],R)},L.update=function(q,v,T,W){return L.create(q,T,W).update(v)},O(L,y,E,H)},a=[{name:"keccak",padding:M,bits:k,createMethod:Y},{name:"sha3",padding:S,bits:k,createMethod:Y},{name:"shake",padding:b,bits:j,createMethod:Q},{name:"cshake",padding:m,bits:j,createMethod:N},{name:"kmac",padding:m,bits:j,createMethod:g}],f={},p=[],w=0;w<a.length;++w)for(var A=a[w],x=A.bits,_=0;_<x.length;++_){var h=A.name+"_"+x[_];if(p.push(h),f[h]=A.createMethod(x[_],A.padding),A.name!=="sha3"){var d=A.name+x[_];p.push(d),f[d]=f[h]}}function D(E,H,R){this.blocks=[],this.s=[],this.padding=H,this.outputBits=R,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(E<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=R>>5,this.extraBytes=(R&31)>>3;for(var L=0;L<50;++L)this.s[L]=0}D.prototype.update=function(E){if(this.finalized)throw new Error(r);var H,R=typeof E;if(R!=="string"){if(R==="object"){if(E===null)throw new Error(e);if(l&&E.constructor===ArrayBuffer)E=new Uint8Array(E);else if(!Array.isArray(E)&&(!l||!ArrayBuffer.isView(E)))throw new Error(e)}else throw new Error(e);H=!0}for(var L=this.blocks,q=this.byteCount,v=E.length,T=this.blockCount,W=0,J=this.s,X,se;W<v;){if(this.reset)for(this.reset=!1,L[0]=this.block,X=1;X<T+1;++X)L[X]=0;if(H)for(X=this.start;W<v&&X<q;++W)L[X>>2]|=E[W]<<I[X++&3];else for(X=this.start;W<v&&X<q;++W)se=E.charCodeAt(W),se<128?L[X>>2]|=se<<I[X++&3]:se<2048?(L[X>>2]|=(192|se>>6)<<I[X++&3],L[X>>2]|=(128|se&63)<<I[X++&3]):se<55296||se>=57344?(L[X>>2]|=(224|se>>12)<<I[X++&3],L[X>>2]|=(128|se>>6&63)<<I[X++&3],L[X>>2]|=(128|se&63)<<I[X++&3]):(se=65536+((se&1023)<<10|E.charCodeAt(++W)&1023),L[X>>2]|=(240|se>>18)<<I[X++&3],L[X>>2]|=(128|se>>12&63)<<I[X++&3],L[X>>2]|=(128|se>>6&63)<<I[X++&3],L[X>>2]|=(128|se&63)<<I[X++&3]);if(this.lastByteIndex=X,X>=q){for(this.start=X-q,this.block=L[T],X=0;X<T;++X)J[X]^=L[X];G(J),this.reset=!0}else this.start=X}return this},D.prototype.encode=function(E,H){var R=E&255,L=1,q=[R];for(E=E>>8,R=E&255;R>0;)q.unshift(R),E=E>>8,R=E&255,++L;return H?q.push(L):q.unshift(L),this.update(q),q.length},D.prototype.encodeString=function(E){var H,R=typeof E;if(R!=="string"){if(R==="object"){if(E===null)throw new Error(e);if(l&&E.constructor===ArrayBuffer)E=new Uint8Array(E);else if(!Array.isArray(E)&&(!l||!ArrayBuffer.isView(E)))throw new Error(e)}else throw new Error(e);H=!0}var L=0,q=E.length;if(H)L=q;else for(var v=0;v<E.length;++v){var T=E.charCodeAt(v);T<128?L+=1:T<2048?L+=2:T<55296||T>=57344?L+=3:(T=65536+((T&1023)<<10|E.charCodeAt(++v)&1023),L+=4)}return L+=this.encode(L*8),this.update(E),L},D.prototype.bytepad=function(E,H){for(var R=this.encode(H),L=0;L<E.length;++L)R+=this.encodeString(E[L]);var q=H-R%H,v=[];return v.length=q,this.update(v),this},D.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var E=this.blocks,H=this.lastByteIndex,R=this.blockCount,L=this.s;if(E[H>>2]|=this.padding[H&3],this.lastByteIndex===this.byteCount)for(E[0]=E[R],H=1;H<R+1;++H)E[H]=0;for(E[R-1]|=2147483648,H=0;H<R;++H)L[H]^=E[H];G(L)}},D.prototype.toString=D.prototype.hex=function(){this.finalize();for(var E=this.blockCount,H=this.s,R=this.outputBlocks,L=this.extraBytes,q=0,v=0,T="",W;v<R;){for(q=0;q<E&&v<R;++q,++v)W=H[q],T+=u[W>>4&15]+u[W&15]+u[W>>12&15]+u[W>>8&15]+u[W>>20&15]+u[W>>16&15]+u[W>>28&15]+u[W>>24&15];v%E===0&&(G(H),q=0)}return L&&(W=H[q],T+=u[W>>4&15]+u[W&15],L>1&&(T+=u[W>>12&15]+u[W>>8&15]),L>2&&(T+=u[W>>20&15]+u[W>>16&15])),T},D.prototype.arrayBuffer=function(){this.finalize();var E=this.blockCount,H=this.s,R=this.outputBlocks,L=this.extraBytes,q=0,v=0,T=this.outputBits>>3,W;L?W=new ArrayBuffer(R+1<<2):W=new ArrayBuffer(T);for(var J=new Uint32Array(W);v<R;){for(q=0;q<E&&v<R;++q,++v)J[v]=H[q];v%E===0&&G(H)}return L&&(J[q]=H[q],W=W.slice(0,T)),W},D.prototype.buffer=D.prototype.arrayBuffer,D.prototype.digest=D.prototype.array=function(){this.finalize();for(var E=this.blockCount,H=this.s,R=this.outputBlocks,L=this.extraBytes,q=0,v=0,T=[],W,J;v<R;){for(q=0;q<E&&v<R;++q,++v)W=v<<2,J=H[q],T[W]=J&255,T[W+1]=J>>8&255,T[W+2]=J>>16&255,T[W+3]=J>>24&255;v%E===0&&G(H)}return L&&(W=v<<2,J=H[q],T[W]=J&255,L>1&&(T[W+1]=J>>8&255),L>2&&(T[W+2]=J>>16&255)),T};function K(E,H,R){D.call(this,E,H,R)}K.prototype=new D,K.prototype.finalize=function(){return this.encode(this.outputBits,!0),D.prototype.finalize.call(this)};var G=function(E){var H,R,L,q,v,T,W,J,X,se,ne,Me,Ce,ue,xe,Ae,re,ve,le,ee,de,fe,te,Ee,he,ae,Se,De,ce,Ie,We,Oe,Qe,He,Re,tt,rt,pe,Pe,Fe,ge,Le,Te,ye,Ue,ze,we,ke,Be,be,Ne,$e,_e,it,nt,qe,Ye,nr,sr,ar,or,cr,wt;for(L=0;L<48;L+=2)q=E[0]^E[10]^E[20]^E[30]^E[40],v=E[1]^E[11]^E[21]^E[31]^E[41],T=E[2]^E[12]^E[22]^E[32]^E[42],W=E[3]^E[13]^E[23]^E[33]^E[43],J=E[4]^E[14]^E[24]^E[34]^E[44],X=E[5]^E[15]^E[25]^E[35]^E[45],se=E[6]^E[16]^E[26]^E[36]^E[46],ne=E[7]^E[17]^E[27]^E[37]^E[47],Me=E[8]^E[18]^E[28]^E[38]^E[48],Ce=E[9]^E[19]^E[29]^E[39]^E[49],H=Me^(T<<1|W>>>31),R=Ce^(W<<1|T>>>31),E[0]^=H,E[1]^=R,E[10]^=H,E[11]^=R,E[20]^=H,E[21]^=R,E[30]^=H,E[31]^=R,E[40]^=H,E[41]^=R,H=q^(J<<1|X>>>31),R=v^(X<<1|J>>>31),E[2]^=H,E[3]^=R,E[12]^=H,E[13]^=R,E[22]^=H,E[23]^=R,E[32]^=H,E[33]^=R,E[42]^=H,E[43]^=R,H=T^(se<<1|ne>>>31),R=W^(ne<<1|se>>>31),E[4]^=H,E[5]^=R,E[14]^=H,E[15]^=R,E[24]^=H,E[25]^=R,E[34]^=H,E[35]^=R,E[44]^=H,E[45]^=R,H=J^(Me<<1|Ce>>>31),R=X^(Ce<<1|Me>>>31),E[6]^=H,E[7]^=R,E[16]^=H,E[17]^=R,E[26]^=H,E[27]^=R,E[36]^=H,E[37]^=R,E[46]^=H,E[47]^=R,H=se^(q<<1|v>>>31),R=ne^(v<<1|q>>>31),E[8]^=H,E[9]^=R,E[18]^=H,E[19]^=R,E[28]^=H,E[29]^=R,E[38]^=H,E[39]^=R,E[48]^=H,E[49]^=R,ue=E[0],xe=E[1],ze=E[11]<<4|E[10]>>>28,we=E[10]<<4|E[11]>>>28,De=E[20]<<3|E[21]>>>29,ce=E[21]<<3|E[20]>>>29,ar=E[31]<<9|E[30]>>>23,or=E[30]<<9|E[31]>>>23,Le=E[40]<<18|E[41]>>>14,Te=E[41]<<18|E[40]>>>14,He=E[2]<<1|E[3]>>>31,Re=E[3]<<1|E[2]>>>31,Ae=E[13]<<12|E[12]>>>20,re=E[12]<<12|E[13]>>>20,ke=E[22]<<10|E[23]>>>22,Be=E[23]<<10|E[22]>>>22,Ie=E[33]<<13|E[32]>>>19,We=E[32]<<13|E[33]>>>19,cr=E[42]<<2|E[43]>>>30,wt=E[43]<<2|E[42]>>>30,it=E[5]<<30|E[4]>>>2,nt=E[4]<<30|E[5]>>>2,tt=E[14]<<6|E[15]>>>26,rt=E[15]<<6|E[14]>>>26,ve=E[25]<<11|E[24]>>>21,le=E[24]<<11|E[25]>>>21,be=E[34]<<15|E[35]>>>17,Ne=E[35]<<15|E[34]>>>17,Oe=E[45]<<29|E[44]>>>3,Qe=E[44]<<29|E[45]>>>3,Ee=E[6]<<28|E[7]>>>4,he=E[7]<<28|E[6]>>>4,qe=E[17]<<23|E[16]>>>9,Ye=E[16]<<23|E[17]>>>9,pe=E[26]<<25|E[27]>>>7,Pe=E[27]<<25|E[26]>>>7,ee=E[36]<<21|E[37]>>>11,de=E[37]<<21|E[36]>>>11,$e=E[47]<<24|E[46]>>>8,_e=E[46]<<24|E[47]>>>8,ye=E[8]<<27|E[9]>>>5,Ue=E[9]<<27|E[8]>>>5,ae=E[18]<<20|E[19]>>>12,Se=E[19]<<20|E[18]>>>12,nr=E[29]<<7|E[28]>>>25,sr=E[28]<<7|E[29]>>>25,Fe=E[38]<<8|E[39]>>>24,ge=E[39]<<8|E[38]>>>24,fe=E[48]<<14|E[49]>>>18,te=E[49]<<14|E[48]>>>18,E[0]=ue^~Ae&ve,E[1]=xe^~re&le,E[10]=Ee^~ae&De,E[11]=he^~Se&ce,E[20]=He^~tt&pe,E[21]=Re^~rt&Pe,E[30]=ye^~ze&ke,E[31]=Ue^~we&Be,E[40]=it^~qe&nr,E[41]=nt^~Ye&sr,E[2]=Ae^~ve&ee,E[3]=re^~le&de,E[12]=ae^~De&Ie,E[13]=Se^~ce&We,E[22]=tt^~pe&Fe,E[23]=rt^~Pe&ge,E[32]=ze^~ke&be,E[33]=we^~Be&Ne,E[42]=qe^~nr&ar,E[43]=Ye^~sr&or,E[4]=ve^~ee&fe,E[5]=le^~de&te,E[14]=De^~Ie&Oe,E[15]=ce^~We&Qe,E[24]=pe^~Fe&Le,E[25]=Pe^~ge&Te,E[34]=ke^~be&$e,E[35]=Be^~Ne&_e,E[44]=nr^~ar&cr,E[45]=sr^~or&wt,E[6]=ee^~fe&ue,E[7]=de^~te&xe,E[16]=Ie^~Oe&Ee,E[17]=We^~Qe&he,E[26]=Fe^~Le&He,E[27]=ge^~Te&Re,E[36]=be^~$e&ye,E[37]=Ne^~_e&Ue,E[46]=ar^~cr&it,E[47]=or^~wt&nt,E[8]=fe^~ue&Ae,E[9]=te^~xe&re,E[18]=Oe^~Ee&ae,E[19]=Qe^~he&Se,E[28]=Le^~He&tt,E[29]=Te^~Re&rt,E[38]=$e^~ye&ze,E[39]=_e^~Ue&we,E[48]=cr^~it&qe,E[49]=wt^~nt&Ye,E[0]^=F[L],E[1]^=F[L+1]};if(c)t.exports=f;else for(w=0;w<p.length;++w)n[p[w]]=f[p[w]]})()})(Fu);var d6=Fu.exports;const l6="logger/5.7.0";let Lu=!1,Bu=!1;const Ca={debug:1,default:2,info:2,warning:3,error:4,off:5};let qu=Ca.default,oc=null;function p6(){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 Uu=p6();var cc;(function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"})(cc||(cc={}));var Rr;(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"})(Rr||(Rr={}));const zu="0123456789abcdef";class Ve{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,r){const i=e.toLowerCase();Ca[i]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(qu>Ca[i])&&console.log.apply(console,r)}debug(...e){this._log(Ve.levels.DEBUG,e)}info(...e){this._log(Ve.levels.INFO,e)}warn(...e){this._log(Ve.levels.WARNING,e)}makeError(e,r,i){if(Bu)return this.makeError("censored error",r,{});r||(r=Ve.errors.UNKNOWN_ERROR),i||(i={});const n=[];Object.keys(i).forEach(l=>{const u=i[l];try{if(u instanceof Uint8Array){let b="";for(let m=0;m<u.length;m++)b+=zu[u[m]>>4],b+=zu[u[m]&15];n.push(l+"=Uint8Array(0x"+b+")")}else n.push(l+"="+JSON.stringify(u))}catch{n.push(l+"="+JSON.stringify(i[l].toString()))}}),n.push(`code=${r}`),n.push(`version=${this.version}`);const s=e;let o="";switch(r){case Rr.NUMERIC_FAULT:{o="NUMERIC_FAULT";const l=e;switch(l){case"overflow":case"underflow":case"division-by-zero":o+="-"+l;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result";break}break}case Rr.CALL_EXCEPTION:case Rr.INSUFFICIENT_FUNDS:case Rr.MISSING_NEW:case Rr.NONCE_EXPIRED:case Rr.REPLACEMENT_UNDERPRICED:case Rr.TRANSACTION_REPLACED:case Rr.UNPREDICTABLE_GAS_LIMIT:o=r;break}o&&(e+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),n.length&&(e+=" ("+n.join(", ")+")");const c=new Error(e);return c.reason=s,c.code=r,Object.keys(i).forEach(function(l){c[l]=i[l]}),c}throwError(e,r,i){throw this.makeError(e,r,i)}throwArgumentError(e,r,i){return this.throwError(e,Ve.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){Uu&&this.throwError("platform missing String.prototype.normalize",Ve.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:Uu})}checkSafeUint53(e,r){typeof e=="number"&&(r==null&&(r="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(r,Ve.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(r,Ve.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,Ve.errors.MISSING_ARGUMENT,{count:e,expectedCount:r}),e>r&&this.throwError("too many arguments"+i,Ve.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:r})}checkNew(e,r){(e===Object||e==null)&&this.throwError("missing new",Ve.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",Ve.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",Ve.errors.MISSING_NEW,{name:r.name})}static globalLogger(){return oc||(oc=new Ve(l6)),oc}static setCensorship(e,r){if(!e&&r&&this.globalLogger().throwError("cannot permanently disable censorship",Ve.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),Lu){if(!e)return;this.globalLogger().throwError("error censorship permanent",Ve.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Bu=!!e,Lu=!!r}static setLogLevel(e){const r=Ca[e.toLowerCase()];if(r==null){Ve.globalLogger().warn("invalid log level - "+e);return}qu=r}static from(e){return new Ve(e)}}Ve.errors=Rr,Ve.levels=cc;const g6="bytes/5.7.0",mt=new Ve(g6);function ku(t){return!!t.toHexString}function jn(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return jn(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function b6(t){return dr(t)&&!(t.length%2)||Kn(t)}function $u(t){return typeof t=="number"&&t==t&&t%1===0}function Kn(t){if(t==null)return!1;if(t.constructor===Uint8Array)return!0;if(typeof t=="string"||!$u(t.length)||t.length<0)return!1;for(let e=0;e<t.length;e++){const r=t[e];if(!$u(r)||r<0||r>=256)return!1}return!0}function gt(t,e){if(e||(e={}),typeof t=="number"){mt.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),jn(new Uint8Array(r))}if(e.allowMissingPrefix&&typeof t=="string"&&t.substring(0,2)!=="0x"&&(t="0x"+t),ku(t)&&(t=t.toHexString()),dr(t)){let r=t.substring(2);r.length%2&&(e.hexPad==="left"?r="0"+r:e.hexPad==="right"?r+="0":mt.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 jn(new Uint8Array(i))}return Kn(t)?jn(new Uint8Array(t)):mt.throwArgumentError("invalid arrayify value","value",t)}function v6(t){const e=t.map(n=>gt(n)),r=e.reduce((n,s)=>n+s.length,0),i=new Uint8Array(r);return e.reduce((n,s)=>(i.set(s,n),n+s.length),0),jn(i)}function m6(t,e){t=gt(t),t.length>e&&mt.throwArgumentError("value out of range","value",arguments[0]);const r=new Uint8Array(e);return r.set(t,e-t.length),jn(r)}function dr(t,e){return!(typeof t!="string"||!t.match(/^0x[0-9A-Fa-f]*$/)||e&&t.length!==2+2*e)}const fc="0123456789abcdef";function Vt(t,e){if(e||(e={}),typeof t=="number"){mt.checkSafeUint53(t,"invalid hexlify value");let r="";for(;t;)r=fc[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),ku(t))return t.toHexString();if(dr(t))return t.length%2&&(e.hexPad==="left"?t="0x0"+t.substring(2):e.hexPad==="right"?t+="0":mt.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(Kn(t)){let r="0x";for(let i=0;i<t.length;i++){let n=t[i];r+=fc[(n&240)>>4]+fc[n&15]}return r}return mt.throwArgumentError("invalid hexlify value","value",t)}function y6(t){if(typeof t!="string")t=Vt(t);else if(!dr(t)||t.length%2)return null;return(t.length-2)/2}function ju(t,e,r){return typeof t!="string"?t=Vt(t):(!dr(t)||t.length%2)&&mt.throwArgumentError("invalid hexData","value",t),e=2+2*e,r!=null?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}function Yr(t,e){for(typeof t!="string"?t=Vt(t):dr(t)||mt.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&mt.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}function Ku(t){const e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(b6(t)){let r=gt(t);r.length===64?(e.v=27+(r[32]>>7),r[32]&=127,e.r=Vt(r.slice(0,32)),e.s=Vt(r.slice(32,64))):r.length===65?(e.r=Vt(r.slice(0,32)),e.s=Vt(r.slice(32,64)),e.v=r[64]):mt.throwArgumentError("invalid signature string","signature",t),e.v<27&&(e.v===0||e.v===1?e.v+=27:mt.throwArgumentError("signature invalid v byte","signature",t)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(r[32]|=128),e._vs=Vt(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=m6(gt(e._vs),32);e._vs=Vt(n);const s=n[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=s:e.recoveryParam!==s&&mt.throwArgumentError("signature recoveryParam mismatch _vs","signature",t),n[0]&=127;const o=Vt(n);e.s==null?e.s=o:e.s!==o&&mt.throwArgumentError("signature v mismatch _vs","signature",t)}if(e.recoveryParam==null)e.v==null?mt.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&&mt.throwArgumentError("signature recoveryParam mismatch v","signature",t)}e.r==null||!dr(e.r)?mt.throwArgumentError("signature missing or invalid r","signature",t):e.r=Yr(e.r,32),e.s==null||!dr(e.s)?mt.throwArgumentError("signature missing or invalid s","signature",t):e.s=Yr(e.s,32);const r=gt(e.s);r[0]>=128&&mt.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(r[0]|=128);const i=Vt(r);e._vs&&(dr(e._vs)||mt.throwArgumentError("signature invalid _vs","signature",t),e._vs=Yr(e._vs,32)),e._vs==null?e._vs=i:e._vs!==i&&mt.throwArgumentError("signature _vs mismatch v and s","signature",t)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}function hc(t){return"0x"+d6.keccak_256(gt(t))}var Hu={exports:{}},w6={},_6=Object.freeze({__proto__:null,default:w6}),A6=u6(_6);(function(t){(function(e,r){function i(a,f){if(!a)throw new Error(f||"Assertion failed")}function n(a,f){a.super_=f;var p=function(){};p.prototype=f.prototype,a.prototype=new p,a.prototype.constructor=a}function s(a,f,p){if(s.isBN(a))return a;this.negative=0,this.words=null,this.length=0,this.red=null,a!==null&&((f==="le"||f==="be")&&(p=f,f=10),this._init(a||0,f||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=A6.Buffer}catch{}s.isBN=function(a){return a instanceof s?!0:a!==null&&typeof a=="object"&&a.constructor.wordSize===s.wordSize&&Array.isArray(a.words)},s.max=function(a,f){return a.cmp(f)>0?a:f},s.min=function(a,f){return a.cmp(f)<0?a:f},s.prototype._init=function(a,f,p){if(typeof a=="number")return this._initNumber(a,f,p);if(typeof a=="object")return this._initArray(a,f,p);f==="hex"&&(f=16),i(f===(f|0)&&f>=2&&f<=36),a=a.toString().replace(/\s+/g,"");var w=0;a[0]==="-"&&(w++,this.negative=1),w<a.length&&(f===16?this._parseHex(a,w,p):(this._parseBase(a,f,w),p==="le"&&this._initArray(this.toArray(),f,p)))},s.prototype._initNumber=function(a,f,p){a<0&&(this.negative=1,a=-a),a<67108864?(this.words=[a&67108863],this.length=1):a<4503599627370496?(this.words=[a&67108863,a/67108864&67108863],this.length=2):(i(a<9007199254740992),this.words=[a&67108863,a/67108864&67108863,1],this.length=3),p==="le"&&this._initArray(this.toArray(),f,p)},s.prototype._initArray=function(a,f,p){if(i(typeof a.length=="number"),a.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(a.length/3),this.words=new Array(this.length);for(var w=0;w<this.length;w++)this.words[w]=0;var A,x,_=0;if(p==="be")for(w=a.length-1,A=0;w>=0;w-=3)x=a[w]|a[w-1]<<8|a[w-2]<<16,this.words[A]|=x<<_&67108863,this.words[A+1]=x>>>26-_&67108863,_+=24,_>=26&&(_-=26,A++);else if(p==="le")for(w=0,A=0;w<a.length;w+=3)x=a[w]|a[w+1]<<8|a[w+2]<<16,this.words[A]|=x<<_&67108863,this.words[A+1]=x>>>26-_&67108863,_+=24,_>=26&&(_-=26,A++);return this._strip()};function c(a,f){var p=a.charCodeAt(f);if(p>=48&&p<=57)return p-48;if(p>=65&&p<=70)return p-55;if(p>=97&&p<=102)return p-87;i(!1,"Invalid character in "+a)}function l(a,f,p){var w=c(a,p);return p-1>=f&&(w|=c(a,p-1)<<4),w}s.prototype._parseHex=function(a,f,p){this.length=Math.ceil((a.length-f)/6),this.words=new Array(this.length);for(var w=0;w<this.length;w++)this.words[w]=0;var A=0,x=0,_;if(p==="be")for(w=a.length-1;w>=f;w-=2)_=l(a,f,w)<<A,this.words[x]|=_&67108863,A>=18?(A-=18,x+=1,this.words[x]|=_>>>26):A+=8;else{var h=a.length-f;for(w=h%2===0?f+1:f;w<a.length;w+=2)_=l(a,f,w)<<A,this.words[x]|=_&67108863,A>=18?(A-=18,x+=1,this.words[x]|=_>>>26):A+=8}this._strip()};function u(a,f,p,w){for(var A=0,x=0,_=Math.min(a.length,p),h=f;h<_;h++){var d=a.charCodeAt(h)-48;A*=w,d>=49?x=d-49+10:d>=17?x=d-17+10:x=d,i(d>=0&&x<w,"Invalid character"),A+=x}return A}s.prototype._parseBase=function(a,f,p){this.words=[0],this.length=1;for(var w=0,A=1;A<=67108863;A*=f)w++;w--,A=A/f|0;for(var x=a.length-p,_=x%w,h=Math.min(x,x-_)+p,d=0,D=p;D<h;D+=w)d=u(a,D,D+w,f),this.imuln(A),this.words[0]+d<67108864?this.words[0]+=d:this._iaddn(d);if(_!==0){var K=1;for(d=u(a,D,a.length,f),D=0;D<_;D++)K*=f;this.imuln(K),this.words[0]+d<67108864?this.words[0]+=d:this._iaddn(d)}this._strip()},s.prototype.copy=function(a){a.words=new Array(this.length);for(var f=0;f<this.length;f++)a.words[f]=this.words[f];a.length=this.length,a.negative=this.negative,a.red=this.red};function b(a,f){a.words=f.words,a.length=f.length,a.negative=f.negative,a.red=f.red}if(s.prototype._move=function(a){b(a,this)},s.prototype.clone=function(){var a=new s(null);return this.copy(a),a},s.prototype._expand=function(a){for(;this.length<a;)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")]=m}catch{s.prototype.inspect=m}else s.prototype.inspect=m;function m(){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"],S=[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],I=[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(a,f){a=a||10,f=f|0||1;var p;if(a===16||a==="hex"){p="";for(var w=0,A=0,x=0;x<this.length;x++){var _=this.words[x],h=((_<<w|A)&16777215).toString(16);A=_>>>24-w&16777215,w+=2,w>=26&&(w-=26,x--),A!==0||x!==this.length-1?p=M[6-h.length]+h+p:p=h+p}for(A!==0&&(p=A.toString(16)+p);p.length%f!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}if(a===(a|0)&&a>=2&&a<=36){var d=S[a],D=I[a];p="";var K=this.clone();for(K.negative=0;!K.isZero();){var G=K.modrn(D).toString(a);K=K.idivn(D),K.isZero()?p=G+p:p=M[d-G.length]+G+p}for(this.isZero()&&(p="0"+p);p.length%f!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}i(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var a=this.words[0];return this.length===2?a+=this.words[1]*67108864:this.length===3&&this.words[2]===1?a+=4503599627370496+this.words[1]*67108864:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-a:a},s.prototype.toJSON=function(){return this.toString(16,2)},o&&(s.prototype.toBuffer=function(a,f){return this.toArrayLike(o,a,f)}),s.prototype.toArray=function(a,f){return this.toArrayLike(Array,a,f)};var F=function(a,f){return a.allocUnsafe?a.allocUnsafe(f):new a(f)};s.prototype.toArrayLike=function(a,f,p){this._strip();var w=this.byteLength(),A=p||Math.max(1,w);i(w<=A,"byte array longer than desired length"),i(A>0,"Requested array length <= 0");var x=F(a,A),_=f==="le"?"LE":"BE";return this["_toArrayLike"+_](x,w),x},s.prototype._toArrayLikeLE=function(a,f){for(var p=0,w=0,A=0,x=0;A<this.length;A++){var _=this.words[A]<<x|w;a[p++]=_&255,p<a.length&&(a[p++]=_>>8&255),p<a.length&&(a[p++]=_>>16&255),x===6?(p<a.length&&(a[p++]=_>>24&255),w=0,x=0):(w=_>>>24,x+=2)}if(p<a.length)for(a[p++]=w;p<a.length;)a[p++]=0},s.prototype._toArrayLikeBE=function(a,f){for(var p=a.length-1,w=0,A=0,x=0;A<this.length;A++){var _=this.words[A]<<x|w;a[p--]=_&255,p>=0&&(a[p--]=_>>8&255),p>=0&&(a[p--]=_>>16&255),x===6?(p>=0&&(a[p--]=_>>24&255),w=0,x=0):(w=_>>>24,x+=2)}if(p>=0)for(a[p--]=w;p>=0;)a[p--]=0},Math.clz32?s.prototype._countBits=function(a){return 32-Math.clz32(a)}:s.prototype._countBits=function(a){var f=a,p=0;return f>=4096&&(p+=13,f>>>=13),f>=64&&(p+=7,f>>>=7),f>=8&&(p+=4,f>>>=4),f>=2&&(p+=2,f>>>=2),p+f},s.prototype._zeroBits=function(a){if(a===0)return 26;var f=a,p=0;return f&8191||(p+=13,f>>>=13),f&127||(p+=7,f>>>=7),f&15||(p+=4,f>>>=4),f&3||(p+=2,f>>>=2),f&1||p++,p},s.prototype.bitLength=function(){var a=this.words[this.length-1],f=this._countBits(a);return(this.length-1)*26+f};function k(a){for(var f=new Array(a.bitLength()),p=0;p<f.length;p++){var w=p/26|0,A=p%26;f[p]=a.words[w]>>>A&1}return f}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var a=0,f=0;f<this.length;f++){var p=this._zeroBits(this.words[f]);if(a+=p,p!==26)break}return a},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(a){return this.negative!==0?this.abs().inotn(a).iaddn(1):this.clone()},s.prototype.fromTwos=function(a){return this.testn(a-1)?this.notn(a).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(a){for(;this.length<a.length;)this.words[this.length++]=0;for(var f=0;f<a.length;f++)this.words[f]=this.words[f]|a.words[f];return this._strip()},s.prototype.ior=function(a){return i((this.negative|a.negative)===0),this.iuor(a)},s.prototype.or=function(a){return this.length>a.length?this.clone().ior(a):a.clone().ior(this)},s.prototype.uor=function(a){return this.length>a.length?this.clone().iuor(a):a.clone().iuor(this)},s.prototype.iuand=function(a){var f;this.length>a.length?f=a:f=this;for(var p=0;p<f.length;p++)this.words[p]=this.words[p]&a.words[p];return this.length=f.length,this._strip()},s.prototype.iand=function(a){return i((this.negative|a.negative)===0),this.iuand(a)},s.prototype.and=function(a){return this.length>a.length?this.clone().iand(a):a.clone().iand(this)},s.prototype.uand=function(a){return this.length>a.length?this.clone().iuand(a):a.clone().iuand(this)},s.prototype.iuxor=function(a){var f,p;this.length>a.length?(f=this,p=a):(f=a,p=this);for(var w=0;w<p.length;w++)this.words[w]=f.words[w]^p.words[w];if(this!==f)for(;w<f.length;w++)this.words[w]=f.words[w];return this.length=f.length,this._strip()},s.prototype.ixor=function(a){return i((this.negative|a.negative)===0),this.iuxor(a)},s.prototype.xor=function(a){return this.length>a.length?this.clone().ixor(a):a.clone().ixor(this)},s.prototype.uxor=function(a){return this.length>a.length?this.clone().iuxor(a):a.clone().iuxor(this)},s.prototype.inotn=function(a){i(typeof a=="number"&&a>=0);var f=Math.ceil(a/26)|0,p=a%26;this._expand(f),p>0&&f--;for(var w=0;w<f;w++)this.words[w]=~this.words[w]&67108863;return p>0&&(this.words[w]=~this.words[w]&67108863>>26-p),this._strip()},s.prototype.notn=function(a){return this.clone().inotn(a)},s.prototype.setn=function(a,f){i(typeof a=="number"&&a>=0);var p=a/26|0,w=a%26;return this._expand(p+1),f?this.words[p]=this.words[p]|1<<w:this.words[p]=this.words[p]&~(1<<w),this._strip()},s.prototype.iadd=function(a){var f;if(this.negative!==0&&a.negative===0)return this.negative=0,f=this.isub(a),this.negative^=1,this._normSign();if(this.negative===0&&a.negative!==0)return a.negative=0,f=this.isub(a),a.negative=1,f._normSign();var p,w;this.length>a.length?(p=this,w=a):(p=a,w=this);for(var A=0,x=0;x<w.length;x++)f=(p.words[x]|0)+(w.words[x]|0)+A,this.words[x]=f&67108863,A=f>>>26;for(;A!==0&&x<p.length;x++)f=(p.words[x]|0)+A,this.words[x]=f&67108863,A=f>>>26;if(this.length=p.length,A!==0)this.words[this.length]=A,this.length++;else if(p!==this)for(;x<p.length;x++)this.words[x]=p.words[x];return this},s.prototype.add=function(a){var f;return a.negative!==0&&this.negative===0?(a.negative=0,f=this.sub(a),a.negative^=1,f):a.negative===0&&this.negative!==0?(this.negative=0,f=a.sub(this),this.negative=1,f):this.length>a.length?this.clone().iadd(a):a.clone().iadd(this)},s.prototype.isub=function(a){if(a.negative!==0){a.negative=0;var f=this.iadd(a);return a.negative=1,f._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(a),this.negative=1,this._normSign();var p=this.cmp(a);if(p===0)return this.negative=0,this.length=1,this.words[0]=0,this;var w,A;p>0?(w=this,A=a):(w=a,A=this);for(var x=0,_=0;_<A.length;_++)f=(w.words[_]|0)-(A.words[_]|0)+x,x=f>>26,this.words[_]=f&67108863;for(;x!==0&&_<w.length;_++)f=(w.words[_]|0)+x,x=f>>26,this.words[_]=f&67108863;if(x===0&&_<w.length&&w!==this)for(;_<w.length;_++)this.words[_]=w.words[_];return this.length=Math.max(this.length,_),w!==this&&(this.negative=1),this._strip()},s.prototype.sub=function(a){return this.clone().isub(a)};function j(a,f,p){p.negative=f.negative^a.negative;var w=a.length+f.length|0;p.length=w,w=w-1|0;var A=a.words[0]|0,x=f.words[0]|0,_=A*x,h=_&67108863,d=_/67108864|0;p.words[0]=h;for(var D=1;D<w;D++){for(var K=d>>>26,G=d&67108863,E=Math.min(D,f.length-1),H=Math.max(0,D-a.length+1);H<=E;H++){var R=D-H|0;A=a.words[R]|0,x=f.words[H]|0,_=A*x+G,K+=_/67108864|0,G=_&67108863}p.words[D]=G|0,d=K|0}return d!==0?p.words[D]=d|0:p.length--,p._strip()}var C=function(a,f,p){var w=a.words,A=f.words,x=p.words,_=0,h,d,D,K=w[0]|0,G=K&8191,E=K>>>13,H=w[1]|0,R=H&8191,L=H>>>13,q=w[2]|0,v=q&8191,T=q>>>13,W=w[3]|0,J=W&8191,X=W>>>13,se=w[4]|0,ne=se&8191,Me=se>>>13,Ce=w[5]|0,ue=Ce&8191,xe=Ce>>>13,Ae=w[6]|0,re=Ae&8191,ve=Ae>>>13,le=w[7]|0,ee=le&8191,de=le>>>13,fe=w[8]|0,te=fe&8191,Ee=fe>>>13,he=w[9]|0,ae=he&8191,Se=he>>>13,De=A[0]|0,ce=De&8191,Ie=De>>>13,We=A[1]|0,Oe=We&8191,Qe=We>>>13,He=A[2]|0,Re=He&8191,tt=He>>>13,rt=A[3]|0,pe=rt&8191,Pe=rt>>>13,Fe=A[4]|0,ge=Fe&8191,Le=Fe>>>13,Te=A[5]|0,ye=Te&8191,Ue=Te>>>13,ze=A[6]|0,we=ze&8191,ke=ze>>>13,Be=A[7]|0,be=Be&8191,Ne=Be>>>13,$e=A[8]|0,_e=$e&8191,it=$e>>>13,nt=A[9]|0,qe=nt&8191,Ye=nt>>>13;p.negative=a.negative^f.negative,p.length=19,h=Math.imul(G,ce),d=Math.imul(G,Ie),d=d+Math.imul(E,ce)|0,D=Math.imul(E,Ie);var nr=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(nr>>>26)|0,nr&=67108863,h=Math.imul(R,ce),d=Math.imul(R,Ie),d=d+Math.imul(L,ce)|0,D=Math.imul(L,Ie),h=h+Math.imul(G,Oe)|0,d=d+Math.imul(G,Qe)|0,d=d+Math.imul(E,Oe)|0,D=D+Math.imul(E,Qe)|0;var sr=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(sr>>>26)|0,sr&=67108863,h=Math.imul(v,ce),d=Math.imul(v,Ie),d=d+Math.imul(T,ce)|0,D=Math.imul(T,Ie),h=h+Math.imul(R,Oe)|0,d=d+Math.imul(R,Qe)|0,d=d+Math.imul(L,Oe)|0,D=D+Math.imul(L,Qe)|0,h=h+Math.imul(G,Re)|0,d=d+Math.imul(G,tt)|0,d=d+Math.imul(E,Re)|0,D=D+Math.imul(E,tt)|0;var ar=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(ar>>>26)|0,ar&=67108863,h=Math.imul(J,ce),d=Math.imul(J,Ie),d=d+Math.imul(X,ce)|0,D=Math.imul(X,Ie),h=h+Math.imul(v,Oe)|0,d=d+Math.imul(v,Qe)|0,d=d+Math.imul(T,Oe)|0,D=D+Math.imul(T,Qe)|0,h=h+Math.imul(R,Re)|0,d=d+Math.imul(R,tt)|0,d=d+Math.imul(L,Re)|0,D=D+Math.imul(L,tt)|0,h=h+Math.imul(G,pe)|0,d=d+Math.imul(G,Pe)|0,d=d+Math.imul(E,pe)|0,D=D+Math.imul(E,Pe)|0;var or=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(or>>>26)|0,or&=67108863,h=Math.imul(ne,ce),d=Math.imul(ne,Ie),d=d+Math.imul(Me,ce)|0,D=Math.imul(Me,Ie),h=h+Math.imul(J,Oe)|0,d=d+Math.imul(J,Qe)|0,d=d+Math.imul(X,Oe)|0,D=D+Math.imul(X,Qe)|0,h=h+Math.imul(v,Re)|0,d=d+Math.imul(v,tt)|0,d=d+Math.imul(T,Re)|0,D=D+Math.imul(T,tt)|0,h=h+Math.imul(R,pe)|0,d=d+Math.imul(R,Pe)|0,d=d+Math.imul(L,pe)|0,D=D+Math.imul(L,Pe)|0,h=h+Math.imul(G,ge)|0,d=d+Math.imul(G,Le)|0,d=d+Math.imul(E,ge)|0,D=D+Math.imul(E,Le)|0;var cr=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(cr>>>26)|0,cr&=67108863,h=Math.imul(ue,ce),d=Math.imul(ue,Ie),d=d+Math.imul(xe,ce)|0,D=Math.imul(xe,Ie),h=h+Math.imul(ne,Oe)|0,d=d+Math.imul(ne,Qe)|0,d=d+Math.imul(Me,Oe)|0,D=D+Math.imul(Me,Qe)|0,h=h+Math.imul(J,Re)|0,d=d+Math.imul(J,tt)|0,d=d+Math.imul(X,Re)|0,D=D+Math.imul(X,tt)|0,h=h+Math.imul(v,pe)|0,d=d+Math.imul(v,Pe)|0,d=d+Math.imul(T,pe)|0,D=D+Math.imul(T,Pe)|0,h=h+Math.imul(R,ge)|0,d=d+Math.imul(R,Le)|0,d=d+Math.imul(L,ge)|0,D=D+Math.imul(L,Le)|0,h=h+Math.imul(G,ye)|0,d=d+Math.imul(G,Ue)|0,d=d+Math.imul(E,ye)|0,D=D+Math.imul(E,Ue)|0;var wt=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(wt>>>26)|0,wt&=67108863,h=Math.imul(re,ce),d=Math.imul(re,Ie),d=d+Math.imul(ve,ce)|0,D=Math.imul(ve,Ie),h=h+Math.imul(ue,Oe)|0,d=d+Math.imul(ue,Qe)|0,d=d+Math.imul(xe,Oe)|0,D=D+Math.imul(xe,Qe)|0,h=h+Math.imul(ne,Re)|0,d=d+Math.imul(ne,tt)|0,d=d+Math.imul(Me,Re)|0,D=D+Math.imul(Me,tt)|0,h=h+Math.imul(J,pe)|0,d=d+Math.imul(J,Pe)|0,d=d+Math.imul(X,pe)|0,D=D+Math.imul(X,Pe)|0,h=h+Math.imul(v,ge)|0,d=d+Math.imul(v,Le)|0,d=d+Math.imul(T,ge)|0,D=D+Math.imul(T,Le)|0,h=h+Math.imul(R,ye)|0,d=d+Math.imul(R,Ue)|0,d=d+Math.imul(L,ye)|0,D=D+Math.imul(L,Ue)|0,h=h+Math.imul(G,we)|0,d=d+Math.imul(G,ke)|0,d=d+Math.imul(E,we)|0,D=D+Math.imul(E,ke)|0;var Ei=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(Ei>>>26)|0,Ei&=67108863,h=Math.imul(ee,ce),d=Math.imul(ee,Ie),d=d+Math.imul(de,ce)|0,D=Math.imul(de,Ie),h=h+Math.imul(re,Oe)|0,d=d+Math.imul(re,Qe)|0,d=d+Math.imul(ve,Oe)|0,D=D+Math.imul(ve,Qe)|0,h=h+Math.imul(ue,Re)|0,d=d+Math.imul(ue,tt)|0,d=d+Math.imul(xe,Re)|0,D=D+Math.imul(xe,tt)|0,h=h+Math.imul(ne,pe)|0,d=d+Math.imul(ne,Pe)|0,d=d+Math.imul(Me,pe)|0,D=D+Math.imul(Me,Pe)|0,h=h+Math.imul(J,ge)|0,d=d+Math.imul(J,Le)|0,d=d+Math.imul(X,ge)|0,D=D+Math.imul(X,Le)|0,h=h+Math.imul(v,ye)|0,d=d+Math.imul(v,Ue)|0,d=d+Math.imul(T,ye)|0,D=D+Math.imul(T,Ue)|0,h=h+Math.imul(R,we)|0,d=d+Math.imul(R,ke)|0,d=d+Math.imul(L,we)|0,D=D+Math.imul(L,ke)|0,h=h+Math.imul(G,be)|0,d=d+Math.imul(G,Ne)|0,d=d+Math.imul(E,be)|0,D=D+Math.imul(E,Ne)|0;var xi=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(xi>>>26)|0,xi&=67108863,h=Math.imul(te,ce),d=Math.imul(te,Ie),d=d+Math.imul(Ee,ce)|0,D=Math.imul(Ee,Ie),h=h+Math.imul(ee,Oe)|0,d=d+Math.imul(ee,Qe)|0,d=d+Math.imul(de,Oe)|0,D=D+Math.imul(de,Qe)|0,h=h+Math.imul(re,Re)|0,d=d+Math.imul(re,tt)|0,d=d+Math.imul(ve,Re)|0,D=D+Math.imul(ve,tt)|0,h=h+Math.imul(ue,pe)|0,d=d+Math.imul(ue,Pe)|0,d=d+Math.imul(xe,pe)|0,D=D+Math.imul(xe,Pe)|0,h=h+Math.imul(ne,ge)|0,d=d+Math.imul(ne,Le)|0,d=d+Math.imul(Me,ge)|0,D=D+Math.imul(Me,Le)|0,h=h+Math.imul(J,ye)|0,d=d+Math.imul(J,Ue)|0,d=d+Math.imul(X,ye)|0,D=D+Math.imul(X,Ue)|0,h=h+Math.imul(v,we)|0,d=d+Math.imul(v,ke)|0,d=d+Math.imul(T,we)|0,D=D+Math.imul(T,ke)|0,h=h+Math.imul(R,be)|0,d=d+Math.imul(R,Ne)|0,d=d+Math.imul(L,be)|0,D=D+Math.imul(L,Ne)|0,h=h+Math.imul(G,_e)|0,d=d+Math.imul(G,it)|0,d=d+Math.imul(E,_e)|0,D=D+Math.imul(E,it)|0;var Si=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(Si>>>26)|0,Si&=67108863,h=Math.imul(ae,ce),d=Math.imul(ae,Ie),d=d+Math.imul(Se,ce)|0,D=Math.imul(Se,Ie),h=h+Math.imul(te,Oe)|0,d=d+Math.imul(te,Qe)|0,d=d+Math.imul(Ee,Oe)|0,D=D+Math.imul(Ee,Qe)|0,h=h+Math.imul(ee,Re)|0,d=d+Math.imul(ee,tt)|0,d=d+Math.imul(de,Re)|0,D=D+Math.imul(de,tt)|0,h=h+Math.imul(re,pe)|0,d=d+Math.imul(re,Pe)|0,d=d+Math.imul(ve,pe)|0,D=D+Math.imul(ve,Pe)|0,h=h+Math.imul(ue,ge)|0,d=d+Math.imul(ue,Le)|0,d=d+Math.imul(xe,ge)|0,D=D+Math.imul(xe,Le)|0,h=h+Math.imul(ne,ye)|0,d=d+Math.imul(ne,Ue)|0,d=d+Math.imul(Me,ye)|0,D=D+Math.imul(Me,Ue)|0,h=h+Math.imul(J,we)|0,d=d+Math.imul(J,ke)|0,d=d+Math.imul(X,we)|0,D=D+Math.imul(X,ke)|0,h=h+Math.imul(v,be)|0,d=d+Math.imul(v,Ne)|0,d=d+Math.imul(T,be)|0,D=D+Math.imul(T,Ne)|0,h=h+Math.imul(R,_e)|0,d=d+Math.imul(R,it)|0,d=d+Math.imul(L,_e)|0,D=D+Math.imul(L,it)|0,h=h+Math.imul(G,qe)|0,d=d+Math.imul(G,Ye)|0,d=d+Math.imul(E,qe)|0,D=D+Math.imul(E,Ye)|0;var Mi=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(Mi>>>26)|0,Mi&=67108863,h=Math.imul(ae,Oe),d=Math.imul(ae,Qe),d=d+Math.imul(Se,Oe)|0,D=Math.imul(Se,Qe),h=h+Math.imul(te,Re)|0,d=d+Math.imul(te,tt)|0,d=d+Math.imul(Ee,Re)|0,D=D+Math.imul(Ee,tt)|0,h=h+Math.imul(ee,pe)|0,d=d+Math.imul(ee,Pe)|0,d=d+Math.imul(de,pe)|0,D=D+Math.imul(de,Pe)|0,h=h+Math.imul(re,ge)|0,d=d+Math.imul(re,Le)|0,d=d+Math.imul(ve,ge)|0,D=D+Math.imul(ve,Le)|0,h=h+Math.imul(ue,ye)|0,d=d+Math.imul(ue,Ue)|0,d=d+Math.imul(xe,ye)|0,D=D+Math.imul(xe,Ue)|0,h=h+Math.imul(ne,we)|0,d=d+Math.imul(ne,ke)|0,d=d+Math.imul(Me,we)|0,D=D+Math.imul(Me,ke)|0,h=h+Math.imul(J,be)|0,d=d+Math.imul(J,Ne)|0,d=d+Math.imul(X,be)|0,D=D+Math.imul(X,Ne)|0,h=h+Math.imul(v,_e)|0,d=d+Math.imul(v,it)|0,d=d+Math.imul(T,_e)|0,D=D+Math.imul(T,it)|0,h=h+Math.imul(R,qe)|0,d=d+Math.imul(R,Ye)|0,d=d+Math.imul(L,qe)|0,D=D+Math.imul(L,Ye)|0;var Ii=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(Ii>>>26)|0,Ii&=67108863,h=Math.imul(ae,Re),d=Math.imul(ae,tt),d=d+Math.imul(Se,Re)|0,D=Math.imul(Se,tt),h=h+Math.imul(te,pe)|0,d=d+Math.imul(te,Pe)|0,d=d+Math.imul(Ee,pe)|0,D=D+Math.imul(Ee,Pe)|0,h=h+Math.imul(ee,ge)|0,d=d+Math.imul(ee,Le)|0,d=d+Math.imul(de,ge)|0,D=D+Math.imul(de,Le)|0,h=h+Math.imul(re,ye)|0,d=d+Math.imul(re,Ue)|0,d=d+Math.imul(ve,ye)|0,D=D+Math.imul(ve,Ue)|0,h=h+Math.imul(ue,we)|0,d=d+Math.imul(ue,ke)|0,d=d+Math.imul(xe,we)|0,D=D+Math.imul(xe,ke)|0,h=h+Math.imul(ne,be)|0,d=d+Math.imul(ne,Ne)|0,d=d+Math.imul(Me,be)|0,D=D+Math.imul(Me,Ne)|0,h=h+Math.imul(J,_e)|0,d=d+Math.imul(J,it)|0,d=d+Math.imul(X,_e)|0,D=D+Math.imul(X,it)|0,h=h+Math.imul(v,qe)|0,d=d+Math.imul(v,Ye)|0,d=d+Math.imul(T,qe)|0,D=D+Math.imul(T,Ye)|0;var Sr=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(Sr>>>26)|0,Sr&=67108863,h=Math.imul(ae,pe),d=Math.imul(ae,Pe),d=d+Math.imul(Se,pe)|0,D=Math.imul(Se,Pe),h=h+Math.imul(te,ge)|0,d=d+Math.imul(te,Le)|0,d=d+Math.imul(Ee,ge)|0,D=D+Math.imul(Ee,Le)|0,h=h+Math.imul(ee,ye)|0,d=d+Math.imul(ee,Ue)|0,d=d+Math.imul(de,ye)|0,D=D+Math.imul(de,Ue)|0,h=h+Math.imul(re,we)|0,d=d+Math.imul(re,ke)|0,d=d+Math.imul(ve,we)|0,D=D+Math.imul(ve,ke)|0,h=h+Math.imul(ue,be)|0,d=d+Math.imul(ue,Ne)|0,d=d+Math.imul(xe,be)|0,D=D+Math.imul(xe,Ne)|0,h=h+Math.imul(ne,_e)|0,d=d+Math.imul(ne,it)|0,d=d+Math.imul(Me,_e)|0,D=D+Math.imul(Me,it)|0,h=h+Math.imul(J,qe)|0,d=d+Math.imul(J,Ye)|0,d=d+Math.imul(X,qe)|0,D=D+Math.imul(X,Ye)|0;var Di=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(Di>>>26)|0,Di&=67108863,h=Math.imul(ae,ge),d=Math.imul(ae,Le),d=d+Math.imul(Se,ge)|0,D=Math.imul(Se,Le),h=h+Math.imul(te,ye)|0,d=d+Math.imul(te,Ue)|0,d=d+Math.imul(Ee,ye)|0,D=D+Math.imul(Ee,Ue)|0,h=h+Math.imul(ee,we)|0,d=d+Math.imul(ee,ke)|0,d=d+Math.imul(de,we)|0,D=D+Math.imul(de,ke)|0,h=h+Math.imul(re,be)|0,d=d+Math.imul(re,Ne)|0,d=d+Math.imul(ve,be)|0,D=D+Math.imul(ve,Ne)|0,h=h+Math.imul(ue,_e)|0,d=d+Math.imul(ue,it)|0,d=d+Math.imul(xe,_e)|0,D=D+Math.imul(xe,it)|0,h=h+Math.imul(ne,qe)|0,d=d+Math.imul(ne,Ye)|0,d=d+Math.imul(Me,qe)|0,D=D+Math.imul(Me,Ye)|0;var Oi=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(Oi>>>26)|0,Oi&=67108863,h=Math.imul(ae,ye),d=Math.imul(ae,Ue),d=d+Math.imul(Se,ye)|0,D=Math.imul(Se,Ue),h=h+Math.imul(te,we)|0,d=d+Math.imul(te,ke)|0,d=d+Math.imul(Ee,we)|0,D=D+Math.imul(Ee,ke)|0,h=h+Math.imul(ee,be)|0,d=d+Math.imul(ee,Ne)|0,d=d+Math.imul(de,be)|0,D=D+Math.imul(de,Ne)|0,h=h+Math.imul(re,_e)|0,d=d+Math.imul(re,it)|0,d=d+Math.imul(ve,_e)|0,D=D+Math.imul(ve,it)|0,h=h+Math.imul(ue,qe)|0,d=d+Math.imul(ue,Ye)|0,d=d+Math.imul(xe,qe)|0,D=D+Math.imul(xe,Ye)|0;var $t=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+($t>>>26)|0,$t&=67108863,h=Math.imul(ae,we),d=Math.imul(ae,ke),d=d+Math.imul(Se,we)|0,D=Math.imul(Se,ke),h=h+Math.imul(te,be)|0,d=d+Math.imul(te,Ne)|0,d=d+Math.imul(Ee,be)|0,D=D+Math.imul(Ee,Ne)|0,h=h+Math.imul(ee,_e)|0,d=d+Math.imul(ee,it)|0,d=d+Math.imul(de,_e)|0,D=D+Math.imul(de,it)|0,h=h+Math.imul(re,qe)|0,d=d+Math.imul(re,Ye)|0,d=d+Math.imul(ve,qe)|0,D=D+Math.imul(ve,Ye)|0;var Ri=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(Ri>>>26)|0,Ri&=67108863,h=Math.imul(ae,be),d=Math.imul(ae,Ne),d=d+Math.imul(Se,be)|0,D=Math.imul(Se,Ne),h=h+Math.imul(te,_e)|0,d=d+Math.imul(te,it)|0,d=d+Math.imul(Ee,_e)|0,D=D+Math.imul(Ee,it)|0,h=h+Math.imul(ee,qe)|0,d=d+Math.imul(ee,Ye)|0,d=d+Math.imul(de,qe)|0,D=D+Math.imul(de,Ye)|0;var Ni=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(Ni>>>26)|0,Ni&=67108863,h=Math.imul(ae,_e),d=Math.imul(ae,it),d=d+Math.imul(Se,_e)|0,D=Math.imul(Se,it),h=h+Math.imul(te,qe)|0,d=d+Math.imul(te,Ye)|0,d=d+Math.imul(Ee,qe)|0,D=D+Math.imul(Ee,Ye)|0;var Pi=(_+h|0)+((d&8191)<<13)|0;_=(D+(d>>>13)|0)+(Pi>>>26)|0,Pi&=67108863,h=Math.imul(ae,qe),d=Math.imul(ae,Ye),d=d+Math.imul(Se,qe)|0,D=Math.imul(Se,Ye);var Vs=(_+h|0)+((d&8191)<<13)|0;return _=(D+(d>>>13)|0)+(Vs>>>26)|0,Vs&=67108863,x[0]=nr,x[1]=sr,x[2]=ar,x[3]=or,x[4]=cr,x[5]=wt,x[6]=Ei,x[7]=xi,x[8]=Si,x[9]=Mi,x[10]=Ii,x[11]=Sr,x[12]=Di,x[13]=Oi,x[14]=$t,x[15]=Ri,x[16]=Ni,x[17]=Pi,x[18]=Vs,_!==0&&(x[19]=_,p.length++),p};Math.imul||(C=j);function $(a,f,p){p.negative=f.negative^a.negative,p.length=a.length+f.length;for(var w=0,A=0,x=0;x<p.length-1;x++){var _=A;A=0;for(var h=w&67108863,d=Math.min(x,f.length-1),D=Math.max(0,x-a.length+1);D<=d;D++){var K=x-D,G=a.words[K]|0,E=f.words[D]|0,H=G*E,R=H&67108863;_=_+(H/67108864|0)|0,R=R+h|0,h=R&67108863,_=_+(R>>>26)|0,A+=_>>>26,_&=67108863}p.words[x]=h,w=_,_=A}return w!==0?p.words[x]=w:p.length--,p._strip()}function P(a,f,p){return $(a,f,p)}s.prototype.mulTo=function(a,f){var p,w=this.length+a.length;return this.length===10&&a.length===10?p=C(this,a,f):w<63?p=j(this,a,f):w<1024?p=$(this,a,f):p=P(this,a,f),p},s.prototype.mul=function(a){var f=new s(null);return f.words=new Array(this.length+a.length),this.mulTo(a,f)},s.prototype.mulf=function(a){var f=new s(null);return f.words=new Array(this.length+a.length),P(this,a,f)},s.prototype.imul=function(a){return this.clone().mulTo(a,this)},s.prototype.imuln=function(a){var f=a<0;f&&(a=-a),i(typeof a=="number"),i(a<67108864);for(var p=0,w=0;w<this.length;w++){var A=(this.words[w]|0)*a,x=(A&67108863)+(p&67108863);p>>=26,p+=A/67108864|0,p+=x>>>26,this.words[w]=x&67108863}return p!==0&&(this.words[w]=p,this.length++),f?this.ineg():this},s.prototype.muln=function(a){return this.clone().imuln(a)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(a){var f=k(a);if(f.length===0)return new s(1);for(var p=this,w=0;w<f.length&&f[w]===0;w++,p=p.sqr());if(++w<f.length)for(var A=p.sqr();w<f.length;w++,A=A.sqr())f[w]!==0&&(p=p.mul(A));return p},s.prototype.iushln=function(a){i(typeof a=="number"&&a>=0);var f=a%26,p=(a-f)/26,w=67108863>>>26-f<<26-f,A;if(f!==0){var x=0;for(A=0;A<this.length;A++){var _=this.words[A]&w,h=(this.words[A]|0)-_<<f;this.words[A]=h|x,x=_>>>26-f}x&&(this.words[A]=x,this.length++)}if(p!==0){for(A=this.length-1;A>=0;A--)this.words[A+p]=this.words[A];for(A=0;A<p;A++)this.words[A]=0;this.length+=p}return this._strip()},s.prototype.ishln=function(a){return i(this.negative===0),this.iushln(a)},s.prototype.iushrn=function(a,f,p){i(typeof a=="number"&&a>=0);var w;f?w=(f-f%26)/26:w=0;var A=a%26,x=Math.min((a-A)/26,this.length),_=67108863^67108863>>>A<<A,h=p;if(w-=x,w=Math.max(0,w),h){for(var d=0;d<x;d++)h.words[d]=this.words[d];h.length=x}if(x!==0)if(this.length>x)for(this.length-=x,d=0;d<this.length;d++)this.words[d]=this.words[d+x];else this.words[0]=0,this.length=1;var D=0;for(d=this.length-1;d>=0&&(D!==0||d>=w);d--){var K=this.words[d]|0;this.words[d]=D<<26-A|K>>>A,D=K&_}return h&&D!==0&&(h.words[h.length++]=D),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(a,f,p){return i(this.negative===0),this.iushrn(a,f,p)},s.prototype.shln=function(a){return this.clone().ishln(a)},s.prototype.ushln=function(a){return this.clone().iushln(a)},s.prototype.shrn=function(a){return this.clone().ishrn(a)},s.prototype.ushrn=function(a){return this.clone().iushrn(a)},s.prototype.testn=function(a){i(typeof a=="number"&&a>=0);var f=a%26,p=(a-f)/26,w=1<<f;if(this.length<=p)return!1;var A=this.words[p];return!!(A&w)},s.prototype.imaskn=function(a){i(typeof a=="number"&&a>=0);var f=a%26,p=(a-f)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=p)return this;if(f!==0&&p++,this.length=Math.min(p,this.length),f!==0){var w=67108863^67108863>>>f<<f;this.words[this.length-1]&=w}return this._strip()},s.prototype.maskn=function(a){return this.clone().imaskn(a)},s.prototype.iaddn=function(a){return i(typeof a=="number"),i(a<67108864),a<0?this.isubn(-a):this.negative!==0?this.length===1&&(this.words[0]|0)<=a?(this.words[0]=a-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(a),this.negative=1,this):this._iaddn(a)},s.prototype._iaddn=function(a){this.words[0]+=a;for(var f=0;f<this.length&&this.words[f]>=67108864;f++)this.words[f]-=67108864,f===this.length-1?this.words[f+1]=1:this.words[f+1]++;return this.length=Math.max(this.length,f+1),this},s.prototype.isubn=function(a){if(i(typeof a=="number"),i(a<67108864),a<0)return this.iaddn(-a);if(this.negative!==0)return this.negative=0,this.iaddn(a),this.negative=1,this;if(this.words[0]-=a,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var f=0;f<this.length&&this.words[f]<0;f++)this.words[f]+=67108864,this.words[f+1]-=1;return this._strip()},s.prototype.addn=function(a){return this.clone().iaddn(a)},s.prototype.subn=function(a){return this.clone().isubn(a)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(a,f,p){var w=a.length+p,A;this._expand(w);var x,_=0;for(A=0;A<a.length;A++){x=(this.words[A+p]|0)+_;var h=(a.words[A]|0)*f;x-=h&67108863,_=(x>>26)-(h/67108864|0),this.words[A+p]=x&67108863}for(;A<this.length-p;A++)x=(this.words[A+p]|0)+_,_=x>>26,this.words[A+p]=x&67108863;if(_===0)return this._strip();for(i(_===-1),_=0,A=0;A<this.length;A++)x=-(this.words[A]|0)+_,_=x>>26,this.words[A]=x&67108863;return this.negative=1,this._strip()},s.prototype._wordDiv=function(a,f){var p=this.length-a.length,w=this.clone(),A=a,x=A.words[A.length-1]|0,_=this._countBits(x);p=26-_,p!==0&&(A=A.ushln(p),w.iushln(p),x=A.words[A.length-1]|0);var h=w.length-A.length,d;if(f!=="mod"){d=new s(null),d.length=h+1,d.words=new Array(d.length);for(var D=0;D<d.length;D++)d.words[D]=0}var K=w.clone()._ishlnsubmul(A,1,h);K.negative===0&&(w=K,d&&(d.words[h]=1));for(var G=h-1;G>=0;G--){var E=(w.words[A.length+G]|0)*67108864+(w.words[A.length+G-1]|0);for(E=Math.min(E/x|0,67108863),w._ishlnsubmul(A,E,G);w.negative!==0;)E--,w.negative=0,w._ishlnsubmul(A,1,G),w.isZero()||(w.negative^=1);d&&(d.words[G]=E)}return d&&d._strip(),w._strip(),f!=="div"&&p!==0&&w.iushrn(p),{div:d||null,mod:w}},s.prototype.divmod=function(a,f,p){if(i(!a.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var w,A,x;return this.negative!==0&&a.negative===0?(x=this.neg().divmod(a,f),f!=="mod"&&(w=x.div.neg()),f!=="div"&&(A=x.mod.neg(),p&&A.negative!==0&&A.iadd(a)),{div:w,mod:A}):this.negative===0&&a.negative!==0?(x=this.divmod(a.neg(),f),f!=="mod"&&(w=x.div.neg()),{div:w,mod:x.mod}):this.negative&a.negative?(x=this.neg().divmod(a.neg(),f),f!=="div"&&(A=x.mod.neg(),p&&A.negative!==0&&A.isub(a)),{div:x.div,mod:A}):a.length>this.length||this.cmp(a)<0?{div:new s(0),mod:this}:a.length===1?f==="div"?{div:this.divn(a.words[0]),mod:null}:f==="mod"?{div:null,mod:new s(this.modrn(a.words[0]))}:{div:this.divn(a.words[0]),mod:new s(this.modrn(a.words[0]))}:this._wordDiv(a,f)},s.prototype.div=function(a){return this.divmod(a,"div",!1).div},s.prototype.mod=function(a){return this.divmod(a,"mod",!1).mod},s.prototype.umod=function(a){return this.divmod(a,"mod",!0).mod},s.prototype.divRound=function(a){var f=this.divmod(a);if(f.mod.isZero())return f.div;var p=f.div.negative!==0?f.mod.isub(a):f.mod,w=a.ushrn(1),A=a.andln(1),x=p.cmp(w);return x<0||A===1&&x===0?f.div:f.div.negative!==0?f.div.isubn(1):f.div.iaddn(1)},s.prototype.modrn=function(a){var f=a<0;f&&(a=-a),i(a<=67108863);for(var p=(1<<26)%a,w=0,A=this.length-1;A>=0;A--)w=(p*w+(this.words[A]|0))%a;return f?-w:w},s.prototype.modn=function(a){return this.modrn(a)},s.prototype.idivn=function(a){var f=a<0;f&&(a=-a),i(a<=67108863);for(var p=0,w=this.length-1;w>=0;w--){var A=(this.words[w]|0)+p*67108864;this.words[w]=A/a|0,p=A%a}return this._strip(),f?this.ineg():this},s.prototype.divn=function(a){return this.clone().idivn(a)},s.prototype.egcd=function(a){i(a.negative===0),i(!a.isZero());var f=this,p=a.clone();f.negative!==0?f=f.umod(a):f=f.clone();for(var w=new s(1),A=new s(0),x=new s(0),_=new s(1),h=0;f.isEven()&&p.isEven();)f.iushrn(1),p.iushrn(1),++h;for(var d=p.clone(),D=f.clone();!f.isZero();){for(var K=0,G=1;!(f.words[0]&G)&&K<26;++K,G<<=1);if(K>0)for(f.iushrn(K);K-- >0;)(w.isOdd()||A.isOdd())&&(w.iadd(d),A.isub(D)),w.iushrn(1),A.iushrn(1);for(var E=0,H=1;!(p.words[0]&H)&&E<26;++E,H<<=1);if(E>0)for(p.iushrn(E);E-- >0;)(x.isOdd()||_.isOdd())&&(x.iadd(d),_.isub(D)),x.iushrn(1),_.iushrn(1);f.cmp(p)>=0?(f.isub(p),w.isub(x),A.isub(_)):(p.isub(f),x.isub(w),_.isub(A))}return{a:x,b:_,gcd:p.iushln(h)}},s.prototype._invmp=function(a){i(a.negative===0),i(!a.isZero());var f=this,p=a.clone();f.negative!==0?f=f.umod(a):f=f.clone();for(var w=new s(1),A=new s(0),x=p.clone();f.cmpn(1)>0&&p.cmpn(1)>0;){for(var _=0,h=1;!(f.words[0]&h)&&_<26;++_,h<<=1);if(_>0)for(f.iushrn(_);_-- >0;)w.isOdd()&&w.iadd(x),w.iushrn(1);for(var d=0,D=1;!(p.words[0]&D)&&d<26;++d,D<<=1);if(d>0)for(p.iushrn(d);d-- >0;)A.isOdd()&&A.iadd(x),A.iushrn(1);f.cmp(p)>=0?(f.isub(p),w.isub(A)):(p.isub(f),A.isub(w))}var K;return f.cmpn(1)===0?K=w:K=A,K.cmpn(0)<0&&K.iadd(a),K},s.prototype.gcd=function(a){if(this.isZero())return a.abs();if(a.isZero())return this.abs();var f=this.clone(),p=a.clone();f.negative=0,p.negative=0;for(var w=0;f.isEven()&&p.isEven();w++)f.iushrn(1),p.iushrn(1);do{for(;f.isEven();)f.iushrn(1);for(;p.isEven();)p.iushrn(1);var A=f.cmp(p);if(A<0){var x=f;f=p,p=x}else if(A===0||p.cmpn(1)===0)break;f.isub(p)}while(!0);return p.iushln(w)},s.prototype.invm=function(a){return this.egcd(a).a.umod(a)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(a){return this.words[0]&a},s.prototype.bincn=function(a){i(typeof a=="number");var f=a%26,p=(a-f)/26,w=1<<f;if(this.length<=p)return this._expand(p+1),this.words[p]|=w,this;for(var A=w,x=p;A!==0&&x<this.length;x++){var _=this.words[x]|0;_+=A,A=_>>>26,_&=67108863,this.words[x]=_}return A!==0&&(this.words[x]=A,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(a){var f=a<0;if(this.negative!==0&&!f)return-1;if(this.negative===0&&f)return 1;this._strip();var p;if(this.length>1)p=1;else{f&&(a=-a),i(a<=67108863,"Number is too big");var w=this.words[0]|0;p=w===a?0:w<a?-1:1}return this.negative!==0?-p|0:p},s.prototype.cmp=function(a){if(this.negative!==0&&a.negative===0)return-1;if(this.negative===0&&a.negative!==0)return 1;var f=this.ucmp(a);return this.negative!==0?-f|0:f},s.prototype.ucmp=function(a){if(this.length>a.length)return 1;if(this.length<a.length)return-1;for(var f=0,p=this.length-1;p>=0;p--){var w=this.words[p]|0,A=a.words[p]|0;if(w!==A){w<A?f=-1:w>A&&(f=1);break}}return f},s.prototype.gtn=function(a){return this.cmpn(a)===1},s.prototype.gt=function(a){return this.cmp(a)===1},s.prototype.gten=function(a){return this.cmpn(a)>=0},s.prototype.gte=function(a){return this.cmp(a)>=0},s.prototype.ltn=function(a){return this.cmpn(a)===-1},s.prototype.lt=function(a){return this.cmp(a)===-1},s.prototype.lten=function(a){return this.cmpn(a)<=0},s.prototype.lte=function(a){return this.cmp(a)<=0},s.prototype.eqn=function(a){return this.cmpn(a)===0},s.prototype.eq=function(a){return this.cmp(a)===0},s.red=function(a){return new N(a)},s.prototype.toRed=function(a){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),a.convertTo(this)._forceRed(a)},s.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(a){return this.red=a,this},s.prototype.forceRed=function(a){return i(!this.red,"Already a number in reduction context"),this._forceRed(a)},s.prototype.redAdd=function(a){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,a)},s.prototype.redIAdd=function(a){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,a)},s.prototype.redSub=function(a){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,a)},s.prototype.redISub=function(a){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,a)},s.prototype.redShl=function(a){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,a)},s.prototype.redMul=function(a){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.mul(this,a)},s.prototype.redIMul=function(a){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.imul(this,a)},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(a){return i(this.red&&!a.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,a)};var B={k256:null,p224:null,p192:null,p25519:null};function U(a,f){this.name=a,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()}U.prototype._tmp=function(){var a=new s(null);return a.words=new Array(Math.ceil(this.n/13)),a},U.prototype.ireduce=function(a){var f=a,p;do this.split(f,this.tmp),f=this.imulK(f),f=f.iadd(this.tmp),p=f.bitLength();while(p>this.n);var w=p<this.n?-1:f.ucmp(this.p);return w===0?(f.words[0]=0,f.length=1):w>0?f.isub(this.p):f.strip!==void 0?f.strip():f._strip(),f},U.prototype.split=function(a,f){a.iushrn(this.n,0,f)},U.prototype.imulK=function(a){return a.imul(this.k)};function y(){U.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(y,U),y.prototype.split=function(a,f){for(var p=4194303,w=Math.min(a.length,9),A=0;A<w;A++)f.words[A]=a.words[A];if(f.length=w,a.length<=9){a.words[0]=0,a.length=1;return}var x=a.words[9];for(f.words[f.length++]=x&p,A=10;A<a.length;A++){var _=a.words[A]|0;a.words[A-10]=(_&p)<<4|x>>>22,x=_}x>>>=22,a.words[A-10]=x,x===0&&a.length>10?a.length-=10:a.length-=9},y.prototype.imulK=function(a){a.words[a.length]=0,a.words[a.length+1]=0,a.length+=2;for(var f=0,p=0;p<a.length;p++){var w=a.words[p]|0;f+=w*977,a.words[p]=f&67108863,f=w*64+(f/67108864|0)}return a.words[a.length-1]===0&&(a.length--,a.words[a.length-1]===0&&a.length--),a};function O(){U.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(O,U);function Y(){U.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(Y,U);function Q(){U.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(Q,U),Q.prototype.imulK=function(a){for(var f=0,p=0;p<a.length;p++){var w=(a.words[p]|0)*19+f,A=w&67108863;w>>>=26,a.words[p]=A,f=w}return f!==0&&(a.words[a.length++]=f),a},s._prime=function(a){if(B[a])return B[a];var f;if(a==="k256")f=new y;else if(a==="p224")f=new O;else if(a==="p192")f=new Y;else if(a==="p25519")f=new Q;else throw new Error("Unknown prime "+a);return B[a]=f,f};function N(a){if(typeof a=="string"){var f=s._prime(a);this.m=f.p,this.prime=f}else i(a.gtn(1),"modulus must be greater than 1"),this.m=a,this.prime=null}N.prototype._verify1=function(a){i(a.negative===0,"red works only with positives"),i(a.red,"red works only with red numbers")},N.prototype._verify2=function(a,f){i((a.negative|f.negative)===0,"red works only with positives"),i(a.red&&a.red===f.red,"red works only with red numbers")},N.prototype.imod=function(a){return this.prime?this.prime.ireduce(a)._forceRed(this):(b(a,a.umod(this.m)._forceRed(this)),a)},N.prototype.neg=function(a){return a.isZero()?a.clone():this.m.sub(a)._forceRed(this)},N.prototype.add=function(a,f){this._verify2(a,f);var p=a.add(f);return p.cmp(this.m)>=0&&p.isub(this.m),p._forceRed(this)},N.prototype.iadd=function(a,f){this._verify2(a,f);var p=a.iadd(f);return p.cmp(this.m)>=0&&p.isub(this.m),p},N.prototype.sub=function(a,f){this._verify2(a,f);var p=a.sub(f);return p.cmpn(0)<0&&p.iadd(this.m),p._forceRed(this)},N.prototype.isub=function(a,f){this._verify2(a,f);var p=a.isub(f);return p.cmpn(0)<0&&p.iadd(this.m),p},N.prototype.shl=function(a,f){return this._verify1(a),this.imod(a.ushln(f))},N.prototype.imul=function(a,f){return this._verify2(a,f),this.imod(a.imul(f))},N.prototype.mul=function(a,f){return this._verify2(a,f),this.imod(a.mul(f))},N.prototype.isqr=function(a){return this.imul(a,a.clone())},N.prototype.sqr=function(a){return this.mul(a,a)},N.prototype.sqrt=function(a){if(a.isZero())return a.clone();var f=this.m.andln(3);if(i(f%2===1),f===3){var p=this.m.add(new s(1)).iushrn(2);return this.pow(a,p)}for(var w=this.m.subn(1),A=0;!w.isZero()&&w.andln(1)===0;)A++,w.iushrn(1);i(!w.isZero());var x=new s(1).toRed(this),_=x.redNeg(),h=this.m.subn(1).iushrn(1),d=this.m.bitLength();for(d=new s(2*d*d).toRed(this);this.pow(d,h).cmp(_)!==0;)d.redIAdd(_);for(var D=this.pow(d,w),K=this.pow(a,w.addn(1).iushrn(1)),G=this.pow(a,w),E=A;G.cmp(x)!==0;){for(var H=G,R=0;H.cmp(x)!==0;R++)H=H.redSqr();i(R<E);var L=this.pow(D,new s(1).iushln(E-R-1));K=K.redMul(L),D=L.redSqr(),G=G.redMul(D),E=R}return K},N.prototype.invm=function(a){var f=a._invmp(this.m);return f.negative!==0?(f.negative=0,this.imod(f).redNeg()):this.imod(f)},N.prototype.pow=function(a,f){if(f.isZero())return new s(1).toRed(this);if(f.cmpn(1)===0)return a.clone();var p=4,w=new Array(1<<p);w[0]=new s(1).toRed(this),w[1]=a;for(var A=2;A<w.length;A++)w[A]=this.mul(w[A-1],a);var x=w[0],_=0,h=0,d=f.bitLength()%26;for(d===0&&(d=26),A=f.length-1;A>=0;A--){for(var D=f.words[A],K=d-1;K>=0;K--){var G=D>>K&1;if(x!==w[0]&&(x=this.sqr(x)),G===0&&_===0){h=0;continue}_<<=1,_|=G,h++,!(h!==p&&(A!==0||K!==0))&&(x=this.mul(x,w[_]),h=0,_=0)}d=26}return x},N.prototype.convertTo=function(a){var f=a.umod(this.m);return f===a?f.clone():f},N.prototype.convertFrom=function(a){var f=a.clone();return f.red=null,f},s.mont=function(a){return new g(a)};function g(a){N.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(g,N),g.prototype.convertTo=function(a){return this.imod(a.ushln(this.shift))},g.prototype.convertFrom=function(a){var f=this.imod(a.mul(this.rinv));return f.red=null,f},g.prototype.imul=function(a,f){if(a.isZero()||f.isZero())return a.words[0]=0,a.length=1,a;var p=a.imul(f),w=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),A=p.isub(w).iushrn(this.shift),x=A;return A.cmp(this.m)>=0?x=A.isub(this.m):A.cmpn(0)<0&&(x=A.iadd(this.m)),x._forceRed(this)},g.prototype.mul=function(a,f){if(a.isZero()||f.isZero())return new s(0)._forceRed(this);var p=a.mul(f),w=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),A=p.isub(w).iushrn(this.shift),x=A;return A.cmp(this.m)>=0?x=A.isub(this.m):A.cmpn(0)<0&&(x=A.iadd(this.m)),x._forceRed(this)},g.prototype.invm=function(a){var f=this.imod(a._invmp(this.m).mul(this.r2));return f._forceRed(this)}})(t,Cu)})(Hu);var je=Hu.exports;const Vu="bignumber/5.7.0";var Fa=je.BN;const pi=new Ve(Vu),uc={},Gu=9007199254740991;function E6(t){return t!=null&&(ft.isBigNumber(t)||typeof t=="number"&&t%1===0||typeof t=="string"&&!!t.match(/^-?[0-9]+$/)||dr(t)||typeof t=="bigint"||Kn(t))}let Wu=!1;class ft{constructor(e,r){e!==uc&&pi.throwError("cannot call constructor directly; use BigNumber.from",Ve.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=r,this._isBigNumber=!0,Object.freeze(this)}fromTwos(e){return tr(Ze(this).fromTwos(e))}toTwos(e){return tr(Ze(this).toTwos(e))}abs(){return this._hex[0]==="-"?ft.from(this._hex.substring(1)):this}add(e){return tr(Ze(this).add(Ze(e)))}sub(e){return tr(Ze(this).sub(Ze(e)))}div(e){return ft.from(e).isZero()&&mr("division-by-zero","div"),tr(Ze(this).div(Ze(e)))}mul(e){return tr(Ze(this).mul(Ze(e)))}mod(e){const r=Ze(e);return r.isNeg()&&mr("division-by-zero","mod"),tr(Ze(this).umod(r))}pow(e){const r=Ze(e);return r.isNeg()&&mr("negative-power","pow"),tr(Ze(this).pow(r))}and(e){const r=Ze(e);return(this.isNegative()||r.isNeg())&&mr("unbound-bitwise-result","and"),tr(Ze(this).and(r))}or(e){const r=Ze(e);return(this.isNegative()||r.isNeg())&&mr("unbound-bitwise-result","or"),tr(Ze(this).or(r))}xor(e){const r=Ze(e);return(this.isNegative()||r.isNeg())&&mr("unbound-bitwise-result","xor"),tr(Ze(this).xor(r))}mask(e){return(this.isNegative()||e<0)&&mr("negative-width","mask"),tr(Ze(this).maskn(e))}shl(e){return(this.isNegative()||e<0)&&mr("negative-width","shl"),tr(Ze(this).shln(e))}shr(e){return(this.isNegative()||e<0)&&mr("negative-width","shr"),tr(Ze(this).shrn(e))}eq(e){return Ze(this).eq(Ze(e))}lt(e){return Ze(this).lt(Ze(e))}lte(e){return Ze(this).lte(Ze(e))}gt(e){return Ze(this).gt(Ze(e))}gte(e){return Ze(this).gte(Ze(e))}isNegative(){return this._hex[0]==="-"}isZero(){return Ze(this).isZero()}toNumber(){try{return Ze(this).toNumber()}catch{mr("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch{}return pi.throwError("this platform does not support BigInt",Ve.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(arguments[0]===10?Wu||(Wu=!0,pi.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):arguments[0]===16?pi.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",Ve.errors.UNEXPECTED_ARGUMENT,{}):pi.throwError("BigNumber.toString does not accept parameters",Ve.errors.UNEXPECTED_ARGUMENT,{})),Ze(this).toString(10)}toHexString(){return this._hex}toJSON(e){return{type:"BigNumber",hex:this.toHexString()}}static from(e){if(e instanceof ft)return e;if(typeof e=="string")return e.match(/^-?0x[0-9a-f]+$/i)?new ft(uc,_s(e)):e.match(/^-?[0-9]+$/)?new ft(uc,_s(new Fa(e))):pi.throwArgumentError("invalid BigNumber string","value",e);if(typeof e=="number")return e%1&&mr("underflow","BigNumber.from",e),(e>=Gu||e<=-Gu)&&mr("overflow","BigNumber.from",e),ft.from(String(e));const r=e;if(typeof r=="bigint")return ft.from(r.toString());if(Kn(r))return ft.from(Vt(r));if(r)if(r.toHexString){const i=r.toHexString();if(typeof i=="string")return ft.from(i)}else{let i=r._hex;if(i==null&&r.type==="BigNumber"&&(i=r.hex),typeof i=="string"&&(dr(i)||i[0]==="-"&&dr(i.substring(1))))return ft.from(i)}return pi.throwArgumentError("invalid BigNumber value","value",e)}static isBigNumber(e){return!!(e&&e._isBigNumber)}}function _s(t){if(typeof t!="string")return _s(t.toString(16));if(t[0]==="-")return t=t.substring(1),t[0]==="-"&&pi.throwArgumentError("invalid hex","value",t),t=_s(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 tr(t){return ft.from(_s(t))}function Ze(t){const e=ft.from(t).toHexString();return e[0]==="-"?new Fa("-"+e.substring(3),16):new Fa(e.substring(2),16)}function mr(t,e,r){const i={fault:t,operation:e};return r!=null&&(i.value=r),pi.throwError(t,Ve.errors.NUMERIC_FAULT,i)}function x6(t){return new Fa(t,36).toString(16)}const Gt=new Ve(Vu),As={},Yu=ft.from(0),Ju=ft.from(-1);function Qu(t,e,r,i){const n={fault:e,operation:r};return i!==void 0&&(n.value=i),Gt.throwError(t,Ve.errors.NUMERIC_FAULT,n)}let Es="0";for(;Es.length<256;)Es+=Es;function dc(t){if(typeof t!="number")try{t=ft.from(t).toNumber()}catch{}return typeof t=="number"&&t>=0&&t<=256&&!(t%1)?"1"+Es.substring(0,t):Gt.throwArgumentError("invalid decimal size","decimals",t)}function lc(t,e){e==null&&(e=0);const r=dc(e);t=ft.from(t);const i=t.lt(Yu);i&&(t=t.mul(Ju));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 gi(t,e){e==null&&(e=0);const r=dc(e);(typeof t!="string"||!t.match(/^-?[0-9.]+$/))&&Gt.throwArgumentError("invalid decimal value","value",t);const i=t.substring(0,1)==="-";i&&(t=t.substring(1)),t==="."&&Gt.throwArgumentError("missing value","value",t);const n=t.split(".");n.length>2&&Gt.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&&Qu("fractional component exceeds decimals","underflow","parseFixed"),o===""&&(o="0");o.length<r.length-1;)o+="0";const c=ft.from(s),l=ft.from(o);let u=c.mul(r).add(l);return i&&(u=u.mul(Ju)),u}class Hn{constructor(e,r,i,n){e!==As&&Gt.throwError("cannot use FixedFormat constructor; use FixedFormat.from",Ve.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=dc(n),Object.freeze(this)}static from(e){if(e instanceof Hn)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||Gt.throwArgumentError("invalid fixed format","format",e),r=s[1]!=="u",i=parseInt(s[2]),n=parseInt(s[3])}}else if(e){const s=(o,c,l)=>e[o]==null?l:(typeof e[o]!==c&&Gt.throwArgumentError("invalid fixed format ("+o+" not "+c+")","format."+o,e[o]),e[o]);r=s("signed","boolean",r),i=s("width","number",i),n=s("decimals","number",n)}return i%8&&Gt.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",i),n>80&&Gt.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",n),new Hn(As,r,i,n)}}class Tt{constructor(e,r,i,n){e!==As&&Gt.throwError("cannot use FixedNumber constructor; use FixedNumber.from",Ve.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&&Gt.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)}addUnsafe(e){this._checkFormat(e);const r=gi(this._value,this.format.decimals),i=gi(e._value,e.format.decimals);return Tt.fromValue(r.add(i),this.format.decimals,this.format)}subUnsafe(e){this._checkFormat(e);const r=gi(this._value,this.format.decimals),i=gi(e._value,e.format.decimals);return Tt.fromValue(r.sub(i),this.format.decimals,this.format)}mulUnsafe(e){this._checkFormat(e);const r=gi(this._value,this.format.decimals),i=gi(e._value,e.format.decimals);return Tt.fromValue(r.mul(i).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(e){this._checkFormat(e);const r=gi(this._value,this.format.decimals),i=gi(e._value,e.format.decimals);return Tt.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=Tt.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=Tt.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)&&Gt.throwArgumentError("invalid decimal count","decimals",e),r[1].length<=e)return this;const i=Tt.from("1"+Es.substring(0,e),this.format),n=S6.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&&Gt.throwArgumentError("invalid byte width","width",e);const r=ft.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString();return Yr(r,e/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return Tt.fromString(this._value,e)}static fromValue(e,r,i){return i==null&&r!=null&&!E6(r)&&(i=r,r=null),r==null&&(r=0),i==null&&(i="fixed"),Tt.fromString(lc(e,r),Hn.from(i))}static fromString(e,r){r==null&&(r="fixed");const i=Hn.from(r),n=gi(e,i.decimals);!i.signed&&n.lt(Yu)&&Qu("unsigned value cannot be negative","overflow","value",e);let s=null;i.signed?s=n.toTwos(i.width).toHexString():(s=n.toHexString(),s=Yr(s,i.width/8));const o=lc(n,i.decimals);return new Tt(As,s,o,i)}static fromBytes(e,r){r==null&&(r="fixed");const i=Hn.from(r);if(gt(e).length>i.width/8)throw new Error("overflow");let n=ft.from(e);i.signed&&(n=n.fromTwos(i.width));const s=n.toTwos((i.signed?0:1)+i.width).toHexString(),o=lc(n,i.decimals);return new Tt(As,s,o,i)}static from(e,r){if(typeof e=="string")return Tt.fromString(e,r);if(Kn(e))return Tt.fromBytes(e,r);try{return Tt.fromValue(e,0,r)}catch(i){if(i.code!==Ve.errors.INVALID_ARGUMENT)throw i}return Gt.throwArgumentError("invalid FixedNumber value","value",e)}static isFixedNumber(e){return!!(e&&e._isFixedNumber)}}const Xu=Tt.from(1),S6=Tt.from("0.5"),M6="strings/5.7.0",Zu=new Ve(M6);var La;(function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD"})(La||(La={}));var Vn;(function(t){t.UNEXPECTED_CONTINUE="unexpected continuation byte",t.BAD_PREFIX="bad codepoint prefix",t.OVERRUN="string overrun",t.MISSING_CONTINUE="missing continuation byte",t.OUT_OF_RANGE="out of UTF-8 range",t.UTF16_SURROGATE="UTF-16 surrogate",t.OVERLONG="overlong representation"})(Vn||(Vn={}));function I6(t,e,r,i,n){return Zu.throwArgumentError(`invalid codepoint at offset ${e}; ${t}`,"bytes",r)}function e0(t,e,r,i,n){if(t===Vn.BAD_PREFIX||t===Vn.UNEXPECTED_CONTINUE){let s=0;for(let o=e+1;o<r.length&&r[o]>>6===2;o++)s++;return s}return t===Vn.OVERRUN?r.length-e-1:0}function D6(t,e,r,i,n){return t===Vn.OVERLONG?(i.push(n),0):(i.push(65533),e0(t,e,r))}Object.freeze({error:I6,ignore:e0,replace:D6});function pc(t,e=La.current){e!=La.current&&(Zu.checkNormalize(),t=t.normalize(e));let r=[];for(let i=0;i<t.length;i++){const n=t.charCodeAt(i);if(n<128)r.push(n);else if(n<2048)r.push(n>>6|192),r.push(n&63|128);else if((n&64512)==55296){i++;const s=t.charCodeAt(i);if(i>=t.length||(s&64512)!==56320)throw new Error("invalid utf-8 string");const o=65536+((n&1023)<<10)+(s&1023);r.push(o>>18|240),r.push(o>>12&63|128),r.push(o>>6&63|128),r.push(o&63|128)}else r.push(n>>12|224),r.push(n>>6&63|128),r.push(n&63|128)}return gt(r)}function O6(t){if(t.length%4!==0)throw new Error("bad data");let e=[];for(let r=0;r<t.length;r+=4)e.push(parseInt(t.substring(r,r+4),16));return e}function gc(t,e){e||(e=function(n){return[parseInt(n,16)]});let r=0,i={};return t.split(",").forEach(n=>{let s=n.split(":");r+=parseInt(s[0],16),i[r]=e(s[1])}),i}function t0(t){let e=0;return t.split(",").map(r=>{let i=r.split("-");i.length===1?i[1]="0":i[1]===""&&(i[1]="1");let n=e+parseInt(i[0],16);return e=parseInt(i[1],16),{l:n,h:e}})}t0("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),"ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(t=>parseInt(t,16)),gc("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),gc("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),gc("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",O6),t0("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001");const r0="hash/5.7.0";function R6(t){t=atob(t);const e=[];for(let r=0;r<t.length;r++)e.push(t.charCodeAt(r));return gt(e)}function i0(t,e){e==null&&(e=1);const r=[],i=r.forEach,n=function(s,o){i.call(s,function(c){o>0&&Array.isArray(c)?n(c,o-1):r.push(c)})};return n(t,e),r}function N6(t){const e={};for(let r=0;r<t.length;r++){const i=t[r];e[i[0]]=i[1]}return e}function P6(t){let e=0;function r(){return t[e++]<<8|t[e++]}let i=r(),n=1,s=[0,1];for(let B=1;B<i;B++)s.push(n+=r());let o=r(),c=e;e+=o;let l=0,u=0;function b(){return l==0&&(u=u<<8|t[e++],l=8),u>>--l&1}const m=31,M=Math.pow(2,m),S=M>>>1,I=S>>1,F=M-1;let k=0;for(let B=0;B<m;B++)k=k<<1|b();let j=[],C=0,$=M;for(;;){let B=Math.floor(((k-C+1)*n-1)/$),U=0,y=i;for(;y-U>1;){let Q=U+y>>>1;B<s[Q]?y=Q:U=Q}if(U==0)break;j.push(U);let O=C+Math.floor($*s[U]/n),Y=C+Math.floor($*s[U+1]/n)-1;for(;!((O^Y)&S);)k=k<<1&F|b(),O=O<<1&F,Y=Y<<1&F|1;for(;O&~Y&I;)k=k&S|k<<1&F>>>1|b(),O=O<<1^S,Y=(Y^S)<<1|S|1;C=O,$=1+Y-O}let P=i-4;return j.map(B=>{switch(B-P){case 3:return P+65792+(t[c++]<<16|t[c++]<<8|t[c++]);case 2:return P+256+(t[c++]<<8|t[c++]);case 1:return P+t[c++];default:return B-1}})}function T6(t){let e=0;return()=>t[e++]}function C6(t){return T6(P6(t))}function F6(t){return t&1?~t>>1:t>>1}function L6(t,e){let r=Array(t);for(let i=0;i<t;i++)r[i]=1+e();return r}function n0(t,e){let r=Array(t);for(let i=0,n=-1;i<t;i++)r[i]=n+=1+e();return r}function B6(t,e){let r=Array(t);for(let i=0,n=0;i<t;i++)r[i]=n+=F6(e());return r}function Ba(t,e){let r=n0(t(),t),i=t(),n=n0(i,t),s=L6(i,t);for(let o=0;o<i;o++)for(let c=0;c<s[o];c++)r.push(n[o]+c);return e?r.map(o=>e[o]):r}function q6(t){let e=[];for(;;){let r=t();if(r==0)break;e.push(z6(r,t))}for(;;){let r=t()-1;if(r<0)break;e.push(k6(r,t))}return N6(i0(e))}function U6(t){let e=[];for(;;){let r=t();if(r==0)break;e.push(r)}return e}function s0(t,e,r){let i=Array(t).fill(void 0).map(()=>[]);for(let n=0;n<e;n++)B6(t,r).forEach((s,o)=>i[o].push(s));return i}function z6(t,e){let r=1+e(),i=e(),n=U6(e),s=s0(n.length,1+t,e);return i0(s.map((o,c)=>{const l=o[0],u=o.slice(1);return Array(n[c]).fill(void 0).map((b,m)=>{let M=m*i;return[l+m*r,u.map(S=>S+M)]})}))}function k6(t,e){let r=1+e();return s0(r,1+t,e).map(i=>[i[0],i.slice(1)])}function $6(t){let e=Ba(t).sort((i,n)=>i-n);return r();function r(){let i=[];for(;;){let u=Ba(t,e);if(u.length==0)break;i.push({set:new Set(u),node:r()})}i.sort((u,b)=>b.set.size-u.set.size);let n=t(),s=n%3;n=n/3|0;let o=!!(n&1);n>>=1;let c=n==1,l=n==2;return{branches:i,valid:s,fe0f:o,save:c,check:l}}}function j6(){return C6(R6("AEQF2AO2DEsA2wIrAGsBRABxAN8AZwCcAEwAqgA0AGwAUgByADcATAAVAFYAIQAyACEAKAAYAFgAGwAjABQAMAAmADIAFAAfABQAKwATACoADgAbAA8AHQAYABoAGQAxADgALAAoADwAEwA9ABMAGgARAA4ADwAWABMAFgAIAA8AHgQXBYMA5BHJAS8JtAYoAe4AExozi0UAH21tAaMnBT8CrnIyhrMDhRgDygIBUAEHcoFHUPe8AXBjAewCjgDQR8IICIcEcQLwATXCDgzvHwBmBoHNAqsBdBcUAykgDhAMShskMgo8AY8jqAQfAUAfHw8BDw87MioGlCIPBwZCa4ELatMAAMspJVgsDl8AIhckSg8XAHdvTwBcIQEiDT4OPhUqbyECAEoAS34Aej8Ybx83JgT/Xw8gHxZ/7w8RICxPHA9vBw+Pfw8PHwAPFv+fAsAvCc8vEr8ivwD/EQ8Bol8OEBa/A78hrwAPCU8vESNvvwWfHwNfAVoDHr+ZAAED34YaAdJPAK7PLwSEgDLHAGo1Pz8Pvx9fUwMrpb8O/58VTzAPIBoXIyQJNF8hpwIVAT8YGAUADDNBaX3RAMomJCg9EhUeA29MABsZBTMNJipjOhc19gcIDR8bBwQHEggCWi6DIgLuAQYA+BAFCha3A5XiAEsqM7UFFgFLhAMjFTMYE1Klnw74nRVBG/ASCm0BYRN/BrsU3VoWy+S0vV8LQx+vN8gF2AC2AK5EAWwApgYDKmAAroQ0NDQ0AT+OCg7wAAIHRAbpNgVcBV0APTA5BfbPFgMLzcYL/QqqA82eBALKCjQCjqYCht0/k2+OAsXQAoP3ASTKDgDw6ACKAUYCMpIKJpRaAE4A5womABzZvs0REEKiACIQAd5QdAECAj4Ywg/wGqY2AVgAYADYvAoCGAEubA0gvAY2ALAAbpbvqpyEAGAEpgQAJgAG7gAgAEACmghUFwCqAMpAINQIwC4DthRAAPcycKgApoIdABwBfCisABoATwBqASIAvhnSBP8aH/ECeAKXAq40NjgDBTwFYQU6AXs3oABgAD4XNgmcCY1eCl5tIFZeUqGgyoNHABgAEQAaABNwWQAmABMATPMa3T34ADldyprmM1M2XociUQgLzvwAXT3xABgAEQAaABNwIGFAnADD8AAgAD4BBJWzaCcIAIEBFMAWwKoAAdq9BWAF5wLQpALEtQAKUSGkahR4GnJM+gsAwCgeFAiUAECQ0BQuL8AAIAAAADKeIheclvFqQAAETr4iAMxIARMgAMIoHhQIAn0E0pDQFC4HhznoAAAAIAI2C0/4lvFqQAAETgBJJwYCAy4ABgYAFAA8MBKYEH4eRhTkAjYeFcgACAYAeABsOqyQ5gRwDayqugEgaIIAtgoACgDmEABmBAWGme5OBJJA2m4cDeoAmITWAXwrMgOgAGwBCh6CBXYF1Tzg1wKAAFdiuABRAFwAXQBsAG8AdgBrAHYAbwCEAHEwfxQBVE5TEQADVFhTBwBDANILAqcCzgLTApQCrQL6vAAMAL8APLhNBKkE6glGKTAU4Dr4N2EYEwBCkABKk8rHAbYBmwIoAiU4Ajf/Aq4CowCAANIChzgaNBsCsTgeODcFXrgClQKdAqQBiQGYAqsCsjTsNHsfNPA0ixsAWTWiOAMFPDQSNCk2BDZHNow2TTZUNhk28Jk9VzI3QkEoAoICoQKwAqcAQAAxBV4FXbS9BW47YkIXP1ciUqs05DS/FwABUwJW11e6nHuYZmSh/RAYA8oMKvZ8KASoUAJYWAJ6ILAsAZSoqjpgA0ocBIhmDgDWAAawRDQoAAcuAj5iAHABZiR2AIgiHgCaAU68ACxuHAG0ygM8MiZIAlgBdF4GagJqAPZOHAMuBgoATkYAsABiAHgAMLoGDPj0HpKEBAAOJgAuALggTAHWAeAMEDbd20Uege0ADwAWADkAQgA9OHd+2MUQZBBhBgNNDkxxPxUQArEPqwvqERoM1irQ090ANK4H8ANYB/ADWANYB/AH8ANYB/ADWANYA1gDWBwP8B/YxRBkD00EcgWTBZAE2wiIJk4RhgctCNdUEnQjHEwDSgEBIypJITuYMxAlR0wRTQgIATZHbKx9PQNMMbBU+pCnA9AyVDlxBgMedhKlAC8PeCE1uk6DekxxpQpQT7NX9wBFBgASqwAS5gBJDSgAUCwGPQBI4zTYABNGAE2bAE3KAExdGABKaAbgAFBXAFCOAFBJABI2SWdObALDOq0//QomCZhvwHdTBkIQHCemEPgMNAG2ATwN7kvZBPIGPATKH34ZGg/OlZ0Ipi3eDO4m5C6igFsj9iqEBe5L9TzeC05RaQ9aC2YJ5DpkgU8DIgEOIowK3g06CG4Q9ArKbA3mEUYHOgPWSZsApgcCCxIdNhW2JhFirQsKOXgG/Br3C5AmsBMqev0F1BoiBk4BKhsAANAu6IWxWjJcHU9gBgQLJiPIFKlQIQ0mQLh4SRocBxYlqgKSQ3FKiFE3HpQh9zw+DWcuFFF9B/Y8BhlQC4I8n0asRQ8R0z6OPUkiSkwtBDaALDAnjAnQD4YMunxzAVoJIgmyDHITMhEYN8YIOgcaLpclJxYIIkaWYJsE+KAD9BPSAwwFQAlCBxQDthwuEy8VKgUOgSXYAvQ21i60ApBWgQEYBcwPJh/gEFFH4Q7qCJwCZgOEJewALhUiABginAhEZABgj9lTBi7MCMhqbSN1A2gU6GIRdAeSDlgHqBw0FcAc4nDJXgyGCSiksAlcAXYJmgFgBOQICjVcjKEgQmdUi1kYnCBiQUBd/QIyDGYVoES+h3kCjA9sEhwBNgF0BzoNAgJ4Ee4RbBCWCOyGBTW2M/k6JgRQIYQgEgooA1BszwsoJvoM+WoBpBJjAw00PnfvZ6xgtyUX/gcaMsZBYSHyC5NPzgydGsIYQ1QvGeUHwAP0GvQn60FYBgADpAQUOk4z7wS+C2oIjAlAAEoOpBgH2BhrCnKM0QEyjAG4mgNYkoQCcJAGOAcMAGgMiAV65gAeAqgIpAAGANADWAA6Aq4HngAaAIZCAT4DKDABIuYCkAOUCDLMAZYwAfQqBBzEDBYA+DhuSwLDsgKAa2ajBd5ZAo8CSjYBTiYEBk9IUgOwcuIA3ABMBhTgSAEWrEvMG+REAeBwLADIAPwABjYHBkIBzgH0bgC4AWALMgmjtLYBTuoqAIQAFmwB2AKKAN4ANgCA8gFUAE4FWvoF1AJQSgESMhksWGIBvAMgATQBDgB6BsyOpsoIIARuB9QCEBwV4gLvLwe2AgMi4BPOQsYCvd9WADIXUu5eZwqoCqdeaAC0YTQHMnM9UQAPH6k+yAdy/BZIiQImSwBQ5gBQQzSaNTFWSTYBpwGqKQK38AFtqwBI/wK37gK3rQK3sAK6280C0gK33AK3zxAAUEIAUD9SklKDArekArw5AEQAzAHCO147WTteO1k7XjtZO147WTteO1kDmChYI03AVU0oJqkKbV9GYewMpw3VRMk6ShPcYFJgMxPJLbgUwhXPJVcZPhq9JwYl5VUKDwUt1GYxCC00dhe9AEApaYNCY4ceMQpMHOhTklT5LRwAskujM7ANrRsWREEFSHXuYisWDwojAmSCAmJDXE6wXDchAqH4AmiZAmYKAp+FOBwMAmY8AmYnBG8EgAN/FAN+kzkHOXgYOYM6JCQCbB4CMjc4CwJtyAJtr/CLADRoRiwBaADfAOIASwYHmQyOAP8MwwAOtgJ3MAJ2o0ACeUxEAni7Hl3cRa9G9AJ8QAJ6yQJ9CgJ88UgBSH5kJQAsFklZSlwWGErNAtECAtDNSygDiFADh+dExpEzAvKiXQQDA69Lz0wuJgTQTU1NsAKLQAKK2cIcCB5EaAa4Ao44Ao5dQZiCAo7aAo5deVG1UzYLUtVUhgKT/AKTDQDqAB1VH1WwVdEHLBwplocy4nhnRTw6ApegAu+zWCKpAFomApaQApZ9nQCqWa1aCoJOADwClrYClk9cRVzSApnMApllXMtdCBoCnJw5wzqeApwXAp+cAp65iwAeEDIrEAKd8gKekwC2PmE1YfACntQCoG8BqgKeoCACnk+mY8lkKCYsAiewAiZ/AqD8AqBN2AKmMAKlzwKoAAB+AqfzaH1osgAESmodatICrOQCrK8CrWgCrQMCVx4CVd0CseLYAx9PbJgCsr4OArLpGGzhbWRtSWADJc4Ctl08QG6RAylGArhfArlIFgK5K3hwN3DiAr0aAy2zAzISAr6JcgMDM3ICvhtzI3NQAsPMAsMFc4N0TDZGdOEDPKgDPJsDPcACxX0CxkgCxhGKAshqUgLIRQLJUALJLwJkngLd03h6YniveSZL0QMYpGcDAmH1GfSVJXsMXpNevBICz2wCz20wTFTT9BSgAMeuAs90ASrrA04TfkwGAtwoAtuLAtJQA1JdA1NgAQIDVY2AikABzBfuYUZ2AILPg44C2sgC2d+EEYRKpz0DhqYAMANkD4ZyWvoAVgLfZgLeuXR4AuIw7RUB8zEoAfScAfLTiALr9ALpcXoAAur6AurlAPpIAboC7ooC652Wq5cEAu5AA4XhmHpw4XGiAvMEAGoDjheZlAL3FAORbwOSiAL3mQL52gL4Z5odmqy8OJsfA52EAv77ARwAOp8dn7QDBY4DpmsDptoA0sYDBmuhiaIGCgMMSgFgASACtgNGAJwEgLpoBgC8BGzAEowcggCEDC6kdjoAJAM0C5IKRoABZCgiAIzw3AYBLACkfng9ogigkgNmWAN6AEQCvrkEVqTGAwCsBRbAA+4iQkMCHR072jI2PTbUNsk2RjY5NvA23TZKNiU3EDcZN5I+RTxDRTBCJkK5VBYKFhZfwQCWygU3AJBRHpu+OytgNxa61A40GMsYjsn7BVwFXQVcBV0FaAVdBVwFXQVcBV0FXAVdBVwFXUsaCNyKAK4AAQUHBwKU7oICoW1e7jAEzgPxA+YDwgCkBFDAwADABKzAAOxFLhitA1UFTDeyPkM+bj51QkRCuwTQWWQ8X+0AWBYzsACNA8xwzAGm7EZ/QisoCTAbLDs6fnLfb8H2GccsbgFw13M1HAVkBW/Jxsm9CNRO8E8FDD0FBQw9FkcClOYCoMFegpDfADgcMiA2AJQACB8AsigKAIzIEAJKeBIApY5yPZQIAKQiHb4fvj5BKSRPQrZCOz0oXyxgOywfKAnGbgMClQaCAkILXgdeCD9IIGUgQj5fPoY+dT52Ao5CM0dAX9BTVG9SDzFwWTQAbxBzJF/lOEIQQglCCkKJIAls5AcClQICoKPMODEFxhi6KSAbiyfIRrMjtCgdWCAkPlFBIitCsEJRzAbMAV/OEyQzDg0OAQQEJ36i328/Mk9AybDJsQlq3tDRApUKAkFzXf1d/j9uALYP6hCoFgCTGD8kPsFKQiobrm0+zj0KSD8kPnVCRBwMDyJRTHFgMTJa5rwXQiQ2YfI/JD7BMEJEHGINTw4TOFlIRzwJO0icMQpyPyQ+wzJCRBv6DVgnKB01NgUKj2bwYzMqCoBkznBgEF+zYDIocwRIX+NgHj4HICNfh2C4CwdwFWpTG/lgUhYGAwRfv2Ts8mAaXzVgml/XYIJfuWC4HI1gUF9pYJZgMR6ilQHMAOwLAlDRefC0in4AXAEJA6PjCwc0IamOANMMCAECRQDFNRTZBgd+CwQlRA+r6+gLBDEFBnwUBXgKATIArwAGRAAHA3cDdAN2A3kDdwN9A3oDdQN7A30DfAN4A3oDfQAYEAAlAtYASwMAUAFsAHcKAHcAmgB3AHUAdQB2AHVu8UgAygDAAHcAdQB1AHYAdQALCgB3AAsAmgB3AAsCOwB3AAtu8UgAygDAAHgKAJoAdwB3AHUAdQB2AHUAeAB1AHUAdgB1bvFIAMoAwAALCgCaAHcACwB3AAsCOwB3AAtu8UgAygDAAH4ACwGgALcBpwC6AahdAu0COwLtbvFIAMoAwAALCgCaAu0ACwLtAAsCOwLtAAtu8UgAygDAA24ACwNvAAu0VsQAAzsAABCkjUIpAAsAUIusOggWcgMeBxVsGwL67U/2HlzmWOEeOgALASvuAAseAfpKUpnpGgYJDCIZM6YyARUE9ThqAD5iXQgnAJYJPnOzw0ZAEZxEKsIAkA4DhAHnTAIDxxUDK0lxCQlPYgIvIQVYJQBVqE1GakUAKGYiDToSBA1EtAYAXQJYAIF8GgMHRyAAIAjOe9YncekRAA0KACUrjwE7Ayc6AAYWAqaiKG4McEcqANoN3+Mg9TwCBhIkuCny+JwUQ29L008JluRxu3K+oAdqiHOqFH0AG5SUIfUJ5SxCGfxdipRzqTmT4V5Zb+r1Uo4Vm+NqSSEl2mNvR2JhIa8SpYO6ntdwFXHCWTCK8f2+Hxo7uiG3drDycAuKIMP5bhi06ACnqArH1rz4Rqg//lm6SgJGEVbF9xJHISaR6HxqxSnkw6shDnelHKNEfGUXSJRJ1GcsmtJw25xrZMDK9gXSm1/YMkdX4/6NKYOdtk/NQ3/NnDASjTc3fPjIjW/5sVfVObX2oTDWkr1dF9f3kxBsD3/3aQO8hPfRz+e0uEiJqt1161griu7gz8hDDwtpy+F+BWtefnKHZPAxcZoWbnznhJpy0e842j36bcNzGnIEusgGX0a8ZxsnjcSsPDZ09yZ36fCQbriHeQ72JRMILNl6ePPf2HWoVwgWAm1fb3V2sAY0+B6rAXqSwPBgseVmoqsBTSrm91+XasMYYySI8eeRxH3ZvHkMz3BQ5aJ3iUVbYPNM3/7emRtjlsMgv/9VyTsyt/mK+8fgWeT6SoFaclXqn42dAIsvAarF5vNNWHzKSkKQ/8Hfk5ZWK7r9yliOsooyBjRhfkHP4Q2DkWXQi6FG/9r/IwbmkV5T7JSopHKn1pJwm9tb5Ot0oyN1Z2mPpKXHTxx2nlK08fKk1hEYA8WgVVWL5lgx0iTv+KdojJeU23ZDjmiubXOxVXJKKi2Wjuh2HLZOFLiSC7Tls5SMh4f+Pj6xUSrNjFqLGehRNB8lC0QSLNmkJJx/wSG3MnjE9T1CkPwJI0wH2lfzwETIiVqUxg0dfu5q39Gt+hwdcxkhhNvQ4TyrBceof3Mhs/IxFci1HmHr4FMZgXEEczPiGCx0HRwzAqDq2j9AVm1kwN0mRVLWLylgtoPNapF5cY4Y1wJh/e0BBwZj44YgZrDNqvD/9Hv7GFYdUQeDJuQ3EWI4HaKqavU1XjC/n41kT4L79kqGq0kLhdTZvgP3TA3fS0ozVz+5piZsoOtIvBUFoMKbNcmBL6YxxaUAusHB38XrS8dQMnQwJfUUkpRoGr5AUeWicvBTzyK9g77+yCkf5PAysL7r/JjcZgrbvRpMW9iyaxZvKO6ceZN2EwIxKwVFPuvFuiEPGCoagbMo+SpydLrXqBzNCDGFCrO/rkcwa2xhokQZ5CdZ0AsU3JfSqJ6n5I14YA+P/uAgfhPU84Tlw7cEFfp7AEE8ey4sP12PTt4Cods1GRgDOB5xvyiR5m+Bx8O5nBCNctU8BevfV5A08x6RHd5jcwPTMDSZJOedIZ1cGQ704lxbAzqZOP05ZxaOghzSdvFBHYqomATARyAADK4elP8Ly3IrUZKfWh23Xy20uBUmLS4Pfagu9+oyVa2iPgqRP3F2CTUsvJ7+RYnN8fFZbU/HVvxvcFFDKkiTqV5UBZ3Gz54JAKByi9hkKMZJvuGgcSYXFmw08UyoQyVdfTD1/dMkCHXcTGAKeROgArsvmRrQTLUOXioOHGK2QkjHuoYFgXciZoTJd6Fs5q1QX1G+p/e26hYsEf7QZD1nnIyl/SFkNtYYmmBhpBrxl9WbY0YpHWRuw2Ll/tj9mD8P4snVzJl4F9J+1arVeTb9E5r2ILH04qStjxQNwn3m4YNqxmaNbLAqW2TN6LidwuJRqS+NXbtqxoeDXpxeGWmxzSkWxjkyCkX4NQRme6q5SAcC+M7+9ETfA/EwrzQajKakCwYyeunP6ZFlxU2oMEn1Pz31zeStW74G406ZJFCl1wAXIoUKkWotYEpOuXB1uVNxJ63dpJEqfxBeptwIHNrPz8BllZoIcBoXwgfJ+8VAUnVPvRvexnw0Ma/WiGYuJO5y8QTvEYBigFmhUxY5RqzE8OcywN/8m4UYrlaniJO75XQ6KSo9+tWHlu+hMi0UVdiKQp7NelnoZUzNaIyBPVeOwK6GNp+FfHuPOoyhaWuNvTYFkvxscMQWDh+zeFCFkgwbXftiV23ywJ4+uwRqmg9k3KzwIQpzppt8DBBOMbrqwQM5Gb05sEwdKzMiAqOloaA/lr0KA+1pr0/+HiWoiIjHA/wir2nIuS3PeU/ji3O6ZwoxcR1SZ9FhtLC5S0FIzFhbBWcGVP/KpxOPSiUoAdWUpqKH++6Scz507iCcxYI6rdMBICPJZea7OcmeFw5mObJSiqpjg2UoWNIs+cFhyDSt6geV5qgi3FunmwwDoGSMgerFOZGX1m0dMCYo5XOruxO063dwENK9DbnVM9wYFREzh4vyU1WYYJ/LRRp6oxgjqP/X5a8/4Af6p6NWkQferzBmXme0zY/4nwMJm/wd1tIqSwGz+E3xPEAOoZlJit3XddD7/BT1pllzOx+8bmQtANQ/S6fZexc6qi3W+Q2xcmXTUhuS5mpHQRvcxZUN0S5+PL9lXWUAaRZhEH8hTdAcuNMMCuVNKTEGtSUKNi3O6KhSaTzck8csZ2vWRZ+d7mW8c4IKwXIYd25S/zIftPkwPzufjEvOHWVD1m+FjpDVUTV0DGDuHj6QnaEwLu/dEgdLQOg9E1Sro9XHJ8ykLAwtPu+pxqKDuFexqON1sKQm7rwbE1E68UCfA/erovrTCG+DBSNg0l4goDQvZN6uNlbyLpcZAwj2UclycvLpIZMgv4yRlpb3YuMftozorbcGVHt/VeDV3+Fdf1TP0iuaCsPi2G4XeGhsyF1ubVDxkoJhmniQ0/jSg/eYML9KLfnCFgISWkp91eauR3IQvED0nAPXK+6hPCYs+n3+hCZbiskmVMG2da+0EsZPonUeIY8EbfusQXjsK/eFDaosbPjEfQS0RKG7yj5GG69M7MeO1HmiUYocgygJHL6M1qzUDDwUSmr99V7Sdr2F3JjQAJY+F0yH33Iv3+C9M38eML7gTgmNu/r2bUMiPvpYbZ6v1/IaESirBHNa7mPKn4dEmYg7v/+HQgPN1G79jBQ1+soydfDC2r+h2Bl/KIc5KjMK7OH6nb1jLsNf0EHVe2KBiE51ox636uyG6Lho0t3J34L5QY/ilE3mikaF4HKXG1mG1rCevT1Vv6GavltxoQe/bMrpZvRggnBxSEPEeEzkEdOxTnPXHVjUYdw8JYvjB/o7Eegc3Ma+NUxLLnsK0kJlinPmUHzHGtrk5+CAbVzFOBqpyy3QVUnzTDfC/0XD94/okH+OB+i7g9lolhWIjSnfIb+Eq43ZXOWmwvjyV/qqD+t0e+7mTEM74qP/Ozt8nmC7mRpyu63OB4KnUzFc074SqoyPUAgM+/TJGFo6T44EHnQU4X4z6qannVqgw/U7zCpwcmXV1AubIrvOmkKHazJAR55ePjp5tLBsN8vAqs3NAHdcEHOR2xQ0lsNAFzSUuxFQCFYvXLZJdOj9p4fNq6p0HBGUik2YzaI4xySy91KzhQ0+q1hjxvImRwPRf76tChlRkhRCi74NXZ9qUNeIwP+s5p+3m5nwPdNOHgSLD79n7O9m1n1uDHiMntq4nkYwV5OZ1ENbXxFd4PgrlvavZsyUO4MqYlqqn1O8W/I1dEZq5dXhrbETLaZIbC2Kj/Aa/QM+fqUOHdf0tXAQ1huZ3cmWECWSXy/43j35+Mvq9xws7JKseriZ1pEWKc8qlzNrGPUGcVgOa9cPJYIJsGnJTAUsEcDOEVULO5x0rXBijc1lgXEzQQKhROf8zIV82w8eswc78YX11KYLWQRcgHNJElBxfXr72lS2RBSl07qTKorO2uUDZr3sFhYsvnhLZn0A94KRzJ/7DEGIAhW5ZWFpL8gEwu1aLA9MuWZzNwl8Oze9Y+bX+v9gywRVnoB5I/8kXTXU3141yRLYrIOOz6SOnyHNy4SieqzkBXharjfjqq1q6tklaEbA8Qfm2DaIPs7OTq/nvJBjKfO2H9bH2cCMh1+5gspfycu8f/cuuRmtDjyqZ7uCIMyjdV3a+p3fqmXsRx4C8lujezIFHnQiVTXLXuI1XrwN3+siYYj2HHTvESUx8DlOTXpak9qFRK+L3mgJ1WsD7F4cu1aJoFoYQnu+wGDMOjJM3kiBQWHCcvhJ/HRdxodOQp45YZaOTA22Nb4XKCVxqkbwMYFhzYQYIAnCW8FW14uf98jhUG2zrKhQQ0q0CEq0t5nXyvUyvR8DvD69LU+g3i+HFWQMQ8PqZuHD+sNKAV0+M6EJC0szq7rEr7B5bQ8BcNHzvDMc9eqB5ZCQdTf80Obn4uzjwpYU7SISdtV0QGa9D3Wrh2BDQtpBKxaNFV+/Cy2P/Sv+8s7Ud0Fd74X4+o/TNztWgETUapy+majNQ68Lq3ee0ZO48VEbTZYiH1Co4OlfWef82RWeyUXo7woM03PyapGfikTnQinoNq5z5veLpeMV3HCAMTaZmA1oGLAn7XS3XYsz+XK7VMQsc4XKrmDXOLU/pSXVNUq8dIqTba///3x6LiLS6xs1xuCAYSfcQ3+rQgmu7uvf3THKt5Ooo97TqcbRqxx7EASizaQCBQllG/rYxVapMLgtLbZS64w1MDBMXX+PQpBKNwqUKOf2DDRDUXQf9EhOS0Qj4nTmlA8dzSLz/G1d+Ud8MTy/6ghhdiLpeerGY/UlDOfiuqFsMUU5/UYlP+BAmgRLuNpvrUaLlVkrqDievNVEAwF+4CoM1MZTmjxjJMsKJq+u8Zd7tNCUFy6LiyYXRJQ4VyvEQFFaCGKsxIwQkk7EzZ6LTJq2hUuPhvAW+gQnSG6J+MszC+7QCRHcnqDdyNRJ6T9xyS87A6MDutbzKGvGktpbXqtzWtXb9HsfK2cBMomjN9a4y+TaJLnXxAeX/HWzmf4cR4vALt/P4w4qgKY04ml4ZdLOinFYS6cup3G/1ie4+t1eOnpBNlqGqs75ilzkT4+DsZQxNvaSKJ//6zIbbk/M7LOhFmRc/1R+kBtz7JFGdZm/COotIdvQoXpTqP/1uqEUmCb/QWoGLMwO5ANcHzxdY48IGP5+J+zKOTBFZ4Pid+GTM+Wq12MV/H86xEJptBa6T+p3kgpwLedManBHC2GgNrFpoN2xnrMz9WFWX/8/ygSBkavq2Uv7FdCsLEYLu9LLIvAU0bNRDtzYl+/vXmjpIvuJFYjmI0im6QEYqnIeMsNjXG4vIutIGHijeAG/9EDBozKV5cldkHbLxHh25vT+ZEzbhXlqvpzKJwcEgfNwLAKFeo0/pvEE10XDB+EXRTXtSzJozQKFFAJhMxYkVaCW+E9AL7tMeU8acxidHqzb6lX4691UsDpy/LLRmT+epgW56+5Cw8tB4kMUv6s9lh3eRKbyGs+H/4mQMaYzPTf2OOdokEn+zzgvoD3FqNKk8QqGAXVsqcGdXrT62fSPkR2vROFi68A6se86UxRUk4cajfPyCC4G5wDhD+zNq4jodQ4u4n/m37Lr36n4LIAAsVr02dFi9AiwA81MYs2rm4eDlDNmdMRvEKRHfBwW5DdMNp0jPFZMeARqF/wL4XBfd+EMLBfMzpH5GH6NaW+1vrvMdg+VxDzatk3MXgO3ro3P/DpcC6+Mo4MySJhKJhSR01SGGGp5hPWmrrUgrv3lDnP+HhcI3nt3YqBoVAVTBAQT5iuhTg8nvPtd8ZeYj6w1x6RqGUBrSku7+N1+BaasZvjTk64RoIDlL8brpEcJx3OmY7jLoZsswdtmhfC/G21llXhITOwmvRDDeTTPbyASOa16cF5/A1fZAidJpqju3wYAy9avPR1ya6eNp9K8XYrrtuxlqi+bDKwlfrYdR0RRiKRVTLOH85+ZY7XSmzRpfZBJjaTa81VDcJHpZnZnSQLASGYW9l51ZV/h7eVzTi3Hv6hUsgc/51AqJRTkpbFVLXXszoBL8nBX0u/0jBLT8nH+fJePbrwURT58OY+UieRjd1vs04w0VG5VN2U6MoGZkQzKN/ptz0Q366dxoTGmj7i1NQGHi9GgnquXFYdrCfZBmeb7s0T6yrdlZH5cZuwHFyIJ/kAtGsTg0xH5taAAq44BAk1CPk9KVVbqQzrCUiFdF/6gtlPQ8bHHc1G1W92MXGZ5HEHftyLYs8mbD/9xYRUWkHmlM0zC2ilJlnNgV4bfALpQghxOUoZL7VTqtCHIaQSXm+YUMnpkXybnV+A6xlm2CVy8fn0Xlm2XRa0+zzOa21JWWmixfiPMSCZ7qA4rS93VN3pkpF1s5TonQjisHf7iU9ZGvUPOAKZcR1pbeVf/Ul7OhepGCaId9wOtqo7pJ7yLcBZ0pFkOF28y4zEI/kcUNmutBHaQpBdNM8vjCS6HZRokkeo88TBAjGyG7SR+6vUgTcyK9Imalj0kuxz0wmK+byQU11AiJFk/ya5dNduRClcnU64yGu/ieWSeOos1t3ep+RPIWQ2pyTYVbZltTbsb7NiwSi3AV+8KLWk7LxCnfZUetEM8ThnsSoGH38/nyAwFguJp8FjvlHtcWZuU4hPva0rHfr0UhOOJ/F6vS62FW7KzkmRll2HEc7oUq4fyi5T70Vl7YVIfsPHUCdHesf9Lk7WNVWO75JDkYbMI8TOW8JKVtLY9d6UJRITO8oKo0xS+o99Yy04iniGHAaGj88kEWgwv0OrHdY/nr76DOGNS59hXCGXzTKUvDl9iKpLSWYN1lxIeyywdNpTkhay74w2jFT6NS8qkjo5CxA1yfSYwp6AJIZNKIeEK5PJAW7ORgWgwp0VgzYpqovMrWxbu+DGZ6Lhie1RAqpzm8VUzKJOH3mCzWuTOLsN3VT/dv2eeYe9UjbR8YTBsLz7q60VN1sU51k+um1f8JxD5pPhbhSC8rRaB454tmh6YUWrJI3+GWY0qeWioj/tbkYITOkJaeuGt4JrJvHA+l0Gu7kY7XOaa05alMnRWVCXqFgLIwSY4uF59Ue5SU4QKuc/HamDxbr0x6csCetXGoP7Qn1Bk/J9DsynO/UD6iZ1Hyrz+jit0hDCwi/E9OjgKTbB3ZQKQ/0ZOvevfNHG0NK4Aj3Cp7NpRk07RT1i/S0EL93Ag8GRgKI9CfpajKyK6+Jj/PI1KO5/85VAwz2AwzP8FTBb075IxCXv6T9RVvWT2tUaqxDS92zrGUbWzUYk9mSs82pECH+fkqsDt93VW++4YsR/dHCYcQSYTO/KaBMDj9LSD/J/+z20Kq8XvZUAIHtm9hRPP3ItbuAu2Hm5lkPs92pd7kCxgRs0xOVBnZ13ccdA0aunrwv9SdqElJRC3g+oCu+nXyCgmXUs9yMjTMAIHfxZV+aPKcZeUBWt057Xo85Ks1Ir5gzEHCWqZEhrLZMuF11ziGtFQUds/EESajhagzcKsxamcSZxGth4UII+adPhQkUnx2WyN+4YWR+r3f8MnkyGFuR4zjzxJS8WsQYR5PTyRaD9ixa6Mh741nBHbzfjXHskGDq179xaRNrCIB1z1xRfWfjqw2pHc1zk9xlPpL8sQWAIuETZZhbnmL54rceXVNRvUiKrrqIkeogsl0XXb17ylNb0f4GA9Wd44vffEG8FSZGHEL2fbaTGRcSiCeA8PmA/f6Hz8HCS76fXUHwgwkzSwlI71ekZ7Fapmlk/KC+Hs8hUcw3N2LN5LhkVYyizYFl/uPeVP5lsoJHhhfWvvSWruCUW1ZcJOeuTbrDgywJ/qG07gZJplnTvLcYdNaH0KMYOYMGX+rB4NGPFmQsNaIwlWrfCezxre8zXBrsMT+edVLbLqN1BqB76JH4BvZTqUIMfGwPGEn+EnmTV86fPBaYbFL3DFEhjB45CewkXEAtJxk4/Ms2pPXnaRqdky0HOYdcUcE2zcXq4vaIvW2/v0nHFJH2XXe22ueDmq/18XGtELSq85j9X8q0tcNSSKJIX8FTuJF/Pf8j5PhqG2u+osvsLxYrvvfeVJL+4tkcXcr9JV7v0ERmj/X6fM3NC4j6dS1+9Umr2oPavqiAydTZPLMNRGY23LO9zAVDly7jD+70G5TPPLdhRIl4WxcYjLnM+SNcJ26FOrkrISUtPObIz5Zb3AG612krnpy15RMW+1cQjlnWFI6538qky9axd2oJmHIHP08KyP0ubGO+TQNOYuv2uh17yCIvR8VcStw7o1g0NM60sk+8Tq7YfIBJrtp53GkvzXH7OA0p8/n/u1satf/VJhtR1l8Wa6Gmaug7haSpaCaYQax6ta0mkutlb+eAOSG1aobM81D9A4iS1RRlzBBoVX6tU1S6WE2N9ORY6DfeLRC4l9Rvr5h95XDWB2mR1d4WFudpsgVYwiTwT31ljskD8ZyDOlm5DkGh9N/UB/0AI5Xvb8ZBmai2hQ4BWMqFwYnzxwB26YHSOv9WgY3JXnvoN+2R4rqGVh/LLDMtpFP+SpMGJNWvbIl5SOodbCczW2RKleksPoUeGEzrjtKHVdtZA+kfqO+rVx/iclCqwoopepvJpSTDjT+b9GWylGRF8EDbGlw6eUzmJM95Ovoz+kwLX3c2fTjFeYEsE7vUZm3mqdGJuKh2w9/QGSaqRHs99aScGOdDqkFcACoqdbBoQqqjamhH6Q9ng39JCg3lrGJwd50Qk9ovnqBTr8MME7Ps2wiVfygUmPoUBJJfJWX5Nda0nuncbFkA=="))}const qa=j6();new Set(Ba(qa)),new Set(Ba(qa)),q6(qa),$6(qa),new Ve(r0),new Uint8Array(32).fill(0);const K6=`Ethereum Signed Message:
|
22
|
+
`;function a0(t){return typeof t=="string"&&(t=pc(t)),hc(v6([pc(K6),pc(String(t.length)),t]))}const H6="rlp/5.7.0";new Ve(H6);const V6="address/5.7.0",xs=new Ve(V6);function o0(t){dr(t,20)||xs.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=gt(hc(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 G6=9007199254740991;function W6(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10}const bc={};for(let t=0;t<10;t++)bc[String(t)]=String(t);for(let t=0;t<26;t++)bc[String.fromCharCode(65+t)]=String(10+t);const c0=Math.floor(W6(G6));function Y6(t){t=t.toUpperCase(),t=t.substring(4)+t.substring(0,2)+"00";let e=t.split("").map(i=>bc[i]).join("");for(;e.length>=c0;){let i=e.substring(0,c0);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 J6(t){let e=null;if(typeof t!="string"&&xs.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))t.substring(0,2)!=="0x"&&(t="0x"+t),e=o0(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&xs.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)!==Y6(t)&&xs.throwArgumentError("bad icap checksum","address",t),e=x6(t.substring(4));e.length<40;)e="0"+e;e=o0("0x"+e)}else xs.throwArgumentError("invalid address","address",t);return e}const Q6="properties/5.7.0";new Ve(Q6);function Ss(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}new Ve(r0),new Uint8Array(32).fill(0),ft.from(-1);const X6=ft.from(0),Z6=ft.from(1);ft.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Yr(Z6.toHexString(),32),Yr(X6.toHexString(),32);var Jr={},et={},Ms=f0;function f0(t,e){if(!t)throw new Error(e||"Assertion failed")}f0.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)};var vc={exports:{}};typeof Object.create=="function"?vc.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:vc.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}};var em=Ms,tm=vc.exports;et.inherits=tm;function rm(t,e){return(t.charCodeAt(e)&64512)!==55296||e<0||e+1>=t.length?!1:(t.charCodeAt(e+1)&64512)===56320}function im(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):rm(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}et.toArray=im;function nm(t){for(var e="",r=0;r<t.length;r++)e+=u0(t[r].toString(16));return e}et.toHex=nm;function h0(t){var e=t>>>24|t>>>8&65280|t<<8&16711680|(t&255)<<24;return e>>>0}et.htonl=h0;function sm(t,e){for(var r="",i=0;i<t.length;i++){var n=t[i];e==="little"&&(n=h0(n)),r+=d0(n.toString(16))}return r}et.toHex32=sm;function u0(t){return t.length===1?"0"+t:t}et.zero2=u0;function d0(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}et.zero8=d0;function am(t,e,r,i){var n=r-e;em(n%4===0);for(var s=new Array(n/4),o=0,c=e;o<s.length;o++,c+=4){var l;i==="big"?l=t[c]<<24|t[c+1]<<16|t[c+2]<<8|t[c+3]:l=t[c+3]<<24|t[c+2]<<16|t[c+1]<<8|t[c],s[o]=l>>>0}return s}et.join32=am;function om(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}et.split32=om;function cm(t,e){return t>>>e|t<<32-e}et.rotr32=cm;function fm(t,e){return t<<e|t>>>32-e}et.rotl32=fm;function hm(t,e){return t+e>>>0}et.sum32=hm;function um(t,e,r){return t+e+r>>>0}et.sum32_3=um;function dm(t,e,r,i){return t+e+r+i>>>0}et.sum32_4=dm;function lm(t,e,r,i,n){return t+e+r+i+n>>>0}et.sum32_5=lm;function pm(t,e,r,i){var n=t[e],s=t[e+1],o=i+s>>>0,c=(o<i?1:0)+r+n;t[e]=c>>>0,t[e+1]=o}et.sum64=pm;function gm(t,e,r,i){var n=e+i>>>0,s=(n<e?1:0)+t+r;return s>>>0}et.sum64_hi=gm;function bm(t,e,r,i){var n=e+i;return n>>>0}et.sum64_lo=bm;function vm(t,e,r,i,n,s,o,c){var l=0,u=e;u=u+i>>>0,l+=u<e?1:0,u=u+s>>>0,l+=u<s?1:0,u=u+c>>>0,l+=u<c?1:0;var b=t+r+n+o+l;return b>>>0}et.sum64_4_hi=vm;function mm(t,e,r,i,n,s,o,c){var l=e+i+s+c;return l>>>0}et.sum64_4_lo=mm;function ym(t,e,r,i,n,s,o,c,l,u){var b=0,m=e;m=m+i>>>0,b+=m<e?1:0,m=m+s>>>0,b+=m<s?1:0,m=m+c>>>0,b+=m<c?1:0,m=m+u>>>0,b+=m<u?1:0;var M=t+r+n+o+l+b;return M>>>0}et.sum64_5_hi=ym;function wm(t,e,r,i,n,s,o,c,l,u){var b=e+i+s+c+u;return b>>>0}et.sum64_5_lo=wm;function _m(t,e,r){var i=e<<32-r|t>>>r;return i>>>0}et.rotr64_hi=_m;function Am(t,e,r){var i=t<<32-r|e>>>r;return i>>>0}et.rotr64_lo=Am;function Em(t,e,r){return t>>>r}et.shr64_hi=Em;function xm(t,e,r){var i=t<<32-r|e>>>r;return i>>>0}et.shr64_lo=xm;var Gn={},l0=et,Sm=Ms;function Ua(){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}Gn.BlockHash=Ua,Ua.prototype.update=function(t,e){if(t=l0.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){t=this.pending;var r=t.length%this._delta8;this.pending=t.slice(t.length-r,t.length),this.pending.length===0&&(this.pending=null),t=l0.join32(t,0,t.length-r,this.endian);for(var i=0;i<t.length;i+=this._delta32)this._update(t,i,i+this._delta32)}return this},Ua.prototype.digest=function(t){return this.update(this._pad()),Sm(this.pending===null),this._digest(t)},Ua.prototype._pad=function(){var t=this.pendingTotal,e=this._delta8,r=e-(t+this.padLength)%e,i=new Array(r+this.padLength);i[0]=128;for(var n=1;n<r;n++)i[n]=0;if(t<<=3,this.endian==="big"){for(var s=8;s<this.padLength;s++)i[n++]=0;i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=t>>>24&255,i[n++]=t>>>16&255,i[n++]=t>>>8&255,i[n++]=t&255}else for(i[n++]=t&255,i[n++]=t>>>8&255,i[n++]=t>>>16&255,i[n++]=t>>>24&255,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,s=8;s<this.padLength;s++)i[n++]=0;return i};var Wn={},Qr={},Mm=et,Xr=Mm.rotr32;function Im(t,e,r,i){if(t===0)return p0(e,r,i);if(t===1||t===3)return b0(e,r,i);if(t===2)return g0(e,r,i)}Qr.ft_1=Im;function p0(t,e,r){return t&e^~t&r}Qr.ch32=p0;function g0(t,e,r){return t&e^t&r^e&r}Qr.maj32=g0;function b0(t,e,r){return t^e^r}Qr.p32=b0;function Dm(t){return Xr(t,2)^Xr(t,13)^Xr(t,22)}Qr.s0_256=Dm;function Om(t){return Xr(t,6)^Xr(t,11)^Xr(t,25)}Qr.s1_256=Om;function Rm(t){return Xr(t,7)^Xr(t,18)^t>>>3}Qr.g0_256=Rm;function Nm(t){return Xr(t,17)^Xr(t,19)^t>>>10}Qr.g1_256=Nm;var Yn=et,Pm=Gn,Tm=Qr,mc=Yn.rotl32,Is=Yn.sum32,Cm=Yn.sum32_5,Fm=Tm.ft_1,v0=Pm.BlockHash,Lm=[1518500249,1859775393,2400959708,3395469782];function Zr(){if(!(this instanceof Zr))return new Zr;v0.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Yn.inherits(Zr,v0);var Bm=Zr;Zr.blockSize=512,Zr.outSize=160,Zr.hmacStrength=80,Zr.padLength=64,Zr.prototype._update=function(t,e){for(var r=this.W,i=0;i<16;i++)r[i]=t[e+i];for(;i<r.length;i++)r[i]=mc(r[i-3]^r[i-8]^r[i-14]^r[i-16],1);var n=this.h[0],s=this.h[1],o=this.h[2],c=this.h[3],l=this.h[4];for(i=0;i<r.length;i++){var u=~~(i/20),b=Cm(mc(n,5),Fm(u,s,o,c),l,r[i],Lm[u]);l=c,c=o,o=mc(s,30),s=n,n=b}this.h[0]=Is(this.h[0],n),this.h[1]=Is(this.h[1],s),this.h[2]=Is(this.h[2],o),this.h[3]=Is(this.h[3],c),this.h[4]=Is(this.h[4],l)},Zr.prototype._digest=function(t){return t==="hex"?Yn.toHex32(this.h,"big"):Yn.split32(this.h,"big")};var Jn=et,qm=Gn,Qn=Qr,Um=Ms,Nr=Jn.sum32,zm=Jn.sum32_4,km=Jn.sum32_5,$m=Qn.ch32,jm=Qn.maj32,Km=Qn.s0_256,Hm=Qn.s1_256,Vm=Qn.g0_256,Gm=Qn.g1_256,m0=qm.BlockHash,Wm=[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 ei(){if(!(this instanceof ei))return new ei;m0.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=Wm,this.W=new Array(64)}Jn.inherits(ei,m0);var y0=ei;ei.blockSize=512,ei.outSize=256,ei.hmacStrength=192,ei.padLength=64,ei.prototype._update=function(t,e){for(var r=this.W,i=0;i<16;i++)r[i]=t[e+i];for(;i<r.length;i++)r[i]=zm(Gm(r[i-2]),r[i-7],Vm(r[i-15]),r[i-16]);var n=this.h[0],s=this.h[1],o=this.h[2],c=this.h[3],l=this.h[4],u=this.h[5],b=this.h[6],m=this.h[7];for(Um(this.k.length===r.length),i=0;i<r.length;i++){var M=km(m,Hm(l),$m(l,u,b),this.k[i],r[i]),S=Nr(Km(n),jm(n,s,o));m=b,b=u,u=l,l=Nr(c,M),c=o,o=s,s=n,n=Nr(M,S)}this.h[0]=Nr(this.h[0],n),this.h[1]=Nr(this.h[1],s),this.h[2]=Nr(this.h[2],o),this.h[3]=Nr(this.h[3],c),this.h[4]=Nr(this.h[4],l),this.h[5]=Nr(this.h[5],u),this.h[6]=Nr(this.h[6],b),this.h[7]=Nr(this.h[7],m)},ei.prototype._digest=function(t){return t==="hex"?Jn.toHex32(this.h,"big"):Jn.split32(this.h,"big")};var yc=et,w0=y0;function bi(){if(!(this instanceof bi))return new bi;w0.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}yc.inherits(bi,w0);var Ym=bi;bi.blockSize=512,bi.outSize=224,bi.hmacStrength=192,bi.padLength=64,bi.prototype._digest=function(t){return t==="hex"?yc.toHex32(this.h.slice(0,7),"big"):yc.split32(this.h.slice(0,7),"big")};var rr=et,Jm=Gn,Qm=Ms,ti=rr.rotr64_hi,ri=rr.rotr64_lo,_0=rr.shr64_hi,A0=rr.shr64_lo,ki=rr.sum64,wc=rr.sum64_hi,_c=rr.sum64_lo,Xm=rr.sum64_4_hi,Zm=rr.sum64_4_lo,ey=rr.sum64_5_hi,ty=rr.sum64_5_lo,E0=Jm.BlockHash,ry=[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 Pr(){if(!(this instanceof Pr))return new Pr;E0.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=ry,this.W=new Array(160)}rr.inherits(Pr,E0);var x0=Pr;Pr.blockSize=1024,Pr.outSize=512,Pr.hmacStrength=192,Pr.padLength=128,Pr.prototype._prepareBlock=function(t,e){for(var r=this.W,i=0;i<32;i++)r[i]=t[e+i];for(;i<r.length;i+=2){var n=ly(r[i-4],r[i-3]),s=py(r[i-4],r[i-3]),o=r[i-14],c=r[i-13],l=uy(r[i-30],r[i-29]),u=dy(r[i-30],r[i-29]),b=r[i-32],m=r[i-31];r[i]=Xm(n,s,o,c,l,u,b,m),r[i+1]=Zm(n,s,o,c,l,u,b,m)}},Pr.prototype._update=function(t,e){this._prepareBlock(t,e);var r=this.W,i=this.h[0],n=this.h[1],s=this.h[2],o=this.h[3],c=this.h[4],l=this.h[5],u=this.h[6],b=this.h[7],m=this.h[8],M=this.h[9],S=this.h[10],I=this.h[11],F=this.h[12],k=this.h[13],j=this.h[14],C=this.h[15];Qm(this.k.length===r.length);for(var $=0;$<r.length;$+=2){var P=j,B=C,U=fy(m,M),y=hy(m,M),O=iy(m,M,S,I,F),Y=ny(m,M,S,I,F,k),Q=this.k[$],N=this.k[$+1],g=r[$],a=r[$+1],f=ey(P,B,U,y,O,Y,Q,N,g,a),p=ty(P,B,U,y,O,Y,Q,N,g,a);P=oy(i,n),B=cy(i,n),U=sy(i,n,s,o,c),y=ay(i,n,s,o,c,l);var w=wc(P,B,U,y),A=_c(P,B,U,y);j=F,C=k,F=S,k=I,S=m,I=M,m=wc(u,b,f,p),M=_c(b,b,f,p),u=c,b=l,c=s,l=o,s=i,o=n,i=wc(f,p,w,A),n=_c(f,p,w,A)}ki(this.h,0,i,n),ki(this.h,2,s,o),ki(this.h,4,c,l),ki(this.h,6,u,b),ki(this.h,8,m,M),ki(this.h,10,S,I),ki(this.h,12,F,k),ki(this.h,14,j,C)},Pr.prototype._digest=function(t){return t==="hex"?rr.toHex32(this.h,"big"):rr.split32(this.h,"big")};function iy(t,e,r,i,n){var s=t&r^~t&n;return s<0&&(s+=4294967296),s}function ny(t,e,r,i,n,s){var o=e&i^~e&s;return o<0&&(o+=4294967296),o}function sy(t,e,r,i,n){var s=t&r^t&n^r&n;return s<0&&(s+=4294967296),s}function ay(t,e,r,i,n,s){var o=e&i^e&s^i&s;return o<0&&(o+=4294967296),o}function oy(t,e){var r=ti(t,e,28),i=ti(e,t,2),n=ti(e,t,7),s=r^i^n;return s<0&&(s+=4294967296),s}function cy(t,e){var r=ri(t,e,28),i=ri(e,t,2),n=ri(e,t,7),s=r^i^n;return s<0&&(s+=4294967296),s}function fy(t,e){var r=ti(t,e,14),i=ti(t,e,18),n=ti(e,t,9),s=r^i^n;return s<0&&(s+=4294967296),s}function hy(t,e){var r=ri(t,e,14),i=ri(t,e,18),n=ri(e,t,9),s=r^i^n;return s<0&&(s+=4294967296),s}function uy(t,e){var r=ti(t,e,1),i=ti(t,e,8),n=_0(t,e,7),s=r^i^n;return s<0&&(s+=4294967296),s}function dy(t,e){var r=ri(t,e,1),i=ri(t,e,8),n=A0(t,e,7),s=r^i^n;return s<0&&(s+=4294967296),s}function ly(t,e){var r=ti(t,e,19),i=ti(e,t,29),n=_0(t,e,6),s=r^i^n;return s<0&&(s+=4294967296),s}function py(t,e){var r=ri(t,e,19),i=ri(e,t,29),n=A0(t,e,6),s=r^i^n;return s<0&&(s+=4294967296),s}var Ac=et,S0=x0;function vi(){if(!(this instanceof vi))return new vi;S0.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Ac.inherits(vi,S0);var gy=vi;vi.blockSize=1024,vi.outSize=384,vi.hmacStrength=192,vi.padLength=128,vi.prototype._digest=function(t){return t==="hex"?Ac.toHex32(this.h.slice(0,12),"big"):Ac.split32(this.h.slice(0,12),"big")},Wn.sha1=Bm,Wn.sha224=Ym,Wn.sha256=y0,Wn.sha384=gy,Wn.sha512=x0;var M0={},fn=et,by=Gn,za=fn.rotl32,I0=fn.sum32,Ds=fn.sum32_3,D0=fn.sum32_4,O0=by.BlockHash;function ii(){if(!(this instanceof ii))return new ii;O0.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}fn.inherits(ii,O0),M0.ripemd160=ii,ii.blockSize=512,ii.outSize=160,ii.hmacStrength=192,ii.padLength=64,ii.prototype._update=function(t,e){for(var r=this.h[0],i=this.h[1],n=this.h[2],s=this.h[3],o=this.h[4],c=r,l=i,u=n,b=s,m=o,M=0;M<80;M++){var S=I0(za(D0(r,R0(M,i,n,s),t[yy[M]+e],vy(M)),_y[M]),o);r=o,o=s,s=za(n,10),n=i,i=S,S=I0(za(D0(c,R0(79-M,l,u,b),t[wy[M]+e],my(M)),Ay[M]),m),c=m,m=b,b=za(u,10),u=l,l=S}S=Ds(this.h[1],n,b),this.h[1]=Ds(this.h[2],s,m),this.h[2]=Ds(this.h[3],o,c),this.h[3]=Ds(this.h[4],r,l),this.h[4]=Ds(this.h[0],i,u),this.h[0]=S},ii.prototype._digest=function(t){return t==="hex"?fn.toHex32(this.h,"little"):fn.split32(this.h,"little")};function R0(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 vy(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function my(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}var yy=[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],wy=[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],_y=[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],Ay=[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],Ey=et,xy=Ms;function Xn(t,e,r){if(!(this instanceof Xn))return new Xn(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(Ey.toArray(e,r))}var Sy=Xn;Xn.prototype._init=function(t){t.length>this.blockSize&&(t=new this.Hash().update(t).digest()),xy(t.length<=this.blockSize);for(var e=t.length;e<this.blockSize;e++)t.push(0);for(e=0;e<t.length;e++)t[e]^=54;for(this.inner=new this.Hash().update(t),e=0;e<t.length;e++)t[e]^=106;this.outer=new this.Hash().update(t)},Xn.prototype.update=function(t,e){return this.inner.update(t,e),this},Xn.prototype.digest=function(t){return this.outer.update(this.inner.digest()),this.outer.digest(t)},function(t){var e=t;e.utils=et,e.common=Gn,e.sha=Wn,e.ripemd=M0,e.hmac=Sy,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}(Jr);function Zn(t,e,r){return r={path:e,exports:{},require:function(i,n){return My(i,n??r.path)}},t(r,r.exports),r.exports}function My(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var Ec=N0;function N0(t,e){if(!t)throw new Error(e||"Assertion failed")}N0.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)};var Tr=Zn(function(t,e){var r=e;function i(o,c){if(Array.isArray(o))return o.slice();if(!o)return[];var l=[];if(typeof o!="string"){for(var u=0;u<o.length;u++)l[u]=o[u]|0;return l}if(c==="hex"){o=o.replace(/[^a-z0-9]+/ig,""),o.length%2!==0&&(o="0"+o);for(var u=0;u<o.length;u+=2)l.push(parseInt(o[u]+o[u+1],16))}else for(var u=0;u<o.length;u++){var b=o.charCodeAt(u),m=b>>8,M=b&255;m?l.push(m,M):l.push(M)}return l}r.toArray=i;function n(o){return o.length===1?"0"+o:o}r.zero2=n;function s(o){for(var c="",l=0;l<o.length;l++)c+=n(o[l].toString(16));return c}r.toHex=s,r.encode=function(o,c){return c==="hex"?s(o):o}}),lr=Zn(function(t,e){var r=e;r.assert=Ec,r.toArray=Tr.toArray,r.zero2=Tr.zero2,r.toHex=Tr.toHex,r.encode=Tr.encode;function i(l,u,b){var m=new Array(Math.max(l.bitLength(),b)+1);m.fill(0);for(var M=1<<u+1,S=l.clone(),I=0;I<m.length;I++){var F,k=S.andln(M-1);S.isOdd()?(k>(M>>1)-1?F=(M>>1)-k:F=k,S.isubn(F)):F=0,m[I]=F,S.iushrn(1)}return m}r.getNAF=i;function n(l,u){var b=[[],[]];l=l.clone(),u=u.clone();for(var m=0,M=0,S;l.cmpn(-m)>0||u.cmpn(-M)>0;){var I=l.andln(3)+m&3,F=u.andln(3)+M&3;I===3&&(I=-1),F===3&&(F=-1);var k;I&1?(S=l.andln(7)+m&7,(S===3||S===5)&&F===2?k=-I:k=I):k=0,b[0].push(k);var j;F&1?(S=u.andln(7)+M&7,(S===3||S===5)&&I===2?j=-F:j=F):j=0,b[1].push(j),2*m===k+1&&(m=1-m),2*M===j+1&&(M=1-M),l.iushrn(1),u.iushrn(1)}return b}r.getJSF=n;function s(l,u,b){var m="_"+u;l.prototype[u]=function(){return this[m]!==void 0?this[m]:this[m]=b.call(this)}}r.cachedProperty=s;function o(l){return typeof l=="string"?r.toArray(l,"hex"):l}r.parseBytes=o;function c(l){return new je(l,"hex","le")}r.intFromLE=c}),ka=lr.getNAF,Iy=lr.getJSF,$a=lr.assert;function $i(t,e){this.type=t,this.p=new je(e.p,16),this.red=e.prime?je.red(e.prime):je.mont(this.p),this.zero=new je(0).toRed(this.red),this.one=new je(1).toRed(this.red),this.two=new je(2).toRed(this.red),this.n=e.n&&new je(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 hn=$i;$i.prototype.point=function(){throw new Error("Not implemented")},$i.prototype.validate=function(){throw new Error("Not implemented")},$i.prototype._fixedNafMul=function(t,e){$a(t.precomputed);var r=t._getDoubles(),i=ka(e,1,this._bitLength),n=(1<<r.step+1)-(r.step%2===0?2:1);n/=3;var s=[],o,c;for(o=0;o<i.length;o+=r.step){c=0;for(var l=o+r.step-1;l>=o;l--)c=(c<<1)+i[l];s.push(c)}for(var u=this.jpoint(null,null,null),b=this.jpoint(null,null,null),m=n;m>0;m--){for(o=0;o<s.length;o++)c=s[o],c===m?b=b.mixedAdd(r.points[o]):c===-m&&(b=b.mixedAdd(r.points[o].neg()));u=u.add(b)}return u.toP()},$i.prototype._wnafMul=function(t,e){var r=4,i=t._getNAFPoints(r);r=i.wnd;for(var n=i.points,s=ka(e,r,this._bitLength),o=this.jpoint(null,null,null),c=s.length-1;c>=0;c--){for(var l=0;c>=0&&s[c]===0;c--)l++;if(c>=0&&l++,o=o.dblp(l),c<0)break;var u=s[c];$a(u!==0),t.type==="affine"?u>0?o=o.mixedAdd(n[u-1>>1]):o=o.mixedAdd(n[-u-1>>1].neg()):u>0?o=o.add(n[u-1>>1]):o=o.add(n[-u-1>>1].neg())}return t.type==="affine"?o.toP():o},$i.prototype._wnafMulAdd=function(t,e,r,i,n){var s=this._wnafT1,o=this._wnafT2,c=this._wnafT3,l=0,u,b,m;for(u=0;u<i;u++){m=e[u];var M=m._getNAFPoints(t);s[u]=M.wnd,o[u]=M.points}for(u=i-1;u>=1;u-=2){var S=u-1,I=u;if(s[S]!==1||s[I]!==1){c[S]=ka(r[S],s[S],this._bitLength),c[I]=ka(r[I],s[I],this._bitLength),l=Math.max(c[S].length,l),l=Math.max(c[I].length,l);continue}var F=[e[S],null,null,e[I]];e[S].y.cmp(e[I].y)===0?(F[1]=e[S].add(e[I]),F[2]=e[S].toJ().mixedAdd(e[I].neg())):e[S].y.cmp(e[I].y.redNeg())===0?(F[1]=e[S].toJ().mixedAdd(e[I]),F[2]=e[S].add(e[I].neg())):(F[1]=e[S].toJ().mixedAdd(e[I]),F[2]=e[S].toJ().mixedAdd(e[I].neg()));var k=[-3,-1,-5,-7,0,7,5,1,3],j=Iy(r[S],r[I]);for(l=Math.max(j[0].length,l),c[S]=new Array(l),c[I]=new Array(l),b=0;b<l;b++){var C=j[0][b]|0,$=j[1][b]|0;c[S][b]=k[(C+1)*3+($+1)],c[I][b]=0,o[S]=F}}var P=this.jpoint(null,null,null),B=this._wnafT4;for(u=l;u>=0;u--){for(var U=0;u>=0;){var y=!0;for(b=0;b<i;b++)B[b]=c[b][u]|0,B[b]!==0&&(y=!1);if(!y)break;U++,u--}if(u>=0&&U++,P=P.dblp(U),u<0)break;for(b=0;b<i;b++){var O=B[b];O!==0&&(O>0?m=o[b][O-1>>1]:O<0&&(m=o[b][-O-1>>1].neg()),m.type==="affine"?P=P.mixedAdd(m):P=P.add(m))}}for(u=0;u<i;u++)o[u]=null;return n?P:P.toP()};function yr(t,e){this.curve=t,this.type=e,this.precomputed=null}$i.BasePoint=yr,yr.prototype.eq=function(){throw new Error("Not implemented")},yr.prototype.validate=function(){return this.curve.validate(this)},$i.prototype.decodePoint=function(t,e){t=lr.toArray(t,e);var r=this.p.byteLength();if((t[0]===4||t[0]===6||t[0]===7)&&t.length-1===2*r){t[0]===6?$a(t[t.length-1]%2===0):t[0]===7&&$a(t[t.length-1]%2===1);var i=this.point(t.slice(1,1+r),t.slice(1+r,1+2*r));return i}else if((t[0]===2||t[0]===3)&&t.length-1===r)return this.pointFromX(t.slice(1,1+r),t[0]===3);throw new Error("Unknown point format")},yr.prototype.encodeCompressed=function(t){return this.encode(t,!0)},yr.prototype._encode=function(t){var e=this.curve.p.byteLength(),r=this.getX().toArray("be",e);return t?[this.getY().isEven()?2:3].concat(r):[4].concat(r,this.getY().toArray("be",e))},yr.prototype.encode=function(t,e){return lr.encode(this._encode(e),t)},yr.prototype.precompute=function(t){if(this.precomputed)return this;var e={doubles:null,naf:null,beta:null};return e.naf=this._getNAFPoints(8),e.doubles=this._getDoubles(4,t),e.beta=this._getBeta(),this.precomputed=e,this},yr.prototype._hasDoubles=function(t){if(!this.precomputed)return!1;var e=this.precomputed.doubles;return e?e.points.length>=Math.ceil((t.bitLength()+1)/e.step):!1},yr.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],i=this,n=0;n<e;n+=t){for(var s=0;s<t;s++)i=i.dbl();r.push(i)}return{step:t,points:r}},yr.prototype._getNAFPoints=function(t){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var e=[this],r=(1<<t)-1,i=r===1?null:this.dbl(),n=1;n<r;n++)e[n]=e[n-1].add(i);return{wnd:t,points:e}},yr.prototype._getBeta=function(){return null},yr.prototype.dblp=function(t){for(var e=this,r=0;r<t;r++)e=e.dbl();return e};var xc=Zn(function(t){typeof Object.create=="function"?t.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,r){if(r){e.super_=r;var i=function(){};i.prototype=r.prototype,e.prototype=new i,e.prototype.constructor=e}}}),Dy=lr.assert;function wr(t){hn.call(this,"short",t),this.a=new je(t.a,16).toRed(this.red),this.b=new je(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)}xc(wr,hn);var Oy=wr;wr.prototype._getEndomorphism=function(t){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var e,r;if(t.beta)e=new je(t.beta,16).toRed(this.red);else{var i=this._getEndoRoots(this.p);e=i[0].cmp(i[1])<0?i[0]:i[1],e=e.toRed(this.red)}if(t.lambda)r=new je(t.lambda,16);else{var n=this._getEndoRoots(this.n);this.g.mul(n[0]).x.cmp(this.g.x.redMul(e))===0?r=n[0]:(r=n[1],Dy(this.g.mul(r).x.cmp(this.g.x.redMul(e))===0))}var s;return t.basis?s=t.basis.map(function(o){return{a:new je(o.a,16),b:new je(o.b,16)}}):s=this._getEndoBasis(r),{beta:e,lambda:r,basis:s}}},wr.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:je.mont(t),r=new je(2).toRed(e).redInvm(),i=r.redNeg(),n=new je(3).toRed(e).redNeg().redSqrt().redMul(r),s=i.redAdd(n).fromRed(),o=i.redSub(n).fromRed();return[s,o]},wr.prototype._getEndoBasis=function(t){for(var e=this.n.ushrn(Math.floor(this.n.bitLength()/2)),r=t,i=this.n.clone(),n=new je(1),s=new je(0),o=new je(0),c=new je(1),l,u,b,m,M,S,I,F=0,k,j;r.cmpn(0)!==0;){var C=i.div(r);k=i.sub(C.mul(r)),j=o.sub(C.mul(n));var $=c.sub(C.mul(s));if(!b&&k.cmp(e)<0)l=I.neg(),u=n,b=k.neg(),m=j;else if(b&&++F===2)break;I=k,i=r,r=k,o=n,n=j,c=s,s=$}M=k.neg(),S=j;var P=b.sqr().add(m.sqr()),B=M.sqr().add(S.sqr());return B.cmp(P)>=0&&(M=l,S=u),b.negative&&(b=b.neg(),m=m.neg()),M.negative&&(M=M.neg(),S=S.neg()),[{a:b,b:m},{a:M,b:S}]},wr.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],i=e[1],n=i.b.mul(t).divRound(this.n),s=r.b.neg().mul(t).divRound(this.n),o=n.mul(r.a),c=s.mul(i.a),l=n.mul(r.b),u=s.mul(i.b),b=t.sub(o).sub(c),m=l.add(u).neg();return{k1:b,k2:m}},wr.prototype.pointFromX=function(t,e){t=new je(t,16),t.red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),i=r.redSqrt();if(i.redSqr().redSub(r).cmp(this.zero)!==0)throw new Error("invalid point");var n=i.fromRed().isOdd();return(e&&!n||!e&&n)&&(i=i.redNeg()),this.point(t,i)},wr.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,i=this.a.redMul(e),n=e.redSqr().redMul(e).redIAdd(i).redIAdd(this.b);return r.redSqr().redISub(n).cmpn(0)===0},wr.prototype._endoWnafMulAdd=function(t,e,r){for(var i=this._endoWnafT1,n=this._endoWnafT2,s=0;s<t.length;s++){var o=this._endoSplit(e[s]),c=t[s],l=c._getBeta();o.k1.negative&&(o.k1.ineg(),c=c.neg(!0)),o.k2.negative&&(o.k2.ineg(),l=l.neg(!0)),i[s*2]=c,i[s*2+1]=l,n[s*2]=o.k1,n[s*2+1]=o.k2}for(var u=this._wnafMulAdd(1,i,n,s*2,r),b=0;b<s*2;b++)i[b]=null,n[b]=null;return u};function Dt(t,e,r,i){hn.BasePoint.call(this,t,"affine"),e===null&&r===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new je(e,16),this.y=new je(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)}xc(Dt,hn.BasePoint),wr.prototype.point=function(t,e,r){return new Dt(this,t,e,r)},wr.prototype.pointFromJSON=function(t,e){return Dt.fromJSON(this,t,e)},Dt.prototype._getBeta=function(){if(this.curve.endo){var t=this.precomputed;if(t&&t.beta)return t.beta;var e=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(t){var r=this.curve,i=function(n){return r.point(n.x.redMul(r.endo.beta),n.y)};t.beta=e,e.precomputed={beta:null,naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(i)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(i)}}}return e}},Dt.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]},Dt.fromJSON=function(t,e,r){typeof e=="string"&&(e=JSON.parse(e));var i=t.point(e[0],e[1],r);if(!e[2])return i;function n(o){return t.point(o[0],o[1],r)}var s=e[2];return i.precomputed={beta:null,doubles:s.doubles&&{step:s.doubles.step,points:[i].concat(s.doubles.points.map(n))},naf:s.naf&&{wnd:s.naf.wnd,points:[i].concat(s.naf.points.map(n))}},i},Dt.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)+">"},Dt.prototype.isInfinity=function(){return this.inf},Dt.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(this.x.cmp(t.x)===0)return this.curve.point(null,null);var e=this.y.redSub(t.y);e.cmpn(0)!==0&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),i=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,i)},Dt.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(t.cmpn(0)===0)return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),i=t.redInvm(),n=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(i),s=n.redSqr().redISub(this.x.redAdd(this.x)),o=n.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,o)},Dt.prototype.getX=function(){return this.x.fromRed()},Dt.prototype.getY=function(){return this.y.fromRed()},Dt.prototype.mul=function(t){return t=new je(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},Dt.prototype.mulAdd=function(t,e,r){var i=[this,e],n=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n):this.curve._wnafMulAdd(1,i,n,2)},Dt.prototype.jmulAdd=function(t,e,r){var i=[this,e],n=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n,!0):this.curve._wnafMulAdd(1,i,n,2,!0)},Dt.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||this.x.cmp(t.x)===0&&this.y.cmp(t.y)===0)},Dt.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,i=function(n){return n.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(i)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(i)}}}return e},Dt.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var t=this.curve.jpoint(this.x,this.y,this.curve.one);return t};function Ct(t,e,r,i){hn.BasePoint.call(this,t,"jacobian"),e===null&&r===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new je(0)):(this.x=new je(e,16),this.y=new je(r,16),this.z=new je(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}xc(Ct,hn.BasePoint),wr.prototype.jpoint=function(t,e,r){return new Ct(this,t,e,r)},Ct.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),i=this.y.redMul(e).redMul(t);return this.curve.point(r,i)},Ct.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Ct.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),i=this.x.redMul(e),n=t.x.redMul(r),s=this.y.redMul(e.redMul(t.z)),o=t.y.redMul(r.redMul(this.z)),c=i.redSub(n),l=s.redSub(o);if(c.cmpn(0)===0)return l.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var u=c.redSqr(),b=u.redMul(c),m=i.redMul(u),M=l.redSqr().redIAdd(b).redISub(m).redISub(m),S=l.redMul(m.redISub(M)).redISub(s.redMul(b)),I=this.z.redMul(t.z).redMul(c);return this.curve.jpoint(M,S,I)},Ct.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,i=t.x.redMul(e),n=this.y,s=t.y.redMul(e).redMul(this.z),o=r.redSub(i),c=n.redSub(s);if(o.cmpn(0)===0)return c.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var l=o.redSqr(),u=l.redMul(o),b=r.redMul(l),m=c.redSqr().redIAdd(u).redISub(b).redISub(b),M=c.redMul(b.redISub(m)).redISub(n.redMul(u)),S=this.z.redMul(o);return this.curve.jpoint(m,M,S)},Ct.prototype.dblp=function(t){if(t===0)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var r=this;for(e=0;e<t;e++)r=r.dbl();return r}var i=this.curve.a,n=this.curve.tinv,s=this.x,o=this.y,c=this.z,l=c.redSqr().redSqr(),u=o.redAdd(o);for(e=0;e<t;e++){var b=s.redSqr(),m=u.redSqr(),M=m.redSqr(),S=b.redAdd(b).redIAdd(b).redIAdd(i.redMul(l)),I=s.redMul(m),F=S.redSqr().redISub(I.redAdd(I)),k=I.redISub(F),j=S.redMul(k);j=j.redIAdd(j).redISub(M);var C=u.redMul(c);e+1<t&&(l=l.redMul(M)),s=F,c=C,u=j}return this.curve.jpoint(s,u.redMul(n),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 t,e,r;if(this.zOne){var i=this.x.redSqr(),n=this.y.redSqr(),s=n.redSqr(),o=this.x.redAdd(n).redSqr().redISub(i).redISub(s);o=o.redIAdd(o);var c=i.redAdd(i).redIAdd(i),l=c.redSqr().redISub(o).redISub(o),u=s.redIAdd(s);u=u.redIAdd(u),u=u.redIAdd(u),t=l,e=c.redMul(o.redISub(l)).redISub(u),r=this.y.redAdd(this.y)}else{var b=this.x.redSqr(),m=this.y.redSqr(),M=m.redSqr(),S=this.x.redAdd(m).redSqr().redISub(b).redISub(M);S=S.redIAdd(S);var I=b.redAdd(b).redIAdd(b),F=I.redSqr(),k=M.redIAdd(M);k=k.redIAdd(k),k=k.redIAdd(k),t=F.redISub(S).redISub(S),e=I.redMul(S.redISub(t)).redISub(k),r=this.y.redMul(this.z),r=r.redIAdd(r)}return this.curve.jpoint(t,e,r)},Ct.prototype._threeDbl=function(){var t,e,r;if(this.zOne){var i=this.x.redSqr(),n=this.y.redSqr(),s=n.redSqr(),o=this.x.redAdd(n).redSqr().redISub(i).redISub(s);o=o.redIAdd(o);var c=i.redAdd(i).redIAdd(i).redIAdd(this.curve.a),l=c.redSqr().redISub(o).redISub(o);t=l;var u=s.redIAdd(s);u=u.redIAdd(u),u=u.redIAdd(u),e=c.redMul(o.redISub(l)).redISub(u),r=this.y.redAdd(this.y)}else{var b=this.z.redSqr(),m=this.y.redSqr(),M=this.x.redMul(m),S=this.x.redSub(b).redMul(this.x.redAdd(b));S=S.redAdd(S).redIAdd(S);var I=M.redIAdd(M);I=I.redIAdd(I);var F=I.redAdd(I);t=S.redSqr().redISub(F),r=this.y.redAdd(this.z).redSqr().redISub(m).redISub(b);var k=m.redSqr();k=k.redIAdd(k),k=k.redIAdd(k),k=k.redIAdd(k),e=S.redMul(I.redISub(t)).redISub(k)}return this.curve.jpoint(t,e,r)},Ct.prototype._dbl=function(){var t=this.curve.a,e=this.x,r=this.y,i=this.z,n=i.redSqr().redSqr(),s=e.redSqr(),o=r.redSqr(),c=s.redAdd(s).redIAdd(s).redIAdd(t.redMul(n)),l=e.redAdd(e);l=l.redIAdd(l);var u=l.redMul(o),b=c.redSqr().redISub(u.redAdd(u)),m=u.redISub(b),M=o.redSqr();M=M.redIAdd(M),M=M.redIAdd(M),M=M.redIAdd(M);var S=c.redMul(m).redISub(M),I=r.redAdd(r).redMul(i);return this.curve.jpoint(b,S,I)},Ct.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr(),i=e.redSqr(),n=t.redAdd(t).redIAdd(t),s=n.redSqr(),o=this.x.redAdd(e).redSqr().redISub(t).redISub(i);o=o.redIAdd(o),o=o.redAdd(o).redIAdd(o),o=o.redISub(s);var c=o.redSqr(),l=i.redIAdd(i);l=l.redIAdd(l),l=l.redIAdd(l),l=l.redIAdd(l);var u=n.redIAdd(o).redSqr().redISub(s).redISub(c).redISub(l),b=e.redMul(u);b=b.redIAdd(b),b=b.redIAdd(b);var m=this.x.redMul(c).redISub(b);m=m.redIAdd(m),m=m.redIAdd(m);var M=this.y.redMul(u.redMul(l.redISub(u)).redISub(o.redMul(c)));M=M.redIAdd(M),M=M.redIAdd(M),M=M.redIAdd(M);var S=this.z.redAdd(o).redSqr().redISub(r).redISub(c);return this.curve.jpoint(m,M,S)},Ct.prototype.mul=function(t,e){return t=new je(t,e),this.curve._wnafMul(this,t)},Ct.prototype.eq=function(t){if(t.type==="affine")return this.eq(t.toJ());if(this===t)return!0;var e=this.z.redSqr(),r=t.z.redSqr();if(this.x.redMul(r).redISub(t.x.redMul(e)).cmpn(0)!==0)return!1;var i=e.redMul(this.z),n=r.redMul(t.z);return this.y.redMul(n).redISub(t.y.redMul(i)).cmpn(0)===0},Ct.prototype.eqXToP=function(t){var e=this.z.redSqr(),r=t.toRed(this.curve.red).redMul(e);if(this.x.cmp(r)===0)return!0;for(var i=t.clone(),n=this.curve.redN.redMul(e);;){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}},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 ja=Zn(function(t,e){var r=e;r.base=hn,r.short=Oy,r.mont=null,r.edwards=null}),Ka=Zn(function(t,e){var r=e,i=lr.assert;function n(c){c.type==="short"?this.curve=new ja.short(c):c.type==="edwards"?this.curve=new ja.edwards(c):this.curve=new ja.mont(c),this.g=this.curve.g,this.n=this.curve.n,this.hash=c.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}r.PresetCurve=n;function s(c,l){Object.defineProperty(r,c,{configurable:!0,enumerable:!0,get:function(){var u=new n(l);return Object.defineProperty(r,c,{configurable:!0,enumerable:!0,value:u}),u}})}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:Jr.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:Jr.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:Jr.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:Jr.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:Jr.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:Jr.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:Jr.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:Jr.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})});function ji(t){if(!(this instanceof ji))return new ji(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=Tr.toArray(t.entropy,t.entropyEnc||"hex"),r=Tr.toArray(t.nonce,t.nonceEnc||"hex"),i=Tr.toArray(t.pers,t.persEnc||"hex");Ec(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,i)}var P0=ji;ji.prototype._init=function(t,e,r){var i=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var n=0;n<this.V.length;n++)this.K[n]=0,this.V[n]=1;this._update(i),this._reseed=1,this.reseedInterval=281474976710656},ji.prototype._hmac=function(){return new Jr.hmac(this.hash,this.K)},ji.prototype._update=function(t){var e=this._hmac().update(this.V).update([0]);t&&(e=e.update(t)),this.K=e.digest(),this.V=this._hmac().update(this.V).digest(),t&&(this.K=this._hmac().update(this.V).update([1]).update(t).digest(),this.V=this._hmac().update(this.V).digest())},ji.prototype.reseed=function(t,e,r,i){typeof e!="string"&&(i=r,r=e,e=null),t=Tr.toArray(t,e),r=Tr.toArray(r,i),Ec(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},ji.prototype.generate=function(t,e,r,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof e!="string"&&(i=r,r=e,e=null),r&&(r=Tr.toArray(r,i||"hex"),this._update(r));for(var n=[];n.length<t;)this.V=this._hmac().update(this.V).digest(),n=n.concat(this.V);var s=n.slice(0,t);return this._update(r),this._reseed++,Tr.encode(s,e)};var Sc=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 Mc=kt;kt.fromPublic=function(t,e,r){return e instanceof kt?e:new kt(t,{pub:e,pubEnc:r})},kt.fromPrivate=function(t,e,r){return e instanceof kt?e:new kt(t,{priv:e,privEnc:r})},kt.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.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(t,e){return typeof t=="string"&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub},kt.prototype.getPrivate=function(t){return t==="hex"?this.priv.toString(16,2):this.priv},kt.prototype._importPrivate=function(t,e){this.priv=new je(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)},kt.prototype._importPublic=function(t,e){if(t.x||t.y){this.ec.curve.type==="mont"?Sc(t.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&Sc(t.x&&t.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(t.x,t.y);return}this.pub=this.ec.curve.decodePoint(t,e)},kt.prototype.derive=function(t){return t.validate()||Sc(t.validate(),"public point not validated"),t.mul(this.priv).getX()},kt.prototype.sign=function(t,e,r){return this.ec.sign(t,this,e,r)},kt.prototype.verify=function(t,e){return this.ec.verify(t,e,this)},kt.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var Ry=lr.assert;function Ha(t,e){if(t instanceof Ha)return t;this._importDER(t,e)||(Ry(t.r&&t.s,"Signature without r or s"),this.r=new je(t.r,16),this.s=new je(t.s,16),t.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var Va=Ha;function Ny(){this.place=0}function Ic(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 T0(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)}Ha.prototype._importDER=function(t,e){t=lr.toArray(t,e);var r=new Ny;if(t[r.place++]!==48)return!1;var i=Ic(t,r);if(i===!1||i+r.place!==t.length||t[r.place++]!==2)return!1;var n=Ic(t,r);if(n===!1)return!1;var s=t.slice(r.place,n+r.place);if(r.place+=n,t[r.place++]!==2)return!1;var o=Ic(t,r);if(o===!1||t.length!==o+r.place)return!1;var c=t.slice(r.place,o+r.place);if(s[0]===0)if(s[1]&128)s=s.slice(1);else return!1;if(c[0]===0)if(c[1]&128)c=c.slice(1);else return!1;return this.r=new je(s),this.s=new je(c),this.recoveryParam=null,!0};function Dc(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)}Ha.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(e[0]&128&&(e=[0].concat(e)),r[0]&128&&(r=[0].concat(r)),e=T0(e),r=T0(r);!r[0]&&!(r[1]&128);)r=r.slice(1);var i=[2];Dc(i,e.length),i=i.concat(e),i.push(2),Dc(i,r.length);var n=i.concat(r),s=[48];return Dc(s,n.length),s=s.concat(n),lr.encode(s,t)};var Py=function(){throw new Error("unsupported")},C0=lr.assert;function _r(t){if(!(this instanceof _r))return new _r(t);typeof t=="string"&&(C0(Object.prototype.hasOwnProperty.call(Ka,t),"Unknown curve "+t),t=Ka[t]),t instanceof Ka.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 Ty=_r;_r.prototype.keyPair=function(t){return new Mc(this,t)},_r.prototype.keyFromPrivate=function(t,e){return Mc.fromPrivate(this,t,e)},_r.prototype.keyFromPublic=function(t,e){return Mc.fromPublic(this,t,e)},_r.prototype.genKeyPair=function(t){t||(t={});for(var e=new P0({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||Py(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),i=this.n.sub(new je(2));;){var n=new je(e.generate(r));if(!(n.cmp(i)>0))return n.iaddn(1),this.keyFromPrivate(n)}},_r.prototype._truncateToN=function(t,e){var r=t.byteLength()*8-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},_r.prototype.sign=function(t,e,r,i){typeof r=="object"&&(i=r,r=null),i||(i={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new je(t,16));for(var n=this.n.byteLength(),s=e.getPrivate().toArray("be",n),o=t.toArray("be",n),c=new P0({hash:this.hash,entropy:s,nonce:o,pers:i.pers,persEnc:i.persEnc||"utf8"}),l=this.n.sub(new je(1)),u=0;;u++){var b=i.k?i.k(u):new je(c.generate(this.n.byteLength()));if(b=this._truncateToN(b,!0),!(b.cmpn(1)<=0||b.cmp(l)>=0)){var m=this.g.mul(b);if(!m.isInfinity()){var M=m.getX(),S=M.umod(this.n);if(S.cmpn(0)!==0){var I=b.invm(this.n).mul(S.mul(e.getPrivate()).iadd(t));if(I=I.umod(this.n),I.cmpn(0)!==0){var F=(m.getY().isOdd()?1:0)|(M.cmp(S)!==0?2:0);return i.canonical&&I.cmp(this.nh)>0&&(I=this.n.sub(I),F^=1),new Va({r:S,s:I,recoveryParam:F})}}}}}},_r.prototype.verify=function(t,e,r,i){t=this._truncateToN(new je(t,16)),r=this.keyFromPublic(r,i),e=new Va(e,"hex");var n=e.r,s=e.s;if(n.cmpn(1)<0||n.cmp(this.n)>=0||s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var o=s.invm(this.n),c=o.mul(t).umod(this.n),l=o.mul(n).umod(this.n),u;return this.curve._maxwellTrick?(u=this.g.jmulAdd(c,r.getPublic(),l),u.isInfinity()?!1:u.eqXToP(n)):(u=this.g.mulAdd(c,r.getPublic(),l),u.isInfinity()?!1:u.getX().umod(this.n).cmp(n)===0)},_r.prototype.recoverPubKey=function(t,e,r,i){C0((3&r)===r,"The recovery param is more than two bits"),e=new Va(e,i);var n=this.n,s=new je(t),o=e.r,c=e.s,l=r&1,u=r>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");u?o=this.curve.pointFromX(o.add(this.curve.n),l):o=this.curve.pointFromX(o,l);var b=e.r.invm(n),m=n.sub(s).mul(b).umod(n),M=c.mul(b).umod(n);return this.g.mulAdd(m,o,M)},_r.prototype.getKeyRecoveryParam=function(t,e,r,i){if(e=new Va(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 Cy=Zn(function(t,e){var r=e;r.version="6.5.4",r.utils=lr,r.rand=function(){throw new Error("unsupported")},r.curve=ja,r.curves=Ka,r.ec=Ty,r.eddsa=null}),Fy=Cy.ec;const Ly="signing-key/5.7.0",Oc=new Ve(Ly);let Rc=null;function ni(){return Rc||(Rc=new Fy("secp256k1")),Rc}class By{constructor(e){Ss(this,"curve","secp256k1"),Ss(this,"privateKey",Vt(e)),y6(this.privateKey)!==32&&Oc.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const r=ni().keyFromPrivate(gt(this.privateKey));Ss(this,"publicKey","0x"+r.getPublic(!1,"hex")),Ss(this,"compressedPublicKey","0x"+r.getPublic(!0,"hex")),Ss(this,"_isSigningKey",!0)}_addPoint(e){const r=ni().keyFromPublic(gt(this.publicKey)),i=ni().keyFromPublic(gt(e));return"0x"+r.pub.add(i.pub).encodeCompressed("hex")}signDigest(e){const r=ni().keyFromPrivate(gt(this.privateKey)),i=gt(e);i.length!==32&&Oc.throwArgumentError("bad digest length","digest",e);const n=r.sign(i,{canonical:!0});return Ku({recoveryParam:n.recoveryParam,r:Yr("0x"+n.r.toString(16),32),s:Yr("0x"+n.s.toString(16),32)})}computeSharedSecret(e){const r=ni().keyFromPrivate(gt(this.privateKey)),i=ni().keyFromPublic(gt(F0(e)));return Yr("0x"+r.derive(i.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}}function qy(t,e){const r=Ku(e),i={r:gt(r.r),s:gt(r.s)};return"0x"+ni().recoverPubKey(gt(t),i,r.recoveryParam).encode("hex",!1)}function F0(t,e){const r=gt(t);if(r.length===32){const i=new By(r);return e?"0x"+ni().keyFromPrivate(r).getPublic(!0,"hex"):i.publicKey}else{if(r.length===33)return e?Vt(r):"0x"+ni().keyFromPublic(r).getPublic(!1,"hex");if(r.length===65)return e?"0x"+ni().keyFromPublic(r).getPublic(!0,"hex"):Vt(r)}return Oc.throwArgumentError("invalid public or private key","key","[REDACTED]")}const Uy="transactions/5.7.0";new Ve(Uy);var L0;(function(t){t[t.legacy=0]="legacy",t[t.eip2930=1]="eip2930",t[t.eip1559=2]="eip1559"})(L0||(L0={}));function zy(t){const e=F0(t);return J6(ju(hc(ju(e,1)),12))}function ky(t,e){return zy(qy(gt(t),e))}const $y="https://rpc.walletconnect.org/v1";async function jy(t,e,r,i,n,s){switch(r.t){case"eip191":return Ky(t,e,r.s);case"eip1271":return await Hy(t,e,r.s,i,n,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r.t}`)}}function Ky(t,e,r){return ky(a0(e),r).toLowerCase()===t.toLowerCase()}async function Hy(t,e,r,i,n,s){try{const o="0x1626ba7e",c="0000000000000000000000000000000000000000000000000000000000000040",l="0000000000000000000000000000000000000000000000000000000000000041",u=r.substring(2),b=a0(e).substring(2),m=o+b+c+l+u,M=await fetch(`${s||$y}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:Vy(),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:m},"latest"]})}),{result:S}=await M.json();return S?S.slice(0,o.length).toLowerCase()===o.toLowerCase():!1}catch(o){return console.error("isValidEip1271Signature: ",o),!1}}function Vy(){return Date.now()+Math.floor(Math.random()*1e3)}var Gy=Object.defineProperty,Wy=Object.defineProperties,Yy=Object.getOwnPropertyDescriptors,B0=Object.getOwnPropertySymbols,Jy=Object.prototype.hasOwnProperty,Qy=Object.prototype.propertyIsEnumerable,q0=(t,e,r)=>e in t?Gy(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Xy=(t,e)=>{for(var r in e||(e={}))Jy.call(e,r)&&q0(t,r,e[r]);if(B0)for(var r of B0(e))Qy.call(e,r)&&q0(t,r,e[r]);return t},Zy=(t,e)=>Wy(t,Yy(e));const e5="did:pkh:",Nc=t=>t?.split(":"),U0=t=>{const e=t&&Nc(t);if(e)return t.includes(e5)?e[3]:e[1]},z0=t=>{const e=t&&Nc(t);if(e)return e[2]+":"+e[3]},Ga=t=>{const e=t&&Nc(t);if(e)return e.pop()};async function k0(t){const{cacao:e,projectId:r}=t,{s:i,p:n}=e,s=$0(n,n.iss),o=Ga(n.iss);return await jy(o,s,i,U0(n.iss),r)}const $0=(t,e)=>{const r=`${t.domain} wants you to sign in with your Ethereum account:`,i=Ga(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}`,c=`Chain ID: ${U0(e)}`,l=`Nonce: ${t.nonce}`,u=`Issued At: ${t.iat}`,b=t.exp?`Expiration Time: ${t.exp}`:void 0,m=t.nbf?`Not Before: ${t.nbf}`:void 0,M=t.requestId?`Request ID: ${t.requestId}`:void 0,S=t.resources?`Resources:${t.resources.map(F=>`
|
23
|
+
- ${F}`).join("")}`:void 0,I=Wa(t.resources);if(I){const F=Os(I);n=f5(n,F)}return[r,i,"",n,"",s,o,c,l,u,b,m,M,S].filter(F=>F!=null).join(`
|
24
|
+
`)};function t5(t){return Buffer.from(JSON.stringify(t)).toString("base64")}function r5(t){return JSON.parse(Buffer.from(t,"base64").toString("utf-8"))}function un(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 i5(t,e,r,i={}){return r?.sort((n,s)=>n.localeCompare(s)),{att:{[t]:n5(e,r,i)}}}function n5(t,e,r={}){e=e?.sort((n,s)=>n.localeCompare(s));const i=e.map(n=>({[`${t}/${n}`]:[r]}));return Object.assign({},...i)}function j0(t){return un(t),`urn:recap:${t5(t).replace(/=/g,"")}`}function Os(t){const e=r5(t.replace("urn:recap:",""));return un(e),e}function s5(t,e,r){const i=i5(t,e,r);return j0(i)}function a5(t){return t&&t.includes("urn:recap:")}function o5(t,e){const r=Os(t),i=Os(e),n=c5(r,i);return j0(n)}function c5(t,e){un(t),un(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((c,l)=>c.localeCompare(l)).forEach(c=>{var l,u;i.att[n]=Zy(Xy({},i.att[n]),{[c]:((l=t.att[n])==null?void 0:l[c])||((u=e.att[n])==null?void 0:u[c])})})}),i}function f5(t="",e){un(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(c=>{const l=Object.keys(e.att[c]).map(m=>({ability:m.split("/")[0],action:m.split("/")[1]}));l.sort((m,M)=>m.action.localeCompare(M.action));const u={};l.forEach(m=>{u[m.ability]||(u[m.ability]=[]),u[m.ability].push(m.action)});const b=Object.keys(u).map(m=>(n++,`(${n}) '${m}': '${u[m].join("', '")}' for '${c}'.`));i.push(b.join(", ").replace(".,","."))});const s=i.join(" "),o=`${r}${s}`;return`${t?t+" ":""}${o}`}function K0(t){var e;const r=Os(t);un(r);const i=(e=r.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function H0(t){const e=Os(t);un(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 Wa(t){if(!t)return;const e=t?.[t.length-1];return a5(e)?e:void 0}const V0="base10",Wt="base16",Ki="base64pad",Rs="base64url",Ns="utf8",G0=0,mi=1,Ps=2,h5=0,W0=1,Ts=12,Pc=32;function u5(){const t=$o.generateKeyPair();return{privateKey:Et(t.secretKey,Wt),publicKey:Et(t.publicKey,Wt)}}function Tc(){const t=Ci.randomBytes(Pc);return Et(t,Wt)}function d5(t,e){const r=$o.sharedKey(xt(t,Wt),xt(e,Wt),!0),i=new D2(ps.SHA256,r).expand(Pc);return Et(i,Wt)}function Ya(t){const e=ps.hash(xt(t,Wt));return Et(e,Wt)}function yi(t){const e=ps.hash(xt(t,Ns));return Et(e,Wt)}function Y0(t){return xt(`${t}`,V0)}function dn(t){return Number(Et(t,V0))}function l5(t){const e=Y0(typeof t.type<"u"?t.type:G0);if(dn(e)===mi&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof t.senderPublicKey<"u"?xt(t.senderPublicKey,Wt):void 0,i=typeof t.iv<"u"?xt(t.iv,Wt):Ci.randomBytes(Ts),n=new Uo.ChaCha20Poly1305(xt(t.symKey,Wt)).seal(i,xt(t.message,Ns));return J0({type:e,sealed:n,iv:i,senderPublicKey:r,encoding:t.encoding})}function p5(t,e){const r=Y0(Ps),i=Ci.randomBytes(Ts),n=xt(t,Ns);return J0({type:r,sealed:n,iv:i,encoding:e})}function g5(t){const e=new Uo.ChaCha20Poly1305(xt(t.symKey,Wt)),{sealed:r,iv:i}=Cs({encoded:t.encoded,encoding:t?.encoding}),n=e.open(i,r);if(n===null)throw new Error("Failed to decrypt");return Et(n,Ns)}function b5(t,e){const{sealed:r}=Cs({encoded:t,encoding:e});return Et(r,Ns)}function J0(t){const{encoding:e=Ki}=t;if(dn(t.type)===Ps)return Et(la([t.type,t.sealed]),e);if(dn(t.type)===mi){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return Et(la([t.type,t.senderPublicKey,t.iv,t.sealed]),e)}return Et(la([t.type,t.iv,t.sealed]),e)}function Cs(t){const{encoded:e,encoding:r=Ki}=t,i=xt(e,r),n=i.slice(h5,W0),s=W0;if(dn(n)===mi){const u=s+Pc,b=u+Ts,m=i.slice(s,u),M=i.slice(u,b),S=i.slice(b);return{type:n,sealed:S,iv:M,senderPublicKey:m}}if(dn(n)===Ps){const u=i.slice(s),b=Ci.randomBytes(Ts);return{type:n,sealed:u,iv:b}}const o=s+Ts,c=i.slice(s,o),l=i.slice(o);return{type:n,sealed:l,iv:c}}function v5(t,e){const r=Cs({encoded:t,encoding:e?.encoding});return Q0({type:dn(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?Et(r.senderPublicKey,Wt):void 0,receiverPublicKey:e?.receiverPublicKey})}function Q0(t){const e=t?.type||G0;if(e===mi){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 X0(t){return t.type===mi&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}function Z0(t){return t.type===Ps}function m5(t){return new qh.ec("p256").keyFromPublic({x:Buffer.from(t.x,"base64").toString("hex"),y:Buffer.from(t.y,"base64").toString("hex")},"hex")}function y5(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");const r=e.length%4;return r>0&&(e+="=".repeat(4-r)),e}function w5(t){return Buffer.from(y5(t),"base64")}function _5(t,e){const[r,i,n]=t.split("."),s=w5(n);if(s.length!==64)throw new Error("Invalid signature length");const o=s.slice(0,32).toString("hex"),c=s.slice(32,64).toString("hex"),l=`${r}.${i}`,u=new ps.SHA256().update(Buffer.from(l)).digest(),b=m5(e),m=Buffer.from(u).toString("hex");if(!b.verify(m,{r:o,s:c}))throw new Error("Invalid signature");return Fo(t).payload}const A5="irn";function Cc(t){return t?.relay||{protocol:A5}}function Fs(t){const e=Hv[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}var E5=Object.defineProperty,x5=Object.defineProperties,S5=Object.getOwnPropertyDescriptors,ed=Object.getOwnPropertySymbols,M5=Object.prototype.hasOwnProperty,I5=Object.prototype.propertyIsEnumerable,td=(t,e,r)=>e in t?E5(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,rd=(t,e)=>{for(var r in e||(e={}))M5.call(e,r)&&td(t,r,e[r]);if(ed)for(var r of ed(e))I5.call(e,r)&&td(t,r,e[r]);return t},D5=(t,e)=>x5(t,S5(e));function O5(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 id(t){if(!t.includes("wc:")){const l=Tu(t);l!=null&&l.includes("wc:")&&(t=l)}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=ds.parse(s),c=typeof o.methods=="string"?o.methods.split(","):void 0;return{protocol:i,topic:R5(n[0]),version:parseInt(n[1],10),symKey:o.symKey,relay:O5(o),methods:c,expiryTimestamp:o.expiryTimestamp?parseInt(o.expiryTimestamp,10):void 0}}function R5(t){return t.startsWith("//")?t.substring(2):t}function N5(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 nd(t){return`${t.protocol}:${t.topic}@${t.version}?`+ds.stringify(rd(D5(rd({symKey:t.symKey},N5(t.relay)),{expiryTimestamp:t.expiryTimestamp}),t.methods?{methods:t.methods.join(",")}:{}))}function Ja(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 P5(t){const e=[];return Object.values(t).forEach(r=>{e.push(...es(r.accounts))}),e}function T5(t,e){const r=[];return Object.values(t).forEach(i=>{es(i.accounts).includes(e)&&r.push(...i.methods)}),r}function C5(t,e){const r=[];return Object.values(t).forEach(i=>{es(i.accounts).includes(e)&&r.push(...i.events)}),r}function F5(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 sd(t,e){e=e.map(i=>i.replace("did:pkh:",""));const r=F5(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 L5={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}},B5={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 ie(t,e){const{message:r,code:i}=B5[t];return{message:e?`${r} ${e}`:r,code:i}}function ht(t,e){const{message:r,code:i}=L5[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 Qa(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function Yt(t){return typeof t>"u"}function yt(t,e){return e&&Yt(t)?!0:typeof t=="string"&&!!t.trim().length}function Fc(t,e){return e&&Yt(t)?!0:typeof t=="number"&&!isNaN(t)}function q5(t,e){const{requiredNamespaces:r}=e,i=Object.keys(t.namespaces),n=Object.keys(r);let s=!0;return on(n,i)?(i.forEach(o=>{const{accounts:c,methods:l,events:u}=t.namespaces[o],b=es(c),m=r[o];(!on(_u(o,m),b)||!on(m.methods,l)||!on(m.events,u))&&(s=!1)}),s):!1}function Xa(t){return yt(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function U5(t){if(yt(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const r=e[0]+":"+e[1];return!!e[2]&&Xa(r)}}return!1}function z5(t){function e(r){try{return typeof new URL(r)<"u"}catch{return!1}}try{if(yt(t,!1)){if(e(t))return!0;const r=Tu(t);return e(r)}}catch{}return!1}function k5(t){var e;return(e=t?.proposer)==null?void 0:e.publicKey}function $5(t){return t?.topic}function j5(t,e){let r=null;return yt(t?.publicKey,!1)||(r=ie("MISSING_OR_INVALID",`${e} controller public key should be a string`)),r}function ad(t){let e=!0;return Ls(t)?t.length&&(e=t.every(r=>yt(r,!1))):e=!1,e}function K5(t,e,r){let i=null;return Ls(e)&&e.length?e.forEach(n=>{i||Xa(n)||(i=ht("UNSUPPORTED_CHAINS",`${r}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):Xa(t)||(i=ht("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 H5(t,e,r){let i=null;return Object.entries(t).forEach(([n,s])=>{if(i)return;const o=K5(n,_u(n,s),`${e} ${r}`);o&&(i=o)}),i}function V5(t,e){let r=null;return Ls(t)?t.forEach(i=>{r||U5(i)||(r=ht("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):r=ht("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function G5(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=V5(i?.accounts,`${e} namespace`);n&&(r=n)}),r}function W5(t,e){let r=null;return ad(t?.methods)?ad(t?.events)||(r=ht("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):r=ht("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),r}function od(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const n=W5(i,`${e}, namespace`);n&&(r=n)}),r}function Y5(t,e,r){let i=null;if(t&&Qa(t)){const n=od(t,e);n&&(i=n);const s=H5(t,e,r);s&&(i=s)}else i=ie("MISSING_OR_INVALID",`${e}, ${r} should be an object with data`);return i}function Lc(t,e){let r=null;if(t&&Qa(t)){const i=od(t,e);i&&(r=i);const n=G5(t,e);n&&(r=n)}else r=ie("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function cd(t){return yt(t.protocol,!0)}function J5(t,e){let r=!1;return e&&!t?r=!0:t&&Ls(t)&&t.length&&t.forEach(i=>{r=cd(i)}),r}function Q5(t){return typeof t=="number"}function ir(t){return typeof t<"u"&&typeof t!==null}function X5(t){return!(!t||typeof t!="object"||!t.code||!Fc(t.code,!1)||!t.message||!yt(t.message,!1))}function Z5(t){return!(Yt(t)||!yt(t.method,!1))}function e8(t){return!(Yt(t)||Yt(t.result)&&Yt(t.error)||!Fc(t.id,!1)||!yt(t.jsonrpc,!1))}function t8(t){return!(Yt(t)||!yt(t.name,!1))}function fd(t,e){return!(!Xa(e)||!P5(t).includes(e))}function r8(t,e,r){return yt(r,!1)?T5(t,e).includes(r):!1}function i8(t,e,r){return yt(r,!1)?C5(t,e).includes(r):!1}function hd(t,e,r){let i=null;const n=n8(t),s=s8(e),o=Object.keys(n),c=Object.keys(s),l=ud(Object.keys(t)),u=ud(Object.keys(e)),b=l.filter(m=>!u.includes(m));return b.length&&(i=ie("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces.
|
25
25
|
Required: ${b.toString()}
|
26
26
|
Received: ${Object.keys(e).toString()}`)),on(o,c)||(i=ie("NON_CONFORMING_NAMESPACES",`${r} namespaces chains don't satisfy required namespaces.
|
27
27
|
Required: ${o.toString()}
|
28
|
-
Approved: ${c.toString()}`)),Object.keys(e).forEach(m=>{if(!m.includes(":")||i)return;const M=
|
28
|
+
Approved: ${c.toString()}`)),Object.keys(e).forEach(m=>{if(!m.includes(":")||i)return;const M=es(e[m].accounts);M.includes(m)||(i=ie("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${m}
|
29
29
|
Required: ${m}
|
30
|
-
Approved: ${M.toString()}`))}),o.forEach(m=>{i||(on(n[m].methods,s[m].methods)?on(n[m].events,s[m].events)||(i=ie("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${m}`)):i=ie("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${m}`))}),i}function
|
30
|
+
Approved: ${M.toString()}`))}),o.forEach(m=>{i||(on(n[m].methods,s[m].methods)?on(n[m].events,s[m].events)||(i=ie("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${m}`)):i=ie("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${m}`))}),i}function n8(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 ud(t){return[...new Set(t.map(e=>e.includes(":")?e.split(":")[0]:e))]}function s8(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 a8(t,e){return Fc(t,!1)&&t<=e.max&&t>=e.min}function dd(){const t=ws();return new Promise(e=>{switch(t){case ur.browser:e(o8());break;case ur.reactNative:e(c8());break;case ur.node:e(f8());break;default:e(!0)}})}function o8(){return ys()&&navigator?.onLine}async function c8(){return kn()&&typeof global<"u"&&global!=null&&global.NetInfo?(await(global==null?void 0:global.NetInfo.fetch()))?.isConnected:!0}function f8(){return!0}function h8(t){switch(ws()){case ur.browser:u8(t);break;case ur.reactNative:d8(t);break}}function u8(t){!kn()&&ys()&&(window.addEventListener("online",()=>t(!0)),window.addEventListener("offline",()=>t(!1)))}function d8(t){kn()&&typeof global<"u"&&global!=null&&global.NetInfo&&global?.NetInfo.addEventListener(e=>t(e?.isConnected))}const Bc={};class Bs{static get(e){return Bc[e]}static set(e,r){Bc[e]=r}static delete(e){delete Bc[e]}}const l8="PARSE_ERROR",p8="INVALID_REQUEST",g8="METHOD_NOT_FOUND",b8="INVALID_PARAMS",ld="INTERNAL_ERROR",qc="SERVER_ERROR",v8=[-32700,-32600,-32601,-32602,-32603],qs={[l8]:{code:-32700,message:"Parse error"},[p8]:{code:-32600,message:"Invalid Request"},[g8]:{code:-32601,message:"Method not found"},[b8]:{code:-32602,message:"Invalid params"},[ld]:{code:-32603,message:"Internal error"},[qc]:{code:-32e3,message:"Server error"}},pd=qc;function m8(t){return v8.includes(t)}function gd(t){return Object.keys(qs).includes(t)?qs[t]:qs[pd]}function y8(t){const e=Object.values(qs).find(r=>r.code===t);return e||qs[pd]}function w8(t,e,r){return t.message.includes("getaddrinfo ENOTFOUND")||t.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${e}`):t}var bd={};/*! *****************************************************************************
|
31
31
|
Copyright (c) Microsoft Corporation.
|
32
32
|
|
33
33
|
Permission to use, copy, modify, and/or distribute this software for any
|
@@ -40,5 +40,5 @@
|
|
40
40
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
41
41
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
42
42
|
PERFORMANCE OF THIS SOFTWARE.
|
43
|
-
***************************************************************************** */var Uc=function(t,e){return Uc=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])},Uc(t,e)};function v8(t,e){Uc(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var zc=function(){return zc=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},zc.apply(this,arguments)};function m8(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 y8(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 c=t.length-1;c>=0;c--)(o=t[c])&&(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 w8(t,e){return function(r,i){e(r,i,t)}}function _8(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function A8(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 c(b){try{u(i.next(b))}catch(m){o(m)}}function l(b){try{u(i.throw(b))}catch(m){o(m)}}function u(b){b.done?s(b.value):n(b.value).then(c,l)}u((i=i.apply(t,e||[])).next())})}function E8(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:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(u){return function(b){return l([u,b])}}function l(u){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,n&&(s=u[0]&2?n.return:u[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,u[1])).done)return s;switch(n=0,s&&(u=[u[0]&2,s.value]),u[0]){case 0:case 1:s=u;break;case 4:return r.label++,{value:u[1],done:!1};case 5:r.label++,n=u[1],u=[0];continue;case 7:u=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){r=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]<s[3])){r.label=u[1];break}if(u[0]===6&&r.label<s[1]){r.label=s[1],s=u;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(u);break}s[2]&&r.ops.pop(),r.trys.pop();continue}u=e.call(t,r)}catch(b){u=[6,b],n=0}finally{i=s=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function x8(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}function S8(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function kc(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 gd(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(c){o={error:c}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function M8(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(gd(arguments[e]));return t}function I8(){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,c=s.length;o<c;o++,n++)i[n]=s[o];return i}function Us(t){return this instanceof Us?(this.v=t,this):new Us(t)}function D8(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(S){return new Promise(function(I,F){s.push([M,S,I,F])>1||c(M,S)})})}function c(M,S){try{l(i[M](S))}catch(I){m(s[0][3],I)}}function l(M){M.value instanceof Us?Promise.resolve(M.value.v).then(u,b):m(s[0][2],M)}function u(M){c("next",M)}function b(M){c("throw",M)}function m(M,S){M(S),s.shift(),s.length&&c(s[0][0],s[0][1])}}function O8(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 R8(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 kc=="function"?kc(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(c,l){o=t[s](o),n(c,l,o.done,o.value)})}}function n(s,o,c,l){Promise.resolve(l).then(function(u){s({value:u,done:c})},o)}}function N8(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function P8(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 T8(t){return t&&t.__esModule?t:{default:t}}function C8(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function F8(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 L8=Object.freeze({__proto__:null,__extends:v8,get __assign(){return zc},__rest:m8,__decorate:y8,__param:w8,__metadata:_8,__awaiter:A8,__generator:E8,__createBinding:x8,__exportStar:S8,__values:kc,__read:gd,__spread:M8,__spreadArrays:I8,__await:Us,__asyncGenerator:D8,__asyncDelegator:O8,__asyncValues:R8,__makeTemplateObject:N8,__importStar:P8,__importDefault:T8,__classPrivateFieldGet:C8,__classPrivateFieldSet:F8}),B8=co(L8),wi={},bd;function q8(){if(bd)return wi;bd=1,Object.defineProperty(wi,"__esModule",{value:!0}),wi.isBrowserCryptoAvailable=wi.getSubtleCrypto=wi.getBrowerCrypto=void 0;function t(){return Kt?.crypto||Kt?.msCrypto||{}}wi.getBrowerCrypto=t;function e(){const i=t();return i.subtle||i.webkitSubtle}wi.getSubtleCrypto=e;function r(){return!!t()&&!!e()}return wi.isBrowserCryptoAvailable=r,wi}var _i={},vd;function U8(){if(vd)return _i;vd=1,Object.defineProperty(_i,"__esModule",{value:!0}),_i.isBrowser=_i.isNode=_i.isReactNative=void 0;function t(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}_i.isReactNative=t;function e(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}_i.isNode=e;function r(){return!t()&&!e()}return _i.isBrowser=r,_i}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=B8;e.__exportStar(q8(),t),e.__exportStar(U8(),t)})(pd);function Hi(t=3){const e=Date.now()*Math.pow(10,t),r=Math.floor(Math.random()*Math.pow(10,t));return e+r}function ln(t=6){return BigInt(Hi(t))}function pn(t,e,r){return{id:r||Hi(),jsonrpc:"2.0",method:t,params:e}}function $c(t,e){return{id:t,jsonrpc:"2.0",result:e}}function jc(t,e,r){return{id:t,jsonrpc:"2.0",error:z8(e,r)}}function z8(t,e){return typeof t>"u"?ld(ud):(typeof t=="string"&&(t=Object.assign(Object.assign({},ld(qc)),{message:t})),typeof e<"u"&&(t.data=e),p8(t.code)&&(t=g8(t.code)),t)}class k8{}class $8 extends k8{constructor(){super()}}class j8 extends $8{constructor(e){super()}}const K8="^wss?:";function H8(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function V8(t,e){const r=H8(t);return typeof r>"u"?!1:new RegExp(e).test(r)}function md(t){return V8(t,K8)}function G8(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function yd(t){return typeof t=="object"&&"id"in t&&"jsonrpc"in t&&t.jsonrpc==="2.0"}function Kc(t){return yd(t)&&"method"in t}function Za(t){return yd(t)&&(si(t)||Ar(t))}function si(t){return"result"in t}function Ar(t){return"error"in t}class W8 extends j8{constructor(e){super(e),this.events=new qt.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(pn(e.method,e.params||[],e.id||ln().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),Za(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 Y8=()=>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"),J8=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",wd=t=>t.split("?")[0],_d=10,Q8=Y8();class X8{constructor(e){if(this.url=e,this.events=new qt.exports.EventEmitter,this.registering=!1,!md(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(Yi(e))}catch(r){this.onError(e.id,r)}}register(e=this.url){if(!md(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=new URLSearchParams(e).get("origin"),s=pd.isReactNative()?{headers:{origin:n}}:{rejectUnauthorized:!G8(e)},o=new Q8(e,[],s);J8()?o.onerror=c=>{const l=c;i(this.emitError(l.error))}:o.on("error",c=>{i(this.emitError(c))}),o.onopen=()=>{this.onOpen(o),r(o)}})}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=jc(e,n);this.events.emit("payload",s)}parseError(e,r=this.url){return b8(e,wd(r),"WS")}resetMaxListeners(){this.events.getMaxListeners()>_d&&this.events.setMaxListeners(_d)}emitError(e){const r=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${wd(this.url)}`));return this.events.emit("register_error",r),r}}var Hc={exports:{}};(function(t,e){var r=200,i="__lodash_hash_undefined__",n=1,s=2,o=9007199254740991,c="[object Arguments]",l="[object Array]",u="[object AsyncFunction]",b="[object Boolean]",m="[object Date]",M="[object Error]",S="[object Function]",I="[object GeneratorFunction]",F="[object Map]",k="[object Number]",j="[object Null]",C="[object Object]",$="[object Promise]",P="[object Proxy]",B="[object RegExp]",U="[object Set]",y="[object String]",O="[object Symbol]",Y="[object Undefined]",Q="[object WeakMap]",N="[object ArrayBuffer]",g="[object DataView]",a="[object Float32Array]",f="[object Float64Array]",p="[object Int8Array]",w="[object Int16Array]",A="[object Int32Array]",x="[object Uint8Array]",_="[object Uint8ClampedArray]",h="[object Uint16Array]",d="[object Uint32Array]",D=/[\\^$.*+?()[\]{}|]/g,K=/^\[object .+?Constructor\]$/,G=/^(?:0|[1-9]\d*)$/,E={};E[a]=E[f]=E[p]=E[w]=E[A]=E[x]=E[_]=E[h]=E[d]=!0,E[c]=E[l]=E[N]=E[b]=E[g]=E[m]=E[M]=E[S]=E[F]=E[k]=E[C]=E[B]=E[U]=E[y]=E[Q]=!1;var H=typeof Kt=="object"&&Kt&&Kt.Object===Object&&Kt,R=typeof self=="object"&&self&&self.Object===Object&&self,L=H||R||Function("return this")(),q=e&&!e.nodeType&&e,v=q&&!0&&t&&!t.nodeType&&t,T=v&&v.exports===q,W=T&&H.process,J=function(){try{return W&&W.binding&&W.binding("util")}catch{}}(),X=J&&J.isTypedArray;function se(z,V){for(var Z=-1,me=z==null?0:z.length,dt=0,Ge=[];++Z<me;){var vt=z[Z];V(vt,Z,z)&&(Ge[dt++]=vt)}return Ge}function ne(z,V){for(var Z=-1,me=V.length,dt=z.length;++Z<me;)z[dt+Z]=V[Z];return z}function Me(z,V){for(var Z=-1,me=z==null?0:z.length;++Z<me;)if(V(z[Z],Z,z))return!0;return!1}function Ce(z,V){for(var Z=-1,me=Array(z);++Z<z;)me[Z]=V(Z);return me}function ue(z){return function(V){return z(V)}}function xe(z,V){return z.has(V)}function Ae(z,V){return z?.[V]}function re(z){var V=-1,Z=Array(z.size);return z.forEach(function(me,dt){Z[++V]=[dt,me]}),Z}function ve(z,V){return function(Z){return z(V(Z))}}function le(z){var V=-1,Z=Array(z.size);return z.forEach(function(me){Z[++V]=me}),Z}var ee=Array.prototype,de=Function.prototype,fe=Object.prototype,te=L["__core-js_shared__"],Ee=de.toString,he=fe.hasOwnProperty,ae=function(){var z=/[^.]+$/.exec(te&&te.keys&&te.keys.IE_PROTO||"");return z?"Symbol(src)_1."+z:""}(),Se=fe.toString,De=RegExp("^"+Ee.call(he).replace(D,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ce=T?L.Buffer:void 0,Ie=L.Symbol,We=L.Uint8Array,Oe=fe.propertyIsEnumerable,Qe=ee.splice,He=Ie?Ie.toStringTag:void 0,Re=Object.getOwnPropertySymbols,tt=ce?ce.isBuffer:void 0,rt=ve(Object.keys,Object),pe=is(L,"DataView"),Pe=is(L,"Map"),Fe=is(L,"Promise"),ge=is(L,"Set"),Le=is(L,"WeakMap"),Te=is(Object,"create"),ye=yn(pe),Ue=yn(Pe),ze=yn(Fe),we=yn(ge),ke=yn(Le),Be=Ie?Ie.prototype:void 0,be=Be?Be.valueOf:void 0;function Ne(z){var V=-1,Z=z==null?0:z.length;for(this.clear();++V<Z;){var me=z[V];this.set(me[0],me[1])}}function $e(){this.__data__=Te?Te(null):{},this.size=0}function _e(z){var V=this.has(z)&&delete this.__data__[z];return this.size-=V?1:0,V}function it(z){var V=this.__data__;if(Te){var Z=V[z];return Z===i?void 0:Z}return he.call(V,z)?V[z]:void 0}function nt(z){var V=this.__data__;return Te?V[z]!==void 0:he.call(V,z)}function qe(z,V){var Z=this.__data__;return this.size+=this.has(z)?0:1,Z[z]=Te&&V===void 0?i:V,this}Ne.prototype.clear=$e,Ne.prototype.delete=_e,Ne.prototype.get=it,Ne.prototype.has=nt,Ne.prototype.set=qe;function Ye(z){var V=-1,Z=z==null?0:z.length;for(this.clear();++V<Z;){var me=z[V];this.set(me[0],me[1])}}function nr(){this.__data__=[],this.size=0}function sr(z){var V=this.__data__,Z=io(V,z);if(Z<0)return!1;var me=V.length-1;return Z==me?V.pop():Qe.call(V,Z,1),--this.size,!0}function ar(z){var V=this.__data__,Z=io(V,z);return Z<0?void 0:V[Z][1]}function or(z){return io(this.__data__,z)>-1}function cr(z,V){var Z=this.__data__,me=io(Z,z);return me<0?(++this.size,Z.push([z,V])):Z[me][1]=V,this}Ye.prototype.clear=nr,Ye.prototype.delete=sr,Ye.prototype.get=ar,Ye.prototype.has=or,Ye.prototype.set=cr;function wt(z){var V=-1,Z=z==null?0:z.length;for(this.clear();++V<Z;){var me=z[V];this.set(me[0],me[1])}}function Ei(){this.size=0,this.__data__={hash:new Ne,map:new(Pe||Ye),string:new Ne}}function xi(z){var V=no(this,z).delete(z);return this.size-=V?1:0,V}function Si(z){return no(this,z).get(z)}function Mi(z){return no(this,z).has(z)}function Ii(z,V){var Z=no(this,z),me=Z.size;return Z.set(z,V),this.size+=Z.size==me?0:1,this}wt.prototype.clear=Ei,wt.prototype.delete=xi,wt.prototype.get=Si,wt.prototype.has=Mi,wt.prototype.set=Ii;function Sr(z){var V=-1,Z=z==null?0:z.length;for(this.__data__=new wt;++V<Z;)this.add(z[V])}function Di(z){return this.__data__.set(z,i),this}function Oi(z){return this.__data__.has(z)}Sr.prototype.add=Sr.prototype.push=Di,Sr.prototype.has=Oi;function $t(z){var V=this.__data__=new Ye(z);this.size=V.size}function Ri(){this.__data__=new Ye,this.size=0}function Ni(z){var V=this.__data__,Z=V.delete(z);return this.size=V.size,Z}function Pi(z){return this.__data__.get(z)}function Vs(z){return this.__data__.has(z)}function M9(z,V){var Z=this.__data__;if(Z instanceof Ye){var me=Z.__data__;if(!Pe||me.length<r-1)return me.push([z,V]),this.size=++Z.size,this;Z=this.__data__=new wt(me)}return Z.set(z,V),this.size=Z.size,this}$t.prototype.clear=Ri,$t.prototype.delete=Ni,$t.prototype.get=Pi,$t.prototype.has=Vs,$t.prototype.set=M9;function I9(z,V){var Z=so(z),me=!Z&&$9(z),dt=!Z&&!me&&af(z),Ge=!Z&&!me&&!dt&&xl(z),vt=Z||me||dt||Ge,Rt=vt?Ce(z.length,String):[],Lt=Rt.length;for(var lt in z)(V||he.call(z,lt))&&!(vt&&(lt=="length"||dt&&(lt=="offset"||lt=="parent")||Ge&&(lt=="buffer"||lt=="byteLength"||lt=="byteOffset")||B9(lt,Lt)))&&Rt.push(lt);return Rt}function io(z,V){for(var Z=z.length;Z--;)if(wl(z[Z][0],V))return Z;return-1}function D9(z,V,Z){var me=V(z);return so(z)?me:ne(me,Z(z))}function Gs(z){return z==null?z===void 0?Y:j:He&&He in Object(z)?F9(z):k9(z)}function bl(z){return Ws(z)&&Gs(z)==c}function vl(z,V,Z,me,dt){return z===V?!0:z==null||V==null||!Ws(z)&&!Ws(V)?z!==z&&V!==V:O9(z,V,Z,me,vl,dt)}function O9(z,V,Z,me,dt,Ge){var vt=so(z),Rt=so(V),Lt=vt?l:Vi(z),lt=Rt?l:Vi(V);Lt=Lt==c?C:Lt,lt=lt==c?C:lt;var pr=Lt==C,Br=lt==C,jt=Lt==lt;if(jt&&af(z)){if(!af(V))return!1;vt=!0,pr=!1}if(jt&&!pr)return Ge||(Ge=new $t),vt||xl(z)?ml(z,V,Z,me,dt,Ge):T9(z,V,Lt,Z,me,dt,Ge);if(!(Z&n)){var Mr=pr&&he.call(z,"__wrapped__"),Ir=Br&&he.call(V,"__wrapped__");if(Mr||Ir){var Gi=Mr?z.value():z,Ti=Ir?V.value():V;return Ge||(Ge=new $t),dt(Gi,Ti,Z,me,Ge)}}return jt?(Ge||(Ge=new $t),C9(z,V,Z,me,dt,Ge)):!1}function R9(z){if(!El(z)||U9(z))return!1;var V=_l(z)?De:K;return V.test(yn(z))}function N9(z){return Ws(z)&&Al(z.length)&&!!E[Gs(z)]}function P9(z){if(!z9(z))return rt(z);var V=[];for(var Z in Object(z))he.call(z,Z)&&Z!="constructor"&&V.push(Z);return V}function ml(z,V,Z,me,dt,Ge){var vt=Z&n,Rt=z.length,Lt=V.length;if(Rt!=Lt&&!(vt&&Lt>Rt))return!1;var lt=Ge.get(z);if(lt&&Ge.get(V))return lt==V;var pr=-1,Br=!0,jt=Z&s?new Sr:void 0;for(Ge.set(z,V),Ge.set(V,z);++pr<Rt;){var Mr=z[pr],Ir=V[pr];if(me)var Gi=vt?me(Ir,Mr,pr,V,z,Ge):me(Mr,Ir,pr,z,V,Ge);if(Gi!==void 0){if(Gi)continue;Br=!1;break}if(jt){if(!Me(V,function(Ti,wn){if(!xe(jt,wn)&&(Mr===Ti||dt(Mr,Ti,Z,me,Ge)))return jt.push(wn)})){Br=!1;break}}else if(!(Mr===Ir||dt(Mr,Ir,Z,me,Ge))){Br=!1;break}}return Ge.delete(z),Ge.delete(V),Br}function T9(z,V,Z,me,dt,Ge,vt){switch(Z){case g:if(z.byteLength!=V.byteLength||z.byteOffset!=V.byteOffset)return!1;z=z.buffer,V=V.buffer;case N:return!(z.byteLength!=V.byteLength||!Ge(new We(z),new We(V)));case b:case m:case k:return wl(+z,+V);case M:return z.name==V.name&&z.message==V.message;case B:case y:return z==V+"";case F:var Rt=re;case U:var Lt=me&n;if(Rt||(Rt=le),z.size!=V.size&&!Lt)return!1;var lt=vt.get(z);if(lt)return lt==V;me|=s,vt.set(z,V);var pr=ml(Rt(z),Rt(V),me,dt,Ge,vt);return vt.delete(z),pr;case O:if(be)return be.call(z)==be.call(V)}return!1}function C9(z,V,Z,me,dt,Ge){var vt=Z&n,Rt=yl(z),Lt=Rt.length,lt=yl(V),pr=lt.length;if(Lt!=pr&&!vt)return!1;for(var Br=Lt;Br--;){var jt=Rt[Br];if(!(vt?jt in V:he.call(V,jt)))return!1}var Mr=Ge.get(z);if(Mr&&Ge.get(V))return Mr==V;var Ir=!0;Ge.set(z,V),Ge.set(V,z);for(var Gi=vt;++Br<Lt;){jt=Rt[Br];var Ti=z[jt],wn=V[jt];if(me)var Sl=vt?me(wn,Ti,jt,V,z,Ge):me(Ti,wn,jt,z,V,Ge);if(!(Sl===void 0?Ti===wn||dt(Ti,wn,Z,me,Ge):Sl)){Ir=!1;break}Gi||(Gi=jt=="constructor")}if(Ir&&!Gi){var ao=z.constructor,oo=V.constructor;ao!=oo&&"constructor"in z&&"constructor"in V&&!(typeof ao=="function"&&ao instanceof ao&&typeof oo=="function"&&oo instanceof oo)&&(Ir=!1)}return Ge.delete(z),Ge.delete(V),Ir}function yl(z){return D9(z,H9,L9)}function no(z,V){var Z=z.__data__;return q9(V)?Z[typeof V=="string"?"string":"hash"]:Z.map}function is(z,V){var Z=Ae(z,V);return R9(Z)?Z:void 0}function F9(z){var V=he.call(z,He),Z=z[He];try{z[He]=void 0;var me=!0}catch{}var dt=Se.call(z);return me&&(V?z[He]=Z:delete z[He]),dt}var L9=Re?function(z){return z==null?[]:(z=Object(z),se(Re(z),function(V){return Oe.call(z,V)}))}:V9,Vi=Gs;(pe&&Vi(new pe(new ArrayBuffer(1)))!=g||Pe&&Vi(new Pe)!=F||Fe&&Vi(Fe.resolve())!=$||ge&&Vi(new ge)!=U||Le&&Vi(new Le)!=Q)&&(Vi=function(z){var V=Gs(z),Z=V==C?z.constructor:void 0,me=Z?yn(Z):"";if(me)switch(me){case ye:return g;case Ue:return F;case ze:return $;case we:return U;case ke:return Q}return V});function B9(z,V){return V=V??o,!!V&&(typeof z=="number"||G.test(z))&&z>-1&&z%1==0&&z<V}function q9(z){var V=typeof z;return V=="string"||V=="number"||V=="symbol"||V=="boolean"?z!=="__proto__":z===null}function U9(z){return!!ae&&ae in z}function z9(z){var V=z&&z.constructor,Z=typeof V=="function"&&V.prototype||fe;return z===Z}function k9(z){return Se.call(z)}function yn(z){if(z!=null){try{return Ee.call(z)}catch{}try{return z+""}catch{}}return""}function wl(z,V){return z===V||z!==z&&V!==V}var $9=bl(function(){return arguments}())?bl:function(z){return Ws(z)&&he.call(z,"callee")&&!Oe.call(z,"callee")},so=Array.isArray;function j9(z){return z!=null&&Al(z.length)&&!_l(z)}var af=tt||G9;function K9(z,V){return vl(z,V)}function _l(z){if(!El(z))return!1;var V=Gs(z);return V==S||V==I||V==u||V==P}function Al(z){return typeof z=="number"&&z>-1&&z%1==0&&z<=o}function El(z){var V=typeof z;return z!=null&&(V=="object"||V=="function")}function Ws(z){return z!=null&&typeof z=="object"}var xl=X?ue(X):N9;function H9(z){return j9(z)?I9(z):P9(z)}function V9(){return[]}function G9(){return!1}t.exports=K9})(Hc,Hc.exports);var Z8=Hc.exports;function e4(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 c=t.length,l=t.charAt(0),u=Math.log(c)/Math.log(256),b=Math.log(256)/Math.log(c);function m(I){if(I instanceof Uint8Array||(ArrayBuffer.isView(I)?I=new Uint8Array(I.buffer,I.byteOffset,I.byteLength):Array.isArray(I)&&(I=Uint8Array.from(I))),!(I instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(I.length===0)return"";for(var F=0,k=0,j=0,C=I.length;j!==C&&I[j]===0;)j++,F++;for(var $=(C-j)*b+1>>>0,P=new Uint8Array($);j!==C;){for(var B=I[j],U=0,y=$-1;(B!==0||U<k)&&y!==-1;y--,U++)B+=256*P[y]>>>0,P[y]=B%c>>>0,B=B/c>>>0;if(B!==0)throw new Error("Non-zero carry");k=U,j++}for(var O=$-k;O!==$&&P[O]===0;)O++;for(var Y=l.repeat(F);O<$;++O)Y+=t.charAt(P[O]);return Y}function M(I){if(typeof I!="string")throw new TypeError("Expected String");if(I.length===0)return new Uint8Array;var F=0;if(I[F]!==" "){for(var k=0,j=0;I[F]===l;)k++,F++;for(var C=(I.length-F)*u+1>>>0,$=new Uint8Array(C);I[F];){var P=r[I.charCodeAt(F)];if(P===255)return;for(var B=0,U=C-1;(P!==0||B<j)&&U!==-1;U--,B++)P+=c*$[U]>>>0,$[U]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");j=B,F++}if(I[F]!==" "){for(var y=C-j;y!==C&&$[y]===0;)y++;for(var O=new Uint8Array(k+(C-y)),Y=k;y!==C;)O[Y++]=$[y++];return O}}}function S(I){var F=M(I);if(F)return F;throw new Error(`Non-${e} character`)}return{encode:m,decodeUnsafe:M,decode:S}}var t4=e4,r4=t4;const Ad=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")},i4=t=>new TextEncoder().encode(t),n4=t=>new TextDecoder().decode(t);class s4{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 a4{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 Ed(this,e)}}class o4{constructor(e){this.decoders=e}or(e){return Ed(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 Ed=(t,e)=>new o4({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class c4{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new s4(e,r,i),this.decoder=new a4(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const eo=({name:t,prefix:e,encode:r,decode:i})=>new c4(t,e,r,i),zs=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=r4(r,e);return eo({prefix:t,name:e,encode:i,decode:s=>Ad(n(s))})},f4=(t,e,r,i)=>{const n={};for(let b=0;b<e.length;++b)n[e[b]]=b;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let c=0,l=0,u=0;for(let b=0;b<s;++b){const m=n[t[b]];if(m===void 0)throw new SyntaxError(`Non-${i} character`);l=l<<r|m,c+=r,c>=8&&(c-=8,o[u++]=255&l>>c)}if(c>=r||255&l<<8-c)throw new SyntaxError("Unexpected end of data");return o},h4=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",o=0,c=0;for(let l=0;l<t.length;++l)for(c=c<<8|t[l],o+=8;o>r;)o-=r,s+=e[n&c>>o];if(o&&(s+=e[n&c<<r-o]),i)for(;s.length*r&7;)s+="=";return s},Ft=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>eo({prefix:e,name:t,encode(n){return h4(n,i,r)},decode(n){return f4(n,i,r,t)}}),u4=eo({prefix:"\0",name:"identity",encode:t=>n4(t),decode:t=>i4(t)});var d4=Object.freeze({__proto__:null,identity:u4});const l4=Ft({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var p4=Object.freeze({__proto__:null,base2:l4});const g4=Ft({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var b4=Object.freeze({__proto__:null,base8:g4});const v4=zs({prefix:"9",name:"base10",alphabet:"0123456789"});var m4=Object.freeze({__proto__:null,base10:v4});const y4=Ft({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),w4=Ft({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var _4=Object.freeze({__proto__:null,base16:y4,base16upper:w4});const A4=Ft({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),E4=Ft({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),x4=Ft({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),S4=Ft({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),M4=Ft({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),I4=Ft({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),D4=Ft({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),O4=Ft({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),R4=Ft({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var N4=Object.freeze({__proto__:null,base32:A4,base32upper:E4,base32pad:x4,base32padupper:S4,base32hex:M4,base32hexupper:I4,base32hexpad:D4,base32hexpadupper:O4,base32z:R4});const P4=zs({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),T4=zs({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var C4=Object.freeze({__proto__:null,base36:P4,base36upper:T4});const F4=zs({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),L4=zs({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var B4=Object.freeze({__proto__:null,base58btc:F4,base58flickr:L4});const q4=Ft({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),U4=Ft({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),z4=Ft({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),k4=Ft({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var $4=Object.freeze({__proto__:null,base64:q4,base64pad:U4,base64url:z4,base64urlpad:k4});const xd=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}"),j4=xd.reduce((t,e,r)=>(t[r]=e,t),[]),K4=xd.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function H4(t){return t.reduce((e,r)=>(e+=j4[r],e),"")}function V4(t){const e=[];for(const r of t){const i=K4[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const G4=eo({prefix:"\u{1F680}",name:"base256emoji",encode:H4,decode:V4});var W4=Object.freeze({__proto__:null,base256emoji:G4}),Y4=Md,Sd=128,J4=127,Q4=~J4,X4=Math.pow(2,31);function Md(t,e,r){e=e||[],r=r||0;for(var i=r;t>=X4;)e[r++]=t&255|Sd,t/=128;for(;t&Q4;)e[r++]=t&255|Sd,t>>>=7;return e[r]=t|0,Md.bytes=r-i+1,e}var Z4=Vc,ew=128,Id=127;function Vc(t,i){var r=0,i=i||0,n=0,s=i,o,c=t.length;do{if(s>=c)throw Vc.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=n<28?(o&Id)<<n:(o&Id)*Math.pow(2,n),n+=7}while(o>=ew);return Vc.bytes=s-i,r}var tw=Math.pow(2,7),rw=Math.pow(2,14),iw=Math.pow(2,21),nw=Math.pow(2,28),sw=Math.pow(2,35),aw=Math.pow(2,42),ow=Math.pow(2,49),cw=Math.pow(2,56),fw=Math.pow(2,63),hw=function(t){return t<tw?1:t<rw?2:t<iw?3:t<nw?4:t<sw?5:t<aw?6:t<ow?7:t<cw?8:t<fw?9:10},uw={encode:Y4,decode:Z4,encodingLength:hw},Dd=uw;const Od=(t,e,r=0)=>(Dd.encode(t,e,r),e),Rd=t=>Dd.encodingLength(t),Gc=(t,e)=>{const r=e.byteLength,i=Rd(t),n=i+Rd(r),s=new Uint8Array(n+r);return Od(t,s,0),Od(r,s,i),s.set(e,n),new dw(t,r,e,s)};class dw{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const Nd=({name:t,code:e,encode:r})=>new lw(t,e,r);class lw{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?Gc(this.code,r):r.then(i=>Gc(this.code,i))}else throw Error("Unknown type, must be binary type")}}const Pd=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),pw=Nd({name:"sha2-256",code:18,encode:Pd("SHA-256")}),gw=Nd({name:"sha2-512",code:19,encode:Pd("SHA-512")});var bw=Object.freeze({__proto__:null,sha256:pw,sha512:gw});const Td=0,vw="identity",Cd=Ad;var mw=Object.freeze({__proto__:null,identity:{code:Td,name:vw,encode:Cd,digest:t=>Gc(Td,Cd(t))}});new TextEncoder,new TextDecoder;const Fd={...d4,...p4,...b4,...m4,..._4,...N4,...C4,...B4,...$4,...W4};({...bw,...mw});function yw(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function Ld(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const Bd=Ld("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Wc=Ld("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=yw(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),ww={utf8:Bd,"utf-8":Bd,hex:Fd.base16,latin1:Wc,ascii:Wc,binary:Wc,...Fd};function _w(t,e="utf8"){const r=ww[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}`)}const qd="wc",Ud=2,Yc="core",ai=`${qd}@2:${Yc}:`,Aw={name:Yc,logger:"error"},Ew={database:":memory:"},xw="crypto",zd="client_ed25519_seed",Sw=oe.ONE_DAY,Mw="keychain",Iw="0.3",Dw="messages",Ow="0.3",Rw=oe.SIX_HOURS,Nw="publisher",kd="irn",Pw="error",$d="wss://relay.walletconnect.org",Tw="relayer",Jt={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"},Cw="_subscription",Er={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},Fw=.1,Jc="2.16.2",at={link_mode:"link_mode",relay:"relay"},Lw="0.3",Bw="WALLETCONNECT_CLIENT_ID",jd="WALLETCONNECT_LINK_MODE_APPS",oi={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},qw="subscription",Uw="0.3",zw=oe.FIVE_SECONDS*1e3,kw="pairing",$w="0.3",ks={wc_pairingDelete:{req:{ttl:oe.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:oe.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:oe.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:oe.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:oe.ONE_DAY,prompt:!1,tag:0},res:{ttl:oe.ONE_DAY,prompt:!1,tag:0}}},es={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Cr={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},jw="history",Kw="0.3",Hw="expirer",xr={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},Vw="0.3",Gw="verify-api",Ww="https://verify.walletconnect.com",Kd="https://verify.walletconnect.org",$s=Kd,Yw=`${$s}/v3`,Jw=[Ww,Kd],Qw="echo",Xw="https://echo.walletconnect.com",ci={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"},Fr={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"},gn={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"},bn={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"},js={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"},Zw=.1,e7="event-client",t7=86400,r7="https://pulse.walletconnect.com/batch";class i7{constructor(e,r){this.core=e,this.logger=r,this.keychain=new Map,this.name=Mw,this.version=Iw,this.initialized=!1,this.storagePrefix=ai,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}=ie("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=Ht(r,this.name)}get context(){return Xt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,Iu(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Du(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=ie("NOT_INITIALIZED",this.name);throw new Error(e)}}}class n7{constructor(e,r,i){this.core=e,this.logger=r,this.name=xw,this.randomSessionIdentifier=Tc(),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=wh(n);return yh(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const n=a5();return this.setPrivateKey(n.publicKey,n.privateKey)},this.signJWT=async n=>{this.isInitialized();const s=await this.getClientSeed(),o=wh(s),c=this.randomSessionIdentifier;return await Bb(c,n,Sw,o)},this.generateSharedKey=(n,s,o)=>{this.isInitialized();const c=this.getPrivateKey(n),l=o5(c,s);return this.setSymKey(l,o)},this.setSymKey=async(n,s)=>{this.isInitialized();const o=s||Ya(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 c=J0(o),l=Yi(s);if(X0(c))return f5(l,o?.encoding);if(Q0(c)){const M=c.senderPublicKey,S=c.receiverPublicKey;n=await this.generateSharedKey(M,S)}const u=this.getSymKey(n),{type:b,senderPublicKey:m}=c;return c5({type:b,symKey:u,message:l,senderPublicKey:m,encoding:o?.encoding})},this.decode=async(n,s,o)=>{this.isInitialized();const c=d5(s,o);if(X0(c)){const l=u5(s,o?.encoding);return An(l)}if(Q0(c)){const l=c.receiverPublicKey,u=c.senderPublicKey;n=await this.generateSharedKey(l,u)}try{const l=this.getSymKey(n),u=h5({symKey:l,encoded:s,encoding:o?.encoding});return An(u)}catch(l){this.logger.error(`Failed to decode message from topic: '${n}', clientId: '${await this.getClientId()}'`),this.logger.error(l)}},this.getPayloadType=(n,s=Ki)=>{const o=Cs({encoded:n,encoding:s});return dn(o.type)},this.getPayloadSenderPublicKey=(n,s=Ki)=>{const o=Cs({encoded:n,encoding:s});return o.senderPublicKey?Et(o.senderPublicKey,Wt):void 0},this.core=e,this.logger=Ht(r,this.name),this.keychain=i||new i7(this.core,this.logger)}get context(){return Xt(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(zd)}catch{e=Tc(),await this.keychain.set(zd,e)}return _w(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=ie("NOT_INITIALIZED",this.name);throw new Error(e)}}}class s7 extends yp{constructor(e,r){super(e,r),this.logger=e,this.core=r,this.messages=new Map,this.name=Dw,this.version=Ow,this.initialized=!1,this.storagePrefix=ai,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=yi(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=yi(n);return typeof s[o]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()},this.logger=Ht(e,this.name),this.core=r}get context(){return Xt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,Iu(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Du(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=ie("NOT_INITIALIZED",this.name);throw new Error(e)}}}class a7 extends wp{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.events=new qt.exports.EventEmitter,this.name=Nw,this.queue=new Map,this.publishTimeout=oe.toMiliseconds(oe.ONE_MINUTE),this.failedPublishTimeout=oe.toMiliseconds(oe.ONE_SECOND),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 c=s?.ttl||Rw,l=Cc(s),u=s?.prompt||!1,b=s?.tag||0,m=s?.id||ln().toString(),M={topic:i,message:n,opts:{ttl:c,relay:l,prompt:u,tag:b,id:m,attestation:s?.attestation}},S=`Failed to publish payload, please try again. id:${m} tag:${b}`,I=Date.now();let F,k=1;try{for(;F===void 0;){if(Date.now()-I>this.publishTimeout)throw new Error(S);this.logger.trace({id:m,attempts:k},`publisher.publish - attempt ${k}`),F=await await kn(this.rpcPublish(i,n,c,l,u,b,m,s?.attestation).catch(j=>this.logger.warn(j)),this.publishTimeout,S),k++,F||await new Promise(j=>setTimeout(j,this.failedPublishTimeout))}this.relayer.events.emit(Jt.publish,M),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{id:m,topic:i,message:n,opts:s}})}catch(j){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(j),(o=s?.internal)!=null&&o.throwOnFailedPublish)throw j;this.queue.set(m,M)}},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=Ht(r,this.name),this.registerEventListeners()}get context(){return Xt(this.logger)}rpcPublish(e,r,i,n,s,o,c,l){var u,b,m,M;const S={method:Fs(n.protocol).publish,params:{topic:e,message:r,ttl:i,prompt:s,tag:o,attestation:l},id:c};return Yt((u=S.params)==null?void 0:u.prompt)&&((b=S.params)==null||delete b.prompt),Yt((m=S.params)==null?void 0:m.tag)&&((M=S.params)==null||delete M.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:S}),this.relayer.request(S)}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{const{topic:r,message:i,opts:n}=e;await this.publish(r,i,n)})}registerEventListeners(){this.relayer.core.heartbeat.on(xn.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Jt.connection_stalled);return}this.checkQueue()}),this.relayer.on(Jt.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}class o7{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 c7=Object.defineProperty,f7=Object.defineProperties,h7=Object.getOwnPropertyDescriptors,Hd=Object.getOwnPropertySymbols,u7=Object.prototype.hasOwnProperty,d7=Object.prototype.propertyIsEnumerable,Vd=(t,e,r)=>e in t?c7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ks=(t,e)=>{for(var r in e||(e={}))u7.call(e,r)&&Vd(t,r,e[r]);if(Hd)for(var r of Hd(e))d7.call(e,r)&&Vd(t,r,e[r]);return t},Qc=(t,e)=>f7(t,h7(e));class l7 extends Ep{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.subscriptions=new Map,this.topicMap=new o7,this.events=new qt.exports.EventEmitter,this.name=qw,this.version=Uw,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=ai,this.subscribeTimeout=oe.toMiliseconds(oe.ONE_MINUTE),this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.pendingBatchMessages=[],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=Cc(n),o={topic:i,relay:s,transportType:n?.transportType};this.pending.set(i,o);const c=await this.rpcSubscribe(i,s,n?.transportType);return typeof c=="string"&&(this.onSubscribe(c,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}})),c}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 c=new oe.Watch;c.start(n);const l=setInterval(()=>{!this.pending.has(i)&&this.topics.includes(i)&&(clearInterval(l),c.stop(n),s(!0)),c.elapsed(n)>=zw&&(clearInterval(l),c.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()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=e,this.logger=Ht(r,this.name),this.clientId=""}get context(){return Xt(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}onEnable(){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=Cc(i);await this.rpcUnsubscribe(e,r,n);const s=ht("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=at.relay){i===at.relay&&await this.restartToComplete();const n={method:Fs(r.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});try{const s=yi(e+this.clientId);return i===at.link_mode?(setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(n).catch(o=>this.logger.warn(o))},oe.toMiliseconds(oe.ONE_SECOND)),s):await await kn(this.relayer.request(n).catch(o=>this.logger.warn(o)),this.subscribeTimeout)?s:null}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Jt.connection_stalled)}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{return await await kn(this.relayer.request(i).catch(n=>this.logger.warn(n)),this.subscribeTimeout)}catch{this.relayer.events.emit(Jt.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 kn(this.relayer.request(i).catch(s=>this.logger.warn(s)),this.subscribeTimeout)}catch{this.relayer.events.emit(Jt.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,Qc(Ks({},r),{id:e})),this.pending.delete(r.topic)}onBatchSubscribe(e){e.length&&e.forEach(r=>{this.setSubscription(r.id,Ks({},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,Ks({},r)),this.topicMap.set(r.topic,e),this.events.emit(oi.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}=ie("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(oi.deleted,Qc(Ks({},i),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(oi.sync)}async reset(){if(this.cached.length){const e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let r=0;r<e;r++){const i=this.cached.splice(0,this.batchSubscribeTopicsLimit);await this.batchFetchMessages(i),await this.batchSubscribe(i)}}this.events.emit(oi.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:r}=ie("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){if(!e.length)return;const r=await this.rpcBatchSubscribe(e);Ls(r)&&this.onBatchSubscribe(r.map((i,n)=>Qc(Ks({},e[n]),{id:i})))}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&&(this.pendingBatchMessages=this.pendingBatchMessages.concat(r.messages))}async onConnect(){await this.restart(),this.onEnable()}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||!this.relayer.connected)return;const e=[];this.pending.forEach(r=>{e.push(r)}),await this.batchSubscribe(e),this.pendingBatchMessages.length&&(await this.relayer.handleBatchMessageEvents(this.pendingBatchMessages),this.pendingBatchMessages=[])}registerEventListeners(){this.relayer.core.heartbeat.on(xn.pulse,async()=>{await this.checkPending()}),this.events.on(oi.created,async e=>{const r=oi.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()}),this.events.on(oi.deleted,async e=>{const r=oi.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=ie("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){!this.relayer.connected&&!this.relayer.connecting&&await this.relayer.transportOpen(),this.restartInProgress&&await new Promise(e=>{const r=setInterval(()=>{this.restartInProgress||(clearInterval(r),e())},this.pollingInterval)})}}var p7=Object.defineProperty,Gd=Object.getOwnPropertySymbols,g7=Object.prototype.hasOwnProperty,b7=Object.prototype.propertyIsEnumerable,Wd=(t,e,r)=>e in t?p7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,v7=(t,e)=>{for(var r in e||(e={}))g7.call(e,r)&&Wd(t,r,e[r]);if(Gd)for(var r of Gd(e))b7.call(e,r)&&Wd(t,r,e[r]);return t};class m7 extends _p{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new qt.exports.EventEmitter,this.name=Tw,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","stalled","interrupted"],this.hasExperiencedNetworkDisruption=!1,this.requestsInFlight=new Map,this.heartBeatTimeout=oe.toMiliseconds(oe.THIRTY_SECONDS+oe.ONE_SECOND),this.request=async r=>{var i,n;this.logger.debug("Publishing Request Payload");const s=r.id||ln().toString();await this.toEstablishConnection();try{const o=this.provider.request(r);this.requestsInFlight.set(s,{promise:o,request:r}),this.logger.trace({id:s,method:r.method,topic:(i=r.params)==null?void 0:i.topic},"relayer.request - attempt to publish...");const c=await new Promise(async(l,u)=>{const b=()=>{u(new Error(`relayer.request - publish interrupted, id: ${s}`))};this.provider.on(Er.disconnect,b);const m=await o;this.provider.off(Er.disconnect,b),l(m)});return this.logger.trace({id:s,method:r.method,topic:(n=r.params)==null?void 0:n.topic},"relayer.request - published"),c}catch(o){throw this.logger.debug(`Failed to Publish Request: ${s}`),o}finally{this.requestsInFlight.delete(s)}},this.resetPingTimeout=()=>{if(Ta())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var r,i,n;(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)}},this.onPayloadHandler=r=>{this.onProviderPayload(r),this.resetPingTimeout()},this.onConnectHandler=()=>{this.logger.trace("relayer connected"),this.startPingTimeout(),this.events.emit(Jt.connect)},this.onDisconnectHandler=()=>{this.logger.trace("relayer disconnected"),this.onProviderDisconnect()},this.onProviderErrorHandler=r=>{this.logger.error(r),this.events.emit(Jt.error,r),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(Er.payload,this.onPayloadHandler),this.provider.on(Er.connect,this.onConnectHandler),this.provider.on(Er.disconnect,this.onDisconnectHandler),this.provider.on(Er.error,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?Ht(e.logger,this.name):hi(So({level:e.logger||Pw})),this.messages=new s7(this.logger,e.core),this.subscriber=new l7(this,this.logger),this.publisher=new a7(this,this.logger),this.relayUrl=e?.relayUrl||$d,this.projectId=e.projectId,this.bundleId=Jv(),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)}}get context(){return Xt(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:at.relay})}async subscribe(e,r){var i;this.isInitialized(),r?.transportType==="relay"&&await this.toEstablishConnection();let n=((i=this.subscriber.topicMap.get(e))==null?void 0:i[0])||"",s;const o=c=>{c.topic===e&&(this.subscriber.off(oi.created,o),s())};return await Promise.all([new Promise(c=>{s=c,this.subscriber.on(oi.created,o)}),new Promise(async c=>{n=await this.subscriber.subscribe(e,r)||n,c()})]),n}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(){if(!this.hasExperiencedNetworkDisruption&&this.connected&&this.requestsInFlight.size>0)try{await Promise.all(Array.from(this.requestsInFlight.values()).map(e=>e.promise))}catch(e){this.logger.warn(e)}this.hasExperiencedNetworkDisruption||this.connected?await kn(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),await this.createProvider(),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;try{await new Promise(async(r,i)=>{const n=()=>{this.provider.off(Er.disconnect,n),i(new Error("Connection interrupted while trying to subscribe"))};this.provider.on(Er.disconnect,n),await kn(this.provider.connect(),oe.toMiliseconds(oe.ONE_MINUTE),`Socket stalled when trying to connect to ${this.relayUrl}`).catch(s=>{i(s)}).finally(()=>{clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0}),this.subscriber.start().catch(s=>{this.logger.error(s),this.onDisconnectHandler()}),this.hasExperiencedNetworkDisruption=!1,r()})}catch(r){this.logger.error(r);const i=r;if(this.hasExperiencedNetworkDisruption=!0,!this.isConnectionStalled(i.message))throw r}finally{this.connectionAttemptInProgress=!1}}async restartTransport(e){this.connectionAttemptInProgress||(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await hd())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.trace(`Batch of ${r.length} message events sorted`);for(const i of r)try{await this.onMessageEvent(i)}catch(n){this.logger.warn(n)}this.logger.trace(`Batch of ${r.length} message events processed`)}async onLinkMessageEvent(e,r){const{topic:i}=e;if(!r.sessionExists){const n=_t(oe.FIVE_MINUTES),s={topic:i,expiry:n,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,s)}this.events.emit(Jt.message,e),await this.recordMessageEvent(e)}startPingTimeout(){var e,r,i,n,s;if(Ta())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.once("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o)}}isConnectionStalled(e){return this.staleConnectionErrors.some(r=>e.includes(r))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new W8(new X8(e6({sdkVersion:Jc,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId}))),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.debug(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(r))return this.logger.debug(`Ignoring message for non-subscribed topic ${r}`),!0;const n=this.messages.has(r,i);return n&&this.logger.debug(`Ignoring duplicate message: ${i}`),n}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Kc(e)){if(!e.method.endsWith(Cw))return;const r=e.params,{topic:i,message:n,publishedAt:s,attestation:o}=r.data,c={topic:i,message:n,publishedAt:s,transportType:at.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(v7({type:"event",event:r.id},c)),this.events.emit(r.id,c),await this.acknowledgePayload(e),await this.onMessageEvent(c)}else Za(e)&&this.events.emit(Jt.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Jt.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const r=$c(e.id,!0);await this.provider.connection.send(r)}unregisterProviderListeners(){this.provider.off(Er.payload,this.onPayloadHandler),this.provider.off(Er.connect,this.onConnectHandler),this.provider.off(Er.disconnect,this.onDisconnectHandler),this.provider.off(Er.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await hd();a8(async r=>{e!==r&&(e=r,r?await this.restartTransport().catch(i=>this.logger.error(i)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){await this.subscriber.stop(),this.requestsInFlight.clear(),clearTimeout(this.pingTimeout),this.events.emit(Jt.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e))},oe.toMiliseconds(Fw))))}isInitialized(){if(!this.initialized){const{message:e}=ie("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&(this.connectionAttemptInProgress&&await new Promise(e=>{const r=setInterval(()=>{this.connected&&(clearInterval(r),e())},this.connectionStatusPollingInterval)}),await this.transportOpen())}}var y7=Object.defineProperty,Yd=Object.getOwnPropertySymbols,w7=Object.prototype.hasOwnProperty,_7=Object.prototype.propertyIsEnumerable,Jd=(t,e,r)=>e in t?y7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Qd=(t,e)=>{for(var r in e||(e={}))w7.call(e,r)&&Jd(t,r,e[r]);if(Yd)for(var r of Yd(e))_7.call(e,r)&&Jd(t,r,e[r]);return t};class vn extends Ap{constructor(e,r,i,n=ai,s=void 0){super(e,r,i,n),this.core=e,this.logger=r,this.name=i,this.map=new Map,this.version=Lw,this.cached=[],this.initialized=!1,this.storagePrefix=ai,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&&!Yt(o)?this.map.set(this.getKey(o),o):B5(o)?this.map.set(o.id,o):q5(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)},this.set=async(o,c)=>{this.isInitialized(),this.map.has(o)?await this.update(o,c):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:c}),this.map.set(o,c),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(c=>Object.keys(o).every(l=>Z8(c[l],o[l]))):this.values),this.update=async(o,c)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:c});const l=Qd(Qd({},this.getData(o)),c);this.map.set(o,l),await this.persist()},this.delete=async(o,c)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:c}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())},this.logger=Ht(r,this.name),this.storagePrefix=n,this.getKey=s}get context(){return Xt(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}=ie("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}const{message:i}=ie("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}=ie("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}=ie("NOT_INITIALIZED",this.name);throw new Error(e)}}}class A7{constructor(e,r){this.core=e,this.logger=r,this.name=kw,this.version=$w,this.events=new qt.exports,this.initialized=!1,this.storagePrefix=ai,this.ignoredPayloadTypes=[mi],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=Tc(),s=await this.core.crypto.setSymKey(n),o=_t(oe.FIVE_MINUTES),c={protocol:kd},l={topic:s,expiry:o,relay:c,active:!1},u=I5({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:n,relay:c,expiryTimestamp:o,methods:i?.methods});return this.core.expirer.set(s,o),await this.pairings.set(s,l),await this.core.relayer.subscribe(s,{transportType:i?.transportType}),{topic:s,uri:u}},this.pair=async i=>{this.isInitialized();const n=this.core.eventClient.createEvent({properties:{topic:i?.uri,trace:[ci.pairing_started]}});this.isValidPair(i,n);const{topic:s,symKey:o,relay:c,expiryTimestamp:l,methods:u}=rd(i.uri);n.props.properties.topic=s,n.addTrace(ci.pairing_uri_validation_success),n.addTrace(ci.pairing_uri_not_expired);let b;if(this.pairings.keys.includes(s)){if(b=this.pairings.get(s),n.addTrace(ci.existing_pairing),b.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(ci.pairing_not_expired)}const m=l||_t(oe.FIVE_MINUTES),M={topic:s,relay:c,expiry:m,active:!1,methods:u};this.core.expirer.set(s,m),await this.pairings.set(s,M),n.addTrace(ci.store_new_pairing),i.activatePairing&&await this.activate({topic:s}),this.events.emit(es.create,M),n.addTrace(ci.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(o,s),n.addTrace(ci.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{n.setError(Ai.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:c})}catch(S){throw n.setError(Ai.subscribe_pairing_topic_failure),S}return n.addTrace(ci.subscribe_pairing_topic_success),M},this.activate=async({topic:i})=>{this.isInitialized();const n=_t(oe.THIRTY_DAYS);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);const{topic:n}=i;if(this.pairings.keys.includes(n)){const s=await this.sendRequest(n,"wc_pairingPing",{}),{done:o,resolve:c,reject:l}=cn();this.events.once(Je("pairing_ping",s),({error:u})=>{u?l(u):c()}),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",ht("USER_DISCONNECTED")),await this.deletePairing(n))},this.sendRequest=async(i,n,s)=>{const o=pn(n,s),c=await this.core.crypto.encode(i,o),l=ks[n].req;return this.core.history.set(i,o),this.core.relayer.publish(i,c,l),o.id},this.sendResult=async(i,n,s)=>{const o=$c(i,s),c=await this.core.crypto.encode(n,o),l=await this.core.history.get(n,i),u=ks[l.request.method].res;await this.core.relayer.publish(n,c,u),await this.core.history.resolve(o)},this.sendError=async(i,n,s)=>{const o=jc(i,s),c=await this.core.crypto.encode(n,o),l=await this.core.history.get(n,i),u=ks[l.request.method]?ks[l.request.method].res:ks.unregistered_method.res;await this.core.relayer.publish(n,c,u),await this.core.history.resolve(o)},this.deletePairing=async(i,n)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,ht("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=>zi(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(es.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(()=>{si(n)?this.events.emit(Je("pairing_ping",s),{}):Ar(n)&&this.events.emit(Je("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(es.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 c=ht("WC_METHOD_UNSUPPORTED",o);await this.sendError(s,i,c),this.logger.error(c)}catch(c){await this.sendError(s,i,c),this.logger.error(c)}},this.onUnknownRpcMethodResponse=i=>{this.registeredMethods.includes(i)||this.logger.error(ht("WC_METHOD_UNSUPPORTED",i))},this.isValidPair=(i,n)=>{var s;if(!ir(i)){const{message:c}=ie("MISSING_OR_INVALID",`pair() params: ${i}`);throw n.setError(Ai.malformed_pairing_uri),new Error(c)}if(!L5(i.uri)){const{message:c}=ie("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw n.setError(Ai.malformed_pairing_uri),new Error(c)}const o=rd(i?.uri);if(!((s=o?.relay)!=null&&s.protocol)){const{message:c}=ie("MISSING_OR_INVALID","pair() uri#relay-protocol");throw n.setError(Ai.malformed_pairing_uri),new Error(c)}if(!(o!=null&&o.symKey)){const{message:c}=ie("MISSING_OR_INVALID","pair() uri#symKey");throw n.setError(Ai.malformed_pairing_uri),new Error(c)}if(o!=null&&o.expiryTimestamp&&oe.toMiliseconds(o?.expiryTimestamp)<Date.now()){n.setError(Ai.pairing_expired);const{message:c}=ie("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(c)}},this.isValidPing=async i=>{if(!ir(i)){const{message:s}=ie("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidDisconnect=async i=>{if(!ir(i)){const{message:s}=ie("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidPairingTopic=async i=>{if(!yt(i,!1)){const{message:n}=ie("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){const{message:n}=ie("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(zi(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:n}=ie("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}},this.core=e,this.logger=Ht(r,this.name),this.pairings=new vn(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Xt(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=ie("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Jt.message,async e=>{const{topic:r,message:i,transportType:n}=e;if(!this.pairings.keys.includes(r)||n===at.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;const s=await this.core.crypto.decode(r,i);try{Kc(s)?(this.core.history.set(r,s),this.onRelayEventRequest({topic:r,payload:s})):Za(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(xr.expired,async e=>{const{topic:r}=Ru(e.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit(es.expire,{topic:r}))})}}class E7 extends mp{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.records=new Map,this.events=new qt.exports.EventEmitter,this.name=jw,this.version=Kw,this.cached=[],this.initialized=!1,this.storagePrefix=ai,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:_t(oe.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(Cr.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(Cr.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(Cr.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=Ht(r,this.name)}get context(){return Xt(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:pn(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}=ie("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Cr.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:r}=ie("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(Cr.created,e=>{const r=Cr.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(Cr.updated,e=>{const r=Cr.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(Cr.deleted,e=>{const r=Cr.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.core.heartbeat.on(xn.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(r=>{oe.toMiliseconds(r.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${r.id}`),this.records.delete(r.id),this.events.emit(Cr.deleted,r,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=ie("NOT_INITIALIZED",this.name);throw new Error(e)}}}class x7 extends xp{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.expirations=new Map,this.events=new qt.exports.EventEmitter,this.name=Hw,this.version=Vw,this.cached=[],this.initialized=!1,this.storagePrefix=ai,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(xr.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(xr.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=Ht(r,this.name)}get context(){return Xt(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 t6(e);if(typeof e=="number")return r6(e);const{message:r}=ie("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(xr.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:r}=ie("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}=ie("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return r}checkExpiry(e,r){const{expiry:i}=r;oe.toMiliseconds(i)-Date.now()<=0&&this.expire(e,r)}expire(e,r){this.expirations.delete(e),this.events.emit(xr.expired,{target:e,expiration:r})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,r)=>this.checkExpiry(r,e))}registerEventListeners(){this.core.heartbeat.on(xn.pulse,()=>this.checkExpirations()),this.events.on(xr.created,e=>{const r=xr.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(xr.expired,e=>{const r=xr.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(xr.deleted,e=>{const r=xr.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=ie("NOT_INITIALIZED",this.name);throw new Error(e)}}}var ut={};Object.defineProperty(ut,"__esModule",{value:!0}),ut.getLocalStorage=ut.getLocalStorageOrThrow=ut.getCrypto=ut.getCryptoOrThrow=ut.getLocation=ut.getLocationOrThrow=ut.getNavigator=ut.getNavigatorOrThrow=Xd=ut.getDocument=ut.getDocumentOrThrow=ut.getFromWindowOrThrow=ut.getFromWindow=void 0;function mn(t){let e;return typeof window<"u"&&typeof window[t]<"u"&&(e=window[t]),e}ut.getFromWindow=mn;function ts(t){const e=mn(t);if(!e)throw new Error(`${t} is not defined in Window`);return e}ut.getFromWindowOrThrow=ts;function S7(){return ts("document")}ut.getDocumentOrThrow=S7;function M7(){return mn("document")}var Xd=ut.getDocument=M7;function I7(){return ts("navigator")}ut.getNavigatorOrThrow=I7;function D7(){return mn("navigator")}ut.getNavigator=D7;function O7(){return ts("location")}ut.getLocationOrThrow=O7;function R7(){return mn("location")}ut.getLocation=R7;function N7(){return ts("crypto")}ut.getCryptoOrThrow=N7;function P7(){return mn("crypto")}ut.getCrypto=P7;function T7(){return ts("localStorage")}ut.getLocalStorageOrThrow=T7;function C7(){return mn("localStorage")}ut.getLocalStorage=C7;class F7 extends Sp{constructor(e,r,i){super(e,r,i),this.core=e,this.logger=r,this.store=i,this.name=Gw,this.verifyUrlV3=Yw,this.storagePrefix=ai,this.version=Ud,this.init=async()=>{var n;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&oe.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(!ys()||this.isDevEnv)return;const s=window.location.origin,{id:o,decryptedId:c}=n,l=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${s}&id=${o}&decryptedId=${c}`;try{const u=Xd(),b=this.startAbortTimer(oe.ONE_SECOND*5),m=await new Promise((M,S)=>{const I=()=>{window.removeEventListener("message",k),u.body.removeChild(F),S("attestation aborted")};this.abortController.signal.addEventListener("abort",I);const F=u.createElement("iframe");F.src=l,F.style.display="none",F.addEventListener("error",I,{signal:this.abortController.signal});const k=j=>{if(!j.data)return;const C=JSON.parse(j.data);if(C.type==="verify_attestation"){if(Fo(C.attestation).payload.id!==o)return;clearInterval(b),u.body.removeChild(F),this.abortController.signal.removeEventListener("abort",I),window.removeEventListener("message",k),M(C.attestation===null?"":C.attestation)}};u.body.appendChild(F),window.addEventListener("message",k,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",m),m}catch(u){this.logger.warn(u)}return""},this.resolve=async n=>{if(this.isDevEnv)return"";const{attestationId:s,hash:o,encryptedId:c}=n;if(s===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(s){if(Fo(s).payload.id!==c)return;const u=await this.isValidJwtAttestation(s);if(u){if(!u.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return u}}if(!o)return;const l=this.getVerifyUrl(n?.verifyUrl);return this.fetchAttestation(o,l)},this.fetchAttestation=async(n,s)=>{this.logger.debug(`resolving attestation: ${n} from url: ${s}`);const o=this.startAbortTimer(oe.ONE_SECOND*5),c=await fetch(`${s}/attestation/${n}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),c.status===200?await c.json():void 0},this.getVerifyUrl=n=>{let s=n||$s;return Jw.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${$s}`),s=$s),s},this.fetchPublicKey=async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const n=this.startAbortTimer(oe.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(c){this.logger.error(c),this.logger.warn("error validating attestation")}const o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(n,o)}catch(c){this.logger.error(c),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=b5(n,s.publicKey),c={hasExpired:oe.toMiliseconds(o.exp)<Date.now(),payload:o};if(c.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:c.payload.origin,isScam:c.payload.isScam,isVerified:c.payload.isVerified}},this.logger=Ht(r,this.name),this.abortController=new AbortController,this.isDevEnv=ac(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return Xt(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),oe.toMiliseconds(e))}}class L7 extends Mp{constructor(e,r){super(e,r),this.projectId=e,this.logger=r,this.context=Qw,this.registerDeviceToken=async i=>{const{clientId:n,token:s,notificationType:o,enableEncrypted:c=!1}=i,l=`${Xw}/${this.projectId}/clients`;await fetch(l,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:n,type:o,token:s,always_raw:c})})},this.logger=Ht(r,this.context)}}var B7=Object.defineProperty,Zd=Object.getOwnPropertySymbols,q7=Object.prototype.hasOwnProperty,U7=Object.prototype.propertyIsEnumerable,el=(t,e,r)=>e in t?B7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Hs=(t,e)=>{for(var r in e||(e={}))q7.call(e,r)&&el(t,r,e[r]);if(Zd)for(var r of Zd(e))U7.call(e,r)&&el(t,r,e[r]);return t};class z7 extends Ip{constructor(e,r,i=!0){super(e,r,i),this.core=e,this.logger=r,this.context=e7,this.storagePrefix=ai,this.storageVersion=Zw,this.events=new Map,this.shouldPersist=!1,this.init=async()=>{if(!ac())try{const n={eventId:Pu(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:Mu(this.core.relayer.protocol,this.core.relayer.version,Jc)}}};await this.sendEvent([n])}catch(n){this.logger.warn(n)}},this.createEvent=n=>{const{event:s="ERROR",type:o="",properties:{topic:c,trace:l}}=n,u=Pu(),b=this.core.projectId||"",m=Date.now(),M=Hs({eventId:u,timestamp:m,props:{event:s,type:o,properties:{topic:c,trace:l}},bundleId:b,domain:this.getAppDomain()},this.setMethods(u));return this.telemetryEnabled&&(this.events.set(u,M),this.shouldPersist=!0),M},this.getEvent=n=>{const{eventId:s,topic:o}=n;if(s)return this.events.get(s);const c=Array.from(this.events.values()).find(l=>l.props.properties.topic===o);if(c)return Hs(Hs({},c),this.setMethods(c.eventId))},this.deleteEvent=n=>{const{eventId:s}=n;this.events.delete(s),this.shouldPersist=!0},this.setEventListeners=()=>{this.core.heartbeat.on(xn.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(n=>{oe.fromMiliseconds(Date.now())-oe.fromMiliseconds(n.timestamp)>t7&&(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,Hs(Hs({},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(`${r7}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${Jc}${s}`,{method:"POST",body:JSON.stringify(n)})},this.getAppDomain=()=>Su().url,this.logger=Ht(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 k7=Object.defineProperty,tl=Object.getOwnPropertySymbols,$7=Object.prototype.hasOwnProperty,j7=Object.prototype.propertyIsEnumerable,rl=(t,e,r)=>e in t?k7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,il=(t,e)=>{for(var r in e||(e={}))$7.call(e,r)&&rl(t,r,e[r]);if(tl)for(var r of tl(e))j7.call(e,r)&&rl(t,r,e[r]);return t};class Xc extends vp{constructor(e){var r;super(e),this.protocol=qd,this.version=Ud,this.name=Yc,this.events=new qt.exports.EventEmitter,this.initialized=!1,this.on=(o,c)=>this.events.on(o,c),this.once=(o,c)=>this.events.once(o,c),this.off=(o,c)=>this.events.off(o,c),this.removeListener=(o,c)=>this.events.removeListener(o,c),this.dispatchEnvelope=({topic:o,message:c,sessionExists:l})=>{if(!o||!c)return;const u={topic:o,message:c,publishedAt:Date.now(),transportType:at.link_mode};this.relayer.onLinkMessageEvent(u,{sessionExists:l})},this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||$d,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=So({level:typeof e?.logger=="string"&&e.logger?e.logger:Aw.logger}),{logger:n,chunkLoggerController:s}=bp({opts:i,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=s,(r=this.logChunkController)!=null&&r.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var o,c;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((c=this.logChunkController)==null||c.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=Ht(n,this.name),this.heartbeat=new _o,this.crypto=new n7(this,this.logger,e?.keychain),this.history=new E7(this,this.logger),this.expirer=new x7(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new l1(il(il({},Ew),e?.storageOptions)),this.relayer=new m7({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new A7(this,this.logger),this.verify=new F7(this,this.logger,this.storage),this.echoClient=new L7(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new z7(this,this.logger,e?.telemetryEnabled)}static async init(e){const r=new Xc(e);await r.initialize();const i=await r.crypto.getClientId();return await r.storage.setItem(Bw,i),r}get context(){return Xt(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(jd,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.eventClient.init(),this.linkModeSupportedApps=await this.storage.getItem(jd)||[],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 Zc=Xc,nl="wc",sl=2,al="client",ef=`${nl}@${sl}:${al}:`,tf={name:al,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.com"},ol="WALLETCONNECT_DEEPLINK_CHOICE",K7="proposal",H7="Proposal expired",V7="session",rs=oe.SEVEN_DAYS,G7="engine",Ot={wc_sessionPropose:{req:{ttl:oe.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:oe.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:oe.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:oe.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:oe.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:oe.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:oe.ONE_DAY,prompt:!1,tag:1104},res:{ttl:oe.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:oe.ONE_DAY,prompt:!1,tag:1106},res:{ttl:oe.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:oe.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:oe.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:oe.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:oe.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:oe.ONE_DAY,prompt:!1,tag:1112},res:{ttl:oe.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:oe.ONE_DAY,prompt:!1,tag:1114},res:{ttl:oe.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:oe.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:oe.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:oe.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:oe.FIVE_MINUTES,prompt:!1,tag:1119}}},rf={min:oe.FIVE_MINUTES,max:oe.SEVEN_DAYS},fi={idle:"IDLE",active:"ACTIVE"},W7="request",Y7=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],J7="wc",Q7="auth",X7="authKeys",Z7="pairingTopics",e9="requests",to=`${J7}@${1.5}:${Q7}:`,ro=`${to}:PUB_KEY`;var t9=Object.defineProperty,r9=Object.defineProperties,i9=Object.getOwnPropertyDescriptors,cl=Object.getOwnPropertySymbols,n9=Object.prototype.hasOwnProperty,s9=Object.prototype.propertyIsEnumerable,fl=(t,e,r)=>e in t?t9(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,bt=(t,e)=>{for(var r in e||(e={}))n9.call(e,r)&&fl(t,r,e[r]);if(cl)for(var r of cl(e))s9.call(e,r)&&fl(t,r,e[r]);return t},Lr=(t,e)=>r9(t,i9(e));class a9 extends Op{constructor(e){super(e),this.name=G7,this.events=new qt.exports,this.initialized=!1,this.requestQueue={state:fi.idle,queue:[]},this.sessionRequestQueue={state:fi.idle,queue:[]},this.requestQueueDelay=oe.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(Ot)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},oe.toMiliseconds(this.requestQueueDelay)))},this.connect=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const i=Lr(bt({},r),{requiredNamespaces:r.requiredNamespaces||{},optionalNamespaces:r.optionalNamespaces||{}});await this.isValidConnect(i);const{pairingTopic:n,requiredNamespaces:s,optionalNamespaces:o,sessionProperties:c,relays:l}=i;let u=n,b,m=!1;try{u&&(m=this.client.core.pairing.pairings.get(u).active)}catch(P){throw this.client.logger.error(`connect() -> pairing.get(${u}) failed`),P}if(!u||!m){const{topic:P,uri:B}=await this.client.core.pairing.create();u=P,b=B}if(!u){const{message:P}=ie("NO_MATCHING_KEY",`connect() pairing topic: ${u}`);throw new Error(P)}const M=await this.client.core.crypto.generateKeyPair(),S=Ot.wc_sessionPropose.req.ttl||oe.FIVE_MINUTES,I=_t(S),F=bt({requiredNamespaces:s,optionalNamespaces:o,relays:l??[{protocol:kd}],proposer:{publicKey:M,metadata:this.client.metadata},expiryTimestamp:I,pairingTopic:u},c&&{sessionProperties:c}),{reject:k,resolve:j,done:C}=cn(S,H7);this.events.once(Je("session_connect"),async({error:P,session:B})=>{if(P)k(P);else if(B){B.self.publicKey=M;const U=Lr(bt({},B),{pairingTopic:F.pairingTopic,requiredNamespaces:F.requiredNamespaces,optionalNamespaces:F.optionalNamespaces,transportType:at.relay});await this.client.session.set(B.topic,U),await this.setExpiry(B.topic,B.expiry),u&&await this.client.core.pairing.updateMetadata({topic:u,metadata:B.peer.metadata}),this.cleanupDuplicatePairings(U),j(U)}});const $=await this.sendRequest({topic:u,method:"wc_sessionPropose",params:F,throwOnFailedPublish:!0});return await this.setProposal($,bt({id:$},F)),{uri:b,approval:C}},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:[Fr.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(O){throw o.setError(gn.no_internet_connection),O}try{await this.isValidProposalId(r?.id)}catch(O){throw this.client.logger.error(`approve() -> proposal.get(${r?.id}) failed`),o.setError(gn.proposal_not_found),O}try{await this.isValidApprove(r)}catch(O){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(gn.session_approve_namespace_validation_failure),O}const{id:c,relayProtocol:l,namespaces:u,sessionProperties:b,sessionConfig:m}=r,M=this.client.proposal.get(c);this.client.core.eventClient.deleteEvent({eventId:o.eventId});const{pairingTopic:S,proposer:I,requiredNamespaces:F,optionalNamespaces:k}=M;let j=(n=this.client.core.eventClient)==null?void 0:n.getEvent({topic:S});j||(j=(s=this.client.core.eventClient)==null?void 0:s.createEvent({type:Fr.session_approve_started,properties:{topic:S,trace:[Fr.session_approve_started,Fr.session_namespaces_validation_success]}}));const C=await this.client.core.crypto.generateKeyPair(),$=I.publicKey,P=await this.client.core.crypto.generateSharedKey(C,$),B=bt(bt({relay:{protocol:l??"irn"},namespaces:u,controller:{publicKey:C,metadata:this.client.metadata},expiry:_t(rs)},b&&{sessionProperties:b}),m&&{sessionConfig:m}),U=at.relay;j.addTrace(Fr.subscribing_session_topic);try{await this.client.core.relayer.subscribe(P,{transportType:U})}catch(O){throw j.setError(gn.subscribe_session_topic_failure),O}j.addTrace(Fr.subscribe_session_topic_success);const y=Lr(bt({},B),{topic:P,requiredNamespaces:F,optionalNamespaces:k,pairingTopic:S,acknowledged:!1,self:B.controller,peer:{publicKey:I.publicKey,metadata:I.metadata},controller:C,transportType:at.relay});await this.client.session.set(P,y),j.addTrace(Fr.store_session);try{j.addTrace(Fr.publishing_session_settle),await this.sendRequest({topic:P,method:"wc_sessionSettle",params:B,throwOnFailedPublish:!0}).catch(O=>{throw j?.setError(gn.session_settle_publish_failure),O}),j.addTrace(Fr.session_settle_publish_success),j.addTrace(Fr.publishing_session_approve),await this.sendResult({id:c,topic:S,result:{relay:{protocol:l??"irn"},responderPublicKey:C},throwOnFailedPublish:!0}).catch(O=>{throw j?.setError(gn.session_approve_publish_failure),O}),j.addTrace(Fr.session_approve_publish_success)}catch(O){throw this.client.logger.error(O),this.client.session.delete(P,ht("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(P),O}return this.client.core.eventClient.deleteEvent({eventId:j.eventId}),await this.client.core.pairing.updateMetadata({topic:S,metadata:I.metadata}),await this.client.proposal.delete(c,ht("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:S}),await this.setExpiry(P,_t(rs)),{topic:P,acknowledged:()=>Promise.resolve(this.client.session.get(P))}},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:Ot.wc_sessionPropose.reject}),await this.client.proposal.delete(i,ht("USER_DISCONNECTED")))},this.update=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(r)}catch(m){throw this.client.logger.error("update() -> isValidUpdate() failed"),m}const{topic:i,namespaces:n}=r,{done:s,resolve:o,reject:c}=cn(),l=Hi(),u=ln().toString(),b=this.client.session.get(i).namespaces;return this.events.once(Je("session_update",l),({error:m})=>{m?c(m):o()}),await this.client.session.update(i,{namespaces:n}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:n},throwOnFailedPublish:!0,clientRpcId:l,relayRpcId:u}).catch(m=>{this.client.logger.error(m),this.client.session.update(i,{namespaces:b}),c(m)}),{acknowledged:s}},this.extend=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(r)}catch(l){throw this.client.logger.error("extend() -> isValidExtend() failed"),l}const{topic:i}=r,n=Hi(),{done:s,resolve:o,reject:c}=cn();return this.events.once(Je("session_extend",n),({error:l})=>{l?c(l):o()}),await this.setExpiry(i,_t(rs)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(l=>{c(l)}),{acknowledged:s}},this.request=async r=>{this.isInitialized();try{await this.isValidRequest(r)}catch(I){throw this.client.logger.error("request() -> isValidRequest() failed"),I}const{chainId:i,request:n,topic:s,expiry:o=Ot.wc_sessionRequest.req.ttl}=r,c=this.client.session.get(s);c?.transportType===at.relay&&await this.confirmOnlineStateOrThrow();const l=Hi(),u=ln().toString(),{done:b,resolve:m,reject:M}=cn(o,"Request expired. Please try again.");this.events.once(Je("session_request",l),({error:I,result:F})=>{I?M(I):m(F)});const S=this.getAppLinkIfEnabled(c.peer.metadata,c.transportType);return S?(await this.sendRequest({clientRpcId:l,relayRpcId:u,topic:s,method:"wc_sessionRequest",params:{request:Lr(bt({},n),{expiryTimestamp:_t(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0,appLink:S}).catch(I=>M(I)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:l}),await b()):await Promise.all([new Promise(async I=>{await this.sendRequest({clientRpcId:l,relayRpcId:u,topic:s,method:"wc_sessionRequest",params:{request:Lr(bt({},n),{expiryTimestamp:_t(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0}).catch(F=>M(F)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:l}),I()}),new Promise(async I=>{var F;if(!((F=c.sessionConfig)!=null&&F.disableDeepLink)){const k=await s6(this.client.core.storage,ol);n6({id:l,topic:s,wcDeepLink:k})}I()}),b()]).then(I=>I[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===at.relay&&await this.confirmOnlineStateOrThrow();const c=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);si(n)?await this.sendResult({id:s,topic:i,result:n.result,throwOnFailedPublish:!0,appLink:c}):Ar(n)&&await this.sendError({id:s,topic:i,error:n.error,appLink:c}),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=Hi(),s=ln().toString(),{done:o,resolve:c,reject:l}=cn();this.events.once(Je("session_ping",n),({error:u})=>{u?l(u):c()}),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)&&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=ln().toString();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:n,chainId:s},throwOnFailedPublish:!0,relayRpcId:o})},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:ht("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}=ie("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(n)}},this.find=r=>(this.isInitialized(),this.client.session.getAll().filter(i=>C5(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?at.link_mode:at.relay;o===at.relay&&await this.confirmOnlineStateOrThrow();const{chains:c,statement:l="",uri:u,domain:b,nonce:m,type:M,exp:S,nbf:I,methods:F=[],expiry:k}=r,j=[...r.resources||[]],{topic:C,uri:$}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:C,uri:$}});const P=await this.client.core.crypto.generateKeyPair(),B=Ya(P);if(await Promise.all([this.client.auth.authKeys.set(ro,{responseTopic:B,publicKey:P}),this.client.auth.pairingTopics.set(B,{topic:B,pairingTopic:C})]),await this.client.core.relayer.subscribe(B,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${C}`),F.length>0){const{namespace:x}=sc(c[0]);let _=e5(x,"request",F);Wa(j)&&(_=r5(_,j.pop())),j.push(_)}const U=k&&k>Ot.wc_sessionAuthenticate.req.ttl?k:Ot.wc_sessionAuthenticate.req.ttl,y={authPayload:{type:M??"caip122",chains:c,statement:l,aud:u,domain:b,version:"1",nonce:m,iat:new Date().toISOString(),exp:S,nbf:I,resources:j},requester:{publicKey:P,metadata:this.client.metadata},expiryTimestamp:_t(U)},O={eip155:{chains:c,methods:[...new Set(["personal_sign",...F])],events:["chainChanged","accountsChanged"]}},Y={requiredNamespaces:{},optionalNamespaces:O,relays:[{protocol:"irn"}],pairingTopic:C,proposer:{publicKey:P,metadata:this.client.metadata},expiryTimestamp:_t(Ot.wc_sessionPropose.req.ttl)},{done:Q,resolve:N,reject:g}=cn(U,"Request expired"),a=async({error:x,session:_})=>{if(this.events.off(Je("session_request",p),f),x)g(x);else if(_){_.self.publicKey=P,await this.client.session.set(_.topic,_),await this.setExpiry(_.topic,_.expiry),C&&await this.client.core.pairing.updateMetadata({topic:C,metadata:_.peer.metadata});const h=this.client.session.get(_.topic);await this.deleteProposal(w),N({session:h})}},f=async x=>{var _,h,d;if(await this.deletePendingAuthRequest(p,{message:"fulfilled",code:0}),x.error){const L=ht("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return x.error.code===L.code?void 0:(this.events.off(Je("session_connect"),a),g(x.error.message))}await this.deleteProposal(w),this.events.off(Je("session_connect"),a);const{cacaos:D,responder:K}=x.result,G=[],E=[];for(const L of D){await z0({cacao:L,projectId:this.client.core.projectId})||(this.client.logger.error(L,"Signature verification failed"),g(ht("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:q}=L,v=Wa(q.resources),T=[U0(q.iss)],W=Ga(q.iss);if(v){const J=j0(v),X=K0(v);G.push(...J),T.push(...X)}for(const J of T)E.push(`${J}:${W}`)}const H=await this.client.core.crypto.generateSharedKey(P,K.publicKey);let R;G.length>0&&(R={topic:H,acknowledged:!0,self:{publicKey:P,metadata:this.client.metadata},peer:K,controller:K.publicKey,expiry:_t(rs),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:C,namespaces:id([...new Set(G)],[...new Set(E)]),transportType:o},await this.client.core.relayer.subscribe(H,{transportType:o}),await this.client.session.set(H,R),C&&await this.client.core.pairing.updateMetadata({topic:C,metadata:K.metadata}),R=this.client.session.get(H)),(_=this.client.metadata.redirect)!=null&&_.linkMode&&(h=K.metadata.redirect)!=null&&h.linkMode&&(d=K.metadata.redirect)!=null&&d.universal&&i&&(this.client.core.addLinkModeSupportedApp(K.metadata.redirect.universal),this.client.session.update(H,{transportType:at.link_mode})),N({auths:D,session:R})},p=Hi(),w=Hi();this.events.once(Je("session_connect"),a),this.events.once(Je("session_request",p),f);let A;try{if(s){const x=pn("wc_sessionAuthenticate",y,p);this.client.core.history.set(C,x);const _=await this.client.core.crypto.encode("",x,{type:Ps,encoding:Rs});A=Ja(i,C,_)}else await Promise.all([this.sendRequest({topic:C,method:"wc_sessionAuthenticate",params:y,expiry:r.expiry,throwOnFailedPublish:!0,clientRpcId:p}),this.sendRequest({topic:C,method:"wc_sessionPropose",params:Y,expiry:Ot.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:w})])}catch(x){throw this.events.off(Je("session_connect"),a),this.events.off(Je("session_request",p),f),x}return await this.setProposal(w,bt({id:w},Y)),await this.setAuthRequest(p,{request:Lr(bt({},y),{verifyContext:{}}),pairingTopic:C,transportType:o}),{uri:A??$,response:Q}},this.approveSessionAuthenticate=async r=>{const{id:i,auths:n}=r,s=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[bn.authenticated_session_approve_started]}});try{this.isInitialized()}catch(k){throw s.setError(js.no_internet_connection),k}const o=this.getPendingAuthRequest(i);if(!o)throw s.setError(js.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);const c=o.transportType||at.relay;c===at.relay&&await this.confirmOnlineStateOrThrow();const l=o.requester.publicKey,u=await this.client.core.crypto.generateKeyPair(),b=Ya(l),m={type:mi,receiverPublicKey:l,senderPublicKey:u},M=[],S=[];for(const k of n){if(!await z0({cacao:k,projectId:this.client.core.projectId})){s.setError(js.invalid_cacao);const B=ht("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:b,error:B,encodeOpts:m}),new Error(B.message)}s.addTrace(bn.cacaos_verified);const{p:j}=k,C=Wa(j.resources),$=[U0(j.iss)],P=Ga(j.iss);if(C){const B=j0(C),U=K0(C);M.push(...B),$.push(...U)}for(const B of $)S.push(`${B}:${P}`)}const I=await this.client.core.crypto.generateSharedKey(u,l);s.addTrace(bn.create_authenticated_session_topic);let F;if(M?.length>0){F={topic:I,acknowledged:!0,self:{publicKey:u,metadata:this.client.metadata},peer:{publicKey:l,metadata:o.requester.metadata},controller:l,expiry:_t(rs),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:id([...new Set(M)],[...new Set(S)]),transportType:c},s.addTrace(bn.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(I,{transportType:c})}catch(k){throw s.setError(js.subscribe_authenticated_session_topic_failure),k}s.addTrace(bn.subscribe_authenticated_session_topic_success),await this.client.session.set(I,F),s.addTrace(bn.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}s.addTrace(bn.publishing_authenticated_session_approve);try{await this.sendResult({topic:b,id:i,result:{cacaos:n,responder:{publicKey:u,metadata:this.client.metadata}},encodeOpts:m,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,c)})}catch(k){throw s.setError(js.authenticated_session_approve_publish_failure),k}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:F}},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===at.relay&&await this.confirmOnlineStateOrThrow();const o=s.requester.publicKey,c=await this.client.core.crypto.generateKeyPair(),l=Ya(o),u={type:mi,receiverPublicKey:o,senderPublicKey:c};await this.sendError({id:i,topic:l,error:n,encodeOpts:u,rpcOpts:Ot.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,ht("USER_DISCONNECTED"))},this.formatAuthMessage=r=>{this.isInitialized();const{request:i,iss:n}=r;return k0(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,c;return((o=s.peerMetadata)==null?void 0:o.url)&&((c=s.peerMetadata)==null?void 0:c.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:c=0}=r,{self:l}=this.client.session.get(n);await this.client.core.relayer.unsubscribe(n),await this.client.session.delete(n,ht("USER_DISCONNECTED")),this.addToRecentlyDeleted(n,"session"),this.client.core.crypto.keychain.has(l.publicKey)&&await this.client.core.crypto.deleteKeyPair(l.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(ol).catch(u=>this.client.logger.warn(u)),this.getPendingSessionRequests().forEach(u=>{u.topic===n&&this.deletePendingSessionRequest(u.id,ht("USER_DISCONNECTED"))}),n===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=fi.idle),o&&this.client.events.emit("session_delete",{id:c,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(gn.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(r,ht("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=fi.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,_t(Ot.wc_sessionPropose.req.ttl)),await this.client.proposal.set(r,i)},this.setAuthRequest=async(r,i)=>{const{request:n,pairingTopic:s,transportType:o=at.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,c=s.request.expiryTimestamp||_t(Ot.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,c),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:c,clientRpcId:l,throwOnFailedPublish:u,appLink:b}=r,m=pn(n,s,l);let M;const S=!!b;try{const k=S?Rs:Ki;M=await this.client.core.crypto.encode(i,m,{encoding:k})}catch(k){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),k}let I;if(Y7.includes(n)){const k=yi(JSON.stringify(m)),j=yi(M);I=await this.client.core.verify.register({id:j,decryptedId:k})}const F=Ot[n].req;if(F.attestation=I,o&&(F.ttl=o),c&&(F.id=c),this.client.core.history.set(i,m),S){const k=Ja(b,i,M);await global.Linking.openURL(k,this.client.name)}else{const k=Ot[n].req;o&&(k.ttl=o),c&&(k.id=c),u?(k.internal=Lr(bt({},k.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,M,k)):this.client.core.relayer.publish(i,M,k).catch(j=>this.client.logger.error(j))}return m.id},this.sendResult=async r=>{const{id:i,topic:n,result:s,throwOnFailedPublish:o,encodeOpts:c,appLink:l}=r,u=$c(i,s);let b;const m=l&&typeof(global==null?void 0:global.Linking)<"u";try{const S=m?Rs:Ki;b=await this.client.core.crypto.encode(n,u,Lr(bt({},c||{}),{encoding:S}))}catch(S){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${n} failed`),S}let M;try{M=await this.client.core.history.get(n,i)}catch(S){throw this.client.logger.error(`sendResult() -> history.get(${n}, ${i}) failed`),S}if(m){const S=Ja(l,n,b);await global.Linking.openURL(S,this.client.name)}else{const S=Ot[M.request.method].res;o?(S.internal=Lr(bt({},S.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,b,S)):this.client.core.relayer.publish(n,b,S).catch(I=>this.client.logger.error(I))}await this.client.core.history.resolve(u)},this.sendError=async r=>{const{id:i,topic:n,error:s,encodeOpts:o,rpcOpts:c,appLink:l}=r,u=jc(i,s);let b;const m=l&&typeof(global==null?void 0:global.Linking)<"u";try{const S=m?Rs:Ki;b=await this.client.core.crypto.encode(n,u,Lr(bt({},o||{}),{encoding:S}))}catch(S){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`),S}let M;try{M=await this.client.core.history.get(n,i)}catch(S){throw this.client.logger.error(`sendError() -> history.get(${n}, ${i}) failed`),S}if(m){const S=Ja(l,n,b);await global.Linking.openURL(S,this.client.name)}else{const S=c||Ot[M.request.method].res;this.client.core.relayer.publish(n,b,S)}await this.client.core.history.resolve(u)},this.cleanup=async()=>{const r=[],i=[];this.client.session.getAll().forEach(n=>{let s=!1;zi(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=>{zi(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===fi.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=fi.active;const r=this.requestQueue.queue.shift();if(r)try{await this.processRequest(r)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=fi.idle},this.processRequest=async r=>{const{topic:i,payload:n,attestation:s,transportType:o,encryptedId:c}=r,l=n.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:l}))switch(l){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:n,attestation:s,encryptedId:c});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:c,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:c,transportType:o});default:return this.client.logger.info(`Unsupported request method ${l}`)}},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}=ie("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:c,id:l}=n;try{const u=this.client.core.eventClient.getEvent({topic:i});this.isValidConnect(bt({},n.params));const b=c.expiryTimestamp||_t(Ot.wc_sessionPropose.req.ttl),m=bt({id:l,pairingTopic:i,expiryTimestamp:b},c);await this.setProposal(l,m);const M=await this.getVerifyContext({attestationId:s,hash:yi(JSON.stringify(n)),encryptedId:o,metadata:m.proposer.metadata});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),u?.setError(Ai.proposal_listener_not_found)),u?.addTrace(ci.emit_session_proposal),this.client.events.emit("session_proposal",{id:l,params:m,verifyContext:M})}catch(u){await this.sendError({id:l,topic:i,error:u,rpcOpts:Ot.wc_sessionPropose.autoReject}),this.client.logger.error(u)}},this.onSessionProposeResponse=async(r,i,n)=>{const{id:s}=i;if(si(i)){const{result:o}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});const c=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:c});const l=c.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:l});const u=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:u});const b=await this.client.core.crypto.generateSharedKey(l,u);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:b});const m=await this.client.core.relayer.subscribe(b,{transportType:n});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:m}),await this.client.core.pairing.activate({topic:r})}else if(Ar(i)){await this.client.proposal.delete(s,ht("USER_DISCONNECTED"));const o=Je("session_connect");if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(Je("session_connect"),{error:i.error})}},this.onSessionSettleRequest=async(r,i)=>{const{id:n,params:s}=i;try{this.isValidSessionSettleRequest(s);const{relay:o,controller:c,expiry:l,namespaces:u,sessionProperties:b,sessionConfig:m}=i.params,M=Lr(bt(bt({topic:r,relay:o,expiry:l,namespaces:u,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:c.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:c.publicKey,metadata:c.metadata}},b&&{sessionProperties:b}),m&&{sessionConfig:m}),{transportType:at.relay}),S=Je("session_connect");if(this.events.listenerCount(S)===0)throw new Error(`emitting ${S} without any listeners 997`);this.events.emit(Je("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;si(i)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(Je("session_approve",n),{})):Ar(i)&&(await this.client.session.delete(r,ht("USER_DISCONNECTED")),this.events.emit(Je("session_approve",n),{error:i.error}))},this.onSessionUpdateRequest=async(r,i)=>{const{params:n,id:s}=i;try{const o=`${r}_session_update`,c=Bs.get(o);if(c&&this.isRequestOutOfSync(c,s)){this.client.logger.info(`Discarding out of sync request - ${s}`),this.sendError({id:s,topic:r,error:ht("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(bt({topic:r},n));try{Bs.set(o,s),await this.client.session.update(r,{namespaces:n.namespaces}),await this.sendResult({id:s,topic:r,result:!0,throwOnFailedPublish:!0})}catch(l){throw Bs.delete(o),l}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)=>parseInt(i.toString().slice(0,-3))<=parseInt(r.toString().slice(0,-3)),this.onSessionUpdateResponse=(r,i)=>{const{id:n}=i,s=Je("session_update",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);si(i)?this.events.emit(Je("session_update",n),{}):Ar(i)&&this.events.emit(Je("session_update",n),{error:i.error})},this.onSessionExtendRequest=async(r,i)=>{const{id:n}=i;try{this.isValidExtend({topic:r}),await this.setExpiry(r,_t(rs)),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=Je("session_extend",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);si(i)?this.events.emit(Je("session_extend",n),{}):Ar(i)&&this.events.emit(Je("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=Je("session_ping",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);setTimeout(()=>{si(i)?this.events.emit(Je("session_ping",n),{}):Ar(i)&&this.events.emit(Je("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(Jt.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:ht("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:c,attestation:l,encryptedId:u,transportType:b}=r,{id:m,params:M}=c;try{await this.isValidRequest(bt({topic:o},M));const S=this.client.session.get(o),I=await this.getVerifyContext({attestationId:l,hash:yi(JSON.stringify(pn("wc_sessionRequest",M,m))),encryptedId:u,metadata:S.peer.metadata,transportType:b}),F={id:m,topic:o,params:M,verifyContext:I};await this.setPendingSessionRequest(F),b===at.link_mode&&(i=S.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((n=S.peer.metadata.redirect)==null?void 0:n.universal),(s=this.client.signConfig)!=null&&s.disableRequestQueue?this.emitSessionRequest(F):(this.addSessionRequestToSessionRequestQueue(F),this.processSessionRequestQueue())}catch(S){await this.sendError({id:m,topic:o,error:S}),this.client.logger.error(S)}},this.onSessionRequestResponse=(r,i)=>{const{id:n}=i,s=Je("session_request",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);si(i)?this.events.emit(Je("session_request",n),{result:i.result}):Ar(i)&&this.events.emit(Je("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}`,c=Bs.get(o);if(c&&this.isRequestOutOfSync(c,n)){this.client.logger.info(`Discarding out of sync request - ${n}`);return}this.isValidEmit(bt({topic:r},s)),this.client.events.emit("session_event",{id:n,topic:r,params:s}),Bs.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}),si(i)?this.events.emit(Je("session_request",n),{result:i.result}):Ar(i)&&this.events.emit(Je("session_request",n),{error:i.error})},this.onSessionAuthenticateRequest=async r=>{var i;const{topic:n,payload:s,attestation:o,encryptedId:c,transportType:l}=r;try{const{requester:u,authPayload:b,expiryTimestamp:m}=s.params,M=await this.getVerifyContext({attestationId:o,hash:yi(JSON.stringify(s)),encryptedId:c,metadata:u.metadata,transportType:l}),S={requester:u,pairingTopic:n,id:s.id,authPayload:b,verifyContext:M,expiryTimestamp:m};await this.setAuthRequest(s.id,{request:S,pairingTopic:n,transportType:l}),l===at.link_mode&&(i=u.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(u.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:n,params:s.params,id:s.id,verifyContext:M})}catch(u){this.client.logger.error(u);const b=s.params.requester.publicKey,m=await this.client.core.crypto.generateKeyPair(),M=this.getAppLinkIfEnabled(s.params.requester.metadata,l),S={type:mi,receiverPublicKey:b,senderPublicKey:m};await this.sendError({id:s.id,topic:n,error:u,encodeOpts:S,rpcOpts:Ot.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=fi.idle,this.processSessionRequestQueue()},oe.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,c=Je("session_request",o);if(this.events.listenerCount(c)===0)throw new Error(`emitting ${c} without any listeners`);this.events.emit(Je("session_request",s.request.id),{error:i})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===fi.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=fi.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:pn("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id)})},this.isValidConnect=async r=>{if(!ir(r)){const{message:l}=ie("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(l)}const{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:s,sessionProperties:o,relays:c}=r;if(Yt(i)||await this.isValidPairingTopic(i),!V5(c,!0)){const{message:l}=ie("MISSING_OR_INVALID",`connect() relays: ${c}`);throw new Error(l)}!Yt(n)&&Qa(n)!==0&&this.validateNamespaces(n,"requiredNamespaces"),!Yt(s)&&Qa(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),Yt(o)||this.validateSessionProps(o,"sessionProperties")},this.validateNamespaces=(r,i)=>{const n=H5(r,"connect()",i);if(n)throw new Error(n.message)},this.isValidApprove=async r=>{if(!ir(r))throw new Error(ie("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 c=this.client.proposal.get(i),l=Lc(n,"approve()");if(l)throw new Error(l.message);const u=cd(c.requiredNamespaces,n,"approve()");if(u)throw new Error(u.message);if(!yt(s,!0)){const{message:b}=ie("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(b)}Yt(o)||this.validateSessionProps(o,"sessionProperties")},this.isValidReject=async r=>{if(!ir(r)){const{message:s}=ie("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(s)}const{id:i,reason:n}=r;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!W5(n)){const{message:s}=ie("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(s)}},this.isValidSessionSettleRequest=r=>{if(!ir(r)){const{message:u}=ie("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(u)}const{relay:i,controller:n,namespaces:s,expiry:o}=r;if(!ad(i)){const{message:u}=ie("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(u)}const c=U5(n,"onSessionSettleRequest()");if(c)throw new Error(c.message);const l=Lc(s,"onSessionSettleRequest()");if(l)throw new Error(l.message);if(zi(o)){const{message:u}=ie("EXPIRED","onSessionSettleRequest()");throw new Error(u)}},this.isValidUpdate=async r=>{if(!ir(r)){const{message:l}=ie("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(l)}const{topic:i,namespaces:n}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const s=this.client.session.get(i),o=Lc(n,"update()");if(o)throw new Error(o.message);const c=cd(s.requiredNamespaces,n,"update()");if(c)throw new Error(c.message)},this.isValidExtend=async r=>{if(!ir(r)){const{message:n}=ie("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(!ir(r)){const{message:l}=ie("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(l)}const{topic:i,request:n,chainId:s,expiry:o}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const{namespaces:c}=this.client.session.get(i);if(!od(c,s)){const{message:l}=ie("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(l)}if(!Y5(n)){const{message:l}=ie("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(l)}if(!X5(c,s,n.method)){const{message:l}=ie("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(l)}if(o&&!r8(o,rf)){const{message:l}=ie("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${rf.min} and ${rf.max}`);throw new Error(l)}},this.isValidRespond=async r=>{var i;if(!ir(r)){const{message:o}=ie("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(!J5(s)){const{message:o}=ie("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(o)}},this.isValidPing=async r=>{if(!ir(r)){const{message:n}=ie("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)},this.isValidEmit=async r=>{if(!ir(r)){const{message:c}=ie("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(c)}const{topic:i,event:n,chainId:s}=r;await this.isValidSessionTopic(i);const{namespaces:o}=this.client.session.get(i);if(!od(o,s)){const{message:c}=ie("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(c)}if(!Q5(n)){const{message:c}=ie("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(c)}if(!Z5(o,s,n.name)){const{message:c}=ie("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(c)}},this.isValidDisconnect=async r=>{if(!ir(r)){const{message:n}=ie("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(!yt(n,!1))throw new Error("uri is required parameter");if(!yt(s,!1))throw new Error("domain is required parameter");if(!yt(o,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(l=>sc(l).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:c}=sc(i[0]);if(c!=="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:c}=r,l={verified:{verifyUrl:o.verifyUrl||$s,validation:"UNKNOWN",origin:o.url||""}};try{if(c===at.link_mode){const b=this.getAppLinkIfEnabled(o,c);return l.verified.validation=b&&new URL(b).origin===new URL(o.url).origin?"VALID":"INVALID",l}const u=await this.client.core.verify.resolve({attestationId:i,hash:n,encryptedId:s,verifyUrl:o.verifyUrl});u&&(l.verified.origin=u.origin,l.verified.isScam=u.isScam,l.verified.validation=u.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(u){this.client.logger.warn(u)}return this.client.logger.debug(`Verify context: ${JSON.stringify(l)}`),l},this.validateSessionProps=(r,i)=>{Object.values(r).forEach(n=>{if(!yt(n,!1)){const{message:s}=ie("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}=ie("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${r}`);throw new Error(n)}},this.isLinkModeEnabled=(r,i)=>{var n,s,o,c,l,u,b,m,M;return!r||i!==at.link_mode?!1:((s=(n=this.client.metadata)==null?void 0:n.redirect)==null?void 0:s.linkMode)===!0&&((c=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:c.universal)!==void 0&&((u=(l=this.client.metadata)==null?void 0:l.redirect)==null?void 0:u.universal)!==""&&((b=r?.redirect)==null?void 0:b.universal)!==void 0&&((m=r?.redirect)==null?void 0:m.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=Nu(r,"topic")||"",n=decodeURIComponent(Nu(r,"wc_ev")||""),s=this.client.session.keys.includes(i);s&&this.client.session.update(i,{transportType:at.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:n,sessionExists:s})},this.registerLinkModeListeners=async()=>{var r;if(ac()||zn()&&(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}=ie("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Jt.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(ro)?this.client.auth.authKeys.get(ro):{responseTopic:void 0,publicKey:void 0},c=await this.client.core.crypto.decode(r,i,{receiverPublicKey:o,encoding:s===at.link_mode?Rs:Ki});try{Kc(c)?(this.client.core.history.set(r,c),this.onRelayEventRequest({topic:r,payload:c,attestation:n,transportType:s,encryptedId:yi(i)})):Za(c)?(await this.client.core.history.resolve(c),await this.onRelayEventResponse({topic:r,payload:c,transportType:s}),this.client.core.history.delete(r,c.id)):this.onRelayEventUnknownPayload({topic:r,payload:c,transportType:s})}catch(l){this.client.logger.error(l)}}registerExpirerEvents(){this.client.core.expirer.on(xr.expired,async e=>{const{topic:r,id:i}=Ru(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,ie("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,ie("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(es.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(es.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!yt(e,!1)){const{message:r}=ie("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}=ie("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(r)}if(zi(this.client.core.pairing.pairings.get(e).expiry)){const{message:r}=ie("EXPIRED",`pairing topic: ${e}`);throw new Error(r)}}async isValidSessionTopic(e){if(!yt(e,!1)){const{message:r}=ie("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}=ie("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(r)}if(zi(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:r}=ie("EXPIRED",`session topic: ${e}`);throw new Error(r)}if(!this.client.core.crypto.keychain.has(e)){const{message:r}=ie("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(yt(e,!1)){const{message:r}=ie("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(r)}else{const{message:r}=ie("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(r)}}async isValidProposalId(e){if(!G5(e)){const{message:r}=ie("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(r)}if(!this.client.proposal.keys.includes(e)){const{message:r}=ie("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(r)}if(zi(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:r}=ie("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}}class o9 extends vn{constructor(e,r){super(e,r,K7,ef),this.core=e,this.logger=r}}class hl extends vn{constructor(e,r){super(e,r,V7,ef),this.core=e,this.logger=r}}class c9 extends vn{constructor(e,r){super(e,r,W7,ef,i=>i.id),this.core=e,this.logger=r}}class f9 extends vn{constructor(e,r){super(e,r,X7,to,()=>ro),this.core=e,this.logger=r}}class h9 extends vn{constructor(e,r){super(e,r,Z7,to),this.core=e,this.logger=r}}class u9 extends vn{constructor(e,r){super(e,r,e9,to,i=>i.id),this.core=e,this.logger=r}}class d9{constructor(e,r){this.core=e,this.logger=r,this.authKeys=new f9(this.core,this.logger),this.pairingTopics=new h9(this.core,this.logger),this.requests=new u9(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}class nf extends Dp{constructor(e){super(e),this.protocol=nl,this.version=sl,this.name=tf.name,this.events=new qt.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||tf.name,this.metadata=e?.metadata||Su(),this.signConfig=e?.signConfig;const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:hi(So({level:e?.logger||tf.logger}));this.core=e?.core||new Zc(e),this.logger=Ht(r,this.name),this.session=new hl(this.core,this.logger),this.proposal=new o9(this.core,this.logger),this.pendingRequest=new c9(this.core,this.logger),this.engine=new a9(this),this.auth=new d9(this.core,this.logger)}static async init(e){const r=new nf(e);return await r.initialize(),r}get context(){return Xt(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"),this.engine.processRelayMessageCache()}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}const l9=hl,p9=nf;class g9 extends qt.exports{constructor(){super()}}class ul{constructor(e){this.opts=e}}class dl{constructor(e){this.client=e}}var b9=Object.defineProperty,v9=Object.defineProperties,m9=Object.getOwnPropertyDescriptors,ll=Object.getOwnPropertySymbols,y9=Object.prototype.hasOwnProperty,w9=Object.prototype.propertyIsEnumerable,pl=(t,e,r)=>e in t?b9(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,_9=(t,e)=>{for(var r in e||(e={}))y9.call(e,r)&&pl(t,r,e[r]);if(ll)for(var r of ll(e))w9.call(e,r)&&pl(t,r,e[r]);return t},A9=(t,e)=>v9(t,m9(e));class E9 extends dl{constructor(e){super(e),this.init=async()=>{this.signClient=await p9.init({core:this.client.core,metadata:this.client.metadata,signConfig:this.client.signConfig})},this.pair=async r=>{await this.client.core.pairing.pair(r)},this.approveSession=async r=>{const{topic:i,acknowledged:n}=await this.signClient.approve(A9(_9({},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 x9={decryptMessage:async t=>{const e={core:new Zc({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 Zc({storageOptions:t.storageOptions,storage:t.storage}),sessionStore:null};e.sessionStore=new l9(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}},gl=class extends ul{constructor(t){super(t),this.events=new qt.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||fo,this.signConfig=t.signConfig,this.core=t.core,this.logger=this.core.logger,this.engine=new E9(this)}static async init(t){const e=new gl(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 sf=gl;sf.notifications=x9;const S9=sf;Bt.CLIENT_CONTEXT=fo,Bt.CLIENT_STORAGE_OPTIONS=Cl,Bt.CLIENT_STORAGE_PREFIX=Tl,Bt.IWalletKit=ul,Bt.IWalletKitEngine=dl,Bt.IWalletKitEvents=g9,Bt.PROTOCOL=vf,Bt.PROTOCOL_VERSION=Pl,Bt.REQUEST_CONTEXT=Fl,Bt.WalletKit=S9,Bt.default=sf,Object.defineProperty(Bt,"__esModule",{value:!0})});
|
43
|
+
***************************************************************************** */var Uc=function(t,e){return Uc=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])},Uc(t,e)};function _8(t,e){Uc(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var zc=function(){return zc=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},zc.apply(this,arguments)};function A8(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 E8(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 c=t.length-1;c>=0;c--)(o=t[c])&&(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 x8(t,e){return function(r,i){e(r,i,t)}}function S8(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function M8(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 c(b){try{u(i.next(b))}catch(m){o(m)}}function l(b){try{u(i.throw(b))}catch(m){o(m)}}function u(b){b.done?s(b.value):n(b.value).then(c,l)}u((i=i.apply(t,e||[])).next())})}function I8(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:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(u){return function(b){return l([u,b])}}function l(u){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,n&&(s=u[0]&2?n.return:u[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,u[1])).done)return s;switch(n=0,s&&(u=[u[0]&2,s.value]),u[0]){case 0:case 1:s=u;break;case 4:return r.label++,{value:u[1],done:!1};case 5:r.label++,n=u[1],u=[0];continue;case 7:u=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){r=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]<s[3])){r.label=u[1];break}if(u[0]===6&&r.label<s[1]){r.label=s[1],s=u;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(u);break}s[2]&&r.ops.pop(),r.trys.pop();continue}u=e.call(t,r)}catch(b){u=[6,b],n=0}finally{i=s=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function D8(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}function O8(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function kc(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 vd(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(c){o={error:c}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function R8(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(vd(arguments[e]));return t}function N8(){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,c=s.length;o<c;o++,n++)i[n]=s[o];return i}function Us(t){return this instanceof Us?(this.v=t,this):new Us(t)}function P8(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(S){return new Promise(function(I,F){s.push([M,S,I,F])>1||c(M,S)})})}function c(M,S){try{l(i[M](S))}catch(I){m(s[0][3],I)}}function l(M){M.value instanceof Us?Promise.resolve(M.value.v).then(u,b):m(s[0][2],M)}function u(M){c("next",M)}function b(M){c("throw",M)}function m(M,S){M(S),s.shift(),s.length&&c(s[0][0],s[0][1])}}function T8(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 C8(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 kc=="function"?kc(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(c,l){o=t[s](o),n(c,l,o.done,o.value)})}}function n(s,o,c,l){Promise.resolve(l).then(function(u){s({value:u,done:c})},o)}}function F8(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function L8(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 B8(t){return t&&t.__esModule?t:{default:t}}function q8(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function U8(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 z8=Object.freeze({__proto__:null,__extends:_8,get __assign(){return zc},__rest:A8,__decorate:E8,__param:x8,__metadata:S8,__awaiter:M8,__generator:I8,__createBinding:D8,__exportStar:O8,__values:kc,__read:vd,__spread:R8,__spreadArrays:N8,__await:Us,__asyncGenerator:P8,__asyncDelegator:T8,__asyncValues:C8,__makeTemplateObject:F8,__importStar:L8,__importDefault:B8,__classPrivateFieldGet:q8,__classPrivateFieldSet:U8}),k8=co(z8),wi={},md;function $8(){if(md)return wi;md=1,Object.defineProperty(wi,"__esModule",{value:!0}),wi.isBrowserCryptoAvailable=wi.getSubtleCrypto=wi.getBrowerCrypto=void 0;function t(){return Kt?.crypto||Kt?.msCrypto||{}}wi.getBrowerCrypto=t;function e(){const i=t();return i.subtle||i.webkitSubtle}wi.getSubtleCrypto=e;function r(){return!!t()&&!!e()}return wi.isBrowserCryptoAvailable=r,wi}var _i={},yd;function j8(){if(yd)return _i;yd=1,Object.defineProperty(_i,"__esModule",{value:!0}),_i.isBrowser=_i.isNode=_i.isReactNative=void 0;function t(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}_i.isReactNative=t;function e(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}_i.isNode=e;function r(){return!t()&&!e()}return _i.isBrowser=r,_i}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=k8;e.__exportStar($8(),t),e.__exportStar(j8(),t)})(bd);function Hi(t=3){const e=Date.now()*Math.pow(10,t),r=Math.floor(Math.random()*Math.pow(10,t));return e+r}function ln(t=6){return BigInt(Hi(t))}function pn(t,e,r){return{id:r||Hi(),jsonrpc:"2.0",method:t,params:e}}function $c(t,e){return{id:t,jsonrpc:"2.0",result:e}}function jc(t,e,r){return{id:t,jsonrpc:"2.0",error:K8(e,r)}}function K8(t,e){return typeof t>"u"?gd(ld):(typeof t=="string"&&(t=Object.assign(Object.assign({},gd(qc)),{message:t})),typeof e<"u"&&(t.data=e),m8(t.code)&&(t=y8(t.code)),t)}class H8{}class V8 extends H8{constructor(){super()}}class G8 extends V8{constructor(e){super()}}const W8="^wss?:";function Y8(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function J8(t,e){const r=Y8(t);return typeof r>"u"?!1:new RegExp(e).test(r)}function wd(t){return J8(t,W8)}function Q8(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function _d(t){return typeof t=="object"&&"id"in t&&"jsonrpc"in t&&t.jsonrpc==="2.0"}function Kc(t){return _d(t)&&"method"in t}function Za(t){return _d(t)&&(si(t)||Ar(t))}function si(t){return"result"in t}function Ar(t){return"error"in t}class X8 extends G8{constructor(e){super(e),this.events=new qt.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(pn(e.method,e.params||[],e.id||ln().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),Za(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 Z8=()=>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"),e4=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",Ad=t=>t.split("?")[0],Ed=10,t4=Z8();class r4{constructor(e){if(this.url=e,this.events=new qt.exports.EventEmitter,this.registering=!1,!wd(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(Xi(e))}catch(r){this.onError(e.id,r)}}register(e=this.url){if(!wd(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=new URLSearchParams(e).get("origin"),s=bd.isReactNative()?{headers:{origin:n}}:{rejectUnauthorized:!Q8(e)},o=new t4(e,[],s);e4()?o.onerror=c=>{const l=c;i(this.emitError(l.error))}:o.on("error",c=>{i(this.emitError(c))}),o.onopen=()=>{this.onOpen(o),r(o)}})}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"?Sn(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const i=this.parseError(r),n=i.message||i.toString(),s=jc(e,n);this.events.emit("payload",s)}parseError(e,r=this.url){return w8(e,Ad(r),"WS")}resetMaxListeners(){this.events.getMaxListeners()>Ed&&this.events.setMaxListeners(Ed)}emitError(e){const r=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${Ad(this.url)}`));return this.events.emit("register_error",r),r}}var Hc={exports:{}};(function(t,e){var r=200,i="__lodash_hash_undefined__",n=1,s=2,o=9007199254740991,c="[object Arguments]",l="[object Array]",u="[object AsyncFunction]",b="[object Boolean]",m="[object Date]",M="[object Error]",S="[object Function]",I="[object GeneratorFunction]",F="[object Map]",k="[object Number]",j="[object Null]",C="[object Object]",$="[object Promise]",P="[object Proxy]",B="[object RegExp]",U="[object Set]",y="[object String]",O="[object Symbol]",Y="[object Undefined]",Q="[object WeakMap]",N="[object ArrayBuffer]",g="[object DataView]",a="[object Float32Array]",f="[object Float64Array]",p="[object Int8Array]",w="[object Int16Array]",A="[object Int32Array]",x="[object Uint8Array]",_="[object Uint8ClampedArray]",h="[object Uint16Array]",d="[object Uint32Array]",D=/[\\^$.*+?()[\]{}|]/g,K=/^\[object .+?Constructor\]$/,G=/^(?:0|[1-9]\d*)$/,E={};E[a]=E[f]=E[p]=E[w]=E[A]=E[x]=E[_]=E[h]=E[d]=!0,E[c]=E[l]=E[N]=E[b]=E[g]=E[m]=E[M]=E[S]=E[F]=E[k]=E[C]=E[B]=E[U]=E[y]=E[Q]=!1;var H=typeof Kt=="object"&&Kt&&Kt.Object===Object&&Kt,R=typeof self=="object"&&self&&self.Object===Object&&self,L=H||R||Function("return this")(),q=e&&!e.nodeType&&e,v=q&&!0&&t&&!t.nodeType&&t,T=v&&v.exports===q,W=T&&H.process,J=function(){try{return W&&W.binding&&W.binding("util")}catch{}}(),X=J&&J.isTypedArray;function se(z,V){for(var Z=-1,me=z==null?0:z.length,dt=0,Ge=[];++Z<me;){var vt=z[Z];V(vt,Z,z)&&(Ge[dt++]=vt)}return Ge}function ne(z,V){for(var Z=-1,me=V.length,dt=z.length;++Z<me;)z[dt+Z]=V[Z];return z}function Me(z,V){for(var Z=-1,me=z==null?0:z.length;++Z<me;)if(V(z[Z],Z,z))return!0;return!1}function Ce(z,V){for(var Z=-1,me=Array(z);++Z<z;)me[Z]=V(Z);return me}function ue(z){return function(V){return z(V)}}function xe(z,V){return z.has(V)}function Ae(z,V){return z?.[V]}function re(z){var V=-1,Z=Array(z.size);return z.forEach(function(me,dt){Z[++V]=[dt,me]}),Z}function ve(z,V){return function(Z){return z(V(Z))}}function le(z){var V=-1,Z=Array(z.size);return z.forEach(function(me){Z[++V]=me}),Z}var ee=Array.prototype,de=Function.prototype,fe=Object.prototype,te=L["__core-js_shared__"],Ee=de.toString,he=fe.hasOwnProperty,ae=function(){var z=/[^.]+$/.exec(te&&te.keys&&te.keys.IE_PROTO||"");return z?"Symbol(src)_1."+z:""}(),Se=fe.toString,De=RegExp("^"+Ee.call(he).replace(D,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ce=T?L.Buffer:void 0,Ie=L.Symbol,We=L.Uint8Array,Oe=fe.propertyIsEnumerable,Qe=ee.splice,He=Ie?Ie.toStringTag:void 0,Re=Object.getOwnPropertySymbols,tt=ce?ce.isBuffer:void 0,rt=ve(Object.keys,Object),pe=is(L,"DataView"),Pe=is(L,"Map"),Fe=is(L,"Promise"),ge=is(L,"Set"),Le=is(L,"WeakMap"),Te=is(Object,"create"),ye=wn(pe),Ue=wn(Pe),ze=wn(Fe),we=wn(ge),ke=wn(Le),Be=Ie?Ie.prototype:void 0,be=Be?Be.valueOf:void 0;function Ne(z){var V=-1,Z=z==null?0:z.length;for(this.clear();++V<Z;){var me=z[V];this.set(me[0],me[1])}}function $e(){this.__data__=Te?Te(null):{},this.size=0}function _e(z){var V=this.has(z)&&delete this.__data__[z];return this.size-=V?1:0,V}function it(z){var V=this.__data__;if(Te){var Z=V[z];return Z===i?void 0:Z}return he.call(V,z)?V[z]:void 0}function nt(z){var V=this.__data__;return Te?V[z]!==void 0:he.call(V,z)}function qe(z,V){var Z=this.__data__;return this.size+=this.has(z)?0:1,Z[z]=Te&&V===void 0?i:V,this}Ne.prototype.clear=$e,Ne.prototype.delete=_e,Ne.prototype.get=it,Ne.prototype.has=nt,Ne.prototype.set=qe;function Ye(z){var V=-1,Z=z==null?0:z.length;for(this.clear();++V<Z;){var me=z[V];this.set(me[0],me[1])}}function nr(){this.__data__=[],this.size=0}function sr(z){var V=this.__data__,Z=io(V,z);if(Z<0)return!1;var me=V.length-1;return Z==me?V.pop():Qe.call(V,Z,1),--this.size,!0}function ar(z){var V=this.__data__,Z=io(V,z);return Z<0?void 0:V[Z][1]}function or(z){return io(this.__data__,z)>-1}function cr(z,V){var Z=this.__data__,me=io(Z,z);return me<0?(++this.size,Z.push([z,V])):Z[me][1]=V,this}Ye.prototype.clear=nr,Ye.prototype.delete=sr,Ye.prototype.get=ar,Ye.prototype.has=or,Ye.prototype.set=cr;function wt(z){var V=-1,Z=z==null?0:z.length;for(this.clear();++V<Z;){var me=z[V];this.set(me[0],me[1])}}function Ei(){this.size=0,this.__data__={hash:new Ne,map:new(Pe||Ye),string:new Ne}}function xi(z){var V=no(this,z).delete(z);return this.size-=V?1:0,V}function Si(z){return no(this,z).get(z)}function Mi(z){return no(this,z).has(z)}function Ii(z,V){var Z=no(this,z),me=Z.size;return Z.set(z,V),this.size+=Z.size==me?0:1,this}wt.prototype.clear=Ei,wt.prototype.delete=xi,wt.prototype.get=Si,wt.prototype.has=Mi,wt.prototype.set=Ii;function Sr(z){var V=-1,Z=z==null?0:z.length;for(this.__data__=new wt;++V<Z;)this.add(z[V])}function Di(z){return this.__data__.set(z,i),this}function Oi(z){return this.__data__.has(z)}Sr.prototype.add=Sr.prototype.push=Di,Sr.prototype.has=Oi;function $t(z){var V=this.__data__=new Ye(z);this.size=V.size}function Ri(){this.__data__=new Ye,this.size=0}function Ni(z){var V=this.__data__,Z=V.delete(z);return this.size=V.size,Z}function Pi(z){return this.__data__.get(z)}function Vs(z){return this.__data__.has(z)}function R9(z,V){var Z=this.__data__;if(Z instanceof Ye){var me=Z.__data__;if(!Pe||me.length<r-1)return me.push([z,V]),this.size=++Z.size,this;Z=this.__data__=new wt(me)}return Z.set(z,V),this.size=Z.size,this}$t.prototype.clear=Ri,$t.prototype.delete=Ni,$t.prototype.get=Pi,$t.prototype.has=Vs,$t.prototype.set=R9;function N9(z,V){var Z=so(z),me=!Z&&V9(z),dt=!Z&&!me&&af(z),Ge=!Z&&!me&&!dt&&Ml(z),vt=Z||me||dt||Ge,Rt=vt?Ce(z.length,String):[],Lt=Rt.length;for(var lt in z)(V||he.call(z,lt))&&!(vt&&(lt=="length"||dt&&(lt=="offset"||lt=="parent")||Ge&&(lt=="buffer"||lt=="byteLength"||lt=="byteOffset")||k9(lt,Lt)))&&Rt.push(lt);return Rt}function io(z,V){for(var Z=z.length;Z--;)if(Al(z[Z][0],V))return Z;return-1}function P9(z,V,Z){var me=V(z);return so(z)?me:ne(me,Z(z))}function Gs(z){return z==null?z===void 0?Y:j:He&&He in Object(z)?U9(z):H9(z)}function ml(z){return Ws(z)&&Gs(z)==c}function yl(z,V,Z,me,dt){return z===V?!0:z==null||V==null||!Ws(z)&&!Ws(V)?z!==z&&V!==V:T9(z,V,Z,me,yl,dt)}function T9(z,V,Z,me,dt,Ge){var vt=so(z),Rt=so(V),Lt=vt?l:Vi(z),lt=Rt?l:Vi(V);Lt=Lt==c?C:Lt,lt=lt==c?C:lt;var pr=Lt==C,Br=lt==C,jt=Lt==lt;if(jt&&af(z)){if(!af(V))return!1;vt=!0,pr=!1}if(jt&&!pr)return Ge||(Ge=new $t),vt||Ml(z)?wl(z,V,Z,me,dt,Ge):B9(z,V,Lt,Z,me,dt,Ge);if(!(Z&n)){var Mr=pr&&he.call(z,"__wrapped__"),Ir=Br&&he.call(V,"__wrapped__");if(Mr||Ir){var Gi=Mr?z.value():z,Ti=Ir?V.value():V;return Ge||(Ge=new $t),dt(Gi,Ti,Z,me,Ge)}}return jt?(Ge||(Ge=new $t),q9(z,V,Z,me,dt,Ge)):!1}function C9(z){if(!Sl(z)||j9(z))return!1;var V=El(z)?De:K;return V.test(wn(z))}function F9(z){return Ws(z)&&xl(z.length)&&!!E[Gs(z)]}function L9(z){if(!K9(z))return rt(z);var V=[];for(var Z in Object(z))he.call(z,Z)&&Z!="constructor"&&V.push(Z);return V}function wl(z,V,Z,me,dt,Ge){var vt=Z&n,Rt=z.length,Lt=V.length;if(Rt!=Lt&&!(vt&&Lt>Rt))return!1;var lt=Ge.get(z);if(lt&&Ge.get(V))return lt==V;var pr=-1,Br=!0,jt=Z&s?new Sr:void 0;for(Ge.set(z,V),Ge.set(V,z);++pr<Rt;){var Mr=z[pr],Ir=V[pr];if(me)var Gi=vt?me(Ir,Mr,pr,V,z,Ge):me(Mr,Ir,pr,z,V,Ge);if(Gi!==void 0){if(Gi)continue;Br=!1;break}if(jt){if(!Me(V,function(Ti,_n){if(!xe(jt,_n)&&(Mr===Ti||dt(Mr,Ti,Z,me,Ge)))return jt.push(_n)})){Br=!1;break}}else if(!(Mr===Ir||dt(Mr,Ir,Z,me,Ge))){Br=!1;break}}return Ge.delete(z),Ge.delete(V),Br}function B9(z,V,Z,me,dt,Ge,vt){switch(Z){case g:if(z.byteLength!=V.byteLength||z.byteOffset!=V.byteOffset)return!1;z=z.buffer,V=V.buffer;case N:return!(z.byteLength!=V.byteLength||!Ge(new We(z),new We(V)));case b:case m:case k:return Al(+z,+V);case M:return z.name==V.name&&z.message==V.message;case B:case y:return z==V+"";case F:var Rt=re;case U:var Lt=me&n;if(Rt||(Rt=le),z.size!=V.size&&!Lt)return!1;var lt=vt.get(z);if(lt)return lt==V;me|=s,vt.set(z,V);var pr=wl(Rt(z),Rt(V),me,dt,Ge,vt);return vt.delete(z),pr;case O:if(be)return be.call(z)==be.call(V)}return!1}function q9(z,V,Z,me,dt,Ge){var vt=Z&n,Rt=_l(z),Lt=Rt.length,lt=_l(V),pr=lt.length;if(Lt!=pr&&!vt)return!1;for(var Br=Lt;Br--;){var jt=Rt[Br];if(!(vt?jt in V:he.call(V,jt)))return!1}var Mr=Ge.get(z);if(Mr&&Ge.get(V))return Mr==V;var Ir=!0;Ge.set(z,V),Ge.set(V,z);for(var Gi=vt;++Br<Lt;){jt=Rt[Br];var Ti=z[jt],_n=V[jt];if(me)var Il=vt?me(_n,Ti,jt,V,z,Ge):me(Ti,_n,jt,z,V,Ge);if(!(Il===void 0?Ti===_n||dt(Ti,_n,Z,me,Ge):Il)){Ir=!1;break}Gi||(Gi=jt=="constructor")}if(Ir&&!Gi){var ao=z.constructor,oo=V.constructor;ao!=oo&&"constructor"in z&&"constructor"in V&&!(typeof ao=="function"&&ao instanceof ao&&typeof oo=="function"&&oo instanceof oo)&&(Ir=!1)}return Ge.delete(z),Ge.delete(V),Ir}function _l(z){return P9(z,Y9,z9)}function no(z,V){var Z=z.__data__;return $9(V)?Z[typeof V=="string"?"string":"hash"]:Z.map}function is(z,V){var Z=Ae(z,V);return C9(Z)?Z:void 0}function U9(z){var V=he.call(z,He),Z=z[He];try{z[He]=void 0;var me=!0}catch{}var dt=Se.call(z);return me&&(V?z[He]=Z:delete z[He]),dt}var z9=Re?function(z){return z==null?[]:(z=Object(z),se(Re(z),function(V){return Oe.call(z,V)}))}:J9,Vi=Gs;(pe&&Vi(new pe(new ArrayBuffer(1)))!=g||Pe&&Vi(new Pe)!=F||Fe&&Vi(Fe.resolve())!=$||ge&&Vi(new ge)!=U||Le&&Vi(new Le)!=Q)&&(Vi=function(z){var V=Gs(z),Z=V==C?z.constructor:void 0,me=Z?wn(Z):"";if(me)switch(me){case ye:return g;case Ue:return F;case ze:return $;case we:return U;case ke:return Q}return V});function k9(z,V){return V=V??o,!!V&&(typeof z=="number"||G.test(z))&&z>-1&&z%1==0&&z<V}function $9(z){var V=typeof z;return V=="string"||V=="number"||V=="symbol"||V=="boolean"?z!=="__proto__":z===null}function j9(z){return!!ae&&ae in z}function K9(z){var V=z&&z.constructor,Z=typeof V=="function"&&V.prototype||fe;return z===Z}function H9(z){return Se.call(z)}function wn(z){if(z!=null){try{return Ee.call(z)}catch{}try{return z+""}catch{}}return""}function Al(z,V){return z===V||z!==z&&V!==V}var V9=ml(function(){return arguments}())?ml:function(z){return Ws(z)&&he.call(z,"callee")&&!Oe.call(z,"callee")},so=Array.isArray;function G9(z){return z!=null&&xl(z.length)&&!El(z)}var af=tt||Q9;function W9(z,V){return yl(z,V)}function El(z){if(!Sl(z))return!1;var V=Gs(z);return V==S||V==I||V==u||V==P}function xl(z){return typeof z=="number"&&z>-1&&z%1==0&&z<=o}function Sl(z){var V=typeof z;return z!=null&&(V=="object"||V=="function")}function Ws(z){return z!=null&&typeof z=="object"}var Ml=X?ue(X):F9;function Y9(z){return G9(z)?N9(z):L9(z)}function J9(){return[]}function Q9(){return!1}t.exports=W9})(Hc,Hc.exports);var i4=Hc.exports;const xd="wc",Sd=2,Vc="core",ai=`${xd}@2:${Vc}:`,n4={name:Vc,logger:"error"},s4={database:":memory:"},a4="crypto",Md="client_ed25519_seed",o4=oe.ONE_DAY,c4="keychain",f4="0.3",h4="messages",u4="0.3",d4=oe.SIX_HOURS,l4="publisher",Id="irn",p4="error",Dd="wss://relay.walletconnect.org",g4="relayer",Jt={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"},b4="_subscription",Er={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},v4=.1,Gc="2.17.0",at={link_mode:"link_mode",relay:"relay"},m4="0.3",y4="WALLETCONNECT_CLIENT_ID",Od="WALLETCONNECT_LINK_MODE_APPS",oi={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},w4="subscription",_4="0.3",A4=oe.FIVE_SECONDS*1e3,E4="pairing",x4="0.3",zs={wc_pairingDelete:{req:{ttl:oe.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:oe.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:oe.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:oe.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:oe.ONE_DAY,prompt:!1,tag:0},res:{ttl:oe.ONE_DAY,prompt:!1,tag:0}}},gn={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Cr={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},S4="history",M4="0.3",I4="expirer",xr={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},D4="0.3",O4="verify-api",R4="https://verify.walletconnect.com",Rd="https://verify.walletconnect.org",ks=Rd,N4=`${ks}/v3`,P4=[R4,Rd],T4="echo",C4="https://echo.walletconnect.com",ci={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"},Fr={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"},bn={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"},vn={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"},$s={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"},F4=.1,L4="event-client",B4=86400,q4="https://pulse.walletconnect.org/batch";function U4(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 c=t.length,l=t.charAt(0),u=Math.log(c)/Math.log(256),b=Math.log(256)/Math.log(c);function m(I){if(I instanceof Uint8Array||(ArrayBuffer.isView(I)?I=new Uint8Array(I.buffer,I.byteOffset,I.byteLength):Array.isArray(I)&&(I=Uint8Array.from(I))),!(I instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(I.length===0)return"";for(var F=0,k=0,j=0,C=I.length;j!==C&&I[j]===0;)j++,F++;for(var $=(C-j)*b+1>>>0,P=new Uint8Array($);j!==C;){for(var B=I[j],U=0,y=$-1;(B!==0||U<k)&&y!==-1;y--,U++)B+=256*P[y]>>>0,P[y]=B%c>>>0,B=B/c>>>0;if(B!==0)throw new Error("Non-zero carry");k=U,j++}for(var O=$-k;O!==$&&P[O]===0;)O++;for(var Y=l.repeat(F);O<$;++O)Y+=t.charAt(P[O]);return Y}function M(I){if(typeof I!="string")throw new TypeError("Expected String");if(I.length===0)return new Uint8Array;var F=0;if(I[F]!==" "){for(var k=0,j=0;I[F]===l;)k++,F++;for(var C=(I.length-F)*u+1>>>0,$=new Uint8Array(C);I[F];){var P=r[I.charCodeAt(F)];if(P===255)return;for(var B=0,U=C-1;(P!==0||B<j)&&U!==-1;U--,B++)P+=c*$[U]>>>0,$[U]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");j=B,F++}if(I[F]!==" "){for(var y=C-j;y!==C&&$[y]===0;)y++;for(var O=new Uint8Array(k+(C-y)),Y=k;y!==C;)O[Y++]=$[y++];return O}}}function S(I){var F=M(I);if(F)return F;throw new Error(`Non-${e} character`)}return{encode:m,decodeUnsafe:M,decode:S}}var z4=U4,k4=z4;const Nd=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")},$4=t=>new TextEncoder().encode(t),j4=t=>new TextDecoder().decode(t);class K4{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 H4{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 Pd(this,e)}}class V4{constructor(e){this.decoders=e}or(e){return Pd(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 Pd=(t,e)=>new V4({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class G4{constructor(e,r,i,n){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=n,this.encoder=new K4(e,r,i),this.decoder=new H4(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const eo=({name:t,prefix:e,encode:r,decode:i})=>new G4(t,e,r,i),js=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:n}=k4(r,e);return eo({prefix:t,name:e,encode:i,decode:s=>Nd(n(s))})},W4=(t,e,r,i)=>{const n={};for(let b=0;b<e.length;++b)n[e[b]]=b;let s=t.length;for(;t[s-1]==="=";)--s;const o=new Uint8Array(s*r/8|0);let c=0,l=0,u=0;for(let b=0;b<s;++b){const m=n[t[b]];if(m===void 0)throw new SyntaxError(`Non-${i} character`);l=l<<r|m,c+=r,c>=8&&(c-=8,o[u++]=255&l>>c)}if(c>=r||255&l<<8-c)throw new SyntaxError("Unexpected end of data");return o},Y4=(t,e,r)=>{const i=e[e.length-1]==="=",n=(1<<r)-1;let s="",o=0,c=0;for(let l=0;l<t.length;++l)for(c=c<<8|t[l],o+=8;o>r;)o-=r,s+=e[n&c>>o];if(o&&(s+=e[n&c<<r-o]),i)for(;s.length*r&7;)s+="=";return s},Ft=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>eo({prefix:e,name:t,encode(n){return Y4(n,i,r)},decode(n){return W4(n,i,r,t)}}),J4=eo({prefix:"\0",name:"identity",encode:t=>j4(t),decode:t=>$4(t)});var Q4=Object.freeze({__proto__:null,identity:J4});const X4=Ft({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Z4=Object.freeze({__proto__:null,base2:X4});const ew=Ft({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var tw=Object.freeze({__proto__:null,base8:ew});const rw=js({prefix:"9",name:"base10",alphabet:"0123456789"});var iw=Object.freeze({__proto__:null,base10:rw});const nw=Ft({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),sw=Ft({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var aw=Object.freeze({__proto__:null,base16:nw,base16upper:sw});const ow=Ft({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),cw=Ft({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),fw=Ft({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),hw=Ft({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),uw=Ft({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),dw=Ft({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),lw=Ft({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),pw=Ft({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),gw=Ft({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var bw=Object.freeze({__proto__:null,base32:ow,base32upper:cw,base32pad:fw,base32padupper:hw,base32hex:uw,base32hexupper:dw,base32hexpad:lw,base32hexpadupper:pw,base32z:gw});const vw=js({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),mw=js({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var yw=Object.freeze({__proto__:null,base36:vw,base36upper:mw});const ww=js({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),_w=js({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Aw=Object.freeze({__proto__:null,base58btc:ww,base58flickr:_w});const Ew=Ft({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),xw=Ft({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Sw=Ft({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Mw=Ft({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Iw=Object.freeze({__proto__:null,base64:Ew,base64pad:xw,base64url:Sw,base64urlpad:Mw});const Td=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}"),Dw=Td.reduce((t,e,r)=>(t[r]=e,t),[]),Ow=Td.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function Rw(t){return t.reduce((e,r)=>(e+=Dw[r],e),"")}function Nw(t){const e=[];for(const r of t){const i=Ow[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const Pw=eo({prefix:"\u{1F680}",name:"base256emoji",encode:Rw,decode:Nw});var Tw=Object.freeze({__proto__:null,base256emoji:Pw}),Cw=Fd,Cd=128,Fw=127,Lw=~Fw,Bw=Math.pow(2,31);function Fd(t,e,r){e=e||[],r=r||0;for(var i=r;t>=Bw;)e[r++]=t&255|Cd,t/=128;for(;t&Lw;)e[r++]=t&255|Cd,t>>>=7;return e[r]=t|0,Fd.bytes=r-i+1,e}var qw=Wc,Uw=128,Ld=127;function Wc(t,i){var r=0,i=i||0,n=0,s=i,o,c=t.length;do{if(s>=c)throw Wc.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=n<28?(o&Ld)<<n:(o&Ld)*Math.pow(2,n),n+=7}while(o>=Uw);return Wc.bytes=s-i,r}var zw=Math.pow(2,7),kw=Math.pow(2,14),$w=Math.pow(2,21),jw=Math.pow(2,28),Kw=Math.pow(2,35),Hw=Math.pow(2,42),Vw=Math.pow(2,49),Gw=Math.pow(2,56),Ww=Math.pow(2,63),Yw=function(t){return t<zw?1:t<kw?2:t<$w?3:t<jw?4:t<Kw?5:t<Hw?6:t<Vw?7:t<Gw?8:t<Ww?9:10},Jw={encode:Cw,decode:qw,encodingLength:Yw},Bd=Jw;const qd=(t,e,r=0)=>(Bd.encode(t,e,r),e),Ud=t=>Bd.encodingLength(t),Yc=(t,e)=>{const r=e.byteLength,i=Ud(t),n=i+Ud(r),s=new Uint8Array(n+r);return qd(t,s,0),qd(r,s,i),s.set(e,n),new Qw(t,r,e,s)};class Qw{constructor(e,r,i,n){this.code=e,this.size=r,this.digest=i,this.bytes=n}}const zd=({name:t,code:e,encode:r})=>new Xw(t,e,r);class Xw{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?Yc(this.code,r):r.then(i=>Yc(this.code,i))}else throw Error("Unknown type, must be binary type")}}const kd=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Zw=zd({name:"sha2-256",code:18,encode:kd("SHA-256")}),e7=zd({name:"sha2-512",code:19,encode:kd("SHA-512")});var t7=Object.freeze({__proto__:null,sha256:Zw,sha512:e7});const $d=0,r7="identity",jd=Nd;var i7=Object.freeze({__proto__:null,identity:{code:$d,name:r7,encode:jd,digest:t=>Yc($d,jd(t))}});new TextEncoder,new TextDecoder;const Kd={...Q4,...Z4,...tw,...iw,...aw,...bw,...yw,...Aw,...Iw,...Tw};({...t7,...i7});function n7(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function Hd(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const Vd=Hd("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Jc=Hd("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=n7(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),s7={utf8:Vd,"utf-8":Vd,hex:Kd.base16,latin1:Jc,ascii:Jc,binary:Jc,...Kd};function a7(t,e="utf8"){const r=s7[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 o7{constructor(e,r){this.core=e,this.logger=r,this.keychain=new Map,this.name=c4,this.version=f4,this.initialized=!1,this.storagePrefix=ai,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}=ie("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=Ht(r,this.name)}get context(){return Xt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,Iu(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Du(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=ie("NOT_INITIALIZED",this.name);throw new Error(e)}}}class c7{constructor(e,r,i){this.core=e,this.logger=r,this.name=a4,this.randomSessionIdentifier=Tc(),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=wh(n);return yh(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const n=u5();return this.setPrivateKey(n.publicKey,n.privateKey)},this.signJWT=async n=>{this.isInitialized();const s=await this.getClientSeed(),o=wh(s),c=this.randomSessionIdentifier;return await Ub(c,n,o4,o)},this.generateSharedKey=(n,s,o)=>{this.isInitialized();const c=this.getPrivateKey(n),l=d5(c,s);return this.setSymKey(l,o)},this.setSymKey=async(n,s)=>{this.isInitialized();const o=s||Ya(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 c=Q0(o),l=Xi(s);if(Z0(c))return p5(l,o?.encoding);if(X0(c)){const M=c.senderPublicKey,S=c.receiverPublicKey;n=await this.generateSharedKey(M,S)}const u=this.getSymKey(n),{type:b,senderPublicKey:m}=c;return l5({type:b,symKey:u,message:l,senderPublicKey:m,encoding:o?.encoding})},this.decode=async(n,s,o)=>{this.isInitialized();const c=v5(s,o);if(Z0(c)){const l=b5(s,o?.encoding);return Sn(l)}if(X0(c)){const l=c.receiverPublicKey,u=c.senderPublicKey;n=await this.generateSharedKey(l,u)}try{const l=this.getSymKey(n),u=g5({symKey:l,encoded:s,encoding:o?.encoding});return Sn(u)}catch(l){this.logger.error(`Failed to decode message from topic: '${n}', clientId: '${await this.getClientId()}'`),this.logger.error(l)}},this.getPayloadType=(n,s=Ki)=>{const o=Cs({encoded:n,encoding:s});return dn(o.type)},this.getPayloadSenderPublicKey=(n,s=Ki)=>{const o=Cs({encoded:n,encoding:s});return o.senderPublicKey?Et(o.senderPublicKey,Wt):void 0},this.core=e,this.logger=Ht(r,this.name),this.keychain=i||new o7(this.core,this.logger)}get context(){return Xt(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(Md)}catch{e=Tc(),await this.keychain.set(Md,e)}return a7(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=ie("NOT_INITIALIZED",this.name);throw new Error(e)}}}class f7 extends _p{constructor(e,r){super(e,r),this.logger=e,this.core=r,this.messages=new Map,this.name=h4,this.version=u4,this.initialized=!1,this.storagePrefix=ai,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=yi(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=yi(n);return typeof s[o]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()},this.logger=Ht(e,this.name),this.core=r}get context(){return Xt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,Iu(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Du(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=ie("NOT_INITIALIZED",this.name);throw new Error(e)}}}class h7 extends Ap{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.events=new qt.exports.EventEmitter,this.name=l4,this.queue=new Map,this.publishTimeout=oe.toMiliseconds(oe.ONE_MINUTE),this.failedPublishTimeout=oe.toMiliseconds(oe.ONE_SECOND),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 c=s?.ttl||d4,l=Cc(s),u=s?.prompt||!1,b=s?.tag||0,m=s?.id||ln().toString(),M={topic:i,message:n,opts:{ttl:c,relay:l,prompt:u,tag:b,id:m,attestation:s?.attestation}},S=`Failed to publish payload, please try again. id:${m} tag:${b}`,I=Date.now();let F,k=1;try{for(;F===void 0;){if(Date.now()-I>this.publishTimeout)throw new Error(S);this.logger.trace({id:m,attempts:k},`publisher.publish - attempt ${k}`),F=await await $n(this.rpcPublish(i,n,c,l,u,b,m,s?.attestation).catch(j=>this.logger.warn(j)),this.publishTimeout,S),k++,F||await new Promise(j=>setTimeout(j,this.failedPublishTimeout))}this.relayer.events.emit(Jt.publish,M),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{id:m,topic:i,message:n,opts:s}})}catch(j){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(j),(o=s?.internal)!=null&&o.throwOnFailedPublish)throw j;this.queue.set(m,M)}},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=Ht(r,this.name),this.registerEventListeners()}get context(){return Xt(this.logger)}rpcPublish(e,r,i,n,s,o,c,l){var u,b,m,M;const S={method:Fs(n.protocol).publish,params:{topic:e,message:r,ttl:i,prompt:s,tag:o,attestation:l},id:c};return Yt((u=S.params)==null?void 0:u.prompt)&&((b=S.params)==null||delete b.prompt),Yt((m=S.params)==null?void 0:m.tag)&&((M=S.params)==null||delete M.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:S}),this.relayer.request(S)}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{const{topic:r,message:i,opts:n}=e;await this.publish(r,i,n)})}registerEventListeners(){this.relayer.core.heartbeat.on(xn.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Jt.connection_stalled);return}this.checkQueue()}),this.relayer.on(Jt.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}class u7{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 d7=Object.defineProperty,l7=Object.defineProperties,p7=Object.getOwnPropertyDescriptors,Gd=Object.getOwnPropertySymbols,g7=Object.prototype.hasOwnProperty,b7=Object.prototype.propertyIsEnumerable,Wd=(t,e,r)=>e in t?d7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ks=(t,e)=>{for(var r in e||(e={}))g7.call(e,r)&&Wd(t,r,e[r]);if(Gd)for(var r of Gd(e))b7.call(e,r)&&Wd(t,r,e[r]);return t},Qc=(t,e)=>l7(t,p7(e));class v7 extends Sp{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.subscriptions=new Map,this.topicMap=new u7,this.events=new qt.exports.EventEmitter,this.name=w4,this.version=_4,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=ai,this.subscribeTimeout=oe.toMiliseconds(oe.ONE_MINUTE),this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.pendingBatchMessages=[],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=Cc(n),o={topic:i,relay:s,transportType:n?.transportType};this.pending.set(i,o);const c=await this.rpcSubscribe(i,s,n?.transportType);return typeof c=="string"&&(this.onSubscribe(c,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}})),c}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 c=new oe.Watch;c.start(n);const l=setInterval(()=>{!this.pending.has(i)&&this.topics.includes(i)&&(clearInterval(l),c.stop(n),s(!0)),c.elapsed(n)>=A4&&(clearInterval(l),c.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()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=e,this.logger=Ht(r,this.name),this.clientId=""}get context(){return Xt(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}onEnable(){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=Cc(i);await this.rpcUnsubscribe(e,r,n);const s=ht("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=at.relay){i===at.relay&&await this.restartToComplete();const n={method:Fs(r.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});try{const s=yi(e+this.clientId);return i===at.link_mode?(setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(n).catch(o=>this.logger.warn(o))},oe.toMiliseconds(oe.ONE_SECOND)),s):await await $n(this.relayer.request(n).catch(o=>this.logger.warn(o)),this.subscribeTimeout)?s:null}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Jt.connection_stalled)}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{return await await $n(this.relayer.request(i).catch(n=>this.logger.warn(n)),this.subscribeTimeout)}catch{this.relayer.events.emit(Jt.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 $n(this.relayer.request(i).catch(s=>this.logger.warn(s)),this.subscribeTimeout)}catch{this.relayer.events.emit(Jt.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,Qc(Ks({},r),{id:e})),this.pending.delete(r.topic)}onBatchSubscribe(e){e.length&&e.forEach(r=>{this.setSubscription(r.id,Ks({},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,Ks({},r)),this.topicMap.set(r.topic,e),this.events.emit(oi.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}=ie("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(oi.deleted,Qc(Ks({},i),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(oi.sync)}async reset(){if(this.cached.length){const e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let r=0;r<e;r++){const i=this.cached.splice(0,this.batchSubscribeTopicsLimit);await this.batchFetchMessages(i),await this.batchSubscribe(i)}}this.events.emit(oi.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:r}=ie("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){if(!e.length)return;const r=await this.rpcBatchSubscribe(e);Ls(r)&&this.onBatchSubscribe(r.map((i,n)=>Qc(Ks({},e[n]),{id:i})))}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&&(this.pendingBatchMessages=this.pendingBatchMessages.concat(r.messages))}async onConnect(){await this.restart(),this.onEnable()}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||!this.relayer.connected)return;const e=[];this.pending.forEach(r=>{e.push(r)}),await this.batchSubscribe(e),this.pendingBatchMessages.length&&(await this.relayer.handleBatchMessageEvents(this.pendingBatchMessages),this.pendingBatchMessages=[])}registerEventListeners(){this.relayer.core.heartbeat.on(xn.pulse,async()=>{await this.checkPending()}),this.events.on(oi.created,async e=>{const r=oi.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()}),this.events.on(oi.deleted,async e=>{const r=oi.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=ie("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){!this.relayer.connected&&!this.relayer.connecting&&await this.relayer.transportOpen(),this.restartInProgress&&await new Promise(e=>{const r=setInterval(()=>{this.restartInProgress||(clearInterval(r),e())},this.pollingInterval)})}}var m7=Object.defineProperty,Yd=Object.getOwnPropertySymbols,y7=Object.prototype.hasOwnProperty,w7=Object.prototype.propertyIsEnumerable,Jd=(t,e,r)=>e in t?m7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,_7=(t,e)=>{for(var r in e||(e={}))y7.call(e,r)&&Jd(t,r,e[r]);if(Yd)for(var r of Yd(e))w7.call(e,r)&&Jd(t,r,e[r]);return t};class A7 extends Ep{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new qt.exports.EventEmitter,this.name=g4,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","stalled","interrupted"],this.hasExperiencedNetworkDisruption=!1,this.requestsInFlight=new Map,this.heartBeatTimeout=oe.toMiliseconds(oe.THIRTY_SECONDS+oe.ONE_SECOND),this.request=async r=>{var i,n;this.logger.debug("Publishing Request Payload");const s=r.id||ln().toString();await this.toEstablishConnection();try{const o=this.provider.request(r);this.requestsInFlight.set(s,{promise:o,request:r}),this.logger.trace({id:s,method:r.method,topic:(i=r.params)==null?void 0:i.topic},"relayer.request - attempt to publish...");const c=await new Promise(async(l,u)=>{const b=()=>{u(new Error(`relayer.request - publish interrupted, id: ${s}`))};this.provider.on(Er.disconnect,b);const m=await o;this.provider.off(Er.disconnect,b),l(m)});return this.logger.trace({id:s,method:r.method,topic:(n=r.params)==null?void 0:n.topic},"relayer.request - published"),c}catch(o){throw this.logger.debug(`Failed to Publish Request: ${s}`),o}finally{this.requestsInFlight.delete(s)}},this.resetPingTimeout=()=>{if(Ta())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var r,i,n;(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)}},this.onPayloadHandler=r=>{this.onProviderPayload(r),this.resetPingTimeout()},this.onConnectHandler=()=>{this.logger.trace("relayer connected"),this.startPingTimeout(),this.events.emit(Jt.connect)},this.onDisconnectHandler=()=>{this.logger.trace("relayer disconnected"),this.onProviderDisconnect()},this.onProviderErrorHandler=r=>{this.logger.error(r),this.events.emit(Jt.error,r),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(Er.payload,this.onPayloadHandler),this.provider.on(Er.connect,this.onConnectHandler),this.provider.on(Er.disconnect,this.onDisconnectHandler),this.provider.on(Er.error,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?Ht(e.logger,this.name):hi(So({level:e.logger||p4})),this.messages=new f7(this.logger,e.core),this.subscriber=new v7(this,this.logger),this.publisher=new h7(this,this.logger),this.relayUrl=e?.relayUrl||Dd,this.projectId=e.projectId,this.bundleId=Xv(),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)}}get context(){return Xt(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:at.relay})}async subscribe(e,r){var i;this.isInitialized(),r?.transportType==="relay"&&await this.toEstablishConnection();let n=((i=this.subscriber.topicMap.get(e))==null?void 0:i[0])||"",s;const o=c=>{c.topic===e&&(this.subscriber.off(oi.created,o),s())};return await Promise.all([new Promise(c=>{s=c,this.subscriber.on(oi.created,o)}),new Promise(async c=>{n=await this.subscriber.subscribe(e,r)||n,c()})]),n}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(){if(!this.hasExperiencedNetworkDisruption&&this.connected&&this.requestsInFlight.size>0)try{await Promise.all(Array.from(this.requestsInFlight.values()).map(e=>e.promise))}catch(e){this.logger.warn(e)}this.hasExperiencedNetworkDisruption||this.connected?await $n(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),await this.createProvider(),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;try{await new Promise(async(r,i)=>{const n=()=>{this.provider.off(Er.disconnect,n),i(new Error("Connection interrupted while trying to subscribe"))};this.provider.on(Er.disconnect,n),await $n(this.provider.connect(),oe.toMiliseconds(oe.ONE_MINUTE),`Socket stalled when trying to connect to ${this.relayUrl}`).catch(s=>{i(s)}).finally(()=>{clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0}),this.subscriber.start().catch(s=>{this.logger.error(s),this.onDisconnectHandler()}),this.hasExperiencedNetworkDisruption=!1,r()})}catch(r){this.logger.error(r);const i=r;if(this.hasExperiencedNetworkDisruption=!0,!this.isConnectionStalled(i.message))throw r}finally{this.connectionAttemptInProgress=!1}}async restartTransport(e){this.connectionAttemptInProgress||(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await dd())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.trace(`Batch of ${r.length} message events sorted`);for(const i of r)try{await this.onMessageEvent(i)}catch(n){this.logger.warn(n)}this.logger.trace(`Batch of ${r.length} message events processed`)}async onLinkMessageEvent(e,r){const{topic:i}=e;if(!r.sessionExists){const n=_t(oe.FIVE_MINUTES),s={topic:i,expiry:n,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,s)}this.events.emit(Jt.message,e),await this.recordMessageEvent(e)}startPingTimeout(){var e,r,i,n,s;if(Ta())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.once("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o)}}isConnectionStalled(e){return this.staleConnectionErrors.some(r=>e.includes(r))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new X8(new r4(r6({sdkVersion:Gc,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId}))),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.debug(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(r))return this.logger.debug(`Ignoring message for non-subscribed topic ${r}`),!0;const n=this.messages.has(r,i);return n&&this.logger.debug(`Ignoring duplicate message: ${i}`),n}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Kc(e)){if(!e.method.endsWith(b4))return;const r=e.params,{topic:i,message:n,publishedAt:s,attestation:o}=r.data,c={topic:i,message:n,publishedAt:s,transportType:at.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(_7({type:"event",event:r.id},c)),this.events.emit(r.id,c),await this.acknowledgePayload(e),await this.onMessageEvent(c)}else Za(e)&&this.events.emit(Jt.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Jt.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const r=$c(e.id,!0);await this.provider.connection.send(r)}unregisterProviderListeners(){this.provider.off(Er.payload,this.onPayloadHandler),this.provider.off(Er.connect,this.onConnectHandler),this.provider.off(Er.disconnect,this.onDisconnectHandler),this.provider.off(Er.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await dd();h8(async r=>{e!==r&&(e=r,r?await this.restartTransport().catch(i=>this.logger.error(i)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){await this.subscriber.stop(),this.requestsInFlight.clear(),clearTimeout(this.pingTimeout),this.events.emit(Jt.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e))},oe.toMiliseconds(v4))))}isInitialized(){if(!this.initialized){const{message:e}=ie("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&(this.connectionAttemptInProgress&&await new Promise(e=>{const r=setInterval(()=>{this.connected&&(clearInterval(r),e())},this.connectionStatusPollingInterval)}),await this.transportOpen())}}var E7=Object.defineProperty,Qd=Object.getOwnPropertySymbols,x7=Object.prototype.hasOwnProperty,S7=Object.prototype.propertyIsEnumerable,Xd=(t,e,r)=>e in t?E7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Zd=(t,e)=>{for(var r in e||(e={}))x7.call(e,r)&&Xd(t,r,e[r]);if(Qd)for(var r of Qd(e))S7.call(e,r)&&Xd(t,r,e[r]);return t};class mn extends xp{constructor(e,r,i,n=ai,s=void 0){super(e,r,i,n),this.core=e,this.logger=r,this.name=i,this.map=new Map,this.version=m4,this.cached=[],this.initialized=!1,this.storagePrefix=ai,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&&!Yt(o)?this.map.set(this.getKey(o),o):k5(o)?this.map.set(o.id,o):$5(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)},this.set=async(o,c)=>{this.isInitialized(),this.map.has(o)?await this.update(o,c):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:c}),this.map.set(o,c),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(c=>Object.keys(o).every(l=>i4(c[l],o[l]))):this.values),this.update=async(o,c)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:c});const l=Zd(Zd({},this.getData(o)),c);this.map.set(o,l),await this.persist()},this.delete=async(o,c)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:c}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())},this.logger=Ht(r,this.name),this.storagePrefix=n,this.getKey=s}get context(){return Xt(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}=ie("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}const{message:i}=ie("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}=ie("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}=ie("NOT_INITIALIZED",this.name);throw new Error(e)}}}class M7{constructor(e,r){this.core=e,this.logger=r,this.name=E4,this.version=x4,this.events=new qt.exports,this.initialized=!1,this.storagePrefix=ai,this.ignoredPayloadTypes=[mi],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=Tc(),s=await this.core.crypto.setSymKey(n),o=_t(oe.FIVE_MINUTES),c={protocol:Id},l={topic:s,expiry:o,relay:c,active:!1,methods:i?.methods},u=nd({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:n,relay:c,expiryTimestamp:o,methods:i?.methods});return this.events.emit(gn.create,l),this.core.expirer.set(s,o),await this.pairings.set(s,l),await this.core.relayer.subscribe(s,{transportType:i?.transportType}),{topic:s,uri:u}},this.pair=async i=>{this.isInitialized();const n=this.core.eventClient.createEvent({properties:{topic:i?.uri,trace:[ci.pairing_started]}});this.isValidPair(i,n);const{topic:s,symKey:o,relay:c,expiryTimestamp:l,methods:u}=id(i.uri);n.props.properties.topic=s,n.addTrace(ci.pairing_uri_validation_success),n.addTrace(ci.pairing_uri_not_expired);let b;if(this.pairings.keys.includes(s)){if(b=this.pairings.get(s),n.addTrace(ci.existing_pairing),b.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(ci.pairing_not_expired)}const m=l||_t(oe.FIVE_MINUTES),M={topic:s,relay:c,expiry:m,active:!1,methods:u};this.core.expirer.set(s,m),await this.pairings.set(s,M),n.addTrace(ci.store_new_pairing),i.activatePairing&&await this.activate({topic:s}),this.events.emit(gn.create,M),n.addTrace(ci.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(o,s),n.addTrace(ci.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{n.setError(Ai.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:c})}catch(S){throw n.setError(Ai.subscribe_pairing_topic_failure),S}return n.addTrace(ci.subscribe_pairing_topic_success),M},this.activate=async({topic:i})=>{this.isInitialized();const n=_t(oe.THIRTY_DAYS);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);const{topic:n}=i;if(this.pairings.keys.includes(n)){const s=await this.sendRequest(n,"wc_pairingPing",{}),{done:o,resolve:c,reject:l}=cn();this.events.once(Je("pairing_ping",s),({error:u})=>{u?l(u):c()}),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",ht("USER_DISCONNECTED")),await this.deletePairing(n))},this.formatUriFromPairing=i=>{this.isInitialized();const{topic:n,relay:s,expiry:o,methods:c}=i,l=this.core.crypto.keychain.get(n);return nd({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:l,relay:s,expiryTimestamp:o,methods:c})},this.sendRequest=async(i,n,s)=>{const o=pn(n,s),c=await this.core.crypto.encode(i,o),l=zs[n].req;return this.core.history.set(i,o),this.core.relayer.publish(i,c,l),o.id},this.sendResult=async(i,n,s)=>{const o=$c(i,s),c=await this.core.crypto.encode(n,o),l=await this.core.history.get(n,i),u=zs[l.request.method].res;await this.core.relayer.publish(n,c,u),await this.core.history.resolve(o)},this.sendError=async(i,n,s)=>{const o=jc(i,s),c=await this.core.crypto.encode(n,o),l=await this.core.history.get(n,i),u=zs[l.request.method]?zs[l.request.method].res:zs.unregistered_method.res;await this.core.relayer.publish(n,c,u),await this.core.history.resolve(o)},this.deletePairing=async(i,n)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,ht("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=>zi(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(gn.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(()=>{si(n)?this.events.emit(Je("pairing_ping",s),{}):Ar(n)&&this.events.emit(Je("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(gn.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 c=ht("WC_METHOD_UNSUPPORTED",o);await this.sendError(s,i,c),this.logger.error(c)}catch(c){await this.sendError(s,i,c),this.logger.error(c)}},this.onUnknownRpcMethodResponse=i=>{this.registeredMethods.includes(i)||this.logger.error(ht("WC_METHOD_UNSUPPORTED",i))},this.isValidPair=(i,n)=>{var s;if(!ir(i)){const{message:c}=ie("MISSING_OR_INVALID",`pair() params: ${i}`);throw n.setError(Ai.malformed_pairing_uri),new Error(c)}if(!z5(i.uri)){const{message:c}=ie("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw n.setError(Ai.malformed_pairing_uri),new Error(c)}const o=id(i?.uri);if(!((s=o?.relay)!=null&&s.protocol)){const{message:c}=ie("MISSING_OR_INVALID","pair() uri#relay-protocol");throw n.setError(Ai.malformed_pairing_uri),new Error(c)}if(!(o!=null&&o.symKey)){const{message:c}=ie("MISSING_OR_INVALID","pair() uri#symKey");throw n.setError(Ai.malformed_pairing_uri),new Error(c)}if(o!=null&&o.expiryTimestamp&&oe.toMiliseconds(o?.expiryTimestamp)<Date.now()){n.setError(Ai.pairing_expired);const{message:c}=ie("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(c)}},this.isValidPing=async i=>{if(!ir(i)){const{message:s}=ie("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidDisconnect=async i=>{if(!ir(i)){const{message:s}=ie("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(s)}const{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidPairingTopic=async i=>{if(!yt(i,!1)){const{message:n}=ie("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){const{message:n}=ie("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(zi(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:n}=ie("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}},this.core=e,this.logger=Ht(r,this.name),this.pairings=new mn(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Xt(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=ie("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Jt.message,async e=>{const{topic:r,message:i,transportType:n}=e;if(!this.pairings.keys.includes(r)||n===at.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;const s=await this.core.crypto.decode(r,i);try{Kc(s)?(this.core.history.set(r,s),this.onRelayEventRequest({topic:r,payload:s})):Za(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(xr.expired,async e=>{const{topic:r}=Ru(e.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit(gn.expire,{topic:r}))})}}class I7 extends wp{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.records=new Map,this.events=new qt.exports.EventEmitter,this.name=S4,this.version=M4,this.cached=[],this.initialized=!1,this.storagePrefix=ai,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:_t(oe.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(Cr.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(Cr.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(Cr.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=Ht(r,this.name)}get context(){return Xt(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:pn(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}=ie("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Cr.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:r}=ie("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(Cr.created,e=>{const r=Cr.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(Cr.updated,e=>{const r=Cr.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(Cr.deleted,e=>{const r=Cr.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.core.heartbeat.on(xn.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(r=>{oe.toMiliseconds(r.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${r.id}`),this.records.delete(r.id),this.events.emit(Cr.deleted,r,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=ie("NOT_INITIALIZED",this.name);throw new Error(e)}}}class D7 extends Mp{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.expirations=new Map,this.events=new qt.exports.EventEmitter,this.name=I4,this.version=D4,this.cached=[],this.initialized=!1,this.storagePrefix=ai,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(xr.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(xr.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=Ht(r,this.name)}get context(){return Xt(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}=ie("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(xr.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:r}=ie("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}=ie("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return r}checkExpiry(e,r){const{expiry:i}=r;oe.toMiliseconds(i)-Date.now()<=0&&this.expire(e,r)}expire(e,r){this.expirations.delete(e),this.events.emit(xr.expired,{target:e,expiration:r})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,r)=>this.checkExpiry(r,e))}registerEventListeners(){this.core.heartbeat.on(xn.pulse,()=>this.checkExpirations()),this.events.on(xr.created,e=>{const r=xr.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(xr.expired,e=>{const r=xr.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(xr.deleted,e=>{const r=xr.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=ie("NOT_INITIALIZED",this.name);throw new Error(e)}}}var ut={};Object.defineProperty(ut,"__esModule",{value:!0}),ut.getLocalStorage=ut.getLocalStorageOrThrow=ut.getCrypto=ut.getCryptoOrThrow=ut.getLocation=ut.getLocationOrThrow=ut.getNavigator=ut.getNavigatorOrThrow=el=ut.getDocument=ut.getDocumentOrThrow=ut.getFromWindowOrThrow=ut.getFromWindow=void 0;function yn(t){let e;return typeof window<"u"&&typeof window[t]<"u"&&(e=window[t]),e}ut.getFromWindow=yn;function ts(t){const e=yn(t);if(!e)throw new Error(`${t} is not defined in Window`);return e}ut.getFromWindowOrThrow=ts;function O7(){return ts("document")}ut.getDocumentOrThrow=O7;function R7(){return yn("document")}var el=ut.getDocument=R7;function N7(){return ts("navigator")}ut.getNavigatorOrThrow=N7;function P7(){return yn("navigator")}ut.getNavigator=P7;function T7(){return ts("location")}ut.getLocationOrThrow=T7;function C7(){return yn("location")}ut.getLocation=C7;function F7(){return ts("crypto")}ut.getCryptoOrThrow=F7;function L7(){return yn("crypto")}ut.getCrypto=L7;function B7(){return ts("localStorage")}ut.getLocalStorageOrThrow=B7;function q7(){return yn("localStorage")}ut.getLocalStorage=q7;class U7 extends Ip{constructor(e,r,i){super(e,r,i),this.core=e,this.logger=r,this.store=i,this.name=O4,this.verifyUrlV3=N4,this.storagePrefix=ai,this.version=Sd,this.init=async()=>{var n;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&oe.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(!ys()||this.isDevEnv)return;const s=window.location.origin,{id:o,decryptedId:c}=n,l=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${s}&id=${o}&decryptedId=${c}`;try{const u=el(),b=this.startAbortTimer(oe.ONE_SECOND*5),m=await new Promise((M,S)=>{const I=()=>{window.removeEventListener("message",k),u.body.removeChild(F),S("attestation aborted")};this.abortController.signal.addEventListener("abort",I);const F=u.createElement("iframe");F.src=l,F.style.display="none",F.addEventListener("error",I,{signal:this.abortController.signal});const k=j=>{if(j.data&&typeof j.data=="string")try{const C=JSON.parse(j.data);if(C.type==="verify_attestation"){if(Fo(C.attestation).payload.id!==o)return;clearInterval(b),u.body.removeChild(F),this.abortController.signal.removeEventListener("abort",I),window.removeEventListener("message",k),M(C.attestation===null?"":C.attestation)}}catch(C){this.logger.warn(C)}};u.body.appendChild(F),window.addEventListener("message",k,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",m),m}catch(u){this.logger.warn(u)}return""},this.resolve=async n=>{if(this.isDevEnv)return"";const{attestationId:s,hash:o,encryptedId:c}=n;if(s===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(s){if(Fo(s).payload.id!==c)return;const u=await this.isValidJwtAttestation(s);if(u){if(!u.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return u}}if(!o)return;const l=this.getVerifyUrl(n?.verifyUrl);return this.fetchAttestation(o,l)},this.fetchAttestation=async(n,s)=>{this.logger.debug(`resolving attestation: ${n} from url: ${s}`);const o=this.startAbortTimer(oe.ONE_SECOND*5),c=await fetch(`${s}/attestation/${n}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),c.status===200?await c.json():void 0},this.getVerifyUrl=n=>{let s=n||ks;return P4.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${ks}`),s=ks),s},this.fetchPublicKey=async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const n=this.startAbortTimer(oe.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(c){this.logger.error(c),this.logger.warn("error validating attestation")}const o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(n,o)}catch(c){this.logger.error(c),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=_5(n,s.publicKey),c={hasExpired:oe.toMiliseconds(o.exp)<Date.now(),payload:o};if(c.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:c.payload.origin,isScam:c.payload.isScam,isVerified:c.payload.isVerified}},this.logger=Ht(r,this.name),this.abortController=new AbortController,this.isDevEnv=ac(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return Xt(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),oe.toMiliseconds(e))}}class z7 extends Dp{constructor(e,r){super(e,r),this.projectId=e,this.logger=r,this.context=T4,this.registerDeviceToken=async i=>{const{clientId:n,token:s,notificationType:o,enableEncrypted:c=!1}=i,l=`${C4}/${this.projectId}/clients`;await fetch(l,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:n,type:o,token:s,always_raw:c})})},this.logger=Ht(r,this.context)}}var k7=Object.defineProperty,tl=Object.getOwnPropertySymbols,$7=Object.prototype.hasOwnProperty,j7=Object.prototype.propertyIsEnumerable,rl=(t,e,r)=>e in t?k7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Hs=(t,e)=>{for(var r in e||(e={}))$7.call(e,r)&&rl(t,r,e[r]);if(tl)for(var r of tl(e))j7.call(e,r)&&rl(t,r,e[r]);return t};class K7 extends Op{constructor(e,r,i=!0){super(e,r,i),this.core=e,this.logger=r,this.context=L4,this.storagePrefix=ai,this.storageVersion=F4,this.events=new Map,this.shouldPersist=!1,this.init=async()=>{if(!ac())try{const n={eventId:Pu(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:Mu(this.core.relayer.protocol,this.core.relayer.version,Gc)}}};await this.sendEvent([n])}catch(n){this.logger.warn(n)}},this.createEvent=n=>{const{event:s="ERROR",type:o="",properties:{topic:c,trace:l}}=n,u=Pu(),b=this.core.projectId||"",m=Date.now(),M=Hs({eventId:u,timestamp:m,props:{event:s,type:o,properties:{topic:c,trace:l}},bundleId:b,domain:this.getAppDomain()},this.setMethods(u));return this.telemetryEnabled&&(this.events.set(u,M),this.shouldPersist=!0),M},this.getEvent=n=>{const{eventId:s,topic:o}=n;if(s)return this.events.get(s);const c=Array.from(this.events.values()).find(l=>l.props.properties.topic===o);if(c)return Hs(Hs({},c),this.setMethods(c.eventId))},this.deleteEvent=n=>{const{eventId:s}=n;this.events.delete(s),this.shouldPersist=!0},this.setEventListeners=()=>{this.core.heartbeat.on(xn.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(n=>{oe.fromMiliseconds(Date.now())-oe.fromMiliseconds(n.timestamp)>B4&&(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,Hs(Hs({},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(`${q4}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${Gc}${s}`,{method:"POST",body:JSON.stringify(n)})},this.getAppDomain=()=>Su().url,this.logger=Ht(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 H7=Object.defineProperty,il=Object.getOwnPropertySymbols,V7=Object.prototype.hasOwnProperty,G7=Object.prototype.propertyIsEnumerable,nl=(t,e,r)=>e in t?H7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,sl=(t,e)=>{for(var r in e||(e={}))V7.call(e,r)&&nl(t,r,e[r]);if(il)for(var r of il(e))G7.call(e,r)&&nl(t,r,e[r]);return t};class Xc extends yp{constructor(e){var r;super(e),this.protocol=xd,this.version=Sd,this.name=Vc,this.events=new qt.exports.EventEmitter,this.initialized=!1,this.on=(o,c)=>this.events.on(o,c),this.once=(o,c)=>this.events.once(o,c),this.off=(o,c)=>this.events.off(o,c),this.removeListener=(o,c)=>this.events.removeListener(o,c),this.dispatchEnvelope=({topic:o,message:c,sessionExists:l})=>{if(!o||!c)return;const u={topic:o,message:c,publishedAt:Date.now(),transportType:at.link_mode};this.relayer.onLinkMessageEvent(u,{sessionExists:l})},this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||Dd,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=So({level:typeof e?.logger=="string"&&e.logger?e.logger:n4.logger}),{logger:n,chunkLoggerController:s}=mp({opts:i,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=s,(r=this.logChunkController)!=null&&r.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var o,c;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((c=this.logChunkController)==null||c.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=Ht(n,this.name),this.heartbeat=new mo,this.crypto=new c7(this,this.logger,e?.keychain),this.history=new I7(this,this.logger),this.expirer=new D7(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new K1(sl(sl({},s4),e?.storageOptions)),this.relayer=new A7({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new M7(this,this.logger),this.verify=new U7(this,this.logger,this.storage),this.echoClient=new z7(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new K7(this,this.logger,e?.telemetryEnabled)}static async init(e){const r=new Xc(e);await r.initialize();const i=await r.crypto.getClientId();return await r.storage.setItem(y4,i),r}get context(){return Xt(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(Od,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.eventClient.init(),this.linkModeSupportedApps=await this.storage.getItem(Od)||[],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 Zc=Xc,al="wc",ol=2,cl="client",ef=`${al}@${ol}:${cl}:`,tf={name:cl,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"},fl="WALLETCONNECT_DEEPLINK_CHOICE",W7="proposal",Y7="Proposal expired",J7="session",rs=oe.SEVEN_DAYS,Q7="engine",Ot={wc_sessionPropose:{req:{ttl:oe.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:oe.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:oe.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:oe.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:oe.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:oe.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:oe.ONE_DAY,prompt:!1,tag:1104},res:{ttl:oe.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:oe.ONE_DAY,prompt:!1,tag:1106},res:{ttl:oe.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:oe.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:oe.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:oe.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:oe.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:oe.ONE_DAY,prompt:!1,tag:1112},res:{ttl:oe.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:oe.ONE_DAY,prompt:!1,tag:1114},res:{ttl:oe.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:oe.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:oe.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:oe.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:oe.FIVE_MINUTES,prompt:!1,tag:1119}}},rf={min:oe.FIVE_MINUTES,max:oe.SEVEN_DAYS},fi={idle:"IDLE",active:"ACTIVE"},X7="request",Z7=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],e9="wc",t9="auth",r9="authKeys",i9="pairingTopics",n9="requests",to=`${e9}@${1.5}:${t9}:`,ro=`${to}:PUB_KEY`;var s9=Object.defineProperty,a9=Object.defineProperties,o9=Object.getOwnPropertyDescriptors,hl=Object.getOwnPropertySymbols,c9=Object.prototype.hasOwnProperty,f9=Object.prototype.propertyIsEnumerable,ul=(t,e,r)=>e in t?s9(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,bt=(t,e)=>{for(var r in e||(e={}))c9.call(e,r)&&ul(t,r,e[r]);if(hl)for(var r of hl(e))f9.call(e,r)&&ul(t,r,e[r]);return t},Lr=(t,e)=>a9(t,o9(e));class h9 extends Np{constructor(e){super(e),this.name=Q7,this.events=new qt.exports,this.initialized=!1,this.requestQueue={state:fi.idle,queue:[]},this.sessionRequestQueue={state:fi.idle,queue:[]},this.requestQueueDelay=oe.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(Ot)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},oe.toMiliseconds(this.requestQueueDelay)))},this.connect=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const i=Lr(bt({},r),{requiredNamespaces:r.requiredNamespaces||{},optionalNamespaces:r.optionalNamespaces||{}});await this.isValidConnect(i);const{pairingTopic:n,requiredNamespaces:s,optionalNamespaces:o,sessionProperties:c,relays:l}=i;let u=n,b,m=!1;try{u&&(m=this.client.core.pairing.pairings.get(u).active)}catch(P){throw this.client.logger.error(`connect() -> pairing.get(${u}) failed`),P}if(!u||!m){const{topic:P,uri:B}=await this.client.core.pairing.create();u=P,b=B}if(!u){const{message:P}=ie("NO_MATCHING_KEY",`connect() pairing topic: ${u}`);throw new Error(P)}const M=await this.client.core.crypto.generateKeyPair(),S=Ot.wc_sessionPropose.req.ttl||oe.FIVE_MINUTES,I=_t(S),F=bt({requiredNamespaces:s,optionalNamespaces:o,relays:l??[{protocol:Id}],proposer:{publicKey:M,metadata:this.client.metadata},expiryTimestamp:I,pairingTopic:u},c&&{sessionProperties:c}),{reject:k,resolve:j,done:C}=cn(S,Y7);this.events.once(Je("session_connect"),async({error:P,session:B})=>{if(P)k(P);else if(B){B.self.publicKey=M;const U=Lr(bt({},B),{pairingTopic:F.pairingTopic,requiredNamespaces:F.requiredNamespaces,optionalNamespaces:F.optionalNamespaces,transportType:at.relay});await this.client.session.set(B.topic,U),await this.setExpiry(B.topic,B.expiry),u&&await this.client.core.pairing.updateMetadata({topic:u,metadata:B.peer.metadata}),this.cleanupDuplicatePairings(U),j(U)}});const $=await this.sendRequest({topic:u,method:"wc_sessionPropose",params:F,throwOnFailedPublish:!0});return await this.setProposal($,bt({id:$},F)),{uri:b,approval:C}},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:[Fr.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(O){throw o.setError(bn.no_internet_connection),O}try{await this.isValidProposalId(r?.id)}catch(O){throw this.client.logger.error(`approve() -> proposal.get(${r?.id}) failed`),o.setError(bn.proposal_not_found),O}try{await this.isValidApprove(r)}catch(O){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(bn.session_approve_namespace_validation_failure),O}const{id:c,relayProtocol:l,namespaces:u,sessionProperties:b,sessionConfig:m}=r,M=this.client.proposal.get(c);this.client.core.eventClient.deleteEvent({eventId:o.eventId});const{pairingTopic:S,proposer:I,requiredNamespaces:F,optionalNamespaces:k}=M;let j=(n=this.client.core.eventClient)==null?void 0:n.getEvent({topic:S});j||(j=(s=this.client.core.eventClient)==null?void 0:s.createEvent({type:Fr.session_approve_started,properties:{topic:S,trace:[Fr.session_approve_started,Fr.session_namespaces_validation_success]}}));const C=await this.client.core.crypto.generateKeyPair(),$=I.publicKey,P=await this.client.core.crypto.generateSharedKey(C,$),B=bt(bt({relay:{protocol:l??"irn"},namespaces:u,controller:{publicKey:C,metadata:this.client.metadata},expiry:_t(rs)},b&&{sessionProperties:b}),m&&{sessionConfig:m}),U=at.relay;j.addTrace(Fr.subscribing_session_topic);try{await this.client.core.relayer.subscribe(P,{transportType:U})}catch(O){throw j.setError(bn.subscribe_session_topic_failure),O}j.addTrace(Fr.subscribe_session_topic_success);const y=Lr(bt({},B),{topic:P,requiredNamespaces:F,optionalNamespaces:k,pairingTopic:S,acknowledged:!1,self:B.controller,peer:{publicKey:I.publicKey,metadata:I.metadata},controller:C,transportType:at.relay});await this.client.session.set(P,y),j.addTrace(Fr.store_session);try{j.addTrace(Fr.publishing_session_settle),await this.sendRequest({topic:P,method:"wc_sessionSettle",params:B,throwOnFailedPublish:!0}).catch(O=>{throw j?.setError(bn.session_settle_publish_failure),O}),j.addTrace(Fr.session_settle_publish_success),j.addTrace(Fr.publishing_session_approve),await this.sendResult({id:c,topic:S,result:{relay:{protocol:l??"irn"},responderPublicKey:C},throwOnFailedPublish:!0}).catch(O=>{throw j?.setError(bn.session_approve_publish_failure),O}),j.addTrace(Fr.session_approve_publish_success)}catch(O){throw this.client.logger.error(O),this.client.session.delete(P,ht("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(P),O}return this.client.core.eventClient.deleteEvent({eventId:j.eventId}),await this.client.core.pairing.updateMetadata({topic:S,metadata:I.metadata}),await this.client.proposal.delete(c,ht("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:S}),await this.setExpiry(P,_t(rs)),{topic:P,acknowledged:()=>Promise.resolve(this.client.session.get(P))}},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:Ot.wc_sessionPropose.reject}),await this.client.proposal.delete(i,ht("USER_DISCONNECTED")))},this.update=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(r)}catch(m){throw this.client.logger.error("update() -> isValidUpdate() failed"),m}const{topic:i,namespaces:n}=r,{done:s,resolve:o,reject:c}=cn(),l=Hi(),u=ln().toString(),b=this.client.session.get(i).namespaces;return this.events.once(Je("session_update",l),({error:m})=>{m?c(m):o()}),await this.client.session.update(i,{namespaces:n}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:n},throwOnFailedPublish:!0,clientRpcId:l,relayRpcId:u}).catch(m=>{this.client.logger.error(m),this.client.session.update(i,{namespaces:b}),c(m)}),{acknowledged:s}},this.extend=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(r)}catch(l){throw this.client.logger.error("extend() -> isValidExtend() failed"),l}const{topic:i}=r,n=Hi(),{done:s,resolve:o,reject:c}=cn();return this.events.once(Je("session_extend",n),({error:l})=>{l?c(l):o()}),await this.setExpiry(i,_t(rs)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(l=>{c(l)}),{acknowledged:s}},this.request=async r=>{this.isInitialized();try{await this.isValidRequest(r)}catch(I){throw this.client.logger.error("request() -> isValidRequest() failed"),I}const{chainId:i,request:n,topic:s,expiry:o=Ot.wc_sessionRequest.req.ttl}=r,c=this.client.session.get(s);c?.transportType===at.relay&&await this.confirmOnlineStateOrThrow();const l=Hi(),u=ln().toString(),{done:b,resolve:m,reject:M}=cn(o,"Request expired. Please try again.");this.events.once(Je("session_request",l),({error:I,result:F})=>{I?M(I):m(F)});const S=this.getAppLinkIfEnabled(c.peer.metadata,c.transportType);return S?(await this.sendRequest({clientRpcId:l,relayRpcId:u,topic:s,method:"wc_sessionRequest",params:{request:Lr(bt({},n),{expiryTimestamp:_t(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0,appLink:S}).catch(I=>M(I)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:l}),await b()):await Promise.all([new Promise(async I=>{await this.sendRequest({clientRpcId:l,relayRpcId:u,topic:s,method:"wc_sessionRequest",params:{request:Lr(bt({},n),{expiryTimestamp:_t(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0}).catch(F=>M(F)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:l}),I()}),new Promise(async I=>{var F;if(!((F=c.sessionConfig)!=null&&F.disableDeepLink)){const k=await c6(this.client.core.storage,fl);await a6({id:l,topic:s,wcDeepLink:k})}I()}),b()]).then(I=>I[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===at.relay&&await this.confirmOnlineStateOrThrow();const c=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);si(n)?await this.sendResult({id:s,topic:i,result:n.result,throwOnFailedPublish:!0,appLink:c}):Ar(n)&&await this.sendError({id:s,topic:i,error:n.error,appLink:c}),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=Hi(),s=ln().toString(),{done:o,resolve:c,reject:l}=cn();this.events.once(Je("session_ping",n),({error:u})=>{u?l(u):c()}),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)&&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=ln().toString();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:n,chainId:s},throwOnFailedPublish:!0,relayRpcId:o})},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:ht("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}=ie("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(n)}},this.find=r=>(this.isInitialized(),this.client.session.getAll().filter(i=>q5(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?at.link_mode:at.relay;o===at.relay&&await this.confirmOnlineStateOrThrow();const{chains:c,statement:l="",uri:u,domain:b,nonce:m,type:M,exp:S,nbf:I,methods:F=[],expiry:k}=r,j=[...r.resources||[]],{topic:C,uri:$}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:C,uri:$}});const P=await this.client.core.crypto.generateKeyPair(),B=Ya(P);if(await Promise.all([this.client.auth.authKeys.set(ro,{responseTopic:B,publicKey:P}),this.client.auth.pairingTopics.set(B,{topic:B,pairingTopic:C})]),await this.client.core.relayer.subscribe(B,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${C}`),F.length>0){const{namespace:x}=sc(c[0]);let _=s5(x,"request",F);Wa(j)&&(_=o5(_,j.pop())),j.push(_)}const U=k&&k>Ot.wc_sessionAuthenticate.req.ttl?k:Ot.wc_sessionAuthenticate.req.ttl,y={authPayload:{type:M??"caip122",chains:c,statement:l,aud:u,domain:b,version:"1",nonce:m,iat:new Date().toISOString(),exp:S,nbf:I,resources:j},requester:{publicKey:P,metadata:this.client.metadata},expiryTimestamp:_t(U)},O={eip155:{chains:c,methods:[...new Set(["personal_sign",...F])],events:["chainChanged","accountsChanged"]}},Y={requiredNamespaces:{},optionalNamespaces:O,relays:[{protocol:"irn"}],pairingTopic:C,proposer:{publicKey:P,metadata:this.client.metadata},expiryTimestamp:_t(Ot.wc_sessionPropose.req.ttl)},{done:Q,resolve:N,reject:g}=cn(U,"Request expired"),a=async({error:x,session:_})=>{if(this.events.off(Je("session_request",p),f),x)g(x);else if(_){_.self.publicKey=P,await this.client.session.set(_.topic,_),await this.setExpiry(_.topic,_.expiry),C&&await this.client.core.pairing.updateMetadata({topic:C,metadata:_.peer.metadata});const h=this.client.session.get(_.topic);await this.deleteProposal(w),N({session:h})}},f=async x=>{var _,h,d;if(await this.deletePendingAuthRequest(p,{message:"fulfilled",code:0}),x.error){const L=ht("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return x.error.code===L.code?void 0:(this.events.off(Je("session_connect"),a),g(x.error.message))}await this.deleteProposal(w),this.events.off(Je("session_connect"),a);const{cacaos:D,responder:K}=x.result,G=[],E=[];for(const L of D){await k0({cacao:L,projectId:this.client.core.projectId})||(this.client.logger.error(L,"Signature verification failed"),g(ht("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:q}=L,v=Wa(q.resources),T=[z0(q.iss)],W=Ga(q.iss);if(v){const J=K0(v),X=H0(v);G.push(...J),T.push(...X)}for(const J of T)E.push(`${J}:${W}`)}const H=await this.client.core.crypto.generateSharedKey(P,K.publicKey);let R;G.length>0&&(R={topic:H,acknowledged:!0,self:{publicKey:P,metadata:this.client.metadata},peer:K,controller:K.publicKey,expiry:_t(rs),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:C,namespaces:sd([...new Set(G)],[...new Set(E)]),transportType:o},await this.client.core.relayer.subscribe(H,{transportType:o}),await this.client.session.set(H,R),C&&await this.client.core.pairing.updateMetadata({topic:C,metadata:K.metadata}),R=this.client.session.get(H)),(_=this.client.metadata.redirect)!=null&&_.linkMode&&(h=K.metadata.redirect)!=null&&h.linkMode&&(d=K.metadata.redirect)!=null&&d.universal&&i&&(this.client.core.addLinkModeSupportedApp(K.metadata.redirect.universal),this.client.session.update(H,{transportType:at.link_mode})),N({auths:D,session:R})},p=Hi(),w=Hi();this.events.once(Je("session_connect"),a),this.events.once(Je("session_request",p),f);let A;try{if(s){const x=pn("wc_sessionAuthenticate",y,p);this.client.core.history.set(C,x);const _=await this.client.core.crypto.encode("",x,{type:Ps,encoding:Rs});A=Ja(i,C,_)}else await Promise.all([this.sendRequest({topic:C,method:"wc_sessionAuthenticate",params:y,expiry:r.expiry,throwOnFailedPublish:!0,clientRpcId:p}),this.sendRequest({topic:C,method:"wc_sessionPropose",params:Y,expiry:Ot.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:w})])}catch(x){throw this.events.off(Je("session_connect"),a),this.events.off(Je("session_request",p),f),x}return await this.setProposal(w,bt({id:w},Y)),await this.setAuthRequest(p,{request:Lr(bt({},y),{verifyContext:{}}),pairingTopic:C,transportType:o}),{uri:A??$,response:Q}},this.approveSessionAuthenticate=async r=>{const{id:i,auths:n}=r,s=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[vn.authenticated_session_approve_started]}});try{this.isInitialized()}catch(k){throw s.setError($s.no_internet_connection),k}const o=this.getPendingAuthRequest(i);if(!o)throw s.setError($s.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);const c=o.transportType||at.relay;c===at.relay&&await this.confirmOnlineStateOrThrow();const l=o.requester.publicKey,u=await this.client.core.crypto.generateKeyPair(),b=Ya(l),m={type:mi,receiverPublicKey:l,senderPublicKey:u},M=[],S=[];for(const k of n){if(!await k0({cacao:k,projectId:this.client.core.projectId})){s.setError($s.invalid_cacao);const B=ht("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:b,error:B,encodeOpts:m}),new Error(B.message)}s.addTrace(vn.cacaos_verified);const{p:j}=k,C=Wa(j.resources),$=[z0(j.iss)],P=Ga(j.iss);if(C){const B=K0(C),U=H0(C);M.push(...B),$.push(...U)}for(const B of $)S.push(`${B}:${P}`)}const I=await this.client.core.crypto.generateSharedKey(u,l);s.addTrace(vn.create_authenticated_session_topic);let F;if(M?.length>0){F={topic:I,acknowledged:!0,self:{publicKey:u,metadata:this.client.metadata},peer:{publicKey:l,metadata:o.requester.metadata},controller:l,expiry:_t(rs),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:sd([...new Set(M)],[...new Set(S)]),transportType:c},s.addTrace(vn.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(I,{transportType:c})}catch(k){throw s.setError($s.subscribe_authenticated_session_topic_failure),k}s.addTrace(vn.subscribe_authenticated_session_topic_success),await this.client.session.set(I,F),s.addTrace(vn.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}s.addTrace(vn.publishing_authenticated_session_approve);try{await this.sendResult({topic:b,id:i,result:{cacaos:n,responder:{publicKey:u,metadata:this.client.metadata}},encodeOpts:m,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,c)})}catch(k){throw s.setError($s.authenticated_session_approve_publish_failure),k}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:F}},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===at.relay&&await this.confirmOnlineStateOrThrow();const o=s.requester.publicKey,c=await this.client.core.crypto.generateKeyPair(),l=Ya(o),u={type:mi,receiverPublicKey:o,senderPublicKey:c};await this.sendError({id:i,topic:l,error:n,encodeOpts:u,rpcOpts:Ot.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,ht("USER_DISCONNECTED"))},this.formatAuthMessage=r=>{this.isInitialized();const{request:i,iss:n}=r;return $0(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,c;return((o=s.peerMetadata)==null?void 0:o.url)&&((c=s.peerMetadata)==null?void 0:c.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:c=0}=r,{self:l}=this.client.session.get(n);await this.client.core.relayer.unsubscribe(n),await this.client.session.delete(n,ht("USER_DISCONNECTED")),this.addToRecentlyDeleted(n,"session"),this.client.core.crypto.keychain.has(l.publicKey)&&await this.client.core.crypto.deleteKeyPair(l.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(fl).catch(u=>this.client.logger.warn(u)),this.getPendingSessionRequests().forEach(u=>{u.topic===n&&this.deletePendingSessionRequest(u.id,ht("USER_DISCONNECTED"))}),n===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=fi.idle),o&&this.client.events.emit("session_delete",{id:c,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(bn.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(r,ht("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=fi.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,_t(Ot.wc_sessionPropose.req.ttl)),await this.client.proposal.set(r,i)},this.setAuthRequest=async(r,i)=>{const{request:n,pairingTopic:s,transportType:o=at.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,c=s.request.expiryTimestamp||_t(Ot.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,c),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:c,clientRpcId:l,throwOnFailedPublish:u,appLink:b}=r,m=pn(n,s,l);let M;const S=!!b;try{const k=S?Rs:Ki;M=await this.client.core.crypto.encode(i,m,{encoding:k})}catch(k){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),k}let I;if(Z7.includes(n)){const k=yi(JSON.stringify(m)),j=yi(M);I=await this.client.core.verify.register({id:j,decryptedId:k})}const F=Ot[n].req;if(F.attestation=I,o&&(F.ttl=o),c&&(F.id=c),this.client.core.history.set(i,m),S){const k=Ja(b,i,M);await global.Linking.openURL(k,this.client.name)}else{const k=Ot[n].req;o&&(k.ttl=o),c&&(k.id=c),u?(k.internal=Lr(bt({},k.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,M,k)):this.client.core.relayer.publish(i,M,k).catch(j=>this.client.logger.error(j))}return m.id},this.sendResult=async r=>{const{id:i,topic:n,result:s,throwOnFailedPublish:o,encodeOpts:c,appLink:l}=r,u=$c(i,s);let b;const m=l&&typeof(global==null?void 0:global.Linking)<"u";try{const S=m?Rs:Ki;b=await this.client.core.crypto.encode(n,u,Lr(bt({},c||{}),{encoding:S}))}catch(S){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${n} failed`),S}let M;try{M=await this.client.core.history.get(n,i)}catch(S){throw this.client.logger.error(`sendResult() -> history.get(${n}, ${i}) failed`),S}if(m){const S=Ja(l,n,b);await global.Linking.openURL(S,this.client.name)}else{const S=Ot[M.request.method].res;o?(S.internal=Lr(bt({},S.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,b,S)):this.client.core.relayer.publish(n,b,S).catch(I=>this.client.logger.error(I))}await this.client.core.history.resolve(u)},this.sendError=async r=>{const{id:i,topic:n,error:s,encodeOpts:o,rpcOpts:c,appLink:l}=r,u=jc(i,s);let b;const m=l&&typeof(global==null?void 0:global.Linking)<"u";try{const S=m?Rs:Ki;b=await this.client.core.crypto.encode(n,u,Lr(bt({},o||{}),{encoding:S}))}catch(S){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`),S}let M;try{M=await this.client.core.history.get(n,i)}catch(S){throw this.client.logger.error(`sendError() -> history.get(${n}, ${i}) failed`),S}if(m){const S=Ja(l,n,b);await global.Linking.openURL(S,this.client.name)}else{const S=c||Ot[M.request.method].res;this.client.core.relayer.publish(n,b,S)}await this.client.core.history.resolve(u)},this.cleanup=async()=>{const r=[],i=[];this.client.session.getAll().forEach(n=>{let s=!1;zi(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=>{zi(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===fi.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=fi.active;const r=this.requestQueue.queue.shift();if(r)try{await this.processRequest(r)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=fi.idle},this.processRequest=async r=>{const{topic:i,payload:n,attestation:s,transportType:o,encryptedId:c}=r,l=n.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:l}))switch(l){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:n,attestation:s,encryptedId:c});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:c,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:c,transportType:o});default:return this.client.logger.info(`Unsupported request method ${l}`)}},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}=ie("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:c,id:l}=n;try{const u=this.client.core.eventClient.getEvent({topic:i});this.isValidConnect(bt({},n.params));const b=c.expiryTimestamp||_t(Ot.wc_sessionPropose.req.ttl),m=bt({id:l,pairingTopic:i,expiryTimestamp:b},c);await this.setProposal(l,m);const M=await this.getVerifyContext({attestationId:s,hash:yi(JSON.stringify(n)),encryptedId:o,metadata:m.proposer.metadata});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),u?.setError(Ai.proposal_listener_not_found)),u?.addTrace(ci.emit_session_proposal),this.client.events.emit("session_proposal",{id:l,params:m,verifyContext:M})}catch(u){await this.sendError({id:l,topic:i,error:u,rpcOpts:Ot.wc_sessionPropose.autoReject}),this.client.logger.error(u)}},this.onSessionProposeResponse=async(r,i,n)=>{const{id:s}=i;if(si(i)){const{result:o}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});const c=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:c});const l=c.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:l});const u=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:u});const b=await this.client.core.crypto.generateSharedKey(l,u);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:b});const m=await this.client.core.relayer.subscribe(b,{transportType:n});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:m}),await this.client.core.pairing.activate({topic:r})}else if(Ar(i)){await this.client.proposal.delete(s,ht("USER_DISCONNECTED"));const o=Je("session_connect");if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(Je("session_connect"),{error:i.error})}},this.onSessionSettleRequest=async(r,i)=>{const{id:n,params:s}=i;try{this.isValidSessionSettleRequest(s);const{relay:o,controller:c,expiry:l,namespaces:u,sessionProperties:b,sessionConfig:m}=i.params,M=Lr(bt(bt({topic:r,relay:o,expiry:l,namespaces:u,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:c.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:c.publicKey,metadata:c.metadata}},b&&{sessionProperties:b}),m&&{sessionConfig:m}),{transportType:at.relay}),S=Je("session_connect");if(this.events.listenerCount(S)===0)throw new Error(`emitting ${S} without any listeners 997`);this.events.emit(Je("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;si(i)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(Je("session_approve",n),{})):Ar(i)&&(await this.client.session.delete(r,ht("USER_DISCONNECTED")),this.events.emit(Je("session_approve",n),{error:i.error}))},this.onSessionUpdateRequest=async(r,i)=>{const{params:n,id:s}=i;try{const o=`${r}_session_update`,c=Bs.get(o);if(c&&this.isRequestOutOfSync(c,s)){this.client.logger.info(`Discarding out of sync request - ${s}`),this.sendError({id:s,topic:r,error:ht("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(bt({topic:r},n));try{Bs.set(o,s),await this.client.session.update(r,{namespaces:n.namespaces}),await this.sendResult({id:s,topic:r,result:!0,throwOnFailedPublish:!0})}catch(l){throw Bs.delete(o),l}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)=>parseInt(i.toString().slice(0,-3))<=parseInt(r.toString().slice(0,-3)),this.onSessionUpdateResponse=(r,i)=>{const{id:n}=i,s=Je("session_update",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);si(i)?this.events.emit(Je("session_update",n),{}):Ar(i)&&this.events.emit(Je("session_update",n),{error:i.error})},this.onSessionExtendRequest=async(r,i)=>{const{id:n}=i;try{this.isValidExtend({topic:r}),await this.setExpiry(r,_t(rs)),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=Je("session_extend",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);si(i)?this.events.emit(Je("session_extend",n),{}):Ar(i)&&this.events.emit(Je("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=Je("session_ping",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);setTimeout(()=>{si(i)?this.events.emit(Je("session_ping",n),{}):Ar(i)&&this.events.emit(Je("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(Jt.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:ht("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:c,attestation:l,encryptedId:u,transportType:b}=r,{id:m,params:M}=c;try{await this.isValidRequest(bt({topic:o},M));const S=this.client.session.get(o),I=await this.getVerifyContext({attestationId:l,hash:yi(JSON.stringify(pn("wc_sessionRequest",M,m))),encryptedId:u,metadata:S.peer.metadata,transportType:b}),F={id:m,topic:o,params:M,verifyContext:I};await this.setPendingSessionRequest(F),b===at.link_mode&&(i=S.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((n=S.peer.metadata.redirect)==null?void 0:n.universal),(s=this.client.signConfig)!=null&&s.disableRequestQueue?this.emitSessionRequest(F):(this.addSessionRequestToSessionRequestQueue(F),this.processSessionRequestQueue())}catch(S){await this.sendError({id:m,topic:o,error:S}),this.client.logger.error(S)}},this.onSessionRequestResponse=(r,i)=>{const{id:n}=i,s=Je("session_request",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);si(i)?this.events.emit(Je("session_request",n),{result:i.result}):Ar(i)&&this.events.emit(Je("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}`,c=Bs.get(o);if(c&&this.isRequestOutOfSync(c,n)){this.client.logger.info(`Discarding out of sync request - ${n}`);return}this.isValidEmit(bt({topic:r},s)),this.client.events.emit("session_event",{id:n,topic:r,params:s}),Bs.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}),si(i)?this.events.emit(Je("session_request",n),{result:i.result}):Ar(i)&&this.events.emit(Je("session_request",n),{error:i.error})},this.onSessionAuthenticateRequest=async r=>{var i;const{topic:n,payload:s,attestation:o,encryptedId:c,transportType:l}=r;try{const{requester:u,authPayload:b,expiryTimestamp:m}=s.params,M=await this.getVerifyContext({attestationId:o,hash:yi(JSON.stringify(s)),encryptedId:c,metadata:u.metadata,transportType:l}),S={requester:u,pairingTopic:n,id:s.id,authPayload:b,verifyContext:M,expiryTimestamp:m};await this.setAuthRequest(s.id,{request:S,pairingTopic:n,transportType:l}),l===at.link_mode&&(i=u.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(u.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:n,params:s.params,id:s.id,verifyContext:M})}catch(u){this.client.logger.error(u);const b=s.params.requester.publicKey,m=await this.client.core.crypto.generateKeyPair(),M=this.getAppLinkIfEnabled(s.params.requester.metadata,l),S={type:mi,receiverPublicKey:b,senderPublicKey:m};await this.sendError({id:s.id,topic:n,error:u,encodeOpts:S,rpcOpts:Ot.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=fi.idle,this.processSessionRequestQueue()},oe.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,c=Je("session_request",o);if(this.events.listenerCount(c)===0)throw new Error(`emitting ${c} without any listeners`);this.events.emit(Je("session_request",s.request.id),{error:i})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===fi.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=fi.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:pn("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id)})},this.isValidConnect=async r=>{if(!ir(r)){const{message:l}=ie("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(l)}const{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:s,sessionProperties:o,relays:c}=r;if(Yt(i)||await this.isValidPairingTopic(i),!J5(c,!0)){const{message:l}=ie("MISSING_OR_INVALID",`connect() relays: ${c}`);throw new Error(l)}!Yt(n)&&Qa(n)!==0&&this.validateNamespaces(n,"requiredNamespaces"),!Yt(s)&&Qa(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),Yt(o)||this.validateSessionProps(o,"sessionProperties")},this.validateNamespaces=(r,i)=>{const n=Y5(r,"connect()",i);if(n)throw new Error(n.message)},this.isValidApprove=async r=>{if(!ir(r))throw new Error(ie("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 c=this.client.proposal.get(i),l=Lc(n,"approve()");if(l)throw new Error(l.message);const u=hd(c.requiredNamespaces,n,"approve()");if(u)throw new Error(u.message);if(!yt(s,!0)){const{message:b}=ie("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(b)}Yt(o)||this.validateSessionProps(o,"sessionProperties")},this.isValidReject=async r=>{if(!ir(r)){const{message:s}=ie("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(s)}const{id:i,reason:n}=r;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!X5(n)){const{message:s}=ie("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(s)}},this.isValidSessionSettleRequest=r=>{if(!ir(r)){const{message:u}=ie("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(u)}const{relay:i,controller:n,namespaces:s,expiry:o}=r;if(!cd(i)){const{message:u}=ie("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(u)}const c=j5(n,"onSessionSettleRequest()");if(c)throw new Error(c.message);const l=Lc(s,"onSessionSettleRequest()");if(l)throw new Error(l.message);if(zi(o)){const{message:u}=ie("EXPIRED","onSessionSettleRequest()");throw new Error(u)}},this.isValidUpdate=async r=>{if(!ir(r)){const{message:l}=ie("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(l)}const{topic:i,namespaces:n}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const s=this.client.session.get(i),o=Lc(n,"update()");if(o)throw new Error(o.message);const c=hd(s.requiredNamespaces,n,"update()");if(c)throw new Error(c.message)},this.isValidExtend=async r=>{if(!ir(r)){const{message:n}=ie("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(!ir(r)){const{message:l}=ie("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(l)}const{topic:i,request:n,chainId:s,expiry:o}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const{namespaces:c}=this.client.session.get(i);if(!fd(c,s)){const{message:l}=ie("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(l)}if(!Z5(n)){const{message:l}=ie("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(l)}if(!r8(c,s,n.method)){const{message:l}=ie("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(l)}if(o&&!a8(o,rf)){const{message:l}=ie("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${rf.min} and ${rf.max}`);throw new Error(l)}},this.isValidRespond=async r=>{var i;if(!ir(r)){const{message:o}=ie("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(!e8(s)){const{message:o}=ie("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(o)}},this.isValidPing=async r=>{if(!ir(r)){const{message:n}=ie("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(n)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)},this.isValidEmit=async r=>{if(!ir(r)){const{message:c}=ie("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(c)}const{topic:i,event:n,chainId:s}=r;await this.isValidSessionTopic(i);const{namespaces:o}=this.client.session.get(i);if(!fd(o,s)){const{message:c}=ie("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(c)}if(!t8(n)){const{message:c}=ie("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(c)}if(!i8(o,s,n.name)){const{message:c}=ie("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(c)}},this.isValidDisconnect=async r=>{if(!ir(r)){const{message:n}=ie("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(!yt(n,!1))throw new Error("uri is required parameter");if(!yt(s,!1))throw new Error("domain is required parameter");if(!yt(o,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(l=>sc(l).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:c}=sc(i[0]);if(c!=="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:c}=r,l={verified:{verifyUrl:o.verifyUrl||ks,validation:"UNKNOWN",origin:o.url||""}};try{if(c===at.link_mode){const b=this.getAppLinkIfEnabled(o,c);return l.verified.validation=b&&new URL(b).origin===new URL(o.url).origin?"VALID":"INVALID",l}const u=await this.client.core.verify.resolve({attestationId:i,hash:n,encryptedId:s,verifyUrl:o.verifyUrl});u&&(l.verified.origin=u.origin,l.verified.isScam=u.isScam,l.verified.validation=u.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(u){this.client.logger.warn(u)}return this.client.logger.debug(`Verify context: ${JSON.stringify(l)}`),l},this.validateSessionProps=(r,i)=>{Object.values(r).forEach(n=>{if(!yt(n,!1)){const{message:s}=ie("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}=ie("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${r}`);throw new Error(n)}},this.isLinkModeEnabled=(r,i)=>{var n,s,o,c,l,u,b,m,M;return!r||i!==at.link_mode?!1:((s=(n=this.client.metadata)==null?void 0:n.redirect)==null?void 0:s.linkMode)===!0&&((c=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:c.universal)!==void 0&&((u=(l=this.client.metadata)==null?void 0:l.redirect)==null?void 0:u.universal)!==""&&((b=r?.redirect)==null?void 0:b.universal)!==void 0&&((m=r?.redirect)==null?void 0:m.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=Nu(r,"topic")||"",n=decodeURIComponent(Nu(r,"wc_ev")||""),s=this.client.session.keys.includes(i);s&&this.client.session.update(i,{transportType:at.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:n,sessionExists:s})},this.registerLinkModeListeners=async()=>{var r;if(ac()||kn()&&(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}=ie("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Jt.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(ro)?this.client.auth.authKeys.get(ro):{responseTopic:void 0,publicKey:void 0},c=await this.client.core.crypto.decode(r,i,{receiverPublicKey:o,encoding:s===at.link_mode?Rs:Ki});try{Kc(c)?(this.client.core.history.set(r,c),this.onRelayEventRequest({topic:r,payload:c,attestation:n,transportType:s,encryptedId:yi(i)})):Za(c)?(await this.client.core.history.resolve(c),await this.onRelayEventResponse({topic:r,payload:c,transportType:s}),this.client.core.history.delete(r,c.id)):this.onRelayEventUnknownPayload({topic:r,payload:c,transportType:s})}catch(l){this.client.logger.error(l)}}registerExpirerEvents(){this.client.core.expirer.on(xr.expired,async e=>{const{topic:r,id:i}=Ru(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,ie("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,ie("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(gn.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(gn.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!yt(e,!1)){const{message:r}=ie("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}=ie("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(r)}if(zi(this.client.core.pairing.pairings.get(e).expiry)){const{message:r}=ie("EXPIRED",`pairing topic: ${e}`);throw new Error(r)}}async isValidSessionTopic(e){if(!yt(e,!1)){const{message:r}=ie("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}=ie("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(r)}if(zi(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:r}=ie("EXPIRED",`session topic: ${e}`);throw new Error(r)}if(!this.client.core.crypto.keychain.has(e)){const{message:r}=ie("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(yt(e,!1)){const{message:r}=ie("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(r)}else{const{message:r}=ie("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(r)}}async isValidProposalId(e){if(!Q5(e)){const{message:r}=ie("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(r)}if(!this.client.proposal.keys.includes(e)){const{message:r}=ie("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(r)}if(zi(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:r}=ie("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}}class u9 extends mn{constructor(e,r){super(e,r,W7,ef),this.core=e,this.logger=r}}class dl extends mn{constructor(e,r){super(e,r,J7,ef),this.core=e,this.logger=r}}class d9 extends mn{constructor(e,r){super(e,r,X7,ef,i=>i.id),this.core=e,this.logger=r}}class l9 extends mn{constructor(e,r){super(e,r,r9,to,()=>ro),this.core=e,this.logger=r}}class p9 extends mn{constructor(e,r){super(e,r,i9,to),this.core=e,this.logger=r}}class g9 extends mn{constructor(e,r){super(e,r,n9,to,i=>i.id),this.core=e,this.logger=r}}class b9{constructor(e,r){this.core=e,this.logger=r,this.authKeys=new l9(this.core,this.logger),this.pairingTopics=new p9(this.core,this.logger),this.requests=new g9(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}class nf extends Rp{constructor(e){super(e),this.protocol=al,this.version=ol,this.name=tf.name,this.events=new qt.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||tf.name,this.metadata=e?.metadata||Su(),this.signConfig=e?.signConfig;const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:hi(So({level:e?.logger||tf.logger}));this.core=e?.core||new Zc(e),this.logger=Ht(r,this.name),this.session=new dl(this.core,this.logger),this.proposal=new u9(this.core,this.logger),this.pendingRequest=new d9(this.core,this.logger),this.engine=new h9(this),this.auth=new b9(this.core,this.logger)}static async init(e){const r=new nf(e);return await r.initialize(),r}get context(){return Xt(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"),this.engine.processRelayMessageCache()}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}const v9=dl,m9=nf;class y9 extends qt.exports{constructor(){super()}}class ll{constructor(e){this.opts=e}}class pl{constructor(e){this.client=e}}var w9=Object.defineProperty,_9=Object.defineProperties,A9=Object.getOwnPropertyDescriptors,gl=Object.getOwnPropertySymbols,E9=Object.prototype.hasOwnProperty,x9=Object.prototype.propertyIsEnumerable,bl=(t,e,r)=>e in t?w9(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,S9=(t,e)=>{for(var r in e||(e={}))E9.call(e,r)&&bl(t,r,e[r]);if(gl)for(var r of gl(e))x9.call(e,r)&&bl(t,r,e[r]);return t},M9=(t,e)=>_9(t,A9(e));class I9 extends pl{constructor(e){super(e),this.init=async()=>{this.signClient=await m9.init({core:this.client.core,metadata:this.client.metadata,signConfig:this.client.signConfig})},this.pair=async r=>{await this.client.core.pairing.pair(r)},this.approveSession=async r=>{const{topic:i,acknowledged:n}=await this.signClient.approve(M9(S9({},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 D9={decryptMessage:async t=>{const e={core:new Zc({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 Zc({storageOptions:t.storageOptions,storage:t.storage}),sessionStore:null};e.sessionStore=new v9(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}},vl=class extends ll{constructor(t){super(t),this.events=new qt.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||fo,this.signConfig=t.signConfig,this.core=t.core,this.logger=this.core.logger,this.engine=new I9(this)}static async init(t){const e=new vl(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 sf=vl;sf.notifications=D9;const O9=sf;Bt.CLIENT_CONTEXT=fo,Bt.CLIENT_STORAGE_OPTIONS=Ll,Bt.CLIENT_STORAGE_PREFIX=Fl,Bt.IWalletKit=ll,Bt.IWalletKitEngine=pl,Bt.IWalletKitEvents=y9,Bt.PROTOCOL=vf,Bt.PROTOCOL_VERSION=Cl,Bt.REQUEST_CONTEXT=Bl,Bt.WalletKit=O9,Bt.default=sf,Object.defineProperty(Bt,"__esModule",{value:!0})});
|
44
44
|
//# sourceMappingURL=index.umd.js.map
|