lab.waku.org/buddybook/assets/index.es-BocJIoGE.js
status-im-auto 541e0eb512 Updates
2024-11-10 20:21:51 +00:00

71 lines
708 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-C91wHTLi.js","assets/index-Cye4tEiE.js","assets/index-CwoEHhxw.css"])))=>i.map(i=>d[i]);
import{j as ev,f as tv,u as w4,h as Ld,_ as _4}from"./index-Cye4tEiE.js";import{e as Vi,J as Fd}from"./events-EbrwmdBG.js";import{r as zd,i as Pf}from"./inherits_browser-DKXdsDax.js";var Ae={};/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var ad=function(r,e){return ad=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var n in i)i.hasOwnProperty(n)&&(t[n]=i[n])},ad(r,e)};function D4(r,e){ad(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var od=function(){return od=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++){t=arguments[i];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e},od.apply(this,arguments)};function E4(r,e){var t={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(r);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(r,i[n])&&(t[i[n]]=r[i[n]]);return t}function A4(r,e,t,i){var n=arguments.length,a=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,i);else for(var f=r.length-1;f>=0;f--)(c=r[f])&&(a=(n<3?c(a):n>3?c(e,t,a):c(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a}function x4(r,e){return function(t,i){e(t,i,r)}}function S4(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function M4(r,e,t,i){function n(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function f(m){try{d(i.next(m))}catch(w){c(w)}}function g(m){try{d(i.throw(m))}catch(w){c(w)}}function d(m){m.done?a(m.value):n(m.value).then(f,g)}d((i=i.apply(r,e||[])).next())})}function I4(r,e){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,n,a,c;return c={next:f(0),throw:f(1),return:f(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function f(d){return function(m){return g([d,m])}}function g(d){if(i)throw new TypeError("Generator is already executing.");for(;t;)try{if(i=1,n&&(a=d[0]&2?n.return:d[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,d[1])).done)return a;switch(n=0,a&&(d=[d[0]&2,a.value]),d[0]){case 0:case 1:a=d;break;case 4:return t.label++,{value:d[1],done:!1};case 5:t.label++,n=d[1],d=[0];continue;case 7:d=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(d[0]===6||d[0]===2)){t=0;continue}if(d[0]===3&&(!a||d[1]>a[0]&&d[1]<a[3])){t.label=d[1];break}if(d[0]===6&&t.label<a[1]){t.label=a[1],a=d;break}if(a&&t.label<a[2]){t.label=a[2],t.ops.push(d);break}a[2]&&t.ops.pop(),t.trys.pop();continue}d=e.call(r,t)}catch(m){d=[6,m],n=0}finally{i=a=0}if(d[0]&5)throw d[1];return{value:d[0]?d[1]:void 0,done:!0}}}function C4(r,e,t,i){i===void 0&&(i=t),r[i]=e[t]}function P4(r,e){for(var t in r)t!=="default"&&!e.hasOwnProperty(t)&&(e[t]=r[t])}function cd(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],i=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&i>=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function rv(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,a=[],c;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(f){c={error:f}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(c)throw c.error}}return a}function O4(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(rv(arguments[e]));return r}function T4(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var i=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],c=0,f=a.length;c<f;c++,n++)i[n]=a[c];return i}function bc(r){return this instanceof bc?(this.v=r,this):new bc(r)}function R4(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(r,e||[]),n,a=[];return n={},c("next"),c("throw"),c("return"),n[Symbol.asyncIterator]=function(){return this},n;function c(O){i[O]&&(n[O]=function(C){return new Promise(function(P,q){a.push([O,C,P,q])>1||f(O,C)})})}function f(O,C){try{g(i[O](C))}catch(P){w(a[0][3],P)}}function g(O){O.value instanceof bc?Promise.resolve(O.value.v).then(d,m):w(a[0][2],O)}function d(O){f("next",O)}function m(O){f("throw",O)}function w(O,C){O(C),a.shift(),a.length&&f(a[0][0],a[0][1])}}function N4(r){var e,t;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,a){e[n]=r[n]?function(c){return(t=!t)?{value:bc(r[n](c)),done:n==="return"}:a?a(c):c}:a}}function B4(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof cd=="function"?cd(r):r[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(a){t[a]=r[a]&&function(c){return new Promise(function(f,g){c=r[a](c),n(f,g,c.done,c.value)})}}function n(a,c,f,g){Promise.resolve(g).then(function(d){a({value:d,done:f})},c)}}function $4(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function U4(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e}function q4(r){return r&&r.__esModule?r:{default:r}}function L4(r,e){if(!e.has(r))throw new TypeError("attempted to get private field on non-instance");return e.get(r)}function F4(r,e,t){if(!e.has(r))throw new TypeError("attempted to set private field on non-instance");return e.set(r,t),t}const z4=Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return od},__asyncDelegator:N4,__asyncGenerator:R4,__asyncValues:B4,__await:bc,__awaiter:M4,__classPrivateFieldGet:L4,__classPrivateFieldSet:F4,__createBinding:C4,__decorate:A4,__exportStar:P4,__extends:D4,__generator:I4,__importDefault:q4,__importStar:U4,__makeTemplateObject:$4,__metadata:S4,__param:x4,__read:rv,__rest:E4,__spread:O4,__spreadArrays:T4,__values:cd},Symbol.toStringTag,{value:"Module"})),Of=ev(z4);var gl={},Go={},w1;function j4(){if(w1)return Go;w1=1,Object.defineProperty(Go,"__esModule",{value:!0}),Go.delay=void 0;function r(e){return new Promise(t=>{setTimeout(()=>{t(!0)},e)})}return Go.delay=r,Go}var sa={},bl={},aa={},_1;function k4(){return _1||(_1=1,Object.defineProperty(aa,"__esModule",{value:!0}),aa.ONE_THOUSAND=aa.ONE_HUNDRED=void 0,aa.ONE_HUNDRED=100,aa.ONE_THOUSAND=1e3),aa}var vl={},D1;function H4(){return D1||(D1=1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.ONE_YEAR=r.FOUR_WEEKS=r.THREE_WEEKS=r.TWO_WEEKS=r.ONE_WEEK=r.THIRTY_DAYS=r.SEVEN_DAYS=r.FIVE_DAYS=r.THREE_DAYS=r.ONE_DAY=r.TWENTY_FOUR_HOURS=r.TWELVE_HOURS=r.SIX_HOURS=r.THREE_HOURS=r.ONE_HOUR=r.SIXTY_MINUTES=r.THIRTY_MINUTES=r.TEN_MINUTES=r.FIVE_MINUTES=r.ONE_MINUTE=r.SIXTY_SECONDS=r.THIRTY_SECONDS=r.TEN_SECONDS=r.FIVE_SECONDS=r.ONE_SECOND=void 0,r.ONE_SECOND=1,r.FIVE_SECONDS=5,r.TEN_SECONDS=10,r.THIRTY_SECONDS=30,r.SIXTY_SECONDS=60,r.ONE_MINUTE=r.SIXTY_SECONDS,r.FIVE_MINUTES=r.ONE_MINUTE*5,r.TEN_MINUTES=r.ONE_MINUTE*10,r.THIRTY_MINUTES=r.ONE_MINUTE*30,r.SIXTY_MINUTES=r.ONE_MINUTE*60,r.ONE_HOUR=r.SIXTY_MINUTES,r.THREE_HOURS=r.ONE_HOUR*3,r.SIX_HOURS=r.ONE_HOUR*6,r.TWELVE_HOURS=r.ONE_HOUR*12,r.TWENTY_FOUR_HOURS=r.ONE_HOUR*24,r.ONE_DAY=r.TWENTY_FOUR_HOURS,r.THREE_DAYS=r.ONE_DAY*3,r.FIVE_DAYS=r.ONE_DAY*5,r.SEVEN_DAYS=r.ONE_DAY*7,r.THIRTY_DAYS=r.ONE_DAY*30,r.ONE_WEEK=r.SEVEN_DAYS,r.TWO_WEEKS=r.ONE_WEEK*2,r.THREE_WEEKS=r.ONE_WEEK*3,r.FOUR_WEEKS=r.ONE_WEEK*4,r.ONE_YEAR=r.ONE_DAY*365}(vl)),vl}var E1;function iv(){return E1||(E1=1,function(r){Object.defineProperty(r,"__esModule",{value:!0});const e=Of;e.__exportStar(k4(),r),e.__exportStar(H4(),r)}(bl)),bl}var A1;function K4(){if(A1)return sa;A1=1,Object.defineProperty(sa,"__esModule",{value:!0}),sa.fromMiliseconds=sa.toMiliseconds=void 0;const r=iv();function e(i){return i*r.ONE_THOUSAND}sa.toMiliseconds=e;function t(i){return Math.floor(i/r.ONE_THOUSAND)}return sa.fromMiliseconds=t,sa}var x1;function V4(){return x1||(x1=1,function(r){Object.defineProperty(r,"__esModule",{value:!0});const e=Of;e.__exportStar(j4(),r),e.__exportStar(K4(),r)}(gl)),gl}var Ga={},S1;function G4(){if(S1)return Ga;S1=1,Object.defineProperty(Ga,"__esModule",{value:!0}),Ga.Watch=void 0;class r{constructor(){this.timestamps=new Map}start(t){if(this.timestamps.has(t))throw new Error(`Watch already started for label: ${t}`);this.timestamps.set(t,{started:Date.now()})}stop(t){const i=this.get(t);if(typeof i.elapsed<"u")throw new Error(`Watch already stopped for label: ${t}`);const n=Date.now()-i.started;this.timestamps.set(t,{started:i.started,elapsed:n})}get(t){const i=this.timestamps.get(t);if(typeof i>"u")throw new Error(`No timestamp found for label: ${t}`);return i}elapsed(t){const i=this.get(t);return i.elapsed||Date.now()-i.started}}return Ga.Watch=r,Ga.default=r,Ga}var ml={},Jo={},M1;function J4(){if(M1)return Jo;M1=1,Object.defineProperty(Jo,"__esModule",{value:!0}),Jo.IWatch=void 0;class r{}return Jo.IWatch=r,Jo}var I1;function W4(){return I1||(I1=1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),Of.__exportStar(J4(),r)}(ml)),ml}(function(r){Object.defineProperty(r,"__esModule",{value:!0});const e=Of;e.__exportStar(V4(),r),e.__exportStar(G4(),r),e.__exportStar(W4(),r),e.__exportStar(iv(),r)})(Ae);var Vt={};Object.defineProperty(Vt,"__esModule",{value:!0});Vt.getLocalStorage=Vt.getLocalStorageOrThrow=Vt.getCrypto=Vt.getCryptoOrThrow=nv=Vt.getLocation=Vt.getLocationOrThrow=jd=Vt.getNavigator=Vt.getNavigatorOrThrow=Tf=Vt.getDocument=Vt.getDocumentOrThrow=Vt.getFromWindowOrThrow=Vt.getFromWindow=void 0;function _a(r){let e;return typeof window<"u"&&typeof window[r]<"u"&&(e=window[r]),e}Vt.getFromWindow=_a;function ho(r){const e=_a(r);if(!e)throw new Error(`${r} is not defined in Window`);return e}Vt.getFromWindowOrThrow=ho;function Y4(){return ho("document")}Vt.getDocumentOrThrow=Y4;function Q4(){return _a("document")}var Tf=Vt.getDocument=Q4;function X4(){return ho("navigator")}Vt.getNavigatorOrThrow=X4;function Z4(){return _a("navigator")}var jd=Vt.getNavigator=Z4;function e_(){return ho("location")}Vt.getLocationOrThrow=e_;function t_(){return _a("location")}var nv=Vt.getLocation=t_;function r_(){return ho("crypto")}Vt.getCryptoOrThrow=r_;function i_(){return _a("crypto")}Vt.getCrypto=i_;function n_(){return ho("localStorage")}Vt.getLocalStorageOrThrow=n_;function s_(){return _a("localStorage")}Vt.getLocalStorage=s_;var kd={};Object.defineProperty(kd,"__esModule",{value:!0});var sv=kd.getWindowMetadata=void 0;const C1=Vt;function a_(){let r,e;try{r=C1.getDocumentOrThrow(),e=C1.getLocationOrThrow()}catch{return null}function t(){const w=r.getElementsByTagName("link"),O=[];for(let C=0;C<w.length;C++){const P=w[C],q=P.getAttribute("rel");if(q&&q.toLowerCase().indexOf("icon")>-1){const K=P.getAttribute("href");if(K)if(K.toLowerCase().indexOf("https:")===-1&&K.toLowerCase().indexOf("http:")===-1&&K.indexOf("//")!==0){let Y=e.protocol+"//"+e.host;if(K.indexOf("/")===0)Y+=K;else{const z=e.pathname.split("/");z.pop();const W=z.join("/");Y+=W+"/"+K}O.push(Y)}else if(K.indexOf("//")===0){const Y=e.protocol+K;O.push(Y)}else O.push(K)}}return O}function i(...w){const O=r.getElementsByTagName("meta");for(let C=0;C<O.length;C++){const P=O[C],q=["itemprop","property","name"].map(K=>P.getAttribute(K)).filter(K=>K?w.includes(K):!1);if(q.length&&q){const K=P.getAttribute("content");if(K)return K}}return""}function n(){let w=i("name","og:site_name","og:title","twitter:title");return w||(w=r.title),w}function a(){return i("description","og:description","twitter:description","keywords")}const c=n(),f=a(),g=e.origin,d=t();return{description:f,url:g,icons:d,name:c}}sv=kd.getWindowMetadata=a_;var vc={},o_=r=>encodeURIComponent(r).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),av="%[a-f0-9]{2}",P1=new RegExp("("+av+")|([^%]+?)","gi"),O1=new RegExp("("+av+")+","gi");function ud(r,e){try{return[decodeURIComponent(r.join(""))]}catch{}if(r.length===1)return r;e=e||1;var t=r.slice(0,e),i=r.slice(e);return Array.prototype.concat.call([],ud(t),ud(i))}function c_(r){try{return decodeURIComponent(r)}catch{for(var e=r.match(P1)||[],t=1;t<e.length;t++)r=ud(e,t).join(""),e=r.match(P1)||[];return r}}function u_(r){for(var e={"%FE%FF":"<22><>","%FF%FE":"<22><>"},t=O1.exec(r);t;){try{e[t[0]]=decodeURIComponent(t[0])}catch{var i=c_(t[0]);i!==t[0]&&(e[t[0]]=i)}t=O1.exec(r)}e["%C2"]="<22>";for(var n=Object.keys(e),a=0;a<n.length;a++){var c=n[a];r=r.replace(new RegExp(c,"g"),e[c])}return r}var f_=function(r){if(typeof r!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof r+"`");try{return r=r.replace(/\+/g," "),decodeURIComponent(r)}catch{return u_(r)}},h_=(r,e)=>{if(!(typeof r=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[r];const t=r.indexOf(e);return t===-1?[r]:[r.slice(0,t),r.slice(t+e.length)]},l_=function(r,e){for(var t={},i=Object.keys(r),n=Array.isArray(e),a=0;a<i.length;a++){var c=i[a],f=r[c];(n?e.indexOf(c)!==-1:e(c,f,r))&&(t[c]=f)}return t};(function(r){const e=o_,t=f_,i=h_,n=l_,a=z=>z==null,c=Symbol("encodeFragmentIdentifier");function f(z){switch(z.arrayFormat){case"index":return W=>(B,j)=>{const k=B.length;return j===void 0||z.skipNull&&j===null||z.skipEmptyString&&j===""?B:j===null?[...B,[m(W,z),"[",k,"]"].join("")]:[...B,[m(W,z),"[",m(k,z),"]=",m(j,z)].join("")]};case"bracket":return W=>(B,j)=>j===void 0||z.skipNull&&j===null||z.skipEmptyString&&j===""?B:j===null?[...B,[m(W,z),"[]"].join("")]:[...B,[m(W,z),"[]=",m(j,z)].join("")];case"colon-list-separator":return W=>(B,j)=>j===void 0||z.skipNull&&j===null||z.skipEmptyString&&j===""?B:j===null?[...B,[m(W,z),":list="].join("")]:[...B,[m(W,z),":list=",m(j,z)].join("")];case"comma":case"separator":case"bracket-separator":{const W=z.arrayFormat==="bracket-separator"?"[]=":"=";return B=>(j,k)=>k===void 0||z.skipNull&&k===null||z.skipEmptyString&&k===""?j:(k=k===null?"":k,j.length===0?[[m(B,z),W,m(k,z)].join("")]:[[j,m(k,z)].join(z.arrayFormatSeparator)])}default:return W=>(B,j)=>j===void 0||z.skipNull&&j===null||z.skipEmptyString&&j===""?B:j===null?[...B,m(W,z)]:[...B,[m(W,z),"=",m(j,z)].join("")]}}function g(z){let W;switch(z.arrayFormat){case"index":return(B,j,k)=>{if(W=/\[(\d*)\]$/.exec(B),B=B.replace(/\[\d*\]$/,""),!W){k[B]=j;return}k[B]===void 0&&(k[B]={}),k[B][W[1]]=j};case"bracket":return(B,j,k)=>{if(W=/(\[\])$/.exec(B),B=B.replace(/\[\]$/,""),!W){k[B]=j;return}if(k[B]===void 0){k[B]=[j];return}k[B]=[].concat(k[B],j)};case"colon-list-separator":return(B,j,k)=>{if(W=/(:list)$/.exec(B),B=B.replace(/:list$/,""),!W){k[B]=j;return}if(k[B]===void 0){k[B]=[j];return}k[B]=[].concat(k[B],j)};case"comma":case"separator":return(B,j,k)=>{const _=typeof j=="string"&&j.includes(z.arrayFormatSeparator),N=typeof j=="string"&&!_&&w(j,z).includes(z.arrayFormatSeparator);j=N?w(j,z):j;const se=_||N?j.split(z.arrayFormatSeparator).map(le=>w(le,z)):j===null?j:w(j,z);k[B]=se};case"bracket-separator":return(B,j,k)=>{const _=/(\[\])$/.test(B);if(B=B.replace(/\[\]$/,""),!_){k[B]=j&&w(j,z);return}const N=j===null?[]:j.split(z.arrayFormatSeparator).map(se=>w(se,z));if(k[B]===void 0){k[B]=N;return}k[B]=[].concat(k[B],N)};default:return(B,j,k)=>{if(k[B]===void 0){k[B]=j;return}k[B]=[].concat(k[B],j)}}}function d(z){if(typeof z!="string"||z.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function m(z,W){return W.encode?W.strict?e(z):encodeURIComponent(z):z}function w(z,W){return W.decode?t(z):z}function O(z){return Array.isArray(z)?z.sort():typeof z=="object"?O(Object.keys(z)).sort((W,B)=>Number(W)-Number(B)).map(W=>z[W]):z}function C(z){const W=z.indexOf("#");return W!==-1&&(z=z.slice(0,W)),z}function P(z){let W="";const B=z.indexOf("#");return B!==-1&&(W=z.slice(B)),W}function q(z){z=C(z);const W=z.indexOf("?");return W===-1?"":z.slice(W+1)}function K(z,W){return W.parseNumbers&&!Number.isNaN(Number(z))&&typeof z=="string"&&z.trim()!==""?z=Number(z):W.parseBooleans&&z!==null&&(z.toLowerCase()==="true"||z.toLowerCase()==="false")&&(z=z.toLowerCase()==="true"),z}function Y(z,W){W=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},W),d(W.arrayFormatSeparator);const B=g(W),j=Object.create(null);if(typeof z!="string"||(z=z.trim().replace(/^[?#&]/,""),!z))return j;for(const k of z.split("&")){if(k==="")continue;let[_,N]=i(W.decode?k.replace(/\+/g," "):k,"=");N=N===void 0?null:["comma","separator","bracket-separator"].includes(W.arrayFormat)?N:w(N,W),B(w(_,W),N,j)}for(const k of Object.keys(j)){const _=j[k];if(typeof _=="object"&&_!==null)for(const N of Object.keys(_))_[N]=K(_[N],W);else j[k]=K(_,W)}return W.sort===!1?j:(W.sort===!0?Object.keys(j).sort():Object.keys(j).sort(W.sort)).reduce((k,_)=>{const N=j[_];return N&&typeof N=="object"&&!Array.isArray(N)?k[_]=O(N):k[_]=N,k},Object.create(null))}r.extract=q,r.parse=Y,r.stringify=(z,W)=>{if(!z)return"";W=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},W),d(W.arrayFormatSeparator);const B=N=>W.skipNull&&a(z[N])||W.skipEmptyString&&z[N]==="",j=f(W),k={};for(const N of Object.keys(z))B(N)||(k[N]=z[N]);const _=Object.keys(k);return W.sort!==!1&&_.sort(W.sort),_.map(N=>{const se=z[N];return se===void 0?"":se===null?m(N,W):Array.isArray(se)?se.length===0&&W.arrayFormat==="bracket-separator"?m(N,W)+"[]":se.reduce(j(N),[]).join("&"):m(N,W)+"="+m(se,W)}).filter(N=>N.length>0).join("&")},r.parseUrl=(z,W)=>{W=Object.assign({decode:!0},W);const[B,j]=i(z,"#");return Object.assign({url:B.split("?")[0]||"",query:Y(q(z),W)},W&&W.parseFragmentIdentifier&&j?{fragmentIdentifier:w(j,W)}:{})},r.stringifyUrl=(z,W)=>{W=Object.assign({encode:!0,strict:!0,[c]:!0},W);const B=C(z.url).split("?")[0]||"",j=r.extract(z.url),k=r.parse(j,{sort:!1}),_=Object.assign(k,z.query);let N=r.stringify(_,W);N&&(N=`?${N}`);let se=P(z.url);return z.fragmentIdentifier&&(se=`#${W[c]?m(z.fragmentIdentifier,W):z.fragmentIdentifier}`),`${B}${N}${se}`},r.pick=(z,W,B)=>{B=Object.assign({parseFragmentIdentifier:!0,[c]:!1},B);const{url:j,query:k,fragmentIdentifier:_}=r.parseUrl(z,B);return r.stringifyUrl({url:j,query:n(k,W),fragmentIdentifier:_},B)},r.exclude=(z,W,B)=>{const j=Array.isArray(W)?k=>!W.includes(k):(k,_)=>!W(k,_);return r.pick(z,j,B)}})(vc);var Hd={},Rf={},mt={},ov={};(function(r){Object.defineProperty(r,"__esModule",{value:!0});function e(f,g){var d=f>>>16&65535,m=f&65535,w=g>>>16&65535,O=g&65535;return m*O+(d*O+m*w<<16>>>0)|0}r.mul=Math.imul||e;function t(f,g){return f+g|0}r.add=t;function i(f,g){return f-g|0}r.sub=i;function n(f,g){return f<<g|f>>>32-g}r.rotl=n;function a(f,g){return f<<32-g|f>>>g}r.rotr=a;function c(f){return typeof f=="number"&&isFinite(f)&&Math.floor(f)===f}r.isInteger=Number.isInteger||c,r.MAX_SAFE_INTEGER=9007199254740991,r.isSafeInteger=function(f){return r.isInteger(f)&&f>=-r.MAX_SAFE_INTEGER&&f<=r.MAX_SAFE_INTEGER}})(ov);Object.defineProperty(mt,"__esModule",{value:!0});var cv=ov;function d_(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])<<16>>16}mt.readInt16BE=d_;function p_(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])>>>0}mt.readUint16BE=p_;function g_(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])<<16>>16}mt.readInt16LE=g_;function b_(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])>>>0}mt.readUint16LE=b_;function uv(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>8,e[t+1]=r>>>0,e}mt.writeUint16BE=uv;mt.writeInt16BE=uv;function fv(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e}mt.writeUint16LE=fv;mt.writeInt16LE=fv;function fd(r,e){return e===void 0&&(e=0),r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3]}mt.readInt32BE=fd;function hd(r,e){return e===void 0&&(e=0),(r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3])>>>0}mt.readUint32BE=hd;function ld(r,e){return e===void 0&&(e=0),r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e]}mt.readInt32LE=ld;function dd(r,e){return e===void 0&&(e=0),(r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e])>>>0}mt.readUint32LE=dd;function lf(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>24,e[t+1]=r>>>16,e[t+2]=r>>>8,e[t+3]=r>>>0,e}mt.writeUint32BE=lf;mt.writeInt32BE=lf;function df(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e[t+2]=r>>>16,e[t+3]=r>>>24,e}mt.writeUint32LE=df;mt.writeInt32LE=df;function v_(r,e){e===void 0&&(e=0);var t=fd(r,e),i=fd(r,e+4);return t*4294967296+i-(i>>31)*4294967296}mt.readInt64BE=v_;function m_(r,e){e===void 0&&(e=0);var t=hd(r,e),i=hd(r,e+4);return t*4294967296+i}mt.readUint64BE=m_;function y_(r,e){e===void 0&&(e=0);var t=ld(r,e),i=ld(r,e+4);return i*4294967296+t-(t>>31)*4294967296}mt.readInt64LE=y_;function w_(r,e){e===void 0&&(e=0);var t=dd(r,e),i=dd(r,e+4);return i*4294967296+t}mt.readUint64LE=w_;function hv(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),lf(r/4294967296>>>0,e,t),lf(r>>>0,e,t+4),e}mt.writeUint64BE=hv;mt.writeInt64BE=hv;function lv(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),df(r>>>0,e,t),df(r/4294967296>>>0,e,t+4),e}mt.writeUint64LE=lv;mt.writeInt64LE=lv;function __(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintBE: array is too short for the given bitLength");for(var i=0,n=1,a=r/8+t-1;a>=t;a--)i+=e[a]*n,n*=256;return i}mt.readUintBE=__;function D_(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintLE: array is too short for the given bitLength");for(var i=0,n=1,a=t;a<t+r/8;a++)i+=e[a]*n,n*=256;return i}mt.readUintLE=D_;function E_(r,e,t,i){if(t===void 0&&(t=new Uint8Array(r/8)),i===void 0&&(i=0),r%8!==0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!cv.isSafeInteger(e))throw new Error("writeUintBE value must be an integer");for(var n=1,a=r/8+i-1;a>=i;a--)t[a]=e/n&255,n*=256;return t}mt.writeUintBE=E_;function A_(r,e,t,i){if(t===void 0&&(t=new Uint8Array(r/8)),i===void 0&&(i=0),r%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!cv.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var n=1,a=i;a<i+r/8;a++)t[a]=e/n&255,n*=256;return t}mt.writeUintLE=A_;function x_(r,e){e===void 0&&(e=0);var t=new DataView(r.buffer,r.byteOffset,r.byteLength);return t.getFloat32(e)}mt.readFloat32BE=x_;function S_(r,e){e===void 0&&(e=0);var t=new DataView(r.buffer,r.byteOffset,r.byteLength);return t.getFloat32(e,!0)}mt.readFloat32LE=S_;function M_(r,e){e===void 0&&(e=0);var t=new DataView(r.buffer,r.byteOffset,r.byteLength);return t.getFloat64(e)}mt.readFloat64BE=M_;function I_(r,e){e===void 0&&(e=0);var t=new DataView(r.buffer,r.byteOffset,r.byteLength);return t.getFloat64(e,!0)}mt.readFloat64LE=I_;function C_(r,e,t){e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat32(t,r),e}mt.writeFloat32BE=C_;function P_(r,e,t){e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat32(t,r,!0),e}mt.writeFloat32LE=P_;function O_(r,e,t){e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat64(t,r),e}mt.writeFloat64BE=O_;function T_(r,e,t){e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0);var i=new DataView(e.buffer,e.byteOffset,e.byteLength);return i.setFloat64(t,r,!0),e}mt.writeFloat64LE=T_;var xi={};Object.defineProperty(xi,"__esModule",{value:!0});function R_(r){for(var e=0;e<r.length;e++)r[e]=0;return r}xi.wipe=R_;Object.defineProperty(Rf,"__esModule",{value:!0});var Fr=mt,pd=xi,N_=20;function B_(r,e,t){for(var i=1634760805,n=857760878,a=2036477234,c=1797285236,f=t[3]<<24|t[2]<<16|t[1]<<8|t[0],g=t[7]<<24|t[6]<<16|t[5]<<8|t[4],d=t[11]<<24|t[10]<<16|t[9]<<8|t[8],m=t[15]<<24|t[14]<<16|t[13]<<8|t[12],w=t[19]<<24|t[18]<<16|t[17]<<8|t[16],O=t[23]<<24|t[22]<<16|t[21]<<8|t[20],C=t[27]<<24|t[26]<<16|t[25]<<8|t[24],P=t[31]<<24|t[30]<<16|t[29]<<8|t[28],q=e[3]<<24|e[2]<<16|e[1]<<8|e[0],K=e[7]<<24|e[6]<<16|e[5]<<8|e[4],Y=e[11]<<24|e[10]<<16|e[9]<<8|e[8],z=e[15]<<24|e[14]<<16|e[13]<<8|e[12],W=i,B=n,j=a,k=c,_=f,N=g,se=d,le=m,U=w,y=O,u=C,h=P,v=q,E=K,S=Y,M=z,x=0;x<N_;x+=2)W=W+_|0,v^=W,v=v>>>16|v<<16,U=U+v|0,_^=U,_=_>>>20|_<<12,B=B+N|0,E^=B,E=E>>>16|E<<16,y=y+E|0,N^=y,N=N>>>20|N<<12,j=j+se|0,S^=j,S=S>>>16|S<<16,u=u+S|0,se^=u,se=se>>>20|se<<12,k=k+le|0,M^=k,M=M>>>16|M<<16,h=h+M|0,le^=h,le=le>>>20|le<<12,j=j+se|0,S^=j,S=S>>>24|S<<8,u=u+S|0,se^=u,se=se>>>25|se<<7,k=k+le|0,M^=k,M=M>>>24|M<<8,h=h+M|0,le^=h,le=le>>>25|le<<7,B=B+N|0,E^=B,E=E>>>24|E<<8,y=y+E|0,N^=y,N=N>>>25|N<<7,W=W+_|0,v^=W,v=v>>>24|v<<8,U=U+v|0,_^=U,_=_>>>25|_<<7,W=W+N|0,M^=W,M=M>>>16|M<<16,u=u+M|0,N^=u,N=N>>>20|N<<12,B=B+se|0,v^=B,v=v>>>16|v<<16,h=h+v|0,se^=h,se=se>>>20|se<<12,j=j+le|0,E^=j,E=E>>>16|E<<16,U=U+E|0,le^=U,le=le>>>20|le<<12,k=k+_|0,S^=k,S=S>>>16|S<<16,y=y+S|0,_^=y,_=_>>>20|_<<12,j=j+le|0,E^=j,E=E>>>24|E<<8,U=U+E|0,le^=U,le=le>>>25|le<<7,k=k+_|0,S^=k,S=S>>>24|S<<8,y=y+S|0,_^=y,_=_>>>25|_<<7,B=B+se|0,v^=B,v=v>>>24|v<<8,h=h+v|0,se^=h,se=se>>>25|se<<7,W=W+N|0,M^=W,M=M>>>24|M<<8,u=u+M|0,N^=u,N=N>>>25|N<<7;Fr.writeUint32LE(W+i|0,r,0),Fr.writeUint32LE(B+n|0,r,4),Fr.writeUint32LE(j+a|0,r,8),Fr.writeUint32LE(k+c|0,r,12),Fr.writeUint32LE(_+f|0,r,16),Fr.writeUint32LE(N+g|0,r,20),Fr.writeUint32LE(se+d|0,r,24),Fr.writeUint32LE(le+m|0,r,28),Fr.writeUint32LE(U+w|0,r,32),Fr.writeUint32LE(y+O|0,r,36),Fr.writeUint32LE(u+C|0,r,40),Fr.writeUint32LE(h+P|0,r,44),Fr.writeUint32LE(v+q|0,r,48),Fr.writeUint32LE(E+K|0,r,52),Fr.writeUint32LE(S+Y|0,r,56),Fr.writeUint32LE(M+z|0,r,60)}function dv(r,e,t,i,n){if(n===void 0&&(n=0),r.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(i.length<t.length)throw new Error("ChaCha: destination is shorter than source");var a,c;if(n===0){if(e.length!==8&&e.length!==12)throw new Error("ChaCha nonce must be 8 or 12 bytes");a=new Uint8Array(16),c=a.length-e.length,a.set(e,c)}else{if(e.length!==16)throw new Error("ChaCha nonce with counter must be 16 bytes");a=e,c=n}for(var f=new Uint8Array(64),g=0;g<t.length;g+=64){B_(f,a,r);for(var d=g;d<g+64&&d<t.length;d++)i[d]=t[d]^f[d-g];U_(a,0,c)}return pd.wipe(f),n===0&&pd.wipe(a),i}Rf.streamXOR=dv;function $_(r,e,t,i){return i===void 0&&(i=0),pd.wipe(t),dv(r,e,t,t,i)}Rf.stream=$_;function U_(r,e,t){for(var i=1;t--;)i=i+(r[e]&255)|0,r[e]=i&255,i>>>=8,e++;if(i>0)throw new Error("ChaCha: counter overflow")}var pv={},js={};Object.defineProperty(js,"__esModule",{value:!0});function q_(r,e,t){return~(r-1)&e|r-1&t}js.select=q_;function L_(r,e){return(r|0)-(e|0)-1>>>31&1}js.lessOrEqual=L_;function gv(r,e){if(r.length!==e.length)return 0;for(var t=0,i=0;i<r.length;i++)t|=r[i]^e[i];return 1&t-1>>>8}js.compare=gv;function F_(r,e){return r.length===0||e.length===0?!1:gv(r,e)!==0}js.equal=F_;(function(r){Object.defineProperty(r,"__esModule",{value:!0});var e=js,t=xi;r.DIGEST_LENGTH=16;var i=function(){function c(f){this.digestLength=r.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 g=f[0]|f[1]<<8;this._r[0]=g&8191;var d=f[2]|f[3]<<8;this._r[1]=(g>>>13|d<<3)&8191;var m=f[4]|f[5]<<8;this._r[2]=(d>>>10|m<<6)&7939;var w=f[6]|f[7]<<8;this._r[3]=(m>>>7|w<<9)&8191;var O=f[8]|f[9]<<8;this._r[4]=(w>>>4|O<<12)&255,this._r[5]=O>>>1&8190;var C=f[10]|f[11]<<8;this._r[6]=(O>>>14|C<<2)&8191;var P=f[12]|f[13]<<8;this._r[7]=(C>>>11|P<<5)&8065;var q=f[14]|f[15]<<8;this._r[8]=(P>>>8|q<<8)&8191,this._r[9]=q>>>5&127,this._pad[0]=f[16]|f[17]<<8,this._pad[1]=f[18]|f[19]<<8,this._pad[2]=f[20]|f[21]<<8,this._pad[3]=f[22]|f[23]<<8,this._pad[4]=f[24]|f[25]<<8,this._pad[5]=f[26]|f[27]<<8,this._pad[6]=f[28]|f[29]<<8,this._pad[7]=f[30]|f[31]<<8}return c.prototype._blocks=function(f,g,d){for(var m=this._fin?0:2048,w=this._h[0],O=this._h[1],C=this._h[2],P=this._h[3],q=this._h[4],K=this._h[5],Y=this._h[6],z=this._h[7],W=this._h[8],B=this._h[9],j=this._r[0],k=this._r[1],_=this._r[2],N=this._r[3],se=this._r[4],le=this._r[5],U=this._r[6],y=this._r[7],u=this._r[8],h=this._r[9];d>=16;){var v=f[g+0]|f[g+1]<<8;w+=v&8191;var E=f[g+2]|f[g+3]<<8;O+=(v>>>13|E<<3)&8191;var S=f[g+4]|f[g+5]<<8;C+=(E>>>10|S<<6)&8191;var M=f[g+6]|f[g+7]<<8;P+=(S>>>7|M<<9)&8191;var x=f[g+8]|f[g+9]<<8;q+=(M>>>4|x<<12)&8191,K+=x>>>1&8191;var p=f[g+10]|f[g+11]<<8;Y+=(x>>>14|p<<2)&8191;var b=f[g+12]|f[g+13]<<8;z+=(p>>>11|b<<5)&8191;var R=f[g+14]|f[g+15]<<8;W+=(b>>>8|R<<8)&8191,B+=R>>>5|m;var Z=0,ae=Z;ae+=w*j,ae+=O*(5*h),ae+=C*(5*u),ae+=P*(5*y),ae+=q*(5*U),Z=ae>>>13,ae&=8191,ae+=K*(5*le),ae+=Y*(5*se),ae+=z*(5*N),ae+=W*(5*_),ae+=B*(5*k),Z+=ae>>>13,ae&=8191;var I=Z;I+=w*k,I+=O*j,I+=C*(5*h),I+=P*(5*u),I+=q*(5*y),Z=I>>>13,I&=8191,I+=K*(5*U),I+=Y*(5*le),I+=z*(5*se),I+=W*(5*N),I+=B*(5*_),Z+=I>>>13,I&=8191;var ee=Z;ee+=w*_,ee+=O*k,ee+=C*j,ee+=P*(5*h),ee+=q*(5*u),Z=ee>>>13,ee&=8191,ee+=K*(5*y),ee+=Y*(5*U),ee+=z*(5*le),ee+=W*(5*se),ee+=B*(5*N),Z+=ee>>>13,ee&=8191;var L=Z;L+=w*N,L+=O*_,L+=C*k,L+=P*j,L+=q*(5*h),Z=L>>>13,L&=8191,L+=K*(5*u),L+=Y*(5*y),L+=z*(5*U),L+=W*(5*le),L+=B*(5*se),Z+=L>>>13,L&=8191;var V=Z;V+=w*se,V+=O*N,V+=C*_,V+=P*k,V+=q*j,Z=V>>>13,V&=8191,V+=K*(5*h),V+=Y*(5*u),V+=z*(5*y),V+=W*(5*U),V+=B*(5*le),Z+=V>>>13,V&=8191;var G=Z;G+=w*le,G+=O*se,G+=C*N,G+=P*_,G+=q*k,Z=G>>>13,G&=8191,G+=K*j,G+=Y*(5*h),G+=z*(5*u),G+=W*(5*y),G+=B*(5*U),Z+=G>>>13,G&=8191;var D=Z;D+=w*U,D+=O*le,D+=C*se,D+=P*N,D+=q*_,Z=D>>>13,D&=8191,D+=K*k,D+=Y*j,D+=z*(5*h),D+=W*(5*u),D+=B*(5*y),Z+=D>>>13,D&=8191;var H=Z;H+=w*y,H+=O*U,H+=C*le,H+=P*se,H+=q*N,Z=H>>>13,H&=8191,H+=K*_,H+=Y*k,H+=z*j,H+=W*(5*h),H+=B*(5*u),Z+=H>>>13,H&=8191;var ne=Z;ne+=w*u,ne+=O*y,ne+=C*U,ne+=P*le,ne+=q*se,Z=ne>>>13,ne&=8191,ne+=K*N,ne+=Y*_,ne+=z*k,ne+=W*j,ne+=B*(5*h),Z+=ne>>>13,ne&=8191;var ce=Z;ce+=w*h,ce+=O*u,ce+=C*y,ce+=P*U,ce+=q*le,Z=ce>>>13,ce&=8191,ce+=K*se,ce+=Y*N,ce+=z*_,ce+=W*k,ce+=B*j,Z+=ce>>>13,ce&=8191,Z=(Z<<2)+Z|0,Z=Z+ae|0,ae=Z&8191,Z=Z>>>13,I+=Z,w=ae,O=I,C=ee,P=L,q=V,K=G,Y=D,z=H,W=ne,B=ce,g+=16,d-=16}this._h[0]=w,this._h[1]=O,this._h[2]=C,this._h[3]=P,this._h[4]=q,this._h[5]=K,this._h[6]=Y,this._h[7]=z,this._h[8]=W,this._h[9]=B},c.prototype.finish=function(f,g){g===void 0&&(g=0);var d=new Uint16Array(10),m,w,O,C;if(this._leftover){for(C=this._leftover,this._buffer[C++]=1;C<16;C++)this._buffer[C]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(m=this._h[1]>>>13,this._h[1]&=8191,C=2;C<10;C++)this._h[C]+=m,m=this._h[C]>>>13,this._h[C]&=8191;for(this._h[0]+=m*5,m=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=m,m=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=m,d[0]=this._h[0]+5,m=d[0]>>>13,d[0]&=8191,C=1;C<10;C++)d[C]=this._h[C]+m,m=d[C]>>>13,d[C]&=8191;for(d[9]-=8192,w=(m^1)-1,C=0;C<10;C++)d[C]&=w;for(w=~w,C=0;C<10;C++)this._h[C]=this._h[C]&w|d[C];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,O=this._h[0]+this._pad[0],this._h[0]=O&65535,C=1;C<8;C++)O=(this._h[C]+this._pad[C]|0)+(O>>>16)|0,this._h[C]=O&65535;return f[g+0]=this._h[0]>>>0,f[g+1]=this._h[0]>>>8,f[g+2]=this._h[1]>>>0,f[g+3]=this._h[1]>>>8,f[g+4]=this._h[2]>>>0,f[g+5]=this._h[2]>>>8,f[g+6]=this._h[3]>>>0,f[g+7]=this._h[3]>>>8,f[g+8]=this._h[4]>>>0,f[g+9]=this._h[4]>>>8,f[g+10]=this._h[5]>>>0,f[g+11]=this._h[5]>>>8,f[g+12]=this._h[6]>>>0,f[g+13]=this._h[6]>>>8,f[g+14]=this._h[7]>>>0,f[g+15]=this._h[7]>>>8,this._finished=!0,this},c.prototype.update=function(f){var g=0,d=f.length,m;if(this._leftover){m=16-this._leftover,m>d&&(m=d);for(var w=0;w<m;w++)this._buffer[this._leftover+w]=f[g+w];if(d-=m,g+=m,this._leftover+=m,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(d>=16&&(m=d-d%16,this._blocks(f,g,m),g+=m,d-=m),d){for(var w=0;w<d;w++)this._buffer[this._leftover+w]=f[g+w];this._leftover+=d}return this},c.prototype.digest=function(){if(this._finished)throw new Error("Poly1305 was finished");var f=new Uint8Array(16);return this.finish(f),f},c.prototype.clean=function(){return t.wipe(this._buffer),t.wipe(this._r),t.wipe(this._h),t.wipe(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this},c}();r.Poly1305=i;function n(c,f){var g=new i(c);g.update(f);var d=g.digest();return g.clean(),d}r.oneTimeAuth=n;function a(c,f){return c.length!==r.DIGEST_LENGTH||f.length!==r.DIGEST_LENGTH?!1:e.equal(c,f)}r.equal=a})(pv);(function(r){Object.defineProperty(r,"__esModule",{value:!0});var e=Rf,t=pv,i=xi,n=mt,a=js;r.KEY_LENGTH=32,r.NONCE_LENGTH=12,r.TAG_LENGTH=16;var c=new Uint8Array(16),f=function(){function g(d){if(this.nonceLength=r.NONCE_LENGTH,this.tagLength=r.TAG_LENGTH,d.length!==r.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(d)}return g.prototype.seal=function(d,m,w,O){if(d.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var C=new Uint8Array(16);C.set(d,C.length-d.length);var P=new Uint8Array(32);e.stream(this._key,C,P,4);var q=m.length+this.tagLength,K;if(O){if(O.length!==q)throw new Error("ChaCha20Poly1305: incorrect destination length");K=O}else K=new Uint8Array(q);return e.streamXOR(this._key,C,m,K,4),this._authenticate(K.subarray(K.length-this.tagLength,K.length),P,K.subarray(0,K.length-this.tagLength),w),i.wipe(C),K},g.prototype.open=function(d,m,w,O){if(d.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(m.length<this.tagLength)return null;var C=new Uint8Array(16);C.set(d,C.length-d.length);var P=new Uint8Array(32);e.stream(this._key,C,P,4);var q=new Uint8Array(this.tagLength);if(this._authenticate(q,P,m.subarray(0,m.length-this.tagLength),w),!a.equal(q,m.subarray(m.length-this.tagLength,m.length)))return null;var K=m.length-this.tagLength,Y;if(O){if(O.length!==K)throw new Error("ChaCha20Poly1305: incorrect destination length");Y=O}else Y=new Uint8Array(K);return e.streamXOR(this._key,C,m.subarray(0,m.length-this.tagLength),Y,4),i.wipe(C),Y},g.prototype.clean=function(){return i.wipe(this._key),this},g.prototype._authenticate=function(d,m,w,O){var C=new t.Poly1305(m);O&&(C.update(O),O.length%16>0&&C.update(c.subarray(O.length%16))),C.update(w),w.length%16>0&&C.update(c.subarray(w.length%16));var P=new Uint8Array(8);O&&n.writeUint64LE(O.length,P),C.update(P),n.writeUint64LE(w.length,P),C.update(P);for(var q=C.digest(),K=0;K<q.length;K++)d[K]=q[K];C.clean(),i.wipe(q),i.wipe(P)},g}();r.ChaCha20Poly1305=f})(Hd);var bv={},xc={},Kd={};Object.defineProperty(Kd,"__esModule",{value:!0});function z_(r){return typeof r.saveState<"u"&&typeof r.restoreState<"u"&&typeof r.cleanSavedState<"u"}Kd.isSerializableHash=z_;Object.defineProperty(xc,"__esModule",{value:!0});var An=Kd,j_=js,k_=xi,vv=function(){function r(e,t){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);t.length>this.blockSize?this._inner.update(t).finish(i).clean():i.set(t);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),An.isSerializableHash(this._inner)&&An.isSerializableHash(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),k_.wipe(i)}return r.prototype.reset=function(){if(!An.isSerializableHash(this._inner)||!An.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},r.prototype.clean=function(){An.isSerializableHash(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),An.isSerializableHash(this._outer)&&this._outer.cleanSavedState(this._outerKeyedState),this._inner.clean(),this._outer.clean()},r.prototype.update=function(e){return this._inner.update(e),this},r.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)},r.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},r.prototype.saveState=function(){if(!An.isSerializableHash(this._inner))throw new Error("hmac: can't saveState() because hash doesn't implement it");return this._inner.saveState()},r.prototype.restoreState=function(e){if(!An.isSerializableHash(this._inner)||!An.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},r.prototype.cleanSavedState=function(e){if(!An.isSerializableHash(this._inner))throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it");this._inner.cleanSavedState(e)},r}();xc.HMAC=vv;function H_(r,e,t){var i=new vv(r,e);i.update(t);var n=i.digest();return i.clean(),n}xc.hmac=H_;xc.equal=j_.equal;Object.defineProperty(bv,"__esModule",{value:!0});var T1=xc,R1=xi,K_=function(){function r(e,t,i,n){i===void 0&&(i=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=n;var a=T1.hmac(this._hash,i,t);this._hmac=new T1.HMAC(e,a),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return r.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},r.prototype.expand=function(e){for(var t=new Uint8Array(e),i=0;i<t.length;i++)this._bufpos===this._buffer.length&&this._fillBuffer(),t[i]=this._buffer[this._bufpos++];return t},r.prototype.clean=function(){this._hmac.clean(),R1.wipe(this._buffer),R1.wipe(this._counter),this._bufpos=0},r}(),V_=bv.HKDF=K_,ks={},Nf={},Bf={};Object.defineProperty(Bf,"__esModule",{value:!0});Bf.BrowserRandomSource=void 0;const N1=65536;class G_{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 t=new Uint8Array(e);for(let i=0;i<t.length;i+=N1)this._crypto.getRandomValues(t.subarray(i,i+Math.min(t.length-i,N1)));return t}}Bf.BrowserRandomSource=G_;function J_(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var $f={};Object.defineProperty($f,"__esModule",{value:!0});$f.NodeRandomSource=void 0;const W_=xi;class Y_{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof J_<"u"){const e=zd;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 t=this._crypto.randomBytes(e);if(t.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]=t[n];return(0,W_.wipe)(t),i}}$f.NodeRandomSource=Y_;Object.defineProperty(Nf,"__esModule",{value:!0});Nf.SystemRandomSource=void 0;const Q_=Bf,X_=$f;class Z_{constructor(){if(this.isAvailable=!1,this.name="",this._source=new Q_.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new X_.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)}}Nf.SystemRandomSource=Z_;(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.randomStringForEntropy=r.randomString=r.randomUint32=r.randomBytes=r.defaultRandomSource=void 0;const e=Nf,t=mt,i=xi;r.defaultRandomSource=new e.SystemRandomSource;function n(d,m=r.defaultRandomSource){return m.randomBytes(d)}r.randomBytes=n;function a(d=r.defaultRandomSource){const m=n(4,d),w=(0,t.readUint32LE)(m);return(0,i.wipe)(m),w}r.randomUint32=a;const c="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function f(d,m=c,w=r.defaultRandomSource){if(m.length<2)throw new Error("randomString charset is too short");if(m.length>256)throw new Error("randomString charset is too long");let O="";const C=m.length,P=256-256%C;for(;d>0;){const q=n(Math.ceil(d*256/P),w);for(let K=0;K<q.length&&d>0;K++){const Y=q[K];Y<P&&(O+=m.charAt(Y%C),d--)}(0,i.wipe)(q)}return O}r.randomString=f;function g(d,m=c,w=r.defaultRandomSource){const O=Math.ceil(d/(Math.log(m.length)/Math.LN2));return f(O,m,w)}r.randomStringForEntropy=g})(ks);var Sc={};(function(r){Object.defineProperty(r,"__esModule",{value:!0});var e=mt,t=xi;r.DIGEST_LENGTH=32,r.BLOCK_SIZE=64;var i=function(){function f(){this.digestLength=r.DIGEST_LENGTH,this.blockSize=r.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 f.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},f.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},f.prototype.clean=function(){t.wipe(this._buffer),t.wipe(this._temp),this.reset()},f.prototype.update=function(g,d){if(d===void 0&&(d=g.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var m=0;if(this._bytesHashed+=d,this._bufferLength>0){for(;this._bufferLength<this.blockSize&&d>0;)this._buffer[this._bufferLength++]=g[m++],d--;this._bufferLength===this.blockSize&&(a(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(d>=this.blockSize&&(m=a(this._temp,this._state,g,m,d),d%=this.blockSize);d>0;)this._buffer[this._bufferLength++]=g[m++],d--;return this},f.prototype.finish=function(g){if(!this._finished){var d=this._bytesHashed,m=this._bufferLength,w=d/536870912|0,O=d<<3,C=d%64<56?64:128;this._buffer[m]=128;for(var P=m+1;P<C-8;P++)this._buffer[P]=0;e.writeUint32BE(w,this._buffer,C-8),e.writeUint32BE(O,this._buffer,C-4),a(this._temp,this._state,this._buffer,0,C),this._finished=!0}for(var P=0;P<this.digestLength/4;P++)e.writeUint32BE(this._state[P],g,P*4);return this},f.prototype.digest=function(){var g=new Uint8Array(this.digestLength);return this.finish(g),g},f.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}},f.prototype.restoreState=function(g){return this._state.set(g.state),this._bufferLength=g.bufferLength,g.buffer&&this._buffer.set(g.buffer),this._bytesHashed=g.bytesHashed,this._finished=!1,this},f.prototype.cleanSavedState=function(g){t.wipe(g.state),g.buffer&&t.wipe(g.buffer),g.bufferLength=0,g.bytesHashed=0},f}();r.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 a(f,g,d,m,w){for(;w>=64;){for(var O=g[0],C=g[1],P=g[2],q=g[3],K=g[4],Y=g[5],z=g[6],W=g[7],B=0;B<16;B++){var j=m+B*4;f[B]=e.readUint32BE(d,j)}for(var B=16;B<64;B++){var k=f[B-2],_=(k>>>17|k<<15)^(k>>>19|k<<13)^k>>>10;k=f[B-15];var N=(k>>>7|k<<25)^(k>>>18|k<<14)^k>>>3;f[B]=(_+f[B-7]|0)+(N+f[B-16]|0)}for(var B=0;B<64;B++){var _=(((K>>>6|K<<26)^(K>>>11|K<<21)^(K>>>25|K<<7))+(K&Y^~K&z)|0)+(W+(n[B]+f[B]|0)|0)|0,N=((O>>>2|O<<30)^(O>>>13|O<<19)^(O>>>22|O<<10))+(O&C^O&P^C&P)|0;W=z,z=Y,Y=K,K=q+_|0,q=P,P=C,C=O,O=_+N|0}g[0]+=O,g[1]+=C,g[2]+=P,g[3]+=q,g[4]+=K,g[5]+=Y,g[6]+=z,g[7]+=W,m+=64,w-=64}return m}function c(f){var g=new i;g.update(f);var d=g.digest();return g.clean(),d}r.hash=c})(Sc);var Vd={};(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.sharedKey=r.generateKeyPair=r.generateKeyPairFromSeed=r.scalarMultBase=r.scalarMult=r.SHARED_KEY_LENGTH=r.SECRET_KEY_LENGTH=r.PUBLIC_KEY_LENGTH=void 0;const e=ks,t=xi;r.PUBLIC_KEY_LENGTH=32,r.SECRET_KEY_LENGTH=32,r.SHARED_KEY_LENGTH=32;function i(B){const j=new Float64Array(16);if(B)for(let k=0;k<B.length;k++)j[k]=B[k];return j}const n=new Uint8Array(32);n[0]=9;const a=i([56129,1]);function c(B){let j=1;for(let k=0;k<16;k++){let _=B[k]+j+65535;j=Math.floor(_/65536),B[k]=_-j*65536}B[0]+=j-1+37*(j-1)}function f(B,j,k){const _=~(k-1);for(let N=0;N<16;N++){const se=_&(B[N]^j[N]);B[N]^=se,j[N]^=se}}function g(B,j){const k=i(),_=i();for(let N=0;N<16;N++)_[N]=j[N];c(_),c(_),c(_);for(let N=0;N<2;N++){k[0]=_[0]-65517;for(let le=1;le<15;le++)k[le]=_[le]-65535-(k[le-1]>>16&1),k[le-1]&=65535;k[15]=_[15]-32767-(k[14]>>16&1);const se=k[15]>>16&1;k[14]&=65535,f(_,k,1-se)}for(let N=0;N<16;N++)B[2*N]=_[N]&255,B[2*N+1]=_[N]>>8}function d(B,j){for(let k=0;k<16;k++)B[k]=j[2*k]+(j[2*k+1]<<8);B[15]&=32767}function m(B,j,k){for(let _=0;_<16;_++)B[_]=j[_]+k[_]}function w(B,j,k){for(let _=0;_<16;_++)B[_]=j[_]-k[_]}function O(B,j,k){let _,N,se=0,le=0,U=0,y=0,u=0,h=0,v=0,E=0,S=0,M=0,x=0,p=0,b=0,R=0,Z=0,ae=0,I=0,ee=0,L=0,V=0,G=0,D=0,H=0,ne=0,ce=0,fe=0,ye=0,we=0,Te=0,Qe=0,Ce=0,Re=k[0],Se=k[1],me=k[2],Pe=k[3],Ne=k[4],be=k[5],Oe=k[6],xe=k[7],ve=k[8],qe=k[9],Me=k[10],_e=k[11],He=k[12],Ve=k[13],Ee=k[14],Ke=k[15];_=j[0],se+=_*Re,le+=_*Se,U+=_*me,y+=_*Pe,u+=_*Ne,h+=_*be,v+=_*Oe,E+=_*xe,S+=_*ve,M+=_*qe,x+=_*Me,p+=_*_e,b+=_*He,R+=_*Ve,Z+=_*Ee,ae+=_*Ke,_=j[1],le+=_*Re,U+=_*Se,y+=_*me,u+=_*Pe,h+=_*Ne,v+=_*be,E+=_*Oe,S+=_*xe,M+=_*ve,x+=_*qe,p+=_*Me,b+=_*_e,R+=_*He,Z+=_*Ve,ae+=_*Ee,I+=_*Ke,_=j[2],U+=_*Re,y+=_*Se,u+=_*me,h+=_*Pe,v+=_*Ne,E+=_*be,S+=_*Oe,M+=_*xe,x+=_*ve,p+=_*qe,b+=_*Me,R+=_*_e,Z+=_*He,ae+=_*Ve,I+=_*Ee,ee+=_*Ke,_=j[3],y+=_*Re,u+=_*Se,h+=_*me,v+=_*Pe,E+=_*Ne,S+=_*be,M+=_*Oe,x+=_*xe,p+=_*ve,b+=_*qe,R+=_*Me,Z+=_*_e,ae+=_*He,I+=_*Ve,ee+=_*Ee,L+=_*Ke,_=j[4],u+=_*Re,h+=_*Se,v+=_*me,E+=_*Pe,S+=_*Ne,M+=_*be,x+=_*Oe,p+=_*xe,b+=_*ve,R+=_*qe,Z+=_*Me,ae+=_*_e,I+=_*He,ee+=_*Ve,L+=_*Ee,V+=_*Ke,_=j[5],h+=_*Re,v+=_*Se,E+=_*me,S+=_*Pe,M+=_*Ne,x+=_*be,p+=_*Oe,b+=_*xe,R+=_*ve,Z+=_*qe,ae+=_*Me,I+=_*_e,ee+=_*He,L+=_*Ve,V+=_*Ee,G+=_*Ke,_=j[6],v+=_*Re,E+=_*Se,S+=_*me,M+=_*Pe,x+=_*Ne,p+=_*be,b+=_*Oe,R+=_*xe,Z+=_*ve,ae+=_*qe,I+=_*Me,ee+=_*_e,L+=_*He,V+=_*Ve,G+=_*Ee,D+=_*Ke,_=j[7],E+=_*Re,S+=_*Se,M+=_*me,x+=_*Pe,p+=_*Ne,b+=_*be,R+=_*Oe,Z+=_*xe,ae+=_*ve,I+=_*qe,ee+=_*Me,L+=_*_e,V+=_*He,G+=_*Ve,D+=_*Ee,H+=_*Ke,_=j[8],S+=_*Re,M+=_*Se,x+=_*me,p+=_*Pe,b+=_*Ne,R+=_*be,Z+=_*Oe,ae+=_*xe,I+=_*ve,ee+=_*qe,L+=_*Me,V+=_*_e,G+=_*He,D+=_*Ve,H+=_*Ee,ne+=_*Ke,_=j[9],M+=_*Re,x+=_*Se,p+=_*me,b+=_*Pe,R+=_*Ne,Z+=_*be,ae+=_*Oe,I+=_*xe,ee+=_*ve,L+=_*qe,V+=_*Me,G+=_*_e,D+=_*He,H+=_*Ve,ne+=_*Ee,ce+=_*Ke,_=j[10],x+=_*Re,p+=_*Se,b+=_*me,R+=_*Pe,Z+=_*Ne,ae+=_*be,I+=_*Oe,ee+=_*xe,L+=_*ve,V+=_*qe,G+=_*Me,D+=_*_e,H+=_*He,ne+=_*Ve,ce+=_*Ee,fe+=_*Ke,_=j[11],p+=_*Re,b+=_*Se,R+=_*me,Z+=_*Pe,ae+=_*Ne,I+=_*be,ee+=_*Oe,L+=_*xe,V+=_*ve,G+=_*qe,D+=_*Me,H+=_*_e,ne+=_*He,ce+=_*Ve,fe+=_*Ee,ye+=_*Ke,_=j[12],b+=_*Re,R+=_*Se,Z+=_*me,ae+=_*Pe,I+=_*Ne,ee+=_*be,L+=_*Oe,V+=_*xe,G+=_*ve,D+=_*qe,H+=_*Me,ne+=_*_e,ce+=_*He,fe+=_*Ve,ye+=_*Ee,we+=_*Ke,_=j[13],R+=_*Re,Z+=_*Se,ae+=_*me,I+=_*Pe,ee+=_*Ne,L+=_*be,V+=_*Oe,G+=_*xe,D+=_*ve,H+=_*qe,ne+=_*Me,ce+=_*_e,fe+=_*He,ye+=_*Ve,we+=_*Ee,Te+=_*Ke,_=j[14],Z+=_*Re,ae+=_*Se,I+=_*me,ee+=_*Pe,L+=_*Ne,V+=_*be,G+=_*Oe,D+=_*xe,H+=_*ve,ne+=_*qe,ce+=_*Me,fe+=_*_e,ye+=_*He,we+=_*Ve,Te+=_*Ee,Qe+=_*Ke,_=j[15],ae+=_*Re,I+=_*Se,ee+=_*me,L+=_*Pe,V+=_*Ne,G+=_*be,D+=_*Oe,H+=_*xe,ne+=_*ve,ce+=_*qe,fe+=_*Me,ye+=_*_e,we+=_*He,Te+=_*Ve,Qe+=_*Ee,Ce+=_*Ke,se+=38*I,le+=38*ee,U+=38*L,y+=38*V,u+=38*G,h+=38*D,v+=38*H,E+=38*ne,S+=38*ce,M+=38*fe,x+=38*ye,p+=38*we,b+=38*Te,R+=38*Qe,Z+=38*Ce,N=1,_=se+N+65535,N=Math.floor(_/65536),se=_-N*65536,_=le+N+65535,N=Math.floor(_/65536),le=_-N*65536,_=U+N+65535,N=Math.floor(_/65536),U=_-N*65536,_=y+N+65535,N=Math.floor(_/65536),y=_-N*65536,_=u+N+65535,N=Math.floor(_/65536),u=_-N*65536,_=h+N+65535,N=Math.floor(_/65536),h=_-N*65536,_=v+N+65535,N=Math.floor(_/65536),v=_-N*65536,_=E+N+65535,N=Math.floor(_/65536),E=_-N*65536,_=S+N+65535,N=Math.floor(_/65536),S=_-N*65536,_=M+N+65535,N=Math.floor(_/65536),M=_-N*65536,_=x+N+65535,N=Math.floor(_/65536),x=_-N*65536,_=p+N+65535,N=Math.floor(_/65536),p=_-N*65536,_=b+N+65535,N=Math.floor(_/65536),b=_-N*65536,_=R+N+65535,N=Math.floor(_/65536),R=_-N*65536,_=Z+N+65535,N=Math.floor(_/65536),Z=_-N*65536,_=ae+N+65535,N=Math.floor(_/65536),ae=_-N*65536,se+=N-1+37*(N-1),N=1,_=se+N+65535,N=Math.floor(_/65536),se=_-N*65536,_=le+N+65535,N=Math.floor(_/65536),le=_-N*65536,_=U+N+65535,N=Math.floor(_/65536),U=_-N*65536,_=y+N+65535,N=Math.floor(_/65536),y=_-N*65536,_=u+N+65535,N=Math.floor(_/65536),u=_-N*65536,_=h+N+65535,N=Math.floor(_/65536),h=_-N*65536,_=v+N+65535,N=Math.floor(_/65536),v=_-N*65536,_=E+N+65535,N=Math.floor(_/65536),E=_-N*65536,_=S+N+65535,N=Math.floor(_/65536),S=_-N*65536,_=M+N+65535,N=Math.floor(_/65536),M=_-N*65536,_=x+N+65535,N=Math.floor(_/65536),x=_-N*65536,_=p+N+65535,N=Math.floor(_/65536),p=_-N*65536,_=b+N+65535,N=Math.floor(_/65536),b=_-N*65536,_=R+N+65535,N=Math.floor(_/65536),R=_-N*65536,_=Z+N+65535,N=Math.floor(_/65536),Z=_-N*65536,_=ae+N+65535,N=Math.floor(_/65536),ae=_-N*65536,se+=N-1+37*(N-1),B[0]=se,B[1]=le,B[2]=U,B[3]=y,B[4]=u,B[5]=h,B[6]=v,B[7]=E,B[8]=S,B[9]=M,B[10]=x,B[11]=p,B[12]=b,B[13]=R,B[14]=Z,B[15]=ae}function C(B,j){O(B,j,j)}function P(B,j){const k=i();for(let _=0;_<16;_++)k[_]=j[_];for(let _=253;_>=0;_--)C(k,k),_!==2&&_!==4&&O(k,k,j);for(let _=0;_<16;_++)B[_]=k[_]}function q(B,j){const k=new Uint8Array(32),_=new Float64Array(80),N=i(),se=i(),le=i(),U=i(),y=i(),u=i();for(let S=0;S<31;S++)k[S]=B[S];k[31]=B[31]&127|64,k[0]&=248,d(_,j);for(let S=0;S<16;S++)se[S]=_[S];N[0]=U[0]=1;for(let S=254;S>=0;--S){const M=k[S>>>3]>>>(S&7)&1;f(N,se,M),f(le,U,M),m(y,N,le),w(N,N,le),m(le,se,U),w(se,se,U),C(U,y),C(u,N),O(N,le,N),O(le,se,y),m(y,N,le),w(N,N,le),C(se,N),w(le,U,u),O(N,le,a),m(N,N,U),O(le,le,N),O(N,U,u),O(U,se,_),C(se,y),f(N,se,M),f(le,U,M)}for(let S=0;S<16;S++)_[S+16]=N[S],_[S+32]=le[S],_[S+48]=se[S],_[S+64]=U[S];const h=_.subarray(32),v=_.subarray(16);P(h,h),O(v,v,h);const E=new Uint8Array(32);return g(E,v),E}r.scalarMult=q;function K(B){return q(B,n)}r.scalarMultBase=K;function Y(B){if(B.length!==r.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${r.SECRET_KEY_LENGTH} bytes`);const j=new Uint8Array(B);return{publicKey:K(j),secretKey:j}}r.generateKeyPairFromSeed=Y;function z(B){const j=(0,e.randomBytes)(32,B),k=Y(j);return(0,t.wipe)(j),k}r.generateKeyPair=z;function W(B,j,k=!1){if(B.length!==r.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(j.length!==r.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");const _=q(B,j);if(k){let N=0;for(let se=0;se<_.length;se++)N|=_[se];if(N===0)throw new Error("X25519: invalid shared key")}return _}r.sharedKey=W})(Vd);function mv(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function yl(r,e){e||(e=r.reduce((n,a)=>n+a.length,0));const t=mv(e);let i=0;for(const n of r)t.set(n,i),i+=n.length;return t}function e7(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i<t.length;i++)t[i]=255;for(var n=0;n<r.length;n++){var a=r.charAt(n),c=a.charCodeAt(0);if(t[c]!==255)throw new TypeError(a+" is ambiguous");t[c]=n}var f=r.length,g=r.charAt(0),d=Math.log(f)/Math.log(256),m=Math.log(256)/Math.log(f);function w(P){if(P instanceof Uint8Array||(ArrayBuffer.isView(P)?P=new Uint8Array(P.buffer,P.byteOffset,P.byteLength):Array.isArray(P)&&(P=Uint8Array.from(P))),!(P instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(P.length===0)return"";for(var q=0,K=0,Y=0,z=P.length;Y!==z&&P[Y]===0;)Y++,q++;for(var W=(z-Y)*m+1>>>0,B=new Uint8Array(W);Y!==z;){for(var j=P[Y],k=0,_=W-1;(j!==0||k<K)&&_!==-1;_--,k++)j+=256*B[_]>>>0,B[_]=j%f>>>0,j=j/f>>>0;if(j!==0)throw new Error("Non-zero carry");K=k,Y++}for(var N=W-K;N!==W&&B[N]===0;)N++;for(var se=g.repeat(q);N<W;++N)se+=r.charAt(B[N]);return se}function O(P){if(typeof P!="string")throw new TypeError("Expected String");if(P.length===0)return new Uint8Array;var q=0;if(P[q]!==" "){for(var K=0,Y=0;P[q]===g;)K++,q++;for(var z=(P.length-q)*d+1>>>0,W=new Uint8Array(z);P[q];){var B=t[P.charCodeAt(q)];if(B===255)return;for(var j=0,k=z-1;(B!==0||j<Y)&&k!==-1;k--,j++)B+=f*W[k]>>>0,W[k]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");Y=j,q++}if(P[q]!==" "){for(var _=z-Y;_!==z&&W[_]===0;)_++;for(var N=new Uint8Array(K+(z-_)),se=K;_!==z;)N[se++]=W[_++];return N}}}function C(P){var q=O(P);if(q)return q;throw new Error(`Non-${e} character`)}return{encode:w,decodeUnsafe:O,decode:C}}var t7=e7,r7=t7;const i7=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},n7=r=>new TextEncoder().encode(r),s7=r=>new TextDecoder().decode(r);let a7=class{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},o7=class{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.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 yv(this,e)}},c7=class{constructor(e){this.decoders=e}or(e){return yv(this,e)}decode(e){const t=e[0],i=this.decoders[t];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 yv=(r,e)=>new c7({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}});let u7=class{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new a7(e,t,i),this.decoder=new o7(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};const Uf=({name:r,prefix:e,encode:t,decode:i})=>new u7(r,e,t,i),Mc=({prefix:r,name:e,alphabet:t})=>{const{encode:i,decode:n}=r7(t,e);return Uf({prefix:r,name:e,encode:i,decode:a=>i7(n(a))})},f7=(r,e,t,i)=>{const n={};for(let m=0;m<e.length;++m)n[e[m]]=m;let a=r.length;for(;r[a-1]==="=";)--a;const c=new Uint8Array(a*t/8|0);let f=0,g=0,d=0;for(let m=0;m<a;++m){const w=n[r[m]];if(w===void 0)throw new SyntaxError(`Non-${i} character`);g=g<<t|w,f+=t,f>=8&&(f-=8,c[d++]=255&g>>f)}if(f>=t||255&g<<8-f)throw new SyntaxError("Unexpected end of data");return c},h7=(r,e,t)=>{const i=e[e.length-1]==="=",n=(1<<t)-1;let a="",c=0,f=0;for(let g=0;g<r.length;++g)for(f=f<<8|r[g],c+=8;c>t;)c-=t,a+=e[n&f>>c];if(c&&(a+=e[n&f<<t-c]),i)for(;a.length*t&7;)a+="=";return a},Ir=({name:r,prefix:e,bitsPerChar:t,alphabet:i})=>Uf({prefix:e,name:r,encode(n){return h7(n,i,t)},decode(n){return f7(n,i,t,r)}}),l7=Uf({prefix:"\0",name:"identity",encode:r=>s7(r),decode:r=>n7(r)}),d7=Object.freeze(Object.defineProperty({__proto__:null,identity:l7},Symbol.toStringTag,{value:"Module"})),p7=Ir({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),g7=Object.freeze(Object.defineProperty({__proto__:null,base2:p7},Symbol.toStringTag,{value:"Module"})),b7=Ir({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),v7=Object.freeze(Object.defineProperty({__proto__:null,base8:b7},Symbol.toStringTag,{value:"Module"})),m7=Mc({prefix:"9",name:"base10",alphabet:"0123456789"}),y7=Object.freeze(Object.defineProperty({__proto__:null,base10:m7},Symbol.toStringTag,{value:"Module"})),w7=Ir({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),_7=Ir({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),D7=Object.freeze(Object.defineProperty({__proto__:null,base16:w7,base16upper:_7},Symbol.toStringTag,{value:"Module"})),E7=Ir({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),A7=Ir({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),x7=Ir({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),S7=Ir({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),M7=Ir({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),I7=Ir({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),C7=Ir({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),P7=Ir({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),O7=Ir({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),T7=Object.freeze(Object.defineProperty({__proto__:null,base32:E7,base32hex:M7,base32hexpad:C7,base32hexpadupper:P7,base32hexupper:I7,base32pad:x7,base32padupper:S7,base32upper:A7,base32z:O7},Symbol.toStringTag,{value:"Module"})),R7=Mc({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),N7=Mc({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),B7=Object.freeze(Object.defineProperty({__proto__:null,base36:R7,base36upper:N7},Symbol.toStringTag,{value:"Module"})),$7=Mc({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),U7=Mc({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),q7=Object.freeze(Object.defineProperty({__proto__:null,base58btc:$7,base58flickr:U7},Symbol.toStringTag,{value:"Module"})),L7=Ir({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),F7=Ir({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),z7=Ir({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),j7=Ir({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),k7=Object.freeze(Object.defineProperty({__proto__:null,base64:L7,base64pad:F7,base64url:z7,base64urlpad:j7},Symbol.toStringTag,{value:"Module"})),wv=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),H7=wv.reduce((r,e,t)=>(r[t]=e,r),[]),K7=wv.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function V7(r){return r.reduce((e,t)=>(e+=H7[t],e),"")}function G7(r){const e=[];for(const t of r){const i=K7[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}const J7=Uf({prefix:"🚀",name:"base256emoji",encode:V7,decode:G7}),W7=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:J7},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const B1={...d7,...g7,...v7,...y7,...D7,...T7,...B7,...q7,...k7,...W7};function _v(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}const $1=_v("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),wl=_v("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);const e=mv(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),Dv={utf8:$1,"utf-8":$1,hex:B1.base16,latin1:wl,ascii:wl,binary:wl,...B1};function Hi(r,e="utf8"){const t=Dv[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r,"utf8"):t.decoder.decode(`${t.prefix}${r}`)}function Di(r,e="utf8"){const t=Dv[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}var Ev={};const Y7="elliptic",Q7="6.6.0",X7="EC cryptography",Z7="lib/elliptic.js",e9=["lib"],t9={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/"},r9={type:"git",url:"git@github.com:indutny/elliptic"},i9=["EC","Elliptic","curve","Cryptography"],n9="Fedor Indutny <fedor@indutny.com>",s9="MIT",a9={url:"https://github.com/indutny/elliptic/issues"},o9="https://github.com/indutny/elliptic",c9={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"},u9={"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"},f9={name:Y7,version:Q7,description:X7,main:Z7,files:e9,scripts:t9,repository:r9,keywords:i9,author:n9,license:s9,bugs:a9,homepage:o9,devDependencies:c9,dependencies:u9};var Si={},Gd={exports:{}};Gd.exports;(function(r){(function(e,t){function i(U,y){if(!U)throw new Error(y||"Assertion failed")}function n(U,y){U.super_=y;var u=function(){};u.prototype=y.prototype,U.prototype=new u,U.prototype.constructor=U}function a(U,y,u){if(a.isBN(U))return U;this.negative=0,this.words=null,this.length=0,this.red=null,U!==null&&((y==="le"||y==="be")&&(u=y,y=10),this._init(U||0,y||10,u||"be"))}typeof e=="object"?e.exports=a:t.BN=a,a.BN=a,a.wordSize=26;var c;try{typeof window<"u"&&typeof window.Buffer<"u"?c=window.Buffer:c=zd.Buffer}catch{}a.isBN=function(y){return y instanceof a?!0:y!==null&&typeof y=="object"&&y.constructor.wordSize===a.wordSize&&Array.isArray(y.words)},a.max=function(y,u){return y.cmp(u)>0?y:u},a.min=function(y,u){return y.cmp(u)<0?y:u},a.prototype._init=function(y,u,h){if(typeof y=="number")return this._initNumber(y,u,h);if(typeof y=="object")return this._initArray(y,u,h);u==="hex"&&(u=16),i(u===(u|0)&&u>=2&&u<=36),y=y.toString().replace(/\s+/g,"");var v=0;y[0]==="-"&&(v++,this.negative=1),v<y.length&&(u===16?this._parseHex(y,v,h):(this._parseBase(y,u,v),h==="le"&&this._initArray(this.toArray(),u,h)))},a.prototype._initNumber=function(y,u,h){y<0&&(this.negative=1,y=-y),y<67108864?(this.words=[y&67108863],this.length=1):y<4503599627370496?(this.words=[y&67108863,y/67108864&67108863],this.length=2):(i(y<9007199254740992),this.words=[y&67108863,y/67108864&67108863,1],this.length=3),h==="le"&&this._initArray(this.toArray(),u,h)},a.prototype._initArray=function(y,u,h){if(i(typeof y.length=="number"),y.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(y.length/3),this.words=new Array(this.length);for(var v=0;v<this.length;v++)this.words[v]=0;var E,S,M=0;if(h==="be")for(v=y.length-1,E=0;v>=0;v-=3)S=y[v]|y[v-1]<<8|y[v-2]<<16,this.words[E]|=S<<M&67108863,this.words[E+1]=S>>>26-M&67108863,M+=24,M>=26&&(M-=26,E++);else if(h==="le")for(v=0,E=0;v<y.length;v+=3)S=y[v]|y[v+1]<<8|y[v+2]<<16,this.words[E]|=S<<M&67108863,this.words[E+1]=S>>>26-M&67108863,M+=24,M>=26&&(M-=26,E++);return this.strip()};function f(U,y){var u=U.charCodeAt(y);return u>=65&&u<=70?u-55:u>=97&&u<=102?u-87:u-48&15}function g(U,y,u){var h=f(U,u);return u-1>=y&&(h|=f(U,u-1)<<4),h}a.prototype._parseHex=function(y,u,h){this.length=Math.ceil((y.length-u)/6),this.words=new Array(this.length);for(var v=0;v<this.length;v++)this.words[v]=0;var E=0,S=0,M;if(h==="be")for(v=y.length-1;v>=u;v-=2)M=g(y,u,v)<<E,this.words[S]|=M&67108863,E>=18?(E-=18,S+=1,this.words[S]|=M>>>26):E+=8;else{var x=y.length-u;for(v=x%2===0?u+1:u;v<y.length;v+=2)M=g(y,u,v)<<E,this.words[S]|=M&67108863,E>=18?(E-=18,S+=1,this.words[S]|=M>>>26):E+=8}this.strip()};function d(U,y,u,h){for(var v=0,E=Math.min(U.length,u),S=y;S<E;S++){var M=U.charCodeAt(S)-48;v*=h,M>=49?v+=M-49+10:M>=17?v+=M-17+10:v+=M}return v}a.prototype._parseBase=function(y,u,h){this.words=[0],this.length=1;for(var v=0,E=1;E<=67108863;E*=u)v++;v--,E=E/u|0;for(var S=y.length-h,M=S%v,x=Math.min(S,S-M)+h,p=0,b=h;b<x;b+=v)p=d(y,b,b+v,u),this.imuln(E),this.words[0]+p<67108864?this.words[0]+=p:this._iaddn(p);if(M!==0){var R=1;for(p=d(y,b,y.length,u),b=0;b<M;b++)R*=u;this.imuln(R),this.words[0]+p<67108864?this.words[0]+=p:this._iaddn(p)}this.strip()},a.prototype.copy=function(y){y.words=new Array(this.length);for(var u=0;u<this.length;u++)y.words[u]=this.words[u];y.length=this.length,y.negative=this.negative,y.red=this.red},a.prototype.clone=function(){var y=new a(null);return this.copy(y),y},a.prototype._expand=function(y){for(;this.length<y;)this.words[this.length++]=0;return this},a.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},a.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},a.prototype.inspect=function(){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"],w=[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],O=[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];a.prototype.toString=function(y,u){y=y||10,u=u|0||1;var h;if(y===16||y==="hex"){h="";for(var v=0,E=0,S=0;S<this.length;S++){var M=this.words[S],x=((M<<v|E)&16777215).toString(16);E=M>>>24-v&16777215,E!==0||S!==this.length-1?h=m[6-x.length]+x+h:h=x+h,v+=2,v>=26&&(v-=26,S--)}for(E!==0&&(h=E.toString(16)+h);h.length%u!==0;)h="0"+h;return this.negative!==0&&(h="-"+h),h}if(y===(y|0)&&y>=2&&y<=36){var p=w[y],b=O[y];h="";var R=this.clone();for(R.negative=0;!R.isZero();){var Z=R.modn(b).toString(y);R=R.idivn(b),R.isZero()?h=Z+h:h=m[p-Z.length]+Z+h}for(this.isZero()&&(h="0"+h);h.length%u!==0;)h="0"+h;return this.negative!==0&&(h="-"+h),h}i(!1,"Base should be between 2 and 36")},a.prototype.toNumber=function(){var y=this.words[0];return this.length===2?y+=this.words[1]*67108864:this.length===3&&this.words[2]===1?y+=4503599627370496+this.words[1]*67108864:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-y:y},a.prototype.toJSON=function(){return this.toString(16)},a.prototype.toBuffer=function(y,u){return i(typeof c<"u"),this.toArrayLike(c,y,u)},a.prototype.toArray=function(y,u){return this.toArrayLike(Array,y,u)},a.prototype.toArrayLike=function(y,u,h){var v=this.byteLength(),E=h||Math.max(1,v);i(v<=E,"byte array longer than desired length"),i(E>0,"Requested array length <= 0"),this.strip();var S=u==="le",M=new y(E),x,p,b=this.clone();if(S){for(p=0;!b.isZero();p++)x=b.andln(255),b.iushrn(8),M[p]=x;for(;p<E;p++)M[p]=0}else{for(p=0;p<E-v;p++)M[p]=0;for(p=0;!b.isZero();p++)x=b.andln(255),b.iushrn(8),M[E-p-1]=x}return M},Math.clz32?a.prototype._countBits=function(y){return 32-Math.clz32(y)}:a.prototype._countBits=function(y){var u=y,h=0;return u>=4096&&(h+=13,u>>>=13),u>=64&&(h+=7,u>>>=7),u>=8&&(h+=4,u>>>=4),u>=2&&(h+=2,u>>>=2),h+u},a.prototype._zeroBits=function(y){if(y===0)return 26;var u=y,h=0;return u&8191||(h+=13,u>>>=13),u&127||(h+=7,u>>>=7),u&15||(h+=4,u>>>=4),u&3||(h+=2,u>>>=2),u&1||h++,h},a.prototype.bitLength=function(){var y=this.words[this.length-1],u=this._countBits(y);return(this.length-1)*26+u};function C(U){for(var y=new Array(U.bitLength()),u=0;u<y.length;u++){var h=u/26|0,v=u%26;y[u]=(U.words[h]&1<<v)>>>v}return y}a.prototype.zeroBits=function(){if(this.isZero())return 0;for(var y=0,u=0;u<this.length;u++){var h=this._zeroBits(this.words[u]);if(y+=h,h!==26)break}return y},a.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},a.prototype.toTwos=function(y){return this.negative!==0?this.abs().inotn(y).iaddn(1):this.clone()},a.prototype.fromTwos=function(y){return this.testn(y-1)?this.notn(y).iaddn(1).ineg():this.clone()},a.prototype.isNeg=function(){return this.negative!==0},a.prototype.neg=function(){return this.clone().ineg()},a.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},a.prototype.iuor=function(y){for(;this.length<y.length;)this.words[this.length++]=0;for(var u=0;u<y.length;u++)this.words[u]=this.words[u]|y.words[u];return this.strip()},a.prototype.ior=function(y){return i((this.negative|y.negative)===0),this.iuor(y)},a.prototype.or=function(y){return this.length>y.length?this.clone().ior(y):y.clone().ior(this)},a.prototype.uor=function(y){return this.length>y.length?this.clone().iuor(y):y.clone().iuor(this)},a.prototype.iuand=function(y){var u;this.length>y.length?u=y:u=this;for(var h=0;h<u.length;h++)this.words[h]=this.words[h]&y.words[h];return this.length=u.length,this.strip()},a.prototype.iand=function(y){return i((this.negative|y.negative)===0),this.iuand(y)},a.prototype.and=function(y){return this.length>y.length?this.clone().iand(y):y.clone().iand(this)},a.prototype.uand=function(y){return this.length>y.length?this.clone().iuand(y):y.clone().iuand(this)},a.prototype.iuxor=function(y){var u,h;this.length>y.length?(u=this,h=y):(u=y,h=this);for(var v=0;v<h.length;v++)this.words[v]=u.words[v]^h.words[v];if(this!==u)for(;v<u.length;v++)this.words[v]=u.words[v];return this.length=u.length,this.strip()},a.prototype.ixor=function(y){return i((this.negative|y.negative)===0),this.iuxor(y)},a.prototype.xor=function(y){return this.length>y.length?this.clone().ixor(y):y.clone().ixor(this)},a.prototype.uxor=function(y){return this.length>y.length?this.clone().iuxor(y):y.clone().iuxor(this)},a.prototype.inotn=function(y){i(typeof y=="number"&&y>=0);var u=Math.ceil(y/26)|0,h=y%26;this._expand(u),h>0&&u--;for(var v=0;v<u;v++)this.words[v]=~this.words[v]&67108863;return h>0&&(this.words[v]=~this.words[v]&67108863>>26-h),this.strip()},a.prototype.notn=function(y){return this.clone().inotn(y)},a.prototype.setn=function(y,u){i(typeof y=="number"&&y>=0);var h=y/26|0,v=y%26;return this._expand(h+1),u?this.words[h]=this.words[h]|1<<v:this.words[h]=this.words[h]&~(1<<v),this.strip()},a.prototype.iadd=function(y){var u;if(this.negative!==0&&y.negative===0)return this.negative=0,u=this.isub(y),this.negative^=1,this._normSign();if(this.negative===0&&y.negative!==0)return y.negative=0,u=this.isub(y),y.negative=1,u._normSign();var h,v;this.length>y.length?(h=this,v=y):(h=y,v=this);for(var E=0,S=0;S<v.length;S++)u=(h.words[S]|0)+(v.words[S]|0)+E,this.words[S]=u&67108863,E=u>>>26;for(;E!==0&&S<h.length;S++)u=(h.words[S]|0)+E,this.words[S]=u&67108863,E=u>>>26;if(this.length=h.length,E!==0)this.words[this.length]=E,this.length++;else if(h!==this)for(;S<h.length;S++)this.words[S]=h.words[S];return this},a.prototype.add=function(y){var u;return y.negative!==0&&this.negative===0?(y.negative=0,u=this.sub(y),y.negative^=1,u):y.negative===0&&this.negative!==0?(this.negative=0,u=y.sub(this),this.negative=1,u):this.length>y.length?this.clone().iadd(y):y.clone().iadd(this)},a.prototype.isub=function(y){if(y.negative!==0){y.negative=0;var u=this.iadd(y);return y.negative=1,u._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(y),this.negative=1,this._normSign();var h=this.cmp(y);if(h===0)return this.negative=0,this.length=1,this.words[0]=0,this;var v,E;h>0?(v=this,E=y):(v=y,E=this);for(var S=0,M=0;M<E.length;M++)u=(v.words[M]|0)-(E.words[M]|0)+S,S=u>>26,this.words[M]=u&67108863;for(;S!==0&&M<v.length;M++)u=(v.words[M]|0)+S,S=u>>26,this.words[M]=u&67108863;if(S===0&&M<v.length&&v!==this)for(;M<v.length;M++)this.words[M]=v.words[M];return this.length=Math.max(this.length,M),v!==this&&(this.negative=1),this.strip()},a.prototype.sub=function(y){return this.clone().isub(y)};function P(U,y,u){u.negative=y.negative^U.negative;var h=U.length+y.length|0;u.length=h,h=h-1|0;var v=U.words[0]|0,E=y.words[0]|0,S=v*E,M=S&67108863,x=S/67108864|0;u.words[0]=M;for(var p=1;p<h;p++){for(var b=x>>>26,R=x&67108863,Z=Math.min(p,y.length-1),ae=Math.max(0,p-U.length+1);ae<=Z;ae++){var I=p-ae|0;v=U.words[I]|0,E=y.words[ae]|0,S=v*E+R,b+=S/67108864|0,R=S&67108863}u.words[p]=R|0,x=b|0}return x!==0?u.words[p]=x|0:u.length--,u.strip()}var q=function(y,u,h){var v=y.words,E=u.words,S=h.words,M=0,x,p,b,R=v[0]|0,Z=R&8191,ae=R>>>13,I=v[1]|0,ee=I&8191,L=I>>>13,V=v[2]|0,G=V&8191,D=V>>>13,H=v[3]|0,ne=H&8191,ce=H>>>13,fe=v[4]|0,ye=fe&8191,we=fe>>>13,Te=v[5]|0,Qe=Te&8191,Ce=Te>>>13,Re=v[6]|0,Se=Re&8191,me=Re>>>13,Pe=v[7]|0,Ne=Pe&8191,be=Pe>>>13,Oe=v[8]|0,xe=Oe&8191,ve=Oe>>>13,qe=v[9]|0,Me=qe&8191,_e=qe>>>13,He=E[0]|0,Ve=He&8191,Ee=He>>>13,Ke=E[1]|0,ht=Ke&8191,Ge=Ke>>>13,_t=E[2]|0,lt=_t&8191,We=_t>>>13,Et=E[3]|0,St=Et&8191,Be=Et>>>13,Xe=E[4]|0,tt=Xe&8191,$e=Xe>>>13,et=E[5]|0,Ze=et&8191,Fe=et>>>13,ut=E[6]|0,rt=ut&8191,ze=ut>>>13,it=E[7]|0,st=it&8191,Ue=it>>>13,Ye=E[8]|0,ft=Ye&8191,je=Ye>>>13,Rt=E[9]|0,Nt=Rt&8191,at=Rt>>>13;h.negative=y.negative^u.negative,h.length=19,x=Math.imul(Z,Ve),p=Math.imul(Z,Ee),p=p+Math.imul(ae,Ve)|0,b=Math.imul(ae,Ee);var vt=(M+x|0)+((p&8191)<<13)|0;M=(b+(p>>>13)|0)+(vt>>>26)|0,vt&=67108863,x=Math.imul(ee,Ve),p=Math.imul(ee,Ee),p=p+Math.imul(L,Ve)|0,b=Math.imul(L,Ee),x=x+Math.imul(Z,ht)|0,p=p+Math.imul(Z,Ge)|0,p=p+Math.imul(ae,ht)|0,b=b+Math.imul(ae,Ge)|0;var Rr=(M+x|0)+((p&8191)<<13)|0;M=(b+(p>>>13)|0)+(Rr>>>26)|0,Rr&=67108863,x=Math.imul(G,Ve),p=Math.imul(G,Ee),p=p+Math.imul(D,Ve)|0,b=Math.imul(D,Ee),x=x+Math.imul(ee,ht)|0,p=p+Math.imul(ee,Ge)|0,p=p+Math.imul(L,ht)|0,b=b+Math.imul(L,Ge)|0,x=x+Math.imul(Z,lt)|0,p=p+Math.imul(Z,We)|0,p=p+Math.imul(ae,lt)|0,b=b+Math.imul(ae,We)|0;var Nr=(M+x|0)+((p&8191)<<13)|0;M=(b+(p>>>13)|0)+(Nr>>>26)|0,Nr&=67108863,x=Math.imul(ne,Ve),p=Math.imul(ne,Ee),p=p+Math.imul(ce,Ve)|0,b=Math.imul(ce,Ee),x=x+Math.imul(G,ht)|0,p=p+Math.imul(G,Ge)|0,p=p+Math.imul(D,ht)|0,b=b+Math.imul(D,Ge)|0,x=x+Math.imul(ee,lt)|0,p=p+Math.imul(ee,We)|0,p=p+Math.imul(L,lt)|0,b=b+Math.imul(L,We)|0,x=x+Math.imul(Z,St)|0,p=p+Math.imul(Z,Be)|0,p=p+Math.imul(ae,St)|0,b=b+Math.imul(ae,Be)|0;var Br=(M+x|0)+((p&8191)<<13)|0;M=(b+(p>>>13)|0)+(Br>>>26)|0,Br&=67108863,x=Math.imul(ye,Ve),p=Math.imul(ye,Ee),p=p+Math.imul(we,Ve)|0,b=Math.imul(we,Ee),x=x+Math.imul(ne,ht)|0,p=p+Math.imul(ne,Ge)|0,p=p+Math.imul(ce,ht)|0,b=b+Math.imul(ce,Ge)|0,x=x+Math.imul(G,lt)|0,p=p+Math.imul(G,We)|0,p=p+Math.imul(D,lt)|0,b=b+Math.imul(D,We)|0,x=x+Math.imul(ee,St)|0,p=p+Math.imul(ee,Be)|0,p=p+Math.imul(L,St)|0,b=b+Math.imul(L,Be)|0,x=x+Math.imul(Z,tt)|0,p=p+Math.imul(Z,$e)|0,p=p+Math.imul(ae,tt)|0,b=b+Math.imul(ae,$e)|0;var $r=(M+x|0)+((p&8191)<<13)|0;M=(b+(p>>>13)|0)+($r>>>26)|0,$r&=67108863,x=Math.imul(Qe,Ve),p=Math.imul(Qe,Ee),p=p+Math.imul(Ce,Ve)|0,b=Math.imul(Ce,Ee),x=x+Math.imul(ye,ht)|0,p=p+Math.imul(ye,Ge)|0,p=p+Math.imul(we,ht)|0,b=b+Math.imul(we,Ge)|0,x=x+Math.imul(ne,lt)|0,p=p+Math.imul(ne,We)|0,p=p+Math.imul(ce,lt)|0,b=b+Math.imul(ce,We)|0,x=x+Math.imul(G,St)|0,p=p+Math.imul(G,Be)|0,p=p+Math.imul(D,St)|0,b=b+Math.imul(D,Be)|0,x=x+Math.imul(ee,tt)|0,p=p+Math.imul(ee,$e)|0,p=p+Math.imul(L,tt)|0,b=b+Math.imul(L,$e)|0,x=x+Math.imul(Z,Ze)|0,p=p+Math.imul(Z,Fe)|0,p=p+Math.imul(ae,Ze)|0,b=b+Math.imul(ae,Fe)|0;var Ur=(M+x|0)+((p&8191)<<13)|0;M=(b+(p>>>13)|0)+(Ur>>>26)|0,Ur&=67108863,x=Math.imul(Se,Ve),p=Math.imul(Se,Ee),p=p+Math.imul(me,Ve)|0,b=Math.imul(me,Ee),x=x+Math.imul(Qe,ht)|0,p=p+Math.imul(Qe,Ge)|0,p=p+Math.imul(Ce,ht)|0,b=b+Math.imul(Ce,Ge)|0,x=x+Math.imul(ye,lt)|0,p=p+Math.imul(ye,We)|0,p=p+Math.imul(we,lt)|0,b=b+Math.imul(we,We)|0,x=x+Math.imul(ne,St)|0,p=p+Math.imul(ne,Be)|0,p=p+Math.imul(ce,St)|0,b=b+Math.imul(ce,Be)|0,x=x+Math.imul(G,tt)|0,p=p+Math.imul(G,$e)|0,p=p+Math.imul(D,tt)|0,b=b+Math.imul(D,$e)|0,x=x+Math.imul(ee,Ze)|0,p=p+Math.imul(ee,Fe)|0,p=p+Math.imul(L,Ze)|0,b=b+Math.imul(L,Fe)|0,x=x+Math.imul(Z,rt)|0,p=p+Math.imul(Z,ze)|0,p=p+Math.imul(ae,rt)|0,b=b+Math.imul(ae,ze)|0;var er=(M+x|0)+((p&8191)<<13)|0;M=(b+(p>>>13)|0)+(er>>>26)|0,er&=67108863,x=Math.imul(Ne,Ve),p=Math.imul(Ne,Ee),p=p+Math.imul(be,Ve)|0,b=Math.imul(be,Ee),x=x+Math.imul(Se,ht)|0,p=p+Math.imul(Se,Ge)|0,p=p+Math.imul(me,ht)|0,b=b+Math.imul(me,Ge)|0,x=x+Math.imul(Qe,lt)|0,p=p+Math.imul(Qe,We)|0,p=p+Math.imul(Ce,lt)|0,b=b+Math.imul(Ce,We)|0,x=x+Math.imul(ye,St)|0,p=p+Math.imul(ye,Be)|0,p=p+Math.imul(we,St)|0,b=b+Math.imul(we,Be)|0,x=x+Math.imul(ne,tt)|0,p=p+Math.imul(ne,$e)|0,p=p+Math.imul(ce,tt)|0,b=b+Math.imul(ce,$e)|0,x=x+Math.imul(G,Ze)|0,p=p+Math.imul(G,Fe)|0,p=p+Math.imul(D,Ze)|0,b=b+Math.imul(D,Fe)|0,x=x+Math.imul(ee,rt)|0,p=p+Math.imul(ee,ze)|0,p=p+Math.imul(L,rt)|0,b=b+Math.imul(L,ze)|0,x=x+Math.imul(Z,st)|0,p=p+Math.imul(Z,Ue)|0,p=p+Math.imul(ae,st)|0,b=b+Math.imul(ae,Ue)|0;var Xr=(M+x|0)+((p&8191)<<13)|0;M=(b+(p>>>13)|0)+(Xr>>>26)|0,Xr&=67108863,x=Math.imul(xe,Ve),p=Math.imul(xe,Ee),p=p+Math.imul(ve,Ve)|0,b=Math.imul(ve,Ee),x=x+Math.imul(Ne,ht)|0,p=p+Math.imul(Ne,Ge)|0,p=p+Math.imul(be,ht)|0,b=b+Math.imul(be,Ge)|0,x=x+Math.imul(Se,lt)|0,p=p+Math.imul(Se,We)|0,p=p+Math.imul(me,lt)|0,b=b+Math.imul(me,We)|0,x=x+Math.imul(Qe,St)|0,p=p+Math.imul(Qe,Be)|0,p=p+Math.imul(Ce,St)|0,b=b+Math.imul(Ce,Be)|0,x=x+Math.imul(ye,tt)|0,p=p+Math.imul(ye,$e)|0,p=p+Math.imul(we,tt)|0,b=b+Math.imul(we,$e)|0,x=x+Math.imul(ne,Ze)|0,p=p+Math.imul(ne,Fe)|0,p=p+Math.imul(ce,Ze)|0,b=b+Math.imul(ce,Fe)|0,x=x+Math.imul(G,rt)|0,p=p+Math.imul(G,ze)|0,p=p+Math.imul(D,rt)|0,b=b+Math.imul(D,ze)|0,x=x+Math.imul(ee,st)|0,p=p+Math.imul(ee,Ue)|0,p=p+Math.imul(L,st)|0,b=b+Math.imul(L,Ue)|0,x=x+Math.imul(Z,ft)|0,p=p+Math.imul(Z,je)|0,p=p+Math.imul(ae,ft)|0,b=b+Math.imul(ae,je)|0;var Wi=(M+x|0)+((p&8191)<<13)|0;M=(b+(p>>>13)|0)+(Wi>>>26)|0,Wi&=67108863,x=Math.imul(Me,Ve),p=Math.imul(Me,Ee),p=p+Math.imul(_e,Ve)|0,b=Math.imul(_e,Ee),x=x+Math.imul(xe,ht)|0,p=p+Math.imul(xe,Ge)|0,p=p+Math.imul(ve,ht)|0,b=b+Math.imul(ve,Ge)|0,x=x+Math.imul(Ne,lt)|0,p=p+Math.imul(Ne,We)|0,p=p+Math.imul(be,lt)|0,b=b+Math.imul(be,We)|0,x=x+Math.imul(Se,St)|0,p=p+Math.imul(Se,Be)|0,p=p+Math.imul(me,St)|0,b=b+Math.imul(me,Be)|0,x=x+Math.imul(Qe,tt)|0,p=p+Math.imul(Qe,$e)|0,p=p+Math.imul(Ce,tt)|0,b=b+Math.imul(Ce,$e)|0,x=x+Math.imul(ye,Ze)|0,p=p+Math.imul(ye,Fe)|0,p=p+Math.imul(we,Ze)|0,b=b+Math.imul(we,Fe)|0,x=x+Math.imul(ne,rt)|0,p=p+Math.imul(ne,ze)|0,p=p+Math.imul(ce,rt)|0,b=b+Math.imul(ce,ze)|0,x=x+Math.imul(G,st)|0,p=p+Math.imul(G,Ue)|0,p=p+Math.imul(D,st)|0,b=b+Math.imul(D,Ue)|0,x=x+Math.imul(ee,ft)|0,p=p+Math.imul(ee,je)|0,p=p+Math.imul(L,ft)|0,b=b+Math.imul(L,je)|0,x=x+Math.imul(Z,Nt)|0,p=p+Math.imul(Z,at)|0,p=p+Math.imul(ae,Nt)|0,b=b+Math.imul(ae,at)|0;var Zr=(M+x|0)+((p&8191)<<13)|0;M=(b+(p>>>13)|0)+(Zr>>>26)|0,Zr&=67108863,x=Math.imul(Me,ht),p=Math.imul(Me,Ge),p=p+Math.imul(_e,ht)|0,b=Math.imul(_e,Ge),x=x+Math.imul(xe,lt)|0,p=p+Math.imul(xe,We)|0,p=p+Math.imul(ve,lt)|0,b=b+Math.imul(ve,We)|0,x=x+Math.imul(Ne,St)|0,p=p+Math.imul(Ne,Be)|0,p=p+Math.imul(be,St)|0,b=b+Math.imul(be,Be)|0,x=x+Math.imul(Se,tt)|0,p=p+Math.imul(Se,$e)|0,p=p+Math.imul(me,tt)|0,b=b+Math.imul(me,$e)|0,x=x+Math.imul(Qe,Ze)|0,p=p+Math.imul(Qe,Fe)|0,p=p+Math.imul(Ce,Ze)|0,b=b+Math.imul(Ce,Fe)|0,x=x+Math.imul(ye,rt)|0,p=p+Math.imul(ye,ze)|0,p=p+Math.imul(we,rt)|0,b=b+Math.imul(we,ze)|0,x=x+Math.imul(ne,st)|0,p=p+Math.imul(ne,Ue)|0,p=p+Math.imul(ce,st)|0,b=b+Math.imul(ce,Ue)|0,x=x+Math.imul(G,ft)|0,p=p+Math.imul(G,je)|0,p=p+Math.imul(D,ft)|0,b=b+Math.imul(D,je)|0,x=x+Math.imul(ee,Nt)|0,p=p+Math.imul(ee,at)|0,p=p+Math.imul(L,Nt)|0,b=b+Math.imul(L,at)|0;var Yi=(M+x|0)+((p&8191)<<13)|0;M=(b+(p>>>13)|0)+(Yi>>>26)|0,Yi&=67108863,x=Math.imul(Me,lt),p=Math.imul(Me,We),p=p+Math.imul(_e,lt)|0,b=Math.imul(_e,We),x=x+Math.imul(xe,St)|0,p=p+Math.imul(xe,Be)|0,p=p+Math.imul(ve,St)|0,b=b+Math.imul(ve,Be)|0,x=x+Math.imul(Ne,tt)|0,p=p+Math.imul(Ne,$e)|0,p=p+Math.imul(be,tt)|0,b=b+Math.imul(be,$e)|0,x=x+Math.imul(Se,Ze)|0,p=p+Math.imul(Se,Fe)|0,p=p+Math.imul(me,Ze)|0,b=b+Math.imul(me,Fe)|0,x=x+Math.imul(Qe,rt)|0,p=p+Math.imul(Qe,ze)|0,p=p+Math.imul(Ce,rt)|0,b=b+Math.imul(Ce,ze)|0,x=x+Math.imul(ye,st)|0,p=p+Math.imul(ye,Ue)|0,p=p+Math.imul(we,st)|0,b=b+Math.imul(we,Ue)|0,x=x+Math.imul(ne,ft)|0,p=p+Math.imul(ne,je)|0,p=p+Math.imul(ce,ft)|0,b=b+Math.imul(ce,je)|0,x=x+Math.imul(G,Nt)|0,p=p+Math.imul(G,at)|0,p=p+Math.imul(D,Nt)|0,b=b+Math.imul(D,at)|0;var Qi=(M+x|0)+((p&8191)<<13)|0;M=(b+(p>>>13)|0)+(Qi>>>26)|0,Qi&=67108863,x=Math.imul(Me,St),p=Math.imul(Me,Be),p=p+Math.imul(_e,St)|0,b=Math.imul(_e,Be),x=x+Math.imul(xe,tt)|0,p=p+Math.imul(xe,$e)|0,p=p+Math.imul(ve,tt)|0,b=b+Math.imul(ve,$e)|0,x=x+Math.imul(Ne,Ze)|0,p=p+Math.imul(Ne,Fe)|0,p=p+Math.imul(be,Ze)|0,b=b+Math.imul(be,Fe)|0,x=x+Math.imul(Se,rt)|0,p=p+Math.imul(Se,ze)|0,p=p+Math.imul(me,rt)|0,b=b+Math.imul(me,ze)|0,x=x+Math.imul(Qe,st)|0,p=p+Math.imul(Qe,Ue)|0,p=p+Math.imul(Ce,st)|0,b=b+Math.imul(Ce,Ue)|0,x=x+Math.imul(ye,ft)|0,p=p+Math.imul(ye,je)|0,p=p+Math.imul(we,ft)|0,b=b+Math.imul(we,je)|0,x=x+Math.imul(ne,Nt)|0,p=p+Math.imul(ne,at)|0,p=p+Math.imul(ce,Nt)|0,b=b+Math.imul(ce,at)|0;var ei=(M+x|0)+((p&8191)<<13)|0;M=(b+(p>>>13)|0)+(ei>>>26)|0,ei&=67108863,x=Math.imul(Me,tt),p=Math.imul(Me,$e),p=p+Math.imul(_e,tt)|0,b=Math.imul(_e,$e),x=x+Math.imul(xe,Ze)|0,p=p+Math.imul(xe,Fe)|0,p=p+Math.imul(ve,Ze)|0,b=b+Math.imul(ve,Fe)|0,x=x+Math.imul(Ne,rt)|0,p=p+Math.imul(Ne,ze)|0,p=p+Math.imul(be,rt)|0,b=b+Math.imul(be,ze)|0,x=x+Math.imul(Se,st)|0,p=p+Math.imul(Se,Ue)|0,p=p+Math.imul(me,st)|0,b=b+Math.imul(me,Ue)|0,x=x+Math.imul(Qe,ft)|0,p=p+Math.imul(Qe,je)|0,p=p+Math.imul(Ce,ft)|0,b=b+Math.imul(Ce,je)|0,x=x+Math.imul(ye,Nt)|0,p=p+Math.imul(ye,at)|0,p=p+Math.imul(we,Nt)|0,b=b+Math.imul(we,at)|0;var Mi=(M+x|0)+((p&8191)<<13)|0;M=(b+(p>>>13)|0)+(Mi>>>26)|0,Mi&=67108863,x=Math.imul(Me,Ze),p=Math.imul(Me,Fe),p=p+Math.imul(_e,Ze)|0,b=Math.imul(_e,Fe),x=x+Math.imul(xe,rt)|0,p=p+Math.imul(xe,ze)|0,p=p+Math.imul(ve,rt)|0,b=b+Math.imul(ve,ze)|0,x=x+Math.imul(Ne,st)|0,p=p+Math.imul(Ne,Ue)|0,p=p+Math.imul(be,st)|0,b=b+Math.imul(be,Ue)|0,x=x+Math.imul(Se,ft)|0,p=p+Math.imul(Se,je)|0,p=p+Math.imul(me,ft)|0,b=b+Math.imul(me,je)|0,x=x+Math.imul(Qe,Nt)|0,p=p+Math.imul(Qe,at)|0,p=p+Math.imul(Ce,Nt)|0,b=b+Math.imul(Ce,at)|0;var Ii=(M+x|0)+((p&8191)<<13)|0;M=(b+(p>>>13)|0)+(Ii>>>26)|0,Ii&=67108863,x=Math.imul(Me,rt),p=Math.imul(Me,ze),p=p+Math.imul(_e,rt)|0,b=Math.imul(_e,ze),x=x+Math.imul(xe,st)|0,p=p+Math.imul(xe,Ue)|0,p=p+Math.imul(ve,st)|0,b=b+Math.imul(ve,Ue)|0,x=x+Math.imul(Ne,ft)|0,p=p+Math.imul(Ne,je)|0,p=p+Math.imul(be,ft)|0,b=b+Math.imul(be,je)|0,x=x+Math.imul(Se,Nt)|0,p=p+Math.imul(Se,at)|0,p=p+Math.imul(me,Nt)|0,b=b+Math.imul(me,at)|0;var lr=(M+x|0)+((p&8191)<<13)|0;M=(b+(p>>>13)|0)+(lr>>>26)|0,lr&=67108863,x=Math.imul(Me,st),p=Math.imul(Me,Ue),p=p+Math.imul(_e,st)|0,b=Math.imul(_e,Ue),x=x+Math.imul(xe,ft)|0,p=p+Math.imul(xe,je)|0,p=p+Math.imul(ve,ft)|0,b=b+Math.imul(ve,je)|0,x=x+Math.imul(Ne,Nt)|0,p=p+Math.imul(Ne,at)|0,p=p+Math.imul(be,Nt)|0,b=b+Math.imul(be,at)|0;var Xi=(M+x|0)+((p&8191)<<13)|0;M=(b+(p>>>13)|0)+(Xi>>>26)|0,Xi&=67108863,x=Math.imul(Me,ft),p=Math.imul(Me,je),p=p+Math.imul(_e,ft)|0,b=Math.imul(_e,je),x=x+Math.imul(xe,Nt)|0,p=p+Math.imul(xe,at)|0,p=p+Math.imul(ve,Nt)|0,b=b+Math.imul(ve,at)|0;var Zi=(M+x|0)+((p&8191)<<13)|0;M=(b+(p>>>13)|0)+(Zi>>>26)|0,Zi&=67108863,x=Math.imul(Me,Nt),p=Math.imul(Me,at),p=p+Math.imul(_e,Nt)|0,b=Math.imul(_e,at);var en=(M+x|0)+((p&8191)<<13)|0;return M=(b+(p>>>13)|0)+(en>>>26)|0,en&=67108863,S[0]=vt,S[1]=Rr,S[2]=Nr,S[3]=Br,S[4]=$r,S[5]=Ur,S[6]=er,S[7]=Xr,S[8]=Wi,S[9]=Zr,S[10]=Yi,S[11]=Qi,S[12]=ei,S[13]=Mi,S[14]=Ii,S[15]=lr,S[16]=Xi,S[17]=Zi,S[18]=en,M!==0&&(S[19]=M,h.length++),h};Math.imul||(q=P);function K(U,y,u){u.negative=y.negative^U.negative,u.length=U.length+y.length;for(var h=0,v=0,E=0;E<u.length-1;E++){var S=v;v=0;for(var M=h&67108863,x=Math.min(E,y.length-1),p=Math.max(0,E-U.length+1);p<=x;p++){var b=E-p,R=U.words[b]|0,Z=y.words[p]|0,ae=R*Z,I=ae&67108863;S=S+(ae/67108864|0)|0,I=I+M|0,M=I&67108863,S=S+(I>>>26)|0,v+=S>>>26,S&=67108863}u.words[E]=M,h=S,S=v}return h!==0?u.words[E]=h:u.length--,u.strip()}function Y(U,y,u){var h=new z;return h.mulp(U,y,u)}a.prototype.mulTo=function(y,u){var h,v=this.length+y.length;return this.length===10&&y.length===10?h=q(this,y,u):v<63?h=P(this,y,u):v<1024?h=K(this,y,u):h=Y(this,y,u),h};function z(U,y){this.x=U,this.y=y}z.prototype.makeRBT=function(y){for(var u=new Array(y),h=a.prototype._countBits(y)-1,v=0;v<y;v++)u[v]=this.revBin(v,h,y);return u},z.prototype.revBin=function(y,u,h){if(y===0||y===h-1)return y;for(var v=0,E=0;E<u;E++)v|=(y&1)<<u-E-1,y>>=1;return v},z.prototype.permute=function(y,u,h,v,E,S){for(var M=0;M<S;M++)v[M]=u[y[M]],E[M]=h[y[M]]},z.prototype.transform=function(y,u,h,v,E,S){this.permute(S,y,u,h,v,E);for(var M=1;M<E;M<<=1)for(var x=M<<1,p=Math.cos(2*Math.PI/x),b=Math.sin(2*Math.PI/x),R=0;R<E;R+=x)for(var Z=p,ae=b,I=0;I<M;I++){var ee=h[R+I],L=v[R+I],V=h[R+I+M],G=v[R+I+M],D=Z*V-ae*G;G=Z*G+ae*V,V=D,h[R+I]=ee+V,v[R+I]=L+G,h[R+I+M]=ee-V,v[R+I+M]=L-G,I!==x&&(D=p*Z-b*ae,ae=p*ae+b*Z,Z=D)}},z.prototype.guessLen13b=function(y,u){var h=Math.max(u,y)|1,v=h&1,E=0;for(h=h/2|0;h;h=h>>>1)E++;return 1<<E+1+v},z.prototype.conjugate=function(y,u,h){if(!(h<=1))for(var v=0;v<h/2;v++){var E=y[v];y[v]=y[h-v-1],y[h-v-1]=E,E=u[v],u[v]=-u[h-v-1],u[h-v-1]=-E}},z.prototype.normalize13b=function(y,u){for(var h=0,v=0;v<u/2;v++){var E=Math.round(y[2*v+1]/u)*8192+Math.round(y[2*v]/u)+h;y[v]=E&67108863,E<67108864?h=0:h=E/67108864|0}return y},z.prototype.convert13b=function(y,u,h,v){for(var E=0,S=0;S<u;S++)E=E+(y[S]|0),h[2*S]=E&8191,E=E>>>13,h[2*S+1]=E&8191,E=E>>>13;for(S=2*u;S<v;++S)h[S]=0;i(E===0),i((E&-8192)===0)},z.prototype.stub=function(y){for(var u=new Array(y),h=0;h<y;h++)u[h]=0;return u},z.prototype.mulp=function(y,u,h){var v=2*this.guessLen13b(y.length,u.length),E=this.makeRBT(v),S=this.stub(v),M=new Array(v),x=new Array(v),p=new Array(v),b=new Array(v),R=new Array(v),Z=new Array(v),ae=h.words;ae.length=v,this.convert13b(y.words,y.length,M,v),this.convert13b(u.words,u.length,b,v),this.transform(M,S,x,p,v,E),this.transform(b,S,R,Z,v,E);for(var I=0;I<v;I++){var ee=x[I]*R[I]-p[I]*Z[I];p[I]=x[I]*Z[I]+p[I]*R[I],x[I]=ee}return this.conjugate(x,p,v),this.transform(x,p,ae,S,v,E),this.conjugate(ae,S,v),this.normalize13b(ae,v),h.negative=y.negative^u.negative,h.length=y.length+u.length,h.strip()},a.prototype.mul=function(y){var u=new a(null);return u.words=new Array(this.length+y.length),this.mulTo(y,u)},a.prototype.mulf=function(y){var u=new a(null);return u.words=new Array(this.length+y.length),Y(this,y,u)},a.prototype.imul=function(y){return this.clone().mulTo(y,this)},a.prototype.imuln=function(y){i(typeof y=="number"),i(y<67108864);for(var u=0,h=0;h<this.length;h++){var v=(this.words[h]|0)*y,E=(v&67108863)+(u&67108863);u>>=26,u+=v/67108864|0,u+=E>>>26,this.words[h]=E&67108863}return u!==0&&(this.words[h]=u,this.length++),this},a.prototype.muln=function(y){return this.clone().imuln(y)},a.prototype.sqr=function(){return this.mul(this)},a.prototype.isqr=function(){return this.imul(this.clone())},a.prototype.pow=function(y){var u=C(y);if(u.length===0)return new a(1);for(var h=this,v=0;v<u.length&&u[v]===0;v++,h=h.sqr());if(++v<u.length)for(var E=h.sqr();v<u.length;v++,E=E.sqr())u[v]!==0&&(h=h.mul(E));return h},a.prototype.iushln=function(y){i(typeof y=="number"&&y>=0);var u=y%26,h=(y-u)/26,v=67108863>>>26-u<<26-u,E;if(u!==0){var S=0;for(E=0;E<this.length;E++){var M=this.words[E]&v,x=(this.words[E]|0)-M<<u;this.words[E]=x|S,S=M>>>26-u}S&&(this.words[E]=S,this.length++)}if(h!==0){for(E=this.length-1;E>=0;E--)this.words[E+h]=this.words[E];for(E=0;E<h;E++)this.words[E]=0;this.length+=h}return this.strip()},a.prototype.ishln=function(y){return i(this.negative===0),this.iushln(y)},a.prototype.iushrn=function(y,u,h){i(typeof y=="number"&&y>=0);var v;u?v=(u-u%26)/26:v=0;var E=y%26,S=Math.min((y-E)/26,this.length),M=67108863^67108863>>>E<<E,x=h;if(v-=S,v=Math.max(0,v),x){for(var p=0;p<S;p++)x.words[p]=this.words[p];x.length=S}if(S!==0)if(this.length>S)for(this.length-=S,p=0;p<this.length;p++)this.words[p]=this.words[p+S];else this.words[0]=0,this.length=1;var b=0;for(p=this.length-1;p>=0&&(b!==0||p>=v);p--){var R=this.words[p]|0;this.words[p]=b<<26-E|R>>>E,b=R&M}return x&&b!==0&&(x.words[x.length++]=b),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},a.prototype.ishrn=function(y,u,h){return i(this.negative===0),this.iushrn(y,u,h)},a.prototype.shln=function(y){return this.clone().ishln(y)},a.prototype.ushln=function(y){return this.clone().iushln(y)},a.prototype.shrn=function(y){return this.clone().ishrn(y)},a.prototype.ushrn=function(y){return this.clone().iushrn(y)},a.prototype.testn=function(y){i(typeof y=="number"&&y>=0);var u=y%26,h=(y-u)/26,v=1<<u;if(this.length<=h)return!1;var E=this.words[h];return!!(E&v)},a.prototype.imaskn=function(y){i(typeof y=="number"&&y>=0);var u=y%26,h=(y-u)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=h)return this;if(u!==0&&h++,this.length=Math.min(h,this.length),u!==0){var v=67108863^67108863>>>u<<u;this.words[this.length-1]&=v}return this.strip()},a.prototype.maskn=function(y){return this.clone().imaskn(y)},a.prototype.iaddn=function(y){return i(typeof y=="number"),i(y<67108864),y<0?this.isubn(-y):this.negative!==0?this.length===1&&(this.words[0]|0)<y?(this.words[0]=y-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(y),this.negative=1,this):this._iaddn(y)},a.prototype._iaddn=function(y){this.words[0]+=y;for(var u=0;u<this.length&&this.words[u]>=67108864;u++)this.words[u]-=67108864,u===this.length-1?this.words[u+1]=1:this.words[u+1]++;return this.length=Math.max(this.length,u+1),this},a.prototype.isubn=function(y){if(i(typeof y=="number"),i(y<67108864),y<0)return this.iaddn(-y);if(this.negative!==0)return this.negative=0,this.iaddn(y),this.negative=1,this;if(this.words[0]-=y,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var u=0;u<this.length&&this.words[u]<0;u++)this.words[u]+=67108864,this.words[u+1]-=1;return this.strip()},a.prototype.addn=function(y){return this.clone().iaddn(y)},a.prototype.subn=function(y){return this.clone().isubn(y)},a.prototype.iabs=function(){return this.negative=0,this},a.prototype.abs=function(){return this.clone().iabs()},a.prototype._ishlnsubmul=function(y,u,h){var v=y.length+h,E;this._expand(v);var S,M=0;for(E=0;E<y.length;E++){S=(this.words[E+h]|0)+M;var x=(y.words[E]|0)*u;S-=x&67108863,M=(S>>26)-(x/67108864|0),this.words[E+h]=S&67108863}for(;E<this.length-h;E++)S=(this.words[E+h]|0)+M,M=S>>26,this.words[E+h]=S&67108863;if(M===0)return this.strip();for(i(M===-1),M=0,E=0;E<this.length;E++)S=-(this.words[E]|0)+M,M=S>>26,this.words[E]=S&67108863;return this.negative=1,this.strip()},a.prototype._wordDiv=function(y,u){var h=this.length-y.length,v=this.clone(),E=y,S=E.words[E.length-1]|0,M=this._countBits(S);h=26-M,h!==0&&(E=E.ushln(h),v.iushln(h),S=E.words[E.length-1]|0);var x=v.length-E.length,p;if(u!=="mod"){p=new a(null),p.length=x+1,p.words=new Array(p.length);for(var b=0;b<p.length;b++)p.words[b]=0}var R=v.clone()._ishlnsubmul(E,1,x);R.negative===0&&(v=R,p&&(p.words[x]=1));for(var Z=x-1;Z>=0;Z--){var ae=(v.words[E.length+Z]|0)*67108864+(v.words[E.length+Z-1]|0);for(ae=Math.min(ae/S|0,67108863),v._ishlnsubmul(E,ae,Z);v.negative!==0;)ae--,v.negative=0,v._ishlnsubmul(E,1,Z),v.isZero()||(v.negative^=1);p&&(p.words[Z]=ae)}return p&&p.strip(),v.strip(),u!=="div"&&h!==0&&v.iushrn(h),{div:p||null,mod:v}},a.prototype.divmod=function(y,u,h){if(i(!y.isZero()),this.isZero())return{div:new a(0),mod:new a(0)};var v,E,S;return this.negative!==0&&y.negative===0?(S=this.neg().divmod(y,u),u!=="mod"&&(v=S.div.neg()),u!=="div"&&(E=S.mod.neg(),h&&E.negative!==0&&E.iadd(y)),{div:v,mod:E}):this.negative===0&&y.negative!==0?(S=this.divmod(y.neg(),u),u!=="mod"&&(v=S.div.neg()),{div:v,mod:S.mod}):this.negative&y.negative?(S=this.neg().divmod(y.neg(),u),u!=="div"&&(E=S.mod.neg(),h&&E.negative!==0&&E.isub(y)),{div:S.div,mod:E}):y.length>this.length||this.cmp(y)<0?{div:new a(0),mod:this}:y.length===1?u==="div"?{div:this.divn(y.words[0]),mod:null}:u==="mod"?{div:null,mod:new a(this.modn(y.words[0]))}:{div:this.divn(y.words[0]),mod:new a(this.modn(y.words[0]))}:this._wordDiv(y,u)},a.prototype.div=function(y){return this.divmod(y,"div",!1).div},a.prototype.mod=function(y){return this.divmod(y,"mod",!1).mod},a.prototype.umod=function(y){return this.divmod(y,"mod",!0).mod},a.prototype.divRound=function(y){var u=this.divmod(y);if(u.mod.isZero())return u.div;var h=u.div.negative!==0?u.mod.isub(y):u.mod,v=y.ushrn(1),E=y.andln(1),S=h.cmp(v);return S<0||E===1&&S===0?u.div:u.div.negative!==0?u.div.isubn(1):u.div.iaddn(1)},a.prototype.modn=function(y){i(y<=67108863);for(var u=(1<<26)%y,h=0,v=this.length-1;v>=0;v--)h=(u*h+(this.words[v]|0))%y;return h},a.prototype.idivn=function(y){i(y<=67108863);for(var u=0,h=this.length-1;h>=0;h--){var v=(this.words[h]|0)+u*67108864;this.words[h]=v/y|0,u=v%y}return this.strip()},a.prototype.divn=function(y){return this.clone().idivn(y)},a.prototype.egcd=function(y){i(y.negative===0),i(!y.isZero());var u=this,h=y.clone();u.negative!==0?u=u.umod(y):u=u.clone();for(var v=new a(1),E=new a(0),S=new a(0),M=new a(1),x=0;u.isEven()&&h.isEven();)u.iushrn(1),h.iushrn(1),++x;for(var p=h.clone(),b=u.clone();!u.isZero();){for(var R=0,Z=1;!(u.words[0]&Z)&&R<26;++R,Z<<=1);if(R>0)for(u.iushrn(R);R-- >0;)(v.isOdd()||E.isOdd())&&(v.iadd(p),E.isub(b)),v.iushrn(1),E.iushrn(1);for(var ae=0,I=1;!(h.words[0]&I)&&ae<26;++ae,I<<=1);if(ae>0)for(h.iushrn(ae);ae-- >0;)(S.isOdd()||M.isOdd())&&(S.iadd(p),M.isub(b)),S.iushrn(1),M.iushrn(1);u.cmp(h)>=0?(u.isub(h),v.isub(S),E.isub(M)):(h.isub(u),S.isub(v),M.isub(E))}return{a:S,b:M,gcd:h.iushln(x)}},a.prototype._invmp=function(y){i(y.negative===0),i(!y.isZero());var u=this,h=y.clone();u.negative!==0?u=u.umod(y):u=u.clone();for(var v=new a(1),E=new a(0),S=h.clone();u.cmpn(1)>0&&h.cmpn(1)>0;){for(var M=0,x=1;!(u.words[0]&x)&&M<26;++M,x<<=1);if(M>0)for(u.iushrn(M);M-- >0;)v.isOdd()&&v.iadd(S),v.iushrn(1);for(var p=0,b=1;!(h.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(h.iushrn(p);p-- >0;)E.isOdd()&&E.iadd(S),E.iushrn(1);u.cmp(h)>=0?(u.isub(h),v.isub(E)):(h.isub(u),E.isub(v))}var R;return u.cmpn(1)===0?R=v:R=E,R.cmpn(0)<0&&R.iadd(y),R},a.prototype.gcd=function(y){if(this.isZero())return y.abs();if(y.isZero())return this.abs();var u=this.clone(),h=y.clone();u.negative=0,h.negative=0;for(var v=0;u.isEven()&&h.isEven();v++)u.iushrn(1),h.iushrn(1);do{for(;u.isEven();)u.iushrn(1);for(;h.isEven();)h.iushrn(1);var E=u.cmp(h);if(E<0){var S=u;u=h,h=S}else if(E===0||h.cmpn(1)===0)break;u.isub(h)}while(!0);return h.iushln(v)},a.prototype.invm=function(y){return this.egcd(y).a.umod(y)},a.prototype.isEven=function(){return(this.words[0]&1)===0},a.prototype.isOdd=function(){return(this.words[0]&1)===1},a.prototype.andln=function(y){return this.words[0]&y},a.prototype.bincn=function(y){i(typeof y=="number");var u=y%26,h=(y-u)/26,v=1<<u;if(this.length<=h)return this._expand(h+1),this.words[h]|=v,this;for(var E=v,S=h;E!==0&&S<this.length;S++){var M=this.words[S]|0;M+=E,E=M>>>26,M&=67108863,this.words[S]=M}return E!==0&&(this.words[S]=E,this.length++),this},a.prototype.isZero=function(){return this.length===1&&this.words[0]===0},a.prototype.cmpn=function(y){var u=y<0;if(this.negative!==0&&!u)return-1;if(this.negative===0&&u)return 1;this.strip();var h;if(this.length>1)h=1;else{u&&(y=-y),i(y<=67108863,"Number is too big");var v=this.words[0]|0;h=v===y?0:v<y?-1:1}return this.negative!==0?-h|0:h},a.prototype.cmp=function(y){if(this.negative!==0&&y.negative===0)return-1;if(this.negative===0&&y.negative!==0)return 1;var u=this.ucmp(y);return this.negative!==0?-u|0:u},a.prototype.ucmp=function(y){if(this.length>y.length)return 1;if(this.length<y.length)return-1;for(var u=0,h=this.length-1;h>=0;h--){var v=this.words[h]|0,E=y.words[h]|0;if(v!==E){v<E?u=-1:v>E&&(u=1);break}}return u},a.prototype.gtn=function(y){return this.cmpn(y)===1},a.prototype.gt=function(y){return this.cmp(y)===1},a.prototype.gten=function(y){return this.cmpn(y)>=0},a.prototype.gte=function(y){return this.cmp(y)>=0},a.prototype.ltn=function(y){return this.cmpn(y)===-1},a.prototype.lt=function(y){return this.cmp(y)===-1},a.prototype.lten=function(y){return this.cmpn(y)<=0},a.prototype.lte=function(y){return this.cmp(y)<=0},a.prototype.eqn=function(y){return this.cmpn(y)===0},a.prototype.eq=function(y){return this.cmp(y)===0},a.red=function(y){return new se(y)},a.prototype.toRed=function(y){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),y.convertTo(this)._forceRed(y)},a.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},a.prototype._forceRed=function(y){return this.red=y,this},a.prototype.forceRed=function(y){return i(!this.red,"Already a number in reduction context"),this._forceRed(y)},a.prototype.redAdd=function(y){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,y)},a.prototype.redIAdd=function(y){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,y)},a.prototype.redSub=function(y){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,y)},a.prototype.redISub=function(y){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,y)},a.prototype.redShl=function(y){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,y)},a.prototype.redMul=function(y){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,y),this.red.mul(this,y)},a.prototype.redIMul=function(y){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,y),this.red.imul(this,y)},a.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},a.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},a.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},a.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},a.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},a.prototype.redPow=function(y){return i(this.red&&!y.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,y)};var W={k256:null,p224:null,p192:null,p25519:null};function B(U,y){this.name=U,this.p=new a(y,16),this.n=this.p.bitLength(),this.k=new a(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}B.prototype._tmp=function(){var y=new a(null);return y.words=new Array(Math.ceil(this.n/13)),y},B.prototype.ireduce=function(y){var u=y,h;do this.split(u,this.tmp),u=this.imulK(u),u=u.iadd(this.tmp),h=u.bitLength();while(h>this.n);var v=h<this.n?-1:u.ucmp(this.p);return v===0?(u.words[0]=0,u.length=1):v>0?u.isub(this.p):u.strip!==void 0?u.strip():u._strip(),u},B.prototype.split=function(y,u){y.iushrn(this.n,0,u)},B.prototype.imulK=function(y){return y.imul(this.k)};function j(){B.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(j,B),j.prototype.split=function(y,u){for(var h=4194303,v=Math.min(y.length,9),E=0;E<v;E++)u.words[E]=y.words[E];if(u.length=v,y.length<=9){y.words[0]=0,y.length=1;return}var S=y.words[9];for(u.words[u.length++]=S&h,E=10;E<y.length;E++){var M=y.words[E]|0;y.words[E-10]=(M&h)<<4|S>>>22,S=M}S>>>=22,y.words[E-10]=S,S===0&&y.length>10?y.length-=10:y.length-=9},j.prototype.imulK=function(y){y.words[y.length]=0,y.words[y.length+1]=0,y.length+=2;for(var u=0,h=0;h<y.length;h++){var v=y.words[h]|0;u+=v*977,y.words[h]=u&67108863,u=v*64+(u/67108864|0)}return y.words[y.length-1]===0&&(y.length--,y.words[y.length-1]===0&&y.length--),y};function k(){B.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(k,B);function _(){B.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(_,B);function N(){B.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(N,B),N.prototype.imulK=function(y){for(var u=0,h=0;h<y.length;h++){var v=(y.words[h]|0)*19+u,E=v&67108863;v>>>=26,y.words[h]=E,u=v}return u!==0&&(y.words[y.length++]=u),y},a._prime=function(y){if(W[y])return W[y];var u;if(y==="k256")u=new j;else if(y==="p224")u=new k;else if(y==="p192")u=new _;else if(y==="p25519")u=new N;else throw new Error("Unknown prime "+y);return W[y]=u,u};function se(U){if(typeof U=="string"){var y=a._prime(U);this.m=y.p,this.prime=y}else i(U.gtn(1),"modulus must be greater than 1"),this.m=U,this.prime=null}se.prototype._verify1=function(y){i(y.negative===0,"red works only with positives"),i(y.red,"red works only with red numbers")},se.prototype._verify2=function(y,u){i((y.negative|u.negative)===0,"red works only with positives"),i(y.red&&y.red===u.red,"red works only with red numbers")},se.prototype.imod=function(y){return this.prime?this.prime.ireduce(y)._forceRed(this):y.umod(this.m)._forceRed(this)},se.prototype.neg=function(y){return y.isZero()?y.clone():this.m.sub(y)._forceRed(this)},se.prototype.add=function(y,u){this._verify2(y,u);var h=y.add(u);return h.cmp(this.m)>=0&&h.isub(this.m),h._forceRed(this)},se.prototype.iadd=function(y,u){this._verify2(y,u);var h=y.iadd(u);return h.cmp(this.m)>=0&&h.isub(this.m),h},se.prototype.sub=function(y,u){this._verify2(y,u);var h=y.sub(u);return h.cmpn(0)<0&&h.iadd(this.m),h._forceRed(this)},se.prototype.isub=function(y,u){this._verify2(y,u);var h=y.isub(u);return h.cmpn(0)<0&&h.iadd(this.m),h},se.prototype.shl=function(y,u){return this._verify1(y),this.imod(y.ushln(u))},se.prototype.imul=function(y,u){return this._verify2(y,u),this.imod(y.imul(u))},se.prototype.mul=function(y,u){return this._verify2(y,u),this.imod(y.mul(u))},se.prototype.isqr=function(y){return this.imul(y,y.clone())},se.prototype.sqr=function(y){return this.mul(y,y)},se.prototype.sqrt=function(y){if(y.isZero())return y.clone();var u=this.m.andln(3);if(i(u%2===1),u===3){var h=this.m.add(new a(1)).iushrn(2);return this.pow(y,h)}for(var v=this.m.subn(1),E=0;!v.isZero()&&v.andln(1)===0;)E++,v.iushrn(1);i(!v.isZero());var S=new a(1).toRed(this),M=S.redNeg(),x=this.m.subn(1).iushrn(1),p=this.m.bitLength();for(p=new a(2*p*p).toRed(this);this.pow(p,x).cmp(M)!==0;)p.redIAdd(M);for(var b=this.pow(p,v),R=this.pow(y,v.addn(1).iushrn(1)),Z=this.pow(y,v),ae=E;Z.cmp(S)!==0;){for(var I=Z,ee=0;I.cmp(S)!==0;ee++)I=I.redSqr();i(ee<ae);var L=this.pow(b,new a(1).iushln(ae-ee-1));R=R.redMul(L),b=L.redSqr(),Z=Z.redMul(b),ae=ee}return R},se.prototype.invm=function(y){var u=y._invmp(this.m);return u.negative!==0?(u.negative=0,this.imod(u).redNeg()):this.imod(u)},se.prototype.pow=function(y,u){if(u.isZero())return new a(1).toRed(this);if(u.cmpn(1)===0)return y.clone();var h=4,v=new Array(1<<h);v[0]=new a(1).toRed(this),v[1]=y;for(var E=2;E<v.length;E++)v[E]=this.mul(v[E-1],y);var S=v[0],M=0,x=0,p=u.bitLength()%26;for(p===0&&(p=26),E=u.length-1;E>=0;E--){for(var b=u.words[E],R=p-1;R>=0;R--){var Z=b>>R&1;if(S!==v[0]&&(S=this.sqr(S)),Z===0&&M===0){x=0;continue}M<<=1,M|=Z,x++,!(x!==h&&(E!==0||R!==0))&&(S=this.mul(S,v[M]),x=0,M=0)}p=26}return S},se.prototype.convertTo=function(y){var u=y.umod(this.m);return u===y?u.clone():u},se.prototype.convertFrom=function(y){var u=y.clone();return u.red=null,u},a.mont=function(y){return new le(y)};function le(U){se.call(this,U),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new a(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(le,se),le.prototype.convertTo=function(y){return this.imod(y.ushln(this.shift))},le.prototype.convertFrom=function(y){var u=this.imod(y.mul(this.rinv));return u.red=null,u},le.prototype.imul=function(y,u){if(y.isZero()||u.isZero())return y.words[0]=0,y.length=1,y;var h=y.imul(u),v=h.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),E=h.isub(v).iushrn(this.shift),S=E;return E.cmp(this.m)>=0?S=E.isub(this.m):E.cmpn(0)<0&&(S=E.iadd(this.m)),S._forceRed(this)},le.prototype.mul=function(y,u){if(y.isZero()||u.isZero())return new a(0)._forceRed(this);var h=y.mul(u),v=h.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),E=h.isub(v).iushrn(this.shift),S=E;return E.cmp(this.m)>=0?S=E.isub(this.m):E.cmpn(0)<0&&(S=E.iadd(this.m)),S._forceRed(this)},le.prototype.invm=function(y){var u=this.imod(y._invmp(this.m).mul(this.r2));return u._forceRed(this)}})(r,tv)})(Gd);var ws=Gd.exports,Da=Av;function Av(r,e){if(!r)throw new Error(e||"Assertion failed")}Av.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)};var Jd={};(function(r){var e=r;function t(a,c){if(Array.isArray(a))return a.slice();if(!a)return[];var f=[];if(typeof a!="string"){for(var g=0;g<a.length;g++)f[g]=a[g]|0;return f}if(c==="hex"){a=a.replace(/[^a-z0-9]+/ig,""),a.length%2!==0&&(a="0"+a);for(var g=0;g<a.length;g+=2)f.push(parseInt(a[g]+a[g+1],16))}else for(var g=0;g<a.length;g++){var d=a.charCodeAt(g),m=d>>8,w=d&255;m?f.push(m,w):f.push(w)}return f}e.toArray=t;function i(a){return a.length===1?"0"+a:a}e.zero2=i;function n(a){for(var c="",f=0;f<a.length;f++)c+=i(a[f].toString(16));return c}e.toHex=n,e.encode=function(c,f){return f==="hex"?n(c):c}})(Jd);(function(r){var e=r,t=ws,i=Da,n=Jd;e.assert=i,e.toArray=n.toArray,e.zero2=n.zero2,e.toHex=n.toHex,e.encode=n.encode;function a(m,w,O){var C=new Array(Math.max(m.bitLength(),O)+1),P;for(P=0;P<C.length;P+=1)C[P]=0;var q=1<<w+1,K=m.clone();for(P=0;P<C.length;P++){var Y,z=K.andln(q-1);K.isOdd()?(z>(q>>1)-1?Y=(q>>1)-z:Y=z,K.isubn(Y)):Y=0,C[P]=Y,K.iushrn(1)}return C}e.getNAF=a;function c(m,w){var O=[[],[]];m=m.clone(),w=w.clone();for(var C=0,P=0,q;m.cmpn(-C)>0||w.cmpn(-P)>0;){var K=m.andln(3)+C&3,Y=w.andln(3)+P&3;K===3&&(K=-1),Y===3&&(Y=-1);var z;K&1?(q=m.andln(7)+C&7,(q===3||q===5)&&Y===2?z=-K:z=K):z=0,O[0].push(z);var W;Y&1?(q=w.andln(7)+P&7,(q===3||q===5)&&K===2?W=-Y:W=Y):W=0,O[1].push(W),2*C===z+1&&(C=1-C),2*P===W+1&&(P=1-P),m.iushrn(1),w.iushrn(1)}return O}e.getJSF=c;function f(m,w,O){var C="_"+w;m.prototype[w]=function(){return this[C]!==void 0?this[C]:this[C]=O.call(this)}}e.cachedProperty=f;function g(m){return typeof m=="string"?e.toArray(m,"hex"):m}e.parseBytes=g;function d(m){return new t(m,"hex","le")}e.intFromLE=d})(Si);var Wd={exports:{}},_l;Wd.exports=function(e){return _l||(_l=new qs(null)),_l.generate(e)};function qs(r){this.rand=r}Wd.exports.Rand=qs;qs.prototype.generate=function(e){return this._rand(e)};qs.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),i=0;i<t.length;i++)t[i]=this.rand.getByte();return t};if(typeof self=="object")self.crypto&&self.crypto.getRandomValues?qs.prototype._rand=function(e){var t=new Uint8Array(e);return self.crypto.getRandomValues(t),t}:self.msCrypto&&self.msCrypto.getRandomValues?qs.prototype._rand=function(e){var t=new Uint8Array(e);return self.msCrypto.getRandomValues(t),t}:typeof window=="object"&&(qs.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var U1=zd;if(typeof U1.randomBytes!="function")throw new Error("Not supported");qs.prototype._rand=function(e){return U1.randomBytes(e)}}catch{}var xv=Wd.exports,Yd={},oa=ws,Ic=Si,pf=Ic.getNAF,h9=Ic.getJSF,gf=Ic.assert;function Hs(r,e){this.type=r,this.p=new oa(e.p,16),this.red=e.prime?oa.red(e.prime):oa.mont(this.p),this.zero=new oa(0).toRed(this.red),this.one=new oa(1).toRed(this.red),this.two=new oa(2).toRed(this.red),this.n=e.n&&new oa(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 t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var qf=Hs;Hs.prototype.point=function(){throw new Error("Not implemented")};Hs.prototype.validate=function(){throw new Error("Not implemented")};Hs.prototype._fixedNafMul=function(e,t){gf(e.precomputed);var i=e._getDoubles(),n=pf(t,1,this._bitLength),a=(1<<i.step+1)-(i.step%2===0?2:1);a/=3;var c=[],f,g;for(f=0;f<n.length;f+=i.step){g=0;for(var d=f+i.step-1;d>=f;d--)g=(g<<1)+n[d];c.push(g)}for(var m=this.jpoint(null,null,null),w=this.jpoint(null,null,null),O=a;O>0;O--){for(f=0;f<c.length;f++)g=c[f],g===O?w=w.mixedAdd(i.points[f]):g===-O&&(w=w.mixedAdd(i.points[f].neg()));m=m.add(w)}return m.toP()};Hs.prototype._wnafMul=function(e,t){var i=4,n=e._getNAFPoints(i);i=n.wnd;for(var a=n.points,c=pf(t,i,this._bitLength),f=this.jpoint(null,null,null),g=c.length-1;g>=0;g--){for(var d=0;g>=0&&c[g]===0;g--)d++;if(g>=0&&d++,f=f.dblp(d),g<0)break;var m=c[g];gf(m!==0),e.type==="affine"?m>0?f=f.mixedAdd(a[m-1>>1]):f=f.mixedAdd(a[-m-1>>1].neg()):m>0?f=f.add(a[m-1>>1]):f=f.add(a[-m-1>>1].neg())}return e.type==="affine"?f.toP():f};Hs.prototype._wnafMulAdd=function(e,t,i,n,a){var c=this._wnafT1,f=this._wnafT2,g=this._wnafT3,d=0,m,w,O;for(m=0;m<n;m++){O=t[m];var C=O._getNAFPoints(e);c[m]=C.wnd,f[m]=C.points}for(m=n-1;m>=1;m-=2){var P=m-1,q=m;if(c[P]!==1||c[q]!==1){g[P]=pf(i[P],c[P],this._bitLength),g[q]=pf(i[q],c[q],this._bitLength),d=Math.max(g[P].length,d),d=Math.max(g[q].length,d);continue}var K=[t[P],null,null,t[q]];t[P].y.cmp(t[q].y)===0?(K[1]=t[P].add(t[q]),K[2]=t[P].toJ().mixedAdd(t[q].neg())):t[P].y.cmp(t[q].y.redNeg())===0?(K[1]=t[P].toJ().mixedAdd(t[q]),K[2]=t[P].add(t[q].neg())):(K[1]=t[P].toJ().mixedAdd(t[q]),K[2]=t[P].toJ().mixedAdd(t[q].neg()));var Y=[-3,-1,-5,-7,0,7,5,1,3],z=h9(i[P],i[q]);for(d=Math.max(z[0].length,d),g[P]=new Array(d),g[q]=new Array(d),w=0;w<d;w++){var W=z[0][w]|0,B=z[1][w]|0;g[P][w]=Y[(W+1)*3+(B+1)],g[q][w]=0,f[P]=K}}var j=this.jpoint(null,null,null),k=this._wnafT4;for(m=d;m>=0;m--){for(var _=0;m>=0;){var N=!0;for(w=0;w<n;w++)k[w]=g[w][m]|0,k[w]!==0&&(N=!1);if(!N)break;_++,m--}if(m>=0&&_++,j=j.dblp(_),m<0)break;for(w=0;w<n;w++){var se=k[w];se!==0&&(se>0?O=f[w][se-1>>1]:se<0&&(O=f[w][-se-1>>1].neg()),O.type==="affine"?j=j.mixedAdd(O):j=j.add(O))}}for(m=0;m<n;m++)f[m]=null;return a?j:j.toP()};function Gi(r,e){this.curve=r,this.type=e,this.precomputed=null}Hs.BasePoint=Gi;Gi.prototype.eq=function(){throw new Error("Not implemented")};Gi.prototype.validate=function(){return this.curve.validate(this)};Hs.prototype.decodePoint=function(e,t){e=Ic.toArray(e,t);var i=this.p.byteLength();if((e[0]===4||e[0]===6||e[0]===7)&&e.length-1===2*i){e[0]===6?gf(e[e.length-1]%2===0):e[0]===7&&gf(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")};Gi.prototype.encodeCompressed=function(e){return this.encode(e,!0)};Gi.prototype._encode=function(e){var t=this.curve.p.byteLength(),i=this.getX().toArray("be",t);return e?[this.getY().isEven()?2:3].concat(i):[4].concat(i,this.getY().toArray("be",t))};Gi.prototype.encode=function(e,t){return Ic.encode(this._encode(t),e)};Gi.prototype.precompute=function(e){if(this.precomputed)return this;var t={doubles:null,naf:null,beta:null};return t.naf=this._getNAFPoints(8),t.doubles=this._getDoubles(4,e),t.beta=this._getBeta(),this.precomputed=t,this};Gi.prototype._hasDoubles=function(e){if(!this.precomputed)return!1;var t=this.precomputed.doubles;return t?t.points.length>=Math.ceil((e.bitLength()+1)/t.step):!1};Gi.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,a=0;a<t;a+=e){for(var c=0;c<e;c++)n=n.dbl();i.push(n)}return{step:e,points:i}};Gi.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var t=[this],i=(1<<e)-1,n=i===1?null:this.dbl(),a=1;a<i;a++)t[a]=t[a-1].add(n);return{wnd:e,points:t}};Gi.prototype._getBeta=function(){return null};Gi.prototype.dblp=function(e){for(var t=this,i=0;i<e;i++)t=t.dbl();return t};var l9=Si,nr=ws,Qd=Pf,lo=qf,d9=l9.assert;function Ji(r){lo.call(this,"short",r),this.a=new nr(r.a,16).toRed(this.red),this.b=new nr(r.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(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}Qd(Ji,lo);var p9=Ji;Ji.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var t,i;if(e.beta)t=new nr(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=n[0].cmp(n[1])<0?n[0]:n[1],t=t.toRed(this.red)}if(e.lambda)i=new nr(e.lambda,16);else{var a=this._getEndoRoots(this.n);this.g.mul(a[0]).x.cmp(this.g.x.redMul(t))===0?i=a[0]:(i=a[1],d9(this.g.mul(i).x.cmp(this.g.x.redMul(t))===0))}var c;return e.basis?c=e.basis.map(function(f){return{a:new nr(f.a,16),b:new nr(f.b,16)}}):c=this._getEndoBasis(i),{beta:t,lambda:i,basis:c}}};Ji.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:nr.mont(e),i=new nr(2).toRed(t).redInvm(),n=i.redNeg(),a=new nr(3).toRed(t).redNeg().redSqrt().redMul(i),c=n.redAdd(a).fromRed(),f=n.redSub(a).fromRed();return[c,f]};Ji.prototype._getEndoBasis=function(e){for(var t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),a=new nr(1),c=new nr(0),f=new nr(0),g=new nr(1),d,m,w,O,C,P,q,K=0,Y,z;i.cmpn(0)!==0;){var W=n.div(i);Y=n.sub(W.mul(i)),z=f.sub(W.mul(a));var B=g.sub(W.mul(c));if(!w&&Y.cmp(t)<0)d=q.neg(),m=a,w=Y.neg(),O=z;else if(w&&++K===2)break;q=Y,n=i,i=Y,f=a,a=z,g=c,c=B}C=Y.neg(),P=z;var j=w.sqr().add(O.sqr()),k=C.sqr().add(P.sqr());return k.cmp(j)>=0&&(C=d,P=m),w.negative&&(w=w.neg(),O=O.neg()),C.negative&&(C=C.neg(),P=P.neg()),[{a:w,b:O},{a:C,b:P}]};Ji.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],a=n.b.mul(e).divRound(this.n),c=i.b.neg().mul(e).divRound(this.n),f=a.mul(i.a),g=c.mul(n.a),d=a.mul(i.b),m=c.mul(n.b),w=e.sub(f).sub(g),O=d.add(m).neg();return{k1:w,k2:O}};Ji.prototype.pointFromX=function(e,t){e=new nr(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 a=n.fromRed().isOdd();return(t&&!a||!t&&a)&&(n=n.redNeg()),this.point(e,n)};Ji.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),a=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(a).cmpn(0)===0};Ji.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,a=this._endoWnafT2,c=0;c<e.length;c++){var f=this._endoSplit(t[c]),g=e[c],d=g._getBeta();f.k1.negative&&(f.k1.ineg(),g=g.neg(!0)),f.k2.negative&&(f.k2.ineg(),d=d.neg(!0)),n[c*2]=g,n[c*2+1]=d,a[c*2]=f.k1,a[c*2+1]=f.k2}for(var m=this._wnafMulAdd(1,n,a,c*2,i),w=0;w<c*2;w++)n[w]=null,a[w]=null;return m};function Ar(r,e,t,i){lo.BasePoint.call(this,r,"affine"),e===null&&t===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new nr(e,16),this.y=new nr(t,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)}Qd(Ar,lo.BasePoint);Ji.prototype.point=function(e,t,i){return new Ar(this,e,t,i)};Ji.prototype.pointFromJSON=function(e,t){return Ar.fromJSON(this,e,t)};Ar.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var t=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var i=this.curve,n=function(a){return i.point(a.x.redMul(i.endo.beta),a.y)};e.beta=t,t.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 t}};Ar.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]};Ar.fromJSON=function(e,t,i){typeof t=="string"&&(t=JSON.parse(t));var n=e.point(t[0],t[1],i);if(!t[2])return n;function a(f){return e.point(f[0],f[1],i)}var c=t[2];return n.precomputed={beta:null,doubles:c.doubles&&{step:c.doubles.step,points:[n].concat(c.doubles.points.map(a))},naf:c.naf&&{wnd:c.naf.wnd,points:[n].concat(c.naf.points.map(a))}},n};Ar.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)+">"};Ar.prototype.isInfinity=function(){return this.inf};Ar.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 t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)};Ar.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 t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),a=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),c=a.redSqr().redISub(this.x.redAdd(this.x)),f=a.redMul(this.x.redSub(c)).redISub(this.y);return this.curve.point(c,f)};Ar.prototype.getX=function(){return this.x.fromRed()};Ar.prototype.getY=function(){return this.y.fromRed()};Ar.prototype.mul=function(e){return e=new nr(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)};Ar.prototype.mulAdd=function(e,t,i){var n=[this,t],a=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,a):this.curve._wnafMulAdd(1,n,a,2)};Ar.prototype.jmulAdd=function(e,t,i){var n=[this,t],a=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,a,!0):this.curve._wnafMulAdd(1,n,a,2,!0)};Ar.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)};Ar.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(a){return a.neg()};t.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 t};Ar.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 Cr(r,e,t,i){lo.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new nr(0)):(this.x=new nr(e,16),this.y=new nr(t,16),this.z=new nr(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}Qd(Cr,lo.BasePoint);Ji.prototype.jpoint=function(e,t,i){return new Cr(this,e,t,i)};Cr.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)};Cr.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};Cr.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),a=e.x.redMul(i),c=this.y.redMul(t.redMul(e.z)),f=e.y.redMul(i.redMul(this.z)),g=n.redSub(a),d=c.redSub(f);if(g.cmpn(0)===0)return d.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var m=g.redSqr(),w=m.redMul(g),O=n.redMul(m),C=d.redSqr().redIAdd(w).redISub(O).redISub(O),P=d.redMul(O.redISub(C)).redISub(c.redMul(w)),q=this.z.redMul(e.z).redMul(g);return this.curve.jpoint(C,P,q)};Cr.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),a=this.y,c=e.y.redMul(t).redMul(this.z),f=i.redSub(n),g=a.redSub(c);if(f.cmpn(0)===0)return g.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var d=f.redSqr(),m=d.redMul(f),w=i.redMul(d),O=g.redSqr().redIAdd(m).redISub(w).redISub(w),C=g.redMul(w.redISub(O)).redISub(a.redMul(m)),P=this.z.redMul(f);return this.curve.jpoint(O,C,P)};Cr.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t<e;t++)i=i.dbl();return i}var n=this.curve.a,a=this.curve.tinv,c=this.x,f=this.y,g=this.z,d=g.redSqr().redSqr(),m=f.redAdd(f);for(t=0;t<e;t++){var w=c.redSqr(),O=m.redSqr(),C=O.redSqr(),P=w.redAdd(w).redIAdd(w).redIAdd(n.redMul(d)),q=c.redMul(O),K=P.redSqr().redISub(q.redAdd(q)),Y=q.redISub(K),z=P.redMul(Y);z=z.redIAdd(z).redISub(C);var W=m.redMul(g);t+1<e&&(d=d.redMul(C)),c=K,g=W,m=z}return this.curve.jpoint(c,m.redMul(a),g)};Cr.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()};Cr.prototype._zeroDbl=function(){var e,t,i;if(this.zOne){var n=this.x.redSqr(),a=this.y.redSqr(),c=a.redSqr(),f=this.x.redAdd(a).redSqr().redISub(n).redISub(c);f=f.redIAdd(f);var g=n.redAdd(n).redIAdd(n),d=g.redSqr().redISub(f).redISub(f),m=c.redIAdd(c);m=m.redIAdd(m),m=m.redIAdd(m),e=d,t=g.redMul(f.redISub(d)).redISub(m),i=this.y.redAdd(this.y)}else{var w=this.x.redSqr(),O=this.y.redSqr(),C=O.redSqr(),P=this.x.redAdd(O).redSqr().redISub(w).redISub(C);P=P.redIAdd(P);var q=w.redAdd(w).redIAdd(w),K=q.redSqr(),Y=C.redIAdd(C);Y=Y.redIAdd(Y),Y=Y.redIAdd(Y),e=K.redISub(P).redISub(P),t=q.redMul(P.redISub(e)).redISub(Y),i=this.y.redMul(this.z),i=i.redIAdd(i)}return this.curve.jpoint(e,t,i)};Cr.prototype._threeDbl=function(){var e,t,i;if(this.zOne){var n=this.x.redSqr(),a=this.y.redSqr(),c=a.redSqr(),f=this.x.redAdd(a).redSqr().redISub(n).redISub(c);f=f.redIAdd(f);var g=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),d=g.redSqr().redISub(f).redISub(f);e=d;var m=c.redIAdd(c);m=m.redIAdd(m),m=m.redIAdd(m),t=g.redMul(f.redISub(d)).redISub(m),i=this.y.redAdd(this.y)}else{var w=this.z.redSqr(),O=this.y.redSqr(),C=this.x.redMul(O),P=this.x.redSub(w).redMul(this.x.redAdd(w));P=P.redAdd(P).redIAdd(P);var q=C.redIAdd(C);q=q.redIAdd(q);var K=q.redAdd(q);e=P.redSqr().redISub(K),i=this.y.redAdd(this.z).redSqr().redISub(O).redISub(w);var Y=O.redSqr();Y=Y.redIAdd(Y),Y=Y.redIAdd(Y),Y=Y.redIAdd(Y),t=P.redMul(q.redISub(e)).redISub(Y)}return this.curve.jpoint(e,t,i)};Cr.prototype._dbl=function(){var e=this.curve.a,t=this.x,i=this.y,n=this.z,a=n.redSqr().redSqr(),c=t.redSqr(),f=i.redSqr(),g=c.redAdd(c).redIAdd(c).redIAdd(e.redMul(a)),d=t.redAdd(t);d=d.redIAdd(d);var m=d.redMul(f),w=g.redSqr().redISub(m.redAdd(m)),O=m.redISub(w),C=f.redSqr();C=C.redIAdd(C),C=C.redIAdd(C),C=C.redIAdd(C);var P=g.redMul(O).redISub(C),q=i.redAdd(i).redMul(n);return this.curve.jpoint(w,P,q)};Cr.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),t=this.y.redSqr(),i=this.z.redSqr(),n=t.redSqr(),a=e.redAdd(e).redIAdd(e),c=a.redSqr(),f=this.x.redAdd(t).redSqr().redISub(e).redISub(n);f=f.redIAdd(f),f=f.redAdd(f).redIAdd(f),f=f.redISub(c);var g=f.redSqr(),d=n.redIAdd(n);d=d.redIAdd(d),d=d.redIAdd(d),d=d.redIAdd(d);var m=a.redIAdd(f).redSqr().redISub(c).redISub(g).redISub(d),w=t.redMul(m);w=w.redIAdd(w),w=w.redIAdd(w);var O=this.x.redMul(g).redISub(w);O=O.redIAdd(O),O=O.redIAdd(O);var C=this.y.redMul(m.redMul(d.redISub(m)).redISub(f.redMul(g)));C=C.redIAdd(C),C=C.redIAdd(C),C=C.redIAdd(C);var P=this.z.redAdd(f).redSqr().redISub(i).redISub(g);return this.curve.jpoint(O,C,P)};Cr.prototype.mul=function(e,t){return e=new nr(e,t),this.curve._wnafMul(this,e)};Cr.prototype.eq=function(e){if(e.type==="affine")return this.eq(e.toJ());if(this===e)return!0;var t=this.z.redSqr(),i=e.z.redSqr();if(this.x.redMul(i).redISub(e.x.redMul(t)).cmpn(0)!==0)return!1;var n=t.redMul(this.z),a=i.redMul(e.z);return this.y.redMul(a).redISub(e.y.redMul(n)).cmpn(0)===0};Cr.prototype.eqXToP=function(e){var t=this.z.redSqr(),i=e.toRed(this.curve.red).redMul(t);if(this.x.cmp(i)===0)return!0;for(var n=e.clone(),a=this.curve.redN.redMul(t);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(i.redIAdd(a),this.x.cmp(i)===0)return!0}};Cr.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)+">"};Cr.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var to=ws,Sv=Pf,Lf=qf,g9=Si;function po(r){Lf.call(this,"mont",r),this.a=new to(r.a,16).toRed(this.red),this.b=new to(r.b,16).toRed(this.red),this.i4=new to(4).toRed(this.red).redInvm(),this.two=new to(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}Sv(po,Lf);var b9=po;po.prototype.validate=function(e){var t=e.normalize().x,i=t.redSqr(),n=i.redMul(t).redAdd(i.redMul(this.a)).redAdd(t),a=n.redSqrt();return a.redSqr().cmp(n)===0};function Er(r,e,t){Lf.BasePoint.call(this,r,"projective"),e===null&&t===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new to(e,16),this.z=new to(t,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}Sv(Er,Lf.BasePoint);po.prototype.decodePoint=function(e,t){return this.point(g9.toArray(e,t),1)};po.prototype.point=function(e,t){return new Er(this,e,t)};po.prototype.pointFromJSON=function(e){return Er.fromJSON(this,e)};Er.prototype.precompute=function(){};Er.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())};Er.fromJSON=function(e,t){return new Er(e,t[0],t[1]||e.one)};Er.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)+">"};Er.prototype.isInfinity=function(){return this.z.cmpn(0)===0};Er.prototype.dbl=function(){var e=this.x.redAdd(this.z),t=e.redSqr(),i=this.x.redSub(this.z),n=i.redSqr(),a=t.redSub(n),c=t.redMul(n),f=a.redMul(n.redAdd(this.curve.a24.redMul(a)));return this.curve.point(c,f)};Er.prototype.add=function(){throw new Error("Not supported on Montgomery curve")};Er.prototype.diffAdd=function(e,t){var i=this.x.redAdd(this.z),n=this.x.redSub(this.z),a=e.x.redAdd(e.z),c=e.x.redSub(e.z),f=c.redMul(i),g=a.redMul(n),d=t.z.redMul(f.redAdd(g).redSqr()),m=t.x.redMul(f.redISub(g).redSqr());return this.curve.point(d,m)};Er.prototype.mul=function(e){for(var t=e.clone(),i=this,n=this.curve.point(null,null),a=this,c=[];t.cmpn(0)!==0;t.iushrn(1))c.push(t.andln(1));for(var f=c.length-1;f>=0;f--)c[f]===0?(i=i.diffAdd(n,a),n=n.dbl()):(n=i.diffAdd(n,a),i=i.dbl());return n};Er.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")};Er.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")};Er.prototype.eq=function(e){return this.getX().cmp(e.getX())===0};Er.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this};Er.prototype.getX=function(){return this.normalize(),this.x.fromRed()};var v9=Si,ps=ws,Mv=Pf,Ff=qf,m9=v9.assert;function Vn(r){this.twisted=(r.a|0)!==1,this.mOneA=this.twisted&&(r.a|0)===-1,this.extended=this.mOneA,Ff.call(this,"edwards",r),this.a=new ps(r.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new ps(r.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new ps(r.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),m9(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(r.c|0)===1}Mv(Vn,Ff);var y9=Vn;Vn.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)};Vn.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)};Vn.prototype.jpoint=function(e,t,i,n){return this.point(e,t,i,n)};Vn.prototype.pointFromX=function(e,t){e=new ps(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=this.c2.redSub(this.a.redMul(i)),a=this.one.redSub(this.c2.redMul(this.d).redMul(i)),c=n.redMul(a.redInvm()),f=c.redSqrt();if(f.redSqr().redSub(c).cmp(this.zero)!==0)throw new Error("invalid point");var g=f.fromRed().isOdd();return(t&&!g||!t&&g)&&(f=f.redNeg()),this.point(e,f)};Vn.prototype.pointFromY=function(e,t){e=new ps(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=i.redSub(this.c2),a=i.redMul(this.d).redMul(this.c2).redSub(this.a),c=n.redMul(a.redInvm());if(c.cmp(this.zero)===0){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var f=c.redSqrt();if(f.redSqr().redSub(c).cmp(this.zero)!==0)throw new Error("invalid point");return f.fromRed().isOdd()!==t&&(f=f.redNeg()),this.point(f,e)};Vn.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),i=e.y.redSqr(),n=t.redMul(this.a).redAdd(i),a=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(i)));return n.cmp(a)===0};function Jt(r,e,t,i,n){Ff.BasePoint.call(this,r,"projective"),e===null&&t===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 ps(e,16),this.y=new ps(t,16),this.z=i?new ps(i,16):this.curve.one,this.t=n&&new ps(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()))))}Mv(Jt,Ff.BasePoint);Vn.prototype.pointFromJSON=function(e){return Jt.fromJSON(this,e)};Vn.prototype.point=function(e,t,i,n){return new Jt(this,e,t,i,n)};Jt.fromJSON=function(e,t){return new Jt(e,t[0],t[1],t[2])};Jt.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)+">"};Jt.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)};Jt.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),i=this.z.redSqr();i=i.redIAdd(i);var n=this.curve._mulA(e),a=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),c=n.redAdd(t),f=c.redSub(i),g=n.redSub(t),d=a.redMul(f),m=c.redMul(g),w=a.redMul(g),O=f.redMul(c);return this.curve.point(d,m,O,w)};Jt.prototype._projDbl=function(){var e=this.x.redAdd(this.y).redSqr(),t=this.x.redSqr(),i=this.y.redSqr(),n,a,c,f,g,d;if(this.curve.twisted){f=this.curve._mulA(t);var m=f.redAdd(i);this.zOne?(n=e.redSub(t).redSub(i).redMul(m.redSub(this.curve.two)),a=m.redMul(f.redSub(i)),c=m.redSqr().redSub(m).redSub(m)):(g=this.z.redSqr(),d=m.redSub(g).redISub(g),n=e.redSub(t).redISub(i).redMul(d),a=m.redMul(f.redSub(i)),c=m.redMul(d))}else f=t.redAdd(i),g=this.curve._mulC(this.z).redSqr(),d=f.redSub(g).redSub(g),n=this.curve._mulC(e.redISub(f)).redMul(d),a=this.curve._mulC(f).redMul(t.redISub(i)),c=f.redMul(d);return this.curve.point(n,a,c)};Jt.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()};Jt.prototype._extAdd=function(e){var t=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),a=this.z.redMul(e.z.redAdd(e.z)),c=i.redSub(t),f=a.redSub(n),g=a.redAdd(n),d=i.redAdd(t),m=c.redMul(f),w=g.redMul(d),O=c.redMul(d),C=f.redMul(g);return this.curve.point(m,w,C,O)};Jt.prototype._projAdd=function(e){var t=this.z.redMul(e.z),i=t.redSqr(),n=this.x.redMul(e.x),a=this.y.redMul(e.y),c=this.curve.d.redMul(n).redMul(a),f=i.redSub(c),g=i.redAdd(c),d=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(n).redISub(a),m=t.redMul(f).redMul(d),w,O;return this.curve.twisted?(w=t.redMul(g).redMul(a.redSub(this.curve._mulA(n))),O=f.redMul(g)):(w=t.redMul(g).redMul(a.redSub(n)),O=this.curve._mulC(f).redMul(g)),this.curve.point(m,w,O)};Jt.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)};Jt.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)};Jt.prototype.mulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!1)};Jt.prototype.jmulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!0)};Jt.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};Jt.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())};Jt.prototype.getX=function(){return this.normalize(),this.x.fromRed()};Jt.prototype.getY=function(){return this.normalize(),this.y.fromRed()};Jt.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0};Jt.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(t)===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(t.redIAdd(n),this.x.cmp(t)===0)return!0}};Jt.prototype.toP=Jt.prototype.normalize;Jt.prototype.mixedAdd=Jt.prototype.add;(function(r){var e=r;e.base=qf,e.short=p9,e.mont=b9,e.edwards=y9})(Yd);var zf={},jf={},Ct={},w9=Da,_9=Pf;Ct.inherits=_9;function D9(r,e){return(r.charCodeAt(e)&64512)!==55296||e<0||e+1>=r.length?!1:(r.charCodeAt(e+1)&64512)===56320}function E9(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r=="string")if(e){if(e==="hex")for(r=r.replace(/[^a-z0-9]+/ig,""),r.length%2!==0&&(r="0"+r),n=0;n<r.length;n+=2)t.push(parseInt(r[n]+r[n+1],16))}else for(var i=0,n=0;n<r.length;n++){var a=r.charCodeAt(n);a<128?t[i++]=a:a<2048?(t[i++]=a>>6|192,t[i++]=a&63|128):D9(r,n)?(a=65536+((a&1023)<<10)+(r.charCodeAt(++n)&1023),t[i++]=a>>18|240,t[i++]=a>>12&63|128,t[i++]=a>>6&63|128,t[i++]=a&63|128):(t[i++]=a>>12|224,t[i++]=a>>6&63|128,t[i++]=a&63|128)}else for(n=0;n<r.length;n++)t[n]=r[n]|0;return t}Ct.toArray=E9;function A9(r){for(var e="",t=0;t<r.length;t++)e+=Cv(r[t].toString(16));return e}Ct.toHex=A9;function Iv(r){var e=r>>>24|r>>>8&65280|r<<8&16711680|(r&255)<<24;return e>>>0}Ct.htonl=Iv;function x9(r,e){for(var t="",i=0;i<r.length;i++){var n=r[i];e==="little"&&(n=Iv(n)),t+=Pv(n.toString(16))}return t}Ct.toHex32=x9;function Cv(r){return r.length===1?"0"+r:r}Ct.zero2=Cv;function Pv(r){return r.length===7?"0"+r:r.length===6?"00"+r:r.length===5?"000"+r:r.length===4?"0000"+r:r.length===3?"00000"+r:r.length===2?"000000"+r:r.length===1?"0000000"+r:r}Ct.zero8=Pv;function S9(r,e,t,i){var n=t-e;w9(n%4===0);for(var a=new Array(n/4),c=0,f=e;c<a.length;c++,f+=4){var g;i==="big"?g=r[f]<<24|r[f+1]<<16|r[f+2]<<8|r[f+3]:g=r[f+3]<<24|r[f+2]<<16|r[f+1]<<8|r[f],a[c]=g>>>0}return a}Ct.join32=S9;function M9(r,e){for(var t=new Array(r.length*4),i=0,n=0;i<r.length;i++,n+=4){var a=r[i];e==="big"?(t[n]=a>>>24,t[n+1]=a>>>16&255,t[n+2]=a>>>8&255,t[n+3]=a&255):(t[n+3]=a>>>24,t[n+2]=a>>>16&255,t[n+1]=a>>>8&255,t[n]=a&255)}return t}Ct.split32=M9;function I9(r,e){return r>>>e|r<<32-e}Ct.rotr32=I9;function C9(r,e){return r<<e|r>>>32-e}Ct.rotl32=C9;function P9(r,e){return r+e>>>0}Ct.sum32=P9;function O9(r,e,t){return r+e+t>>>0}Ct.sum32_3=O9;function T9(r,e,t,i){return r+e+t+i>>>0}Ct.sum32_4=T9;function R9(r,e,t,i,n){return r+e+t+i+n>>>0}Ct.sum32_5=R9;function N9(r,e,t,i){var n=r[e],a=r[e+1],c=i+a>>>0,f=(c<i?1:0)+t+n;r[e]=f>>>0,r[e+1]=c}Ct.sum64=N9;function B9(r,e,t,i){var n=e+i>>>0,a=(n<e?1:0)+r+t;return a>>>0}Ct.sum64_hi=B9;function $9(r,e,t,i){var n=e+i;return n>>>0}Ct.sum64_lo=$9;function U9(r,e,t,i,n,a,c,f){var g=0,d=e;d=d+i>>>0,g+=d<e?1:0,d=d+a>>>0,g+=d<a?1:0,d=d+f>>>0,g+=d<f?1:0;var m=r+t+n+c+g;return m>>>0}Ct.sum64_4_hi=U9;function q9(r,e,t,i,n,a,c,f){var g=e+i+a+f;return g>>>0}Ct.sum64_4_lo=q9;function L9(r,e,t,i,n,a,c,f,g,d){var m=0,w=e;w=w+i>>>0,m+=w<e?1:0,w=w+a>>>0,m+=w<a?1:0,w=w+f>>>0,m+=w<f?1:0,w=w+d>>>0,m+=w<d?1:0;var O=r+t+n+c+g+m;return O>>>0}Ct.sum64_5_hi=L9;function F9(r,e,t,i,n,a,c,f,g,d){var m=e+i+a+f+d;return m>>>0}Ct.sum64_5_lo=F9;function z9(r,e,t){var i=e<<32-t|r>>>t;return i>>>0}Ct.rotr64_hi=z9;function j9(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ct.rotr64_lo=j9;function k9(r,e,t){return r>>>t}Ct.shr64_hi=k9;function H9(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ct.shr64_lo=H9;var go={},q1=Ct,K9=Da;function kf(){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}go.BlockHash=kf;kf.prototype.update=function(e,t){if(e=q1.toArray(e,t),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=q1.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};kf.prototype.digest=function(e){return this.update(this._pad()),K9(this.pending===null),this._digest(e)};kf.prototype._pad=function(){var e=this.pendingTotal,t=this._delta8,i=t-(e+this.padLength)%t,n=new Array(i+this.padLength);n[0]=128;for(var a=1;a<i;a++)n[a]=0;if(e<<=3,this.endian==="big"){for(var c=8;c<this.padLength;c++)n[a++]=0;n[a++]=0,n[a++]=0,n[a++]=0,n[a++]=0,n[a++]=e>>>24&255,n[a++]=e>>>16&255,n[a++]=e>>>8&255,n[a++]=e&255}else for(n[a++]=e&255,n[a++]=e>>>8&255,n[a++]=e>>>16&255,n[a++]=e>>>24&255,n[a++]=0,n[a++]=0,n[a++]=0,n[a++]=0,c=8;c<this.padLength;c++)n[a++]=0;return n};var bo={},Gn={},V9=Ct,Rn=V9.rotr32;function G9(r,e,t,i){if(r===0)return Ov(e,t,i);if(r===1||r===3)return Rv(e,t,i);if(r===2)return Tv(e,t,i)}Gn.ft_1=G9;function Ov(r,e,t){return r&e^~r&t}Gn.ch32=Ov;function Tv(r,e,t){return r&e^r&t^e&t}Gn.maj32=Tv;function Rv(r,e,t){return r^e^t}Gn.p32=Rv;function J9(r){return Rn(r,2)^Rn(r,13)^Rn(r,22)}Gn.s0_256=J9;function W9(r){return Rn(r,6)^Rn(r,11)^Rn(r,25)}Gn.s1_256=W9;function Y9(r){return Rn(r,7)^Rn(r,18)^r>>>3}Gn.g0_256=Y9;function Q9(r){return Rn(r,17)^Rn(r,19)^r>>>10}Gn.g1_256=Q9;var so=Ct,X9=go,Z9=Gn,Dl=so.rotl32,Wo=so.sum32,eD=so.sum32_5,tD=Z9.ft_1,Nv=X9.BlockHash,rD=[1518500249,1859775393,2400959708,3395469782];function zn(){if(!(this instanceof zn))return new zn;Nv.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}so.inherits(zn,Nv);var iD=zn;zn.blockSize=512;zn.outSize=160;zn.hmacStrength=80;zn.padLength=64;zn.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n<i.length;n++)i[n]=Dl(i[n-3]^i[n-8]^i[n-14]^i[n-16],1);var a=this.h[0],c=this.h[1],f=this.h[2],g=this.h[3],d=this.h[4];for(n=0;n<i.length;n++){var m=~~(n/20),w=eD(Dl(a,5),tD(m,c,f,g),d,i[n],rD[m]);d=g,g=f,f=Dl(c,30),c=a,a=w}this.h[0]=Wo(this.h[0],a),this.h[1]=Wo(this.h[1],c),this.h[2]=Wo(this.h[2],f),this.h[3]=Wo(this.h[3],g),this.h[4]=Wo(this.h[4],d)};zn.prototype._digest=function(e){return e==="hex"?so.toHex32(this.h,"big"):so.split32(this.h,"big")};var ao=Ct,nD=go,vo=Gn,sD=Da,on=ao.sum32,aD=ao.sum32_4,oD=ao.sum32_5,cD=vo.ch32,uD=vo.maj32,fD=vo.s0_256,hD=vo.s1_256,lD=vo.g0_256,dD=vo.g1_256,Bv=nD.BlockHash,pD=[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 jn(){if(!(this instanceof jn))return new jn;Bv.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=pD,this.W=new Array(64)}ao.inherits(jn,Bv);var $v=jn;jn.blockSize=512;jn.outSize=256;jn.hmacStrength=192;jn.padLength=64;jn.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n<i.length;n++)i[n]=aD(dD(i[n-2]),i[n-7],lD(i[n-15]),i[n-16]);var a=this.h[0],c=this.h[1],f=this.h[2],g=this.h[3],d=this.h[4],m=this.h[5],w=this.h[6],O=this.h[7];for(sD(this.k.length===i.length),n=0;n<i.length;n++){var C=oD(O,hD(d),cD(d,m,w),this.k[n],i[n]),P=on(fD(a),uD(a,c,f));O=w,w=m,m=d,d=on(g,C),g=f,f=c,c=a,a=on(C,P)}this.h[0]=on(this.h[0],a),this.h[1]=on(this.h[1],c),this.h[2]=on(this.h[2],f),this.h[3]=on(this.h[3],g),this.h[4]=on(this.h[4],d),this.h[5]=on(this.h[5],m),this.h[6]=on(this.h[6],w),this.h[7]=on(this.h[7],O)};jn.prototype._digest=function(e){return e==="hex"?ao.toHex32(this.h,"big"):ao.split32(this.h,"big")};var gd=Ct,Uv=$v;function vs(){if(!(this instanceof vs))return new vs;Uv.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}gd.inherits(vs,Uv);var gD=vs;vs.blockSize=512;vs.outSize=224;vs.hmacStrength=192;vs.padLength=64;vs.prototype._digest=function(e){return e==="hex"?gd.toHex32(this.h.slice(0,7),"big"):gd.split32(this.h.slice(0,7),"big")};var hi=Ct,bD=go,vD=Da,Nn=hi.rotr64_hi,Bn=hi.rotr64_lo,qv=hi.shr64_hi,Lv=hi.shr64_lo,Os=hi.sum64,El=hi.sum64_hi,Al=hi.sum64_lo,mD=hi.sum64_4_hi,yD=hi.sum64_4_lo,wD=hi.sum64_5_hi,_D=hi.sum64_5_lo,Fv=bD.BlockHash,DD=[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 gn(){if(!(this instanceof gn))return new gn;Fv.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=DD,this.W=new Array(160)}hi.inherits(gn,Fv);var zv=gn;gn.blockSize=1024;gn.outSize=512;gn.hmacStrength=192;gn.padLength=128;gn.prototype._prepareBlock=function(e,t){for(var i=this.W,n=0;n<32;n++)i[n]=e[t+n];for(;n<i.length;n+=2){var a=RD(i[n-4],i[n-3]),c=ND(i[n-4],i[n-3]),f=i[n-14],g=i[n-13],d=OD(i[n-30],i[n-29]),m=TD(i[n-30],i[n-29]),w=i[n-32],O=i[n-31];i[n]=mD(a,c,f,g,d,m,w,O),i[n+1]=yD(a,c,f,g,d,m,w,O)}};gn.prototype._update=function(e,t){this._prepareBlock(e,t);var i=this.W,n=this.h[0],a=this.h[1],c=this.h[2],f=this.h[3],g=this.h[4],d=this.h[5],m=this.h[6],w=this.h[7],O=this.h[8],C=this.h[9],P=this.h[10],q=this.h[11],K=this.h[12],Y=this.h[13],z=this.h[14],W=this.h[15];vD(this.k.length===i.length);for(var B=0;B<i.length;B+=2){var j=z,k=W,_=CD(O,C),N=PD(O,C),se=ED(O,C,P,q,K),le=AD(O,C,P,q,K,Y),U=this.k[B],y=this.k[B+1],u=i[B],h=i[B+1],v=wD(j,k,_,N,se,le,U,y,u,h),E=_D(j,k,_,N,se,le,U,y,u,h);j=MD(n,a),k=ID(n,a),_=xD(n,a,c,f,g),N=SD(n,a,c,f,g,d);var S=El(j,k,_,N),M=Al(j,k,_,N);z=K,W=Y,K=P,Y=q,P=O,q=C,O=El(m,w,v,E),C=Al(w,w,v,E),m=g,w=d,g=c,d=f,c=n,f=a,n=El(v,E,S,M),a=Al(v,E,S,M)}Os(this.h,0,n,a),Os(this.h,2,c,f),Os(this.h,4,g,d),Os(this.h,6,m,w),Os(this.h,8,O,C),Os(this.h,10,P,q),Os(this.h,12,K,Y),Os(this.h,14,z,W)};gn.prototype._digest=function(e){return e==="hex"?hi.toHex32(this.h,"big"):hi.split32(this.h,"big")};function ED(r,e,t,i,n){var a=r&t^~r&n;return a<0&&(a+=4294967296),a}function AD(r,e,t,i,n,a){var c=e&i^~e&a;return c<0&&(c+=4294967296),c}function xD(r,e,t,i,n){var a=r&t^r&n^t&n;return a<0&&(a+=4294967296),a}function SD(r,e,t,i,n,a){var c=e&i^e&a^i&a;return c<0&&(c+=4294967296),c}function MD(r,e){var t=Nn(r,e,28),i=Nn(e,r,2),n=Nn(e,r,7),a=t^i^n;return a<0&&(a+=4294967296),a}function ID(r,e){var t=Bn(r,e,28),i=Bn(e,r,2),n=Bn(e,r,7),a=t^i^n;return a<0&&(a+=4294967296),a}function CD(r,e){var t=Nn(r,e,14),i=Nn(r,e,18),n=Nn(e,r,9),a=t^i^n;return a<0&&(a+=4294967296),a}function PD(r,e){var t=Bn(r,e,14),i=Bn(r,e,18),n=Bn(e,r,9),a=t^i^n;return a<0&&(a+=4294967296),a}function OD(r,e){var t=Nn(r,e,1),i=Nn(r,e,8),n=qv(r,e,7),a=t^i^n;return a<0&&(a+=4294967296),a}function TD(r,e){var t=Bn(r,e,1),i=Bn(r,e,8),n=Lv(r,e,7),a=t^i^n;return a<0&&(a+=4294967296),a}function RD(r,e){var t=Nn(r,e,19),i=Nn(e,r,29),n=qv(r,e,6),a=t^i^n;return a<0&&(a+=4294967296),a}function ND(r,e){var t=Bn(r,e,19),i=Bn(e,r,29),n=Lv(r,e,6),a=t^i^n;return a<0&&(a+=4294967296),a}var bd=Ct,jv=zv;function ms(){if(!(this instanceof ms))return new ms;jv.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}bd.inherits(ms,jv);var BD=ms;ms.blockSize=1024;ms.outSize=384;ms.hmacStrength=192;ms.padLength=128;ms.prototype._digest=function(e){return e==="hex"?bd.toHex32(this.h.slice(0,12),"big"):bd.split32(this.h.slice(0,12),"big")};bo.sha1=iD;bo.sha224=gD;bo.sha256=$v;bo.sha384=BD;bo.sha512=zv;var kv={},va=Ct,$D=go,ku=va.rotl32,L1=va.sum32,Yo=va.sum32_3,F1=va.sum32_4,Hv=$D.BlockHash;function kn(){if(!(this instanceof kn))return new kn;Hv.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}va.inherits(kn,Hv);kv.ripemd160=kn;kn.blockSize=512;kn.outSize=160;kn.hmacStrength=192;kn.padLength=64;kn.prototype._update=function(e,t){for(var i=this.h[0],n=this.h[1],a=this.h[2],c=this.h[3],f=this.h[4],g=i,d=n,m=a,w=c,O=f,C=0;C<80;C++){var P=L1(ku(F1(i,z1(C,n,a,c),e[LD[C]+t],UD(C)),zD[C]),f);i=f,f=c,c=ku(a,10),a=n,n=P,P=L1(ku(F1(g,z1(79-C,d,m,w),e[FD[C]+t],qD(C)),jD[C]),O),g=O,O=w,w=ku(m,10),m=d,d=P}P=Yo(this.h[1],a,w),this.h[1]=Yo(this.h[2],c,O),this.h[2]=Yo(this.h[3],f,g),this.h[3]=Yo(this.h[4],i,d),this.h[4]=Yo(this.h[0],n,m),this.h[0]=P};kn.prototype._digest=function(e){return e==="hex"?va.toHex32(this.h,"little"):va.split32(this.h,"little")};function z1(r,e,t,i){return r<=15?e^t^i:r<=31?e&t|~e&i:r<=47?(e|~t)^i:r<=63?e&i|t&~i:e^(t|~i)}function UD(r){return r<=15?0:r<=31?1518500249:r<=47?1859775393:r<=63?2400959708:2840853838}function qD(r){return r<=15?1352829926:r<=31?1548603684:r<=47?1836072691:r<=63?2053994217:0}var LD=[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],FD=[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],zD=[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],jD=[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],kD=Ct,HD=Da;function oo(r,e,t){if(!(this instanceof oo))return new oo(r,e,t);this.Hash=r,this.blockSize=r.blockSize/8,this.outSize=r.outSize/8,this.inner=null,this.outer=null,this._init(kD.toArray(e,t))}var KD=oo;oo.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),HD(e.length<=this.blockSize);for(var t=e.length;t<this.blockSize;t++)e.push(0);for(t=0;t<e.length;t++)e[t]^=54;for(this.inner=new this.Hash().update(e),t=0;t<e.length;t++)e[t]^=106;this.outer=new this.Hash().update(e)};oo.prototype.update=function(e,t){return this.inner.update(e,t),this};oo.prototype.digest=function(e){return this.outer.update(this.inner.digest()),this.outer.digest(e)};(function(r){var e=r;e.utils=Ct,e.common=go,e.sha=bo,e.ripemd=kv,e.hmac=KD,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})(jf);var xl,j1;function VD(){return j1||(j1=1,xl={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"]]}}),xl}(function(r){var e=r,t=jf,i=Yd,n=Si,a=n.assert;function c(d){d.type==="short"?this.curve=new i.short(d):d.type==="edwards"?this.curve=new i.edwards(d):this.curve=new i.mont(d),this.g=this.curve.g,this.n=this.curve.n,this.hash=d.hash,a(this.g.validate(),"Invalid curve"),a(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}e.PresetCurve=c;function f(d,m){Object.defineProperty(e,d,{configurable:!0,enumerable:!0,get:function(){var w=new c(m);return Object.defineProperty(e,d,{configurable:!0,enumerable:!0,value:w}),w}})}f("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:t.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),f("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:t.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),f("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:t.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),f("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:t.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),f("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:t.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),f("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:t.sha256,gRed:!1,g:["9"]}),f("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:t.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var g;try{g=VD()}catch{g=void 0}f("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:t.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",g]})})(zf);var GD=jf,pa=Jd,Kv=Da;function zs(r){if(!(this instanceof zs))return new zs(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=pa.toArray(r.entropy,r.entropyEnc||"hex"),t=pa.toArray(r.nonce,r.nonceEnc||"hex"),i=pa.toArray(r.pers,r.persEnc||"hex");Kv(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}var JD=zs;zs.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var a=0;a<this.V.length;a++)this.K[a]=0,this.V[a]=1;this._update(n),this._reseed=1,this.reseedInterval=281474976710656};zs.prototype._hmac=function(){return new GD.hmac(this.hash,this.K)};zs.prototype._update=function(e){var t=this._hmac().update(this.V).update([0]);e&&(t=t.update(e)),this.K=t.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())};zs.prototype.reseed=function(e,t,i,n){typeof t!="string"&&(n=i,i=t,t=null),e=pa.toArray(e,t),i=pa.toArray(i,n),Kv(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1};zs.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=pa.toArray(i,n||"hex"),this._update(i));for(var a=[];a.length<e;)this.V=this._hmac().update(this.V).digest(),a=a.concat(this.V);var c=a.slice(0,e);return this._update(i),this._reseed++,pa.encode(c,t)};var WD=ws,YD=Si,vd=YD.assert;function jr(r,e){this.ec=r,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var QD=jr;jr.fromPublic=function(e,t,i){return t instanceof jr?t:new jr(e,{pub:t,pubEnc:i})};jr.fromPrivate=function(e,t,i){return t instanceof jr?t:new jr(e,{priv:t,privEnc:i})};jr.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"}};jr.prototype.getPublic=function(e,t){return typeof e=="string"&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub};jr.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv};jr.prototype._importPrivate=function(e,t){this.priv=new WD(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)};jr.prototype._importPublic=function(e,t){if(e.x||e.y){this.ec.curve.type==="mont"?vd(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&vd(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,t)};jr.prototype.derive=function(e){return e.validate()||vd(e.validate(),"public point not validated"),e.mul(this.priv).getX()};jr.prototype.sign=function(e,t,i){return this.ec.sign(e,this,t,i)};jr.prototype.verify=function(e,t,i){return this.ec.verify(e,t,this,void 0,i)};jr.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var bf=ws,Xd=Si,XD=Xd.assert;function Hf(r,e){if(r instanceof Hf)return r;this._importDER(r,e)||(XD(r.r&&r.s,"Signature without r or s"),this.r=new bf(r.r,16),this.s=new bf(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}var ZD=Hf;function eE(){this.place=0}function Sl(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4||r[e.place]===0)return!1;for(var n=0,a=0,c=e.place;a<i;a++,c++)n<<=8,n|=r[c],n>>>=0;return n<=127?!1:(e.place=c,n)}function k1(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e<t;)e++;return e===0?r:r.slice(e)}Hf.prototype._importDER=function(e,t){e=Xd.toArray(e,t);var i=new eE;if(e[i.place++]!==48)return!1;var n=Sl(e,i);if(n===!1||n+i.place!==e.length||e[i.place++]!==2)return!1;var a=Sl(e,i);if(a===!1||e[i.place]&128)return!1;var c=e.slice(i.place,a+i.place);if(i.place+=a,e[i.place++]!==2)return!1;var f=Sl(e,i);if(f===!1||e.length!==f+i.place||e[i.place]&128)return!1;var g=e.slice(i.place,f+i.place);if(c[0]===0)if(c[1]&128)c=c.slice(1);else return!1;if(g[0]===0)if(g[1]&128)g=g.slice(1);else return!1;return this.r=new bf(c),this.s=new bf(g),this.recoveryParam=null,!0};function Ml(r,e){if(e<128){r.push(e);return}var t=1+(Math.log(e)/Math.LN2>>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}Hf.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=k1(t),i=k1(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];Ml(n,t.length),n=n.concat(t),n.push(2),Ml(n,i.length);var a=n.concat(i),c=[48];return Ml(c,a.length),c=c.concat(a),Xd.encode(c,e)};var gs=ws,Vv=JD,tE=Si,Il=zf,rE=xv,Gv=tE.assert,Zd=QD,Kf=ZD;function Ki(r){if(!(this instanceof Ki))return new Ki(r);typeof r=="string"&&(Gv(Object.prototype.hasOwnProperty.call(Il,r),"Unknown curve "+r),r=Il[r]),r instanceof Il.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}var iE=Ki;Ki.prototype.keyPair=function(e){return new Zd(this,e)};Ki.prototype.keyFromPrivate=function(e,t){return Zd.fromPrivate(this,e,t)};Ki.prototype.keyFromPublic=function(e,t){return Zd.fromPublic(this,e,t)};Ki.prototype.genKeyPair=function(e){e||(e={});for(var t=new Vv({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||rE(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new gs(2));;){var a=new gs(t.generate(i));if(!(a.cmp(n)>0))return a.iaddn(1),this.keyFromPrivate(a)}};Ki.prototype._truncateToN=function(e,t,i){var n;if(gs.isBN(e)||typeof e=="number")e=new gs(e,16),n=e.byteLength();else if(typeof e=="object")n=e.length,e=new gs(e,16);else{var a=e.toString();n=a.length+1>>>1,e=new gs(a,16)}typeof i!="number"&&(i=n*8);var c=i-this.n.bitLength();return c>0&&(e=e.ushrn(c)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};Ki.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(e,!1,n.msgBitLength);for(var a=this.n.byteLength(),c=t.getPrivate().toArray("be",a),f=e.toArray("be",a),g=new Vv({hash:this.hash,entropy:c,nonce:f,pers:n.pers,persEnc:n.persEnc||"utf8"}),d=this.n.sub(new gs(1)),m=0;;m++){var w=n.k?n.k(m):new gs(g.generate(this.n.byteLength()));if(w=this._truncateToN(w,!0),!(w.cmpn(1)<=0||w.cmp(d)>=0)){var O=this.g.mul(w);if(!O.isInfinity()){var C=O.getX(),P=C.umod(this.n);if(P.cmpn(0)!==0){var q=w.invm(this.n).mul(P.mul(t.getPrivate()).iadd(e));if(q=q.umod(this.n),q.cmpn(0)!==0){var K=(O.getY().isOdd()?1:0)|(C.cmp(P)!==0?2:0);return n.canonical&&q.cmp(this.nh)>0&&(q=this.n.sub(q),K^=1),new Kf({r:P,s:q,recoveryParam:K})}}}}}};Ki.prototype.verify=function(e,t,i,n,a){a||(a={}),e=this._truncateToN(e,!1,a.msgBitLength),i=this.keyFromPublic(i,n),t=new Kf(t,"hex");var c=t.r,f=t.s;if(c.cmpn(1)<0||c.cmp(this.n)>=0||f.cmpn(1)<0||f.cmp(this.n)>=0)return!1;var g=f.invm(this.n),d=g.mul(e).umod(this.n),m=g.mul(c).umod(this.n),w;return this.curve._maxwellTrick?(w=this.g.jmulAdd(d,i.getPublic(),m),w.isInfinity()?!1:w.eqXToP(c)):(w=this.g.mulAdd(d,i.getPublic(),m),w.isInfinity()?!1:w.getX().umod(this.n).cmp(c)===0)};Ki.prototype.recoverPubKey=function(r,e,t,i){Gv((3&t)===t,"The recovery param is more than two bits"),e=new Kf(e,i);var n=this.n,a=new gs(r),c=e.r,f=e.s,g=t&1,d=t>>1;if(c.cmp(this.curve.p.umod(this.curve.n))>=0&&d)throw new Error("Unable to find sencond key candinate");d?c=this.curve.pointFromX(c.add(this.curve.n),g):c=this.curve.pointFromX(c,g);var m=e.r.invm(n),w=n.sub(a).mul(m).umod(n),O=f.mul(m).umod(n);return this.g.mulAdd(w,c,O)};Ki.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new Kf(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var a;try{a=this.recoverPubKey(r,e,n)}catch{continue}if(a.eq(t))return n}throw new Error("Unable to find valid recovery factor")};var Cc=Si,Jv=Cc.assert,H1=Cc.parseBytes,mo=Cc.cachedProperty;function Dr(r,e){this.eddsa=r,this._secret=H1(e.secret),r.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=H1(e.pub)}Dr.fromPublic=function(e,t){return t instanceof Dr?t:new Dr(e,{pub:t})};Dr.fromSecret=function(e,t){return t instanceof Dr?t:new Dr(e,{secret:t})};Dr.prototype.secret=function(){return this._secret};mo(Dr,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())});mo(Dr,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())});mo(Dr,"privBytes",function(){var e=this.eddsa,t=this.hash(),i=e.encodingLength-1,n=t.slice(0,e.encodingLength);return n[0]&=248,n[i]&=127,n[i]|=64,n});mo(Dr,"priv",function(){return this.eddsa.decodeInt(this.privBytes())});mo(Dr,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()});mo(Dr,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)});Dr.prototype.sign=function(e){return Jv(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)};Dr.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)};Dr.prototype.getSecret=function(e){return Jv(this._secret,"KeyPair is public only"),Cc.encode(this.secret(),e)};Dr.prototype.getPublic=function(e){return Cc.encode(this.pubBytes(),e)};var nE=Dr,sE=ws,Vf=Si,K1=Vf.assert,Gf=Vf.cachedProperty,aE=Vf.parseBytes;function Ea(r,e){this.eddsa=r,typeof e!="object"&&(e=aE(e)),Array.isArray(e)&&(K1(e.length===r.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,r.encodingLength),S:e.slice(r.encodingLength)}),K1(e.R&&e.S,"Signature without R or S"),r.isPoint(e.R)&&(this._R=e.R),e.S instanceof sE&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}Gf(Ea,"S",function(){return this.eddsa.decodeInt(this.Sencoded())});Gf(Ea,"R",function(){return this.eddsa.decodePoint(this.Rencoded())});Gf(Ea,"Rencoded",function(){return this.eddsa.encodePoint(this.R())});Gf(Ea,"Sencoded",function(){return this.eddsa.encodeInt(this.S())});Ea.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())};Ea.prototype.toHex=function(){return Vf.encode(this.toBytes(),"hex").toUpperCase()};var oE=Ea,cE=jf,uE=zf,co=Si,fE=co.assert,Wv=co.parseBytes,Yv=nE,V1=oE;function li(r){if(fE(r==="ed25519","only tested with ed25519 so far"),!(this instanceof li))return new li(r);r=uE[r].curve,this.curve=r,this.g=r.g,this.g.precompute(r.n.bitLength()+1),this.pointClass=r.point().constructor,this.encodingLength=Math.ceil(r.n.bitLength()/8),this.hash=cE.sha512}var hE=li;li.prototype.sign=function(e,t){e=Wv(e);var i=this.keyFromSecret(t),n=this.hashInt(i.messagePrefix(),e),a=this.g.mul(n),c=this.encodePoint(a),f=this.hashInt(c,i.pubBytes(),e).mul(i.priv()),g=n.add(f).umod(this.curve.n);return this.makeSignature({R:a,S:g,Rencoded:c})};li.prototype.verify=function(e,t,i){if(e=Wv(e),t=this.makeSignature(t),t.S().gte(t.eddsa.curve.n)||t.S().isNeg())return!1;var n=this.keyFromPublic(i),a=this.hashInt(t.Rencoded(),n.pubBytes(),e),c=this.g.mul(t.S()),f=t.R().add(n.pub().mul(a));return f.eq(c)};li.prototype.hashInt=function(){for(var e=this.hash(),t=0;t<arguments.length;t++)e.update(arguments[t]);return co.intFromLE(e.digest()).umod(this.curve.n)};li.prototype.keyFromPublic=function(e){return Yv.fromPublic(this,e)};li.prototype.keyFromSecret=function(e){return Yv.fromSecret(this,e)};li.prototype.makeSignature=function(e){return e instanceof V1?e:new V1(this,e)};li.prototype.encodePoint=function(e){var t=e.getY().toArray("le",this.encodingLength);return t[this.encodingLength-1]|=e.getX().isOdd()?128:0,t};li.prototype.decodePoint=function(e){e=co.parseBytes(e);var t=e.length-1,i=e.slice(0,t).concat(e[t]&-129),n=(e[t]&128)!==0,a=co.intFromLE(i);return this.curve.pointFromY(a,n)};li.prototype.encodeInt=function(e){return e.toArray("le",this.encodingLength)};li.prototype.decodeInt=function(e){return co.intFromLE(e)};li.prototype.isPoint=function(e){return e instanceof this.pointClass};(function(r){var e=r;e.version=f9.version,e.utils=Si,e.rand=xv,e.curve=Yd,e.curves=zf,e.ec=iE,e.eddsa=hE})(Ev);var e0={},Qv={};(function(r){Object.defineProperty(r,"__esModule",{value:!0});var e=mt,t=xi;r.DIGEST_LENGTH=64,r.BLOCK_SIZE=128;var i=function(){function f(){this.digestLength=r.DIGEST_LENGTH,this.blockSize=r.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 f.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},f.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},f.prototype.clean=function(){t.wipe(this._buffer),t.wipe(this._tempHi),t.wipe(this._tempLo),this.reset()},f.prototype.update=function(g,d){if(d===void 0&&(d=g.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var m=0;if(this._bytesHashed+=d,this._bufferLength>0){for(;this._bufferLength<r.BLOCK_SIZE&&d>0;)this._buffer[this._bufferLength++]=g[m++],d--;this._bufferLength===this.blockSize&&(a(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(d>=this.blockSize&&(m=a(this._tempHi,this._tempLo,this._stateHi,this._stateLo,g,m,d),d%=this.blockSize);d>0;)this._buffer[this._bufferLength++]=g[m++],d--;return this},f.prototype.finish=function(g){if(!this._finished){var d=this._bytesHashed,m=this._bufferLength,w=d/536870912|0,O=d<<3,C=d%128<112?128:256;this._buffer[m]=128;for(var P=m+1;P<C-8;P++)this._buffer[P]=0;e.writeUint32BE(w,this._buffer,C-8),e.writeUint32BE(O,this._buffer,C-4),a(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,C),this._finished=!0}for(var P=0;P<this.digestLength/8;P++)e.writeUint32BE(this._stateHi[P],g,P*8),e.writeUint32BE(this._stateLo[P],g,P*8+4);return this},f.prototype.digest=function(){var g=new Uint8Array(this.digestLength);return this.finish(g),g},f.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}},f.prototype.restoreState=function(g){return this._stateHi.set(g.stateHi),this._stateLo.set(g.stateLo),this._bufferLength=g.bufferLength,g.buffer&&this._buffer.set(g.buffer),this._bytesHashed=g.bytesHashed,this._finished=!1,this},f.prototype.cleanSavedState=function(g){t.wipe(g.stateHi),t.wipe(g.stateLo),g.buffer&&t.wipe(g.buffer),g.bufferLength=0,g.bytesHashed=0},f}();r.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 a(f,g,d,m,w,O,C){for(var P=d[0],q=d[1],K=d[2],Y=d[3],z=d[4],W=d[5],B=d[6],j=d[7],k=m[0],_=m[1],N=m[2],se=m[3],le=m[4],U=m[5],y=m[6],u=m[7],h,v,E,S,M,x,p,b;C>=128;){for(var R=0;R<16;R++){var Z=8*R+O;f[R]=e.readUint32BE(w,Z),g[R]=e.readUint32BE(w,Z+4)}for(var R=0;R<80;R++){var ae=P,I=q,ee=K,L=Y,V=z,G=W,D=B,H=j,ne=k,ce=_,fe=N,ye=se,we=le,Te=U,Qe=y,Ce=u;if(h=j,v=u,M=v&65535,x=v>>>16,p=h&65535,b=h>>>16,h=(z>>>14|le<<18)^(z>>>18|le<<14)^(le>>>9|z<<23),v=(le>>>14|z<<18)^(le>>>18|z<<14)^(z>>>9|le<<23),M+=v&65535,x+=v>>>16,p+=h&65535,b+=h>>>16,h=z&W^~z&B,v=le&U^~le&y,M+=v&65535,x+=v>>>16,p+=h&65535,b+=h>>>16,h=n[R*2],v=n[R*2+1],M+=v&65535,x+=v>>>16,p+=h&65535,b+=h>>>16,h=f[R%16],v=g[R%16],M+=v&65535,x+=v>>>16,p+=h&65535,b+=h>>>16,x+=M>>>16,p+=x>>>16,b+=p>>>16,E=p&65535|b<<16,S=M&65535|x<<16,h=E,v=S,M=v&65535,x=v>>>16,p=h&65535,b=h>>>16,h=(P>>>28|k<<4)^(k>>>2|P<<30)^(k>>>7|P<<25),v=(k>>>28|P<<4)^(P>>>2|k<<30)^(P>>>7|k<<25),M+=v&65535,x+=v>>>16,p+=h&65535,b+=h>>>16,h=P&q^P&K^q&K,v=k&_^k&N^_&N,M+=v&65535,x+=v>>>16,p+=h&65535,b+=h>>>16,x+=M>>>16,p+=x>>>16,b+=p>>>16,H=p&65535|b<<16,Ce=M&65535|x<<16,h=L,v=ye,M=v&65535,x=v>>>16,p=h&65535,b=h>>>16,h=E,v=S,M+=v&65535,x+=v>>>16,p+=h&65535,b+=h>>>16,x+=M>>>16,p+=x>>>16,b+=p>>>16,L=p&65535|b<<16,ye=M&65535|x<<16,q=ae,K=I,Y=ee,z=L,W=V,B=G,j=D,P=H,_=ne,N=ce,se=fe,le=ye,U=we,y=Te,u=Qe,k=Ce,R%16===15)for(var Z=0;Z<16;Z++)h=f[Z],v=g[Z],M=v&65535,x=v>>>16,p=h&65535,b=h>>>16,h=f[(Z+9)%16],v=g[(Z+9)%16],M+=v&65535,x+=v>>>16,p+=h&65535,b+=h>>>16,E=f[(Z+1)%16],S=g[(Z+1)%16],h=(E>>>1|S<<31)^(E>>>8|S<<24)^E>>>7,v=(S>>>1|E<<31)^(S>>>8|E<<24)^(S>>>7|E<<25),M+=v&65535,x+=v>>>16,p+=h&65535,b+=h>>>16,E=f[(Z+14)%16],S=g[(Z+14)%16],h=(E>>>19|S<<13)^(S>>>29|E<<3)^E>>>6,v=(S>>>19|E<<13)^(E>>>29|S<<3)^(S>>>6|E<<26),M+=v&65535,x+=v>>>16,p+=h&65535,b+=h>>>16,x+=M>>>16,p+=x>>>16,b+=p>>>16,f[Z]=p&65535|b<<16,g[Z]=M&65535|x<<16}h=P,v=k,M=v&65535,x=v>>>16,p=h&65535,b=h>>>16,h=d[0],v=m[0],M+=v&65535,x+=v>>>16,p+=h&65535,b+=h>>>16,x+=M>>>16,p+=x>>>16,b+=p>>>16,d[0]=P=p&65535|b<<16,m[0]=k=M&65535|x<<16,h=q,v=_,M=v&65535,x=v>>>16,p=h&65535,b=h>>>16,h=d[1],v=m[1],M+=v&65535,x+=v>>>16,p+=h&65535,b+=h>>>16,x+=M>>>16,p+=x>>>16,b+=p>>>16,d[1]=q=p&65535|b<<16,m[1]=_=M&65535|x<<16,h=K,v=N,M=v&65535,x=v>>>16,p=h&65535,b=h>>>16,h=d[2],v=m[2],M+=v&65535,x+=v>>>16,p+=h&65535,b+=h>>>16,x+=M>>>16,p+=x>>>16,b+=p>>>16,d[2]=K=p&65535|b<<16,m[2]=N=M&65535|x<<16,h=Y,v=se,M=v&65535,x=v>>>16,p=h&65535,b=h>>>16,h=d[3],v=m[3],M+=v&65535,x+=v>>>16,p+=h&65535,b+=h>>>16,x+=M>>>16,p+=x>>>16,b+=p>>>16,d[3]=Y=p&65535|b<<16,m[3]=se=M&65535|x<<16,h=z,v=le,M=v&65535,x=v>>>16,p=h&65535,b=h>>>16,h=d[4],v=m[4],M+=v&65535,x+=v>>>16,p+=h&65535,b+=h>>>16,x+=M>>>16,p+=x>>>16,b+=p>>>16,d[4]=z=p&65535|b<<16,m[4]=le=M&65535|x<<16,h=W,v=U,M=v&65535,x=v>>>16,p=h&65535,b=h>>>16,h=d[5],v=m[5],M+=v&65535,x+=v>>>16,p+=h&65535,b+=h>>>16,x+=M>>>16,p+=x>>>16,b+=p>>>16,d[5]=W=p&65535|b<<16,m[5]=U=M&65535|x<<16,h=B,v=y,M=v&65535,x=v>>>16,p=h&65535,b=h>>>16,h=d[6],v=m[6],M+=v&65535,x+=v>>>16,p+=h&65535,b+=h>>>16,x+=M>>>16,p+=x>>>16,b+=p>>>16,d[6]=B=p&65535|b<<16,m[6]=y=M&65535|x<<16,h=j,v=u,M=v&65535,x=v>>>16,p=h&65535,b=h>>>16,h=d[7],v=m[7],M+=v&65535,x+=v>>>16,p+=h&65535,b+=h>>>16,x+=M>>>16,p+=x>>>16,b+=p>>>16,d[7]=j=p&65535|b<<16,m[7]=u=M&65535|x<<16,O+=128,C-=128}return O}function c(f){var g=new i;g.update(f);var d=g.digest();return g.clean(),d}r.hash=c})(Qv);(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.convertSecretKeyToX25519=r.convertPublicKeyToX25519=r.verify=r.sign=r.extractPublicKeyFromSecretKey=r.generateKeyPair=r.generateKeyPairFromSeed=r.SEED_LENGTH=r.SECRET_KEY_LENGTH=r.PUBLIC_KEY_LENGTH=r.SIGNATURE_LENGTH=void 0;const e=ks,t=Qv,i=xi;r.SIGNATURE_LENGTH=64,r.PUBLIC_KEY_LENGTH=32,r.SECRET_KEY_LENGTH=64,r.SEED_LENGTH=32;function n(L){const V=new Float64Array(16);if(L)for(let G=0;G<L.length;G++)V[G]=L[G];return V}const a=new Uint8Array(32);a[0]=9;const c=n(),f=n([1]),g=n([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),d=n([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),m=n([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),w=n([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),O=n([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function C(L,V){for(let G=0;G<16;G++)L[G]=V[G]|0}function P(L){let V=1;for(let G=0;G<16;G++){let D=L[G]+V+65535;V=Math.floor(D/65536),L[G]=D-V*65536}L[0]+=V-1+37*(V-1)}function q(L,V,G){const D=~(G-1);for(let H=0;H<16;H++){const ne=D&(L[H]^V[H]);L[H]^=ne,V[H]^=ne}}function K(L,V){const G=n(),D=n();for(let H=0;H<16;H++)D[H]=V[H];P(D),P(D),P(D);for(let H=0;H<2;H++){G[0]=D[0]-65517;for(let ce=1;ce<15;ce++)G[ce]=D[ce]-65535-(G[ce-1]>>16&1),G[ce-1]&=65535;G[15]=D[15]-32767-(G[14]>>16&1);const ne=G[15]>>16&1;G[14]&=65535,q(D,G,1-ne)}for(let H=0;H<16;H++)L[2*H]=D[H]&255,L[2*H+1]=D[H]>>8}function Y(L,V){let G=0;for(let D=0;D<32;D++)G|=L[D]^V[D];return(1&G-1>>>8)-1}function z(L,V){const G=new Uint8Array(32),D=new Uint8Array(32);return K(G,L),K(D,V),Y(G,D)}function W(L){const V=new Uint8Array(32);return K(V,L),V[0]&1}function B(L,V){for(let G=0;G<16;G++)L[G]=V[2*G]+(V[2*G+1]<<8);L[15]&=32767}function j(L,V,G){for(let D=0;D<16;D++)L[D]=V[D]+G[D]}function k(L,V,G){for(let D=0;D<16;D++)L[D]=V[D]-G[D]}function _(L,V,G){let D,H,ne=0,ce=0,fe=0,ye=0,we=0,Te=0,Qe=0,Ce=0,Re=0,Se=0,me=0,Pe=0,Ne=0,be=0,Oe=0,xe=0,ve=0,qe=0,Me=0,_e=0,He=0,Ve=0,Ee=0,Ke=0,ht=0,Ge=0,_t=0,lt=0,We=0,Et=0,St=0,Be=G[0],Xe=G[1],tt=G[2],$e=G[3],et=G[4],Ze=G[5],Fe=G[6],ut=G[7],rt=G[8],ze=G[9],it=G[10],st=G[11],Ue=G[12],Ye=G[13],ft=G[14],je=G[15];D=V[0],ne+=D*Be,ce+=D*Xe,fe+=D*tt,ye+=D*$e,we+=D*et,Te+=D*Ze,Qe+=D*Fe,Ce+=D*ut,Re+=D*rt,Se+=D*ze,me+=D*it,Pe+=D*st,Ne+=D*Ue,be+=D*Ye,Oe+=D*ft,xe+=D*je,D=V[1],ce+=D*Be,fe+=D*Xe,ye+=D*tt,we+=D*$e,Te+=D*et,Qe+=D*Ze,Ce+=D*Fe,Re+=D*ut,Se+=D*rt,me+=D*ze,Pe+=D*it,Ne+=D*st,be+=D*Ue,Oe+=D*Ye,xe+=D*ft,ve+=D*je,D=V[2],fe+=D*Be,ye+=D*Xe,we+=D*tt,Te+=D*$e,Qe+=D*et,Ce+=D*Ze,Re+=D*Fe,Se+=D*ut,me+=D*rt,Pe+=D*ze,Ne+=D*it,be+=D*st,Oe+=D*Ue,xe+=D*Ye,ve+=D*ft,qe+=D*je,D=V[3],ye+=D*Be,we+=D*Xe,Te+=D*tt,Qe+=D*$e,Ce+=D*et,Re+=D*Ze,Se+=D*Fe,me+=D*ut,Pe+=D*rt,Ne+=D*ze,be+=D*it,Oe+=D*st,xe+=D*Ue,ve+=D*Ye,qe+=D*ft,Me+=D*je,D=V[4],we+=D*Be,Te+=D*Xe,Qe+=D*tt,Ce+=D*$e,Re+=D*et,Se+=D*Ze,me+=D*Fe,Pe+=D*ut,Ne+=D*rt,be+=D*ze,Oe+=D*it,xe+=D*st,ve+=D*Ue,qe+=D*Ye,Me+=D*ft,_e+=D*je,D=V[5],Te+=D*Be,Qe+=D*Xe,Ce+=D*tt,Re+=D*$e,Se+=D*et,me+=D*Ze,Pe+=D*Fe,Ne+=D*ut,be+=D*rt,Oe+=D*ze,xe+=D*it,ve+=D*st,qe+=D*Ue,Me+=D*Ye,_e+=D*ft,He+=D*je,D=V[6],Qe+=D*Be,Ce+=D*Xe,Re+=D*tt,Se+=D*$e,me+=D*et,Pe+=D*Ze,Ne+=D*Fe,be+=D*ut,Oe+=D*rt,xe+=D*ze,ve+=D*it,qe+=D*st,Me+=D*Ue,_e+=D*Ye,He+=D*ft,Ve+=D*je,D=V[7],Ce+=D*Be,Re+=D*Xe,Se+=D*tt,me+=D*$e,Pe+=D*et,Ne+=D*Ze,be+=D*Fe,Oe+=D*ut,xe+=D*rt,ve+=D*ze,qe+=D*it,Me+=D*st,_e+=D*Ue,He+=D*Ye,Ve+=D*ft,Ee+=D*je,D=V[8],Re+=D*Be,Se+=D*Xe,me+=D*tt,Pe+=D*$e,Ne+=D*et,be+=D*Ze,Oe+=D*Fe,xe+=D*ut,ve+=D*rt,qe+=D*ze,Me+=D*it,_e+=D*st,He+=D*Ue,Ve+=D*Ye,Ee+=D*ft,Ke+=D*je,D=V[9],Se+=D*Be,me+=D*Xe,Pe+=D*tt,Ne+=D*$e,be+=D*et,Oe+=D*Ze,xe+=D*Fe,ve+=D*ut,qe+=D*rt,Me+=D*ze,_e+=D*it,He+=D*st,Ve+=D*Ue,Ee+=D*Ye,Ke+=D*ft,ht+=D*je,D=V[10],me+=D*Be,Pe+=D*Xe,Ne+=D*tt,be+=D*$e,Oe+=D*et,xe+=D*Ze,ve+=D*Fe,qe+=D*ut,Me+=D*rt,_e+=D*ze,He+=D*it,Ve+=D*st,Ee+=D*Ue,Ke+=D*Ye,ht+=D*ft,Ge+=D*je,D=V[11],Pe+=D*Be,Ne+=D*Xe,be+=D*tt,Oe+=D*$e,xe+=D*et,ve+=D*Ze,qe+=D*Fe,Me+=D*ut,_e+=D*rt,He+=D*ze,Ve+=D*it,Ee+=D*st,Ke+=D*Ue,ht+=D*Ye,Ge+=D*ft,_t+=D*je,D=V[12],Ne+=D*Be,be+=D*Xe,Oe+=D*tt,xe+=D*$e,ve+=D*et,qe+=D*Ze,Me+=D*Fe,_e+=D*ut,He+=D*rt,Ve+=D*ze,Ee+=D*it,Ke+=D*st,ht+=D*Ue,Ge+=D*Ye,_t+=D*ft,lt+=D*je,D=V[13],be+=D*Be,Oe+=D*Xe,xe+=D*tt,ve+=D*$e,qe+=D*et,Me+=D*Ze,_e+=D*Fe,He+=D*ut,Ve+=D*rt,Ee+=D*ze,Ke+=D*it,ht+=D*st,Ge+=D*Ue,_t+=D*Ye,lt+=D*ft,We+=D*je,D=V[14],Oe+=D*Be,xe+=D*Xe,ve+=D*tt,qe+=D*$e,Me+=D*et,_e+=D*Ze,He+=D*Fe,Ve+=D*ut,Ee+=D*rt,Ke+=D*ze,ht+=D*it,Ge+=D*st,_t+=D*Ue,lt+=D*Ye,We+=D*ft,Et+=D*je,D=V[15],xe+=D*Be,ve+=D*Xe,qe+=D*tt,Me+=D*$e,_e+=D*et,He+=D*Ze,Ve+=D*Fe,Ee+=D*ut,Ke+=D*rt,ht+=D*ze,Ge+=D*it,_t+=D*st,lt+=D*Ue,We+=D*Ye,Et+=D*ft,St+=D*je,ne+=38*ve,ce+=38*qe,fe+=38*Me,ye+=38*_e,we+=38*He,Te+=38*Ve,Qe+=38*Ee,Ce+=38*Ke,Re+=38*ht,Se+=38*Ge,me+=38*_t,Pe+=38*lt,Ne+=38*We,be+=38*Et,Oe+=38*St,H=1,D=ne+H+65535,H=Math.floor(D/65536),ne=D-H*65536,D=ce+H+65535,H=Math.floor(D/65536),ce=D-H*65536,D=fe+H+65535,H=Math.floor(D/65536),fe=D-H*65536,D=ye+H+65535,H=Math.floor(D/65536),ye=D-H*65536,D=we+H+65535,H=Math.floor(D/65536),we=D-H*65536,D=Te+H+65535,H=Math.floor(D/65536),Te=D-H*65536,D=Qe+H+65535,H=Math.floor(D/65536),Qe=D-H*65536,D=Ce+H+65535,H=Math.floor(D/65536),Ce=D-H*65536,D=Re+H+65535,H=Math.floor(D/65536),Re=D-H*65536,D=Se+H+65535,H=Math.floor(D/65536),Se=D-H*65536,D=me+H+65535,H=Math.floor(D/65536),me=D-H*65536,D=Pe+H+65535,H=Math.floor(D/65536),Pe=D-H*65536,D=Ne+H+65535,H=Math.floor(D/65536),Ne=D-H*65536,D=be+H+65535,H=Math.floor(D/65536),be=D-H*65536,D=Oe+H+65535,H=Math.floor(D/65536),Oe=D-H*65536,D=xe+H+65535,H=Math.floor(D/65536),xe=D-H*65536,ne+=H-1+37*(H-1),H=1,D=ne+H+65535,H=Math.floor(D/65536),ne=D-H*65536,D=ce+H+65535,H=Math.floor(D/65536),ce=D-H*65536,D=fe+H+65535,H=Math.floor(D/65536),fe=D-H*65536,D=ye+H+65535,H=Math.floor(D/65536),ye=D-H*65536,D=we+H+65535,H=Math.floor(D/65536),we=D-H*65536,D=Te+H+65535,H=Math.floor(D/65536),Te=D-H*65536,D=Qe+H+65535,H=Math.floor(D/65536),Qe=D-H*65536,D=Ce+H+65535,H=Math.floor(D/65536),Ce=D-H*65536,D=Re+H+65535,H=Math.floor(D/65536),Re=D-H*65536,D=Se+H+65535,H=Math.floor(D/65536),Se=D-H*65536,D=me+H+65535,H=Math.floor(D/65536),me=D-H*65536,D=Pe+H+65535,H=Math.floor(D/65536),Pe=D-H*65536,D=Ne+H+65535,H=Math.floor(D/65536),Ne=D-H*65536,D=be+H+65535,H=Math.floor(D/65536),be=D-H*65536,D=Oe+H+65535,H=Math.floor(D/65536),Oe=D-H*65536,D=xe+H+65535,H=Math.floor(D/65536),xe=D-H*65536,ne+=H-1+37*(H-1),L[0]=ne,L[1]=ce,L[2]=fe,L[3]=ye,L[4]=we,L[5]=Te,L[6]=Qe,L[7]=Ce,L[8]=Re,L[9]=Se,L[10]=me,L[11]=Pe,L[12]=Ne,L[13]=be,L[14]=Oe,L[15]=xe}function N(L,V){_(L,V,V)}function se(L,V){const G=n();let D;for(D=0;D<16;D++)G[D]=V[D];for(D=253;D>=0;D--)N(G,G),D!==2&&D!==4&&_(G,G,V);for(D=0;D<16;D++)L[D]=G[D]}function le(L,V){const G=n();let D;for(D=0;D<16;D++)G[D]=V[D];for(D=250;D>=0;D--)N(G,G),D!==1&&_(G,G,V);for(D=0;D<16;D++)L[D]=G[D]}function U(L,V){const G=n(),D=n(),H=n(),ne=n(),ce=n(),fe=n(),ye=n(),we=n(),Te=n();k(G,L[1],L[0]),k(Te,V[1],V[0]),_(G,G,Te),j(D,L[0],L[1]),j(Te,V[0],V[1]),_(D,D,Te),_(H,L[3],V[3]),_(H,H,d),_(ne,L[2],V[2]),j(ne,ne,ne),k(ce,D,G),k(fe,ne,H),j(ye,ne,H),j(we,D,G),_(L[0],ce,fe),_(L[1],we,ye),_(L[2],ye,fe),_(L[3],ce,we)}function y(L,V,G){for(let D=0;D<4;D++)q(L[D],V[D],G)}function u(L,V){const G=n(),D=n(),H=n();se(H,V[2]),_(G,V[0],H),_(D,V[1],H),K(L,D),L[31]^=W(G)<<7}function h(L,V,G){C(L[0],c),C(L[1],f),C(L[2],f),C(L[3],c);for(let D=255;D>=0;--D){const H=G[D/8|0]>>(D&7)&1;y(L,V,H),U(V,L),U(L,L),y(L,V,H)}}function v(L,V){const G=[n(),n(),n(),n()];C(G[0],m),C(G[1],w),C(G[2],f),_(G[3],m,w),h(L,G,V)}function E(L){if(L.length!==r.SEED_LENGTH)throw new Error(`ed25519: seed must be ${r.SEED_LENGTH} bytes`);const V=(0,t.hash)(L);V[0]&=248,V[31]&=127,V[31]|=64;const G=new Uint8Array(32),D=[n(),n(),n(),n()];v(D,V),u(G,D);const H=new Uint8Array(64);return H.set(L),H.set(G,32),{publicKey:G,secretKey:H}}r.generateKeyPairFromSeed=E;function S(L){const V=(0,e.randomBytes)(32,L),G=E(V);return(0,i.wipe)(V),G}r.generateKeyPair=S;function M(L){if(L.length!==r.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${r.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(L.subarray(32))}r.extractPublicKeyFromSecretKey=M;const x=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 p(L,V){let G,D,H,ne;for(D=63;D>=32;--D){for(G=0,H=D-32,ne=D-12;H<ne;++H)V[H]+=G-16*V[D]*x[H-(D-32)],G=Math.floor((V[H]+128)/256),V[H]-=G*256;V[H]+=G,V[D]=0}for(G=0,H=0;H<32;H++)V[H]+=G-(V[31]>>4)*x[H],G=V[H]>>8,V[H]&=255;for(H=0;H<32;H++)V[H]-=G*x[H];for(D=0;D<32;D++)V[D+1]+=V[D]>>8,L[D]=V[D]&255}function b(L){const V=new Float64Array(64);for(let G=0;G<64;G++)V[G]=L[G];for(let G=0;G<64;G++)L[G]=0;p(L,V)}function R(L,V){const G=new Float64Array(64),D=[n(),n(),n(),n()],H=(0,t.hash)(L.subarray(0,32));H[0]&=248,H[31]&=127,H[31]|=64;const ne=new Uint8Array(64);ne.set(H.subarray(32),32);const ce=new t.SHA512;ce.update(ne.subarray(32)),ce.update(V);const fe=ce.digest();ce.clean(),b(fe),v(D,fe),u(ne,D),ce.reset(),ce.update(ne.subarray(0,32)),ce.update(L.subarray(32)),ce.update(V);const ye=ce.digest();b(ye);for(let we=0;we<32;we++)G[we]=fe[we];for(let we=0;we<32;we++)for(let Te=0;Te<32;Te++)G[we+Te]+=ye[we]*H[Te];return p(ne.subarray(32),G),ne}r.sign=R;function Z(L,V){const G=n(),D=n(),H=n(),ne=n(),ce=n(),fe=n(),ye=n();return C(L[2],f),B(L[1],V),N(H,L[1]),_(ne,H,g),k(H,H,L[2]),j(ne,L[2],ne),N(ce,ne),N(fe,ce),_(ye,fe,ce),_(G,ye,H),_(G,G,ne),le(G,G),_(G,G,H),_(G,G,ne),_(G,G,ne),_(L[0],G,ne),N(D,L[0]),_(D,D,ne),z(D,H)&&_(L[0],L[0],O),N(D,L[0]),_(D,D,ne),z(D,H)?-1:(W(L[0])===V[31]>>7&&k(L[0],c,L[0]),_(L[3],L[0],L[1]),0)}function ae(L,V,G){const D=new Uint8Array(32),H=[n(),n(),n(),n()],ne=[n(),n(),n(),n()];if(G.length!==r.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${r.SIGNATURE_LENGTH} bytes`);if(Z(ne,L))return!1;const ce=new t.SHA512;ce.update(G.subarray(0,32)),ce.update(L),ce.update(V);const fe=ce.digest();return b(fe),h(H,ne,fe),v(ne,G.subarray(32)),U(H,ne),u(D,H),!Y(G,D)}r.verify=ae;function I(L){let V=[n(),n(),n(),n()];if(Z(V,L))throw new Error("Ed25519: invalid public key");let G=n(),D=n(),H=V[1];j(G,f,H),k(D,f,H),se(D,D),_(G,G,D);let ne=new Uint8Array(32);return K(ne,G),ne}r.convertPublicKeyToX25519=I;function ee(L){const V=(0,t.hash)(L.subarray(0,32));V[0]&=248,V[31]&=127,V[31]|=64;const G=new Uint8Array(V.subarray(0,32));return(0,i.wipe)(V),G}r.convertSecretKeyToX25519=ee})(e0);const lE="EdDSA",dE="JWT",vf=".",Jf="base64url",Xv="utf8",Zv="utf8",pE=":",gE="did",bE="key",G1="base58btc",vE="z",mE="K36",yE=32;function t0(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function e3(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?t0(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function wE(r,e){e||(e=r.reduce((n,a)=>n+a.length,0));const t=e3(e);let i=0;for(const n of r)t.set(n,i),i+=n.length;return t0(t)}function _E(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i<t.length;i++)t[i]=255;for(var n=0;n<r.length;n++){var a=r.charAt(n),c=a.charCodeAt(0);if(t[c]!==255)throw new TypeError(a+" is ambiguous");t[c]=n}var f=r.length,g=r.charAt(0),d=Math.log(f)/Math.log(256),m=Math.log(256)/Math.log(f);function w(P){if(P instanceof Uint8Array||(ArrayBuffer.isView(P)?P=new Uint8Array(P.buffer,P.byteOffset,P.byteLength):Array.isArray(P)&&(P=Uint8Array.from(P))),!(P instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(P.length===0)return"";for(var q=0,K=0,Y=0,z=P.length;Y!==z&&P[Y]===0;)Y++,q++;for(var W=(z-Y)*m+1>>>0,B=new Uint8Array(W);Y!==z;){for(var j=P[Y],k=0,_=W-1;(j!==0||k<K)&&_!==-1;_--,k++)j+=256*B[_]>>>0,B[_]=j%f>>>0,j=j/f>>>0;if(j!==0)throw new Error("Non-zero carry");K=k,Y++}for(var N=W-K;N!==W&&B[N]===0;)N++;for(var se=g.repeat(q);N<W;++N)se+=r.charAt(B[N]);return se}function O(P){if(typeof P!="string")throw new TypeError("Expected String");if(P.length===0)return new Uint8Array;var q=0;if(P[q]!==" "){for(var K=0,Y=0;P[q]===g;)K++,q++;for(var z=(P.length-q)*d+1>>>0,W=new Uint8Array(z);P[q];){var B=t[P.charCodeAt(q)];if(B===255)return;for(var j=0,k=z-1;(B!==0||j<Y)&&k!==-1;k--,j++)B+=f*W[k]>>>0,W[k]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");Y=j,q++}if(P[q]!==" "){for(var _=z-Y;_!==z&&W[_]===0;)_++;for(var N=new Uint8Array(K+(z-_)),se=K;_!==z;)N[se++]=W[_++];return N}}}function C(P){var q=O(P);if(q)return q;throw new Error(`Non-${e} character`)}return{encode:w,decodeUnsafe:O,decode:C}}var DE=_E,EE=DE;const AE=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},xE=r=>new TextEncoder().encode(r),SE=r=>new TextDecoder().decode(r);let ME=class{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},IE=class{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.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 t3(this,e)}},CE=class{constructor(e){this.decoders=e}or(e){return t3(this,e)}decode(e){const t=e[0],i=this.decoders[t];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 t3=(r,e)=>new CE({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}});let PE=class{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new ME(e,t,i),this.decoder=new IE(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};const Wf=({name:r,prefix:e,encode:t,decode:i})=>new PE(r,e,t,i),Pc=({prefix:r,name:e,alphabet:t})=>{const{encode:i,decode:n}=EE(t,e);return Wf({prefix:r,name:e,encode:i,decode:a=>AE(n(a))})},OE=(r,e,t,i)=>{const n={};for(let m=0;m<e.length;++m)n[e[m]]=m;let a=r.length;for(;r[a-1]==="=";)--a;const c=new Uint8Array(a*t/8|0);let f=0,g=0,d=0;for(let m=0;m<a;++m){const w=n[r[m]];if(w===void 0)throw new SyntaxError(`Non-${i} character`);g=g<<t|w,f+=t,f>=8&&(f-=8,c[d++]=255&g>>f)}if(f>=t||255&g<<8-f)throw new SyntaxError("Unexpected end of data");return c},TE=(r,e,t)=>{const i=e[e.length-1]==="=",n=(1<<t)-1;let a="",c=0,f=0;for(let g=0;g<r.length;++g)for(f=f<<8|r[g],c+=8;c>t;)c-=t,a+=e[n&f>>c];if(c&&(a+=e[n&f<<t-c]),i)for(;a.length*t&7;)a+="=";return a},Pr=({name:r,prefix:e,bitsPerChar:t,alphabet:i})=>Wf({prefix:e,name:r,encode(n){return TE(n,i,t)},decode(n){return OE(n,i,t,r)}}),RE=Wf({prefix:"\0",name:"identity",encode:r=>SE(r),decode:r=>xE(r)}),NE=Object.freeze(Object.defineProperty({__proto__:null,identity:RE},Symbol.toStringTag,{value:"Module"})),BE=Pr({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),$E=Object.freeze(Object.defineProperty({__proto__:null,base2:BE},Symbol.toStringTag,{value:"Module"})),UE=Pr({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),qE=Object.freeze(Object.defineProperty({__proto__:null,base8:UE},Symbol.toStringTag,{value:"Module"})),LE=Pc({prefix:"9",name:"base10",alphabet:"0123456789"}),FE=Object.freeze(Object.defineProperty({__proto__:null,base10:LE},Symbol.toStringTag,{value:"Module"})),zE=Pr({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),jE=Pr({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),kE=Object.freeze(Object.defineProperty({__proto__:null,base16:zE,base16upper:jE},Symbol.toStringTag,{value:"Module"})),HE=Pr({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),KE=Pr({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),VE=Pr({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),GE=Pr({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),JE=Pr({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),WE=Pr({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),YE=Pr({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),QE=Pr({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),XE=Pr({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),ZE=Object.freeze(Object.defineProperty({__proto__:null,base32:HE,base32hex:JE,base32hexpad:YE,base32hexpadupper:QE,base32hexupper:WE,base32pad:VE,base32padupper:GE,base32upper:KE,base32z:XE},Symbol.toStringTag,{value:"Module"})),eA=Pc({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),tA=Pc({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),rA=Object.freeze(Object.defineProperty({__proto__:null,base36:eA,base36upper:tA},Symbol.toStringTag,{value:"Module"})),iA=Pc({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),nA=Pc({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),sA=Object.freeze(Object.defineProperty({__proto__:null,base58btc:iA,base58flickr:nA},Symbol.toStringTag,{value:"Module"})),aA=Pr({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),oA=Pr({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),cA=Pr({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),uA=Pr({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),fA=Object.freeze(Object.defineProperty({__proto__:null,base64:aA,base64pad:oA,base64url:cA,base64urlpad:uA},Symbol.toStringTag,{value:"Module"})),r3=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),hA=r3.reduce((r,e,t)=>(r[t]=e,r),[]),lA=r3.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function dA(r){return r.reduce((e,t)=>(e+=hA[t],e),"")}function pA(r){const e=[];for(const t of r){const i=lA[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}const gA=Wf({prefix:"🚀",name:"base256emoji",encode:dA,decode:pA}),bA=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:gA},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const J1={...NE,...$E,...qE,...FE,...kE,...ZE,...rA,...sA,...fA,...bA};function i3(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}const W1=i3("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Cl=i3("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);const e=e3(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),n3={utf8:W1,"utf-8":W1,hex:J1.base16,latin1:Cl,ascii:Cl,binary:Cl,...J1};function Yf(r,e="utf8"){const t=n3[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}function yo(r,e="utf8"){const t=n3[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?t0(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}const vA=r=>JSON.stringify(r,(e,t)=>typeof t=="bigint"?t.toString()+"n":t),mA=r=>{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,t=r.replace(e,'$1"$2n"$3');return JSON.parse(t,(i,n)=>typeof n=="string"&&n.match(/^\d+n$/)?BigInt(n.substring(0,n.length-1)):n)};function ma(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return mA(r)}catch{return r}}function ys(r){return typeof r=="string"?r:vA(r)||""}function Y1(r){return ma(Yf(yo(r,Jf),Xv))}function mf(r){return Yf(yo(ys(r),Xv),Jf)}function s3(r){const e=yo(mE,G1),t=vE+Yf(wE([e,r]),G1);return[gE,bE,t].join(pE)}function yA(r){return Yf(r,Jf)}function wA(r){return yo(r,Jf)}function _A(r){return yo([mf(r.header),mf(r.payload)].join(vf),Zv)}function DA(r){return[mf(r.header),mf(r.payload),yA(r.signature)].join(vf)}function md(r){const e=r.split(vf),t=Y1(e[0]),i=Y1(e[1]),n=wA(e[2]),a=yo(e.slice(0,2).join(vf),Zv);return{header:t,payload:i,signature:n,data:a}}function Q1(r=ks.randomBytes(yE)){return e0.generateKeyPairFromSeed(r)}async function EA(r,e,t,i,n=Ae.fromMiliseconds(Date.now())){const a={alg:lE,typ:dE},c=s3(i.publicKey),f=n+t,g={iss:c,sub:r,aud:e,iat:n,exp:f},d=_A({header:a,payload:g}),m=e0.sign(i.secretKey,d);return DA({header:a,payload:g,signature:m})}const AA={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"}};var ga={env:{NODE_ENV:'"production"',VITE_WALLETCONNECT_PROJECT_ID:'"1d93edc21291f98e3bed6ff7617ff539"'},nextTick:"setImmediate",platform:'"browser"',version:'"v16.0.0"',browser:!0},xA={};const SA=":";function fc(r){const[e,t]=r.split(SA);return{namespace:e,reference:t}}function X1(r,e=[]){const t=[];return Object.keys(r).forEach(i=>{if(e.length&&!e.includes(i))return;const n=r[i];t.push(...n.accounts)}),t}function a3(r,e){return r.includes(":")?[r]:e.chains||[]}var MA=Object.defineProperty,Z1=Object.getOwnPropertySymbols,IA=Object.prototype.hasOwnProperty,CA=Object.prototype.propertyIsEnumerable,eg=(r,e,t)=>e in r?MA(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,tg=(r,e)=>{for(var t in e||(e={}))IA.call(e,t)&&eg(r,t,e[t]);if(Z1)for(var t of Z1(e))CA.call(e,t)&&eg(r,t,e[t]);return r};const PA="ReactNative",_i={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},OA="js";function yf(){return typeof ga<"u"&&typeof ga.versions<"u"&&typeof ga.versions.node<"u"}function wo(){return!Tf()&&!!jd()&&navigator.product===PA}function Oc(){return!yf()&&!!jd()&&!!Tf()}function Tc(){return wo()?_i.reactNative:yf()?_i.node:Oc()?_i.browser:_i.unknown}function TA(){var r;try{return wo()&&typeof globalThis<"u"&&typeof(globalThis==null?void 0:globalThis.Application)<"u"?(r=globalThis.Application)==null?void 0:r.applicationId:void 0}catch{return}}function RA(r,e){let t=vc.parse(r);return t=tg(tg({},t),e),r=vc.stringify(t),r}function o3(){return sv()||{name:"",description:"",url:"",icons:[""]}}function NA(){if(Tc()===_i.reactNative&&typeof globalThis<"u"&&typeof(globalThis==null?void 0:globalThis.Platform)<"u"){const{OS:t,Version:i}=globalThis.Platform;return[t,i].join("-")}const r=w4();if(r===null)return"unknown";const e=r.os?r.os.replace(" ","").toLowerCase():"unknown";return r.type==="browser"?[e,r.name,r.version].join("-"):[e,r.version].join("-")}function BA(){var r;const e=Tc();return e===_i.browser?[e,((r=nv())==null?void 0:r.host)||"unknown"].join(":"):e}function c3(r,e,t){const i=NA(),n=BA();return[[r,e].join("-"),[OA,t].join("-"),i,n].join("/")}function $A({protocol:r,version:e,relayUrl:t,sdkVersion:i,auth:n,projectId:a,useOnCloseEvent:c,bundleId:f}){const g=t.split("?"),d=c3(r,e,i),m={auth:n,ua:d,projectId:a,useOnCloseEvent:c||void 0,origin:f||void 0},w=RA(g[1]||"",m);return g[0]+"?"+w}function la(r,e){return r.filter(t=>e.includes(t)).length===r.length}function u3(r){return Object.fromEntries(r.entries())}function f3(r){return new Map(Object.entries(r))}function fa(r=Ae.FIVE_MINUTES,e){const t=Ae.toMiliseconds(r||Ae.FIVE_MINUTES);let i,n,a;return{resolve:c=>{a&&i&&(clearTimeout(a),i(c))},reject:c=>{a&&n&&(clearTimeout(a),n(c))},done:()=>new Promise((c,f)=>{a=setTimeout(()=>{f(new Error(e))},t),i=c,n=f})}}function ro(r,e,t){return new Promise(async(i,n)=>{const a=setTimeout(()=>n(new Error(t)),e);try{const c=await r;i(c)}catch(c){n(c)}clearTimeout(a)})}function h3(r,e){if(typeof e=="string"&&e.startsWith(`${r}:`))return e;if(r.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(r.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: ${r}`)}function UA(r){return h3("topic",r)}function qA(r){return h3("id",r)}function l3(r){const[e,t]=r.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof t=="string")i.topic=t;else if(e==="id"&&Number.isInteger(Number(t)))i.id=Number(t);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);return i}function br(r,e){return Ae.fromMiliseconds(Date.now()+Ae.toMiliseconds(r))}function Rs(r){return Date.now()>=Ae.toMiliseconds(r)}function xt(r,e){return`${r}${e?`:${e}`:""}`}function rf(r=[],e=[]){return[...new Set([...r,...e])]}async function LA({id:r,topic:e,wcDeepLink:t}){var i;try{if(!t)return;const n=typeof t=="string"?JSON.parse(t):t,a=n==null?void 0:n.href;if(typeof a!="string")return;const c=FA(a,r,e),f=Tc();if(f===_i.browser){if(!((i=Tf())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}c.startsWith("https://")||c.startsWith("http://")?window.open(c,"_blank","noreferrer noopener"):window.open(c,jA()?"_blank":"_self","noreferrer noopener")}else f===_i.reactNative&&typeof(globalThis==null?void 0:globalThis.Linking)<"u"&&await globalThis.Linking.openURL(c)}catch(n){console.error(n)}}function FA(r,e,t){const i=`requestId=${e}&sessionTopic=${t}`;r.endsWith("/")&&(r=r.slice(0,-1));let n=`${r}`;if(r.startsWith("https://t.me")){const a=r.includes("?")?"&startapp=":"?startapp=";n=`${n}${a}${kA(i,!0)}`}else n=`${n}/wc?${i}`;return n}async function zA(r,e){let t="";try{if(Oc()&&(t=localStorage.getItem(e),t))return t;t=await r.getItem(e)}catch(i){console.error(i)}return t}function rg(r,e){if(!r.includes(e))return null;const t=r.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function ig(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,r=>{const e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)})}function r0(){return typeof ga<"u"&&xA.IS_VITEST==="true"}function jA(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function kA(r,e=!1){const t=Buffer.from(r).toString("base64");return e?t.replace(/[=]/g,""):t}function d3(r){return Buffer.from(r,"base64").toString("utf-8")}var p3=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};function HA(r){var e=r.default;if(typeof e=="function"){var t=function(){return e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(i){var n=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(t,i,n.get?n:{enumerable:!0,get:function(){return r[i]}})}),t}var g3={exports:{}};/**
* [js-sha3]{@link https://github.com/emn178/js-sha3}
*
* @version 0.8.0
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2015-2018
* @license MIT
*/(function(r){(function(){var e="input is invalid type",t="finalize already called",i=typeof window=="object",n=i?window:{};n.JS_SHA3_NO_WINDOW&&(i=!1);var a=!i&&typeof self=="object",c=!n.JS_SHA3_NO_NODE_JS&&typeof ga=="object"&&ga.versions&&ga.versions.node;c?n=p3:a&&(n=self);var f=!n.JS_SHA3_NO_COMMON_JS&&!0&&r.exports,g=!n.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",d="0123456789abcdef".split(""),m=[31,7936,2031616,520093696],w=[4,1024,262144,67108864],O=[1,256,65536,16777216],C=[6,1536,393216,100663296],P=[0,8,16,24],q=[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],Y=[128,256],z=["hex","buffer","arrayBuffer","array","digest"],W={128:168,256:136};(n.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(I){return Object.prototype.toString.call(I)==="[object Array]"}),g&&(n.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(I){return typeof I=="object"&&I.buffer&&I.buffer.constructor===ArrayBuffer});for(var B=function(I,ee,L){return function(V){return new R(I,ee,I).update(V)[L]()}},j=function(I,ee,L){return function(V,G){return new R(I,ee,G).update(V)[L]()}},k=function(I,ee,L){return function(V,G,D,H){return h["cshake"+I].update(V,G,D,H)[L]()}},_=function(I,ee,L){return function(V,G,D,H){return h["kmac"+I].update(V,G,D,H)[L]()}},N=function(I,ee,L,V){for(var G=0;G<z.length;++G){var D=z[G];I[D]=ee(L,V,D)}return I},se=function(I,ee){var L=B(I,ee,"hex");return L.create=function(){return new R(I,ee,I)},L.update=function(V){return L.create().update(V)},N(L,B,I,ee)},le=function(I,ee){var L=j(I,ee,"hex");return L.create=function(V){return new R(I,ee,V)},L.update=function(V,G){return L.create(G).update(V)},N(L,j,I,ee)},U=function(I,ee){var L=W[I],V=k(I,ee,"hex");return V.create=function(G,D,H){return!D&&!H?h["shake"+I].create(G):new R(I,ee,G).bytepad([D,H],L)},V.update=function(G,D,H,ne){return V.create(D,H,ne).update(G)},N(V,k,I,ee)},y=function(I,ee){var L=W[I],V=_(I,ee,"hex");return V.create=function(G,D,H){return new Z(I,ee,D).bytepad(["KMAC",H],L).bytepad([G],L)},V.update=function(G,D,H,ne){return V.create(G,H,ne).update(D)},N(V,_,I,ee)},u=[{name:"keccak",padding:O,bits:K,createMethod:se},{name:"sha3",padding:C,bits:K,createMethod:se},{name:"shake",padding:m,bits:Y,createMethod:le},{name:"cshake",padding:w,bits:Y,createMethod:U},{name:"kmac",padding:w,bits:Y,createMethod:y}],h={},v=[],E=0;E<u.length;++E)for(var S=u[E],M=S.bits,x=0;x<M.length;++x){var p=S.name+"_"+M[x];if(v.push(p),h[p]=S.createMethod(M[x],S.padding),S.name!=="sha3"){var b=S.name+M[x];v.push(b),h[b]=h[p]}}function R(I,ee,L){this.blocks=[],this.s=[],this.padding=ee,this.outputBits=L,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(I<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=L>>5,this.extraBytes=(L&31)>>3;for(var V=0;V<50;++V)this.s[V]=0}R.prototype.update=function(I){if(this.finalized)throw new Error(t);var ee,L=typeof I;if(L!=="string"){if(L==="object"){if(I===null)throw new Error(e);if(g&&I.constructor===ArrayBuffer)I=new Uint8Array(I);else if(!Array.isArray(I)&&(!g||!ArrayBuffer.isView(I)))throw new Error(e)}else throw new Error(e);ee=!0}for(var V=this.blocks,G=this.byteCount,D=I.length,H=this.blockCount,ne=0,ce=this.s,fe,ye;ne<D;){if(this.reset)for(this.reset=!1,V[0]=this.block,fe=1;fe<H+1;++fe)V[fe]=0;if(ee)for(fe=this.start;ne<D&&fe<G;++ne)V[fe>>2]|=I[ne]<<P[fe++&3];else for(fe=this.start;ne<D&&fe<G;++ne)ye=I.charCodeAt(ne),ye<128?V[fe>>2]|=ye<<P[fe++&3]:ye<2048?(V[fe>>2]|=(192|ye>>6)<<P[fe++&3],V[fe>>2]|=(128|ye&63)<<P[fe++&3]):ye<55296||ye>=57344?(V[fe>>2]|=(224|ye>>12)<<P[fe++&3],V[fe>>2]|=(128|ye>>6&63)<<P[fe++&3],V[fe>>2]|=(128|ye&63)<<P[fe++&3]):(ye=65536+((ye&1023)<<10|I.charCodeAt(++ne)&1023),V[fe>>2]|=(240|ye>>18)<<P[fe++&3],V[fe>>2]|=(128|ye>>12&63)<<P[fe++&3],V[fe>>2]|=(128|ye>>6&63)<<P[fe++&3],V[fe>>2]|=(128|ye&63)<<P[fe++&3]);if(this.lastByteIndex=fe,fe>=G){for(this.start=fe-G,this.block=V[H],fe=0;fe<H;++fe)ce[fe]^=V[fe];ae(ce),this.reset=!0}else this.start=fe}return this},R.prototype.encode=function(I,ee){var L=I&255,V=1,G=[L];for(I=I>>8,L=I&255;L>0;)G.unshift(L),I=I>>8,L=I&255,++V;return ee?G.push(V):G.unshift(V),this.update(G),G.length},R.prototype.encodeString=function(I){var ee,L=typeof I;if(L!=="string"){if(L==="object"){if(I===null)throw new Error(e);if(g&&I.constructor===ArrayBuffer)I=new Uint8Array(I);else if(!Array.isArray(I)&&(!g||!ArrayBuffer.isView(I)))throw new Error(e)}else throw new Error(e);ee=!0}var V=0,G=I.length;if(ee)V=G;else for(var D=0;D<I.length;++D){var H=I.charCodeAt(D);H<128?V+=1:H<2048?V+=2:H<55296||H>=57344?V+=3:(H=65536+((H&1023)<<10|I.charCodeAt(++D)&1023),V+=4)}return V+=this.encode(V*8),this.update(I),V},R.prototype.bytepad=function(I,ee){for(var L=this.encode(ee),V=0;V<I.length;++V)L+=this.encodeString(I[V]);var G=ee-L%ee,D=[];return D.length=G,this.update(D),this},R.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var I=this.blocks,ee=this.lastByteIndex,L=this.blockCount,V=this.s;if(I[ee>>2]|=this.padding[ee&3],this.lastByteIndex===this.byteCount)for(I[0]=I[L],ee=1;ee<L+1;++ee)I[ee]=0;for(I[L-1]|=2147483648,ee=0;ee<L;++ee)V[ee]^=I[ee];ae(V)}},R.prototype.toString=R.prototype.hex=function(){this.finalize();for(var I=this.blockCount,ee=this.s,L=this.outputBlocks,V=this.extraBytes,G=0,D=0,H="",ne;D<L;){for(G=0;G<I&&D<L;++G,++D)ne=ee[G],H+=d[ne>>4&15]+d[ne&15]+d[ne>>12&15]+d[ne>>8&15]+d[ne>>20&15]+d[ne>>16&15]+d[ne>>28&15]+d[ne>>24&15];D%I===0&&(ae(ee),G=0)}return V&&(ne=ee[G],H+=d[ne>>4&15]+d[ne&15],V>1&&(H+=d[ne>>12&15]+d[ne>>8&15]),V>2&&(H+=d[ne>>20&15]+d[ne>>16&15])),H},R.prototype.arrayBuffer=function(){this.finalize();var I=this.blockCount,ee=this.s,L=this.outputBlocks,V=this.extraBytes,G=0,D=0,H=this.outputBits>>3,ne;V?ne=new ArrayBuffer(L+1<<2):ne=new ArrayBuffer(H);for(var ce=new Uint32Array(ne);D<L;){for(G=0;G<I&&D<L;++G,++D)ce[D]=ee[G];D%I===0&&ae(ee)}return V&&(ce[G]=ee[G],ne=ne.slice(0,H)),ne},R.prototype.buffer=R.prototype.arrayBuffer,R.prototype.digest=R.prototype.array=function(){this.finalize();for(var I=this.blockCount,ee=this.s,L=this.outputBlocks,V=this.extraBytes,G=0,D=0,H=[],ne,ce;D<L;){for(G=0;G<I&&D<L;++G,++D)ne=D<<2,ce=ee[G],H[ne]=ce&255,H[ne+1]=ce>>8&255,H[ne+2]=ce>>16&255,H[ne+3]=ce>>24&255;D%I===0&&ae(ee)}return V&&(ne=D<<2,ce=ee[G],H[ne]=ce&255,V>1&&(H[ne+1]=ce>>8&255),V>2&&(H[ne+2]=ce>>16&255)),H};function Z(I,ee,L){R.call(this,I,ee,L)}Z.prototype=new R,Z.prototype.finalize=function(){return this.encode(this.outputBits,!0),R.prototype.finalize.call(this)};var ae=function(I){var ee,L,V,G,D,H,ne,ce,fe,ye,we,Te,Qe,Ce,Re,Se,me,Pe,Ne,be,Oe,xe,ve,qe,Me,_e,He,Ve,Ee,Ke,ht,Ge,_t,lt,We,Et,St,Be,Xe,tt,$e,et,Ze,Fe,ut,rt,ze,it,st,Ue,Ye,ft,je,Rt,Nt,at,vt,Rr,Nr,Br,$r,Ur,er;for(V=0;V<48;V+=2)G=I[0]^I[10]^I[20]^I[30]^I[40],D=I[1]^I[11]^I[21]^I[31]^I[41],H=I[2]^I[12]^I[22]^I[32]^I[42],ne=I[3]^I[13]^I[23]^I[33]^I[43],ce=I[4]^I[14]^I[24]^I[34]^I[44],fe=I[5]^I[15]^I[25]^I[35]^I[45],ye=I[6]^I[16]^I[26]^I[36]^I[46],we=I[7]^I[17]^I[27]^I[37]^I[47],Te=I[8]^I[18]^I[28]^I[38]^I[48],Qe=I[9]^I[19]^I[29]^I[39]^I[49],ee=Te^(H<<1|ne>>>31),L=Qe^(ne<<1|H>>>31),I[0]^=ee,I[1]^=L,I[10]^=ee,I[11]^=L,I[20]^=ee,I[21]^=L,I[30]^=ee,I[31]^=L,I[40]^=ee,I[41]^=L,ee=G^(ce<<1|fe>>>31),L=D^(fe<<1|ce>>>31),I[2]^=ee,I[3]^=L,I[12]^=ee,I[13]^=L,I[22]^=ee,I[23]^=L,I[32]^=ee,I[33]^=L,I[42]^=ee,I[43]^=L,ee=H^(ye<<1|we>>>31),L=ne^(we<<1|ye>>>31),I[4]^=ee,I[5]^=L,I[14]^=ee,I[15]^=L,I[24]^=ee,I[25]^=L,I[34]^=ee,I[35]^=L,I[44]^=ee,I[45]^=L,ee=ce^(Te<<1|Qe>>>31),L=fe^(Qe<<1|Te>>>31),I[6]^=ee,I[7]^=L,I[16]^=ee,I[17]^=L,I[26]^=ee,I[27]^=L,I[36]^=ee,I[37]^=L,I[46]^=ee,I[47]^=L,ee=ye^(G<<1|D>>>31),L=we^(D<<1|G>>>31),I[8]^=ee,I[9]^=L,I[18]^=ee,I[19]^=L,I[28]^=ee,I[29]^=L,I[38]^=ee,I[39]^=L,I[48]^=ee,I[49]^=L,Ce=I[0],Re=I[1],rt=I[11]<<4|I[10]>>>28,ze=I[10]<<4|I[11]>>>28,Ve=I[20]<<3|I[21]>>>29,Ee=I[21]<<3|I[20]>>>29,Br=I[31]<<9|I[30]>>>23,$r=I[30]<<9|I[31]>>>23,et=I[40]<<18|I[41]>>>14,Ze=I[41]<<18|I[40]>>>14,lt=I[2]<<1|I[3]>>>31,We=I[3]<<1|I[2]>>>31,Se=I[13]<<12|I[12]>>>20,me=I[12]<<12|I[13]>>>20,it=I[22]<<10|I[23]>>>22,st=I[23]<<10|I[22]>>>22,Ke=I[33]<<13|I[32]>>>19,ht=I[32]<<13|I[33]>>>19,Ur=I[42]<<2|I[43]>>>30,er=I[43]<<2|I[42]>>>30,Rt=I[5]<<30|I[4]>>>2,Nt=I[4]<<30|I[5]>>>2,Et=I[14]<<6|I[15]>>>26,St=I[15]<<6|I[14]>>>26,Pe=I[25]<<11|I[24]>>>21,Ne=I[24]<<11|I[25]>>>21,Ue=I[34]<<15|I[35]>>>17,Ye=I[35]<<15|I[34]>>>17,Ge=I[45]<<29|I[44]>>>3,_t=I[44]<<29|I[45]>>>3,qe=I[6]<<28|I[7]>>>4,Me=I[7]<<28|I[6]>>>4,at=I[17]<<23|I[16]>>>9,vt=I[16]<<23|I[17]>>>9,Be=I[26]<<25|I[27]>>>7,Xe=I[27]<<25|I[26]>>>7,be=I[36]<<21|I[37]>>>11,Oe=I[37]<<21|I[36]>>>11,ft=I[47]<<24|I[46]>>>8,je=I[46]<<24|I[47]>>>8,Fe=I[8]<<27|I[9]>>>5,ut=I[9]<<27|I[8]>>>5,_e=I[18]<<20|I[19]>>>12,He=I[19]<<20|I[18]>>>12,Rr=I[29]<<7|I[28]>>>25,Nr=I[28]<<7|I[29]>>>25,tt=I[38]<<8|I[39]>>>24,$e=I[39]<<8|I[38]>>>24,xe=I[48]<<14|I[49]>>>18,ve=I[49]<<14|I[48]>>>18,I[0]=Ce^~Se&Pe,I[1]=Re^~me&Ne,I[10]=qe^~_e&Ve,I[11]=Me^~He&Ee,I[20]=lt^~Et&Be,I[21]=We^~St&Xe,I[30]=Fe^~rt&it,I[31]=ut^~ze&st,I[40]=Rt^~at&Rr,I[41]=Nt^~vt&Nr,I[2]=Se^~Pe&be,I[3]=me^~Ne&Oe,I[12]=_e^~Ve&Ke,I[13]=He^~Ee&ht,I[22]=Et^~Be&tt,I[23]=St^~Xe&$e,I[32]=rt^~it&Ue,I[33]=ze^~st&Ye,I[42]=at^~Rr&Br,I[43]=vt^~Nr&$r,I[4]=Pe^~be&xe,I[5]=Ne^~Oe&ve,I[14]=Ve^~Ke&Ge,I[15]=Ee^~ht&_t,I[24]=Be^~tt&et,I[25]=Xe^~$e&Ze,I[34]=it^~Ue&ft,I[35]=st^~Ye&je,I[44]=Rr^~Br&Ur,I[45]=Nr^~$r&er,I[6]=be^~xe&Ce,I[7]=Oe^~ve&Re,I[16]=Ke^~Ge&qe,I[17]=ht^~_t&Me,I[26]=tt^~et&lt,I[27]=$e^~Ze&We,I[36]=Ue^~ft&Fe,I[37]=Ye^~je&ut,I[46]=Br^~Ur&Rt,I[47]=$r^~er&Nt,I[8]=xe^~Ce&Se,I[9]=ve^~Re&me,I[18]=Ge^~qe&_e,I[19]=_t^~Me&He,I[28]=et^~lt&Et,I[29]=Ze^~We&St,I[38]=ft^~Fe&rt,I[39]=je^~ut&ze,I[48]=Ur^~Rt&at,I[49]=er^~Nt&vt,I[0]^=q[V],I[1]^=q[V+1]};if(f)r.exports=h;else for(E=0;E<v.length;++E)n[v[E]]=h[v[E]]})()})(g3);var KA=g3.exports;const VA="logger/5.7.0";let ng=!1,sg=!1;const nf={debug:1,default:2,info:2,warning:3,error:4,off:5};let ag=nf.default,Pl=null;function GA(){try{const r=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{r.push(e)}}),r.length)throw new Error("missing "+r.join(", "));if("é".normalize("NFD")!=="é")throw new Error("broken implementation")}catch(r){return r.message}return null}const og=GA();var yd;(function(r){r.DEBUG="DEBUG",r.INFO="INFO",r.WARNING="WARNING",r.ERROR="ERROR",r.OFF="OFF"})(yd||(yd={}));var ln;(function(r){r.UNKNOWN_ERROR="UNKNOWN_ERROR",r.NOT_IMPLEMENTED="NOT_IMPLEMENTED",r.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",r.NETWORK_ERROR="NETWORK_ERROR",r.SERVER_ERROR="SERVER_ERROR",r.TIMEOUT="TIMEOUT",r.BUFFER_OVERRUN="BUFFER_OVERRUN",r.NUMERIC_FAULT="NUMERIC_FAULT",r.MISSING_NEW="MISSING_NEW",r.INVALID_ARGUMENT="INVALID_ARGUMENT",r.MISSING_ARGUMENT="MISSING_ARGUMENT",r.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",r.CALL_EXCEPTION="CALL_EXCEPTION",r.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",r.NONCE_EXPIRED="NONCE_EXPIRED",r.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",r.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",r.TRANSACTION_REPLACED="TRANSACTION_REPLACED",r.ACTION_REJECTED="ACTION_REJECTED"})(ln||(ln={}));const cg="0123456789abcdef";let Mr=class gr{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){const i=e.toLowerCase();nf[i]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(ag>nf[i])&&console.log.apply(console,t)}debug(...e){this._log(gr.levels.DEBUG,e)}info(...e){this._log(gr.levels.INFO,e)}warn(...e){this._log(gr.levels.WARNING,e)}makeError(e,t,i){if(sg)return this.makeError("censored error",t,{});t||(t=gr.errors.UNKNOWN_ERROR),i||(i={});const n=[];Object.keys(i).forEach(g=>{const d=i[g];try{if(d instanceof Uint8Array){let m="";for(let w=0;w<d.length;w++)m+=cg[d[w]>>4],m+=cg[d[w]&15];n.push(g+"=Uint8Array(0x"+m+")")}else n.push(g+"="+JSON.stringify(d))}catch{n.push(g+"="+JSON.stringify(i[g].toString()))}}),n.push(`code=${t}`),n.push(`version=${this.version}`);const a=e;let c="";switch(t){case ln.NUMERIC_FAULT:{c="NUMERIC_FAULT";const g=e;switch(g){case"overflow":case"underflow":case"division-by-zero":c+="-"+g;break;case"negative-power":case"negative-width":c+="-unsupported";break;case"unbound-bitwise-result":c+="-unbound-result";break}break}case ln.CALL_EXCEPTION:case ln.INSUFFICIENT_FUNDS:case ln.MISSING_NEW:case ln.NONCE_EXPIRED:case ln.REPLACEMENT_UNDERPRICED:case ln.TRANSACTION_REPLACED:case ln.UNPREDICTABLE_GAS_LIMIT:c=t;break}c&&(e+=" [ See: https://links.ethers.org/v5-errors-"+c+" ]"),n.length&&(e+=" ("+n.join(", ")+")");const f=new Error(e);return f.reason=a,f.code=t,Object.keys(i).forEach(function(g){f[g]=i[g]}),f}throwError(e,t,i){throw this.makeError(e,t,i)}throwArgumentError(e,t,i){return this.throwError(e,gr.errors.INVALID_ARGUMENT,{argument:t,value:i})}assert(e,t,i,n){e||this.throwError(t,i,n)}assertArgument(e,t,i,n){e||this.throwArgumentError(t,i,n)}checkNormalize(e){og&&this.throwError("platform missing String.prototype.normalize",gr.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:og})}checkSafeUint53(e,t){typeof e=="number"&&(t==null&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,gr.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,gr.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,t,i){i?i=": "+i:i="",e<t&&this.throwError("missing argument"+i,gr.errors.MISSING_ARGUMENT,{count:e,expectedCount:t}),e>t&&this.throwError("too many arguments"+i,gr.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})}checkNew(e,t){(e===Object||e==null)&&this.throwError("missing new",gr.errors.MISSING_NEW,{name:t.name})}checkAbstract(e,t){e===t?this.throwError("cannot instantiate abstract class "+JSON.stringify(t.name)+" directly; use a sub-class",gr.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",gr.errors.MISSING_NEW,{name:t.name})}static globalLogger(){return Pl||(Pl=new gr(VA)),Pl}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",gr.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),ng){if(!e)return;this.globalLogger().throwError("error censorship permanent",gr.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}sg=!!e,ng=!!t}static setLogLevel(e){const t=nf[e.toLowerCase()];if(t==null){gr.globalLogger().warn("invalid log level - "+e);return}ag=t}static from(e){return new gr(e)}};Mr.errors=ln,Mr.levels=yd;const JA="bytes/5.7.0",cr=new Mr(JA);function b3(r){return!!r.toHexString}function io(r){return r.slice||(r.slice=function(){const e=Array.prototype.slice.call(arguments);return io(new Uint8Array(Array.prototype.slice.apply(r,e)))}),r}function WA(r){return Ei(r)&&!(r.length%2)||_o(r)}function ug(r){return typeof r=="number"&&r==r&&r%1===0}function _o(r){if(r==null)return!1;if(r.constructor===Uint8Array)return!0;if(typeof r=="string"||!ug(r.length)||r.length<0)return!1;for(let e=0;e<r.length;e++){const t=r[e];if(!ug(t)||t<0||t>=256)return!1}return!0}function ir(r,e){if(e||(e={}),typeof r=="number"){cr.checkSafeUint53(r,"invalid arrayify value");const t=[];for(;r;)t.unshift(r&255),r=parseInt(String(r/256));return t.length===0&&t.push(0),io(new Uint8Array(t))}if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),b3(r)&&(r=r.toHexString()),Ei(r)){let t=r.substring(2);t.length%2&&(e.hexPad==="left"?t="0"+t:e.hexPad==="right"?t+="0":cr.throwArgumentError("hex data is odd-length","value",r));const i=[];for(let n=0;n<t.length;n+=2)i.push(parseInt(t.substring(n,n+2),16));return io(new Uint8Array(i))}return _o(r)?io(new Uint8Array(r)):cr.throwArgumentError("invalid arrayify value","value",r)}function YA(r){const e=r.map(n=>ir(n)),t=e.reduce((n,a)=>n+a.length,0),i=new Uint8Array(t);return e.reduce((n,a)=>(i.set(a,n),n+a.length),0),io(i)}function QA(r,e){r=ir(r),r.length>e&&cr.throwArgumentError("value out of range","value",arguments[0]);const t=new Uint8Array(e);return t.set(r,e-r.length),io(t)}function Ei(r,e){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||e&&r.length!==2+2*e)}const Ol="0123456789abcdef";function ui(r,e){if(e||(e={}),typeof r=="number"){cr.checkSafeUint53(r,"invalid hexlify value");let t="";for(;r;)t=Ol[r&15]+t,r=Math.floor(r/16);return t.length?(t.length%2&&(t="0"+t),"0x"+t):"0x00"}if(typeof r=="bigint")return r=r.toString(16),r.length%2?"0x0"+r:"0x"+r;if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),b3(r))return r.toHexString();if(Ei(r))return r.length%2&&(e.hexPad==="left"?r="0x0"+r.substring(2):e.hexPad==="right"?r+="0":cr.throwArgumentError("hex data is odd-length","value",r)),r.toLowerCase();if(_o(r)){let t="0x";for(let i=0;i<r.length;i++){let n=r[i];t+=Ol[(n&240)>>4]+Ol[n&15]}return t}return cr.throwArgumentError("invalid hexlify value","value",r)}function XA(r){if(typeof r!="string")r=ui(r);else if(!Ei(r)||r.length%2)return null;return(r.length-2)/2}function fg(r,e,t){return typeof r!="string"?r=ui(r):(!Ei(r)||r.length%2)&&cr.throwArgumentError("invalid hexData","value",r),e=2+2*e,t!=null?"0x"+r.substring(e,2+2*t):"0x"+r.substring(e)}function $n(r,e){for(typeof r!="string"?r=ui(r):Ei(r)||cr.throwArgumentError("invalid hex string","value",r),r.length>2*e+2&&cr.throwArgumentError("value out of range","value",arguments[1]);r.length<2*e+2;)r="0x0"+r.substring(2);return r}function v3(r){const e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(WA(r)){let t=ir(r);t.length===64?(e.v=27+(t[32]>>7),t[32]&=127,e.r=ui(t.slice(0,32)),e.s=ui(t.slice(32,64))):t.length===65?(e.r=ui(t.slice(0,32)),e.s=ui(t.slice(32,64)),e.v=t[64]):cr.throwArgumentError("invalid signature string","signature",r),e.v<27&&(e.v===0||e.v===1?e.v+=27:cr.throwArgumentError("signature invalid v byte","signature",r)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(t[32]|=128),e._vs=ui(t.slice(32,64))}else{if(e.r=r.r,e.s=r.s,e.v=r.v,e.recoveryParam=r.recoveryParam,e._vs=r._vs,e._vs!=null){const n=QA(ir(e._vs),32);e._vs=ui(n);const a=n[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=a:e.recoveryParam!==a&&cr.throwArgumentError("signature recoveryParam mismatch _vs","signature",r),n[0]&=127;const c=ui(n);e.s==null?e.s=c:e.s!==c&&cr.throwArgumentError("signature v mismatch _vs","signature",r)}if(e.recoveryParam==null)e.v==null?cr.throwArgumentError("signature missing v and recoveryParam","signature",r):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&&cr.throwArgumentError("signature recoveryParam mismatch v","signature",r)}e.r==null||!Ei(e.r)?cr.throwArgumentError("signature missing or invalid r","signature",r):e.r=$n(e.r,32),e.s==null||!Ei(e.s)?cr.throwArgumentError("signature missing or invalid s","signature",r):e.s=$n(e.s,32);const t=ir(e.s);t[0]>=128&&cr.throwArgumentError("signature s out of range","signature",r),e.recoveryParam&&(t[0]|=128);const i=ui(t);e._vs&&(Ei(e._vs)||cr.throwArgumentError("signature invalid _vs","signature",r),e._vs=$n(e._vs,32)),e._vs==null?e._vs=i:e._vs!==i&&cr.throwArgumentError("signature _vs mismatch v and s","signature",r)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}function i0(r){return"0x"+KA.keccak_256(ir(r))}var m3={exports:{}},ZA={},ex=Object.freeze({__proto__:null,default:ZA}),tx=HA(ex);(function(r){(function(e,t){function i(u,h){if(!u)throw new Error(h||"Assertion failed")}function n(u,h){u.super_=h;var v=function(){};v.prototype=h.prototype,u.prototype=new v,u.prototype.constructor=u}function a(u,h,v){if(a.isBN(u))return u;this.negative=0,this.words=null,this.length=0,this.red=null,u!==null&&((h==="le"||h==="be")&&(v=h,h=10),this._init(u||0,h||10,v||"be"))}typeof e=="object"?e.exports=a:t.BN=a,a.BN=a,a.wordSize=26;var c;try{typeof window<"u"&&typeof window.Buffer<"u"?c=window.Buffer:c=tx.Buffer}catch{}a.isBN=function(u){return u instanceof a?!0:u!==null&&typeof u=="object"&&u.constructor.wordSize===a.wordSize&&Array.isArray(u.words)},a.max=function(u,h){return u.cmp(h)>0?u:h},a.min=function(u,h){return u.cmp(h)<0?u:h},a.prototype._init=function(u,h,v){if(typeof u=="number")return this._initNumber(u,h,v);if(typeof u=="object")return this._initArray(u,h,v);h==="hex"&&(h=16),i(h===(h|0)&&h>=2&&h<=36),u=u.toString().replace(/\s+/g,"");var E=0;u[0]==="-"&&(E++,this.negative=1),E<u.length&&(h===16?this._parseHex(u,E,v):(this._parseBase(u,h,E),v==="le"&&this._initArray(this.toArray(),h,v)))},a.prototype._initNumber=function(u,h,v){u<0&&(this.negative=1,u=-u),u<67108864?(this.words=[u&67108863],this.length=1):u<4503599627370496?(this.words=[u&67108863,u/67108864&67108863],this.length=2):(i(u<9007199254740992),this.words=[u&67108863,u/67108864&67108863,1],this.length=3),v==="le"&&this._initArray(this.toArray(),h,v)},a.prototype._initArray=function(u,h,v){if(i(typeof u.length=="number"),u.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(u.length/3),this.words=new Array(this.length);for(var E=0;E<this.length;E++)this.words[E]=0;var S,M,x=0;if(v==="be")for(E=u.length-1,S=0;E>=0;E-=3)M=u[E]|u[E-1]<<8|u[E-2]<<16,this.words[S]|=M<<x&67108863,this.words[S+1]=M>>>26-x&67108863,x+=24,x>=26&&(x-=26,S++);else if(v==="le")for(E=0,S=0;E<u.length;E+=3)M=u[E]|u[E+1]<<8|u[E+2]<<16,this.words[S]|=M<<x&67108863,this.words[S+1]=M>>>26-x&67108863,x+=24,x>=26&&(x-=26,S++);return this._strip()};function f(u,h){var v=u.charCodeAt(h);if(v>=48&&v<=57)return v-48;if(v>=65&&v<=70)return v-55;if(v>=97&&v<=102)return v-87;i(!1,"Invalid character in "+u)}function g(u,h,v){var E=f(u,v);return v-1>=h&&(E|=f(u,v-1)<<4),E}a.prototype._parseHex=function(u,h,v){this.length=Math.ceil((u.length-h)/6),this.words=new Array(this.length);for(var E=0;E<this.length;E++)this.words[E]=0;var S=0,M=0,x;if(v==="be")for(E=u.length-1;E>=h;E-=2)x=g(u,h,E)<<S,this.words[M]|=x&67108863,S>=18?(S-=18,M+=1,this.words[M]|=x>>>26):S+=8;else{var p=u.length-h;for(E=p%2===0?h+1:h;E<u.length;E+=2)x=g(u,h,E)<<S,this.words[M]|=x&67108863,S>=18?(S-=18,M+=1,this.words[M]|=x>>>26):S+=8}this._strip()};function d(u,h,v,E){for(var S=0,M=0,x=Math.min(u.length,v),p=h;p<x;p++){var b=u.charCodeAt(p)-48;S*=E,b>=49?M=b-49+10:b>=17?M=b-17+10:M=b,i(b>=0&&M<E,"Invalid character"),S+=M}return S}a.prototype._parseBase=function(u,h,v){this.words=[0],this.length=1;for(var E=0,S=1;S<=67108863;S*=h)E++;E--,S=S/h|0;for(var M=u.length-v,x=M%E,p=Math.min(M,M-x)+v,b=0,R=v;R<p;R+=E)b=d(u,R,R+E,h),this.imuln(S),this.words[0]+b<67108864?this.words[0]+=b:this._iaddn(b);if(x!==0){var Z=1;for(b=d(u,R,u.length,h),R=0;R<x;R++)Z*=h;this.imuln(Z),this.words[0]+b<67108864?this.words[0]+=b:this._iaddn(b)}this._strip()},a.prototype.copy=function(u){u.words=new Array(this.length);for(var h=0;h<this.length;h++)u.words[h]=this.words[h];u.length=this.length,u.negative=this.negative,u.red=this.red};function m(u,h){u.words=h.words,u.length=h.length,u.negative=h.negative,u.red=h.red}if(a.prototype._move=function(u){m(u,this)},a.prototype.clone=function(){var u=new a(null);return this.copy(u),u},a.prototype._expand=function(u){for(;this.length<u;)this.words[this.length++]=0;return this},a.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},a.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{a.prototype[Symbol.for("nodejs.util.inspect.custom")]=w}catch{a.prototype.inspect=w}else a.prototype.inspect=w;function w(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var O=["","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"],C=[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],P=[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];a.prototype.toString=function(u,h){u=u||10,h=h|0||1;var v;if(u===16||u==="hex"){v="";for(var E=0,S=0,M=0;M<this.length;M++){var x=this.words[M],p=((x<<E|S)&16777215).toString(16);S=x>>>24-E&16777215,E+=2,E>=26&&(E-=26,M--),S!==0||M!==this.length-1?v=O[6-p.length]+p+v:v=p+v}for(S!==0&&(v=S.toString(16)+v);v.length%h!==0;)v="0"+v;return this.negative!==0&&(v="-"+v),v}if(u===(u|0)&&u>=2&&u<=36){var b=C[u],R=P[u];v="";var Z=this.clone();for(Z.negative=0;!Z.isZero();){var ae=Z.modrn(R).toString(u);Z=Z.idivn(R),Z.isZero()?v=ae+v:v=O[b-ae.length]+ae+v}for(this.isZero()&&(v="0"+v);v.length%h!==0;)v="0"+v;return this.negative!==0&&(v="-"+v),v}i(!1,"Base should be between 2 and 36")},a.prototype.toNumber=function(){var u=this.words[0];return this.length===2?u+=this.words[1]*67108864:this.length===3&&this.words[2]===1?u+=4503599627370496+this.words[1]*67108864:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-u:u},a.prototype.toJSON=function(){return this.toString(16,2)},c&&(a.prototype.toBuffer=function(u,h){return this.toArrayLike(c,u,h)}),a.prototype.toArray=function(u,h){return this.toArrayLike(Array,u,h)};var q=function(u,h){return u.allocUnsafe?u.allocUnsafe(h):new u(h)};a.prototype.toArrayLike=function(u,h,v){this._strip();var E=this.byteLength(),S=v||Math.max(1,E);i(E<=S,"byte array longer than desired length"),i(S>0,"Requested array length <= 0");var M=q(u,S),x=h==="le"?"LE":"BE";return this["_toArrayLike"+x](M,E),M},a.prototype._toArrayLikeLE=function(u,h){for(var v=0,E=0,S=0,M=0;S<this.length;S++){var x=this.words[S]<<M|E;u[v++]=x&255,v<u.length&&(u[v++]=x>>8&255),v<u.length&&(u[v++]=x>>16&255),M===6?(v<u.length&&(u[v++]=x>>24&255),E=0,M=0):(E=x>>>24,M+=2)}if(v<u.length)for(u[v++]=E;v<u.length;)u[v++]=0},a.prototype._toArrayLikeBE=function(u,h){for(var v=u.length-1,E=0,S=0,M=0;S<this.length;S++){var x=this.words[S]<<M|E;u[v--]=x&255,v>=0&&(u[v--]=x>>8&255),v>=0&&(u[v--]=x>>16&255),M===6?(v>=0&&(u[v--]=x>>24&255),E=0,M=0):(E=x>>>24,M+=2)}if(v>=0)for(u[v--]=E;v>=0;)u[v--]=0},Math.clz32?a.prototype._countBits=function(u){return 32-Math.clz32(u)}:a.prototype._countBits=function(u){var h=u,v=0;return h>=4096&&(v+=13,h>>>=13),h>=64&&(v+=7,h>>>=7),h>=8&&(v+=4,h>>>=4),h>=2&&(v+=2,h>>>=2),v+h},a.prototype._zeroBits=function(u){if(u===0)return 26;var h=u,v=0;return h&8191||(v+=13,h>>>=13),h&127||(v+=7,h>>>=7),h&15||(v+=4,h>>>=4),h&3||(v+=2,h>>>=2),h&1||v++,v},a.prototype.bitLength=function(){var u=this.words[this.length-1],h=this._countBits(u);return(this.length-1)*26+h};function K(u){for(var h=new Array(u.bitLength()),v=0;v<h.length;v++){var E=v/26|0,S=v%26;h[v]=u.words[E]>>>S&1}return h}a.prototype.zeroBits=function(){if(this.isZero())return 0;for(var u=0,h=0;h<this.length;h++){var v=this._zeroBits(this.words[h]);if(u+=v,v!==26)break}return u},a.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},a.prototype.toTwos=function(u){return this.negative!==0?this.abs().inotn(u).iaddn(1):this.clone()},a.prototype.fromTwos=function(u){return this.testn(u-1)?this.notn(u).iaddn(1).ineg():this.clone()},a.prototype.isNeg=function(){return this.negative!==0},a.prototype.neg=function(){return this.clone().ineg()},a.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},a.prototype.iuor=function(u){for(;this.length<u.length;)this.words[this.length++]=0;for(var h=0;h<u.length;h++)this.words[h]=this.words[h]|u.words[h];return this._strip()},a.prototype.ior=function(u){return i((this.negative|u.negative)===0),this.iuor(u)},a.prototype.or=function(u){return this.length>u.length?this.clone().ior(u):u.clone().ior(this)},a.prototype.uor=function(u){return this.length>u.length?this.clone().iuor(u):u.clone().iuor(this)},a.prototype.iuand=function(u){var h;this.length>u.length?h=u:h=this;for(var v=0;v<h.length;v++)this.words[v]=this.words[v]&u.words[v];return this.length=h.length,this._strip()},a.prototype.iand=function(u){return i((this.negative|u.negative)===0),this.iuand(u)},a.prototype.and=function(u){return this.length>u.length?this.clone().iand(u):u.clone().iand(this)},a.prototype.uand=function(u){return this.length>u.length?this.clone().iuand(u):u.clone().iuand(this)},a.prototype.iuxor=function(u){var h,v;this.length>u.length?(h=this,v=u):(h=u,v=this);for(var E=0;E<v.length;E++)this.words[E]=h.words[E]^v.words[E];if(this!==h)for(;E<h.length;E++)this.words[E]=h.words[E];return this.length=h.length,this._strip()},a.prototype.ixor=function(u){return i((this.negative|u.negative)===0),this.iuxor(u)},a.prototype.xor=function(u){return this.length>u.length?this.clone().ixor(u):u.clone().ixor(this)},a.prototype.uxor=function(u){return this.length>u.length?this.clone().iuxor(u):u.clone().iuxor(this)},a.prototype.inotn=function(u){i(typeof u=="number"&&u>=0);var h=Math.ceil(u/26)|0,v=u%26;this._expand(h),v>0&&h--;for(var E=0;E<h;E++)this.words[E]=~this.words[E]&67108863;return v>0&&(this.words[E]=~this.words[E]&67108863>>26-v),this._strip()},a.prototype.notn=function(u){return this.clone().inotn(u)},a.prototype.setn=function(u,h){i(typeof u=="number"&&u>=0);var v=u/26|0,E=u%26;return this._expand(v+1),h?this.words[v]=this.words[v]|1<<E:this.words[v]=this.words[v]&~(1<<E),this._strip()},a.prototype.iadd=function(u){var h;if(this.negative!==0&&u.negative===0)return this.negative=0,h=this.isub(u),this.negative^=1,this._normSign();if(this.negative===0&&u.negative!==0)return u.negative=0,h=this.isub(u),u.negative=1,h._normSign();var v,E;this.length>u.length?(v=this,E=u):(v=u,E=this);for(var S=0,M=0;M<E.length;M++)h=(v.words[M]|0)+(E.words[M]|0)+S,this.words[M]=h&67108863,S=h>>>26;for(;S!==0&&M<v.length;M++)h=(v.words[M]|0)+S,this.words[M]=h&67108863,S=h>>>26;if(this.length=v.length,S!==0)this.words[this.length]=S,this.length++;else if(v!==this)for(;M<v.length;M++)this.words[M]=v.words[M];return this},a.prototype.add=function(u){var h;return u.negative!==0&&this.negative===0?(u.negative=0,h=this.sub(u),u.negative^=1,h):u.negative===0&&this.negative!==0?(this.negative=0,h=u.sub(this),this.negative=1,h):this.length>u.length?this.clone().iadd(u):u.clone().iadd(this)},a.prototype.isub=function(u){if(u.negative!==0){u.negative=0;var h=this.iadd(u);return u.negative=1,h._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(u),this.negative=1,this._normSign();var v=this.cmp(u);if(v===0)return this.negative=0,this.length=1,this.words[0]=0,this;var E,S;v>0?(E=this,S=u):(E=u,S=this);for(var M=0,x=0;x<S.length;x++)h=(E.words[x]|0)-(S.words[x]|0)+M,M=h>>26,this.words[x]=h&67108863;for(;M!==0&&x<E.length;x++)h=(E.words[x]|0)+M,M=h>>26,this.words[x]=h&67108863;if(M===0&&x<E.length&&E!==this)for(;x<E.length;x++)this.words[x]=E.words[x];return this.length=Math.max(this.length,x),E!==this&&(this.negative=1),this._strip()},a.prototype.sub=function(u){return this.clone().isub(u)};function Y(u,h,v){v.negative=h.negative^u.negative;var E=u.length+h.length|0;v.length=E,E=E-1|0;var S=u.words[0]|0,M=h.words[0]|0,x=S*M,p=x&67108863,b=x/67108864|0;v.words[0]=p;for(var R=1;R<E;R++){for(var Z=b>>>26,ae=b&67108863,I=Math.min(R,h.length-1),ee=Math.max(0,R-u.length+1);ee<=I;ee++){var L=R-ee|0;S=u.words[L]|0,M=h.words[ee]|0,x=S*M+ae,Z+=x/67108864|0,ae=x&67108863}v.words[R]=ae|0,b=Z|0}return b!==0?v.words[R]=b|0:v.length--,v._strip()}var z=function(u,h,v){var E=u.words,S=h.words,M=v.words,x=0,p,b,R,Z=E[0]|0,ae=Z&8191,I=Z>>>13,ee=E[1]|0,L=ee&8191,V=ee>>>13,G=E[2]|0,D=G&8191,H=G>>>13,ne=E[3]|0,ce=ne&8191,fe=ne>>>13,ye=E[4]|0,we=ye&8191,Te=ye>>>13,Qe=E[5]|0,Ce=Qe&8191,Re=Qe>>>13,Se=E[6]|0,me=Se&8191,Pe=Se>>>13,Ne=E[7]|0,be=Ne&8191,Oe=Ne>>>13,xe=E[8]|0,ve=xe&8191,qe=xe>>>13,Me=E[9]|0,_e=Me&8191,He=Me>>>13,Ve=S[0]|0,Ee=Ve&8191,Ke=Ve>>>13,ht=S[1]|0,Ge=ht&8191,_t=ht>>>13,lt=S[2]|0,We=lt&8191,Et=lt>>>13,St=S[3]|0,Be=St&8191,Xe=St>>>13,tt=S[4]|0,$e=tt&8191,et=tt>>>13,Ze=S[5]|0,Fe=Ze&8191,ut=Ze>>>13,rt=S[6]|0,ze=rt&8191,it=rt>>>13,st=S[7]|0,Ue=st&8191,Ye=st>>>13,ft=S[8]|0,je=ft&8191,Rt=ft>>>13,Nt=S[9]|0,at=Nt&8191,vt=Nt>>>13;v.negative=u.negative^h.negative,v.length=19,p=Math.imul(ae,Ee),b=Math.imul(ae,Ke),b=b+Math.imul(I,Ee)|0,R=Math.imul(I,Ke);var Rr=(x+p|0)+((b&8191)<<13)|0;x=(R+(b>>>13)|0)+(Rr>>>26)|0,Rr&=67108863,p=Math.imul(L,Ee),b=Math.imul(L,Ke),b=b+Math.imul(V,Ee)|0,R=Math.imul(V,Ke),p=p+Math.imul(ae,Ge)|0,b=b+Math.imul(ae,_t)|0,b=b+Math.imul(I,Ge)|0,R=R+Math.imul(I,_t)|0;var Nr=(x+p|0)+((b&8191)<<13)|0;x=(R+(b>>>13)|0)+(Nr>>>26)|0,Nr&=67108863,p=Math.imul(D,Ee),b=Math.imul(D,Ke),b=b+Math.imul(H,Ee)|0,R=Math.imul(H,Ke),p=p+Math.imul(L,Ge)|0,b=b+Math.imul(L,_t)|0,b=b+Math.imul(V,Ge)|0,R=R+Math.imul(V,_t)|0,p=p+Math.imul(ae,We)|0,b=b+Math.imul(ae,Et)|0,b=b+Math.imul(I,We)|0,R=R+Math.imul(I,Et)|0;var Br=(x+p|0)+((b&8191)<<13)|0;x=(R+(b>>>13)|0)+(Br>>>26)|0,Br&=67108863,p=Math.imul(ce,Ee),b=Math.imul(ce,Ke),b=b+Math.imul(fe,Ee)|0,R=Math.imul(fe,Ke),p=p+Math.imul(D,Ge)|0,b=b+Math.imul(D,_t)|0,b=b+Math.imul(H,Ge)|0,R=R+Math.imul(H,_t)|0,p=p+Math.imul(L,We)|0,b=b+Math.imul(L,Et)|0,b=b+Math.imul(V,We)|0,R=R+Math.imul(V,Et)|0,p=p+Math.imul(ae,Be)|0,b=b+Math.imul(ae,Xe)|0,b=b+Math.imul(I,Be)|0,R=R+Math.imul(I,Xe)|0;var $r=(x+p|0)+((b&8191)<<13)|0;x=(R+(b>>>13)|0)+($r>>>26)|0,$r&=67108863,p=Math.imul(we,Ee),b=Math.imul(we,Ke),b=b+Math.imul(Te,Ee)|0,R=Math.imul(Te,Ke),p=p+Math.imul(ce,Ge)|0,b=b+Math.imul(ce,_t)|0,b=b+Math.imul(fe,Ge)|0,R=R+Math.imul(fe,_t)|0,p=p+Math.imul(D,We)|0,b=b+Math.imul(D,Et)|0,b=b+Math.imul(H,We)|0,R=R+Math.imul(H,Et)|0,p=p+Math.imul(L,Be)|0,b=b+Math.imul(L,Xe)|0,b=b+Math.imul(V,Be)|0,R=R+Math.imul(V,Xe)|0,p=p+Math.imul(ae,$e)|0,b=b+Math.imul(ae,et)|0,b=b+Math.imul(I,$e)|0,R=R+Math.imul(I,et)|0;var Ur=(x+p|0)+((b&8191)<<13)|0;x=(R+(b>>>13)|0)+(Ur>>>26)|0,Ur&=67108863,p=Math.imul(Ce,Ee),b=Math.imul(Ce,Ke),b=b+Math.imul(Re,Ee)|0,R=Math.imul(Re,Ke),p=p+Math.imul(we,Ge)|0,b=b+Math.imul(we,_t)|0,b=b+Math.imul(Te,Ge)|0,R=R+Math.imul(Te,_t)|0,p=p+Math.imul(ce,We)|0,b=b+Math.imul(ce,Et)|0,b=b+Math.imul(fe,We)|0,R=R+Math.imul(fe,Et)|0,p=p+Math.imul(D,Be)|0,b=b+Math.imul(D,Xe)|0,b=b+Math.imul(H,Be)|0,R=R+Math.imul(H,Xe)|0,p=p+Math.imul(L,$e)|0,b=b+Math.imul(L,et)|0,b=b+Math.imul(V,$e)|0,R=R+Math.imul(V,et)|0,p=p+Math.imul(ae,Fe)|0,b=b+Math.imul(ae,ut)|0,b=b+Math.imul(I,Fe)|0,R=R+Math.imul(I,ut)|0;var er=(x+p|0)+((b&8191)<<13)|0;x=(R+(b>>>13)|0)+(er>>>26)|0,er&=67108863,p=Math.imul(me,Ee),b=Math.imul(me,Ke),b=b+Math.imul(Pe,Ee)|0,R=Math.imul(Pe,Ke),p=p+Math.imul(Ce,Ge)|0,b=b+Math.imul(Ce,_t)|0,b=b+Math.imul(Re,Ge)|0,R=R+Math.imul(Re,_t)|0,p=p+Math.imul(we,We)|0,b=b+Math.imul(we,Et)|0,b=b+Math.imul(Te,We)|0,R=R+Math.imul(Te,Et)|0,p=p+Math.imul(ce,Be)|0,b=b+Math.imul(ce,Xe)|0,b=b+Math.imul(fe,Be)|0,R=R+Math.imul(fe,Xe)|0,p=p+Math.imul(D,$e)|0,b=b+Math.imul(D,et)|0,b=b+Math.imul(H,$e)|0,R=R+Math.imul(H,et)|0,p=p+Math.imul(L,Fe)|0,b=b+Math.imul(L,ut)|0,b=b+Math.imul(V,Fe)|0,R=R+Math.imul(V,ut)|0,p=p+Math.imul(ae,ze)|0,b=b+Math.imul(ae,it)|0,b=b+Math.imul(I,ze)|0,R=R+Math.imul(I,it)|0;var Xr=(x+p|0)+((b&8191)<<13)|0;x=(R+(b>>>13)|0)+(Xr>>>26)|0,Xr&=67108863,p=Math.imul(be,Ee),b=Math.imul(be,Ke),b=b+Math.imul(Oe,Ee)|0,R=Math.imul(Oe,Ke),p=p+Math.imul(me,Ge)|0,b=b+Math.imul(me,_t)|0,b=b+Math.imul(Pe,Ge)|0,R=R+Math.imul(Pe,_t)|0,p=p+Math.imul(Ce,We)|0,b=b+Math.imul(Ce,Et)|0,b=b+Math.imul(Re,We)|0,R=R+Math.imul(Re,Et)|0,p=p+Math.imul(we,Be)|0,b=b+Math.imul(we,Xe)|0,b=b+Math.imul(Te,Be)|0,R=R+Math.imul(Te,Xe)|0,p=p+Math.imul(ce,$e)|0,b=b+Math.imul(ce,et)|0,b=b+Math.imul(fe,$e)|0,R=R+Math.imul(fe,et)|0,p=p+Math.imul(D,Fe)|0,b=b+Math.imul(D,ut)|0,b=b+Math.imul(H,Fe)|0,R=R+Math.imul(H,ut)|0,p=p+Math.imul(L,ze)|0,b=b+Math.imul(L,it)|0,b=b+Math.imul(V,ze)|0,R=R+Math.imul(V,it)|0,p=p+Math.imul(ae,Ue)|0,b=b+Math.imul(ae,Ye)|0,b=b+Math.imul(I,Ue)|0,R=R+Math.imul(I,Ye)|0;var Wi=(x+p|0)+((b&8191)<<13)|0;x=(R+(b>>>13)|0)+(Wi>>>26)|0,Wi&=67108863,p=Math.imul(ve,Ee),b=Math.imul(ve,Ke),b=b+Math.imul(qe,Ee)|0,R=Math.imul(qe,Ke),p=p+Math.imul(be,Ge)|0,b=b+Math.imul(be,_t)|0,b=b+Math.imul(Oe,Ge)|0,R=R+Math.imul(Oe,_t)|0,p=p+Math.imul(me,We)|0,b=b+Math.imul(me,Et)|0,b=b+Math.imul(Pe,We)|0,R=R+Math.imul(Pe,Et)|0,p=p+Math.imul(Ce,Be)|0,b=b+Math.imul(Ce,Xe)|0,b=b+Math.imul(Re,Be)|0,R=R+Math.imul(Re,Xe)|0,p=p+Math.imul(we,$e)|0,b=b+Math.imul(we,et)|0,b=b+Math.imul(Te,$e)|0,R=R+Math.imul(Te,et)|0,p=p+Math.imul(ce,Fe)|0,b=b+Math.imul(ce,ut)|0,b=b+Math.imul(fe,Fe)|0,R=R+Math.imul(fe,ut)|0,p=p+Math.imul(D,ze)|0,b=b+Math.imul(D,it)|0,b=b+Math.imul(H,ze)|0,R=R+Math.imul(H,it)|0,p=p+Math.imul(L,Ue)|0,b=b+Math.imul(L,Ye)|0,b=b+Math.imul(V,Ue)|0,R=R+Math.imul(V,Ye)|0,p=p+Math.imul(ae,je)|0,b=b+Math.imul(ae,Rt)|0,b=b+Math.imul(I,je)|0,R=R+Math.imul(I,Rt)|0;var Zr=(x+p|0)+((b&8191)<<13)|0;x=(R+(b>>>13)|0)+(Zr>>>26)|0,Zr&=67108863,p=Math.imul(_e,Ee),b=Math.imul(_e,Ke),b=b+Math.imul(He,Ee)|0,R=Math.imul(He,Ke),p=p+Math.imul(ve,Ge)|0,b=b+Math.imul(ve,_t)|0,b=b+Math.imul(qe,Ge)|0,R=R+Math.imul(qe,_t)|0,p=p+Math.imul(be,We)|0,b=b+Math.imul(be,Et)|0,b=b+Math.imul(Oe,We)|0,R=R+Math.imul(Oe,Et)|0,p=p+Math.imul(me,Be)|0,b=b+Math.imul(me,Xe)|0,b=b+Math.imul(Pe,Be)|0,R=R+Math.imul(Pe,Xe)|0,p=p+Math.imul(Ce,$e)|0,b=b+Math.imul(Ce,et)|0,b=b+Math.imul(Re,$e)|0,R=R+Math.imul(Re,et)|0,p=p+Math.imul(we,Fe)|0,b=b+Math.imul(we,ut)|0,b=b+Math.imul(Te,Fe)|0,R=R+Math.imul(Te,ut)|0,p=p+Math.imul(ce,ze)|0,b=b+Math.imul(ce,it)|0,b=b+Math.imul(fe,ze)|0,R=R+Math.imul(fe,it)|0,p=p+Math.imul(D,Ue)|0,b=b+Math.imul(D,Ye)|0,b=b+Math.imul(H,Ue)|0,R=R+Math.imul(H,Ye)|0,p=p+Math.imul(L,je)|0,b=b+Math.imul(L,Rt)|0,b=b+Math.imul(V,je)|0,R=R+Math.imul(V,Rt)|0,p=p+Math.imul(ae,at)|0,b=b+Math.imul(ae,vt)|0,b=b+Math.imul(I,at)|0,R=R+Math.imul(I,vt)|0;var Yi=(x+p|0)+((b&8191)<<13)|0;x=(R+(b>>>13)|0)+(Yi>>>26)|0,Yi&=67108863,p=Math.imul(_e,Ge),b=Math.imul(_e,_t),b=b+Math.imul(He,Ge)|0,R=Math.imul(He,_t),p=p+Math.imul(ve,We)|0,b=b+Math.imul(ve,Et)|0,b=b+Math.imul(qe,We)|0,R=R+Math.imul(qe,Et)|0,p=p+Math.imul(be,Be)|0,b=b+Math.imul(be,Xe)|0,b=b+Math.imul(Oe,Be)|0,R=R+Math.imul(Oe,Xe)|0,p=p+Math.imul(me,$e)|0,b=b+Math.imul(me,et)|0,b=b+Math.imul(Pe,$e)|0,R=R+Math.imul(Pe,et)|0,p=p+Math.imul(Ce,Fe)|0,b=b+Math.imul(Ce,ut)|0,b=b+Math.imul(Re,Fe)|0,R=R+Math.imul(Re,ut)|0,p=p+Math.imul(we,ze)|0,b=b+Math.imul(we,it)|0,b=b+Math.imul(Te,ze)|0,R=R+Math.imul(Te,it)|0,p=p+Math.imul(ce,Ue)|0,b=b+Math.imul(ce,Ye)|0,b=b+Math.imul(fe,Ue)|0,R=R+Math.imul(fe,Ye)|0,p=p+Math.imul(D,je)|0,b=b+Math.imul(D,Rt)|0,b=b+Math.imul(H,je)|0,R=R+Math.imul(H,Rt)|0,p=p+Math.imul(L,at)|0,b=b+Math.imul(L,vt)|0,b=b+Math.imul(V,at)|0,R=R+Math.imul(V,vt)|0;var Qi=(x+p|0)+((b&8191)<<13)|0;x=(R+(b>>>13)|0)+(Qi>>>26)|0,Qi&=67108863,p=Math.imul(_e,We),b=Math.imul(_e,Et),b=b+Math.imul(He,We)|0,R=Math.imul(He,Et),p=p+Math.imul(ve,Be)|0,b=b+Math.imul(ve,Xe)|0,b=b+Math.imul(qe,Be)|0,R=R+Math.imul(qe,Xe)|0,p=p+Math.imul(be,$e)|0,b=b+Math.imul(be,et)|0,b=b+Math.imul(Oe,$e)|0,R=R+Math.imul(Oe,et)|0,p=p+Math.imul(me,Fe)|0,b=b+Math.imul(me,ut)|0,b=b+Math.imul(Pe,Fe)|0,R=R+Math.imul(Pe,ut)|0,p=p+Math.imul(Ce,ze)|0,b=b+Math.imul(Ce,it)|0,b=b+Math.imul(Re,ze)|0,R=R+Math.imul(Re,it)|0,p=p+Math.imul(we,Ue)|0,b=b+Math.imul(we,Ye)|0,b=b+Math.imul(Te,Ue)|0,R=R+Math.imul(Te,Ye)|0,p=p+Math.imul(ce,je)|0,b=b+Math.imul(ce,Rt)|0,b=b+Math.imul(fe,je)|0,R=R+Math.imul(fe,Rt)|0,p=p+Math.imul(D,at)|0,b=b+Math.imul(D,vt)|0,b=b+Math.imul(H,at)|0,R=R+Math.imul(H,vt)|0;var ei=(x+p|0)+((b&8191)<<13)|0;x=(R+(b>>>13)|0)+(ei>>>26)|0,ei&=67108863,p=Math.imul(_e,Be),b=Math.imul(_e,Xe),b=b+Math.imul(He,Be)|0,R=Math.imul(He,Xe),p=p+Math.imul(ve,$e)|0,b=b+Math.imul(ve,et)|0,b=b+Math.imul(qe,$e)|0,R=R+Math.imul(qe,et)|0,p=p+Math.imul(be,Fe)|0,b=b+Math.imul(be,ut)|0,b=b+Math.imul(Oe,Fe)|0,R=R+Math.imul(Oe,ut)|0,p=p+Math.imul(me,ze)|0,b=b+Math.imul(me,it)|0,b=b+Math.imul(Pe,ze)|0,R=R+Math.imul(Pe,it)|0,p=p+Math.imul(Ce,Ue)|0,b=b+Math.imul(Ce,Ye)|0,b=b+Math.imul(Re,Ue)|0,R=R+Math.imul(Re,Ye)|0,p=p+Math.imul(we,je)|0,b=b+Math.imul(we,Rt)|0,b=b+Math.imul(Te,je)|0,R=R+Math.imul(Te,Rt)|0,p=p+Math.imul(ce,at)|0,b=b+Math.imul(ce,vt)|0,b=b+Math.imul(fe,at)|0,R=R+Math.imul(fe,vt)|0;var Mi=(x+p|0)+((b&8191)<<13)|0;x=(R+(b>>>13)|0)+(Mi>>>26)|0,Mi&=67108863,p=Math.imul(_e,$e),b=Math.imul(_e,et),b=b+Math.imul(He,$e)|0,R=Math.imul(He,et),p=p+Math.imul(ve,Fe)|0,b=b+Math.imul(ve,ut)|0,b=b+Math.imul(qe,Fe)|0,R=R+Math.imul(qe,ut)|0,p=p+Math.imul(be,ze)|0,b=b+Math.imul(be,it)|0,b=b+Math.imul(Oe,ze)|0,R=R+Math.imul(Oe,it)|0,p=p+Math.imul(me,Ue)|0,b=b+Math.imul(me,Ye)|0,b=b+Math.imul(Pe,Ue)|0,R=R+Math.imul(Pe,Ye)|0,p=p+Math.imul(Ce,je)|0,b=b+Math.imul(Ce,Rt)|0,b=b+Math.imul(Re,je)|0,R=R+Math.imul(Re,Rt)|0,p=p+Math.imul(we,at)|0,b=b+Math.imul(we,vt)|0,b=b+Math.imul(Te,at)|0,R=R+Math.imul(Te,vt)|0;var Ii=(x+p|0)+((b&8191)<<13)|0;x=(R+(b>>>13)|0)+(Ii>>>26)|0,Ii&=67108863,p=Math.imul(_e,Fe),b=Math.imul(_e,ut),b=b+Math.imul(He,Fe)|0,R=Math.imul(He,ut),p=p+Math.imul(ve,ze)|0,b=b+Math.imul(ve,it)|0,b=b+Math.imul(qe,ze)|0,R=R+Math.imul(qe,it)|0,p=p+Math.imul(be,Ue)|0,b=b+Math.imul(be,Ye)|0,b=b+Math.imul(Oe,Ue)|0,R=R+Math.imul(Oe,Ye)|0,p=p+Math.imul(me,je)|0,b=b+Math.imul(me,Rt)|0,b=b+Math.imul(Pe,je)|0,R=R+Math.imul(Pe,Rt)|0,p=p+Math.imul(Ce,at)|0,b=b+Math.imul(Ce,vt)|0,b=b+Math.imul(Re,at)|0,R=R+Math.imul(Re,vt)|0;var lr=(x+p|0)+((b&8191)<<13)|0;x=(R+(b>>>13)|0)+(lr>>>26)|0,lr&=67108863,p=Math.imul(_e,ze),b=Math.imul(_e,it),b=b+Math.imul(He,ze)|0,R=Math.imul(He,it),p=p+Math.imul(ve,Ue)|0,b=b+Math.imul(ve,Ye)|0,b=b+Math.imul(qe,Ue)|0,R=R+Math.imul(qe,Ye)|0,p=p+Math.imul(be,je)|0,b=b+Math.imul(be,Rt)|0,b=b+Math.imul(Oe,je)|0,R=R+Math.imul(Oe,Rt)|0,p=p+Math.imul(me,at)|0,b=b+Math.imul(me,vt)|0,b=b+Math.imul(Pe,at)|0,R=R+Math.imul(Pe,vt)|0;var Xi=(x+p|0)+((b&8191)<<13)|0;x=(R+(b>>>13)|0)+(Xi>>>26)|0,Xi&=67108863,p=Math.imul(_e,Ue),b=Math.imul(_e,Ye),b=b+Math.imul(He,Ue)|0,R=Math.imul(He,Ye),p=p+Math.imul(ve,je)|0,b=b+Math.imul(ve,Rt)|0,b=b+Math.imul(qe,je)|0,R=R+Math.imul(qe,Rt)|0,p=p+Math.imul(be,at)|0,b=b+Math.imul(be,vt)|0,b=b+Math.imul(Oe,at)|0,R=R+Math.imul(Oe,vt)|0;var Zi=(x+p|0)+((b&8191)<<13)|0;x=(R+(b>>>13)|0)+(Zi>>>26)|0,Zi&=67108863,p=Math.imul(_e,je),b=Math.imul(_e,Rt),b=b+Math.imul(He,je)|0,R=Math.imul(He,Rt),p=p+Math.imul(ve,at)|0,b=b+Math.imul(ve,vt)|0,b=b+Math.imul(qe,at)|0,R=R+Math.imul(qe,vt)|0;var en=(x+p|0)+((b&8191)<<13)|0;x=(R+(b>>>13)|0)+(en>>>26)|0,en&=67108863,p=Math.imul(_e,at),b=Math.imul(_e,vt),b=b+Math.imul(He,at)|0,R=Math.imul(He,vt);var Ks=(x+p|0)+((b&8191)<<13)|0;return x=(R+(b>>>13)|0)+(Ks>>>26)|0,Ks&=67108863,M[0]=Rr,M[1]=Nr,M[2]=Br,M[3]=$r,M[4]=Ur,M[5]=er,M[6]=Xr,M[7]=Wi,M[8]=Zr,M[9]=Yi,M[10]=Qi,M[11]=ei,M[12]=Mi,M[13]=Ii,M[14]=lr,M[15]=Xi,M[16]=Zi,M[17]=en,M[18]=Ks,x!==0&&(M[19]=x,v.length++),v};Math.imul||(z=Y);function W(u,h,v){v.negative=h.negative^u.negative,v.length=u.length+h.length;for(var E=0,S=0,M=0;M<v.length-1;M++){var x=S;S=0;for(var p=E&67108863,b=Math.min(M,h.length-1),R=Math.max(0,M-u.length+1);R<=b;R++){var Z=M-R,ae=u.words[Z]|0,I=h.words[R]|0,ee=ae*I,L=ee&67108863;x=x+(ee/67108864|0)|0,L=L+p|0,p=L&67108863,x=x+(L>>>26)|0,S+=x>>>26,x&=67108863}v.words[M]=p,E=x,x=S}return E!==0?v.words[M]=E:v.length--,v._strip()}function B(u,h,v){return W(u,h,v)}a.prototype.mulTo=function(u,h){var v,E=this.length+u.length;return this.length===10&&u.length===10?v=z(this,u,h):E<63?v=Y(this,u,h):E<1024?v=W(this,u,h):v=B(this,u,h),v},a.prototype.mul=function(u){var h=new a(null);return h.words=new Array(this.length+u.length),this.mulTo(u,h)},a.prototype.mulf=function(u){var h=new a(null);return h.words=new Array(this.length+u.length),B(this,u,h)},a.prototype.imul=function(u){return this.clone().mulTo(u,this)},a.prototype.imuln=function(u){var h=u<0;h&&(u=-u),i(typeof u=="number"),i(u<67108864);for(var v=0,E=0;E<this.length;E++){var S=(this.words[E]|0)*u,M=(S&67108863)+(v&67108863);v>>=26,v+=S/67108864|0,v+=M>>>26,this.words[E]=M&67108863}return v!==0&&(this.words[E]=v,this.length++),h?this.ineg():this},a.prototype.muln=function(u){return this.clone().imuln(u)},a.prototype.sqr=function(){return this.mul(this)},a.prototype.isqr=function(){return this.imul(this.clone())},a.prototype.pow=function(u){var h=K(u);if(h.length===0)return new a(1);for(var v=this,E=0;E<h.length&&h[E]===0;E++,v=v.sqr());if(++E<h.length)for(var S=v.sqr();E<h.length;E++,S=S.sqr())h[E]!==0&&(v=v.mul(S));return v},a.prototype.iushln=function(u){i(typeof u=="number"&&u>=0);var h=u%26,v=(u-h)/26,E=67108863>>>26-h<<26-h,S;if(h!==0){var M=0;for(S=0;S<this.length;S++){var x=this.words[S]&E,p=(this.words[S]|0)-x<<h;this.words[S]=p|M,M=x>>>26-h}M&&(this.words[S]=M,this.length++)}if(v!==0){for(S=this.length-1;S>=0;S--)this.words[S+v]=this.words[S];for(S=0;S<v;S++)this.words[S]=0;this.length+=v}return this._strip()},a.prototype.ishln=function(u){return i(this.negative===0),this.iushln(u)},a.prototype.iushrn=function(u,h,v){i(typeof u=="number"&&u>=0);var E;h?E=(h-h%26)/26:E=0;var S=u%26,M=Math.min((u-S)/26,this.length),x=67108863^67108863>>>S<<S,p=v;if(E-=M,E=Math.max(0,E),p){for(var b=0;b<M;b++)p.words[b]=this.words[b];p.length=M}if(M!==0)if(this.length>M)for(this.length-=M,b=0;b<this.length;b++)this.words[b]=this.words[b+M];else this.words[0]=0,this.length=1;var R=0;for(b=this.length-1;b>=0&&(R!==0||b>=E);b--){var Z=this.words[b]|0;this.words[b]=R<<26-S|Z>>>S,R=Z&x}return p&&R!==0&&(p.words[p.length++]=R),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},a.prototype.ishrn=function(u,h,v){return i(this.negative===0),this.iushrn(u,h,v)},a.prototype.shln=function(u){return this.clone().ishln(u)},a.prototype.ushln=function(u){return this.clone().iushln(u)},a.prototype.shrn=function(u){return this.clone().ishrn(u)},a.prototype.ushrn=function(u){return this.clone().iushrn(u)},a.prototype.testn=function(u){i(typeof u=="number"&&u>=0);var h=u%26,v=(u-h)/26,E=1<<h;if(this.length<=v)return!1;var S=this.words[v];return!!(S&E)},a.prototype.imaskn=function(u){i(typeof u=="number"&&u>=0);var h=u%26,v=(u-h)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=v)return this;if(h!==0&&v++,this.length=Math.min(v,this.length),h!==0){var E=67108863^67108863>>>h<<h;this.words[this.length-1]&=E}return this._strip()},a.prototype.maskn=function(u){return this.clone().imaskn(u)},a.prototype.iaddn=function(u){return i(typeof u=="number"),i(u<67108864),u<0?this.isubn(-u):this.negative!==0?this.length===1&&(this.words[0]|0)<=u?(this.words[0]=u-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(u),this.negative=1,this):this._iaddn(u)},a.prototype._iaddn=function(u){this.words[0]+=u;for(var h=0;h<this.length&&this.words[h]>=67108864;h++)this.words[h]-=67108864,h===this.length-1?this.words[h+1]=1:this.words[h+1]++;return this.length=Math.max(this.length,h+1),this},a.prototype.isubn=function(u){if(i(typeof u=="number"),i(u<67108864),u<0)return this.iaddn(-u);if(this.negative!==0)return this.negative=0,this.iaddn(u),this.negative=1,this;if(this.words[0]-=u,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var h=0;h<this.length&&this.words[h]<0;h++)this.words[h]+=67108864,this.words[h+1]-=1;return this._strip()},a.prototype.addn=function(u){return this.clone().iaddn(u)},a.prototype.subn=function(u){return this.clone().isubn(u)},a.prototype.iabs=function(){return this.negative=0,this},a.prototype.abs=function(){return this.clone().iabs()},a.prototype._ishlnsubmul=function(u,h,v){var E=u.length+v,S;this._expand(E);var M,x=0;for(S=0;S<u.length;S++){M=(this.words[S+v]|0)+x;var p=(u.words[S]|0)*h;M-=p&67108863,x=(M>>26)-(p/67108864|0),this.words[S+v]=M&67108863}for(;S<this.length-v;S++)M=(this.words[S+v]|0)+x,x=M>>26,this.words[S+v]=M&67108863;if(x===0)return this._strip();for(i(x===-1),x=0,S=0;S<this.length;S++)M=-(this.words[S]|0)+x,x=M>>26,this.words[S]=M&67108863;return this.negative=1,this._strip()},a.prototype._wordDiv=function(u,h){var v=this.length-u.length,E=this.clone(),S=u,M=S.words[S.length-1]|0,x=this._countBits(M);v=26-x,v!==0&&(S=S.ushln(v),E.iushln(v),M=S.words[S.length-1]|0);var p=E.length-S.length,b;if(h!=="mod"){b=new a(null),b.length=p+1,b.words=new Array(b.length);for(var R=0;R<b.length;R++)b.words[R]=0}var Z=E.clone()._ishlnsubmul(S,1,p);Z.negative===0&&(E=Z,b&&(b.words[p]=1));for(var ae=p-1;ae>=0;ae--){var I=(E.words[S.length+ae]|0)*67108864+(E.words[S.length+ae-1]|0);for(I=Math.min(I/M|0,67108863),E._ishlnsubmul(S,I,ae);E.negative!==0;)I--,E.negative=0,E._ishlnsubmul(S,1,ae),E.isZero()||(E.negative^=1);b&&(b.words[ae]=I)}return b&&b._strip(),E._strip(),h!=="div"&&v!==0&&E.iushrn(v),{div:b||null,mod:E}},a.prototype.divmod=function(u,h,v){if(i(!u.isZero()),this.isZero())return{div:new a(0),mod:new a(0)};var E,S,M;return this.negative!==0&&u.negative===0?(M=this.neg().divmod(u,h),h!=="mod"&&(E=M.div.neg()),h!=="div"&&(S=M.mod.neg(),v&&S.negative!==0&&S.iadd(u)),{div:E,mod:S}):this.negative===0&&u.negative!==0?(M=this.divmod(u.neg(),h),h!=="mod"&&(E=M.div.neg()),{div:E,mod:M.mod}):this.negative&u.negative?(M=this.neg().divmod(u.neg(),h),h!=="div"&&(S=M.mod.neg(),v&&S.negative!==0&&S.isub(u)),{div:M.div,mod:S}):u.length>this.length||this.cmp(u)<0?{div:new a(0),mod:this}:u.length===1?h==="div"?{div:this.divn(u.words[0]),mod:null}:h==="mod"?{div:null,mod:new a(this.modrn(u.words[0]))}:{div:this.divn(u.words[0]),mod:new a(this.modrn(u.words[0]))}:this._wordDiv(u,h)},a.prototype.div=function(u){return this.divmod(u,"div",!1).div},a.prototype.mod=function(u){return this.divmod(u,"mod",!1).mod},a.prototype.umod=function(u){return this.divmod(u,"mod",!0).mod},a.prototype.divRound=function(u){var h=this.divmod(u);if(h.mod.isZero())return h.div;var v=h.div.negative!==0?h.mod.isub(u):h.mod,E=u.ushrn(1),S=u.andln(1),M=v.cmp(E);return M<0||S===1&&M===0?h.div:h.div.negative!==0?h.div.isubn(1):h.div.iaddn(1)},a.prototype.modrn=function(u){var h=u<0;h&&(u=-u),i(u<=67108863);for(var v=(1<<26)%u,E=0,S=this.length-1;S>=0;S--)E=(v*E+(this.words[S]|0))%u;return h?-E:E},a.prototype.modn=function(u){return this.modrn(u)},a.prototype.idivn=function(u){var h=u<0;h&&(u=-u),i(u<=67108863);for(var v=0,E=this.length-1;E>=0;E--){var S=(this.words[E]|0)+v*67108864;this.words[E]=S/u|0,v=S%u}return this._strip(),h?this.ineg():this},a.prototype.divn=function(u){return this.clone().idivn(u)},a.prototype.egcd=function(u){i(u.negative===0),i(!u.isZero());var h=this,v=u.clone();h.negative!==0?h=h.umod(u):h=h.clone();for(var E=new a(1),S=new a(0),M=new a(0),x=new a(1),p=0;h.isEven()&&v.isEven();)h.iushrn(1),v.iushrn(1),++p;for(var b=v.clone(),R=h.clone();!h.isZero();){for(var Z=0,ae=1;!(h.words[0]&ae)&&Z<26;++Z,ae<<=1);if(Z>0)for(h.iushrn(Z);Z-- >0;)(E.isOdd()||S.isOdd())&&(E.iadd(b),S.isub(R)),E.iushrn(1),S.iushrn(1);for(var I=0,ee=1;!(v.words[0]&ee)&&I<26;++I,ee<<=1);if(I>0)for(v.iushrn(I);I-- >0;)(M.isOdd()||x.isOdd())&&(M.iadd(b),x.isub(R)),M.iushrn(1),x.iushrn(1);h.cmp(v)>=0?(h.isub(v),E.isub(M),S.isub(x)):(v.isub(h),M.isub(E),x.isub(S))}return{a:M,b:x,gcd:v.iushln(p)}},a.prototype._invmp=function(u){i(u.negative===0),i(!u.isZero());var h=this,v=u.clone();h.negative!==0?h=h.umod(u):h=h.clone();for(var E=new a(1),S=new a(0),M=v.clone();h.cmpn(1)>0&&v.cmpn(1)>0;){for(var x=0,p=1;!(h.words[0]&p)&&x<26;++x,p<<=1);if(x>0)for(h.iushrn(x);x-- >0;)E.isOdd()&&E.iadd(M),E.iushrn(1);for(var b=0,R=1;!(v.words[0]&R)&&b<26;++b,R<<=1);if(b>0)for(v.iushrn(b);b-- >0;)S.isOdd()&&S.iadd(M),S.iushrn(1);h.cmp(v)>=0?(h.isub(v),E.isub(S)):(v.isub(h),S.isub(E))}var Z;return h.cmpn(1)===0?Z=E:Z=S,Z.cmpn(0)<0&&Z.iadd(u),Z},a.prototype.gcd=function(u){if(this.isZero())return u.abs();if(u.isZero())return this.abs();var h=this.clone(),v=u.clone();h.negative=0,v.negative=0;for(var E=0;h.isEven()&&v.isEven();E++)h.iushrn(1),v.iushrn(1);do{for(;h.isEven();)h.iushrn(1);for(;v.isEven();)v.iushrn(1);var S=h.cmp(v);if(S<0){var M=h;h=v,v=M}else if(S===0||v.cmpn(1)===0)break;h.isub(v)}while(!0);return v.iushln(E)},a.prototype.invm=function(u){return this.egcd(u).a.umod(u)},a.prototype.isEven=function(){return(this.words[0]&1)===0},a.prototype.isOdd=function(){return(this.words[0]&1)===1},a.prototype.andln=function(u){return this.words[0]&u},a.prototype.bincn=function(u){i(typeof u=="number");var h=u%26,v=(u-h)/26,E=1<<h;if(this.length<=v)return this._expand(v+1),this.words[v]|=E,this;for(var S=E,M=v;S!==0&&M<this.length;M++){var x=this.words[M]|0;x+=S,S=x>>>26,x&=67108863,this.words[M]=x}return S!==0&&(this.words[M]=S,this.length++),this},a.prototype.isZero=function(){return this.length===1&&this.words[0]===0},a.prototype.cmpn=function(u){var h=u<0;if(this.negative!==0&&!h)return-1;if(this.negative===0&&h)return 1;this._strip();var v;if(this.length>1)v=1;else{h&&(u=-u),i(u<=67108863,"Number is too big");var E=this.words[0]|0;v=E===u?0:E<u?-1:1}return this.negative!==0?-v|0:v},a.prototype.cmp=function(u){if(this.negative!==0&&u.negative===0)return-1;if(this.negative===0&&u.negative!==0)return 1;var h=this.ucmp(u);return this.negative!==0?-h|0:h},a.prototype.ucmp=function(u){if(this.length>u.length)return 1;if(this.length<u.length)return-1;for(var h=0,v=this.length-1;v>=0;v--){var E=this.words[v]|0,S=u.words[v]|0;if(E!==S){E<S?h=-1:E>S&&(h=1);break}}return h},a.prototype.gtn=function(u){return this.cmpn(u)===1},a.prototype.gt=function(u){return this.cmp(u)===1},a.prototype.gten=function(u){return this.cmpn(u)>=0},a.prototype.gte=function(u){return this.cmp(u)>=0},a.prototype.ltn=function(u){return this.cmpn(u)===-1},a.prototype.lt=function(u){return this.cmp(u)===-1},a.prototype.lten=function(u){return this.cmpn(u)<=0},a.prototype.lte=function(u){return this.cmp(u)<=0},a.prototype.eqn=function(u){return this.cmpn(u)===0},a.prototype.eq=function(u){return this.cmp(u)===0},a.red=function(u){return new U(u)},a.prototype.toRed=function(u){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),u.convertTo(this)._forceRed(u)},a.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},a.prototype._forceRed=function(u){return this.red=u,this},a.prototype.forceRed=function(u){return i(!this.red,"Already a number in reduction context"),this._forceRed(u)},a.prototype.redAdd=function(u){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,u)},a.prototype.redIAdd=function(u){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,u)},a.prototype.redSub=function(u){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,u)},a.prototype.redISub=function(u){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,u)},a.prototype.redShl=function(u){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,u)},a.prototype.redMul=function(u){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,u),this.red.mul(this,u)},a.prototype.redIMul=function(u){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,u),this.red.imul(this,u)},a.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},a.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},a.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},a.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},a.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},a.prototype.redPow=function(u){return i(this.red&&!u.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,u)};var j={k256:null,p224:null,p192:null,p25519:null};function k(u,h){this.name=u,this.p=new a(h,16),this.n=this.p.bitLength(),this.k=new a(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}k.prototype._tmp=function(){var u=new a(null);return u.words=new Array(Math.ceil(this.n/13)),u},k.prototype.ireduce=function(u){var h=u,v;do this.split(h,this.tmp),h=this.imulK(h),h=h.iadd(this.tmp),v=h.bitLength();while(v>this.n);var E=v<this.n?-1:h.ucmp(this.p);return E===0?(h.words[0]=0,h.length=1):E>0?h.isub(this.p):h.strip!==void 0?h.strip():h._strip(),h},k.prototype.split=function(u,h){u.iushrn(this.n,0,h)},k.prototype.imulK=function(u){return u.imul(this.k)};function _(){k.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(_,k),_.prototype.split=function(u,h){for(var v=4194303,E=Math.min(u.length,9),S=0;S<E;S++)h.words[S]=u.words[S];if(h.length=E,u.length<=9){u.words[0]=0,u.length=1;return}var M=u.words[9];for(h.words[h.length++]=M&v,S=10;S<u.length;S++){var x=u.words[S]|0;u.words[S-10]=(x&v)<<4|M>>>22,M=x}M>>>=22,u.words[S-10]=M,M===0&&u.length>10?u.length-=10:u.length-=9},_.prototype.imulK=function(u){u.words[u.length]=0,u.words[u.length+1]=0,u.length+=2;for(var h=0,v=0;v<u.length;v++){var E=u.words[v]|0;h+=E*977,u.words[v]=h&67108863,h=E*64+(h/67108864|0)}return u.words[u.length-1]===0&&(u.length--,u.words[u.length-1]===0&&u.length--),u};function N(){k.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(N,k);function se(){k.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(se,k);function le(){k.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(le,k),le.prototype.imulK=function(u){for(var h=0,v=0;v<u.length;v++){var E=(u.words[v]|0)*19+h,S=E&67108863;E>>>=26,u.words[v]=S,h=E}return h!==0&&(u.words[u.length++]=h),u},a._prime=function(u){if(j[u])return j[u];var h;if(u==="k256")h=new _;else if(u==="p224")h=new N;else if(u==="p192")h=new se;else if(u==="p25519")h=new le;else throw new Error("Unknown prime "+u);return j[u]=h,h};function U(u){if(typeof u=="string"){var h=a._prime(u);this.m=h.p,this.prime=h}else i(u.gtn(1),"modulus must be greater than 1"),this.m=u,this.prime=null}U.prototype._verify1=function(u){i(u.negative===0,"red works only with positives"),i(u.red,"red works only with red numbers")},U.prototype._verify2=function(u,h){i((u.negative|h.negative)===0,"red works only with positives"),i(u.red&&u.red===h.red,"red works only with red numbers")},U.prototype.imod=function(u){return this.prime?this.prime.ireduce(u)._forceRed(this):(m(u,u.umod(this.m)._forceRed(this)),u)},U.prototype.neg=function(u){return u.isZero()?u.clone():this.m.sub(u)._forceRed(this)},U.prototype.add=function(u,h){this._verify2(u,h);var v=u.add(h);return v.cmp(this.m)>=0&&v.isub(this.m),v._forceRed(this)},U.prototype.iadd=function(u,h){this._verify2(u,h);var v=u.iadd(h);return v.cmp(this.m)>=0&&v.isub(this.m),v},U.prototype.sub=function(u,h){this._verify2(u,h);var v=u.sub(h);return v.cmpn(0)<0&&v.iadd(this.m),v._forceRed(this)},U.prototype.isub=function(u,h){this._verify2(u,h);var v=u.isub(h);return v.cmpn(0)<0&&v.iadd(this.m),v},U.prototype.shl=function(u,h){return this._verify1(u),this.imod(u.ushln(h))},U.prototype.imul=function(u,h){return this._verify2(u,h),this.imod(u.imul(h))},U.prototype.mul=function(u,h){return this._verify2(u,h),this.imod(u.mul(h))},U.prototype.isqr=function(u){return this.imul(u,u.clone())},U.prototype.sqr=function(u){return this.mul(u,u)},U.prototype.sqrt=function(u){if(u.isZero())return u.clone();var h=this.m.andln(3);if(i(h%2===1),h===3){var v=this.m.add(new a(1)).iushrn(2);return this.pow(u,v)}for(var E=this.m.subn(1),S=0;!E.isZero()&&E.andln(1)===0;)S++,E.iushrn(1);i(!E.isZero());var M=new a(1).toRed(this),x=M.redNeg(),p=this.m.subn(1).iushrn(1),b=this.m.bitLength();for(b=new a(2*b*b).toRed(this);this.pow(b,p).cmp(x)!==0;)b.redIAdd(x);for(var R=this.pow(b,E),Z=this.pow(u,E.addn(1).iushrn(1)),ae=this.pow(u,E),I=S;ae.cmp(M)!==0;){for(var ee=ae,L=0;ee.cmp(M)!==0;L++)ee=ee.redSqr();i(L<I);var V=this.pow(R,new a(1).iushln(I-L-1));Z=Z.redMul(V),R=V.redSqr(),ae=ae.redMul(R),I=L}return Z},U.prototype.invm=function(u){var h=u._invmp(this.m);return h.negative!==0?(h.negative=0,this.imod(h).redNeg()):this.imod(h)},U.prototype.pow=function(u,h){if(h.isZero())return new a(1).toRed(this);if(h.cmpn(1)===0)return u.clone();var v=4,E=new Array(1<<v);E[0]=new a(1).toRed(this),E[1]=u;for(var S=2;S<E.length;S++)E[S]=this.mul(E[S-1],u);var M=E[0],x=0,p=0,b=h.bitLength()%26;for(b===0&&(b=26),S=h.length-1;S>=0;S--){for(var R=h.words[S],Z=b-1;Z>=0;Z--){var ae=R>>Z&1;if(M!==E[0]&&(M=this.sqr(M)),ae===0&&x===0){p=0;continue}x<<=1,x|=ae,p++,!(p!==v&&(S!==0||Z!==0))&&(M=this.mul(M,E[x]),p=0,x=0)}b=26}return M},U.prototype.convertTo=function(u){var h=u.umod(this.m);return h===u?h.clone():h},U.prototype.convertFrom=function(u){var h=u.clone();return h.red=null,h},a.mont=function(u){return new y(u)};function y(u){U.call(this,u),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new a(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(y,U),y.prototype.convertTo=function(u){return this.imod(u.ushln(this.shift))},y.prototype.convertFrom=function(u){var h=this.imod(u.mul(this.rinv));return h.red=null,h},y.prototype.imul=function(u,h){if(u.isZero()||h.isZero())return u.words[0]=0,u.length=1,u;var v=u.imul(h),E=v.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),S=v.isub(E).iushrn(this.shift),M=S;return S.cmp(this.m)>=0?M=S.isub(this.m):S.cmpn(0)<0&&(M=S.iadd(this.m)),M._forceRed(this)},y.prototype.mul=function(u,h){if(u.isZero()||h.isZero())return new a(0)._forceRed(this);var v=u.mul(h),E=v.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),S=v.isub(E).iushrn(this.shift),M=S;return S.cmp(this.m)>=0?M=S.isub(this.m):S.cmpn(0)<0&&(M=S.iadd(this.m)),M._forceRed(this)},y.prototype.invm=function(u){var h=this.imod(u._invmp(this.m).mul(this.r2));return h._forceRed(this)}})(r,p3)})(m3);var bt=m3.exports;const y3="bignumber/5.7.0";var wf=bt.BN;const fs=new Mr(y3),Tl={},hg=9007199254740991;function rx(r){return r!=null&&(Gt.isBigNumber(r)||typeof r=="number"&&r%1===0||typeof r=="string"&&!!r.match(/^-?[0-9]+$/)||Ei(r)||typeof r=="bigint"||_o(r))}let lg=!1;class Gt{constructor(e,t){e!==Tl&&fs.throwError("cannot call constructor directly; use BigNumber.from",Mr.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=t,this._isBigNumber=!0,Object.freeze(this)}fromTwos(e){return ai(It(this).fromTwos(e))}toTwos(e){return ai(It(this).toTwos(e))}abs(){return this._hex[0]==="-"?Gt.from(this._hex.substring(1)):this}add(e){return ai(It(this).add(It(e)))}sub(e){return ai(It(this).sub(It(e)))}div(e){return Gt.from(e).isZero()&&Ui("division-by-zero","div"),ai(It(this).div(It(e)))}mul(e){return ai(It(this).mul(It(e)))}mod(e){const t=It(e);return t.isNeg()&&Ui("division-by-zero","mod"),ai(It(this).umod(t))}pow(e){const t=It(e);return t.isNeg()&&Ui("negative-power","pow"),ai(It(this).pow(t))}and(e){const t=It(e);return(this.isNegative()||t.isNeg())&&Ui("unbound-bitwise-result","and"),ai(It(this).and(t))}or(e){const t=It(e);return(this.isNegative()||t.isNeg())&&Ui("unbound-bitwise-result","or"),ai(It(this).or(t))}xor(e){const t=It(e);return(this.isNegative()||t.isNeg())&&Ui("unbound-bitwise-result","xor"),ai(It(this).xor(t))}mask(e){return(this.isNegative()||e<0)&&Ui("negative-width","mask"),ai(It(this).maskn(e))}shl(e){return(this.isNegative()||e<0)&&Ui("negative-width","shl"),ai(It(this).shln(e))}shr(e){return(this.isNegative()||e<0)&&Ui("negative-width","shr"),ai(It(this).shrn(e))}eq(e){return It(this).eq(It(e))}lt(e){return It(this).lt(It(e))}lte(e){return It(this).lte(It(e))}gt(e){return It(this).gt(It(e))}gte(e){return It(this).gte(It(e))}isNegative(){return this._hex[0]==="-"}isZero(){return It(this).isZero()}toNumber(){try{return It(this).toNumber()}catch{Ui("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch{}return fs.throwError("this platform does not support BigInt",Mr.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(arguments[0]===10?lg||(lg=!0,fs.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):arguments[0]===16?fs.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",Mr.errors.UNEXPECTED_ARGUMENT,{}):fs.throwError("BigNumber.toString does not accept parameters",Mr.errors.UNEXPECTED_ARGUMENT,{})),It(this).toString(10)}toHexString(){return this._hex}toJSON(e){return{type:"BigNumber",hex:this.toHexString()}}static from(e){if(e instanceof Gt)return e;if(typeof e=="string")return e.match(/^-?0x[0-9a-f]+$/i)?new Gt(Tl,mc(e)):e.match(/^-?[0-9]+$/)?new Gt(Tl,mc(new wf(e))):fs.throwArgumentError("invalid BigNumber string","value",e);if(typeof e=="number")return e%1&&Ui("underflow","BigNumber.from",e),(e>=hg||e<=-hg)&&Ui("overflow","BigNumber.from",e),Gt.from(String(e));const t=e;if(typeof t=="bigint")return Gt.from(t.toString());if(_o(t))return Gt.from(ui(t));if(t)if(t.toHexString){const i=t.toHexString();if(typeof i=="string")return Gt.from(i)}else{let i=t._hex;if(i==null&&t.type==="BigNumber"&&(i=t.hex),typeof i=="string"&&(Ei(i)||i[0]==="-"&&Ei(i.substring(1))))return Gt.from(i)}return fs.throwArgumentError("invalid BigNumber value","value",e)}static isBigNumber(e){return!!(e&&e._isBigNumber)}}function mc(r){if(typeof r!="string")return mc(r.toString(16));if(r[0]==="-")return r=r.substring(1),r[0]==="-"&&fs.throwArgumentError("invalid hex","value",r),r=mc(r),r==="0x00"?r:"-"+r;if(r.substring(0,2)!=="0x"&&(r="0x"+r),r==="0x")return"0x00";for(r.length%2&&(r="0x0"+r.substring(2));r.length>4&&r.substring(0,4)==="0x00";)r="0x"+r.substring(4);return r}function ai(r){return Gt.from(mc(r))}function It(r){const e=Gt.from(r).toHexString();return e[0]==="-"?new wf("-"+e.substring(3),16):new wf(e.substring(2),16)}function Ui(r,e,t){const i={fault:r,operation:e};return t!=null&&(i.value=t),fs.throwError(r,Mr.errors.NUMERIC_FAULT,i)}function ix(r){return new wf(r,36).toString(16)}const Wr=new Mr(y3),hc={},w3=Gt.from(0),_3=Gt.from(-1);function D3(r,e,t,i){const n={fault:e,operation:t};return i!==void 0&&(n.value=i),Wr.throwError(r,Mr.errors.NUMERIC_FAULT,n)}let lc="0";for(;lc.length<256;)lc+=lc;function n0(r){if(typeof r!="number")try{r=Gt.from(r).toNumber()}catch{}return typeof r=="number"&&r>=0&&r<=256&&!(r%1)?"1"+lc.substring(0,r):Wr.throwArgumentError("invalid decimal size","decimals",r)}function Rl(r,e){e==null&&(e=0);const t=n0(e);r=Gt.from(r);const i=r.lt(w3);i&&(r=r.mul(_3));let n=r.mod(t).toString();for(;n.length<t.length-1;)n="0"+n;n=n.match(/^([0-9]*[1-9]|0)(0*)/)[1];const a=r.div(t).toString();return t.length===1?r=a:r=a+"."+n,i&&(r="-"+r),r}function as(r,e){e==null&&(e=0);const t=n0(e);(typeof r!="string"||!r.match(/^-?[0-9.]+$/))&&Wr.throwArgumentError("invalid decimal value","value",r);const i=r.substring(0,1)==="-";i&&(r=r.substring(1)),r==="."&&Wr.throwArgumentError("missing value","value",r);const n=r.split(".");n.length>2&&Wr.throwArgumentError("too many decimal points","value",r);let a=n[0],c=n[1];for(a||(a="0"),c||(c="0");c[c.length-1]==="0";)c=c.substring(0,c.length-1);for(c.length>t.length-1&&D3("fractional component exceeds decimals","underflow","parseFixed"),c===""&&(c="0");c.length<t.length-1;)c+="0";const f=Gt.from(a),g=Gt.from(c);let d=f.mul(t).add(g);return i&&(d=d.mul(_3)),d}let Nl=class wd{constructor(e,t,i,n){e!==hc&&Wr.throwError("cannot use FixedFormat constructor; use FixedFormat.from",Mr.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.signed=t,this.width=i,this.decimals=n,this.name=(t?"":"u")+"fixed"+String(i)+"x"+String(n),this._multiplier=n0(n),Object.freeze(this)}static from(e){if(e instanceof wd)return e;typeof e=="number"&&(e=`fixed128x${e}`);let t=!0,i=128,n=18;if(typeof e=="string"){if(e!=="fixed")if(e==="ufixed")t=!1;else{const a=e.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);a||Wr.throwArgumentError("invalid fixed format","format",e),t=a[1]!=="u",i=parseInt(a[2]),n=parseInt(a[3])}}else if(e){const a=(c,f,g)=>e[c]==null?g:(typeof e[c]!==f&&Wr.throwArgumentError("invalid fixed format ("+c+" not "+f+")","format."+c,e[c]),e[c]);t=a("signed","boolean",t),i=a("width","number",i),n=a("decimals","number",n)}return i%8&&Wr.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",i),n>80&&Wr.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",n),new wd(hc,t,i,n)}},E3=class Gr{constructor(e,t,i,n){e!==hc&&Wr.throwError("cannot use FixedNumber constructor; use FixedNumber.from",Mr.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=n,this._hex=t,this._value=i,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(e){this.format.name!==e.format.name&&Wr.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)}addUnsafe(e){this._checkFormat(e);const t=as(this._value,this.format.decimals),i=as(e._value,e.format.decimals);return Gr.fromValue(t.add(i),this.format.decimals,this.format)}subUnsafe(e){this._checkFormat(e);const t=as(this._value,this.format.decimals),i=as(e._value,e.format.decimals);return Gr.fromValue(t.sub(i),this.format.decimals,this.format)}mulUnsafe(e){this._checkFormat(e);const t=as(this._value,this.format.decimals),i=as(e._value,e.format.decimals);return Gr.fromValue(t.mul(i).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(e){this._checkFormat(e);const t=as(this._value,this.format.decimals),i=as(e._value,e.format.decimals);return Gr.fromValue(t.mul(this.format._multiplier).div(i),this.format.decimals,this.format)}floor(){const e=this.toString().split(".");e.length===1&&e.push("0");let t=Gr.from(e[0],this.format);const i=!e[1].match(/^(0*)$/);return this.isNegative()&&i&&(t=t.subUnsafe(dg.toFormat(t.format))),t}ceiling(){const e=this.toString().split(".");e.length===1&&e.push("0");let t=Gr.from(e[0],this.format);const i=!e[1].match(/^(0*)$/);return!this.isNegative()&&i&&(t=t.addUnsafe(dg.toFormat(t.format))),t}round(e){e==null&&(e=0);const t=this.toString().split(".");if(t.length===1&&t.push("0"),(e<0||e>80||e%1)&&Wr.throwArgumentError("invalid decimal count","decimals",e),t[1].length<=e)return this;const i=Gr.from("1"+lc.substring(0,e),this.format),n=nx.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&&Wr.throwArgumentError("invalid byte width","width",e);const t=Gt.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString();return $n(t,e/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return Gr.fromString(this._value,e)}static fromValue(e,t,i){return i==null&&t!=null&&!rx(t)&&(i=t,t=null),t==null&&(t=0),i==null&&(i="fixed"),Gr.fromString(Rl(e,t),Nl.from(i))}static fromString(e,t){t==null&&(t="fixed");const i=Nl.from(t),n=as(e,i.decimals);!i.signed&&n.lt(w3)&&D3("unsigned value cannot be negative","overflow","value",e);let a=null;i.signed?a=n.toTwos(i.width).toHexString():(a=n.toHexString(),a=$n(a,i.width/8));const c=Rl(n,i.decimals);return new Gr(hc,a,c,i)}static fromBytes(e,t){t==null&&(t="fixed");const i=Nl.from(t);if(ir(e).length>i.width/8)throw new Error("overflow");let n=Gt.from(e);i.signed&&(n=n.fromTwos(i.width));const a=n.toTwos((i.signed?0:1)+i.width).toHexString(),c=Rl(n,i.decimals);return new Gr(hc,a,c,i)}static from(e,t){if(typeof e=="string")return Gr.fromString(e,t);if(_o(e))return Gr.fromBytes(e,t);try{return Gr.fromValue(e,0,t)}catch(i){if(i.code!==Mr.errors.INVALID_ARGUMENT)throw i}return Wr.throwArgumentError("invalid FixedNumber value","value",e)}static isFixedNumber(e){return!!(e&&e._isFixedNumber)}};const dg=E3.from(1),nx=E3.from("0.5"),sx="strings/5.7.0",ax=new Mr(sx);var _f;(function(r){r.current="",r.NFC="NFC",r.NFD="NFD",r.NFKC="NFKC",r.NFKD="NFKD"})(_f||(_f={}));var pg;(function(r){r.UNEXPECTED_CONTINUE="unexpected continuation byte",r.BAD_PREFIX="bad codepoint prefix",r.OVERRUN="string overrun",r.MISSING_CONTINUE="missing continuation byte",r.OUT_OF_RANGE="out of UTF-8 range",r.UTF16_SURROGATE="UTF-16 surrogate",r.OVERLONG="overlong representation"})(pg||(pg={}));function Bl(r,e=_f.current){e!=_f.current&&(ax.checkNormalize(),r=r.normalize(e));let t=[];for(let i=0;i<r.length;i++){const n=r.charCodeAt(i);if(n<128)t.push(n);else if(n<2048)t.push(n>>6|192),t.push(n&63|128);else if((n&64512)==55296){i++;const a=r.charCodeAt(i);if(i>=r.length||(a&64512)!==56320)throw new Error("invalid utf-8 string");const c=65536+((n&1023)<<10)+(a&1023);t.push(c>>18|240),t.push(c>>12&63|128),t.push(c>>6&63|128),t.push(c&63|128)}else t.push(n>>12|224),t.push(n>>6&63|128),t.push(n&63|128)}return ir(t)}function ox(r){if(r.length%4!==0)throw new Error("bad data");let e=[];for(let t=0;t<r.length;t+=4)e.push(parseInt(r.substring(t,t+4),16));return e}function $l(r,e){e||(e=function(n){return[parseInt(n,16)]});let t=0,i={};return r.split(",").forEach(n=>{let a=n.split(":");t+=parseInt(a[0],16),i[t]=e(a[1])}),i}function gg(r){let e=0;return r.split(",").map(t=>{let i=t.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}})}gg("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(r=>parseInt(r,16)),$l("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"),$l("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"),$l("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",ox),gg("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");function cx(r){r=atob(r);const e=[];for(let t=0;t<r.length;t++)e.push(r.charCodeAt(t));return ir(e)}function A3(r,e){e==null&&(e=1);const t=[],i=t.forEach,n=function(a,c){i.call(a,function(f){c>0&&Array.isArray(f)?n(f,c-1):t.push(f)})};return n(r,e),t}function ux(r){const e={};for(let t=0;t<r.length;t++){const i=r[t];e[i[0]]=i[1]}return e}function fx(r){let e=0;function t(){return r[e++]<<8|r[e++]}let i=t(),n=1,a=[0,1];for(let j=1;j<i;j++)a.push(n+=t());let c=t(),f=e;e+=c;let g=0,d=0;function m(){return g==0&&(d=d<<8|r[e++],g=8),d>>--g&1}const w=31,O=Math.pow(2,w),C=O>>>1,P=C>>1,q=O-1;let K=0;for(let j=0;j<w;j++)K=K<<1|m();let Y=[],z=0,W=O;for(;;){let j=Math.floor(((K-z+1)*n-1)/W),k=0,_=i;for(;_-k>1;){let le=k+_>>>1;j<a[le]?_=le:k=le}if(k==0)break;Y.push(k);let N=z+Math.floor(W*a[k]/n),se=z+Math.floor(W*a[k+1]/n)-1;for(;!((N^se)&C);)K=K<<1&q|m(),N=N<<1&q,se=se<<1&q|1;for(;N&~se&P;)K=K&C|K<<1&q>>>1|m(),N=N<<1^C,se=(se^C)<<1|C|1;z=N,W=1+se-N}let B=i-4;return Y.map(j=>{switch(j-B){case 3:return B+65792+(r[f++]<<16|r[f++]<<8|r[f++]);case 2:return B+256+(r[f++]<<8|r[f++]);case 1:return B+r[f++];default:return j-1}})}function hx(r){let e=0;return()=>r[e++]}function lx(r){return hx(fx(r))}function dx(r){return r&1?~r>>1:r>>1}function px(r,e){let t=Array(r);for(let i=0;i<r;i++)t[i]=1+e();return t}function bg(r,e){let t=Array(r);for(let i=0,n=-1;i<r;i++)t[i]=n+=1+e();return t}function gx(r,e){let t=Array(r);for(let i=0,n=0;i<r;i++)t[i]=n+=dx(e());return t}function Df(r,e){let t=bg(r(),r),i=r(),n=bg(i,r),a=px(i,r);for(let c=0;c<i;c++)for(let f=0;f<a[c];f++)t.push(n[c]+f);return e?t.map(c=>e[c]):t}function bx(r){let e=[];for(;;){let t=r();if(t==0)break;e.push(mx(t,r))}for(;;){let t=r()-1;if(t<0)break;e.push(yx(t,r))}return ux(A3(e))}function vx(r){let e=[];for(;;){let t=r();if(t==0)break;e.push(t)}return e}function x3(r,e,t){let i=Array(r).fill(void 0).map(()=>[]);for(let n=0;n<e;n++)gx(r,t).forEach((a,c)=>i[c].push(a));return i}function mx(r,e){let t=1+e(),i=e(),n=vx(e),a=x3(n.length,1+r,e);return A3(a.map((c,f)=>{const g=c[0],d=c.slice(1);return Array(n[f]).fill(void 0).map((m,w)=>{let O=w*i;return[g+w*t,d.map(C=>C+O)]})}))}function yx(r,e){let t=1+e();return x3(t,1+r,e).map(i=>[i[0],i.slice(1)])}function wx(r){let e=Df(r).sort((i,n)=>i-n);return t();function t(){let i=[];for(;;){let d=Df(r,e);if(d.length==0)break;i.push({set:new Set(d),node:t()})}i.sort((d,m)=>m.set.size-d.set.size);let n=r(),a=n%3;n=n/3|0;let c=!!(n&1);n>>=1;let f=n==1,g=n==2;return{branches:i,valid:a,fe0f:c,save:f,check:g}}}function _x(){return lx(cx("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 Hu=_x();new Set(Df(Hu)),new Set(Df(Hu)),bx(Hu),wx(Hu);const Dx=new Uint8Array(32);Dx.fill(0);const Ex=`Ethereum Signed Message:
`;function S3(r){return typeof r=="string"&&(r=Bl(r)),i0(YA([Bl(Ex),Bl(String(r.length)),r]))}const Ax="address/5.7.0",oc=new Mr(Ax);function vg(r){Ei(r,20)||oc.throwArgumentError("invalid address","address",r),r=r.toLowerCase();const e=r.substring(2).split(""),t=new Uint8Array(40);for(let n=0;n<40;n++)t[n]=e[n].charCodeAt(0);const i=ir(i0(t));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 xx=9007199254740991;function Sx(r){return Math.log10?Math.log10(r):Math.log(r)/Math.LN10}const s0={};for(let r=0;r<10;r++)s0[String(r)]=String(r);for(let r=0;r<26;r++)s0[String.fromCharCode(65+r)]=String(10+r);const mg=Math.floor(Sx(xx));function Mx(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let e=r.split("").map(i=>s0[i]).join("");for(;e.length>=mg;){let i=e.substring(0,mg);e=parseInt(i,10)%97+e.substring(i.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}function Ix(r){let e=null;if(typeof r!="string"&&oc.throwArgumentError("invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/))r.substring(0,2)!=="0x"&&(r="0x"+r),e=vg(r),r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==r&&oc.throwArgumentError("bad address checksum","address",r);else if(r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(r.substring(2,4)!==Mx(r)&&oc.throwArgumentError("bad icap checksum","address",r),e=ix(r.substring(4));e.length<40;)e="0"+e;e=vg("0x"+e)}else oc.throwArgumentError("invalid address","address",r);return e}function Qo(r,e,t){Object.defineProperty(r,e,{enumerable:!0,value:t,writable:!1})}const Cx=new Uint8Array(32);Cx.fill(0),Gt.from(-1);const Px=Gt.from(0),Ox=Gt.from(1);Gt.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),$n(Ox.toHexString(),32),$n(Px.toHexString(),32);var Mn={},Pt={},Rc=M3;function M3(r,e){if(!r)throw new Error(e||"Assertion failed")}M3.equal=function(r,e,t){if(r!=e)throw new Error(t||"Assertion failed: "+r+" != "+e)};var _d={exports:{}};typeof Object.create=="function"?_d.exports=function(r,e){e&&(r.super_=e,r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}))}:_d.exports=function(r,e){if(e){r.super_=e;var t=function(){};t.prototype=e.prototype,r.prototype=new t,r.prototype.constructor=r}};var Tx=Rc,Rx=_d.exports;Pt.inherits=Rx;function Nx(r,e){return(r.charCodeAt(e)&64512)!==55296||e<0||e+1>=r.length?!1:(r.charCodeAt(e+1)&64512)===56320}function Bx(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r=="string")if(e){if(e==="hex")for(r=r.replace(/[^a-z0-9]+/ig,""),r.length%2!==0&&(r="0"+r),n=0;n<r.length;n+=2)t.push(parseInt(r[n]+r[n+1],16))}else for(var i=0,n=0;n<r.length;n++){var a=r.charCodeAt(n);a<128?t[i++]=a:a<2048?(t[i++]=a>>6|192,t[i++]=a&63|128):Nx(r,n)?(a=65536+((a&1023)<<10)+(r.charCodeAt(++n)&1023),t[i++]=a>>18|240,t[i++]=a>>12&63|128,t[i++]=a>>6&63|128,t[i++]=a&63|128):(t[i++]=a>>12|224,t[i++]=a>>6&63|128,t[i++]=a&63|128)}else for(n=0;n<r.length;n++)t[n]=r[n]|0;return t}Pt.toArray=Bx;function $x(r){for(var e="",t=0;t<r.length;t++)e+=C3(r[t].toString(16));return e}Pt.toHex=$x;function I3(r){var e=r>>>24|r>>>8&65280|r<<8&16711680|(r&255)<<24;return e>>>0}Pt.htonl=I3;function Ux(r,e){for(var t="",i=0;i<r.length;i++){var n=r[i];e==="little"&&(n=I3(n)),t+=P3(n.toString(16))}return t}Pt.toHex32=Ux;function C3(r){return r.length===1?"0"+r:r}Pt.zero2=C3;function P3(r){return r.length===7?"0"+r:r.length===6?"00"+r:r.length===5?"000"+r:r.length===4?"0000"+r:r.length===3?"00000"+r:r.length===2?"000000"+r:r.length===1?"0000000"+r:r}Pt.zero8=P3;function qx(r,e,t,i){var n=t-e;Tx(n%4===0);for(var a=new Array(n/4),c=0,f=e;c<a.length;c++,f+=4){var g;i==="big"?g=r[f]<<24|r[f+1]<<16|r[f+2]<<8|r[f+3]:g=r[f+3]<<24|r[f+2]<<16|r[f+1]<<8|r[f],a[c]=g>>>0}return a}Pt.join32=qx;function Lx(r,e){for(var t=new Array(r.length*4),i=0,n=0;i<r.length;i++,n+=4){var a=r[i];e==="big"?(t[n]=a>>>24,t[n+1]=a>>>16&255,t[n+2]=a>>>8&255,t[n+3]=a&255):(t[n+3]=a>>>24,t[n+2]=a>>>16&255,t[n+1]=a>>>8&255,t[n]=a&255)}return t}Pt.split32=Lx;function Fx(r,e){return r>>>e|r<<32-e}Pt.rotr32=Fx;function zx(r,e){return r<<e|r>>>32-e}Pt.rotl32=zx;function jx(r,e){return r+e>>>0}Pt.sum32=jx;function kx(r,e,t){return r+e+t>>>0}Pt.sum32_3=kx;function Hx(r,e,t,i){return r+e+t+i>>>0}Pt.sum32_4=Hx;function Kx(r,e,t,i,n){return r+e+t+i+n>>>0}Pt.sum32_5=Kx;function Vx(r,e,t,i){var n=r[e],a=r[e+1],c=i+a>>>0,f=(c<i?1:0)+t+n;r[e]=f>>>0,r[e+1]=c}Pt.sum64=Vx;function Gx(r,e,t,i){var n=e+i>>>0,a=(n<e?1:0)+r+t;return a>>>0}Pt.sum64_hi=Gx;function Jx(r,e,t,i){var n=e+i;return n>>>0}Pt.sum64_lo=Jx;function Wx(r,e,t,i,n,a,c,f){var g=0,d=e;d=d+i>>>0,g+=d<e?1:0,d=d+a>>>0,g+=d<a?1:0,d=d+f>>>0,g+=d<f?1:0;var m=r+t+n+c+g;return m>>>0}Pt.sum64_4_hi=Wx;function Yx(r,e,t,i,n,a,c,f){var g=e+i+a+f;return g>>>0}Pt.sum64_4_lo=Yx;function Qx(r,e,t,i,n,a,c,f,g,d){var m=0,w=e;w=w+i>>>0,m+=w<e?1:0,w=w+a>>>0,m+=w<a?1:0,w=w+f>>>0,m+=w<f?1:0,w=w+d>>>0,m+=w<d?1:0;var O=r+t+n+c+g+m;return O>>>0}Pt.sum64_5_hi=Qx;function Xx(r,e,t,i,n,a,c,f,g,d){var m=e+i+a+f+d;return m>>>0}Pt.sum64_5_lo=Xx;function Zx(r,e,t){var i=e<<32-t|r>>>t;return i>>>0}Pt.rotr64_hi=Zx;function eS(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Pt.rotr64_lo=eS;function tS(r,e,t){return r>>>t}Pt.shr64_hi=tS;function rS(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Pt.shr64_lo=rS;var Do={},yg=Pt,iS=Rc;function Ku(){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}Do.BlockHash=Ku,Ku.prototype.update=function(r,e){if(r=yg.toArray(r,e),this.pending?this.pending=this.pending.concat(r):this.pending=r,this.pendingTotal+=r.length,this.pending.length>=this._delta8){r=this.pending;var t=r.length%this._delta8;this.pending=r.slice(r.length-t,r.length),this.pending.length===0&&(this.pending=null),r=yg.join32(r,0,r.length-t,this.endian);for(var i=0;i<r.length;i+=this._delta32)this._update(r,i,i+this._delta32)}return this},Ku.prototype.digest=function(r){return this.update(this._pad()),iS(this.pending===null),this._digest(r)},Ku.prototype._pad=function(){var r=this.pendingTotal,e=this._delta8,t=e-(r+this.padLength)%e,i=new Array(t+this.padLength);i[0]=128;for(var n=1;n<t;n++)i[n]=0;if(r<<=3,this.endian==="big"){for(var a=8;a<this.padLength;a++)i[n++]=0;i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=r>>>24&255,i[n++]=r>>>16&255,i[n++]=r>>>8&255,i[n++]=r&255}else for(i[n++]=r&255,i[n++]=r>>>8&255,i[n++]=r>>>16&255,i[n++]=r>>>24&255,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,a=8;a<this.padLength;a++)i[n++]=0;return i};var Qa={},Jn={},nS=Pt,Un=nS.rotr32;function sS(r,e,t,i){if(r===0)return O3(e,t,i);if(r===1||r===3)return R3(e,t,i);if(r===2)return T3(e,t,i)}Jn.ft_1=sS;function O3(r,e,t){return r&e^~r&t}Jn.ch32=O3;function T3(r,e,t){return r&e^r&t^e&t}Jn.maj32=T3;function R3(r,e,t){return r^e^t}Jn.p32=R3;function aS(r){return Un(r,2)^Un(r,13)^Un(r,22)}Jn.s0_256=aS;function oS(r){return Un(r,6)^Un(r,11)^Un(r,25)}Jn.s1_256=oS;function cS(r){return Un(r,7)^Un(r,18)^r>>>3}Jn.g0_256=cS;function uS(r){return Un(r,17)^Un(r,19)^r>>>10}Jn.g1_256=uS;var uo=Pt,fS=Do,hS=Jn,Ul=uo.rotl32,Xo=uo.sum32,lS=uo.sum32_5,dS=hS.ft_1,N3=fS.BlockHash,pS=[1518500249,1859775393,2400959708,3395469782];function On(){if(!(this instanceof On))return new On;N3.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}uo.inherits(On,N3);var gS=On;On.blockSize=512,On.outSize=160,On.hmacStrength=80,On.padLength=64,On.prototype._update=function(r,e){for(var t=this.W,i=0;i<16;i++)t[i]=r[e+i];for(;i<t.length;i++)t[i]=Ul(t[i-3]^t[i-8]^t[i-14]^t[i-16],1);var n=this.h[0],a=this.h[1],c=this.h[2],f=this.h[3],g=this.h[4];for(i=0;i<t.length;i++){var d=~~(i/20),m=lS(Ul(n,5),dS(d,a,c,f),g,t[i],pS[d]);g=f,f=c,c=Ul(a,30),a=n,n=m}this.h[0]=Xo(this.h[0],n),this.h[1]=Xo(this.h[1],a),this.h[2]=Xo(this.h[2],c),this.h[3]=Xo(this.h[3],f),this.h[4]=Xo(this.h[4],g)},On.prototype._digest=function(r){return r==="hex"?uo.toHex32(this.h,"big"):uo.split32(this.h,"big")};var fo=Pt,bS=Do,Eo=Jn,vS=Rc,cn=fo.sum32,mS=fo.sum32_4,yS=fo.sum32_5,wS=Eo.ch32,_S=Eo.maj32,DS=Eo.s0_256,ES=Eo.s1_256,AS=Eo.g0_256,xS=Eo.g1_256,B3=bS.BlockHash,SS=[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 Tn(){if(!(this instanceof Tn))return new Tn;B3.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=SS,this.W=new Array(64)}fo.inherits(Tn,B3);var $3=Tn;Tn.blockSize=512,Tn.outSize=256,Tn.hmacStrength=192,Tn.padLength=64,Tn.prototype._update=function(r,e){for(var t=this.W,i=0;i<16;i++)t[i]=r[e+i];for(;i<t.length;i++)t[i]=mS(xS(t[i-2]),t[i-7],AS(t[i-15]),t[i-16]);var n=this.h[0],a=this.h[1],c=this.h[2],f=this.h[3],g=this.h[4],d=this.h[5],m=this.h[6],w=this.h[7];for(vS(this.k.length===t.length),i=0;i<t.length;i++){var O=yS(w,ES(g),wS(g,d,m),this.k[i],t[i]),C=cn(DS(n),_S(n,a,c));w=m,m=d,d=g,g=cn(f,O),f=c,c=a,a=n,n=cn(O,C)}this.h[0]=cn(this.h[0],n),this.h[1]=cn(this.h[1],a),this.h[2]=cn(this.h[2],c),this.h[3]=cn(this.h[3],f),this.h[4]=cn(this.h[4],g),this.h[5]=cn(this.h[5],d),this.h[6]=cn(this.h[6],m),this.h[7]=cn(this.h[7],w)},Tn.prototype._digest=function(r){return r==="hex"?fo.toHex32(this.h,"big"):fo.split32(this.h,"big")};var Dd=Pt,U3=$3;function ls(){if(!(this instanceof ls))return new ls;U3.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}Dd.inherits(ls,U3);var MS=ls;ls.blockSize=512,ls.outSize=224,ls.hmacStrength=192,ls.padLength=64,ls.prototype._digest=function(r){return r==="hex"?Dd.toHex32(this.h.slice(0,7),"big"):Dd.split32(this.h.slice(0,7),"big")};var di=Pt,IS=Do,CS=Rc,qn=di.rotr64_hi,Ln=di.rotr64_lo,q3=di.shr64_hi,L3=di.shr64_lo,Ts=di.sum64,ql=di.sum64_hi,Ll=di.sum64_lo,PS=di.sum64_4_hi,OS=di.sum64_4_lo,TS=di.sum64_5_hi,RS=di.sum64_5_lo,F3=IS.BlockHash,NS=[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 dn(){if(!(this instanceof dn))return new dn;F3.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=NS,this.W=new Array(160)}di.inherits(dn,F3);var z3=dn;dn.blockSize=1024,dn.outSize=512,dn.hmacStrength=192,dn.padLength=128,dn.prototype._prepareBlock=function(r,e){for(var t=this.W,i=0;i<32;i++)t[i]=r[e+i];for(;i<t.length;i+=2){var n=KS(t[i-4],t[i-3]),a=VS(t[i-4],t[i-3]),c=t[i-14],f=t[i-13],g=kS(t[i-30],t[i-29]),d=HS(t[i-30],t[i-29]),m=t[i-32],w=t[i-31];t[i]=PS(n,a,c,f,g,d,m,w),t[i+1]=OS(n,a,c,f,g,d,m,w)}},dn.prototype._update=function(r,e){this._prepareBlock(r,e);var t=this.W,i=this.h[0],n=this.h[1],a=this.h[2],c=this.h[3],f=this.h[4],g=this.h[5],d=this.h[6],m=this.h[7],w=this.h[8],O=this.h[9],C=this.h[10],P=this.h[11],q=this.h[12],K=this.h[13],Y=this.h[14],z=this.h[15];CS(this.k.length===t.length);for(var W=0;W<t.length;W+=2){var B=Y,j=z,k=zS(w,O),_=jS(w,O),N=BS(w,O,C,P,q),se=$S(w,O,C,P,q,K),le=this.k[W],U=this.k[W+1],y=t[W],u=t[W+1],h=TS(B,j,k,_,N,se,le,U,y,u),v=RS(B,j,k,_,N,se,le,U,y,u);B=LS(i,n),j=FS(i,n),k=US(i,n,a,c,f),_=qS(i,n,a,c,f,g);var E=ql(B,j,k,_),S=Ll(B,j,k,_);Y=q,z=K,q=C,K=P,C=w,P=O,w=ql(d,m,h,v),O=Ll(m,m,h,v),d=f,m=g,f=a,g=c,a=i,c=n,i=ql(h,v,E,S),n=Ll(h,v,E,S)}Ts(this.h,0,i,n),Ts(this.h,2,a,c),Ts(this.h,4,f,g),Ts(this.h,6,d,m),Ts(this.h,8,w,O),Ts(this.h,10,C,P),Ts(this.h,12,q,K),Ts(this.h,14,Y,z)},dn.prototype._digest=function(r){return r==="hex"?di.toHex32(this.h,"big"):di.split32(this.h,"big")};function BS(r,e,t,i,n){var a=r&t^~r&n;return a<0&&(a+=4294967296),a}function $S(r,e,t,i,n,a){var c=e&i^~e&a;return c<0&&(c+=4294967296),c}function US(r,e,t,i,n){var a=r&t^r&n^t&n;return a<0&&(a+=4294967296),a}function qS(r,e,t,i,n,a){var c=e&i^e&a^i&a;return c<0&&(c+=4294967296),c}function LS(r,e){var t=qn(r,e,28),i=qn(e,r,2),n=qn(e,r,7),a=t^i^n;return a<0&&(a+=4294967296),a}function FS(r,e){var t=Ln(r,e,28),i=Ln(e,r,2),n=Ln(e,r,7),a=t^i^n;return a<0&&(a+=4294967296),a}function zS(r,e){var t=qn(r,e,14),i=qn(r,e,18),n=qn(e,r,9),a=t^i^n;return a<0&&(a+=4294967296),a}function jS(r,e){var t=Ln(r,e,14),i=Ln(r,e,18),n=Ln(e,r,9),a=t^i^n;return a<0&&(a+=4294967296),a}function kS(r,e){var t=qn(r,e,1),i=qn(r,e,8),n=q3(r,e,7),a=t^i^n;return a<0&&(a+=4294967296),a}function HS(r,e){var t=Ln(r,e,1),i=Ln(r,e,8),n=L3(r,e,7),a=t^i^n;return a<0&&(a+=4294967296),a}function KS(r,e){var t=qn(r,e,19),i=qn(e,r,29),n=q3(r,e,6),a=t^i^n;return a<0&&(a+=4294967296),a}function VS(r,e){var t=Ln(r,e,19),i=Ln(e,r,29),n=L3(r,e,6),a=t^i^n;return a<0&&(a+=4294967296),a}var Ed=Pt,j3=z3;function ds(){if(!(this instanceof ds))return new ds;j3.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Ed.inherits(ds,j3);var GS=ds;ds.blockSize=1024,ds.outSize=384,ds.hmacStrength=192,ds.padLength=128,ds.prototype._digest=function(r){return r==="hex"?Ed.toHex32(this.h.slice(0,12),"big"):Ed.split32(this.h.slice(0,12),"big")},Qa.sha1=gS,Qa.sha224=MS,Qa.sha256=$3,Qa.sha384=GS,Qa.sha512=z3;var k3={},ba=Pt,JS=Do,Vu=ba.rotl32,wg=ba.sum32,Zo=ba.sum32_3,_g=ba.sum32_4,H3=JS.BlockHash;function In(){if(!(this instanceof In))return new In;H3.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}ba.inherits(In,H3),k3.ripemd160=In,In.blockSize=512,In.outSize=160,In.hmacStrength=192,In.padLength=64,In.prototype._update=function(r,e){for(var t=this.h[0],i=this.h[1],n=this.h[2],a=this.h[3],c=this.h[4],f=t,g=i,d=n,m=a,w=c,O=0;O<80;O++){var C=wg(Vu(_g(t,Dg(O,i,n,a),r[QS[O]+e],WS(O)),ZS[O]),c);t=c,c=a,a=Vu(n,10),n=i,i=C,C=wg(Vu(_g(f,Dg(79-O,g,d,m),r[XS[O]+e],YS(O)),eM[O]),w),f=w,w=m,m=Vu(d,10),d=g,g=C}C=Zo(this.h[1],n,m),this.h[1]=Zo(this.h[2],a,w),this.h[2]=Zo(this.h[3],c,f),this.h[3]=Zo(this.h[4],t,g),this.h[4]=Zo(this.h[0],i,d),this.h[0]=C},In.prototype._digest=function(r){return r==="hex"?ba.toHex32(this.h,"little"):ba.split32(this.h,"little")};function Dg(r,e,t,i){return r<=15?e^t^i:r<=31?e&t|~e&i:r<=47?(e|~t)^i:r<=63?e&i|t&~i:e^(t|~i)}function WS(r){return r<=15?0:r<=31?1518500249:r<=47?1859775393:r<=63?2400959708:2840853838}function YS(r){return r<=15?1352829926:r<=31?1548603684:r<=47?1836072691:r<=63?2053994217:0}var QS=[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],XS=[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],ZS=[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],eM=[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],tM=Pt,rM=Rc;function no(r,e,t){if(!(this instanceof no))return new no(r,e,t);this.Hash=r,this.blockSize=r.blockSize/8,this.outSize=r.outSize/8,this.inner=null,this.outer=null,this._init(tM.toArray(e,t))}var iM=no;no.prototype._init=function(r){r.length>this.blockSize&&(r=new this.Hash().update(r).digest()),rM(r.length<=this.blockSize);for(var e=r.length;e<this.blockSize;e++)r.push(0);for(e=0;e<r.length;e++)r[e]^=54;for(this.inner=new this.Hash().update(r),e=0;e<r.length;e++)r[e]^=106;this.outer=new this.Hash().update(r)},no.prototype.update=function(r,e){return this.inner.update(r,e),this},no.prototype.digest=function(r){return this.outer.update(this.inner.digest()),this.outer.digest(r)},function(r){var e=r;e.utils=Pt,e.common=Do,e.sha=Qa,e.ripemd=k3,e.hmac=iM,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}(Mn);function Ao(r,e,t){return t={path:e,exports:{},require:function(i,n){return nM(i,n??t.path)}},r(t,t.exports),t.exports}function nM(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var a0=K3;function K3(r,e){if(!r)throw new Error(e||"Assertion failed")}K3.equal=function(r,e,t){if(r!=e)throw new Error(t||"Assertion failed: "+r+" != "+e)};var pn=Ao(function(r,e){var t=e;function i(c,f){if(Array.isArray(c))return c.slice();if(!c)return[];var g=[];if(typeof c!="string"){for(var d=0;d<c.length;d++)g[d]=c[d]|0;return g}if(f==="hex"){c=c.replace(/[^a-z0-9]+/ig,""),c.length%2!==0&&(c="0"+c);for(var d=0;d<c.length;d+=2)g.push(parseInt(c[d]+c[d+1],16))}else for(var d=0;d<c.length;d++){var m=c.charCodeAt(d),w=m>>8,O=m&255;w?g.push(w,O):g.push(O)}return g}t.toArray=i;function n(c){return c.length===1?"0"+c:c}t.zero2=n;function a(c){for(var f="",g=0;g<c.length;g++)f+=n(c[g].toString(16));return f}t.toHex=a,t.encode=function(c,f){return f==="hex"?a(c):c}}),Ai=Ao(function(r,e){var t=e;t.assert=a0,t.toArray=pn.toArray,t.zero2=pn.zero2,t.toHex=pn.toHex,t.encode=pn.encode;function i(g,d,m){var w=new Array(Math.max(g.bitLength(),m)+1);w.fill(0);for(var O=1<<d+1,C=g.clone(),P=0;P<w.length;P++){var q,K=C.andln(O-1);C.isOdd()?(K>(O>>1)-1?q=(O>>1)-K:q=K,C.isubn(q)):q=0,w[P]=q,C.iushrn(1)}return w}t.getNAF=i;function n(g,d){var m=[[],[]];g=g.clone(),d=d.clone();for(var w=0,O=0,C;g.cmpn(-w)>0||d.cmpn(-O)>0;){var P=g.andln(3)+w&3,q=d.andln(3)+O&3;P===3&&(P=-1),q===3&&(q=-1);var K;P&1?(C=g.andln(7)+w&7,(C===3||C===5)&&q===2?K=-P:K=P):K=0,m[0].push(K);var Y;q&1?(C=d.andln(7)+O&7,(C===3||C===5)&&P===2?Y=-q:Y=q):Y=0,m[1].push(Y),2*w===K+1&&(w=1-w),2*O===Y+1&&(O=1-O),g.iushrn(1),d.iushrn(1)}return m}t.getJSF=n;function a(g,d,m){var w="_"+d;g.prototype[d]=function(){return this[w]!==void 0?this[w]:this[w]=m.call(this)}}t.cachedProperty=a;function c(g){return typeof g=="string"?t.toArray(g,"hex"):g}t.parseBytes=c;function f(g){return new bt(g,"hex","le")}t.intFromLE=f}),Gu=Ai.getNAF,sM=Ai.getJSF,Ef=Ai.assert;function $s(r,e){this.type=r,this.p=new bt(e.p,16),this.red=e.prime?bt.red(e.prime):bt.mont(this.p),this.zero=new bt(0).toRed(this.red),this.one=new bt(1).toRed(this.red),this.two=new bt(2).toRed(this.red),this.n=e.n&&new bt(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 t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Aa=$s;$s.prototype.point=function(){throw new Error("Not implemented")},$s.prototype.validate=function(){throw new Error("Not implemented")},$s.prototype._fixedNafMul=function(r,e){Ef(r.precomputed);var t=r._getDoubles(),i=Gu(e,1,this._bitLength),n=(1<<t.step+1)-(t.step%2===0?2:1);n/=3;var a=[],c,f;for(c=0;c<i.length;c+=t.step){f=0;for(var g=c+t.step-1;g>=c;g--)f=(f<<1)+i[g];a.push(f)}for(var d=this.jpoint(null,null,null),m=this.jpoint(null,null,null),w=n;w>0;w--){for(c=0;c<a.length;c++)f=a[c],f===w?m=m.mixedAdd(t.points[c]):f===-w&&(m=m.mixedAdd(t.points[c].neg()));d=d.add(m)}return d.toP()},$s.prototype._wnafMul=function(r,e){var t=4,i=r._getNAFPoints(t);t=i.wnd;for(var n=i.points,a=Gu(e,t,this._bitLength),c=this.jpoint(null,null,null),f=a.length-1;f>=0;f--){for(var g=0;f>=0&&a[f]===0;f--)g++;if(f>=0&&g++,c=c.dblp(g),f<0)break;var d=a[f];Ef(d!==0),r.type==="affine"?d>0?c=c.mixedAdd(n[d-1>>1]):c=c.mixedAdd(n[-d-1>>1].neg()):d>0?c=c.add(n[d-1>>1]):c=c.add(n[-d-1>>1].neg())}return r.type==="affine"?c.toP():c},$s.prototype._wnafMulAdd=function(r,e,t,i,n){var a=this._wnafT1,c=this._wnafT2,f=this._wnafT3,g=0,d,m,w;for(d=0;d<i;d++){w=e[d];var O=w._getNAFPoints(r);a[d]=O.wnd,c[d]=O.points}for(d=i-1;d>=1;d-=2){var C=d-1,P=d;if(a[C]!==1||a[P]!==1){f[C]=Gu(t[C],a[C],this._bitLength),f[P]=Gu(t[P],a[P],this._bitLength),g=Math.max(f[C].length,g),g=Math.max(f[P].length,g);continue}var q=[e[C],null,null,e[P]];e[C].y.cmp(e[P].y)===0?(q[1]=e[C].add(e[P]),q[2]=e[C].toJ().mixedAdd(e[P].neg())):e[C].y.cmp(e[P].y.redNeg())===0?(q[1]=e[C].toJ().mixedAdd(e[P]),q[2]=e[C].add(e[P].neg())):(q[1]=e[C].toJ().mixedAdd(e[P]),q[2]=e[C].toJ().mixedAdd(e[P].neg()));var K=[-3,-1,-5,-7,0,7,5,1,3],Y=sM(t[C],t[P]);for(g=Math.max(Y[0].length,g),f[C]=new Array(g),f[P]=new Array(g),m=0;m<g;m++){var z=Y[0][m]|0,W=Y[1][m]|0;f[C][m]=K[(z+1)*3+(W+1)],f[P][m]=0,c[C]=q}}var B=this.jpoint(null,null,null),j=this._wnafT4;for(d=g;d>=0;d--){for(var k=0;d>=0;){var _=!0;for(m=0;m<i;m++)j[m]=f[m][d]|0,j[m]!==0&&(_=!1);if(!_)break;k++,d--}if(d>=0&&k++,B=B.dblp(k),d<0)break;for(m=0;m<i;m++){var N=j[m];N!==0&&(N>0?w=c[m][N-1>>1]:N<0&&(w=c[m][-N-1>>1].neg()),w.type==="affine"?B=B.mixedAdd(w):B=B.add(w))}}for(d=0;d<i;d++)c[d]=null;return n?B:B.toP()};function qi(r,e){this.curve=r,this.type=e,this.precomputed=null}$s.BasePoint=qi,qi.prototype.eq=function(){throw new Error("Not implemented")},qi.prototype.validate=function(){return this.curve.validate(this)},$s.prototype.decodePoint=function(r,e){r=Ai.toArray(r,e);var t=this.p.byteLength();if((r[0]===4||r[0]===6||r[0]===7)&&r.length-1===2*t){r[0]===6?Ef(r[r.length-1]%2===0):r[0]===7&&Ef(r[r.length-1]%2===1);var i=this.point(r.slice(1,1+t),r.slice(1+t,1+2*t));return i}else if((r[0]===2||r[0]===3)&&r.length-1===t)return this.pointFromX(r.slice(1,1+t),r[0]===3);throw new Error("Unknown point format")},qi.prototype.encodeCompressed=function(r){return this.encode(r,!0)},qi.prototype._encode=function(r){var e=this.curve.p.byteLength(),t=this.getX().toArray("be",e);return r?[this.getY().isEven()?2:3].concat(t):[4].concat(t,this.getY().toArray("be",e))},qi.prototype.encode=function(r,e){return Ai.encode(this._encode(e),r)},qi.prototype.precompute=function(r){if(this.precomputed)return this;var e={doubles:null,naf:null,beta:null};return e.naf=this._getNAFPoints(8),e.doubles=this._getDoubles(4,r),e.beta=this._getBeta(),this.precomputed=e,this},qi.prototype._hasDoubles=function(r){if(!this.precomputed)return!1;var e=this.precomputed.doubles;return e?e.points.length>=Math.ceil((r.bitLength()+1)/e.step):!1},qi.prototype._getDoubles=function(r,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var t=[this],i=this,n=0;n<e;n+=r){for(var a=0;a<r;a++)i=i.dbl();t.push(i)}return{step:r,points:t}},qi.prototype._getNAFPoints=function(r){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var e=[this],t=(1<<r)-1,i=t===1?null:this.dbl(),n=1;n<t;n++)e[n]=e[n-1].add(i);return{wnd:r,points:e}},qi.prototype._getBeta=function(){return null},qi.prototype.dblp=function(r){for(var e=this,t=0;t<r;t++)e=e.dbl();return e};var o0=Ao(function(r){typeof Object.create=="function"?r.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:r.exports=function(e,t){if(t){e.super_=t;var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e}}}),aM=Ai.assert;function ki(r){Aa.call(this,"short",r),this.a=new bt(r.a,16).toRed(this.red),this.b=new bt(r.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(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}o0(ki,Aa);var oM=ki;ki.prototype._getEndomorphism=function(r){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var e,t;if(r.beta)e=new bt(r.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(r.lambda)t=new bt(r.lambda,16);else{var n=this._getEndoRoots(this.n);this.g.mul(n[0]).x.cmp(this.g.x.redMul(e))===0?t=n[0]:(t=n[1],aM(this.g.mul(t).x.cmp(this.g.x.redMul(e))===0))}var a;return r.basis?a=r.basis.map(function(c){return{a:new bt(c.a,16),b:new bt(c.b,16)}}):a=this._getEndoBasis(t),{beta:e,lambda:t,basis:a}}},ki.prototype._getEndoRoots=function(r){var e=r===this.p?this.red:bt.mont(r),t=new bt(2).toRed(e).redInvm(),i=t.redNeg(),n=new bt(3).toRed(e).redNeg().redSqrt().redMul(t),a=i.redAdd(n).fromRed(),c=i.redSub(n).fromRed();return[a,c]},ki.prototype._getEndoBasis=function(r){for(var e=this.n.ushrn(Math.floor(this.n.bitLength()/2)),t=r,i=this.n.clone(),n=new bt(1),a=new bt(0),c=new bt(0),f=new bt(1),g,d,m,w,O,C,P,q=0,K,Y;t.cmpn(0)!==0;){var z=i.div(t);K=i.sub(z.mul(t)),Y=c.sub(z.mul(n));var W=f.sub(z.mul(a));if(!m&&K.cmp(e)<0)g=P.neg(),d=n,m=K.neg(),w=Y;else if(m&&++q===2)break;P=K,i=t,t=K,c=n,n=Y,f=a,a=W}O=K.neg(),C=Y;var B=m.sqr().add(w.sqr()),j=O.sqr().add(C.sqr());return j.cmp(B)>=0&&(O=g,C=d),m.negative&&(m=m.neg(),w=w.neg()),O.negative&&(O=O.neg(),C=C.neg()),[{a:m,b:w},{a:O,b:C}]},ki.prototype._endoSplit=function(r){var e=this.endo.basis,t=e[0],i=e[1],n=i.b.mul(r).divRound(this.n),a=t.b.neg().mul(r).divRound(this.n),c=n.mul(t.a),f=a.mul(i.a),g=n.mul(t.b),d=a.mul(i.b),m=r.sub(c).sub(f),w=g.add(d).neg();return{k1:m,k2:w}},ki.prototype.pointFromX=function(r,e){r=new bt(r,16),r.red||(r=r.toRed(this.red));var t=r.redSqr().redMul(r).redIAdd(r.redMul(this.a)).redIAdd(this.b),i=t.redSqrt();if(i.redSqr().redSub(t).cmp(this.zero)!==0)throw new Error("invalid point");var n=i.fromRed().isOdd();return(e&&!n||!e&&n)&&(i=i.redNeg()),this.point(r,i)},ki.prototype.validate=function(r){if(r.inf)return!0;var e=r.x,t=r.y,i=this.a.redMul(e),n=e.redSqr().redMul(e).redIAdd(i).redIAdd(this.b);return t.redSqr().redISub(n).cmpn(0)===0},ki.prototype._endoWnafMulAdd=function(r,e,t){for(var i=this._endoWnafT1,n=this._endoWnafT2,a=0;a<r.length;a++){var c=this._endoSplit(e[a]),f=r[a],g=f._getBeta();c.k1.negative&&(c.k1.ineg(),f=f.neg(!0)),c.k2.negative&&(c.k2.ineg(),g=g.neg(!0)),i[a*2]=f,i[a*2+1]=g,n[a*2]=c.k1,n[a*2+1]=c.k2}for(var d=this._wnafMulAdd(1,i,n,a*2,t),m=0;m<a*2;m++)i[m]=null,n[m]=null;return d};function yr(r,e,t,i){Aa.BasePoint.call(this,r,"affine"),e===null&&t===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new bt(e,16),this.y=new bt(t,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)}o0(yr,Aa.BasePoint),ki.prototype.point=function(r,e,t){return new yr(this,r,e,t)},ki.prototype.pointFromJSON=function(r,e){return yr.fromJSON(this,r,e)},yr.prototype._getBeta=function(){if(this.curve.endo){var r=this.precomputed;if(r&&r.beta)return r.beta;var e=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(r){var t=this.curve,i=function(n){return t.point(n.x.redMul(t.endo.beta),n.y)};r.beta=e,e.precomputed={beta:null,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}},yr.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]},yr.fromJSON=function(r,e,t){typeof e=="string"&&(e=JSON.parse(e));var i=r.point(e[0],e[1],t);if(!e[2])return i;function n(c){return r.point(c[0],c[1],t)}var a=e[2];return i.precomputed={beta:null,doubles:a.doubles&&{step:a.doubles.step,points:[i].concat(a.doubles.points.map(n))},naf:a.naf&&{wnd:a.naf.wnd,points:[i].concat(a.naf.points.map(n))}},i},yr.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)+">"},yr.prototype.isInfinity=function(){return this.inf},yr.prototype.add=function(r){if(this.inf)return r;if(r.inf)return this;if(this.eq(r))return this.dbl();if(this.neg().eq(r))return this.curve.point(null,null);if(this.x.cmp(r.x)===0)return this.curve.point(null,null);var e=this.y.redSub(r.y);e.cmpn(0)!==0&&(e=e.redMul(this.x.redSub(r.x).redInvm()));var t=e.redSqr().redISub(this.x).redISub(r.x),i=e.redMul(this.x.redSub(t)).redISub(this.y);return this.curve.point(t,i)},yr.prototype.dbl=function(){if(this.inf)return this;var r=this.y.redAdd(this.y);if(r.cmpn(0)===0)return this.curve.point(null,null);var e=this.curve.a,t=this.x.redSqr(),i=r.redInvm(),n=t.redAdd(t).redIAdd(t).redIAdd(e).redMul(i),a=n.redSqr().redISub(this.x.redAdd(this.x)),c=n.redMul(this.x.redSub(a)).redISub(this.y);return this.curve.point(a,c)},yr.prototype.getX=function(){return this.x.fromRed()},yr.prototype.getY=function(){return this.y.fromRed()},yr.prototype.mul=function(r){return r=new bt(r,16),this.isInfinity()?this:this._hasDoubles(r)?this.curve._fixedNafMul(this,r):this.curve.endo?this.curve._endoWnafMulAdd([this],[r]):this.curve._wnafMul(this,r)},yr.prototype.mulAdd=function(r,e,t){var i=[this,e],n=[r,t];return this.curve.endo?this.curve._endoWnafMulAdd(i,n):this.curve._wnafMulAdd(1,i,n,2)},yr.prototype.jmulAdd=function(r,e,t){var i=[this,e],n=[r,t];return this.curve.endo?this.curve._endoWnafMulAdd(i,n,!0):this.curve._wnafMulAdd(1,i,n,2,!0)},yr.prototype.eq=function(r){return this===r||this.inf===r.inf&&(this.inf||this.x.cmp(r.x)===0&&this.y.cmp(r.y)===0)},yr.prototype.neg=function(r){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(r&&this.precomputed){var t=this.precomputed,i=function(n){return n.neg()};e.precomputed={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},yr.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var r=this.curve.jpoint(this.x,this.y,this.curve.one);return r};function Sr(r,e,t,i){Aa.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new bt(0)):(this.x=new bt(e,16),this.y=new bt(t,16),this.z=new bt(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}o0(Sr,Aa.BasePoint),ki.prototype.jpoint=function(r,e,t){return new Sr(this,r,e,t)},Sr.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var r=this.z.redInvm(),e=r.redSqr(),t=this.x.redMul(e),i=this.y.redMul(e).redMul(r);return this.curve.point(t,i)},Sr.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Sr.prototype.add=function(r){if(this.isInfinity())return r;if(r.isInfinity())return this;var e=r.z.redSqr(),t=this.z.redSqr(),i=this.x.redMul(e),n=r.x.redMul(t),a=this.y.redMul(e.redMul(r.z)),c=r.y.redMul(t.redMul(this.z)),f=i.redSub(n),g=a.redSub(c);if(f.cmpn(0)===0)return g.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var d=f.redSqr(),m=d.redMul(f),w=i.redMul(d),O=g.redSqr().redIAdd(m).redISub(w).redISub(w),C=g.redMul(w.redISub(O)).redISub(a.redMul(m)),P=this.z.redMul(r.z).redMul(f);return this.curve.jpoint(O,C,P)},Sr.prototype.mixedAdd=function(r){if(this.isInfinity())return r.toJ();if(r.isInfinity())return this;var e=this.z.redSqr(),t=this.x,i=r.x.redMul(e),n=this.y,a=r.y.redMul(e).redMul(this.z),c=t.redSub(i),f=n.redSub(a);if(c.cmpn(0)===0)return f.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var g=c.redSqr(),d=g.redMul(c),m=t.redMul(g),w=f.redSqr().redIAdd(d).redISub(m).redISub(m),O=f.redMul(m.redISub(w)).redISub(n.redMul(d)),C=this.z.redMul(c);return this.curve.jpoint(w,O,C)},Sr.prototype.dblp=function(r){if(r===0)return this;if(this.isInfinity())return this;if(!r)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var t=this;for(e=0;e<r;e++)t=t.dbl();return t}var i=this.curve.a,n=this.curve.tinv,a=this.x,c=this.y,f=this.z,g=f.redSqr().redSqr(),d=c.redAdd(c);for(e=0;e<r;e++){var m=a.redSqr(),w=d.redSqr(),O=w.redSqr(),C=m.redAdd(m).redIAdd(m).redIAdd(i.redMul(g)),P=a.redMul(w),q=C.redSqr().redISub(P.redAdd(P)),K=P.redISub(q),Y=C.redMul(K);Y=Y.redIAdd(Y).redISub(O);var z=d.redMul(f);e+1<r&&(g=g.redMul(O)),a=q,f=z,d=Y}return this.curve.jpoint(a,d.redMul(n),f)},Sr.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},Sr.prototype._zeroDbl=function(){var r,e,t;if(this.zOne){var i=this.x.redSqr(),n=this.y.redSqr(),a=n.redSqr(),c=this.x.redAdd(n).redSqr().redISub(i).redISub(a);c=c.redIAdd(c);var f=i.redAdd(i).redIAdd(i),g=f.redSqr().redISub(c).redISub(c),d=a.redIAdd(a);d=d.redIAdd(d),d=d.redIAdd(d),r=g,e=f.redMul(c.redISub(g)).redISub(d),t=this.y.redAdd(this.y)}else{var m=this.x.redSqr(),w=this.y.redSqr(),O=w.redSqr(),C=this.x.redAdd(w).redSqr().redISub(m).redISub(O);C=C.redIAdd(C);var P=m.redAdd(m).redIAdd(m),q=P.redSqr(),K=O.redIAdd(O);K=K.redIAdd(K),K=K.redIAdd(K),r=q.redISub(C).redISub(C),e=P.redMul(C.redISub(r)).redISub(K),t=this.y.redMul(this.z),t=t.redIAdd(t)}return this.curve.jpoint(r,e,t)},Sr.prototype._threeDbl=function(){var r,e,t;if(this.zOne){var i=this.x.redSqr(),n=this.y.redSqr(),a=n.redSqr(),c=this.x.redAdd(n).redSqr().redISub(i).redISub(a);c=c.redIAdd(c);var f=i.redAdd(i).redIAdd(i).redIAdd(this.curve.a),g=f.redSqr().redISub(c).redISub(c);r=g;var d=a.redIAdd(a);d=d.redIAdd(d),d=d.redIAdd(d),e=f.redMul(c.redISub(g)).redISub(d),t=this.y.redAdd(this.y)}else{var m=this.z.redSqr(),w=this.y.redSqr(),O=this.x.redMul(w),C=this.x.redSub(m).redMul(this.x.redAdd(m));C=C.redAdd(C).redIAdd(C);var P=O.redIAdd(O);P=P.redIAdd(P);var q=P.redAdd(P);r=C.redSqr().redISub(q),t=this.y.redAdd(this.z).redSqr().redISub(w).redISub(m);var K=w.redSqr();K=K.redIAdd(K),K=K.redIAdd(K),K=K.redIAdd(K),e=C.redMul(P.redISub(r)).redISub(K)}return this.curve.jpoint(r,e,t)},Sr.prototype._dbl=function(){var r=this.curve.a,e=this.x,t=this.y,i=this.z,n=i.redSqr().redSqr(),a=e.redSqr(),c=t.redSqr(),f=a.redAdd(a).redIAdd(a).redIAdd(r.redMul(n)),g=e.redAdd(e);g=g.redIAdd(g);var d=g.redMul(c),m=f.redSqr().redISub(d.redAdd(d)),w=d.redISub(m),O=c.redSqr();O=O.redIAdd(O),O=O.redIAdd(O),O=O.redIAdd(O);var C=f.redMul(w).redISub(O),P=t.redAdd(t).redMul(i);return this.curve.jpoint(m,C,P)},Sr.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var r=this.x.redSqr(),e=this.y.redSqr(),t=this.z.redSqr(),i=e.redSqr(),n=r.redAdd(r).redIAdd(r),a=n.redSqr(),c=this.x.redAdd(e).redSqr().redISub(r).redISub(i);c=c.redIAdd(c),c=c.redAdd(c).redIAdd(c),c=c.redISub(a);var f=c.redSqr(),g=i.redIAdd(i);g=g.redIAdd(g),g=g.redIAdd(g),g=g.redIAdd(g);var d=n.redIAdd(c).redSqr().redISub(a).redISub(f).redISub(g),m=e.redMul(d);m=m.redIAdd(m),m=m.redIAdd(m);var w=this.x.redMul(f).redISub(m);w=w.redIAdd(w),w=w.redIAdd(w);var O=this.y.redMul(d.redMul(g.redISub(d)).redISub(c.redMul(f)));O=O.redIAdd(O),O=O.redIAdd(O),O=O.redIAdd(O);var C=this.z.redAdd(c).redSqr().redISub(t).redISub(f);return this.curve.jpoint(w,O,C)},Sr.prototype.mul=function(r,e){return r=new bt(r,e),this.curve._wnafMul(this,r)},Sr.prototype.eq=function(r){if(r.type==="affine")return this.eq(r.toJ());if(this===r)return!0;var e=this.z.redSqr(),t=r.z.redSqr();if(this.x.redMul(t).redISub(r.x.redMul(e)).cmpn(0)!==0)return!1;var i=e.redMul(this.z),n=t.redMul(r.z);return this.y.redMul(n).redISub(r.y.redMul(i)).cmpn(0)===0},Sr.prototype.eqXToP=function(r){var e=this.z.redSqr(),t=r.toRed(this.curve.red).redMul(e);if(this.x.cmp(t)===0)return!0;for(var i=r.clone(),n=this.curve.redN.redMul(e);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),this.x.cmp(t)===0)return!0}},Sr.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)+">"},Sr.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var sf=Ao(function(r,e){var t=e;t.base=Aa,t.short=oM,t.mont=null,t.edwards=null}),af=Ao(function(r,e){var t=e,i=Ai.assert;function n(f){f.type==="short"?this.curve=new sf.short(f):f.type==="edwards"?this.curve=new sf.edwards(f):this.curve=new sf.mont(f),this.g=this.curve.g,this.n=this.curve.n,this.hash=f.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}t.PresetCurve=n;function a(f,g){Object.defineProperty(t,f,{configurable:!0,enumerable:!0,get:function(){var d=new n(g);return Object.defineProperty(t,f,{configurable:!0,enumerable:!0,value:d}),d}})}a("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:Mn.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),a("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:Mn.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),a("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:Mn.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),a("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:Mn.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),a("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:Mn.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),a("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Mn.sha256,gRed:!1,g:["9"]}),a("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Mn.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var c;try{c=null.crash()}catch{c=void 0}a("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:Mn.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",c]})});function Us(r){if(!(this instanceof Us))return new Us(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=pn.toArray(r.entropy,r.entropyEnc||"hex"),t=pn.toArray(r.nonce,r.nonceEnc||"hex"),i=pn.toArray(r.pers,r.persEnc||"hex");a0(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}var Eg=Us;Us.prototype._init=function(r,e,t){var i=r.concat(e).concat(t);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},Us.prototype._hmac=function(){return new Mn.hmac(this.hash,this.K)},Us.prototype._update=function(r){var e=this._hmac().update(this.V).update([0]);r&&(e=e.update(r)),this.K=e.digest(),this.V=this._hmac().update(this.V).digest(),r&&(this.K=this._hmac().update(this.V).update([1]).update(r).digest(),this.V=this._hmac().update(this.V).digest())},Us.prototype.reseed=function(r,e,t,i){typeof e!="string"&&(i=t,t=e,e=null),r=pn.toArray(r,e),t=pn.toArray(t,i),a0(r.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(r.concat(t||[])),this._reseed=1},Us.prototype.generate=function(r,e,t,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof e!="string"&&(i=t,t=e,e=null),t&&(t=pn.toArray(t,i||"hex"),this._update(t));for(var n=[];n.length<r;)this.V=this._hmac().update(this.V).digest(),n=n.concat(this.V);var a=n.slice(0,r);return this._update(t),this._reseed++,pn.encode(a,e)};var Fl=Ai.assert;function zr(r,e){this.ec=r,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var zl=zr;zr.fromPublic=function(r,e,t){return e instanceof zr?e:new zr(r,{pub:e,pubEnc:t})},zr.fromPrivate=function(r,e,t){return e instanceof zr?e:new zr(r,{priv:e,privEnc:t})},zr.prototype.validate=function(){var r=this.getPublic();return r.isInfinity()?{result:!1,reason:"Invalid public key"}:r.validate()?r.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"}},zr.prototype.getPublic=function(r,e){return typeof r=="string"&&(e=r,r=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,r):this.pub},zr.prototype.getPrivate=function(r){return r==="hex"?this.priv.toString(16,2):this.priv},zr.prototype._importPrivate=function(r,e){this.priv=new bt(r,e||16),this.priv=this.priv.umod(this.ec.curve.n)},zr.prototype._importPublic=function(r,e){if(r.x||r.y){this.ec.curve.type==="mont"?Fl(r.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&Fl(r.x&&r.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(r.x,r.y);return}this.pub=this.ec.curve.decodePoint(r,e)},zr.prototype.derive=function(r){return r.validate()||Fl(r.validate(),"public point not validated"),r.mul(this.priv).getX()},zr.prototype.sign=function(r,e,t){return this.ec.sign(r,this,e,t)},zr.prototype.verify=function(r,e){return this.ec.verify(r,e,this)},zr.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var cM=Ai.assert;function Qf(r,e){if(r instanceof Qf)return r;this._importDER(r,e)||(cM(r.r&&r.s,"Signature without r or s"),this.r=new bt(r.r,16),this.s=new bt(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}var Ju=Qf;function uM(){this.place=0}function jl(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4)return!1;for(var n=0,a=0,c=e.place;a<i;a++,c++)n<<=8,n|=r[c],n>>>=0;return n<=127?!1:(e.place=c,n)}function Ag(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e<t;)e++;return e===0?r:r.slice(e)}Qf.prototype._importDER=function(r,e){r=Ai.toArray(r,e);var t=new uM;if(r[t.place++]!==48)return!1;var i=jl(r,t);if(i===!1||i+t.place!==r.length||r[t.place++]!==2)return!1;var n=jl(r,t);if(n===!1)return!1;var a=r.slice(t.place,n+t.place);if(t.place+=n,r[t.place++]!==2)return!1;var c=jl(r,t);if(c===!1||r.length!==c+t.place)return!1;var f=r.slice(t.place,c+t.place);if(a[0]===0)if(a[1]&128)a=a.slice(1);else return!1;if(f[0]===0)if(f[1]&128)f=f.slice(1);else return!1;return this.r=new bt(a),this.s=new bt(f),this.recoveryParam=null,!0};function kl(r,e){if(e<128){r.push(e);return}var t=1+(Math.log(e)/Math.LN2>>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}Qf.prototype.toDER=function(r){var e=this.r.toArray(),t=this.s.toArray();for(e[0]&128&&(e=[0].concat(e)),t[0]&128&&(t=[0].concat(t)),e=Ag(e),t=Ag(t);!t[0]&&!(t[1]&128);)t=t.slice(1);var i=[2];kl(i,e.length),i=i.concat(e),i.push(2),kl(i,t.length);var n=i.concat(t),a=[48];return kl(a,n.length),a=a.concat(n),Ai.encode(a,r)};var fM=function(){throw new Error("unsupported")},V3=Ai.assert;function zi(r){if(!(this instanceof zi))return new zi(r);typeof r=="string"&&(V3(Object.prototype.hasOwnProperty.call(af,r),"Unknown curve "+r),r=af[r]),r instanceof af.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}var hM=zi;zi.prototype.keyPair=function(r){return new zl(this,r)},zi.prototype.keyFromPrivate=function(r,e){return zl.fromPrivate(this,r,e)},zi.prototype.keyFromPublic=function(r,e){return zl.fromPublic(this,r,e)},zi.prototype.genKeyPair=function(r){r||(r={});for(var e=new Eg({hash:this.hash,pers:r.pers,persEnc:r.persEnc||"utf8",entropy:r.entropy||fM(this.hash.hmacStrength),entropyEnc:r.entropy&&r.entropyEnc||"utf8",nonce:this.n.toArray()}),t=this.n.byteLength(),i=this.n.sub(new bt(2));;){var n=new bt(e.generate(t));if(!(n.cmp(i)>0))return n.iaddn(1),this.keyFromPrivate(n)}},zi.prototype._truncateToN=function(r,e){var t=r.byteLength()*8-this.n.bitLength();return t>0&&(r=r.ushrn(t)),!e&&r.cmp(this.n)>=0?r.sub(this.n):r},zi.prototype.sign=function(r,e,t,i){typeof t=="object"&&(i=t,t=null),i||(i={}),e=this.keyFromPrivate(e,t),r=this._truncateToN(new bt(r,16));for(var n=this.n.byteLength(),a=e.getPrivate().toArray("be",n),c=r.toArray("be",n),f=new Eg({hash:this.hash,entropy:a,nonce:c,pers:i.pers,persEnc:i.persEnc||"utf8"}),g=this.n.sub(new bt(1)),d=0;;d++){var m=i.k?i.k(d):new bt(f.generate(this.n.byteLength()));if(m=this._truncateToN(m,!0),!(m.cmpn(1)<=0||m.cmp(g)>=0)){var w=this.g.mul(m);if(!w.isInfinity()){var O=w.getX(),C=O.umod(this.n);if(C.cmpn(0)!==0){var P=m.invm(this.n).mul(C.mul(e.getPrivate()).iadd(r));if(P=P.umod(this.n),P.cmpn(0)!==0){var q=(w.getY().isOdd()?1:0)|(O.cmp(C)!==0?2:0);return i.canonical&&P.cmp(this.nh)>0&&(P=this.n.sub(P),q^=1),new Ju({r:C,s:P,recoveryParam:q})}}}}}},zi.prototype.verify=function(r,e,t,i){r=this._truncateToN(new bt(r,16)),t=this.keyFromPublic(t,i),e=new Ju(e,"hex");var n=e.r,a=e.s;if(n.cmpn(1)<0||n.cmp(this.n)>=0||a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var c=a.invm(this.n),f=c.mul(r).umod(this.n),g=c.mul(n).umod(this.n),d;return this.curve._maxwellTrick?(d=this.g.jmulAdd(f,t.getPublic(),g),d.isInfinity()?!1:d.eqXToP(n)):(d=this.g.mulAdd(f,t.getPublic(),g),d.isInfinity()?!1:d.getX().umod(this.n).cmp(n)===0)},zi.prototype.recoverPubKey=function(r,e,t,i){V3((3&t)===t,"The recovery param is more than two bits"),e=new Ju(e,i);var n=this.n,a=new bt(r),c=e.r,f=e.s,g=t&1,d=t>>1;if(c.cmp(this.curve.p.umod(this.curve.n))>=0&&d)throw new Error("Unable to find sencond key candinate");d?c=this.curve.pointFromX(c.add(this.curve.n),g):c=this.curve.pointFromX(c,g);var m=e.r.invm(n),w=n.sub(a).mul(m).umod(n),O=f.mul(m).umod(n);return this.g.mulAdd(w,c,O)},zi.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new Ju(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var a;try{a=this.recoverPubKey(r,e,n)}catch{continue}if(a.eq(t))return n}throw new Error("Unable to find valid recovery factor")};var lM=Ao(function(r,e){var t=e;t.version="6.5.4",t.utils=Ai,t.rand=function(){throw new Error("unsupported")},t.curve=sf,t.curves=af,t.ec=hM,t.eddsa=null}),dM=lM.ec;const pM="signing-key/5.7.0",Ad=new Mr(pM);let Hl=null;function Ns(){return Hl||(Hl=new dM("secp256k1")),Hl}class gM{constructor(e){Qo(this,"curve","secp256k1"),Qo(this,"privateKey",ui(e)),XA(this.privateKey)!==32&&Ad.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const t=Ns().keyFromPrivate(ir(this.privateKey));Qo(this,"publicKey","0x"+t.getPublic(!1,"hex")),Qo(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),Qo(this,"_isSigningKey",!0)}_addPoint(e){const t=Ns().keyFromPublic(ir(this.publicKey)),i=Ns().keyFromPublic(ir(e));return"0x"+t.pub.add(i.pub).encodeCompressed("hex")}signDigest(e){const t=Ns().keyFromPrivate(ir(this.privateKey)),i=ir(e);i.length!==32&&Ad.throwArgumentError("bad digest length","digest",e);const n=t.sign(i,{canonical:!0});return v3({recoveryParam:n.recoveryParam,r:$n("0x"+n.r.toString(16),32),s:$n("0x"+n.s.toString(16),32)})}computeSharedSecret(e){const t=Ns().keyFromPrivate(ir(this.privateKey)),i=Ns().keyFromPublic(ir(G3(e)));return $n("0x"+t.derive(i.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}}function bM(r,e){const t=v3(e),i={r:ir(t.r),s:ir(t.s)};return"0x"+Ns().recoverPubKey(ir(r),i,t.recoveryParam).encode("hex",!1)}function G3(r,e){const t=ir(r);return t.length===32?new gM(t).publicKey:t.length===33?"0x"+Ns().keyFromPublic(t).getPublic(!1,"hex"):t.length===65?ui(t):Ad.throwArgumentError("invalid public or private key","key","[REDACTED]")}var xg;(function(r){r[r.legacy=0]="legacy",r[r.eip2930=1]="eip2930",r[r.eip1559=2]="eip1559"})(xg||(xg={}));function vM(r){const e=G3(r);return Ix(fg(i0(fg(e,1)),12))}function mM(r,e){return vM(bM(ir(r),e))}const yM="https://rpc.walletconnect.org/v1";async function wM(r,e,t,i,n,a){switch(t.t){case"eip191":return _M(r,e,t.s);case"eip1271":return await DM(r,e,t.s,i,n,a);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${t.t}`)}}function _M(r,e,t){return mM(S3(e),t).toLowerCase()===r.toLowerCase()}async function DM(r,e,t,i,n,a){try{const c="0x1626ba7e",f="0000000000000000000000000000000000000000000000000000000000000040",g="0000000000000000000000000000000000000000000000000000000000000041",d=t.substring(2),m=S3(e).substring(2),w=c+m+f+g+d,O=await fetch(`${a||yM}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:EM(),jsonrpc:"2.0",method:"eth_call",params:[{to:r,data:w},"latest"]})}),{result:C}=await O.json();return C?C.slice(0,c.length).toLowerCase()===c.toLowerCase():!1}catch(c){return console.error("isValidEip1271Signature: ",c),!1}}function EM(){return Date.now()+Math.floor(Math.random()*1e3)}var AM=Object.defineProperty,xM=Object.defineProperties,SM=Object.getOwnPropertyDescriptors,Sg=Object.getOwnPropertySymbols,MM=Object.prototype.hasOwnProperty,IM=Object.prototype.propertyIsEnumerable,Mg=(r,e,t)=>e in r?AM(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,CM=(r,e)=>{for(var t in e||(e={}))MM.call(e,t)&&Mg(r,t,e[t]);if(Sg)for(var t of Sg(e))IM.call(e,t)&&Mg(r,t,e[t]);return r},PM=(r,e)=>xM(r,SM(e));const OM="did:pkh:",c0=r=>r==null?void 0:r.split(":"),J3=r=>{const e=r&&c0(r);if(e)return r.includes(OM)?e[3]:e[1]},Ig=r=>{const e=r&&c0(r);if(e)return e[2]+":"+e[3]},Af=r=>{const e=r&&c0(r);if(e)return e.pop()};async function Cg(r){const{cacao:e,projectId:t}=r,{s:i,p:n}=e,a=W3(n,n.iss),c=Af(n.iss);return await wM(c,a,i,J3(n.iss),t)}const W3=(r,e)=>{const t=`${r.domain} wants you to sign in with your Ethereum account:`,i=Af(e);if(!r.aud&&!r.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let n=r.statement||void 0;const a=`URI: ${r.aud||r.uri}`,c=`Version: ${r.version}`,f=`Chain ID: ${J3(e)}`,g=`Nonce: ${r.nonce}`,d=`Issued At: ${r.iat}`,m=r.exp?`Expiration Time: ${r.exp}`:void 0,w=r.nbf?`Not Before: ${r.nbf}`:void 0,O=r.requestId?`Request ID: ${r.requestId}`:void 0,C=r.resources?`Resources:${r.resources.map(q=>`
- ${q}`).join("")}`:void 0,P=of(r.resources);if(P){const q=yc(P);n=FM(n,q)}return[t,i,"",n,"",a,c,f,g,d,m,w,O,C].filter(q=>q!=null).join(`
`)};function TM(r){return Buffer.from(JSON.stringify(r)).toString("base64")}function RM(r){return JSON.parse(Buffer.from(r,"base64").toString("utf-8"))}function ya(r){if(!r)throw new Error("No recap provided, value is undefined");if(!r.att)throw new Error("No `att` property found");const e=Object.keys(r.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(t=>{const i=r.att[t];if(Array.isArray(i))throw new Error(`Resource must be an object: ${t}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${t}`);Object.keys(i).forEach(n=>{const a=i[n];if(!Array.isArray(a))throw new Error(`Ability limits ${n} must be an array of objects, found: ${a}`);if(!a.length)throw new Error(`Value of ${n} is empty array, must be an array with objects`);a.forEach(c=>{if(typeof c!="object")throw new Error(`Ability limits (${n}) must be an array of objects, found: ${c}`)})})})}function NM(r,e,t,i={}){return t==null||t.sort((n,a)=>n.localeCompare(a)),{att:{[r]:BM(e,t,i)}}}function BM(r,e,t={}){e=e==null?void 0:e.sort((n,a)=>n.localeCompare(a));const i=e.map(n=>({[`${r}/${n}`]:[t]}));return Object.assign({},...i)}function Y3(r){return ya(r),`urn:recap:${TM(r).replace(/=/g,"")}`}function yc(r){const e=RM(r.replace("urn:recap:",""));return ya(e),e}function $M(r,e,t){const i=NM(r,e,t);return Y3(i)}function UM(r){return r&&r.includes("urn:recap:")}function qM(r,e){const t=yc(r),i=yc(e),n=LM(t,i);return Y3(n)}function LM(r,e){ya(r),ya(e);const t=Object.keys(r.att).concat(Object.keys(e.att)).sort((n,a)=>n.localeCompare(a)),i={att:{}};return t.forEach(n=>{var a,c;Object.keys(((a=r.att)==null?void 0:a[n])||{}).concat(Object.keys(((c=e.att)==null?void 0:c[n])||{})).sort((f,g)=>f.localeCompare(g)).forEach(f=>{var g,d;i.att[n]=PM(CM({},i.att[n]),{[f]:((g=r.att[n])==null?void 0:g[f])||((d=e.att[n])==null?void 0:d[f])})})}),i}function FM(r="",e){ya(e);const t="I further authorize the stated URI to perform the following actions on my behalf: ";if(r.includes(t))return r;const i=[];let n=0;Object.keys(e.att).forEach(f=>{const g=Object.keys(e.att[f]).map(w=>({ability:w.split("/")[0],action:w.split("/")[1]}));g.sort((w,O)=>w.action.localeCompare(O.action));const d={};g.forEach(w=>{d[w.ability]||(d[w.ability]=[]),d[w.ability].push(w.action)});const m=Object.keys(d).map(w=>(n++,`(${n}) '${w}': '${d[w].join("', '")}' for '${f}'.`));i.push(m.join(", ").replace(".,","."))});const a=i.join(" "),c=`${t}${a}`;return`${r?r+" ":""}${c}`}function Pg(r){var e;const t=yc(r);ya(t);const i=(e=t.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function Og(r){const e=yc(r);ya(e);const t=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(n=>{var a;(a=n==null?void 0:n[0])!=null&&a.chains&&t.push(n[0].chains)})}),[...new Set(t.flat())]}function of(r){if(!r)return;const e=r==null?void 0:r[r.length-1];return UM(e)?e:void 0}const Q3="base10",Yr="base16",Ls="base64pad",ec="base64url",Nc="utf8",X3=0,bs=1,Bc=2,zM=0,Tg=1,dc=12,u0=32;function jM(){const r=Vd.generateKeyPair();return{privateKey:Di(r.secretKey,Yr),publicKey:Di(r.publicKey,Yr)}}function xd(){const r=ks.randomBytes(u0);return Di(r,Yr)}function kM(r,e){const t=Vd.sharedKey(Hi(r,Yr),Hi(e,Yr),!0),i=new V_(Sc.SHA256,t).expand(u0);return Di(i,Yr)}function cf(r){const e=Sc.hash(Hi(r,Yr));return Di(e,Yr)}function hs(r){const e=Sc.hash(Hi(r,Nc));return Di(e,Yr)}function Z3(r){return Hi(`${r}`,Q3)}function wa(r){return Number(Di(r,Q3))}function HM(r){const e=Z3(typeof r.type<"u"?r.type:X3);if(wa(e)===bs&&typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const t=typeof r.senderPublicKey<"u"?Hi(r.senderPublicKey,Yr):void 0,i=typeof r.iv<"u"?Hi(r.iv,Yr):ks.randomBytes(dc),n=new Hd.ChaCha20Poly1305(Hi(r.symKey,Yr)).seal(i,Hi(r.message,Nc));return e2({type:e,sealed:n,iv:i,senderPublicKey:t,encoding:r.encoding})}function KM(r,e){const t=Z3(Bc),i=ks.randomBytes(dc),n=Hi(r,Nc);return e2({type:t,sealed:n,iv:i,encoding:e})}function VM(r){const e=new Hd.ChaCha20Poly1305(Hi(r.symKey,Yr)),{sealed:t,iv:i}=wc({encoded:r.encoded,encoding:r==null?void 0:r.encoding}),n=e.open(i,t);if(n===null)throw new Error("Failed to decrypt");return Di(n,Nc)}function GM(r,e){const{sealed:t}=wc({encoded:r,encoding:e});return Di(t,Nc)}function e2(r){const{encoding:e=Ls}=r;if(wa(r.type)===Bc)return Di(yl([r.type,r.sealed]),e);if(wa(r.type)===bs){if(typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return Di(yl([r.type,r.senderPublicKey,r.iv,r.sealed]),e)}return Di(yl([r.type,r.iv,r.sealed]),e)}function wc(r){const{encoded:e,encoding:t=Ls}=r,i=Hi(e,t),n=i.slice(zM,Tg),a=Tg;if(wa(n)===bs){const d=a+u0,m=d+dc,w=i.slice(a,d),O=i.slice(d,m),C=i.slice(m);return{type:n,sealed:C,iv:O,senderPublicKey:w}}if(wa(n)===Bc){const d=i.slice(a),m=ks.randomBytes(dc);return{type:n,sealed:d,iv:m}}const c=a+dc,f=i.slice(a,c),g=i.slice(c);return{type:n,sealed:g,iv:f}}function JM(r,e){const t=wc({encoded:r,encoding:e==null?void 0:e.encoding});return t2({type:wa(t.type),senderPublicKey:typeof t.senderPublicKey<"u"?Di(t.senderPublicKey,Yr):void 0,receiverPublicKey:e==null?void 0:e.receiverPublicKey})}function t2(r){const e=(r==null?void 0:r.type)||X3;if(e===bs){if(typeof(r==null?void 0:r.senderPublicKey)>"u")throw new Error("missing sender public key");if(typeof(r==null?void 0:r.receiverPublicKey)>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:r==null?void 0:r.senderPublicKey,receiverPublicKey:r==null?void 0:r.receiverPublicKey}}function Rg(r){return r.type===bs&&typeof r.senderPublicKey=="string"&&typeof r.receiverPublicKey=="string"}function Ng(r){return r.type===Bc}function WM(r){return new Ev.ec("p256").keyFromPublic({x:Buffer.from(r.x,"base64").toString("hex"),y:Buffer.from(r.y,"base64").toString("hex")},"hex")}function YM(r){let e=r.replace(/-/g,"+").replace(/_/g,"/");const t=e.length%4;return t>0&&(e+="=".repeat(4-t)),e}function QM(r){return Buffer.from(YM(r),"base64")}function XM(r,e){const[t,i,n]=r.split("."),a=QM(n);if(a.length!==64)throw new Error("Invalid signature length");const c=a.slice(0,32).toString("hex"),f=a.slice(32,64).toString("hex"),g=`${t}.${i}`,d=new Sc.SHA256().update(Buffer.from(g)).digest(),m=WM(e),w=Buffer.from(d).toString("hex");if(!m.verify(w,{r:c,s:f}))throw new Error("Invalid signature");return md(r).payload}const ZM="irn";function Sd(r){return(r==null?void 0:r.relay)||{protocol:ZM}}function cc(r){const e=AA[r];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${r}`);return e}var eI=Object.defineProperty,tI=Object.defineProperties,rI=Object.getOwnPropertyDescriptors,Bg=Object.getOwnPropertySymbols,iI=Object.prototype.hasOwnProperty,nI=Object.prototype.propertyIsEnumerable,$g=(r,e,t)=>e in r?eI(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ug=(r,e)=>{for(var t in e||(e={}))iI.call(e,t)&&$g(r,t,e[t]);if(Bg)for(var t of Bg(e))nI.call(e,t)&&$g(r,t,e[t]);return r},sI=(r,e)=>tI(r,rI(e));function aI(r,e="-"){const t={},i="relay"+e;return Object.keys(r).forEach(n=>{if(n.startsWith(i)){const a=n.replace(i,""),c=r[n];t[a]=c}}),t}function qg(r){if(!r.includes("wc:")){const g=d3(r);g!=null&&g.includes("wc:")&&(r=g)}r=r.includes("wc://")?r.replace("wc://",""):r,r=r.includes("wc:")?r.replace("wc:",""):r;const e=r.indexOf(":"),t=r.indexOf("?")!==-1?r.indexOf("?"):void 0,i=r.substring(0,e),n=r.substring(e+1,t).split("@"),a=typeof t<"u"?r.substring(t):"",c=vc.parse(a),f=typeof c.methods=="string"?c.methods.split(","):void 0;return{protocol:i,topic:oI(n[0]),version:parseInt(n[1],10),symKey:c.symKey,relay:aI(c),methods:f,expiryTimestamp:c.expiryTimestamp?parseInt(c.expiryTimestamp,10):void 0}}function oI(r){return r.startsWith("//")?r.substring(2):r}function cI(r,e="-"){const t="relay",i={};return Object.keys(r).forEach(n=>{const a=t+e+n;r[n]&&(i[a]=r[n])}),i}function Lg(r){return`${r.protocol}:${r.topic}@${r.version}?`+vc.stringify(Ug(sI(Ug({symKey:r.symKey},cI(r.relay)),{expiryTimestamp:r.expiryTimestamp}),r.methods?{methods:r.methods.join(",")}:{}))}function Wu(r,e,t){return`${r}?wc_ev=${t}&topic=${e}`}function xo(r){const e=[];return r.forEach(t=>{const[i,n]=t.split(":");e.push(`${i}:${n}`)}),e}function uI(r){const e=[];return Object.values(r).forEach(t=>{e.push(...xo(t.accounts))}),e}function fI(r,e){const t=[];return Object.values(r).forEach(i=>{xo(i.accounts).includes(e)&&t.push(...i.methods)}),t}function hI(r,e){const t=[];return Object.values(r).forEach(i=>{xo(i.accounts).includes(e)&&t.push(...i.events)}),t}function f0(r){return r.includes(":")}function uc(r){return f0(r)?r.split(":")[0]:r}function lI(r){const e={};return r==null||r.forEach(t=>{const[i,n]=t.split(":");e[i]||(e[i]={accounts:[],chains:[],events:[]}),e[i].accounts.push(t),e[i].chains.push(`${i}:${n}`)}),e}function Fg(r,e){e=e.map(i=>i.replace("did:pkh:",""));const t=lI(e);for(const[i,n]of Object.entries(t))n.methods?n.methods=rf(n.methods,r):n.methods=r,n.events=["chainChanged","accountsChanged"];return t}const dI={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}},pI={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 De(r,e){const{message:t,code:i}=pI[r];return{message:e?`${t} ${e}`:t,code:i}}function Lt(r,e){const{message:t,code:i}=dI[r];return{message:e?`${t} ${e}`:t,code:i}}function Hn(r,e){return!!Array.isArray(r)}function _c(r){return Object.getPrototypeOf(r)===Object.prototype&&Object.keys(r).length}function fi(r){return typeof r>"u"}function ur(r,e){return e&&fi(r)?!0:typeof r=="string"&&!!r.trim().length}function h0(r,e){return typeof r=="number"&&!isNaN(r)}function gI(r,e){const{requiredNamespaces:t}=e,i=Object.keys(r.namespaces),n=Object.keys(t);let a=!0;return la(n,i)?(i.forEach(c=>{const{accounts:f,methods:g,events:d}=r.namespaces[c],m=xo(f),w=t[c];(!la(a3(c,w),m)||!la(w.methods,g)||!la(w.events,d))&&(a=!1)}),a):!1}function xf(r){return ur(r,!1)&&r.includes(":")?r.split(":").length===2:!1}function bI(r){if(ur(r,!1)&&r.includes(":")){const e=r.split(":");if(e.length===3){const t=e[0]+":"+e[1];return!!e[2]&&xf(t)}}return!1}function vI(r){function e(t){try{return typeof new URL(t)<"u"}catch{return!1}}try{if(ur(r,!1)){if(e(r))return!0;const t=d3(r);return e(t)}}catch{}return!1}function mI(r){var e;return(e=r==null?void 0:r.proposer)==null?void 0:e.publicKey}function yI(r){return r==null?void 0:r.topic}function wI(r,e){let t=null;return ur(r==null?void 0:r.publicKey,!1)||(t=De("MISSING_OR_INVALID",`${e} controller public key should be a string`)),t}function zg(r){let e=!0;return Hn(r)?r.length&&(e=r.every(t=>ur(t,!1))):e=!1,e}function _I(r,e,t){let i=null;return Hn(e)&&e.length?e.forEach(n=>{i||xf(n)||(i=Lt("UNSUPPORTED_CHAINS",`${t}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):xf(r)||(i=Lt("UNSUPPORTED_CHAINS",`${t}, 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 DI(r,e,t){let i=null;return Object.entries(r).forEach(([n,a])=>{if(i)return;const c=_I(n,a3(n,a),`${e} ${t}`);c&&(i=c)}),i}function EI(r,e){let t=null;return Hn(r)?r.forEach(i=>{t||bI(i)||(t=Lt("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):t=Lt("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),t}function AI(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;const n=EI(i==null?void 0:i.accounts,`${e} namespace`);n&&(t=n)}),t}function xI(r,e){let t=null;return zg(r==null?void 0:r.methods)?zg(r==null?void 0:r.events)||(t=Lt("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):t=Lt("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),t}function r2(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;const n=xI(i,`${e}, namespace`);n&&(t=n)}),t}function SI(r,e,t){let i=null;if(r&&_c(r)){const n=r2(r,e);n&&(i=n);const a=DI(r,e,t);a&&(i=a)}else i=De("MISSING_OR_INVALID",`${e}, ${t} should be an object with data`);return i}function Kl(r,e){let t=null;if(r&&_c(r)){const i=r2(r,e);i&&(t=i);const n=AI(r,e);n&&(t=n)}else t=De("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return t}function i2(r){return ur(r.protocol,!0)}function MI(r,e){let t=!1;return r?r&&Hn(r)&&r.length&&r.forEach(i=>{t=i2(i)}):t=!0,t}function II(r){return typeof r=="number"}function ci(r){return typeof r<"u"&&typeof r!==null}function CI(r){return!(!r||typeof r!="object"||!r.code||!h0(r.code)||!r.message||!ur(r.message,!1))}function PI(r){return!(fi(r)||!ur(r.method,!1))}function OI(r){return!(fi(r)||fi(r.result)&&fi(r.error)||!h0(r.id)||!ur(r.jsonrpc,!1))}function TI(r){return!(fi(r)||!ur(r.name,!1))}function jg(r,e){return!(!xf(e)||!uI(r).includes(e))}function RI(r,e,t){return ur(t,!1)?fI(r,e).includes(t):!1}function NI(r,e,t){return ur(t,!1)?hI(r,e).includes(t):!1}function kg(r,e,t){let i=null;const n=BI(r),a=$I(e),c=Object.keys(n),f=Object.keys(a),g=Hg(Object.keys(r)),d=Hg(Object.keys(e)),m=g.filter(w=>!d.includes(w));return m.length&&(i=De("NON_CONFORMING_NAMESPACES",`${t} namespaces keys don't satisfy requiredNamespaces.
Required: ${m.toString()}
Received: ${Object.keys(e).toString()}`)),la(c,f)||(i=De("NON_CONFORMING_NAMESPACES",`${t} namespaces chains don't satisfy required namespaces.
Required: ${c.toString()}
Approved: ${f.toString()}`)),Object.keys(e).forEach(w=>{if(!w.includes(":")||i)return;const O=xo(e[w].accounts);O.includes(w)||(i=De("NON_CONFORMING_NAMESPACES",`${t} namespaces accounts don't satisfy namespace accounts for ${w}
Required: ${w}
Approved: ${O.toString()}`))}),c.forEach(w=>{i||(la(n[w].methods,a[w].methods)?la(n[w].events,a[w].events)||(i=De("NON_CONFORMING_NAMESPACES",`${t} namespaces events don't satisfy namespace events for ${w}`)):i=De("NON_CONFORMING_NAMESPACES",`${t} namespaces methods don't satisfy namespace methods for ${w}`))}),i}function BI(r){const e={};return Object.keys(r).forEach(t=>{var i;t.includes(":")?e[t]=r[t]:(i=r[t].chains)==null||i.forEach(n=>{e[n]={methods:r[t].methods,events:r[t].events}})}),e}function Hg(r){return[...new Set(r.map(e=>e.includes(":")?e.split(":")[0]:e))]}function $I(r){const e={};return Object.keys(r).forEach(t=>{if(t.includes(":"))e[t]=r[t];else{const i=xo(r[t].accounts);i==null||i.forEach(n=>{e[n]={accounts:r[t].accounts.filter(a=>a.includes(`${n}:`)),methods:r[t].methods,events:r[t].events}})}}),e}function UI(r,e){return h0(r)&&r<=e.max&&r>=e.min}function Kg(){const r=Tc();return new Promise(e=>{switch(r){case _i.browser:e(qI());break;case _i.reactNative:e(LI());break;case _i.node:e(FI());break;default:e(!0)}})}function qI(){return Oc()&&(navigator==null?void 0:navigator.onLine)}async function LI(){if(wo()&&typeof globalThis<"u"&&globalThis!=null&&globalThis.NetInfo){const r=await(globalThis==null?void 0:globalThis.NetInfo.fetch());return r==null?void 0:r.isConnected}return!0}function FI(){return!0}function zI(r){switch(Tc()){case _i.browser:jI(r);break;case _i.reactNative:kI(r);break}}function jI(r){!wo()&&Oc()&&(window.addEventListener("online",()=>r(!0)),window.addEventListener("offline",()=>r(!1)))}function kI(r){wo()&&typeof globalThis<"u"&&globalThis!=null&&globalThis.NetInfo&&(globalThis==null||globalThis.NetInfo.addEventListener(e=>r(e==null?void 0:e.isConnected)))}const Vl={};class tc{static get(e){return Vl[e]}static set(e,t){Vl[e]=t}static delete(e){delete Vl[e]}}class xa{}let HI=class extends xa{constructor(e){super()}};const Vg=Ae.FIVE_SECONDS,So={pulse:"heartbeat_pulse"};let KI=class n2 extends HI{constructor(e){super(e),this.events=new Vi.EventEmitter,this.interval=Vg,this.interval=(e==null?void 0:e.interval)||Vg}static async init(e){const t=new n2(e);return await t.init(),t}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),Ae.toMiliseconds(this.interval))}pulse(){this.events.emit(So.pulse)}};const VI=/"(?:_|\\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*:/,GI=/"(?: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*:/,JI=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function WI(r,e){if(r==="__proto__"||r==="constructor"&&e&&typeof e=="object"&&"prototype"in e){YI(r);return}return e}function YI(r){console.warn(`[destr] Dropping "${r}" key to prevent prototype pollution.`)}function Yu(r,e={}){if(typeof r!="string")return r;const t=r.trim();if(r[0]==='"'&&r.endsWith('"')&&!r.includes("\\"))return t.slice(1,-1);if(t.length<=9){const i=t.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(!JI.test(r)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return r}try{if(VI.test(r)||GI.test(r)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(r,WI)}return JSON.parse(r)}catch(i){if(e.strict)throw i;return r}}function QI(r){return!r||typeof r.then!="function"?Promise.resolve(r):r}function _r(r,...e){try{return QI(r(...e))}catch(t){return Promise.reject(t)}}function XI(r){const e=typeof r;return r===null||e!=="object"&&e!=="function"}function ZI(r){const e=Object.getPrototypeOf(r);return!e||e.isPrototypeOf(Object)}function uf(r){if(XI(r))return String(r);if(ZI(r)||Array.isArray(r))return JSON.stringify(r);if(typeof r.toJSON=="function")return uf(r.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function s2(){if(typeof Buffer>"u")throw new TypeError("[unstorage] Buffer is not supported!")}const Md="base64:";function eC(r){if(typeof r=="string")return r;s2();const e=Buffer.from(r).toString("base64");return Md+e}function tC(r){return typeof r!="string"||!r.startsWith(Md)?r:(s2(),Buffer.from(r.slice(Md.length),"base64"))}function oi(r){return r?r.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function rC(...r){return oi(r.join(":"))}function Qu(r){return r=oi(r),r?r+":":""}const iC="memory",nC=()=>{const r=new Map;return{name:iC,getInstance:()=>r,hasItem(e){return r.has(e)},getItem(e){return r.get(e)??null},getItemRaw(e){return r.get(e)??null},setItem(e,t){r.set(e,t)},setItemRaw(e,t){r.set(e,t)},removeItem(e){r.delete(e)},getKeys(){return[...r.keys()]},clear(){r.clear()},dispose(){r.clear()}}};function sC(r={}){const e={mounts:{"":r.driver||nC()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},t=d=>{for(const m of e.mountpoints)if(d.startsWith(m))return{base:m,relativeKey:d.slice(m.length),driver:e.mounts[m]};return{base:"",relativeKey:d,driver:e.mounts[""]}},i=(d,m)=>e.mountpoints.filter(w=>w.startsWith(d)||m&&d.startsWith(w)).map(w=>({relativeBase:d.length>w.length?d.slice(w.length):void 0,mountpoint:w,driver:e.mounts[w]})),n=(d,m)=>{if(e.watching){m=oi(m);for(const w of e.watchListeners)w(d,m)}},a=async()=>{if(!e.watching){e.watching=!0;for(const d in e.mounts)e.unwatch[d]=await Gg(e.mounts[d],n,d)}},c=async()=>{if(e.watching){for(const d in e.unwatch)await e.unwatch[d]();e.unwatch={},e.watching=!1}},f=(d,m,w)=>{const O=new Map,C=P=>{let q=O.get(P.base);return q||(q={driver:P.driver,base:P.base,items:[]},O.set(P.base,q)),q};for(const P of d){const q=typeof P=="string",K=oi(q?P:P.key),Y=q?void 0:P.value,z=q||!P.options?m:{...m,...P.options},W=t(K);C(W).items.push({key:K,value:Y,relativeKey:W.relativeKey,options:z})}return Promise.all([...O.values()].map(P=>w(P))).then(P=>P.flat())},g={hasItem(d,m={}){d=oi(d);const{relativeKey:w,driver:O}=t(d);return _r(O.hasItem,w,m)},getItem(d,m={}){d=oi(d);const{relativeKey:w,driver:O}=t(d);return _r(O.getItem,w,m).then(C=>Yu(C))},getItems(d,m){return f(d,m,w=>w.driver.getItems?_r(w.driver.getItems,w.items.map(O=>({key:O.relativeKey,options:O.options})),m).then(O=>O.map(C=>({key:rC(w.base,C.key),value:Yu(C.value)}))):Promise.all(w.items.map(O=>_r(w.driver.getItem,O.relativeKey,O.options).then(C=>({key:O.key,value:Yu(C)})))))},getItemRaw(d,m={}){d=oi(d);const{relativeKey:w,driver:O}=t(d);return O.getItemRaw?_r(O.getItemRaw,w,m):_r(O.getItem,w,m).then(C=>tC(C))},async setItem(d,m,w={}){if(m===void 0)return g.removeItem(d);d=oi(d);const{relativeKey:O,driver:C}=t(d);C.setItem&&(await _r(C.setItem,O,uf(m),w),C.watch||n("update",d))},async setItems(d,m){await f(d,m,async w=>{if(w.driver.setItems)return _r(w.driver.setItems,w.items.map(O=>({key:O.relativeKey,value:uf(O.value),options:O.options})),m);w.driver.setItem&&await Promise.all(w.items.map(O=>_r(w.driver.setItem,O.relativeKey,uf(O.value),O.options)))})},async setItemRaw(d,m,w={}){if(m===void 0)return g.removeItem(d,w);d=oi(d);const{relativeKey:O,driver:C}=t(d);if(C.setItemRaw)await _r(C.setItemRaw,O,m,w);else if(C.setItem)await _r(C.setItem,O,eC(m),w);else return;C.watch||n("update",d)},async removeItem(d,m={}){typeof m=="boolean"&&(m={removeMeta:m}),d=oi(d);const{relativeKey:w,driver:O}=t(d);O.removeItem&&(await _r(O.removeItem,w,m),(m.removeMeta||m.removeMata)&&await _r(O.removeItem,w+"$",m),O.watch||n("remove",d))},async getMeta(d,m={}){typeof m=="boolean"&&(m={nativeOnly:m}),d=oi(d);const{relativeKey:w,driver:O}=t(d),C=Object.create(null);if(O.getMeta&&Object.assign(C,await _r(O.getMeta,w,m)),!m.nativeOnly){const P=await _r(O.getItem,w+"$",m).then(q=>Yu(q));P&&typeof P=="object"&&(typeof P.atime=="string"&&(P.atime=new Date(P.atime)),typeof P.mtime=="string"&&(P.mtime=new Date(P.mtime)),Object.assign(C,P))}return C},setMeta(d,m,w={}){return this.setItem(d+"$",m,w)},removeMeta(d,m={}){return this.removeItem(d+"$",m)},async getKeys(d,m={}){d=Qu(d);const w=i(d,!0);let O=[];const C=[];for(const P of w){const q=await _r(P.driver.getKeys,P.relativeBase,m);for(const K of q){const Y=P.mountpoint+oi(K);O.some(z=>Y.startsWith(z))||C.push(Y)}O=[P.mountpoint,...O.filter(K=>!K.startsWith(P.mountpoint))]}return d?C.filter(P=>P.startsWith(d)&&P[P.length-1]!=="$"):C.filter(P=>P[P.length-1]!=="$")},async clear(d,m={}){d=Qu(d),await Promise.all(i(d,!1).map(async w=>{if(w.driver.clear)return _r(w.driver.clear,w.relativeBase,m);if(w.driver.removeItem){const O=await w.driver.getKeys(w.relativeBase||"",m);return Promise.all(O.map(C=>w.driver.removeItem(C,m)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(d=>Jg(d)))},async watch(d){return await a(),e.watchListeners.push(d),async()=>{e.watchListeners=e.watchListeners.filter(m=>m!==d),e.watchListeners.length===0&&await c()}},async unwatch(){e.watchListeners=[],await c()},mount(d,m){if(d=Qu(d),d&&e.mounts[d])throw new Error(`already mounted at ${d}`);return d&&(e.mountpoints.push(d),e.mountpoints.sort((w,O)=>O.length-w.length)),e.mounts[d]=m,e.watching&&Promise.resolve(Gg(m,n,d)).then(w=>{e.unwatch[d]=w}).catch(console.error),g},async unmount(d,m=!0){d=Qu(d),!(!d||!e.mounts[d])&&(e.watching&&d in e.unwatch&&(e.unwatch[d](),delete e.unwatch[d]),m&&await Jg(e.mounts[d]),e.mountpoints=e.mountpoints.filter(w=>w!==d),delete e.mounts[d])},getMount(d=""){d=oi(d)+":";const m=t(d);return{driver:m.driver,base:m.base}},getMounts(d="",m={}){return d=oi(d),i(d,m.parents).map(O=>({driver:O.driver,base:O.mountpoint}))},keys:(d,m={})=>g.getKeys(d,m),get:(d,m={})=>g.getItem(d,m),set:(d,m,w={})=>g.setItem(d,m,w),has:(d,m={})=>g.hasItem(d,m),del:(d,m={})=>g.removeItem(d,m),remove:(d,m={})=>g.removeItem(d,m)};return g}function Gg(r,e,t){return r.watch?r.watch((i,n)=>e(i,t+n)):()=>{}}async function Jg(r){typeof r.dispose=="function"&&await _r(r.dispose)}function Sa(r){return new Promise((e,t)=>{r.oncomplete=r.onsuccess=()=>e(r.result),r.onabort=r.onerror=()=>t(r.error)})}function a2(r,e){const t=indexedDB.open(r);t.onupgradeneeded=()=>t.result.createObjectStore(e);const i=Sa(t);return(n,a)=>i.then(c=>a(c.transaction(e,n).objectStore(e)))}let Gl;function $c(){return Gl||(Gl=a2("keyval-store","keyval")),Gl}function Wg(r,e=$c()){return e("readonly",t=>Sa(t.get(r)))}function aC(r,e,t=$c()){return t("readwrite",i=>(i.put(e,r),Sa(i.transaction)))}function oC(r,e=$c()){return e("readwrite",t=>(t.delete(r),Sa(t.transaction)))}function cC(r=$c()){return r("readwrite",e=>(e.clear(),Sa(e.transaction)))}function uC(r,e){return r.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},Sa(r.transaction)}function fC(r=$c()){return r("readonly",e=>{if(e.getAllKeys)return Sa(e.getAllKeys());const t=[];return uC(e,i=>t.push(i.key)).then(()=>t)})}const hC="idb-keyval";var lC=(r={})=>{const e=r.base&&r.base.length>0?`${r.base}:`:"",t=n=>e+n;let i;return r.dbName&&r.storeName&&(i=a2(r.dbName,r.storeName)),{name:hC,options:r,async hasItem(n){return!(typeof await Wg(t(n),i)>"u")},async getItem(n){return await Wg(t(n),i)??null},setItem(n,a){return aC(t(n),a,i)},removeItem(n){return oC(t(n),i)},getKeys(){return fC(i)},clear(){return cC(i)}}};const dC="WALLET_CONNECT_V2_INDEXED_DB",pC="keyvaluestorage";let gC=class{constructor(){this.indexedDb=sC({driver:lC({dbName:dC,storeName:pC})})}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 t=await this.indexedDb.getItem(e);if(t!==null)return t}async setItem(e,t){await this.indexedDb.setItem(e,ys(t))}async removeItem(e){await this.indexedDb.removeItem(e)}};var Jl=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},ff={exports:{}};(function(){let r;function e(){}r=e,r.prototype.getItem=function(t){return this.hasOwnProperty(t)?String(this[t]):null},r.prototype.setItem=function(t,i){this[t]=String(i)},r.prototype.removeItem=function(t){delete this[t]},r.prototype.clear=function(){const t=this;Object.keys(t).forEach(function(i){t[i]=void 0,delete t[i]})},r.prototype.key=function(t){return t=t||0,Object.keys(this)[t]},r.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Jl<"u"&&Jl.localStorage?ff.exports=Jl.localStorage:typeof window<"u"&&window.localStorage?ff.exports=window.localStorage:ff.exports=new e})();function bC(r){var e;return[r[0],ma((e=r[1])!=null?e:"")]}class vC{constructor(){this.localStorage=ff.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(bC)}async getItem(e){const t=this.localStorage.getItem(e);if(t!==null)return ma(t)}async setItem(e,t){this.localStorage.setItem(e,ys(t))}async removeItem(e){this.localStorage.removeItem(e)}}const mC="wc_storage_version",Yg=1,yC=async(r,e,t)=>{const i=mC,n=await e.getItem(i);if(n&&n>=Yg){t(e);return}const a=await r.getKeys();if(!a.length){t(e);return}const c=[];for(;a.length;){const f=a.shift();if(!f)continue;const g=f.toLowerCase();if(g.includes("wc@")||g.includes("walletconnect")||g.includes("wc_")||g.includes("wallet_connect")){const d=await r.getItem(f);await e.setItem(f,d),c.push(f)}}await e.setItem(i,Yg),t(e),wC(r,c)},wC=async(r,e)=>{e.length&&e.forEach(async t=>{await r.removeItem(t)})};let _C=class{constructor(){this.initialized=!1,this.setInitialized=t=>{this.storage=t,this.initialized=!0};const e=new vC;this.storage=e;try{const t=new gC;yC(e,t,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,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{const t=setInterval(()=>{this.initialized&&(clearInterval(t),e())},20)})}};function DC(r){try{return JSON.stringify(r)}catch{return'"[Circular]"'}}var EC=AC;function AC(r,e,t){var i=t&&t.stringify||DC,n=1;if(typeof r=="object"&&r!==null){var a=e.length+n;if(a===1)return r;var c=new Array(a);c[0]=i(r);for(var f=1;f<a;f++)c[f]=i(e[f]);return c.join(" ")}if(typeof r!="string")return r;var g=e.length;if(g===0)return r;for(var d="",m=1-n,w=-1,O=r&&r.length||0,C=0;C<O;){if(r.charCodeAt(C)===37&&C+1<O){switch(w=w>-1?w:0,r.charCodeAt(C+1)){case 100:case 102:if(m>=g||e[m]==null)break;w<C&&(d+=r.slice(w,C)),d+=Number(e[m]),w=C+2,C++;break;case 105:if(m>=g||e[m]==null)break;w<C&&(d+=r.slice(w,C)),d+=Math.floor(Number(e[m])),w=C+2,C++;break;case 79:case 111:case 106:if(m>=g||e[m]===void 0)break;w<C&&(d+=r.slice(w,C));var P=typeof e[m];if(P==="string"){d+="'"+e[m]+"'",w=C+2,C++;break}if(P==="function"){d+=e[m].name||"<anonymous>",w=C+2,C++;break}d+=i(e[m]),w=C+2,C++;break;case 115:if(m>=g)break;w<C&&(d+=r.slice(w,C)),d+=String(e[m]),w=C+2,C++;break;case 37:w<C&&(d+=r.slice(w,C)),d+="%",w=C+2,C++,m--;break}++m}++C}return w===-1?r:(w<O&&(d+=r.slice(w)),d)}const Qg=EC;var Xa=Fn;const Dc=NC().console||{},xC={mapHttpRequest:Xu,mapHttpResponse:Xu,wrapRequestSerializer:Wl,wrapResponseSerializer:Wl,wrapErrorSerializer:Wl,req:Xu,res:Xu,err:PC};function SC(r,e){return Array.isArray(r)?r.filter(function(i){return i!=="!stdSerializers.err"}):r===!0?Object.keys(e):!1}function Fn(r){r=r||{},r.browser=r.browser||{};const e=r.browser.transmit;if(e&&typeof e.send!="function")throw Error("pino: transmit option must have a send function");const t=r.browser.write||Dc;r.browser.write&&(r.browser.asObject=!0);const i=r.serializers||{},n=SC(r.browser.serialize,i);let a=r.browser.serialize;Array.isArray(r.browser.serialize)&&r.browser.serialize.indexOf("!stdSerializers.err")>-1&&(a=!1);const c=["error","fatal","warn","info","debug","trace"];typeof t=="function"&&(t.error=t.fatal=t.warn=t.info=t.debug=t.trace=t),r.enabled===!1&&(r.level="silent");const f=r.level||"info",g=Object.create(t);g.log||(g.log=Ec),Object.defineProperty(g,"levelVal",{get:m}),Object.defineProperty(g,"level",{get:w,set:O});const d={transmit:e,serialize:n,asObject:r.browser.asObject,levels:c,timestamp:OC(r)};g.levels=Fn.levels,g.level=f,g.setMaxListeners=g.getMaxListeners=g.emit=g.addListener=g.on=g.prependListener=g.once=g.prependOnceListener=g.removeListener=g.removeAllListeners=g.listeners=g.listenerCount=g.eventNames=g.write=g.flush=Ec,g.serializers=i,g._serialize=n,g._stdErrSerialize=a,g.child=C,e&&(g._logEvent=Id());function m(){return this.level==="silent"?1/0:this.levels.values[this.level]}function w(){return this._level}function O(P){if(P!=="silent"&&!this.levels.values[P])throw Error("unknown level "+P);this._level=P,Ja(d,g,"error","log"),Ja(d,g,"fatal","error"),Ja(d,g,"warn","error"),Ja(d,g,"info","log"),Ja(d,g,"debug","log"),Ja(d,g,"trace","log")}function C(P,q){if(!P)throw new Error("missing bindings for child Pino");q=q||{},n&&P.serializers&&(q.serializers=P.serializers);const K=q.serializers;if(n&&K){var Y=Object.assign({},i,K),z=r.browser.serialize===!0?Object.keys(Y):n;delete P.serializers,Xf([P],z,Y,this._stdErrSerialize)}function W(B){this._childLevel=(B._childLevel|0)+1,this.error=Wa(B,P,"error"),this.fatal=Wa(B,P,"fatal"),this.warn=Wa(B,P,"warn"),this.info=Wa(B,P,"info"),this.debug=Wa(B,P,"debug"),this.trace=Wa(B,P,"trace"),Y&&(this.serializers=Y,this._serialize=z),e&&(this._logEvent=Id([].concat(B._logEvent.bindings,P)))}return W.prototype=this,new W(this)}return g}Fn.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"}};Fn.stdSerializers=xC;Fn.stdTimeFunctions=Object.assign({},{nullTime:o2,epochTime:c2,unixTime:TC,isoTime:RC});function Ja(r,e,t,i){const n=Object.getPrototypeOf(e);e[t]=e.levelVal>e.levels.values[t]?Ec:n[t]?n[t]:Dc[t]||Dc[i]||Ec,MC(r,e,t)}function MC(r,e,t){!r.transmit&&e[t]===Ec||(e[t]=function(i){return function(){const a=r.timestamp(),c=new Array(arguments.length),f=Object.getPrototypeOf&&Object.getPrototypeOf(this)===Dc?Dc:this;for(var g=0;g<c.length;g++)c[g]=arguments[g];if(r.serialize&&!r.asObject&&Xf(c,this._serialize,this.serializers,this._stdErrSerialize),r.asObject?i.call(f,IC(this,t,c,a)):i.apply(f,c),r.transmit){const d=r.transmit.level||e.level,m=Fn.levels.values[d],w=Fn.levels.values[t];if(w<m)return;CC(this,{ts:a,methodLevel:t,methodValue:w,transmitLevel:d,transmitValue:Fn.levels.values[r.transmit.level||e.level],send:r.transmit.send,val:e.levelVal},c)}}}(e[t]))}function IC(r,e,t,i){r._serialize&&Xf(t,r._serialize,r.serializers,r._stdErrSerialize);const n=t.slice();let a=n[0];const c={};i&&(c.time=i),c.level=Fn.levels.values[e];let f=(r._childLevel|0)+1;if(f<1&&(f=1),a!==null&&typeof a=="object"){for(;f--&&typeof n[0]=="object";)Object.assign(c,n.shift());a=n.length?Qg(n.shift(),n):void 0}else typeof a=="string"&&(a=Qg(n.shift(),n));return a!==void 0&&(c.msg=a),c}function Xf(r,e,t,i){for(const n in r)if(i&&r[n]instanceof Error)r[n]=Fn.stdSerializers.err(r[n]);else if(typeof r[n]=="object"&&!Array.isArray(r[n]))for(const a in r[n])e&&e.indexOf(a)>-1&&a in t&&(r[n][a]=t[a](r[n][a]))}function Wa(r,e,t){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 r[t].apply(this,i)}}function CC(r,e,t){const i=e.send,n=e.ts,a=e.methodLevel,c=e.methodValue,f=e.val,g=r._logEvent.bindings;Xf(t,r._serialize||Object.keys(r.serializers),r.serializers,r._stdErrSerialize===void 0?!0:r._stdErrSerialize),r._logEvent.ts=n,r._logEvent.messages=t.filter(function(d){return g.indexOf(d)===-1}),r._logEvent.level.label=a,r._logEvent.level.value=c,i(a,r._logEvent,f),r._logEvent=Id(g)}function Id(r){return{ts:0,messages:[],bindings:r||[],level:{label:"",value:0}}}function PC(r){const e={type:r.constructor.name,msg:r.message,stack:r.stack};for(const t in r)e[t]===void 0&&(e[t]=r[t]);return e}function OC(r){return typeof r.timestamp=="function"?r.timestamp:r.timestamp===!1?o2:c2}function Xu(){return{}}function Wl(r){return r}function Ec(){}function o2(){return!1}function c2(){return Date.now()}function TC(){return Math.round(Date.now()/1e3)}function RC(){return new Date(Date.now()).toISOString()}function NC(){function r(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 r(self)||r(window)||r(this)||{}}}const Uc=Ld(Xa),BC={level:"info"},qc="custom_context",l0=1e3*1024;let $C=class{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}},Xg=class{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){const t=new $C(e);if(t.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${t.size}`);for(;this.size+t.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=t),this.tail=t):(this.head=t,this.tail=t),this.lengthInNodes++,this.sizeInBytes+=t.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 t=this.head;for(;t!==null;)e.push(t.value),t=t.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 t=e.value;return e=e.next,{done:!1,value:t}}}}},u2=class{constructor(e,t=l0){this.level=e??"error",this.levelValue=Xa.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=t,this.logs=new Xg(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,t){t===Xa.levels.values.error?console.error(e):t===Xa.levels.values.warn?console.warn(e):t===Xa.levels.values.debug?console.debug(e):t===Xa.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(ys({timestamp:new Date().toISOString(),log:e}));const t=typeof e=="string"?JSON.parse(e).level:e.level;t>=this.levelValue&&this.forwardToConsole(e,t)}getLogs(){return this.logs}clearLogs(){this.logs=new Xg(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const t=this.getLogArray();return t.push(ys({extraMetadata:e})),new Blob(t,{type:"application/json"})}},UC=class{constructor(e,t=l0){this.baseChunkLogger=new u2(e,t)}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 t=URL.createObjectURL(this.logsToBlob(e)),i=document.createElement("a");i.href=t,i.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(t)}};class qC{constructor(e,t=l0){this.baseChunkLogger=new u2(e,t)}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 LC=Object.defineProperty,FC=Object.defineProperties,zC=Object.getOwnPropertyDescriptors,Zg=Object.getOwnPropertySymbols,jC=Object.prototype.hasOwnProperty,kC=Object.prototype.propertyIsEnumerable,eb=(r,e,t)=>e in r?LC(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Sf=(r,e)=>{for(var t in e||(e={}))jC.call(e,t)&&eb(r,t,e[t]);if(Zg)for(var t of Zg(e))kC.call(e,t)&&eb(r,t,e[t]);return r},Mf=(r,e)=>FC(r,zC(e));function Zf(r){return Mf(Sf({},r),{level:(r==null?void 0:r.level)||BC.level})}function HC(r,e=qc){return r[e]||""}function KC(r,e,t=qc){return r[t]=e,r}function pi(r,e=qc){let t="";return typeof r.bindings>"u"?t=HC(r,e):t=r.bindings().context||"",t}function VC(r,e,t=qc){const i=pi(r,t);return i.trim()?`${i}/${e}`:e}function Qr(r,e,t=qc){const i=VC(r,e,t),n=r.child({context:i});return KC(n,i,t)}function GC(r){var e,t;const i=new UC((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:Uc(Mf(Sf({},r.opts),{level:"trace",browser:Mf(Sf({},(t=r.opts)==null?void 0:t.browser),{write:n=>i.write(n)})})),chunkLoggerController:i}}function JC(r){var e;const t=new qC((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:Uc(Mf(Sf({},r.opts),{level:"trace"}),t),chunkLoggerController:t}}function WC(r){return typeof r.loggerOverride<"u"&&typeof r.loggerOverride!="string"?{logger:r.loggerOverride,chunkLoggerController:null}:typeof window<"u"?GC(r):JC(r)}let YC=class extends xa{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}},QC=class extends xa{constructor(e,t){super(),this.core=e,this.logger=t,this.records=new Map}},XC=class{constructor(e,t){this.logger=e,this.core=t}},ZC=class extends xa{constructor(e,t){super(),this.relayer=e,this.logger=t}},eP=class extends xa{constructor(e){super()}},tP=class{constructor(e,t,i,n){this.core=e,this.logger=t,this.name=i}},rP=class extends xa{constructor(e,t){super(),this.relayer=e,this.logger=t}},iP=class extends xa{constructor(e,t){super(),this.core=e,this.logger=t}},nP=class{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}},sP=class{constructor(e,t){this.projectId=e,this.logger=t}},aP=class{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}},oP=class{constructor(e){this.opts=e,this.protocol="wc",this.version=2}},cP=class{constructor(e){this.client=e}};function uP(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function fP(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i<t.length;i++)t[i]=255;for(var n=0;n<r.length;n++){var a=r.charAt(n),c=a.charCodeAt(0);if(t[c]!==255)throw new TypeError(a+" is ambiguous");t[c]=n}var f=r.length,g=r.charAt(0),d=Math.log(f)/Math.log(256),m=Math.log(256)/Math.log(f);function w(P){if(P instanceof Uint8Array||(ArrayBuffer.isView(P)?P=new Uint8Array(P.buffer,P.byteOffset,P.byteLength):Array.isArray(P)&&(P=Uint8Array.from(P))),!(P instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(P.length===0)return"";for(var q=0,K=0,Y=0,z=P.length;Y!==z&&P[Y]===0;)Y++,q++;for(var W=(z-Y)*m+1>>>0,B=new Uint8Array(W);Y!==z;){for(var j=P[Y],k=0,_=W-1;(j!==0||k<K)&&_!==-1;_--,k++)j+=256*B[_]>>>0,B[_]=j%f>>>0,j=j/f>>>0;if(j!==0)throw new Error("Non-zero carry");K=k,Y++}for(var N=W-K;N!==W&&B[N]===0;)N++;for(var se=g.repeat(q);N<W;++N)se+=r.charAt(B[N]);return se}function O(P){if(typeof P!="string")throw new TypeError("Expected String");if(P.length===0)return new Uint8Array;var q=0;if(P[q]!==" "){for(var K=0,Y=0;P[q]===g;)K++,q++;for(var z=(P.length-q)*d+1>>>0,W=new Uint8Array(z);P[q];){var B=t[P.charCodeAt(q)];if(B===255)return;for(var j=0,k=z-1;(B!==0||j<Y)&&k!==-1;k--,j++)B+=f*W[k]>>>0,W[k]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");Y=j,q++}if(P[q]!==" "){for(var _=z-Y;_!==z&&W[_]===0;)_++;for(var N=new Uint8Array(K+(z-_)),se=K;_!==z;)N[se++]=W[_++];return N}}}function C(P){var q=O(P);if(q)return q;throw new Error(`Non-${e} character`)}return{encode:w,decodeUnsafe:O,decode:C}}var hP=fP,lP=hP;const dP=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},pP=r=>new TextEncoder().encode(r),gP=r=>new TextDecoder().decode(r);class bP{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class vP{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.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 f2(this,e)}}class mP{constructor(e){this.decoders=e}or(e){return f2(this,e)}decode(e){const t=e[0],i=this.decoders[t];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 f2=(r,e)=>new mP({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}});class yP{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new bP(e,t,i),this.decoder=new vP(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const eh=({name:r,prefix:e,encode:t,decode:i})=>new yP(r,e,t,i),Lc=({prefix:r,name:e,alphabet:t})=>{const{encode:i,decode:n}=lP(t,e);return eh({prefix:r,name:e,encode:i,decode:a=>dP(n(a))})},wP=(r,e,t,i)=>{const n={};for(let m=0;m<e.length;++m)n[e[m]]=m;let a=r.length;for(;r[a-1]==="=";)--a;const c=new Uint8Array(a*t/8|0);let f=0,g=0,d=0;for(let m=0;m<a;++m){const w=n[r[m]];if(w===void 0)throw new SyntaxError(`Non-${i} character`);g=g<<t|w,f+=t,f>=8&&(f-=8,c[d++]=255&g>>f)}if(f>=t||255&g<<8-f)throw new SyntaxError("Unexpected end of data");return c},_P=(r,e,t)=>{const i=e[e.length-1]==="=",n=(1<<t)-1;let a="",c=0,f=0;for(let g=0;g<r.length;++g)for(f=f<<8|r[g],c+=8;c>t;)c-=t,a+=e[n&f>>c];if(c&&(a+=e[n&f<<t-c]),i)for(;a.length*t&7;)a+="=";return a},Or=({name:r,prefix:e,bitsPerChar:t,alphabet:i})=>eh({prefix:e,name:r,encode(n){return _P(n,i,t)},decode(n){return wP(n,i,t,r)}}),DP=eh({prefix:"\0",name:"identity",encode:r=>gP(r),decode:r=>pP(r)}),EP=Object.freeze(Object.defineProperty({__proto__:null,identity:DP},Symbol.toStringTag,{value:"Module"})),AP=Or({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),xP=Object.freeze(Object.defineProperty({__proto__:null,base2:AP},Symbol.toStringTag,{value:"Module"})),SP=Or({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),MP=Object.freeze(Object.defineProperty({__proto__:null,base8:SP},Symbol.toStringTag,{value:"Module"})),IP=Lc({prefix:"9",name:"base10",alphabet:"0123456789"}),CP=Object.freeze(Object.defineProperty({__proto__:null,base10:IP},Symbol.toStringTag,{value:"Module"})),PP=Or({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),OP=Or({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),TP=Object.freeze(Object.defineProperty({__proto__:null,base16:PP,base16upper:OP},Symbol.toStringTag,{value:"Module"})),RP=Or({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),NP=Or({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),BP=Or({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),$P=Or({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),UP=Or({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),qP=Or({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),LP=Or({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),FP=Or({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),zP=Or({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),jP=Object.freeze(Object.defineProperty({__proto__:null,base32:RP,base32hex:UP,base32hexpad:LP,base32hexpadupper:FP,base32hexupper:qP,base32pad:BP,base32padupper:$P,base32upper:NP,base32z:zP},Symbol.toStringTag,{value:"Module"})),kP=Lc({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),HP=Lc({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),KP=Object.freeze(Object.defineProperty({__proto__:null,base36:kP,base36upper:HP},Symbol.toStringTag,{value:"Module"})),VP=Lc({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),GP=Lc({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),JP=Object.freeze(Object.defineProperty({__proto__:null,base58btc:VP,base58flickr:GP},Symbol.toStringTag,{value:"Module"})),WP=Or({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),YP=Or({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),QP=Or({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),XP=Or({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),ZP=Object.freeze(Object.defineProperty({__proto__:null,base64:WP,base64pad:YP,base64url:QP,base64urlpad:XP},Symbol.toStringTag,{value:"Module"})),h2=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),eO=h2.reduce((r,e,t)=>(r[t]=e,r),[]),tO=h2.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function rO(r){return r.reduce((e,t)=>(e+=eO[t],e),"")}function iO(r){const e=[];for(const t of r){const i=tO[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}const nO=eh({prefix:"🚀",name:"base256emoji",encode:rO,decode:iO}),sO=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:nO},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const tb={...EP,...xP,...MP,...CP,...TP,...jP,...KP,...JP,...ZP,...sO};function l2(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}const rb=l2("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Yl=l2("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);const e=uP(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),aO={utf8:rb,"utf-8":rb,hex:tb.base16,latin1:Yl,ascii:Yl,binary:Yl,...tb};function oO(r,e="utf8"){const t=aO[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}const cO="PARSE_ERROR",uO="INVALID_REQUEST",fO="METHOD_NOT_FOUND",hO="INVALID_PARAMS",d2="INTERNAL_ERROR",d0="SERVER_ERROR",lO=[-32700,-32600,-32601,-32602,-32603],pc={[cO]:{code:-32700,message:"Parse error"},[uO]:{code:-32600,message:"Invalid Request"},[fO]:{code:-32601,message:"Method not found"},[hO]:{code:-32602,message:"Invalid params"},[d2]:{code:-32603,message:"Internal error"},[d0]:{code:-32e3,message:"Server error"}},p2=d0;function dO(r){return lO.includes(r)}function ib(r){return Object.keys(pc).includes(r)?pc[r]:pc[p2]}function pO(r){const e=Object.values(pc).find(t=>t.code===r);return e||pc[p2]}function g2(r,e,t){return r.message.includes("getaddrinfo ENOTFOUND")||r.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${t} RPC url at ${e}`):r}var b2={};/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var Cd=function(r,e){return Cd=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var n in i)i.hasOwnProperty(n)&&(t[n]=i[n])},Cd(r,e)};function gO(r,e){Cd(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var Pd=function(){return Pd=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++){t=arguments[i];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e},Pd.apply(this,arguments)};function bO(r,e){var t={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(r);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(r,i[n])&&(t[i[n]]=r[i[n]]);return t}function vO(r,e,t,i){var n=arguments.length,a=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,i);else for(var f=r.length-1;f>=0;f--)(c=r[f])&&(a=(n<3?c(a):n>3?c(e,t,a):c(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a}function mO(r,e){return function(t,i){e(t,i,r)}}function yO(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function wO(r,e,t,i){function n(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function f(m){try{d(i.next(m))}catch(w){c(w)}}function g(m){try{d(i.throw(m))}catch(w){c(w)}}function d(m){m.done?a(m.value):n(m.value).then(f,g)}d((i=i.apply(r,e||[])).next())})}function _O(r,e){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,n,a,c;return c={next:f(0),throw:f(1),return:f(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function f(d){return function(m){return g([d,m])}}function g(d){if(i)throw new TypeError("Generator is already executing.");for(;t;)try{if(i=1,n&&(a=d[0]&2?n.return:d[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,d[1])).done)return a;switch(n=0,a&&(d=[d[0]&2,a.value]),d[0]){case 0:case 1:a=d;break;case 4:return t.label++,{value:d[1],done:!1};case 5:t.label++,n=d[1],d=[0];continue;case 7:d=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(d[0]===6||d[0]===2)){t=0;continue}if(d[0]===3&&(!a||d[1]>a[0]&&d[1]<a[3])){t.label=d[1];break}if(d[0]===6&&t.label<a[1]){t.label=a[1],a=d;break}if(a&&t.label<a[2]){t.label=a[2],t.ops.push(d);break}a[2]&&t.ops.pop(),t.trys.pop();continue}d=e.call(r,t)}catch(m){d=[6,m],n=0}finally{i=a=0}if(d[0]&5)throw d[1];return{value:d[0]?d[1]:void 0,done:!0}}}function DO(r,e,t,i){i===void 0&&(i=t),r[i]=e[t]}function EO(r,e){for(var t in r)t!=="default"&&!e.hasOwnProperty(t)&&(e[t]=r[t])}function Od(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],i=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&i>=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function v2(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,a=[],c;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(f){c={error:f}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(c)throw c.error}}return a}function AO(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(v2(arguments[e]));return r}function xO(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var i=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],c=0,f=a.length;c<f;c++,n++)i[n]=a[c];return i}function Ac(r){return this instanceof Ac?(this.v=r,this):new Ac(r)}function SO(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(r,e||[]),n,a=[];return n={},c("next"),c("throw"),c("return"),n[Symbol.asyncIterator]=function(){return this},n;function c(O){i[O]&&(n[O]=function(C){return new Promise(function(P,q){a.push([O,C,P,q])>1||f(O,C)})})}function f(O,C){try{g(i[O](C))}catch(P){w(a[0][3],P)}}function g(O){O.value instanceof Ac?Promise.resolve(O.value.v).then(d,m):w(a[0][2],O)}function d(O){f("next",O)}function m(O){f("throw",O)}function w(O,C){O(C),a.shift(),a.length&&f(a[0][0],a[0][1])}}function MO(r){var e,t;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,a){e[n]=r[n]?function(c){return(t=!t)?{value:Ac(r[n](c)),done:n==="return"}:a?a(c):c}:a}}function IO(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof Od=="function"?Od(r):r[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(a){t[a]=r[a]&&function(c){return new Promise(function(f,g){c=r[a](c),n(f,g,c.done,c.value)})}}function n(a,c,f,g){Promise.resolve(g).then(function(d){a({value:d,done:f})},c)}}function CO(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function PO(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e}function OO(r){return r&&r.__esModule?r:{default:r}}function TO(r,e){if(!e.has(r))throw new TypeError("attempted to get private field on non-instance");return e.get(r)}function RO(r,e,t){if(!e.has(r))throw new TypeError("attempted to set private field on non-instance");return e.set(r,t),t}const NO=Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return Pd},__asyncDelegator:MO,__asyncGenerator:SO,__asyncValues:IO,__await:Ac,__awaiter:wO,__classPrivateFieldGet:TO,__classPrivateFieldSet:RO,__createBinding:DO,__decorate:vO,__exportStar:EO,__extends:gO,__generator:_O,__importDefault:OO,__importStar:PO,__makeTemplateObject:CO,__metadata:yO,__param:mO,__read:v2,__rest:bO,__spread:AO,__spreadArrays:xO,__values:Od},Symbol.toStringTag,{value:"Module"})),BO=ev(NO);var os={},nb;function $O(){if(nb)return os;nb=1,Object.defineProperty(os,"__esModule",{value:!0}),os.isBrowserCryptoAvailable=os.getSubtleCrypto=os.getBrowerCrypto=void 0;function r(){return(globalThis==null?void 0:globalThis.crypto)||(globalThis==null?void 0:globalThis.msCrypto)||{}}os.getBrowerCrypto=r;function e(){const i=r();return i.subtle||i.webkitSubtle}os.getSubtleCrypto=e;function t(){return!!r()&&!!e()}return os.isBrowserCryptoAvailable=t,os}var cs={},sb;function UO(){if(sb)return cs;sb=1;var r={env:{NODE_ENV:'"production"',VITE_WALLETCONNECT_PROJECT_ID:'"1d93edc21291f98e3bed6ff7617ff539"'},nextTick:"setImmediate",platform:'"browser"',version:'"v16.0.0"',browser:!0};Object.defineProperty(cs,"__esModule",{value:!0}),cs.isBrowser=cs.isNode=cs.isReactNative=void 0;function e(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}cs.isReactNative=e;function t(){return typeof r<"u"&&typeof r.versions<"u"&&typeof r.versions.node<"u"}cs.isNode=t;function i(){return!e()&&!t()}return cs.isBrowser=i,cs}(function(r){Object.defineProperty(r,"__esModule",{value:!0});const e=BO;e.__exportStar($O(),r),e.__exportStar(UO(),r)})(b2);function Bs(r=3){const e=Date.now()*Math.pow(10,r),t=Math.floor(Math.random()*Math.pow(10,r));return e+t}function da(r=6){return BigInt(Bs(r))}function Fs(r,e,t){return{id:t||Bs(),jsonrpc:"2.0",method:r,params:e}}function th(r,e){return{id:r,jsonrpc:"2.0",result:e}}function rh(r,e,t){return{id:r,jsonrpc:"2.0",error:qO(e)}}function qO(r,e){return typeof r>"u"?ib(d2):(typeof r=="string"&&(r=Object.assign(Object.assign({},ib(d0)),{message:r})),dO(r.code)&&(r=pO(r.code)),r)}class LO{}class FO extends LO{constructor(){super()}}class zO extends FO{constructor(e){super()}}const jO="^https?:",kO="^wss?:";function HO(r){const e=r.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function m2(r,e){const t=HO(r);return typeof t>"u"?!1:new RegExp(e).test(t)}function ab(r){return m2(r,jO)}function ob(r){return m2(r,kO)}function KO(r){return new RegExp("wss?://localhost(:d{2,5})?").test(r)}function y2(r){return typeof r=="object"&&"id"in r&&"jsonrpc"in r&&r.jsonrpc==="2.0"}function p0(r){return y2(r)&&"method"in r}function ih(r){return y2(r)&&(Cn(r)||ji(r))}function Cn(r){return"result"in r}function ji(r){return"error"in r}let vn=class extends zO{constructor(e){super(e),this.events=new Vi.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,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async request(e,t){return this.requestStrict(Fs(e.method,e.params||[],e.id||da().toString()),t)}async requestStrict(e,t){return new Promise(async(i,n)=>{if(!this.connection.connected)try{await this.open()}catch(a){n(a)}this.events.on(`${e.id}`,a=>{ji(a)?n(a.error):i(a.result)});try{await this.connection.send(e,t)}catch(a){n(a)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),ih(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 VO=()=>typeof WebSocket<"u"?WebSocket:typeof globalThis<"u"&&typeof globalThis.WebSocket<"u"?globalThis.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),GO=()=>typeof WebSocket<"u"||typeof globalThis<"u"&&typeof globalThis.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",cb=r=>r.split("?")[0],ub=10,JO=VO();let WO=class{constructor(e){if(this.url=e,this.events=new Vi.EventEmitter,this.registering=!1,!ob(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,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,t)=>{if(typeof this.socket>"u"){t(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(ys(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!ob(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise((i,n)=>{this.events.once("register_error",a=>{this.resetMaxListeners(),n(a)}),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((t,i)=>{const n=new URLSearchParams(e).get("origin"),a=b2.isReactNative()?{headers:{origin:n}}:{rejectUnauthorized:!KO(e)},c=new JO(e,[],a);GO()?c.onerror=f=>{const g=f;i(this.emitError(g.error))}:c.on("error",f=>{i(this.emitError(f))}),c.onopen=()=>{this.onOpen(c),t(c)}})}onOpen(e){e.onmessage=t=>this.onPayload(t),e.onclose=t=>this.onClose(t),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 t=typeof e.data=="string"?ma(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const i=this.parseError(t),n=i.message||i.toString(),a=rh(e,n);this.events.emit("payload",a)}parseError(e,t=this.url){return g2(e,cb(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>ub&&this.events.setMaxListeners(ub)}emitError(e){const t=this.parseError(new Error((e==null?void 0:e.message)||`WebSocket connection failed for host: ${cb(this.url)}`));return this.events.emit("register_error",t),t}};var If={exports:{}};If.exports;(function(r,e){var t=200,i="__lodash_hash_undefined__",n=1,a=2,c=9007199254740991,f="[object Arguments]",g="[object Array]",d="[object AsyncFunction]",m="[object Boolean]",w="[object Date]",O="[object Error]",C="[object Function]",P="[object GeneratorFunction]",q="[object Map]",K="[object Number]",Y="[object Null]",z="[object Object]",W="[object Promise]",B="[object Proxy]",j="[object RegExp]",k="[object Set]",_="[object String]",N="[object Symbol]",se="[object Undefined]",le="[object WeakMap]",U="[object ArrayBuffer]",y="[object DataView]",u="[object Float32Array]",h="[object Float64Array]",v="[object Int8Array]",E="[object Int16Array]",S="[object Int32Array]",M="[object Uint8Array]",x="[object Uint8ClampedArray]",p="[object Uint16Array]",b="[object Uint32Array]",R=/[\\^$.*+?()[\]{}|]/g,Z=/^\[object .+?Constructor\]$/,ae=/^(?:0|[1-9]\d*)$/,I={};I[u]=I[h]=I[v]=I[E]=I[S]=I[M]=I[x]=I[p]=I[b]=!0,I[f]=I[g]=I[U]=I[m]=I[y]=I[w]=I[O]=I[C]=I[q]=I[K]=I[z]=I[j]=I[k]=I[_]=I[le]=!1;var ee=typeof globalThis=="object"&&globalThis&&globalThis.Object===Object&&globalThis,L=typeof self=="object"&&self&&self.Object===Object&&self,V=ee||L||Function("return this")(),G=e&&!e.nodeType&&e,D=G&&!0&&r&&!r.nodeType&&r,H=D&&D.exports===G,ne=H&&ee.process,ce=function(){try{return ne&&ne.binding&&ne.binding("util")}catch{}}(),fe=ce&&ce.isTypedArray;function ye(J,te){for(var pe=-1,Le=J==null?0:J.length,jt=0,pt=[];++pe<Le;){var Wt=J[pe];te(Wt,pe,J)&&(pt[jt++]=Wt)}return pt}function we(J,te){for(var pe=-1,Le=te.length,jt=J.length;++pe<Le;)J[jt+pe]=te[pe];return J}function Te(J,te){for(var pe=-1,Le=J==null?0:J.length;++pe<Le;)if(te(J[pe],pe,J))return!0;return!1}function Qe(J,te){for(var pe=-1,Le=Array(J);++pe<J;)Le[pe]=te(pe);return Le}function Ce(J){return function(te){return J(te)}}function Re(J,te){return J.has(te)}function Se(J,te){return J==null?void 0:J[te]}function me(J){var te=-1,pe=Array(J.size);return J.forEach(function(Le,jt){pe[++te]=[jt,Le]}),pe}function Pe(J,te){return function(pe){return J(te(pe))}}function Ne(J){var te=-1,pe=Array(J.size);return J.forEach(function(Le){pe[++te]=Le}),pe}var be=Array.prototype,Oe=Function.prototype,xe=Object.prototype,ve=V["__core-js_shared__"],qe=Oe.toString,Me=xe.hasOwnProperty,_e=function(){var J=/[^.]+$/.exec(ve&&ve.keys&&ve.keys.IE_PROTO||"");return J?"Symbol(src)_1."+J:""}(),He=xe.toString,Ve=RegExp("^"+qe.call(Me).replace(R,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ee=H?V.Buffer:void 0,Ke=V.Symbol,ht=V.Uint8Array,Ge=xe.propertyIsEnumerable,_t=be.splice,lt=Ke?Ke.toStringTag:void 0,We=Object.getOwnPropertySymbols,Et=Ee?Ee.isBuffer:void 0,St=Pe(Object.keys,Object),Be=gi(V,"DataView"),Xe=gi(V,"Map"),tt=gi(V,"Promise"),$e=gi(V,"Set"),et=gi(V,"WeakMap"),Ze=gi(Object,"create"),Fe=Yn(Be),ut=Yn(Xe),rt=Yn(tt),ze=Yn($e),it=Yn(et),st=Ke?Ke.prototype:void 0,Ue=st?st.valueOf:void 0;function Ye(J){var te=-1,pe=J==null?0:J.length;for(this.clear();++te<pe;){var Le=J[te];this.set(Le[0],Le[1])}}function ft(){this.__data__=Ze?Ze(null):{},this.size=0}function je(J){var te=this.has(J)&&delete this.__data__[J];return this.size-=te?1:0,te}function Rt(J){var te=this.__data__;if(Ze){var pe=te[J];return pe===i?void 0:pe}return Me.call(te,J)?te[J]:void 0}function Nt(J){var te=this.__data__;return Ze?te[J]!==void 0:Me.call(te,J)}function at(J,te){var pe=this.__data__;return this.size+=this.has(J)?0:1,pe[J]=Ze&&te===void 0?i:te,this}Ye.prototype.clear=ft,Ye.prototype.delete=je,Ye.prototype.get=Rt,Ye.prototype.has=Nt,Ye.prototype.set=at;function vt(J){var te=-1,pe=J==null?0:J.length;for(this.clear();++te<pe;){var Le=J[te];this.set(Le[0],Le[1])}}function Rr(){this.__data__=[],this.size=0}function Nr(J){var te=this.__data__,pe=Vs(te,J);if(pe<0)return!1;var Le=te.length-1;return pe==Le?te.pop():_t.call(te,pe,1),--this.size,!0}function Br(J){var te=this.__data__,pe=Vs(te,J);return pe<0?void 0:te[pe][1]}function $r(J){return Vs(this.__data__,J)>-1}function Ur(J,te){var pe=this.__data__,Le=Vs(pe,J);return Le<0?(++this.size,pe.push([J,te])):pe[Le][1]=te,this}vt.prototype.clear=Rr,vt.prototype.delete=Nr,vt.prototype.get=Br,vt.prototype.has=$r,vt.prototype.set=Ur;function er(J){var te=-1,pe=J==null?0:J.length;for(this.clear();++te<pe;){var Le=J[te];this.set(Le[0],Le[1])}}function Xr(){this.size=0,this.__data__={hash:new Ye,map:new(Xe||vt),string:new Ye}}function Wi(J){var te=_s(this,J).delete(J);return this.size-=te?1:0,te}function Zr(J){return _s(this,J).get(J)}function Yi(J){return _s(this,J).has(J)}function Qi(J,te){var pe=_s(this,J),Le=pe.size;return pe.set(J,te),this.size+=pe.size==Le?0:1,this}er.prototype.clear=Xr,er.prototype.delete=Wi,er.prototype.get=Zr,er.prototype.has=Yi,er.prototype.set=Qi;function ei(J){var te=-1,pe=J==null?0:J.length;for(this.__data__=new er;++te<pe;)this.add(J[te])}function Mi(J){return this.__data__.set(J,i),this}function Ii(J){return this.__data__.has(J)}ei.prototype.add=ei.prototype.push=Mi,ei.prototype.has=Ii;function lr(J){var te=this.__data__=new vt(J);this.size=te.size}function Xi(){this.__data__=new vt,this.size=0}function Zi(J){var te=this.__data__,pe=te.delete(J);return this.size=te.size,pe}function en(J){return this.__data__.get(J)}function Ks(J){return this.__data__.has(J)}function zc(J,te){var pe=this.__data__;if(pe instanceof vt){var Le=pe.__data__;if(!Xe||Le.length<t-1)return Le.push([J,te]),this.size=++pe.size,this;pe=this.__data__=new er(Le)}return pe.set(J,te),this.size=pe.size,this}lr.prototype.clear=Xi,lr.prototype.delete=Zi,lr.prototype.get=en,lr.prototype.has=Ks,lr.prototype.set=zc;function jc(J,te){var pe=Ta(J),Le=!pe&&eu(J),jt=!pe&&!Le&&Po(J),pt=!pe&&!Le&&!jt&&iu(J),Wt=pe||Le||jt||pt,fr=Wt?Qe(J.length,String):[],Ot=fr.length;for(var kt in J)Me.call(J,kt)&&!(Wt&&(kt=="length"||jt&&(kt=="offset"||kt=="parent")||pt&&(kt=="buffer"||kt=="byteLength"||kt=="byteOffset")||Wc(kt,Ot)))&&fr.push(kt);return fr}function Vs(J,te){for(var pe=J.length;pe--;)if(Zc(J[pe][0],te))return pe;return-1}function Io(J,te,pe){var Le=te(J);return Ta(J)?Le:we(Le,pe(J))}function Gs(J){return J==null?J===void 0?se:Y:lt&&lt in Object(J)?Gc(J):ch(J)}function Co(J){return Ws(J)&&Gs(J)==f}function Js(J,te,pe,Le,jt){return J===te?!0:J==null||te==null||!Ws(J)&&!Ws(te)?J!==J&&te!==te:kc(J,te,pe,Le,Js,jt)}function kc(J,te,pe,Le,jt,pt){var Wt=Ta(J),fr=Ta(te),Ot=Wt?g:yn(J),kt=fr?g:yn(te);Ot=Ot==f?z:Ot,kt=kt==f?z:kt;var sr=Ot==z,ti=kt==z,hr=Ot==kt;if(hr&&Po(J)){if(!Po(te))return!1;Wt=!0,sr=!1}if(hr&&!sr)return pt||(pt=new lr),Wt||iu(J)?Pa(J,te,pe,Le,jt,pt):oh(J,te,Ot,pe,Le,jt,pt);if(!(pe&n)){var Yt=sr&&Me.call(J,"__wrapped__"),kr=ti&&Me.call(te,"__wrapped__");if(Yt||kr){var tn=Yt?J.value():J,Ci=kr?te.value():te;return pt||(pt=new lr),jt(tn,Ci,pe,Le,pt)}}return hr?(pt||(pt=new lr),Vc(J,te,pe,Le,jt,pt)):!1}function ah(J){if(!ru(J)||Qc(J))return!1;var te=Ra(J)?Ve:Z;return te.test(Yn(J))}function Hc(J){return Ws(J)&&tu(J.length)&&!!I[Gs(J)]}function Kc(J){if(!Xc(J))return St(J);var te=[];for(var pe in Object(J))Me.call(J,pe)&&pe!="constructor"&&te.push(pe);return te}function Pa(J,te,pe,Le,jt,pt){var Wt=pe&n,fr=J.length,Ot=te.length;if(fr!=Ot&&!(Wt&&Ot>fr))return!1;var kt=pt.get(J);if(kt&&pt.get(te))return kt==te;var sr=-1,ti=!0,hr=pe&a?new ei:void 0;for(pt.set(J,te),pt.set(te,J);++sr<fr;){var Yt=J[sr],kr=te[sr];if(Le)var tn=Wt?Le(kr,Yt,sr,te,J,pt):Le(Yt,kr,sr,J,te,pt);if(tn!==void 0){if(tn)continue;ti=!1;break}if(hr){if(!Te(te,function(Ci,wn){if(!Re(hr,wn)&&(Yt===Ci||jt(Yt,Ci,pe,Le,pt)))return hr.push(wn)})){ti=!1;break}}else if(!(Yt===kr||jt(Yt,kr,pe,Le,pt))){ti=!1;break}}return pt.delete(J),pt.delete(te),ti}function oh(J,te,pe,Le,jt,pt,Wt){switch(pe){case y:if(J.byteLength!=te.byteLength||J.byteOffset!=te.byteOffset)return!1;J=J.buffer,te=te.buffer;case U:return!(J.byteLength!=te.byteLength||!pt(new ht(J),new ht(te)));case m:case w:case K:return Zc(+J,+te);case O:return J.name==te.name&&J.message==te.message;case j:case _:return J==te+"";case q:var fr=me;case k:var Ot=Le&n;if(fr||(fr=Ne),J.size!=te.size&&!Ot)return!1;var kt=Wt.get(J);if(kt)return kt==te;Le|=a,Wt.set(J,te);var sr=Pa(fr(J),fr(te),Le,jt,pt,Wt);return Wt.delete(J),sr;case N:if(Ue)return Ue.call(J)==Ue.call(te)}return!1}function Vc(J,te,pe,Le,jt,pt){var Wt=pe&n,fr=Oa(J),Ot=fr.length,kt=Oa(te),sr=kt.length;if(Ot!=sr&&!Wt)return!1;for(var ti=Ot;ti--;){var hr=fr[ti];if(!(Wt?hr in te:Me.call(te,hr)))return!1}var Yt=pt.get(J);if(Yt&&pt.get(te))return Yt==te;var kr=!0;pt.set(J,te),pt.set(te,J);for(var tn=Wt;++ti<Ot;){hr=fr[ti];var Ci=J[hr],wn=te[hr];if(Le)var Oo=Wt?Le(wn,Ci,hr,te,J,pt):Le(Ci,wn,hr,J,te,pt);if(!(Oo===void 0?Ci===wn||jt(Ci,wn,pe,Le,pt):Oo)){kr=!1;break}tn||(tn=hr=="constructor")}if(kr&&!tn){var Ys=J.constructor,vr=te.constructor;Ys!=vr&&"constructor"in J&&"constructor"in te&&!(typeof Ys=="function"&&Ys instanceof Ys&&typeof vr=="function"&&vr instanceof vr)&&(kr=!1)}return pt.delete(J),pt.delete(te),kr}function Oa(J){return Io(J,hh,Jc)}function _s(J,te){var pe=J.__data__;return Yc(te)?pe[typeof te=="string"?"string":"hash"]:pe.map}function gi(J,te){var pe=Se(J,te);return ah(pe)?pe:void 0}function Gc(J){var te=Me.call(J,lt),pe=J[lt];try{J[lt]=void 0;var Le=!0}catch{}var jt=He.call(J);return Le&&(te?J[lt]=pe:delete J[lt]),jt}var Jc=We?function(J){return J==null?[]:(J=Object(J),ye(We(J),function(te){return Ge.call(J,te)}))}:zt,yn=Gs;(Be&&yn(new Be(new ArrayBuffer(1)))!=y||Xe&&yn(new Xe)!=q||tt&&yn(tt.resolve())!=W||$e&&yn(new $e)!=k||et&&yn(new et)!=le)&&(yn=function(J){var te=Gs(J),pe=te==z?J.constructor:void 0,Le=pe?Yn(pe):"";if(Le)switch(Le){case Fe:return y;case ut:return q;case rt:return W;case ze:return k;case it:return le}return te});function Wc(J,te){return te=te??c,!!te&&(typeof J=="number"||ae.test(J))&&J>-1&&J%1==0&&J<te}function Yc(J){var te=typeof J;return te=="string"||te=="number"||te=="symbol"||te=="boolean"?J!=="__proto__":J===null}function Qc(J){return!!_e&&_e in J}function Xc(J){var te=J&&J.constructor,pe=typeof te=="function"&&te.prototype||xe;return J===pe}function ch(J){return He.call(J)}function Yn(J){if(J!=null){try{return qe.call(J)}catch{}try{return J+""}catch{}}return""}function Zc(J,te){return J===te||J!==J&&te!==te}var eu=Co(function(){return arguments}())?Co:function(J){return Ws(J)&&Me.call(J,"callee")&&!Ge.call(J,"callee")},Ta=Array.isArray;function uh(J){return J!=null&&tu(J.length)&&!Ra(J)}var Po=Et||Ft;function fh(J,te){return Js(J,te)}function Ra(J){if(!ru(J))return!1;var te=Gs(J);return te==C||te==P||te==d||te==B}function tu(J){return typeof J=="number"&&J>-1&&J%1==0&&J<=c}function ru(J){var te=typeof J;return J!=null&&(te=="object"||te=="function")}function Ws(J){return J!=null&&typeof J=="object"}var iu=fe?Ce(fe):Hc;function hh(J){return uh(J)?jc(J):Kc(J)}function zt(){return[]}function Ft(){return!1}r.exports=fh})(If,If.exports);var YO=If.exports;const QO=Ld(YO),w2="wc",_2=2,g0="core",Kn=`${w2}@2:${g0}:`,XO={name:g0,logger:"error"},ZO={database:":memory:"},eT="crypto",fb="client_ed25519_seed",tT=Ae.ONE_DAY,rT="keychain",iT="0.3",nT="messages",sT="0.3",aT=Ae.SIX_HOURS,oT="publisher",D2="irn",cT="error",E2="wss://relay.walletconnect.org",uT="relayer",Jr={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"},fT="_subscription",Li={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},hT=.1,Td="2.17.0",Kt={link_mode:"link_mode",relay:"relay"},lT="0.3",dT="WALLETCONNECT_CLIENT_ID",hb="WALLETCONNECT_LINK_MODE_APPS",Pn={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},pT="subscription",gT="0.3",bT=Ae.FIVE_SECONDS*1e3,vT="pairing",mT="0.3",rc={wc_pairingDelete:{req:{ttl:Ae.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:Ae.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:Ae.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:Ae.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:Ae.ONE_DAY,prompt:!1,tag:0},res:{ttl:Ae.ONE_DAY,prompt:!1,tag:0}}},ha={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},un={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},yT="history",wT="0.3",_T="expirer",Fi={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},DT="0.3",ET="verify-api",AT="https://verify.walletconnect.com",A2="https://verify.walletconnect.org",gc=A2,xT=`${gc}/v3`,ST=[AT,A2],MT="echo",IT="https://echo.walletconnect.com",Sn={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"},us={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"},fn={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"},ca={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"},ua={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"},ic={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"},CT=.1,PT="event-client",OT=86400,TT="https://pulse.walletconnect.org/batch";function RT(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i<t.length;i++)t[i]=255;for(var n=0;n<r.length;n++){var a=r.charAt(n),c=a.charCodeAt(0);if(t[c]!==255)throw new TypeError(a+" is ambiguous");t[c]=n}var f=r.length,g=r.charAt(0),d=Math.log(f)/Math.log(256),m=Math.log(256)/Math.log(f);function w(P){if(P instanceof Uint8Array||(ArrayBuffer.isView(P)?P=new Uint8Array(P.buffer,P.byteOffset,P.byteLength):Array.isArray(P)&&(P=Uint8Array.from(P))),!(P instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(P.length===0)return"";for(var q=0,K=0,Y=0,z=P.length;Y!==z&&P[Y]===0;)Y++,q++;for(var W=(z-Y)*m+1>>>0,B=new Uint8Array(W);Y!==z;){for(var j=P[Y],k=0,_=W-1;(j!==0||k<K)&&_!==-1;_--,k++)j+=256*B[_]>>>0,B[_]=j%f>>>0,j=j/f>>>0;if(j!==0)throw new Error("Non-zero carry");K=k,Y++}for(var N=W-K;N!==W&&B[N]===0;)N++;for(var se=g.repeat(q);N<W;++N)se+=r.charAt(B[N]);return se}function O(P){if(typeof P!="string")throw new TypeError("Expected String");if(P.length===0)return new Uint8Array;var q=0;if(P[q]!==" "){for(var K=0,Y=0;P[q]===g;)K++,q++;for(var z=(P.length-q)*d+1>>>0,W=new Uint8Array(z);P[q];){var B=t[P.charCodeAt(q)];if(B===255)return;for(var j=0,k=z-1;(B!==0||j<Y)&&k!==-1;k--,j++)B+=f*W[k]>>>0,W[k]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");Y=j,q++}if(P[q]!==" "){for(var _=z-Y;_!==z&&W[_]===0;)_++;for(var N=new Uint8Array(K+(z-_)),se=K;_!==z;)N[se++]=W[_++];return N}}}function C(P){var q=O(P);if(q)return q;throw new Error(`Non-${e} character`)}return{encode:w,decodeUnsafe:O,decode:C}}var NT=RT,BT=NT;const x2=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},$T=r=>new TextEncoder().encode(r),UT=r=>new TextDecoder().decode(r);class qT{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class LT{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.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 S2(this,e)}}class FT{constructor(e){this.decoders=e}or(e){return S2(this,e)}decode(e){const t=e[0],i=this.decoders[t];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 S2=(r,e)=>new FT({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}});class zT{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new qT(e,t,i),this.decoder=new LT(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const nh=({name:r,prefix:e,encode:t,decode:i})=>new zT(r,e,t,i),Fc=({prefix:r,name:e,alphabet:t})=>{const{encode:i,decode:n}=BT(t,e);return nh({prefix:r,name:e,encode:i,decode:a=>x2(n(a))})},jT=(r,e,t,i)=>{const n={};for(let m=0;m<e.length;++m)n[e[m]]=m;let a=r.length;for(;r[a-1]==="=";)--a;const c=new Uint8Array(a*t/8|0);let f=0,g=0,d=0;for(let m=0;m<a;++m){const w=n[r[m]];if(w===void 0)throw new SyntaxError(`Non-${i} character`);g=g<<t|w,f+=t,f>=8&&(f-=8,c[d++]=255&g>>f)}if(f>=t||255&g<<8-f)throw new SyntaxError("Unexpected end of data");return c},kT=(r,e,t)=>{const i=e[e.length-1]==="=",n=(1<<t)-1;let a="",c=0,f=0;for(let g=0;g<r.length;++g)for(f=f<<8|r[g],c+=8;c>t;)c-=t,a+=e[n&f>>c];if(c&&(a+=e[n&f<<t-c]),i)for(;a.length*t&7;)a+="=";return a},Tr=({name:r,prefix:e,bitsPerChar:t,alphabet:i})=>nh({prefix:e,name:r,encode(n){return kT(n,i,t)},decode(n){return jT(n,i,t,r)}}),HT=nh({prefix:"\0",name:"identity",encode:r=>UT(r),decode:r=>$T(r)});var KT=Object.freeze({__proto__:null,identity:HT});const VT=Tr({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var GT=Object.freeze({__proto__:null,base2:VT});const JT=Tr({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var WT=Object.freeze({__proto__:null,base8:JT});const YT=Fc({prefix:"9",name:"base10",alphabet:"0123456789"});var QT=Object.freeze({__proto__:null,base10:YT});const XT=Tr({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ZT=Tr({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var eR=Object.freeze({__proto__:null,base16:XT,base16upper:ZT});const tR=Tr({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),rR=Tr({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),iR=Tr({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),nR=Tr({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),sR=Tr({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),aR=Tr({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),oR=Tr({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),cR=Tr({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),uR=Tr({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var fR=Object.freeze({__proto__:null,base32:tR,base32upper:rR,base32pad:iR,base32padupper:nR,base32hex:sR,base32hexupper:aR,base32hexpad:oR,base32hexpadupper:cR,base32z:uR});const hR=Fc({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),lR=Fc({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var dR=Object.freeze({__proto__:null,base36:hR,base36upper:lR});const pR=Fc({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),gR=Fc({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var bR=Object.freeze({__proto__:null,base58btc:pR,base58flickr:gR});const vR=Tr({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),mR=Tr({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),yR=Tr({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),wR=Tr({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var _R=Object.freeze({__proto__:null,base64:vR,base64pad:mR,base64url:yR,base64urlpad:wR});const M2=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),DR=M2.reduce((r,e,t)=>(r[t]=e,r),[]),ER=M2.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function AR(r){return r.reduce((e,t)=>(e+=DR[t],e),"")}function xR(r){const e=[];for(const t of r){const i=ER[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}const SR=nh({prefix:"🚀",name:"base256emoji",encode:AR,decode:xR});var MR=Object.freeze({__proto__:null,base256emoji:SR}),IR=I2,lb=128,CR=127,PR=~CR,OR=Math.pow(2,31);function I2(r,e,t){e=e||[],t=t||0;for(var i=t;r>=OR;)e[t++]=r&255|lb,r/=128;for(;r&PR;)e[t++]=r&255|lb,r>>>=7;return e[t]=r|0,I2.bytes=t-i+1,e}var TR=Rd,RR=128,db=127;function Rd(r,i){var t=0,i=i||0,n=0,a=i,c,f=r.length;do{if(a>=f)throw Rd.bytes=0,new RangeError("Could not decode varint");c=r[a++],t+=n<28?(c&db)<<n:(c&db)*Math.pow(2,n),n+=7}while(c>=RR);return Rd.bytes=a-i,t}var NR=Math.pow(2,7),BR=Math.pow(2,14),$R=Math.pow(2,21),UR=Math.pow(2,28),qR=Math.pow(2,35),LR=Math.pow(2,42),FR=Math.pow(2,49),zR=Math.pow(2,56),jR=Math.pow(2,63),kR=function(r){return r<NR?1:r<BR?2:r<$R?3:r<UR?4:r<qR?5:r<LR?6:r<FR?7:r<zR?8:r<jR?9:10},HR={encode:IR,decode:TR,encodingLength:kR},C2=HR;const pb=(r,e,t=0)=>(C2.encode(r,e,t),e),gb=r=>C2.encodingLength(r),Nd=(r,e)=>{const t=e.byteLength,i=gb(r),n=i+gb(t),a=new Uint8Array(n+t);return pb(r,a,0),pb(t,a,i),a.set(e,n),new KR(r,t,e,a)};class KR{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}}const P2=({name:r,code:e,encode:t})=>new VR(r,e,t);class VR{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?Nd(this.code,t):t.then(i=>Nd(this.code,i))}else throw Error("Unknown type, must be binary type")}}const O2=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),GR=P2({name:"sha2-256",code:18,encode:O2("SHA-256")}),JR=P2({name:"sha2-512",code:19,encode:O2("SHA-512")});var WR=Object.freeze({__proto__:null,sha256:GR,sha512:JR});const T2=0,YR="identity",R2=x2,QR=r=>Nd(T2,R2(r)),XR={code:T2,name:YR,encode:R2,digest:QR};var ZR=Object.freeze({__proto__:null,identity:XR});new TextEncoder,new TextDecoder;const bb={...KT,...GT,...WT,...QT,...eR,...fR,...dR,...bR,..._R,...MR};({...WR,...ZR});function eN(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function N2(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}const vb=N2("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Ql=N2("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);const e=eN(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),tN={utf8:vb,"utf-8":vb,hex:bb.base16,latin1:Ql,ascii:Ql,binary:Ql,...bb};function rN(r,e="utf8"){const t=tN[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r,"utf8"):t.decoder.decode(`${t.prefix}${r}`)}class iN{constructor(e,t){this.core=e,this.logger=t,this.keychain=new Map,this.name=rT,this.version=iT,this.initialized=!1,this.storagePrefix=Kn,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:a}=De("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(a)}return n},this.del=async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()},this.core=e,this.logger=Qr(t,this.name)}get context(){return pi(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,u3(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?f3(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=De("NOT_INITIALIZED",this.name);throw new Error(e)}}}class nN{constructor(e,t,i){this.core=e,this.logger=t,this.name=eT,this.randomSessionIdentifier=xd(),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(),a=Q1(n);return s3(a.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const n=jM();return this.setPrivateKey(n.publicKey,n.privateKey)},this.signJWT=async n=>{this.isInitialized();const a=await this.getClientSeed(),c=Q1(a),f=this.randomSessionIdentifier;return await EA(f,n,tT,c)},this.generateSharedKey=(n,a,c)=>{this.isInitialized();const f=this.getPrivateKey(n),g=kM(f,a);return this.setSymKey(g,c)},this.setSymKey=async(n,a)=>{this.isInitialized();const c=a||cf(n);return await this.keychain.set(c,n),c},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,a,c)=>{this.isInitialized();const f=t2(c),g=ys(a);if(Ng(f))return KM(g,c==null?void 0:c.encoding);if(Rg(f)){const O=f.senderPublicKey,C=f.receiverPublicKey;n=await this.generateSharedKey(O,C)}const d=this.getSymKey(n),{type:m,senderPublicKey:w}=f;return HM({type:m,symKey:d,message:g,senderPublicKey:w,encoding:c==null?void 0:c.encoding})},this.decode=async(n,a,c)=>{this.isInitialized();const f=JM(a,c);if(Ng(f)){const g=GM(a,c==null?void 0:c.encoding);return ma(g)}if(Rg(f)){const g=f.receiverPublicKey,d=f.senderPublicKey;n=await this.generateSharedKey(g,d)}try{const g=this.getSymKey(n),d=VM({symKey:g,encoded:a,encoding:c==null?void 0:c.encoding});return ma(d)}catch(g){this.logger.error(`Failed to decode message from topic: '${n}', clientId: '${await this.getClientId()}'`),this.logger.error(g)}},this.getPayloadType=(n,a=Ls)=>{const c=wc({encoded:n,encoding:a});return wa(c.type)},this.getPayloadSenderPublicKey=(n,a=Ls)=>{const c=wc({encoded:n,encoding:a});return c.senderPublicKey?oO(c.senderPublicKey,Yr):void 0},this.core=e,this.logger=Qr(t,this.name),this.keychain=i||new iN(this.core,this.logger)}get context(){return pi(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(fb)}catch{e=xd(),await this.keychain.set(fb,e)}return rN(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=De("NOT_INITIALIZED",this.name);throw new Error(e)}}}class sN extends XC{constructor(e,t){super(e,t),this.logger=e,this.core=t,this.messages=new Map,this.name=nT,this.version=sT,this.initialized=!1,this.storagePrefix=Kn,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 a=hs(n);let c=this.messages.get(i);return typeof c>"u"&&(c={}),typeof c[a]<"u"||(c[a]=n,this.messages.set(i,c),await this.persist()),a},this.get=i=>{this.isInitialized();let n=this.messages.get(i);return typeof n>"u"&&(n={}),n},this.has=(i,n)=>{this.isInitialized();const a=this.get(i),c=hs(n);return typeof a[c]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()},this.logger=Qr(e,this.name),this.core=t}get context(){return pi(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,u3(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?f3(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=De("NOT_INITIALIZED",this.name);throw new Error(e)}}}class aN extends ZC{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.events=new Vi.EventEmitter,this.name=oT,this.queue=new Map,this.publishTimeout=Ae.toMiliseconds(Ae.ONE_MINUTE),this.failedPublishTimeout=Ae.toMiliseconds(Ae.ONE_SECOND),this.needsTransportRestart=!1,this.publish=async(i,n,a)=>{var c;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:n,opts:a}});const f=(a==null?void 0:a.ttl)||aT,g=Sd(a),d=(a==null?void 0:a.prompt)||!1,m=(a==null?void 0:a.tag)||0,w=(a==null?void 0:a.id)||da().toString(),O={topic:i,message:n,opts:{ttl:f,relay:g,prompt:d,tag:m,id:w,attestation:a==null?void 0:a.attestation}},C=`Failed to publish payload, please try again. id:${w} tag:${m}`,P=Date.now();let q,K=1;try{for(;q===void 0;){if(Date.now()-P>this.publishTimeout)throw new Error(C);this.logger.trace({id:w,attempts:K},`publisher.publish - attempt ${K}`),q=await await ro(this.rpcPublish(i,n,f,g,d,m,w,a==null?void 0:a.attestation).catch(Y=>this.logger.warn(Y)),this.publishTimeout,C),K++,q||await new Promise(Y=>setTimeout(Y,this.failedPublishTimeout))}this.relayer.events.emit(Jr.publish,O),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{id:w,topic:i,message:n,opts:a}})}catch(Y){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(Y),(c=a==null?void 0:a.internal)!=null&&c.throwOnFailedPublish)throw Y;this.queue.set(w,O)}},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=Qr(t,this.name),this.registerEventListeners()}get context(){return pi(this.logger)}rpcPublish(e,t,i,n,a,c,f,g){var d,m,w,O;const C={method:cc(n.protocol).publish,params:{topic:e,message:t,ttl:i,prompt:a,tag:c,attestation:g},id:f};return fi((d=C.params)==null?void 0:d.prompt)&&((m=C.params)==null||delete m.prompt),fi((w=C.params)==null?void 0:w.tag)&&((O=C.params)==null||delete O.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:C}),this.relayer.request(C)}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{const{topic:t,message:i,opts:n}=e;await this.publish(t,i,n)})}registerEventListeners(){this.relayer.core.heartbeat.on(So.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Jr.connection_stalled);return}this.checkQueue()}),this.relayer.on(Jr.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}class oN{constructor(){this.map=new Map,this.set=(e,t)=>{const i=this.get(e);this.exists(e,t)||this.map.set(e,[...i,t])},this.get=e=>this.map.get(e)||[],this.exists=(e,t)=>this.get(e).includes(t),this.delete=(e,t)=>{if(typeof t>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const i=this.get(e);if(!this.exists(e,t))return;const n=i.filter(a=>a!==t);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 cN=Object.defineProperty,uN=Object.defineProperties,fN=Object.getOwnPropertyDescriptors,mb=Object.getOwnPropertySymbols,hN=Object.prototype.hasOwnProperty,lN=Object.prototype.propertyIsEnumerable,yb=(r,e,t)=>e in r?cN(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,nc=(r,e)=>{for(var t in e||(e={}))hN.call(e,t)&&yb(r,t,e[t]);if(mb)for(var t of mb(e))lN.call(e,t)&&yb(r,t,e[t]);return r},Xl=(r,e)=>uN(r,fN(e));class dN extends rP{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new oN,this.events=new Vi.EventEmitter,this.name=pT,this.version=gT,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=Kn,this.subscribeTimeout=Ae.toMiliseconds(Ae.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 a=Sd(n),c={topic:i,relay:a,transportType:n==null?void 0:n.transportType};this.pending.set(i,c);const f=await this.rpcSubscribe(i,a,n==null?void 0:n.transportType);return typeof f=="string"&&(this.onSubscribe(f,c),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}})),f}catch(a){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(a),a}},this.unsubscribe=async(i,n)=>{await this.restartToComplete(),this.isInitialized(),typeof(n==null?void 0: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((a,c)=>{const f=new Ae.Watch;f.start(n);const g=setInterval(()=>{!this.pending.has(i)&&this.topics.includes(i)&&(clearInterval(g),f.stop(n),a(!0)),f.elapsed(n)>=bT&&(clearInterval(g),f.stop(n),c(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=Qr(t,this.name),this.clientId=""}get context(){return pi(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,t){let i=!1;try{i=this.getSubscription(e).topic===t}catch{}return i}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){const i=this.topicMap.get(e);await Promise.all(i.map(async n=>await this.unsubscribeById(e,n,t)))}async unsubscribeById(e,t,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});try{const n=Sd(i);await this.rpcUnsubscribe(e,t,n);const a=Lt("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,a),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}})}catch(n){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(n),n}}async rpcSubscribe(e,t,i=Kt.relay){i===Kt.relay&&await this.restartToComplete();const n={method:cc(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});try{const a=hs(e+this.clientId);return i===Kt.link_mode?(setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(n).catch(c=>this.logger.warn(c))},Ae.toMiliseconds(Ae.ONE_SECOND)),a):await await ro(this.relayer.request(n).catch(c=>this.logger.warn(c)),this.subscribeTimeout)?a:null}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Jr.connection_stalled)}return null}async rpcBatchSubscribe(e){if(!e.length)return;const t=e[0].relay,i={method:cc(t.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 ro(this.relayer.request(i).catch(n=>this.logger.warn(n)),this.subscribeTimeout)}catch{this.relayer.events.emit(Jr.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const t=e[0].relay,i={method:cc(t.protocol).batchFetchMessages,params:{topics:e.map(a=>a.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let n;try{n=await await ro(this.relayer.request(i).catch(a=>this.logger.warn(a)),this.subscribeTimeout)}catch{this.relayer.events.emit(Jr.connection_stalled)}return n}rpcUnsubscribe(e,t,i){const n={method:cc(i.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),this.relayer.request(n)}onSubscribe(e,t){this.setSubscription(e,Xl(nc({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(t=>{this.setSubscription(t.id,nc({},t)),this.pending.delete(t.topic)})}async onUnsubscribe(e,t,i){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,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,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t)}addSubscription(e,t){this.subscriptions.set(e,nc({},t)),this.topicMap.set(t.topic,e),this.events.emit(Pn.created,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const{message:i}=De("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(Pn.deleted,Xl(nc({},i),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Pn.sync)}async reset(){if(this.cached.length){const e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let t=0;t<e;t++){const i=this.cached.splice(0,this.batchSubscribeTopicsLimit);await this.batchFetchMessages(i),await this.batchSubscribe(i)}}this.events.emit(Pn.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:t}=De("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(t)}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 t=await this.rpcBatchSubscribe(e);Hn(t)&&this.onBatchSubscribe(t.map((i,n)=>Xl(nc({},e[n]),{id:i})))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(this.pendingBatchMessages=this.pendingBatchMessages.concat(t.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(t=>{e.push(t)}),await this.batchSubscribe(e),this.pendingBatchMessages.length&&(await this.relayer.handleBatchMessageEvents(this.pendingBatchMessages),this.pendingBatchMessages=[])}registerEventListeners(){this.relayer.core.heartbeat.on(So.pulse,async()=>{await this.checkPending()}),this.events.on(Pn.created,async e=>{const t=Pn.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}),this.events.on(Pn.deleted,async e=>{const t=Pn.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=De("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 t=setInterval(()=>{this.restartInProgress||(clearInterval(t),e())},this.pollingInterval)})}}var pN=Object.defineProperty,wb=Object.getOwnPropertySymbols,gN=Object.prototype.hasOwnProperty,bN=Object.prototype.propertyIsEnumerable,_b=(r,e,t)=>e in r?pN(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,vN=(r,e)=>{for(var t in e||(e={}))gN.call(e,t)&&_b(r,t,e[t]);if(wb)for(var t of wb(e))bN.call(e,t)&&_b(r,t,e[t]);return r};class mN extends eP{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new Vi.EventEmitter,this.name=uT,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=Ae.toMiliseconds(Ae.THIRTY_SECONDS+Ae.ONE_SECOND),this.request=async t=>{var i,n;this.logger.debug("Publishing Request Payload");const a=t.id||da().toString();await this.toEstablishConnection();try{const c=this.provider.request(t);this.requestsInFlight.set(a,{promise:c,request:t}),this.logger.trace({id:a,method:t.method,topic:(i=t.params)==null?void 0:i.topic},"relayer.request - attempt to publish...");const f=await new Promise(async(g,d)=>{const m=()=>{d(new Error(`relayer.request - publish interrupted, id: ${a}`))};this.provider.on(Li.disconnect,m);const w=await c;this.provider.off(Li.disconnect,m),g(w)});return this.logger.trace({id:a,method:t.method,topic:(n=t.params)==null?void 0:n.topic},"relayer.request - published"),f}catch(c){throw this.logger.debug(`Failed to Publish Request: ${a}`),c}finally{this.requestsInFlight.delete(a)}},this.resetPingTimeout=()=>{if(yf())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var t,i,n;(n=(i=(t=this.provider)==null?void 0:t.connection)==null?void 0:i.socket)==null||n.terminate()},this.heartBeatTimeout)}catch(t){this.logger.warn(t)}},this.onPayloadHandler=t=>{this.onProviderPayload(t),this.resetPingTimeout()},this.onConnectHandler=()=>{this.logger.trace("relayer connected"),this.startPingTimeout(),this.events.emit(Jr.connect)},this.onDisconnectHandler=()=>{this.logger.trace("relayer disconnected"),this.onProviderDisconnect()},this.onProviderErrorHandler=t=>{this.logger.error(t),this.events.emit(Jr.error,t),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(Li.payload,this.onPayloadHandler),this.provider.on(Li.connect,this.onConnectHandler),this.provider.on(Li.disconnect,this.onDisconnectHandler),this.provider.on(Li.error,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?Qr(e.logger,this.name):Uc(Zf({level:e.logger||cT})),this.messages=new sN(this.logger,e.core),this.subscriber=new dN(this,this.logger),this.publisher=new aN(this,this.logger),this.relayUrl=(e==null?void 0:e.relayUrl)||E2,this.projectId=e.projectId,this.bundleId=TA(),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 pi(this.logger)}get connected(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===1}get connecting(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===0}async publish(e,t,i){this.isInitialized(),await this.publisher.publish(e,t,i),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:Kt.relay})}async subscribe(e,t){var i;this.isInitialized(),(t==null?void 0:t.transportType)==="relay"&&await this.toEstablishConnection();let n=((i=this.subscriber.topicMap.get(e))==null?void 0:i[0])||"",a;const c=f=>{f.topic===e&&(this.subscriber.off(Pn.created,c),a())};return await Promise.all([new Promise(f=>{a=f,this.subscriber.on(Pn.created,c)}),new Promise(async f=>{n=await this.subscriber.subscribe(e,t)||n,f()})]),n}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}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 ro(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(t,i)=>{const n=()=>{this.provider.off(Li.disconnect,n),i(new Error("Connection interrupted while trying to subscribe"))};this.provider.on(Li.disconnect,n),await ro(this.provider.connect(),Ae.toMiliseconds(Ae.ONE_MINUTE),`Socket stalled when trying to connect to ${this.relayUrl}`).catch(a=>{i(a)}).finally(()=>{clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0}),this.subscriber.start().catch(a=>{this.logger.error(a),this.onDisconnectHandler()}),this.hasExperiencedNetworkDisruption=!1,t()})}catch(t){this.logger.error(t);const i=t;if(this.hasExperiencedNetworkDisruption=!0,!this.isConnectionStalled(i.message))throw t}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 Kg())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if((e==null?void 0:e.length)===0){this.logger.trace("Batch message events is empty. Ignoring...");return}const t=e.sort((i,n)=>i.publishedAt-n.publishedAt);this.logger.trace(`Batch of ${t.length} message events sorted`);for(const i of t)try{await this.onMessageEvent(i)}catch(n){this.logger.warn(n)}this.logger.trace(`Batch of ${t.length} message events processed`)}async onLinkMessageEvent(e,t){const{topic:i}=e;if(!t.sessionExists){const n=br(Ae.FIVE_MINUTES),a={topic:i,expiry:n,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,a)}this.events.emit(Jr.message,e),await this.recordMessageEvent(e)}startPingTimeout(){var e,t,i,n,a;if(yf())try{(t=(e=this.provider)==null?void 0:e.connection)!=null&&t.socket&&((a=(n=(i=this.provider)==null?void 0:i.connection)==null?void 0:n.socket)==null||a.once("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(c){this.logger.warn(c)}}isConnectionStalled(e){return this.staleConnectionErrors.some(t=>e.includes(t))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new vn(new WO($A({sdkVersion:Td,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:t,message:i}=e;await this.messages.set(t,i)}async shouldIgnoreMessageEvent(e){const{topic:t,message:i}=e;if(!i||i.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.debug(`Ignoring message for non-subscribed topic ${t}`),!0;const n=this.messages.has(t,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}),p0(e)){if(!e.method.endsWith(fT))return;const t=e.params,{topic:i,message:n,publishedAt:a,attestation:c}=t.data,f={topic:i,message:n,publishedAt:a,transportType:Kt.relay,attestation:c};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(vN({type:"event",event:t.id},f)),this.events.emit(t.id,f),await this.acknowledgePayload(e),await this.onMessageEvent(f)}else ih(e)&&this.events.emit(Jr.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Jr.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const t=th(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(Li.payload,this.onPayloadHandler),this.provider.off(Li.connect,this.onConnectHandler),this.provider.off(Li.disconnect,this.onDisconnectHandler),this.provider.off(Li.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await Kg();zI(async t=>{e!==t&&(e=t,t?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(Jr.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e))},Ae.toMiliseconds(hT))))}isInitialized(){if(!this.initialized){const{message:e}=De("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&(this.connectionAttemptInProgress&&await new Promise(e=>{const t=setInterval(()=>{this.connected&&(clearInterval(t),e())},this.connectionStatusPollingInterval)}),await this.transportOpen())}}var yN=Object.defineProperty,Db=Object.getOwnPropertySymbols,wN=Object.prototype.hasOwnProperty,_N=Object.prototype.propertyIsEnumerable,Eb=(r,e,t)=>e in r?yN(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ab=(r,e)=>{for(var t in e||(e={}))wN.call(e,t)&&Eb(r,t,e[t]);if(Db)for(var t of Db(e))_N.call(e,t)&&Eb(r,t,e[t]);return r};class Ma extends tP{constructor(e,t,i,n=Kn,a=void 0){super(e,t,i,n),this.core=e,this.logger=t,this.name=i,this.map=new Map,this.version=lT,this.cached=[],this.initialized=!1,this.storagePrefix=Kn,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(c=>{this.getKey&&c!==null&&!fi(c)?this.map.set(this.getKey(c),c):mI(c)?this.map.set(c.id,c):yI(c)&&this.map.set(c.topic,c)}),this.cached=[],this.initialized=!0)},this.set=async(c,f)=>{this.isInitialized(),this.map.has(c)?await this.update(c,f):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:c,value:f}),this.map.set(c,f),await this.persist())},this.get=c=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:c}),this.getData(c)),this.getAll=c=>(this.isInitialized(),c?this.values.filter(f=>Object.keys(c).every(g=>QO(f[g],c[g]))):this.values),this.update=async(c,f)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:c,update:f});const g=Ab(Ab({},this.getData(c)),f);this.map.set(c,g),await this.persist()},this.delete=async(c,f)=>{this.isInitialized(),this.map.has(c)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:c,reason:f}),this.map.delete(c),this.addToRecentlyDeleted(c),await this.persist())},this.logger=Qr(t,this.name),this.storagePrefix=n,this.getKey=a}get context(){return pi(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 t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){const{message:n}=De("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}const{message:i}=De("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return t}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:t}=De("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}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}=De("NOT_INITIALIZED",this.name);throw new Error(e)}}}class DN{constructor(e,t){this.core=e,this.logger=t,this.name=vT,this.version=mT,this.events=new Fd,this.initialized=!1,this.storagePrefix=Kn,this.ignoredPayloadTypes=[bs],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=xd(),a=await this.core.crypto.setSymKey(n),c=br(Ae.FIVE_MINUTES),f={protocol:D2},g={topic:a,expiry:c,relay:f,active:!1,methods:i==null?void 0:i.methods},d=Lg({protocol:this.core.protocol,version:this.core.version,topic:a,symKey:n,relay:f,expiryTimestamp:c,methods:i==null?void 0:i.methods});return this.events.emit(ha.create,g),this.core.expirer.set(a,c),await this.pairings.set(a,g),await this.core.relayer.subscribe(a,{transportType:i==null?void 0:i.transportType}),{topic:a,uri:d}},this.pair=async i=>{this.isInitialized();const n=this.core.eventClient.createEvent({properties:{topic:i==null?void 0:i.uri,trace:[Sn.pairing_started]}});this.isValidPair(i,n);const{topic:a,symKey:c,relay:f,expiryTimestamp:g,methods:d}=qg(i.uri);n.props.properties.topic=a,n.addTrace(Sn.pairing_uri_validation_success),n.addTrace(Sn.pairing_uri_not_expired);let m;if(this.pairings.keys.includes(a)){if(m=this.pairings.get(a),n.addTrace(Sn.existing_pairing),m.active)throw n.setError(us.active_pairing_already_exists),new Error(`Pairing already exists: ${a}. Please try again with a new connection URI.`);n.addTrace(Sn.pairing_not_expired)}const w=g||br(Ae.FIVE_MINUTES),O={topic:a,relay:f,expiry:w,active:!1,methods:d};this.core.expirer.set(a,w),await this.pairings.set(a,O),n.addTrace(Sn.store_new_pairing),i.activatePairing&&await this.activate({topic:a}),this.events.emit(ha.create,O),n.addTrace(Sn.emit_inactive_pairing),this.core.crypto.keychain.has(a)||await this.core.crypto.setSymKey(c,a),n.addTrace(Sn.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{n.setError(us.no_internet_connection)}try{await this.core.relayer.subscribe(a,{relay:f})}catch(C){throw n.setError(us.subscribe_pairing_topic_failure),C}return n.addTrace(Sn.subscribe_pairing_topic_success),O},this.activate=async({topic:i})=>{this.isInitialized();const n=br(Ae.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 a=await this.sendRequest(n,"wc_pairingPing",{}),{done:c,resolve:f,reject:g}=fa();this.events.once(xt("pairing_ping",a),({error:d})=>{d?g(d):f()}),await c()}},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",Lt("USER_DISCONNECTED")),await this.deletePairing(n))},this.formatUriFromPairing=i=>{this.isInitialized();const{topic:n,relay:a,expiry:c,methods:f}=i,g=this.core.crypto.keychain.get(n);return Lg({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:g,relay:a,expiryTimestamp:c,methods:f})},this.sendRequest=async(i,n,a)=>{const c=Fs(n,a),f=await this.core.crypto.encode(i,c),g=rc[n].req;return this.core.history.set(i,c),this.core.relayer.publish(i,f,g),c.id},this.sendResult=async(i,n,a)=>{const c=th(i,a),f=await this.core.crypto.encode(n,c),g=await this.core.history.get(n,i),d=rc[g.request.method].res;await this.core.relayer.publish(n,f,d),await this.core.history.resolve(c)},this.sendError=async(i,n,a)=>{const c=rh(i,a),f=await this.core.crypto.encode(n,c),g=await this.core.history.get(n,i),d=rc[g.request.method]?rc[g.request.method].res:rc.unregistered_method.res;await this.core.relayer.publish(n,f,d),await this.core.history.resolve(c)},this.deletePairing=async(i,n)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,Lt("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=>Rs(n.expiry));await Promise.all(i.map(n=>this.deletePairing(n.topic)))},this.onRelayEventRequest=i=>{const{topic:n,payload:a}=i;switch(a.method){case"wc_pairingPing":return this.onPairingPingRequest(n,a);case"wc_pairingDelete":return this.onPairingDeleteRequest(n,a);default:return this.onUnknownRpcMethodRequest(n,a)}},this.onRelayEventResponse=async i=>{const{topic:n,payload:a}=i,c=(await this.core.history.get(n,a.id)).request.method;switch(c){case"wc_pairingPing":return this.onPairingPingResponse(n,a);default:return this.onUnknownRpcMethodResponse(c)}},this.onPairingPingRequest=async(i,n)=>{const{id:a}=n;try{this.isValidPing({topic:i}),await this.sendResult(a,i,!0),this.events.emit(ha.ping,{id:a,topic:i})}catch(c){await this.sendError(a,i,c),this.logger.error(c)}},this.onPairingPingResponse=(i,n)=>{const{id:a}=n;setTimeout(()=>{Cn(n)?this.events.emit(xt("pairing_ping",a),{}):ji(n)&&this.events.emit(xt("pairing_ping",a),{error:n.error})},500)},this.onPairingDeleteRequest=async(i,n)=>{const{id:a}=n;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(ha.delete,{id:a,topic:i})}catch(c){await this.sendError(a,i,c),this.logger.error(c)}},this.onUnknownRpcMethodRequest=async(i,n)=>{const{id:a,method:c}=n;try{if(this.registeredMethods.includes(c))return;const f=Lt("WC_METHOD_UNSUPPORTED",c);await this.sendError(a,i,f),this.logger.error(f)}catch(f){await this.sendError(a,i,f),this.logger.error(f)}},this.onUnknownRpcMethodResponse=i=>{this.registeredMethods.includes(i)||this.logger.error(Lt("WC_METHOD_UNSUPPORTED",i))},this.isValidPair=(i,n)=>{var a;if(!ci(i)){const{message:f}=De("MISSING_OR_INVALID",`pair() params: ${i}`);throw n.setError(us.malformed_pairing_uri),new Error(f)}if(!vI(i.uri)){const{message:f}=De("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw n.setError(us.malformed_pairing_uri),new Error(f)}const c=qg(i==null?void 0:i.uri);if(!((a=c==null?void 0:c.relay)!=null&&a.protocol)){const{message:f}=De("MISSING_OR_INVALID","pair() uri#relay-protocol");throw n.setError(us.malformed_pairing_uri),new Error(f)}if(!(c!=null&&c.symKey)){const{message:f}=De("MISSING_OR_INVALID","pair() uri#symKey");throw n.setError(us.malformed_pairing_uri),new Error(f)}if(c!=null&&c.expiryTimestamp&&Ae.toMiliseconds(c==null?void 0:c.expiryTimestamp)<Date.now()){n.setError(us.pairing_expired);const{message:f}=De("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(f)}},this.isValidPing=async i=>{if(!ci(i)){const{message:a}=De("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(a)}const{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidDisconnect=async i=>{if(!ci(i)){const{message:a}=De("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(a)}const{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidPairingTopic=async i=>{if(!ur(i,!1)){const{message:n}=De("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){const{message:n}=De("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(Rs(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:n}=De("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}},this.core=e,this.logger=Qr(t,this.name),this.pairings=new Ma(this.core,this.logger,this.name,this.storagePrefix)}get context(){return pi(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=De("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Jr.message,async e=>{const{topic:t,message:i,transportType:n}=e;if(!this.pairings.keys.includes(t)||n===Kt.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;const a=await this.core.crypto.decode(t,i);try{p0(a)?(this.core.history.set(t,a),this.onRelayEventRequest({topic:t,payload:a})):ih(a)&&(await this.core.history.resolve(a),await this.onRelayEventResponse({topic:t,payload:a}),this.core.history.delete(t,a.id))}catch(c){this.logger.error(c)}})}registerExpirerEvents(){this.core.expirer.on(Fi.expired,async e=>{const{topic:t}=l3(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(ha.expire,{topic:t}))})}}class EN extends QC{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.records=new Map,this.events=new Vi.EventEmitter,this.name=yT,this.version=wT,this.cached=[],this.initialized=!1,this.storagePrefix=Kn,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,a)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:n,chainId:a}),this.records.has(n.id))return;const c={id:n.id,topic:i,request:{method:n.method,params:n.params||null},chainId:a,expiry:br(Ae.THIRTY_DAYS)};this.records.set(c.id,c),this.persist(),this.events.emit(un.created,c)},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=ji(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.persist(),this.events.emit(un.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(a=>{if(a.topic===i){if(typeof n<"u"&&a.id!==n)return;this.records.delete(a.id),this.events.emit(un.deleted,a)}}),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=Qr(t,this.name)}get context(){return pi(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(t=>{if(typeof t.response<"u")return;const i={topic:t.topic,request:Fs(t.request.method,t.request.params,t.id),chainId:t.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 t=this.records.get(e);if(!t){const{message:i}=De("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(un.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:t}=De("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}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(un.created,e=>{const t=un.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(un.updated,e=>{const t=un.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(un.deleted,e=>{const t=un.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.core.heartbeat.on(So.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{Ae.toMiliseconds(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(un.deleted,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=De("NOT_INITIALIZED",this.name);throw new Error(e)}}}class AN extends iP{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.expirations=new Map,this.events=new Vi.EventEmitter,this.name=_T,this.version=DT,this.cached=[],this.initialized=!1,this.storagePrefix=Kn,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 a=this.formatTarget(i),c={target:a,expiry:n};this.expirations.set(a,c),this.checkExpiry(a,c),this.events.emit(Fi.created,{target:a,expiration:c})},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),a=this.getExpiration(n);this.expirations.delete(n),this.events.emit(Fi.deleted,{target:n,expiration:a})}},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=Qr(t,this.name)}get context(){return pi(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 UA(e);if(typeof e=="number")return qA(e);const{message:t}=De("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(t)}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(Fi.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:t}=De("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}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 t=this.expirations.get(e);if(!t){const{message:i}=De("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return t}checkExpiry(e,t){const{expiry:i}=t;Ae.toMiliseconds(i)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(Fi.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(So.pulse,()=>this.checkExpirations()),this.events.on(Fi.created,e=>{const t=Fi.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Fi.expired,e=>{const t=Fi.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Fi.deleted,e=>{const t=Fi.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=De("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Qt={};Object.defineProperty(Qt,"__esModule",{value:!0}),Qt.getLocalStorage=Qt.getLocalStorageOrThrow=Qt.getCrypto=Qt.getCryptoOrThrow=Qt.getLocation=Qt.getLocationOrThrow=Qt.getNavigator=Qt.getNavigatorOrThrow=B2=Qt.getDocument=Qt.getDocumentOrThrow=Qt.getFromWindowOrThrow=Qt.getFromWindow=void 0;function Ia(r){let e;return typeof window<"u"&&typeof window[r]<"u"&&(e=window[r]),e}Qt.getFromWindow=Ia;function Mo(r){const e=Ia(r);if(!e)throw new Error(`${r} is not defined in Window`);return e}Qt.getFromWindowOrThrow=Mo;function xN(){return Mo("document")}Qt.getDocumentOrThrow=xN;function SN(){return Ia("document")}var B2=Qt.getDocument=SN;function MN(){return Mo("navigator")}Qt.getNavigatorOrThrow=MN;function IN(){return Ia("navigator")}Qt.getNavigator=IN;function CN(){return Mo("location")}Qt.getLocationOrThrow=CN;function PN(){return Ia("location")}Qt.getLocation=PN;function ON(){return Mo("crypto")}Qt.getCryptoOrThrow=ON;function TN(){return Ia("crypto")}Qt.getCrypto=TN;function RN(){return Mo("localStorage")}Qt.getLocalStorageOrThrow=RN;function NN(){return Ia("localStorage")}Qt.getLocalStorage=NN;class BN extends nP{constructor(e,t,i){super(e,t,i),this.core=e,this.logger=t,this.store=i,this.name=ET,this.verifyUrlV3=xT,this.storagePrefix=Kn,this.version=_2,this.init=async()=>{var n;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&Ae.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(!Oc()||this.isDevEnv)return;const a=window.location.origin,{id:c,decryptedId:f}=n,g=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${a}&id=${c}&decryptedId=${f}`;try{const d=B2(),m=this.startAbortTimer(Ae.ONE_SECOND*5),w=await new Promise((O,C)=>{const P=()=>{window.removeEventListener("message",K),d.body.removeChild(q),C("attestation aborted")};this.abortController.signal.addEventListener("abort",P);const q=d.createElement("iframe");q.src=g,q.style.display="none",q.addEventListener("error",P,{signal:this.abortController.signal});const K=Y=>{if(Y.data&&typeof Y.data=="string")try{const z=JSON.parse(Y.data);if(z.type==="verify_attestation"){if(md(z.attestation).payload.id!==c)return;clearInterval(m),d.body.removeChild(q),this.abortController.signal.removeEventListener("abort",P),window.removeEventListener("message",K),O(z.attestation===null?"":z.attestation)}}catch(z){this.logger.warn(z)}};d.body.appendChild(q),window.addEventListener("message",K,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",w),w}catch(d){this.logger.warn(d)}return""},this.resolve=async n=>{if(this.isDevEnv)return"";const{attestationId:a,hash:c,encryptedId:f}=n;if(a===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(a){if(md(a).payload.id!==f)return;const d=await this.isValidJwtAttestation(a);if(d){if(!d.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return d}}if(!c)return;const g=this.getVerifyUrl(n==null?void 0:n.verifyUrl);return this.fetchAttestation(c,g)},this.fetchAttestation=async(n,a)=>{this.logger.debug(`resolving attestation: ${n} from url: ${a}`);const c=this.startAbortTimer(Ae.ONE_SECOND*5),f=await fetch(`${a}/attestation/${n}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(c),f.status===200?await f.json():void 0},this.getVerifyUrl=n=>{let a=n||gc;return ST.includes(a)||(this.logger.info(`verify url: ${a}, not included in trusted list, assigning default: ${gc}`),a=gc),a},this.fetchPublicKey=async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const n=this.startAbortTimer(Ae.FIVE_SECONDS),a=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(n),await a.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 a=await this.getPublicKey();try{if(a)return this.validateAttestation(n,a)}catch(f){this.logger.error(f),this.logger.warn("error validating attestation")}const c=await this.fetchAndPersistPublicKey();try{if(c)return this.validateAttestation(n,c)}catch(f){this.logger.error(f),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 a=>{const c=await this.fetchPublicKey();c&&(await this.persistPublicKey(c),a(c))});const n=await this.fetchPromise;return this.fetchPromise=void 0,n},this.validateAttestation=(n,a)=>{const c=XM(n,a.publicKey),f={hasExpired:Ae.toMiliseconds(c.exp)<Date.now(),payload:c};if(f.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:f.payload.origin,isScam:f.payload.isScam,isVerified:f.payload.isVerified}},this.logger=Qr(t,this.name),this.abortController=new AbortController,this.isDevEnv=r0(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return pi(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),Ae.toMiliseconds(e))}}class $N extends sP{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.context=MT,this.registerDeviceToken=async i=>{const{clientId:n,token:a,notificationType:c,enableEncrypted:f=!1}=i,g=`${IT}/${this.projectId}/clients`;await fetch(g,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:n,type:c,token:a,always_raw:f})})},this.logger=Qr(t,this.context)}}var UN=Object.defineProperty,xb=Object.getOwnPropertySymbols,qN=Object.prototype.hasOwnProperty,LN=Object.prototype.propertyIsEnumerable,Sb=(r,e,t)=>e in r?UN(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,sc=(r,e)=>{for(var t in e||(e={}))qN.call(e,t)&&Sb(r,t,e[t]);if(xb)for(var t of xb(e))LN.call(e,t)&&Sb(r,t,e[t]);return r};class FN extends aP{constructor(e,t,i=!0){super(e,t,i),this.core=e,this.logger=t,this.context=PT,this.storagePrefix=Kn,this.storageVersion=CT,this.events=new Map,this.shouldPersist=!1,this.init=async()=>{if(!r0())try{const n={eventId:ig(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:c3(this.core.relayer.protocol,this.core.relayer.version,Td)}}};await this.sendEvent([n])}catch(n){this.logger.warn(n)}},this.createEvent=n=>{const{event:a="ERROR",type:c="",properties:{topic:f,trace:g}}=n,d=ig(),m=this.core.projectId||"",w=Date.now(),O=sc({eventId:d,timestamp:w,props:{event:a,type:c,properties:{topic:f,trace:g}},bundleId:m,domain:this.getAppDomain()},this.setMethods(d));return this.telemetryEnabled&&(this.events.set(d,O),this.shouldPersist=!0),O},this.getEvent=n=>{const{eventId:a,topic:c}=n;if(a)return this.events.get(a);const f=Array.from(this.events.values()).find(g=>g.props.properties.topic===c);if(f)return sc(sc({},f),this.setMethods(f.eventId))},this.deleteEvent=n=>{const{eventId:a}=n;this.events.delete(a),this.shouldPersist=!0},this.setEventListeners=()=>{this.core.heartbeat.on(So.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(n=>{Ae.fromMiliseconds(Date.now())-Ae.fromMiliseconds(n.timestamp)>OT&&(this.events.delete(n.eventId),this.shouldPersist=!0)})})},this.setMethods=n=>({addTrace:a=>this.addTrace(n,a),setError:a=>this.setError(n,a)}),this.addTrace=(n,a)=>{const c=this.events.get(n);c&&(c.props.properties.trace.push(a),this.events.set(n,c),this.shouldPersist=!0)},this.setError=(n,a)=>{const c=this.events.get(n);c&&(c.props.type=a,c.timestamp=Date.now(),this.events.set(n,c),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(a=>{this.events.set(a.eventId,sc(sc({},a),this.setMethods(a.eventId)))})}catch(n){this.logger.warn(n)}},this.submit=async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const n=[];for(const[a,c]of this.events)c.props.type&&n.push(c);if(n.length!==0)try{if((await this.sendEvent(n)).ok)for(const a of n)this.events.delete(a.eventId),this.shouldPersist=!0}catch(a){this.logger.warn(a)}},this.sendEvent=async n=>{const a=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${TT}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${Td}${a}`,{method:"POST",body:JSON.stringify(n)})},this.getAppDomain=()=>o3().url,this.logger=Qr(t,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 zN=Object.defineProperty,Mb=Object.getOwnPropertySymbols,jN=Object.prototype.hasOwnProperty,kN=Object.prototype.propertyIsEnumerable,Ib=(r,e,t)=>e in r?zN(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Cb=(r,e)=>{for(var t in e||(e={}))jN.call(e,t)&&Ib(r,t,e[t]);if(Mb)for(var t of Mb(e))kN.call(e,t)&&Ib(r,t,e[t]);return r};class b0 extends YC{constructor(e){var t;super(e),this.protocol=w2,this.version=_2,this.name=g0,this.events=new Vi.EventEmitter,this.initialized=!1,this.on=(c,f)=>this.events.on(c,f),this.once=(c,f)=>this.events.once(c,f),this.off=(c,f)=>this.events.off(c,f),this.removeListener=(c,f)=>this.events.removeListener(c,f),this.dispatchEnvelope=({topic:c,message:f,sessionExists:g})=>{if(!c||!f)return;const d={topic:c,message:f,publishedAt:Date.now(),transportType:Kt.link_mode};this.relayer.onLinkMessageEvent(d,{sessionExists:g})},this.projectId=e==null?void 0:e.projectId,this.relayUrl=(e==null?void 0:e.relayUrl)||E2,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=Zf({level:typeof(e==null?void 0:e.logger)=="string"&&e.logger?e.logger:XO.logger}),{logger:n,chunkLoggerController:a}=WC({opts:i,maxSizeInBytes:e==null?void 0:e.maxLogBlobSizeInBytes,loggerOverride:e==null?void 0:e.logger});this.logChunkController=a,(t=this.logChunkController)!=null&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var c,f;(c=this.logChunkController)!=null&&c.downloadLogsBlobInBrowser&&((f=this.logChunkController)==null||f.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=Qr(n,this.name),this.heartbeat=new KI,this.crypto=new nN(this,this.logger,e==null?void 0:e.keychain),this.history=new EN(this,this.logger),this.expirer=new AN(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new _C(Cb(Cb({},ZO),e==null?void 0:e.storageOptions)),this.relayer=new mN({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new DN(this,this.logger),this.verify=new BN(this,this.logger,this.storage),this.echoClient=new $N(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new FN(this,this.logger,e==null?void 0:e.telemetryEnabled)}static async init(e){const t=new b0(e);await t.initialize();const i=await t.crypto.getClientId();return await t.storage.setItem(dT,i),t}get context(){return pi(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(hb,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(hb)||[],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 HN=b0,$2="wc",U2=2,q2="client",v0=`${$2}@${U2}:${q2}:`,Zl={name:q2,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"},Pb="WALLETCONNECT_DEEPLINK_CHOICE",KN="proposal",L2="Proposal expired",VN="session",Ya=Ae.SEVEN_DAYS,GN="engine",wr={wc_sessionPropose:{req:{ttl:Ae.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:Ae.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:Ae.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:Ae.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:Ae.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:Ae.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:Ae.ONE_DAY,prompt:!1,tag:1104},res:{ttl:Ae.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:Ae.ONE_DAY,prompt:!1,tag:1106},res:{ttl:Ae.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:Ae.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:Ae.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:Ae.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:Ae.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:Ae.ONE_DAY,prompt:!1,tag:1112},res:{ttl:Ae.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:Ae.ONE_DAY,prompt:!1,tag:1114},res:{ttl:Ae.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:Ae.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:Ae.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:Ae.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:Ae.FIVE_MINUTES,prompt:!1,tag:1119}}},ed={min:Ae.FIVE_MINUTES,max:Ae.SEVEN_DAYS},xn={idle:"IDLE",active:"ACTIVE"},JN="request",WN=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],YN="wc",QN="auth",XN="authKeys",ZN="pairingTopics",eB="requests",sh=`${YN}@${1.5}:${QN}:`,hf=`${sh}:PUB_KEY`;var tB=Object.defineProperty,rB=Object.defineProperties,iB=Object.getOwnPropertyDescriptors,Ob=Object.getOwnPropertySymbols,nB=Object.prototype.hasOwnProperty,sB=Object.prototype.propertyIsEnumerable,Tb=(r,e,t)=>e in r?tB(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,rr=(r,e)=>{for(var t in e||(e={}))nB.call(e,t)&&Tb(r,t,e[t]);if(Ob)for(var t of Ob(e))sB.call(e,t)&&Tb(r,t,e[t]);return r},hn=(r,e)=>rB(r,iB(e));class aB extends cP{constructor(e){super(e),this.name=GN,this.events=new Fd,this.initialized=!1,this.requestQueue={state:xn.idle,queue:[]},this.sessionRequestQueue={state:xn.idle,queue:[]},this.requestQueueDelay=Ae.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(wr)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},Ae.toMiliseconds(this.requestQueueDelay)))},this.connect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const i=hn(rr({},t),{requiredNamespaces:t.requiredNamespaces||{},optionalNamespaces:t.optionalNamespaces||{}});await this.isValidConnect(i);const{pairingTopic:n,requiredNamespaces:a,optionalNamespaces:c,sessionProperties:f,relays:g}=i;let d=n,m,w=!1;try{d&&(w=this.client.core.pairing.pairings.get(d).active)}catch(B){throw this.client.logger.error(`connect() -> pairing.get(${d}) failed`),B}if(!d||!w){const{topic:B,uri:j}=await this.client.core.pairing.create();d=B,m=j}if(!d){const{message:B}=De("NO_MATCHING_KEY",`connect() pairing topic: ${d}`);throw new Error(B)}const O=await this.client.core.crypto.generateKeyPair(),C=wr.wc_sessionPropose.req.ttl||Ae.FIVE_MINUTES,P=br(C),q=rr({requiredNamespaces:a,optionalNamespaces:c,relays:g??[{protocol:D2}],proposer:{publicKey:O,metadata:this.client.metadata},expiryTimestamp:P,pairingTopic:d},f&&{sessionProperties:f}),{reject:K,resolve:Y,done:z}=fa(C,L2);this.events.once(xt("session_connect"),async({error:B,session:j})=>{if(B)K(B);else if(j){j.self.publicKey=O;const k=hn(rr({},j),{pairingTopic:q.pairingTopic,requiredNamespaces:q.requiredNamespaces,optionalNamespaces:q.optionalNamespaces,transportType:Kt.relay});await this.client.session.set(j.topic,k),await this.setExpiry(j.topic,j.expiry),d&&await this.client.core.pairing.updateMetadata({topic:d,metadata:j.peer.metadata}),this.cleanupDuplicatePairings(k),Y(k)}});const W=await this.sendRequest({topic:d,method:"wc_sessionPropose",params:q,throwOnFailedPublish:!0});return await this.setProposal(W,rr({id:W},q)),{uri:m,approval:z}},this.pair=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(t)}catch(i){throw this.client.logger.error("pair() failed"),i}},this.approve=async t=>{var i,n,a;const c=this.client.core.eventClient.createEvent({properties:{topic:(i=t==null?void 0:t.id)==null?void 0:i.toString(),trace:[fn.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(N){throw c.setError(ca.no_internet_connection),N}try{await this.isValidProposalId(t==null?void 0:t.id)}catch(N){throw this.client.logger.error(`approve() -> proposal.get(${t==null?void 0:t.id}) failed`),c.setError(ca.proposal_not_found),N}try{await this.isValidApprove(t)}catch(N){throw this.client.logger.error("approve() -> isValidApprove() failed"),c.setError(ca.session_approve_namespace_validation_failure),N}const{id:f,relayProtocol:g,namespaces:d,sessionProperties:m,sessionConfig:w}=t,O=this.client.proposal.get(f);this.client.core.eventClient.deleteEvent({eventId:c.eventId});const{pairingTopic:C,proposer:P,requiredNamespaces:q,optionalNamespaces:K}=O;let Y=(n=this.client.core.eventClient)==null?void 0:n.getEvent({topic:C});Y||(Y=(a=this.client.core.eventClient)==null?void 0:a.createEvent({type:fn.session_approve_started,properties:{topic:C,trace:[fn.session_approve_started,fn.session_namespaces_validation_success]}}));const z=await this.client.core.crypto.generateKeyPair(),W=P.publicKey,B=await this.client.core.crypto.generateSharedKey(z,W),j=rr(rr({relay:{protocol:g??"irn"},namespaces:d,controller:{publicKey:z,metadata:this.client.metadata},expiry:br(Ya)},m&&{sessionProperties:m}),w&&{sessionConfig:w}),k=Kt.relay;Y.addTrace(fn.subscribing_session_topic);try{await this.client.core.relayer.subscribe(B,{transportType:k})}catch(N){throw Y.setError(ca.subscribe_session_topic_failure),N}Y.addTrace(fn.subscribe_session_topic_success);const _=hn(rr({},j),{topic:B,requiredNamespaces:q,optionalNamespaces:K,pairingTopic:C,acknowledged:!1,self:j.controller,peer:{publicKey:P.publicKey,metadata:P.metadata},controller:z,transportType:Kt.relay});await this.client.session.set(B,_),Y.addTrace(fn.store_session);try{Y.addTrace(fn.publishing_session_settle),await this.sendRequest({topic:B,method:"wc_sessionSettle",params:j,throwOnFailedPublish:!0}).catch(N=>{throw Y==null||Y.setError(ca.session_settle_publish_failure),N}),Y.addTrace(fn.session_settle_publish_success),Y.addTrace(fn.publishing_session_approve),await this.sendResult({id:f,topic:C,result:{relay:{protocol:g??"irn"},responderPublicKey:z},throwOnFailedPublish:!0}).catch(N=>{throw Y==null||Y.setError(ca.session_approve_publish_failure),N}),Y.addTrace(fn.session_approve_publish_success)}catch(N){throw this.client.logger.error(N),this.client.session.delete(B,Lt("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(B),N}return this.client.core.eventClient.deleteEvent({eventId:Y.eventId}),await this.client.core.pairing.updateMetadata({topic:C,metadata:P.metadata}),await this.client.proposal.delete(f,Lt("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:C}),await this.setExpiry(B,br(Ya)),{topic:B,acknowledged:()=>Promise.resolve(this.client.session.get(B))}},this.reject=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(t)}catch(c){throw this.client.logger.error("reject() -> isValidReject() failed"),c}const{id:i,reason:n}=t;let a;try{a=this.client.proposal.get(i).pairingTopic}catch(c){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),c}a&&(await this.sendError({id:i,topic:a,error:n,rpcOpts:wr.wc_sessionPropose.reject}),await this.client.proposal.delete(i,Lt("USER_DISCONNECTED")))},this.update=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(t)}catch(w){throw this.client.logger.error("update() -> isValidUpdate() failed"),w}const{topic:i,namespaces:n}=t,{done:a,resolve:c,reject:f}=fa(),g=Bs(),d=da().toString(),m=this.client.session.get(i).namespaces;return this.events.once(xt("session_update",g),({error:w})=>{w?f(w):c()}),await this.client.session.update(i,{namespaces:n}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:n},throwOnFailedPublish:!0,clientRpcId:g,relayRpcId:d}).catch(w=>{this.client.logger.error(w),this.client.session.update(i,{namespaces:m}),f(w)}),{acknowledged:a}},this.extend=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(t)}catch(g){throw this.client.logger.error("extend() -> isValidExtend() failed"),g}const{topic:i}=t,n=Bs(),{done:a,resolve:c,reject:f}=fa();return this.events.once(xt("session_extend",n),({error:g})=>{g?f(g):c()}),await this.setExpiry(i,br(Ya)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(g=>{f(g)}),{acknowledged:a}},this.request=async t=>{this.isInitialized();try{await this.isValidRequest(t)}catch(P){throw this.client.logger.error("request() -> isValidRequest() failed"),P}const{chainId:i,request:n,topic:a,expiry:c=wr.wc_sessionRequest.req.ttl}=t,f=this.client.session.get(a);(f==null?void 0:f.transportType)===Kt.relay&&await this.confirmOnlineStateOrThrow();const g=Bs(),d=da().toString(),{done:m,resolve:w,reject:O}=fa(c,"Request expired. Please try again.");this.events.once(xt("session_request",g),({error:P,result:q})=>{P?O(P):w(q)});const C=this.getAppLinkIfEnabled(f.peer.metadata,f.transportType);return C?(await this.sendRequest({clientRpcId:g,relayRpcId:d,topic:a,method:"wc_sessionRequest",params:{request:hn(rr({},n),{expiryTimestamp:br(c)}),chainId:i},expiry:c,throwOnFailedPublish:!0,appLink:C}).catch(P=>O(P)),this.client.events.emit("session_request_sent",{topic:a,request:n,chainId:i,id:g}),await m()):await Promise.all([new Promise(async P=>{await this.sendRequest({clientRpcId:g,relayRpcId:d,topic:a,method:"wc_sessionRequest",params:{request:hn(rr({},n),{expiryTimestamp:br(c)}),chainId:i},expiry:c,throwOnFailedPublish:!0}).catch(q=>O(q)),this.client.events.emit("session_request_sent",{topic:a,request:n,chainId:i,id:g}),P()}),new Promise(async P=>{var q;if(!((q=f.sessionConfig)!=null&&q.disableDeepLink)){const K=await zA(this.client.core.storage,Pb);await LA({id:g,topic:a,wcDeepLink:K})}P()}),m()]).then(P=>P[2])},this.respond=async t=>{this.isInitialized(),await this.isValidRespond(t);const{topic:i,response:n}=t,{id:a}=n,c=this.client.session.get(i);c.transportType===Kt.relay&&await this.confirmOnlineStateOrThrow();const f=this.getAppLinkIfEnabled(c.peer.metadata,c.transportType);Cn(n)?await this.sendResult({id:a,topic:i,result:n.result,throwOnFailedPublish:!0,appLink:f}):ji(n)&&await this.sendError({id:a,topic:i,error:n.error,appLink:f}),this.cleanupAfterResponse(t)},this.ping=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(t)}catch(n){throw this.client.logger.error("ping() -> isValidPing() failed"),n}const{topic:i}=t;if(this.client.session.keys.includes(i)){const n=Bs(),a=da().toString(),{done:c,resolve:f,reject:g}=fa();this.events.once(xt("session_ping",n),({error:d})=>{d?g(d):f()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:n,relayRpcId:a}),c()])}else this.client.core.pairing.pairings.keys.includes(i)&&await this.client.core.pairing.ping({topic:i})},this.emit=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(t);const{topic:i,event:n,chainId:a}=t,c=da().toString();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:n,chainId:a},throwOnFailedPublish:!0,relayRpcId:c})},this.disconnect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(t);const{topic:i}=t;if(this.client.session.keys.includes(i))await this.sendRequest({topic:i,method:"wc_sessionDelete",params:Lt("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}=De("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(n)}},this.find=t=>(this.isInitialized(),this.client.session.getAll().filter(i=>gI(i,t))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async(t,i)=>{var n;this.isInitialized(),this.isValidAuthenticate(t);const a=i&&this.client.core.linkModeSupportedApps.includes(i)&&((n=this.client.metadata.redirect)==null?void 0:n.linkMode),c=a?Kt.link_mode:Kt.relay;c===Kt.relay&&await this.confirmOnlineStateOrThrow();const{chains:f,statement:g="",uri:d,domain:m,nonce:w,type:O,exp:C,nbf:P,methods:q=[],expiry:K}=t,Y=[...t.resources||[]],{topic:z,uri:W}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:c});this.client.logger.info({message:"Generated new pairing",pairing:{topic:z,uri:W}});const B=await this.client.core.crypto.generateKeyPair(),j=cf(B);if(await Promise.all([this.client.auth.authKeys.set(hf,{responseTopic:j,publicKey:B}),this.client.auth.pairingTopics.set(j,{topic:j,pairingTopic:z})]),await this.client.core.relayer.subscribe(j,{transportType:c}),this.client.logger.info(`sending request to new pairing topic: ${z}`),q.length>0){const{namespace:M}=fc(f[0]);let x=$M(M,"request",q);of(Y)&&(x=qM(x,Y.pop())),Y.push(x)}const k=K&&K>wr.wc_sessionAuthenticate.req.ttl?K:wr.wc_sessionAuthenticate.req.ttl,_={authPayload:{type:O??"caip122",chains:f,statement:g,aud:d,domain:m,version:"1",nonce:w,iat:new Date().toISOString(),exp:C,nbf:P,resources:Y},requester:{publicKey:B,metadata:this.client.metadata},expiryTimestamp:br(k)},N={eip155:{chains:f,methods:[...new Set(["personal_sign",...q])],events:["chainChanged","accountsChanged"]}},se={requiredNamespaces:{},optionalNamespaces:N,relays:[{protocol:"irn"}],pairingTopic:z,proposer:{publicKey:B,metadata:this.client.metadata},expiryTimestamp:br(wr.wc_sessionPropose.req.ttl)},{done:le,resolve:U,reject:y}=fa(k,"Request expired"),u=async({error:M,session:x})=>{if(this.events.off(xt("session_request",v),h),M)y(M);else if(x){x.self.publicKey=B,await this.client.session.set(x.topic,x),await this.setExpiry(x.topic,x.expiry),z&&await this.client.core.pairing.updateMetadata({topic:z,metadata:x.peer.metadata});const p=this.client.session.get(x.topic);await this.deleteProposal(E),U({session:p})}},h=async M=>{var x,p,b;if(await this.deletePendingAuthRequest(v,{message:"fulfilled",code:0}),M.error){const V=Lt("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return M.error.code===V.code?void 0:(this.events.off(xt("session_connect"),u),y(M.error.message))}await this.deleteProposal(E),this.events.off(xt("session_connect"),u);const{cacaos:R,responder:Z}=M.result,ae=[],I=[];for(const V of R){await Cg({cacao:V,projectId:this.client.core.projectId})||(this.client.logger.error(V,"Signature verification failed"),y(Lt("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:G}=V,D=of(G.resources),H=[Ig(G.iss)],ne=Af(G.iss);if(D){const ce=Pg(D),fe=Og(D);ae.push(...ce),H.push(...fe)}for(const ce of H)I.push(`${ce}:${ne}`)}const ee=await this.client.core.crypto.generateSharedKey(B,Z.publicKey);let L;ae.length>0&&(L={topic:ee,acknowledged:!0,self:{publicKey:B,metadata:this.client.metadata},peer:Z,controller:Z.publicKey,expiry:br(Ya),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:z,namespaces:Fg([...new Set(ae)],[...new Set(I)]),transportType:c},await this.client.core.relayer.subscribe(ee,{transportType:c}),await this.client.session.set(ee,L),z&&await this.client.core.pairing.updateMetadata({topic:z,metadata:Z.metadata}),L=this.client.session.get(ee)),(x=this.client.metadata.redirect)!=null&&x.linkMode&&(p=Z.metadata.redirect)!=null&&p.linkMode&&(b=Z.metadata.redirect)!=null&&b.universal&&i&&(this.client.core.addLinkModeSupportedApp(Z.metadata.redirect.universal),this.client.session.update(ee,{transportType:Kt.link_mode})),U({auths:R,session:L})},v=Bs(),E=Bs();this.events.once(xt("session_connect"),u),this.events.once(xt("session_request",v),h);let S;try{if(a){const M=Fs("wc_sessionAuthenticate",_,v);this.client.core.history.set(z,M);const x=await this.client.core.crypto.encode("",M,{type:Bc,encoding:ec});S=Wu(i,z,x)}else await Promise.all([this.sendRequest({topic:z,method:"wc_sessionAuthenticate",params:_,expiry:t.expiry,throwOnFailedPublish:!0,clientRpcId:v}),this.sendRequest({topic:z,method:"wc_sessionPropose",params:se,expiry:wr.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:E})])}catch(M){throw this.events.off(xt("session_connect"),u),this.events.off(xt("session_request",v),h),M}return await this.setProposal(E,rr({id:E},se)),await this.setAuthRequest(v,{request:hn(rr({},_),{verifyContext:{}}),pairingTopic:z,transportType:c}),{uri:S??W,response:le}},this.approveSessionAuthenticate=async t=>{const{id:i,auths:n}=t,a=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[ua.authenticated_session_approve_started]}});try{this.isInitialized()}catch(K){throw a.setError(ic.no_internet_connection),K}const c=this.getPendingAuthRequest(i);if(!c)throw a.setError(ic.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);const f=c.transportType||Kt.relay;f===Kt.relay&&await this.confirmOnlineStateOrThrow();const g=c.requester.publicKey,d=await this.client.core.crypto.generateKeyPair(),m=cf(g),w={type:bs,receiverPublicKey:g,senderPublicKey:d},O=[],C=[];for(const K of n){if(!await Cg({cacao:K,projectId:this.client.core.projectId})){a.setError(ic.invalid_cacao);const j=Lt("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:m,error:j,encodeOpts:w}),new Error(j.message)}a.addTrace(ua.cacaos_verified);const{p:Y}=K,z=of(Y.resources),W=[Ig(Y.iss)],B=Af(Y.iss);if(z){const j=Pg(z),k=Og(z);O.push(...j),W.push(...k)}for(const j of W)C.push(`${j}:${B}`)}const P=await this.client.core.crypto.generateSharedKey(d,g);a.addTrace(ua.create_authenticated_session_topic);let q;if((O==null?void 0:O.length)>0){q={topic:P,acknowledged:!0,self:{publicKey:d,metadata:this.client.metadata},peer:{publicKey:g,metadata:c.requester.metadata},controller:g,expiry:br(Ya),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:c.pairingTopic,namespaces:Fg([...new Set(O)],[...new Set(C)]),transportType:f},a.addTrace(ua.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(P,{transportType:f})}catch(K){throw a.setError(ic.subscribe_authenticated_session_topic_failure),K}a.addTrace(ua.subscribe_authenticated_session_topic_success),await this.client.session.set(P,q),a.addTrace(ua.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:c.pairingTopic,metadata:c.requester.metadata})}a.addTrace(ua.publishing_authenticated_session_approve);try{await this.sendResult({topic:m,id:i,result:{cacaos:n,responder:{publicKey:d,metadata:this.client.metadata}},encodeOpts:w,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(c.requester.metadata,f)})}catch(K){throw a.setError(ic.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:c.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:a.eventId}),{session:q}},this.rejectSessionAuthenticate=async t=>{this.isInitialized();const{id:i,reason:n}=t,a=this.getPendingAuthRequest(i);if(!a)throw new Error(`Could not find pending auth request with id ${i}`);a.transportType===Kt.relay&&await this.confirmOnlineStateOrThrow();const c=a.requester.publicKey,f=await this.client.core.crypto.generateKeyPair(),g=cf(c),d={type:bs,receiverPublicKey:c,senderPublicKey:f};await this.sendError({id:i,topic:g,error:n,encodeOpts:d,rpcOpts:wr.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(a.requester.metadata,a.transportType)}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.client.proposal.delete(i,Lt("USER_DISCONNECTED"))},this.formatAuthMessage=t=>{this.isInitialized();const{request:i,iss:n}=t;return W3(i,n)},this.processRelayMessageCache=()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{const t=this.relayMessageCache.shift();t&&await this.onRelayMessage(t)}catch(t){this.client.logger.error(t)}},50)},this.cleanupDuplicatePairings=async t=>{if(t.pairingTopic)try{const i=this.client.core.pairing.pairings.get(t.pairingTopic),n=this.client.core.pairing.pairings.getAll().filter(a=>{var c,f;return((c=a.peerMetadata)==null?void 0:c.url)&&((f=a.peerMetadata)==null?void 0:f.url)===t.peer.metadata.url&&a.topic&&a.topic!==i.topic});if(n.length===0)return;this.client.logger.info(`Cleaning up ${n.length} duplicate pairing(s)`),await Promise.all(n.map(a=>this.client.core.pairing.disconnect({topic:a.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(i){this.client.logger.error(i)}},this.deleteSession=async t=>{var i;const{topic:n,expirerHasDeleted:a=!1,emitEvent:c=!0,id:f=0}=t,{self:g}=this.client.session.get(n);await this.client.core.relayer.unsubscribe(n),await this.client.session.delete(n,Lt("USER_DISCONNECTED")),this.addToRecentlyDeleted(n,"session"),this.client.core.crypto.keychain.has(g.publicKey)&&await this.client.core.crypto.deleteKeyPair(g.publicKey),this.client.core.crypto.keychain.has(n)&&await this.client.core.crypto.deleteSymKey(n),a||this.client.core.expirer.del(n),this.client.core.storage.removeItem(Pb).catch(d=>this.client.logger.warn(d)),this.getPendingSessionRequests().forEach(d=>{d.topic===n&&this.deletePendingSessionRequest(d.id,Lt("USER_DISCONNECTED"))}),n===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=xn.idle),c&&this.client.events.emit("session_delete",{id:f,topic:n})},this.deleteProposal=async(t,i)=>{if(i)try{const n=this.client.proposal.get(t),a=this.client.core.eventClient.getEvent({topic:n.pairingTopic});a==null||a.setError(ca.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(t,Lt("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"proposal")},this.deletePendingSessionRequest=async(t,i,n=!1)=>{await Promise.all([this.client.pendingRequest.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(a=>a.id!==t),n&&(this.sessionRequestQueue.state=xn.idle,this.client.events.emit("session_request_expire",{id:t}))},this.deletePendingAuthRequest=async(t,i,n=!1)=>{await Promise.all([this.client.auth.requests.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)])},this.setExpiry=async(t,i)=>{this.client.session.keys.includes(t)&&(this.client.core.expirer.set(t,i),await this.client.session.update(t,{expiry:i}))},this.setProposal=async(t,i)=>{this.client.core.expirer.set(t,br(wr.wc_sessionPropose.req.ttl)),await this.client.proposal.set(t,i)},this.setAuthRequest=async(t,i)=>{const{request:n,pairingTopic:a,transportType:c=Kt.relay}=i;this.client.core.expirer.set(t,n.expiryTimestamp),await this.client.auth.requests.set(t,{authPayload:n.authPayload,requester:n.requester,expiryTimestamp:n.expiryTimestamp,id:t,pairingTopic:a,verifyContext:n.verifyContext,transportType:c})},this.setPendingSessionRequest=async t=>{const{id:i,topic:n,params:a,verifyContext:c}=t,f=a.request.expiryTimestamp||br(wr.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,f),await this.client.pendingRequest.set(i,{id:i,topic:n,params:a,verifyContext:c})},this.sendRequest=async t=>{const{topic:i,method:n,params:a,expiry:c,relayRpcId:f,clientRpcId:g,throwOnFailedPublish:d,appLink:m}=t,w=Fs(n,a,g);let O;const C=!!m;try{const K=C?ec:Ls;O=await this.client.core.crypto.encode(i,w,{encoding:K})}catch(K){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),K}let P;if(WN.includes(n)){const K=hs(JSON.stringify(w)),Y=hs(O);P=await this.client.core.verify.register({id:Y,decryptedId:K})}const q=wr[n].req;if(q.attestation=P,c&&(q.ttl=c),f&&(q.id=f),this.client.core.history.set(i,w),C){const K=Wu(m,i,O);await globalThis.Linking.openURL(K,this.client.name)}else{const K=wr[n].req;c&&(K.ttl=c),f&&(K.id=f),d?(K.internal=hn(rr({},K.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,O,K)):this.client.core.relayer.publish(i,O,K).catch(Y=>this.client.logger.error(Y))}return w.id},this.sendResult=async t=>{const{id:i,topic:n,result:a,throwOnFailedPublish:c,encodeOpts:f,appLink:g}=t,d=th(i,a);let m;const w=g&&typeof(globalThis==null?void 0:globalThis.Linking)<"u";try{const C=w?ec:Ls;m=await this.client.core.crypto.encode(n,d,hn(rr({},f||{}),{encoding:C}))}catch(C){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${n} failed`),C}let O;try{O=await this.client.core.history.get(n,i)}catch(C){throw this.client.logger.error(`sendResult() -> history.get(${n}, ${i}) failed`),C}if(w){const C=Wu(g,n,m);await globalThis.Linking.openURL(C,this.client.name)}else{const C=wr[O.request.method].res;c?(C.internal=hn(rr({},C.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,m,C)):this.client.core.relayer.publish(n,m,C).catch(P=>this.client.logger.error(P))}await this.client.core.history.resolve(d)},this.sendError=async t=>{const{id:i,topic:n,error:a,encodeOpts:c,rpcOpts:f,appLink:g}=t,d=rh(i,a);let m;const w=g&&typeof(globalThis==null?void 0:globalThis.Linking)<"u";try{const C=w?ec:Ls;m=await this.client.core.crypto.encode(n,d,hn(rr({},c||{}),{encoding:C}))}catch(C){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`),C}let O;try{O=await this.client.core.history.get(n,i)}catch(C){throw this.client.logger.error(`sendError() -> history.get(${n}, ${i}) failed`),C}if(w){const C=Wu(g,n,m);await globalThis.Linking.openURL(C,this.client.name)}else{const C=f||wr[O.request.method].res;this.client.core.relayer.publish(n,m,C)}await this.client.core.history.resolve(d)},this.cleanup=async()=>{const t=[],i=[];this.client.session.getAll().forEach(n=>{let a=!1;Rs(n.expiry)&&(a=!0),this.client.core.crypto.keychain.has(n.topic)||(a=!0),a&&t.push(n.topic)}),this.client.proposal.getAll().forEach(n=>{Rs(n.expiryTimestamp)&&i.push(n.id)}),await Promise.all([...t.map(n=>this.deleteSession({topic:n})),...i.map(n=>this.deleteProposal(n))])},this.onRelayEventRequest=async t=>{this.requestQueue.queue.push(t),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===xn.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=xn.active;const t=this.requestQueue.queue.shift();if(t)try{await this.processRequest(t)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=xn.idle},this.processRequest=async t=>{const{topic:i,payload:n,attestation:a,transportType:c,encryptedId:f}=t,g=n.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:g}))switch(g){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:n,attestation:a,encryptedId:f});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:a,encryptedId:f,transportType:c});case"wc_sessionEvent":return await this.onSessionEventRequest(i,n);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:i,payload:n,attestation:a,encryptedId:f,transportType:c});default:return this.client.logger.info(`Unsupported request method ${g}`)}},this.onRelayEventResponse=async t=>{const{topic:i,payload:n,transportType:a}=t,c=(await this.client.core.history.get(i,n.id)).request.method;switch(c){case"wc_sessionPropose":return this.onSessionProposeResponse(i,n,a);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 ${c}`)}},this.onRelayEventUnknownPayload=t=>{const{topic:i}=t,{message:n}=De("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=t=>{const{topic:i,requestMethod:n}=t,a=this.expectedPairingMethodMap.get(i);return!a||a.includes(n)?!1:!!(a.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)},this.onSessionProposeRequest=async t=>{const{topic:i,payload:n,attestation:a,encryptedId:c}=t,{params:f,id:g}=n;try{const d=this.client.core.eventClient.getEvent({topic:i});this.isValidConnect(rr({},n.params));const m=f.expiryTimestamp||br(wr.wc_sessionPropose.req.ttl),w=rr({id:g,pairingTopic:i,expiryTimestamp:m},f);await this.setProposal(g,w);const O=await this.getVerifyContext({attestationId:a,hash:hs(JSON.stringify(n)),encryptedId:c,metadata:w.proposer.metadata});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),d==null||d.setError(us.proposal_listener_not_found)),d==null||d.addTrace(Sn.emit_session_proposal),this.client.events.emit("session_proposal",{id:g,params:w,verifyContext:O})}catch(d){await this.sendError({id:g,topic:i,error:d,rpcOpts:wr.wc_sessionPropose.autoReject}),this.client.logger.error(d)}},this.onSessionProposeResponse=async(t,i,n)=>{const{id:a}=i;if(Cn(i)){const{result:c}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:c});const f=this.client.proposal.get(a);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:f});const g=f.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:g});const d=c.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:d});const m=await this.client.core.crypto.generateSharedKey(g,d);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:m});const w=await this.client.core.relayer.subscribe(m,{transportType:n});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:w}),await this.client.core.pairing.activate({topic:t})}else if(ji(i)){await this.client.proposal.delete(a,Lt("USER_DISCONNECTED"));const c=xt("session_connect");if(this.events.listenerCount(c)===0)throw new Error(`emitting ${c} without any listeners, 954`);this.events.emit(xt("session_connect"),{error:i.error})}},this.onSessionSettleRequest=async(t,i)=>{const{id:n,params:a}=i;try{this.isValidSessionSettleRequest(a);const{relay:c,controller:f,expiry:g,namespaces:d,sessionProperties:m,sessionConfig:w}=i.params,O=hn(rr(rr({topic:t,relay:c,expiry:g,namespaces:d,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:f.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:f.publicKey,metadata:f.metadata}},m&&{sessionProperties:m}),w&&{sessionConfig:w}),{transportType:Kt.relay}),C=xt("session_connect");if(this.events.listenerCount(C)===0)throw new Error(`emitting ${C} without any listeners 997`);this.events.emit(xt("session_connect"),{session:O}),await this.sendResult({id:i.id,topic:t,result:!0,throwOnFailedPublish:!0})}catch(c){await this.sendError({id:n,topic:t,error:c}),this.client.logger.error(c)}},this.onSessionSettleResponse=async(t,i)=>{const{id:n}=i;Cn(i)?(await this.client.session.update(t,{acknowledged:!0}),this.events.emit(xt("session_approve",n),{})):ji(i)&&(await this.client.session.delete(t,Lt("USER_DISCONNECTED")),this.events.emit(xt("session_approve",n),{error:i.error}))},this.onSessionUpdateRequest=async(t,i)=>{const{params:n,id:a}=i;try{const c=`${t}_session_update`,f=tc.get(c);if(f&&this.isRequestOutOfSync(f,a)){this.client.logger.info(`Discarding out of sync request - ${a}`),this.sendError({id:a,topic:t,error:Lt("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(rr({topic:t},n));try{tc.set(c,a),await this.client.session.update(t,{namespaces:n.namespaces}),await this.sendResult({id:a,topic:t,result:!0,throwOnFailedPublish:!0})}catch(g){throw tc.delete(c),g}this.client.events.emit("session_update",{id:a,topic:t,params:n})}catch(c){await this.sendError({id:a,topic:t,error:c}),this.client.logger.error(c)}},this.isRequestOutOfSync=(t,i)=>parseInt(i.toString().slice(0,-3))<=parseInt(t.toString().slice(0,-3)),this.onSessionUpdateResponse=(t,i)=>{const{id:n}=i,a=xt("session_update",n);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);Cn(i)?this.events.emit(xt("session_update",n),{}):ji(i)&&this.events.emit(xt("session_update",n),{error:i.error})},this.onSessionExtendRequest=async(t,i)=>{const{id:n}=i;try{this.isValidExtend({topic:t}),await this.setExpiry(t,br(Ya)),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:n,topic:t})}catch(a){await this.sendError({id:n,topic:t,error:a}),this.client.logger.error(a)}},this.onSessionExtendResponse=(t,i)=>{const{id:n}=i,a=xt("session_extend",n);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);Cn(i)?this.events.emit(xt("session_extend",n),{}):ji(i)&&this.events.emit(xt("session_extend",n),{error:i.error})},this.onSessionPingRequest=async(t,i)=>{const{id:n}=i;try{this.isValidPing({topic:t}),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:n,topic:t})}catch(a){await this.sendError({id:n,topic:t,error:a}),this.client.logger.error(a)}},this.onSessionPingResponse=(t,i)=>{const{id:n}=i,a=xt("session_ping",n);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);setTimeout(()=>{Cn(i)?this.events.emit(xt("session_ping",n),{}):ji(i)&&this.events.emit(xt("session_ping",n),{error:i.error})},500)},this.onSessionDeleteRequest=async(t,i)=>{const{id:n}=i;try{this.isValidDisconnect({topic:t,reason:i.params}),Promise.all([new Promise(a=>{this.client.core.relayer.once(Jr.publish,async()=>{a(await this.deleteSession({topic:t,id:n}))})}),this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:t,error:Lt("USER_DISCONNECTED")})]).catch(a=>this.client.logger.error(a))}catch(a){this.client.logger.error(a)}},this.onSessionRequest=async t=>{var i,n,a;const{topic:c,payload:f,attestation:g,encryptedId:d,transportType:m}=t,{id:w,params:O}=f;try{await this.isValidRequest(rr({topic:c},O));const C=this.client.session.get(c),P=await this.getVerifyContext({attestationId:g,hash:hs(JSON.stringify(Fs("wc_sessionRequest",O,w))),encryptedId:d,metadata:C.peer.metadata,transportType:m}),q={id:w,topic:c,params:O,verifyContext:P};await this.setPendingSessionRequest(q),m===Kt.link_mode&&(i=C.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((n=C.peer.metadata.redirect)==null?void 0:n.universal),(a=this.client.signConfig)!=null&&a.disableRequestQueue?this.emitSessionRequest(q):(this.addSessionRequestToSessionRequestQueue(q),this.processSessionRequestQueue())}catch(C){await this.sendError({id:w,topic:c,error:C}),this.client.logger.error(C)}},this.onSessionRequestResponse=(t,i)=>{const{id:n}=i,a=xt("session_request",n);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);Cn(i)?this.events.emit(xt("session_request",n),{result:i.result}):ji(i)&&this.events.emit(xt("session_request",n),{error:i.error})},this.onSessionEventRequest=async(t,i)=>{const{id:n,params:a}=i;try{const c=`${t}_session_event_${a.event.name}`,f=tc.get(c);if(f&&this.isRequestOutOfSync(f,n)){this.client.logger.info(`Discarding out of sync request - ${n}`);return}this.isValidEmit(rr({topic:t},a)),this.client.events.emit("session_event",{id:n,topic:t,params:a}),tc.set(c,n)}catch(c){await this.sendError({id:n,topic:t,error:c}),this.client.logger.error(c)}},this.onSessionAuthenticateResponse=(t,i)=>{const{id:n}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:t,payload:i}),Cn(i)?this.events.emit(xt("session_request",n),{result:i.result}):ji(i)&&this.events.emit(xt("session_request",n),{error:i.error})},this.onSessionAuthenticateRequest=async t=>{var i;const{topic:n,payload:a,attestation:c,encryptedId:f,transportType:g}=t;try{const{requester:d,authPayload:m,expiryTimestamp:w}=a.params,O=await this.getVerifyContext({attestationId:c,hash:hs(JSON.stringify(a)),encryptedId:f,metadata:d.metadata,transportType:g}),C={requester:d,pairingTopic:n,id:a.id,authPayload:m,verifyContext:O,expiryTimestamp:w};await this.setAuthRequest(a.id,{request:C,pairingTopic:n,transportType:g}),g===Kt.link_mode&&(i=d.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(d.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:n,params:a.params,id:a.id,verifyContext:O})}catch(d){this.client.logger.error(d);const m=a.params.requester.publicKey,w=await this.client.core.crypto.generateKeyPair(),O=this.getAppLinkIfEnabled(a.params.requester.metadata,g),C={type:bs,receiverPublicKey:m,senderPublicKey:w};await this.sendError({id:a.id,topic:n,error:d,encodeOpts:C,rpcOpts:wr.wc_sessionAuthenticate.autoReject,appLink:O})}},this.addSessionRequestToSessionRequestQueue=t=>{this.sessionRequestQueue.queue.push(t)},this.cleanupAfterResponse=t=>{this.deletePendingSessionRequest(t.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=xn.idle,this.processSessionRequestQueue()},Ae.toMiliseconds(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:t,error:i})=>{const n=this.client.core.history.pending;n.length>0&&n.filter(a=>a.topic===t&&a.request.method==="wc_sessionRequest").forEach(a=>{const c=a.request.id,f=xt("session_request",c);if(this.events.listenerCount(f)===0)throw new Error(`emitting ${f} without any listeners`);this.events.emit(xt("session_request",a.request.id),{error:i})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===xn.active){this.client.logger.info("session request queue is already active.");return}const t=this.sessionRequestQueue.queue[0];if(!t){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=xn.active,this.emitSessionRequest(t)}catch(i){this.client.logger.error(i)}},this.emitSessionRequest=t=>{this.client.events.emit("session_request",t)},this.onPairingCreated=t=>{if(t.methods&&this.expectedPairingMethodMap.set(t.topic,t.methods),t.active)return;const i=this.client.proposal.getAll().find(n=>n.pairingTopic===t.topic);i&&this.onSessionProposeRequest({topic:t.topic,payload:Fs("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id)})},this.isValidConnect=async t=>{if(!ci(t)){const{message:g}=De("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(t)}`);throw new Error(g)}const{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:a,sessionProperties:c,relays:f}=t;if(fi(i)||await this.isValidPairingTopic(i),!MI(f)){const{message:g}=De("MISSING_OR_INVALID",`connect() relays: ${f}`);throw new Error(g)}!fi(n)&&_c(n)!==0&&this.validateNamespaces(n,"requiredNamespaces"),!fi(a)&&_c(a)!==0&&this.validateNamespaces(a,"optionalNamespaces"),fi(c)||this.validateSessionProps(c,"sessionProperties")},this.validateNamespaces=(t,i)=>{const n=SI(t,"connect()",i);if(n)throw new Error(n.message)},this.isValidApprove=async t=>{if(!ci(t))throw new Error(De("MISSING_OR_INVALID",`approve() params: ${t}`).message);const{id:i,namespaces:n,relayProtocol:a,sessionProperties:c}=t;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);const f=this.client.proposal.get(i),g=Kl(n,"approve()");if(g)throw new Error(g.message);const d=kg(f.requiredNamespaces,n,"approve()");if(d)throw new Error(d.message);if(!ur(a,!0)){const{message:m}=De("MISSING_OR_INVALID",`approve() relayProtocol: ${a}`);throw new Error(m)}fi(c)||this.validateSessionProps(c,"sessionProperties")},this.isValidReject=async t=>{if(!ci(t)){const{message:a}=De("MISSING_OR_INVALID",`reject() params: ${t}`);throw new Error(a)}const{id:i,reason:n}=t;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!CI(n)){const{message:a}=De("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(a)}},this.isValidSessionSettleRequest=t=>{if(!ci(t)){const{message:d}=De("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${t}`);throw new Error(d)}const{relay:i,controller:n,namespaces:a,expiry:c}=t;if(!i2(i)){const{message:d}=De("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(d)}const f=wI(n,"onSessionSettleRequest()");if(f)throw new Error(f.message);const g=Kl(a,"onSessionSettleRequest()");if(g)throw new Error(g.message);if(Rs(c)){const{message:d}=De("EXPIRED","onSessionSettleRequest()");throw new Error(d)}},this.isValidUpdate=async t=>{if(!ci(t)){const{message:g}=De("MISSING_OR_INVALID",`update() params: ${t}`);throw new Error(g)}const{topic:i,namespaces:n}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const a=this.client.session.get(i),c=Kl(n,"update()");if(c)throw new Error(c.message);const f=kg(a.requiredNamespaces,n,"update()");if(f)throw new Error(f.message)},this.isValidExtend=async t=>{if(!ci(t)){const{message:n}=De("MISSING_OR_INVALID",`extend() params: ${t}`);throw new Error(n)}const{topic:i}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)},this.isValidRequest=async t=>{if(!ci(t)){const{message:g}=De("MISSING_OR_INVALID",`request() params: ${t}`);throw new Error(g)}const{topic:i,request:n,chainId:a,expiry:c}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const{namespaces:f}=this.client.session.get(i);if(!jg(f,a)){const{message:g}=De("MISSING_OR_INVALID",`request() chainId: ${a}`);throw new Error(g)}if(!PI(n)){const{message:g}=De("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(g)}if(!RI(f,a,n.method)){const{message:g}=De("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(g)}if(c&&!UI(c,ed)){const{message:g}=De("MISSING_OR_INVALID",`request() expiry: ${c}. Expiry must be a number (in seconds) between ${ed.min} and ${ed.max}`);throw new Error(g)}},this.isValidRespond=async t=>{var i;if(!ci(t)){const{message:c}=De("MISSING_OR_INVALID",`respond() params: ${t}`);throw new Error(c)}const{topic:n,response:a}=t;try{await this.isValidSessionTopic(n)}catch(c){throw(i=t==null?void 0:t.response)!=null&&i.id&&this.cleanupAfterResponse(t),c}if(!OI(a)){const{message:c}=De("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(a)}`);throw new Error(c)}},this.isValidPing=async t=>{if(!ci(t)){const{message:n}=De("MISSING_OR_INVALID",`ping() params: ${t}`);throw new Error(n)}const{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidEmit=async t=>{if(!ci(t)){const{message:f}=De("MISSING_OR_INVALID",`emit() params: ${t}`);throw new Error(f)}const{topic:i,event:n,chainId:a}=t;await this.isValidSessionTopic(i);const{namespaces:c}=this.client.session.get(i);if(!jg(c,a)){const{message:f}=De("MISSING_OR_INVALID",`emit() chainId: ${a}`);throw new Error(f)}if(!TI(n)){const{message:f}=De("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(f)}if(!NI(c,a,n.name)){const{message:f}=De("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(f)}},this.isValidDisconnect=async t=>{if(!ci(t)){const{message:n}=De("MISSING_OR_INVALID",`disconnect() params: ${t}`);throw new Error(n)}const{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidAuthenticate=t=>{const{chains:i,uri:n,domain:a,nonce:c}=t;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!ur(n,!1))throw new Error("uri is required parameter");if(!ur(a,!1))throw new Error("domain is required parameter");if(!ur(c,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(g=>fc(g).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:f}=fc(i[0]);if(f!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async t=>{const{attestationId:i,hash:n,encryptedId:a,metadata:c,transportType:f}=t,g={verified:{verifyUrl:c.verifyUrl||gc,validation:"UNKNOWN",origin:c.url||""}};try{if(f===Kt.link_mode){const m=this.getAppLinkIfEnabled(c,f);return g.verified.validation=m&&new URL(m).origin===new URL(c.url).origin?"VALID":"INVALID",g}const d=await this.client.core.verify.resolve({attestationId:i,hash:n,encryptedId:a,verifyUrl:c.verifyUrl});d&&(g.verified.origin=d.origin,g.verified.isScam=d.isScam,g.verified.validation=d.origin===new URL(c.url).origin?"VALID":"INVALID")}catch(d){this.client.logger.warn(d)}return this.client.logger.debug(`Verify context: ${JSON.stringify(g)}`),g},this.validateSessionProps=(t,i)=>{Object.values(t).forEach(n=>{if(!ur(n,!1)){const{message:a}=De("MISSING_OR_INVALID",`${i} must be in Record<string, string> format. Received: ${JSON.stringify(n)}`);throw new Error(a)}})},this.getPendingAuthRequest=t=>{const i=this.client.auth.requests.get(t);return typeof i=="object"?i:void 0},this.addToRecentlyDeleted=(t,i)=>{if(this.recentlyDeletedMap.set(t,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let n=0;const a=this.recentlyDeletedLimit/2;for(const c of this.recentlyDeletedMap.keys()){if(n++>=a)break;this.recentlyDeletedMap.delete(c)}}},this.checkRecentlyDeleted=t=>{const i=this.recentlyDeletedMap.get(t);if(i){const{message:n}=De("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${t}`);throw new Error(n)}},this.isLinkModeEnabled=(t,i)=>{var n,a,c,f,g,d,m,w,O;return!t||i!==Kt.link_mode?!1:((a=(n=this.client.metadata)==null?void 0:n.redirect)==null?void 0:a.linkMode)===!0&&((f=(c=this.client.metadata)==null?void 0:c.redirect)==null?void 0:f.universal)!==void 0&&((d=(g=this.client.metadata)==null?void 0:g.redirect)==null?void 0:d.universal)!==""&&((m=t==null?void 0:t.redirect)==null?void 0:m.universal)!==void 0&&((w=t==null?void 0:t.redirect)==null?void 0:w.universal)!==""&&((O=t==null?void 0:t.redirect)==null?void 0:O.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(t.redirect.universal)&&typeof(globalThis==null?void 0:globalThis.Linking)<"u"},this.getAppLinkIfEnabled=(t,i)=>{var n;return this.isLinkModeEnabled(t,i)?(n=t==null?void 0:t.redirect)==null?void 0:n.universal:void 0},this.handleLinkModeMessage=({url:t})=>{if(!t||!t.includes("wc_ev")||!t.includes("topic"))return;const i=rg(t,"topic")||"",n=decodeURIComponent(rg(t,"wc_ev")||""),a=this.client.session.keys.includes(i);a&&this.client.session.update(i,{transportType:Kt.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:n,sessionExists:a})},this.registerLinkModeListeners=async()=>{var t;if(r0()||wo()&&(t=this.client.metadata.redirect)!=null&&t.linkMode){const i=globalThis==null?void 0:globalThis.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}=De("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Jr.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){const{topic:t,message:i,attestation:n,transportType:a}=e,{publicKey:c}=this.client.auth.authKeys.keys.includes(hf)?this.client.auth.authKeys.get(hf):{responseTopic:void 0,publicKey:void 0},f=await this.client.core.crypto.decode(t,i,{receiverPublicKey:c,encoding:a===Kt.link_mode?ec:Ls});try{p0(f)?(this.client.core.history.set(t,f),this.onRelayEventRequest({topic:t,payload:f,attestation:n,transportType:a,encryptedId:hs(i)})):ih(f)?(await this.client.core.history.resolve(f),await this.onRelayEventResponse({topic:t,payload:f,transportType:a}),this.client.core.history.delete(t,f.id)):this.onRelayEventUnknownPayload({topic:t,payload:f,transportType:a})}catch(g){this.client.logger.error(g)}}registerExpirerEvents(){this.client.core.expirer.on(Fi.expired,async e=>{const{topic:t,id:i}=l3(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,De("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,De("EXPIRED"),!0);t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))})}registerPairingEvents(){this.client.core.pairing.events.on(ha.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(ha.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!ur(e,!1)){const{message:t}=De("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:t}=De("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(Rs(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=De("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!ur(e,!1)){const{message:t}=De("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:t}=De("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if(Rs(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:t}=De("EXPIRED",`session topic: ${e}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){const{message:t}=De("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(t)}}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(ur(e,!1)){const{message:t}=De("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}else{const{message:t}=De("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}async isValidProposalId(e){if(!II(e)){const{message:t}=De("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){const{message:t}=De("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if(Rs(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:t}=De("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}}class oB extends Ma{constructor(e,t){super(e,t,KN,v0),this.core=e,this.logger=t}}class cB extends Ma{constructor(e,t){super(e,t,VN,v0),this.core=e,this.logger=t}}class uB extends Ma{constructor(e,t){super(e,t,JN,v0,i=>i.id),this.core=e,this.logger=t}}class fB extends Ma{constructor(e,t){super(e,t,XN,sh,()=>hf),this.core=e,this.logger=t}}class hB extends Ma{constructor(e,t){super(e,t,ZN,sh),this.core=e,this.logger=t}}class lB extends Ma{constructor(e,t){super(e,t,eB,sh,i=>i.id),this.core=e,this.logger=t}}class dB{constructor(e,t){this.core=e,this.logger=t,this.authKeys=new fB(this.core,this.logger),this.pairingTopics=new hB(this.core,this.logger),this.requests=new lB(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}class m0 extends oP{constructor(e){super(e),this.protocol=$2,this.version=U2,this.name=Zl.name,this.events=new Vi.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(a){throw this.logger.error(a.message),a}},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==null?void 0:e.name)||Zl.name,this.metadata=(e==null?void 0:e.metadata)||o3(),this.signConfig=e==null?void 0:e.signConfig;const t=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:Uc(Zf({level:(e==null?void 0:e.logger)||Zl.logger}));this.core=(e==null?void 0:e.core)||new HN(e),this.logger=Qr(t,this.name),this.session=new cB(this.core,this.logger),this.proposal=new oB(this.core,this.logger),this.pendingRequest=new uB(this.core,this.logger),this.engine=new aB(this),this.auth=new dB(this.core,this.logger)}static async init(e){const t=new m0(e);return await t.initialize(),t}get context(){return pi(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}}}var Bd={exports:{}};(function(r,e){var t=typeof self<"u"?self:tv,i=function(){function a(){this.fetch=!1,this.DOMException=t.DOMException}return a.prototype=t,new a}();(function(a){(function(c){var f={searchParams:"URLSearchParams"in a,iterable:"Symbol"in a&&"iterator"in Symbol,blob:"FileReader"in a&&"Blob"in a&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in a,arrayBuffer:"ArrayBuffer"in a};function g(h){return h&&DataView.prototype.isPrototypeOf(h)}if(f.arrayBuffer)var d=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],m=ArrayBuffer.isView||function(h){return h&&d.indexOf(Object.prototype.toString.call(h))>-1};function w(h){if(typeof h!="string"&&(h=String(h)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(h))throw new TypeError("Invalid character in header field name");return h.toLowerCase()}function O(h){return typeof h!="string"&&(h=String(h)),h}function C(h){var v={next:function(){var E=h.shift();return{done:E===void 0,value:E}}};return f.iterable&&(v[Symbol.iterator]=function(){return v}),v}function P(h){this.map={},h instanceof P?h.forEach(function(v,E){this.append(E,v)},this):Array.isArray(h)?h.forEach(function(v){this.append(v[0],v[1])},this):h&&Object.getOwnPropertyNames(h).forEach(function(v){this.append(v,h[v])},this)}P.prototype.append=function(h,v){h=w(h),v=O(v);var E=this.map[h];this.map[h]=E?E+", "+v:v},P.prototype.delete=function(h){delete this.map[w(h)]},P.prototype.get=function(h){return h=w(h),this.has(h)?this.map[h]:null},P.prototype.has=function(h){return this.map.hasOwnProperty(w(h))},P.prototype.set=function(h,v){this.map[w(h)]=O(v)},P.prototype.forEach=function(h,v){for(var E in this.map)this.map.hasOwnProperty(E)&&h.call(v,this.map[E],E,this)},P.prototype.keys=function(){var h=[];return this.forEach(function(v,E){h.push(E)}),C(h)},P.prototype.values=function(){var h=[];return this.forEach(function(v){h.push(v)}),C(h)},P.prototype.entries=function(){var h=[];return this.forEach(function(v,E){h.push([E,v])}),C(h)},f.iterable&&(P.prototype[Symbol.iterator]=P.prototype.entries);function q(h){if(h.bodyUsed)return Promise.reject(new TypeError("Already read"));h.bodyUsed=!0}function K(h){return new Promise(function(v,E){h.onload=function(){v(h.result)},h.onerror=function(){E(h.error)}})}function Y(h){var v=new FileReader,E=K(v);return v.readAsArrayBuffer(h),E}function z(h){var v=new FileReader,E=K(v);return v.readAsText(h),E}function W(h){for(var v=new Uint8Array(h),E=new Array(v.length),S=0;S<v.length;S++)E[S]=String.fromCharCode(v[S]);return E.join("")}function B(h){if(h.slice)return h.slice(0);var v=new Uint8Array(h.byteLength);return v.set(new Uint8Array(h)),v.buffer}function j(){return this.bodyUsed=!1,this._initBody=function(h){this._bodyInit=h,h?typeof h=="string"?this._bodyText=h:f.blob&&Blob.prototype.isPrototypeOf(h)?this._bodyBlob=h:f.formData&&FormData.prototype.isPrototypeOf(h)?this._bodyFormData=h:f.searchParams&&URLSearchParams.prototype.isPrototypeOf(h)?this._bodyText=h.toString():f.arrayBuffer&&f.blob&&g(h)?(this._bodyArrayBuffer=B(h.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):f.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(h)||m(h))?this._bodyArrayBuffer=B(h):this._bodyText=h=Object.prototype.toString.call(h):this._bodyText="",this.headers.get("content-type")||(typeof h=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):f.searchParams&&URLSearchParams.prototype.isPrototypeOf(h)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},f.blob&&(this.blob=function(){var h=q(this);if(h)return h;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?q(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(Y)}),this.text=function(){var h=q(this);if(h)return h;if(this._bodyBlob)return z(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(W(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},f.formData&&(this.formData=function(){return this.text().then(se)}),this.json=function(){return this.text().then(JSON.parse)},this}var k=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function _(h){var v=h.toUpperCase();return k.indexOf(v)>-1?v:h}function N(h,v){v=v||{};var E=v.body;if(h instanceof N){if(h.bodyUsed)throw new TypeError("Already read");this.url=h.url,this.credentials=h.credentials,v.headers||(this.headers=new P(h.headers)),this.method=h.method,this.mode=h.mode,this.signal=h.signal,!E&&h._bodyInit!=null&&(E=h._bodyInit,h.bodyUsed=!0)}else this.url=String(h);if(this.credentials=v.credentials||this.credentials||"same-origin",(v.headers||!this.headers)&&(this.headers=new P(v.headers)),this.method=_(v.method||this.method||"GET"),this.mode=v.mode||this.mode||null,this.signal=v.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&E)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(E)}N.prototype.clone=function(){return new N(this,{body:this._bodyInit})};function se(h){var v=new FormData;return h.trim().split("&").forEach(function(E){if(E){var S=E.split("="),M=S.shift().replace(/\+/g," "),x=S.join("=").replace(/\+/g," ");v.append(decodeURIComponent(M),decodeURIComponent(x))}}),v}function le(h){var v=new P,E=h.replace(/\r?\n[\t ]+/g," ");return E.split(/\r?\n/).forEach(function(S){var M=S.split(":"),x=M.shift().trim();if(x){var p=M.join(":").trim();v.append(x,p)}}),v}j.call(N.prototype);function U(h,v){v||(v={}),this.type="default",this.status=v.status===void 0?200:v.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in v?v.statusText:"OK",this.headers=new P(v.headers),this.url=v.url||"",this._initBody(h)}j.call(U.prototype),U.prototype.clone=function(){return new U(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new P(this.headers),url:this.url})},U.error=function(){var h=new U(null,{status:0,statusText:""});return h.type="error",h};var y=[301,302,303,307,308];U.redirect=function(h,v){if(y.indexOf(v)===-1)throw new RangeError("Invalid status code");return new U(null,{status:v,headers:{location:h}})},c.DOMException=a.DOMException;try{new c.DOMException}catch{c.DOMException=function(v,E){this.message=v,this.name=E;var S=Error(v);this.stack=S.stack},c.DOMException.prototype=Object.create(Error.prototype),c.DOMException.prototype.constructor=c.DOMException}function u(h,v){return new Promise(function(E,S){var M=new N(h,v);if(M.signal&&M.signal.aborted)return S(new c.DOMException("Aborted","AbortError"));var x=new XMLHttpRequest;function p(){x.abort()}x.onload=function(){var b={status:x.status,statusText:x.statusText,headers:le(x.getAllResponseHeaders()||"")};b.url="responseURL"in x?x.responseURL:b.headers.get("X-Request-URL");var R="response"in x?x.response:x.responseText;E(new U(R,b))},x.onerror=function(){S(new TypeError("Network request failed"))},x.ontimeout=function(){S(new TypeError("Network request failed"))},x.onabort=function(){S(new c.DOMException("Aborted","AbortError"))},x.open(M.method,M.url,!0),M.credentials==="include"?x.withCredentials=!0:M.credentials==="omit"&&(x.withCredentials=!1),"responseType"in x&&f.blob&&(x.responseType="blob"),M.headers.forEach(function(b,R){x.setRequestHeader(R,b)}),M.signal&&(M.signal.addEventListener("abort",p),x.onreadystatechange=function(){x.readyState===4&&M.signal.removeEventListener("abort",p)}),x.send(typeof M._bodyInit>"u"?null:M._bodyInit)})}return u.polyfill=!0,a.fetch||(a.fetch=u,a.Headers=P,a.Request=N,a.Response=U),c.Headers=P,c.Request=N,c.Response=U,c.fetch=u,Object.defineProperty(c,"__esModule",{value:!0}),c})({})})(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var n=i;e=n.fetch,e.default=n.fetch,e.fetch=n.fetch,e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response,r.exports=e})(Bd,Bd.exports);var pB=Bd.exports;const Rb=Ld(pB);var gB=Object.defineProperty,bB=Object.defineProperties,vB=Object.getOwnPropertyDescriptors,Nb=Object.getOwnPropertySymbols,mB=Object.prototype.hasOwnProperty,yB=Object.prototype.propertyIsEnumerable,Bb=(r,e,t)=>e in r?gB(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,$b=(r,e)=>{for(var t in e||(e={}))mB.call(e,t)&&Bb(r,t,e[t]);if(Nb)for(var t of Nb(e))yB.call(e,t)&&Bb(r,t,e[t]);return r},Ub=(r,e)=>bB(r,vB(e));const wB={Accept:"application/json","Content-Type":"application/json"},_B="POST",qb={headers:wB,method:_B},Lb=10;class Wn{constructor(e,t=!1){if(this.url=e,this.disableProviderPing=t,this.events=new Vi.EventEmitter,this.isAvailable=!1,this.registering=!1,!ab(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);this.url=e,this.disableProviderPing=t}get connected(){return this.isAvailable}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(e){this.isAvailable||await this.register();try{const t=ys(e),i=await(await Rb(this.url,Ub($b({},qb),{body:t}))).json();this.onPayload({data:i})}catch(t){this.onError(e.id,t)}}async register(e=this.url){if(!ab(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering){const t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise((i,n)=>{this.events.once("register_error",a=>{this.resetMaxListeners(),n(a)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return n(new Error("HTTP connection is missing or invalid"));i()})})}this.url=e,this.registering=!0;try{if(!this.disableProviderPing){const t=ys({id:1,jsonrpc:"2.0",method:"test",params:[]});await Rb(e,Ub($b({},qb),{body:t}))}this.onOpen()}catch(t){const i=this.parseError(t);throw this.events.emit("register_error",i),this.onClose(),i}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(e){if(typeof e.data>"u")return;const t=typeof e.data=="string"?ma(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const i=this.parseError(t),n=i.message||i.toString(),a=rh(e,n);this.events.emit("payload",a)}parseError(e,t=this.url){return g2(e,t,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>Lb&&this.events.setMaxListeners(Lb)}}const Fb="error",DB="wss://relay.walletconnect.org",EB="wc",AB="universal_provider",zb=`${EB}@2:${AB}:`,F2="https://rpc.walletconnect.org/v1/",Za="generic",xB=`${F2}bundler`,mn={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var ac=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},$d={exports:{}};/**
* @license
* Lodash <https://lodash.com/>
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/(function(r,e){(function(){var t,i="4.17.21",n=200,a="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",c="Expected a function",f="Invalid `variable` option passed into `_.template`",g="__lodash_hash_undefined__",d=500,m="__lodash_placeholder__",w=1,O=2,C=4,P=1,q=2,K=1,Y=2,z=4,W=8,B=16,j=32,k=64,_=128,N=256,se=512,le=30,U="...",y=800,u=16,h=1,v=2,E=3,S=1/0,M=9007199254740991,x=17976931348623157e292,p=NaN,b=4294967295,R=b-1,Z=b>>>1,ae=[["ary",_],["bind",K],["bindKey",Y],["curry",W],["curryRight",B],["flip",se],["partial",j],["partialRight",k],["rearg",N]],I="[object Arguments]",ee="[object Array]",L="[object AsyncFunction]",V="[object Boolean]",G="[object Date]",D="[object DOMException]",H="[object Error]",ne="[object Function]",ce="[object GeneratorFunction]",fe="[object Map]",ye="[object Number]",we="[object Null]",Te="[object Object]",Qe="[object Promise]",Ce="[object Proxy]",Re="[object RegExp]",Se="[object Set]",me="[object String]",Pe="[object Symbol]",Ne="[object Undefined]",be="[object WeakMap]",Oe="[object WeakSet]",xe="[object ArrayBuffer]",ve="[object DataView]",qe="[object Float32Array]",Me="[object Float64Array]",_e="[object Int8Array]",He="[object Int16Array]",Ve="[object Int32Array]",Ee="[object Uint8Array]",Ke="[object Uint8ClampedArray]",ht="[object Uint16Array]",Ge="[object Uint32Array]",_t=/\b__p \+= '';/g,lt=/\b(__p \+=) '' \+/g,We=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Et=/&(?:amp|lt|gt|quot|#39);/g,St=/[&<>"']/g,Be=RegExp(Et.source),Xe=RegExp(St.source),tt=/<%-([\s\S]+?)%>/g,$e=/<%([\s\S]+?)%>/g,et=/<%=([\s\S]+?)%>/g,Ze=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Fe=/^\w*$/,ut=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,rt=/[\\^$.*+?()[\]{}|]/g,ze=RegExp(rt.source),it=/^\s+/,st=/\s/,Ue=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Ye=/\{\n\/\* \[wrapped with (.+)\] \*/,ft=/,? & /,je=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Rt=/[()=,{}\[\]\/\s]/,Nt=/\\(\\)?/g,at=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,vt=/\w*$/,Rr=/^[-+]0x[0-9a-f]+$/i,Nr=/^0b[01]+$/i,Br=/^\[object .+?Constructor\]$/,$r=/^0o[0-7]+$/i,Ur=/^(?:0|[1-9]\d*)$/,er=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Xr=/($^)/,Wi=/['\n\r\u2028\u2029\\]/g,Zr="\\ud800-\\udfff",Yi="\\u0300-\\u036f",Qi="\\ufe20-\\ufe2f",ei="\\u20d0-\\u20ff",Mi=Yi+Qi+ei,Ii="\\u2700-\\u27bf",lr="a-z\\xdf-\\xf6\\xf8-\\xff",Xi="\\xac\\xb1\\xd7\\xf7",Zi="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",en="\\u2000-\\u206f",Ks=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",zc="A-Z\\xc0-\\xd6\\xd8-\\xde",jc="\\ufe0e\\ufe0f",Vs=Xi+Zi+en+Ks,Io="[']",Gs="["+Zr+"]",Co="["+Vs+"]",Js="["+Mi+"]",kc="\\d+",ah="["+Ii+"]",Hc="["+lr+"]",Kc="[^"+Zr+Vs+kc+Ii+lr+zc+"]",Pa="\\ud83c[\\udffb-\\udfff]",oh="(?:"+Js+"|"+Pa+")",Vc="[^"+Zr+"]",Oa="(?:\\ud83c[\\udde6-\\uddff]){2}",_s="[\\ud800-\\udbff][\\udc00-\\udfff]",gi="["+zc+"]",Gc="\\u200d",Jc="(?:"+Hc+"|"+Kc+")",yn="(?:"+gi+"|"+Kc+")",Wc="(?:"+Io+"(?:d|ll|m|re|s|t|ve))?",Yc="(?:"+Io+"(?:D|LL|M|RE|S|T|VE))?",Qc=oh+"?",Xc="["+jc+"]?",ch="(?:"+Gc+"(?:"+[Vc,Oa,_s].join("|")+")"+Xc+Qc+")*",Yn="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Zc="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",eu=Xc+Qc+ch,Ta="(?:"+[ah,Oa,_s].join("|")+")"+eu,uh="(?:"+[Vc+Js+"?",Js,Oa,_s,Gs].join("|")+")",Po=RegExp(Io,"g"),fh=RegExp(Js,"g"),Ra=RegExp(Pa+"(?="+Pa+")|"+uh+eu,"g"),tu=RegExp([gi+"?"+Hc+"+"+Wc+"(?="+[Co,gi,"$"].join("|")+")",yn+"+"+Yc+"(?="+[Co,gi+Jc,"$"].join("|")+")",gi+"?"+Jc+"+"+Wc,gi+"+"+Yc,Zc,Yn,kc,Ta].join("|"),"g"),ru=RegExp("["+Gc+Zr+Mi+jc+"]"),Ws=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,iu=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],hh=-1,zt={};zt[qe]=zt[Me]=zt[_e]=zt[He]=zt[Ve]=zt[Ee]=zt[Ke]=zt[ht]=zt[Ge]=!0,zt[I]=zt[ee]=zt[xe]=zt[V]=zt[ve]=zt[G]=zt[H]=zt[ne]=zt[fe]=zt[ye]=zt[Te]=zt[Re]=zt[Se]=zt[me]=zt[be]=!1;var Ft={};Ft[I]=Ft[ee]=Ft[xe]=Ft[ve]=Ft[V]=Ft[G]=Ft[qe]=Ft[Me]=Ft[_e]=Ft[He]=Ft[Ve]=Ft[fe]=Ft[ye]=Ft[Te]=Ft[Re]=Ft[Se]=Ft[me]=Ft[Pe]=Ft[Ee]=Ft[Ke]=Ft[ht]=Ft[Ge]=!0,Ft[H]=Ft[ne]=Ft[be]=!1;var J={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},te={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},pe={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},Le={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},jt=parseFloat,pt=parseInt,Wt=typeof ac=="object"&&ac&&ac.Object===Object&&ac,fr=typeof self=="object"&&self&&self.Object===Object&&self,Ot=Wt||fr||Function("return this")(),kt=e&&!e.nodeType&&e,sr=kt&&!0&&r&&!r.nodeType&&r,ti=sr&&sr.exports===kt,hr=ti&&Wt.process,Yt=function(){try{var re=sr&&sr.require&&sr.require("util").types;return re||hr&&hr.binding&&hr.binding("util")}catch{}}(),kr=Yt&&Yt.isArrayBuffer,tn=Yt&&Yt.isDate,Ci=Yt&&Yt.isMap,wn=Yt&&Yt.isRegExp,Oo=Yt&&Yt.isSet,Ys=Yt&&Yt.isTypedArray;function vr(re,ue,oe){switch(oe.length){case 0:return re.call(ue);case 1:return re.call(ue,oe[0]);case 2:return re.call(ue,oe[0],oe[1]);case 3:return re.call(ue,oe[0],oe[1],oe[2])}return re.apply(ue,oe)}function k2(re,ue,oe,ke){for(var dt=-1,Bt=re==null?0:re.length;++dt<Bt;){var dr=re[dt];ue(ke,dr,oe(dr),re)}return ke}function Pi(re,ue){for(var oe=-1,ke=re==null?0:re.length;++oe<ke&&ue(re[oe],oe,re)!==!1;);return re}function H2(re,ue){for(var oe=re==null?0:re.length;oe--&&ue(re[oe],oe,re)!==!1;);return re}function _0(re,ue){for(var oe=-1,ke=re==null?0:re.length;++oe<ke;)if(!ue(re[oe],oe,re))return!1;return!0}function Ds(re,ue){for(var oe=-1,ke=re==null?0:re.length,dt=0,Bt=[];++oe<ke;){var dr=re[oe];ue(dr,oe,re)&&(Bt[dt++]=dr)}return Bt}function nu(re,ue){var oe=re==null?0:re.length;return!!oe&&Na(re,ue,0)>-1}function lh(re,ue,oe){for(var ke=-1,dt=re==null?0:re.length;++ke<dt;)if(oe(ue,re[ke]))return!0;return!1}function Xt(re,ue){for(var oe=-1,ke=re==null?0:re.length,dt=Array(ke);++oe<ke;)dt[oe]=ue(re[oe],oe,re);return dt}function Es(re,ue){for(var oe=-1,ke=ue.length,dt=re.length;++oe<ke;)re[dt+oe]=ue[oe];return re}function dh(re,ue,oe,ke){var dt=-1,Bt=re==null?0:re.length;for(ke&&Bt&&(oe=re[++dt]);++dt<Bt;)oe=ue(oe,re[dt],dt,re);return oe}function K2(re,ue,oe,ke){var dt=re==null?0:re.length;for(ke&&dt&&(oe=re[--dt]);dt--;)oe=ue(oe,re[dt],dt,re);return oe}function ph(re,ue){for(var oe=-1,ke=re==null?0:re.length;++oe<ke;)if(ue(re[oe],oe,re))return!0;return!1}var V2=gh("length");function G2(re){return re.split("")}function J2(re){return re.match(je)||[]}function D0(re,ue,oe){var ke;return oe(re,function(dt,Bt,dr){if(ue(dt,Bt,dr))return ke=Bt,!1}),ke}function su(re,ue,oe,ke){for(var dt=re.length,Bt=oe+(ke?1:-1);ke?Bt--:++Bt<dt;)if(ue(re[Bt],Bt,re))return Bt;return-1}function Na(re,ue,oe){return ue===ue?am(re,ue,oe):su(re,E0,oe)}function W2(re,ue,oe,ke){for(var dt=oe-1,Bt=re.length;++dt<Bt;)if(ke(re[dt],ue))return dt;return-1}function E0(re){return re!==re}function A0(re,ue){var oe=re==null?0:re.length;return oe?vh(re,ue)/oe:p}function gh(re){return function(ue){return ue==null?t:ue[re]}}function bh(re){return function(ue){return re==null?t:re[ue]}}function x0(re,ue,oe,ke,dt){return dt(re,function(Bt,dr,Ht){oe=ke?(ke=!1,Bt):ue(oe,Bt,dr,Ht)}),oe}function Y2(re,ue){var oe=re.length;for(re.sort(ue);oe--;)re[oe]=re[oe].value;return re}function vh(re,ue){for(var oe,ke=-1,dt=re.length;++ke<dt;){var Bt=ue(re[ke]);Bt!==t&&(oe=oe===t?Bt:oe+Bt)}return oe}function mh(re,ue){for(var oe=-1,ke=Array(re);++oe<re;)ke[oe]=ue(oe);return ke}function Q2(re,ue){return Xt(ue,function(oe){return[oe,re[oe]]})}function S0(re){return re&&re.slice(0,P0(re)+1).replace(it,"")}function bi(re){return function(ue){return re(ue)}}function yh(re,ue){return Xt(ue,function(oe){return re[oe]})}function To(re,ue){return re.has(ue)}function M0(re,ue){for(var oe=-1,ke=re.length;++oe<ke&&Na(ue,re[oe],0)>-1;);return oe}function I0(re,ue){for(var oe=re.length;oe--&&Na(ue,re[oe],0)>-1;);return oe}function X2(re,ue){for(var oe=re.length,ke=0;oe--;)re[oe]===ue&&++ke;return ke}var Z2=bh(J),em=bh(te);function tm(re){return"\\"+Le[re]}function rm(re,ue){return re==null?t:re[ue]}function Ba(re){return ru.test(re)}function im(re){return Ws.test(re)}function nm(re){for(var ue,oe=[];!(ue=re.next()).done;)oe.push(ue.value);return oe}function wh(re){var ue=-1,oe=Array(re.size);return re.forEach(function(ke,dt){oe[++ue]=[dt,ke]}),oe}function C0(re,ue){return function(oe){return re(ue(oe))}}function As(re,ue){for(var oe=-1,ke=re.length,dt=0,Bt=[];++oe<ke;){var dr=re[oe];(dr===ue||dr===m)&&(re[oe]=m,Bt[dt++]=oe)}return Bt}function au(re){var ue=-1,oe=Array(re.size);return re.forEach(function(ke){oe[++ue]=ke}),oe}function sm(re){var ue=-1,oe=Array(re.size);return re.forEach(function(ke){oe[++ue]=[ke,ke]}),oe}function am(re,ue,oe){for(var ke=oe-1,dt=re.length;++ke<dt;)if(re[ke]===ue)return ke;return-1}function om(re,ue,oe){for(var ke=oe+1;ke--;)if(re[ke]===ue)return ke;return ke}function $a(re){return Ba(re)?um(re):V2(re)}function rn(re){return Ba(re)?fm(re):G2(re)}function P0(re){for(var ue=re.length;ue--&&st.test(re.charAt(ue)););return ue}var cm=bh(pe);function um(re){for(var ue=Ra.lastIndex=0;Ra.test(re);)++ue;return ue}function fm(re){return re.match(Ra)||[]}function hm(re){return re.match(tu)||[]}var lm=function re(ue){ue=ue==null?Ot:Ua.defaults(Ot.Object(),ue,Ua.pick(Ot,iu));var oe=ue.Array,ke=ue.Date,dt=ue.Error,Bt=ue.Function,dr=ue.Math,Ht=ue.Object,_h=ue.RegExp,dm=ue.String,Oi=ue.TypeError,ou=oe.prototype,pm=Bt.prototype,qa=Ht.prototype,cu=ue["__core-js_shared__"],uu=pm.toString,qt=qa.hasOwnProperty,gm=0,O0=function(){var s=/[^.]+$/.exec(cu&&cu.keys&&cu.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""}(),fu=qa.toString,bm=uu.call(Ht),vm=Ot._,mm=_h("^"+uu.call(qt).replace(rt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),hu=ti?ue.Buffer:t,xs=ue.Symbol,lu=ue.Uint8Array,T0=hu?hu.allocUnsafe:t,du=C0(Ht.getPrototypeOf,Ht),R0=Ht.create,N0=qa.propertyIsEnumerable,pu=ou.splice,B0=xs?xs.isConcatSpreadable:t,Ro=xs?xs.iterator:t,Qs=xs?xs.toStringTag:t,gu=function(){try{var s=ra(Ht,"defineProperty");return s({},"",{}),s}catch{}}(),ym=ue.clearTimeout!==Ot.clearTimeout&&ue.clearTimeout,wm=ke&&ke.now!==Ot.Date.now&&ke.now,_m=ue.setTimeout!==Ot.setTimeout&&ue.setTimeout,bu=dr.ceil,vu=dr.floor,Dh=Ht.getOwnPropertySymbols,Dm=hu?hu.isBuffer:t,$0=ue.isFinite,Em=ou.join,Am=C0(Ht.keys,Ht),pr=dr.max,qr=dr.min,xm=ke.now,Sm=ue.parseInt,U0=dr.random,Mm=ou.reverse,Eh=ra(ue,"DataView"),No=ra(ue,"Map"),Ah=ra(ue,"Promise"),La=ra(ue,"Set"),Bo=ra(ue,"WeakMap"),$o=ra(Ht,"create"),mu=Bo&&new Bo,Fa={},Im=ia(Eh),Cm=ia(No),Pm=ia(Ah),Om=ia(La),Tm=ia(Bo),yu=xs?xs.prototype:t,Uo=yu?yu.valueOf:t,q0=yu?yu.toString:t;function $(s){if(tr(s)&&!gt(s)&&!(s instanceof Mt)){if(s instanceof Ti)return s;if(qt.call(s,"__wrapped__"))return Lp(s)}return new Ti(s)}var za=function(){function s(){}return function(o){if(!Zt(o))return{};if(R0)return R0(o);s.prototype=o;var l=new s;return s.prototype=t,l}}();function wu(){}function Ti(s,o){this.__wrapped__=s,this.__actions__=[],this.__chain__=!!o,this.__index__=0,this.__values__=t}$.templateSettings={escape:tt,evaluate:$e,interpolate:et,variable:"",imports:{_:$}},$.prototype=wu.prototype,$.prototype.constructor=$,Ti.prototype=za(wu.prototype),Ti.prototype.constructor=Ti;function Mt(s){this.__wrapped__=s,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=b,this.__views__=[]}function Rm(){var s=new Mt(this.__wrapped__);return s.__actions__=ri(this.__actions__),s.__dir__=this.__dir__,s.__filtered__=this.__filtered__,s.__iteratees__=ri(this.__iteratees__),s.__takeCount__=this.__takeCount__,s.__views__=ri(this.__views__),s}function Nm(){if(this.__filtered__){var s=new Mt(this);s.__dir__=-1,s.__filtered__=!0}else s=this.clone(),s.__dir__*=-1;return s}function Bm(){var s=this.__wrapped__.value(),o=this.__dir__,l=gt(s),A=o<0,T=l?s.length:0,F=Gy(0,T,this.__views__),Q=F.start,X=F.end,ie=X-Q,he=A?X:Q-1,de=this.__iteratees__,ge=de.length,Ie=0,Je=qr(ie,this.__takeCount__);if(!l||!A&&T==ie&&Je==ie)return cp(s,this.__actions__);var ot=[];e:for(;ie--&&Ie<Je;){he+=o;for(var wt=-1,ct=s[he];++wt<ge;){var At=de[wt],Tt=At.iteratee,yi=At.type,Vr=Tt(ct);if(yi==v)ct=Vr;else if(!Vr){if(yi==h)continue e;break e}}ot[Ie++]=ct}return ot}Mt.prototype=za(wu.prototype),Mt.prototype.constructor=Mt;function Xs(s){var o=-1,l=s==null?0:s.length;for(this.clear();++o<l;){var A=s[o];this.set(A[0],A[1])}}function $m(){this.__data__=$o?$o(null):{},this.size=0}function Um(s){var o=this.has(s)&&delete this.__data__[s];return this.size-=o?1:0,o}function qm(s){var o=this.__data__;if($o){var l=o[s];return l===g?t:l}return qt.call(o,s)?o[s]:t}function Lm(s){var o=this.__data__;return $o?o[s]!==t:qt.call(o,s)}function Fm(s,o){var l=this.__data__;return this.size+=this.has(s)?0:1,l[s]=$o&&o===t?g:o,this}Xs.prototype.clear=$m,Xs.prototype.delete=Um,Xs.prototype.get=qm,Xs.prototype.has=Lm,Xs.prototype.set=Fm;function Qn(s){var o=-1,l=s==null?0:s.length;for(this.clear();++o<l;){var A=s[o];this.set(A[0],A[1])}}function zm(){this.__data__=[],this.size=0}function jm(s){var o=this.__data__,l=_u(o,s);if(l<0)return!1;var A=o.length-1;return l==A?o.pop():pu.call(o,l,1),--this.size,!0}function km(s){var o=this.__data__,l=_u(o,s);return l<0?t:o[l][1]}function Hm(s){return _u(this.__data__,s)>-1}function Km(s,o){var l=this.__data__,A=_u(l,s);return A<0?(++this.size,l.push([s,o])):l[A][1]=o,this}Qn.prototype.clear=zm,Qn.prototype.delete=jm,Qn.prototype.get=km,Qn.prototype.has=Hm,Qn.prototype.set=Km;function Xn(s){var o=-1,l=s==null?0:s.length;for(this.clear();++o<l;){var A=s[o];this.set(A[0],A[1])}}function Vm(){this.size=0,this.__data__={hash:new Xs,map:new(No||Qn),string:new Xs}}function Gm(s){var o=Ru(this,s).delete(s);return this.size-=o?1:0,o}function Jm(s){return Ru(this,s).get(s)}function Wm(s){return Ru(this,s).has(s)}function Ym(s,o){var l=Ru(this,s),A=l.size;return l.set(s,o),this.size+=l.size==A?0:1,this}Xn.prototype.clear=Vm,Xn.prototype.delete=Gm,Xn.prototype.get=Jm,Xn.prototype.has=Wm,Xn.prototype.set=Ym;function Zs(s){var o=-1,l=s==null?0:s.length;for(this.__data__=new Xn;++o<l;)this.add(s[o])}function Qm(s){return this.__data__.set(s,g),this}function Xm(s){return this.__data__.has(s)}Zs.prototype.add=Zs.prototype.push=Qm,Zs.prototype.has=Xm;function nn(s){var o=this.__data__=new Qn(s);this.size=o.size}function Zm(){this.__data__=new Qn,this.size=0}function ey(s){var o=this.__data__,l=o.delete(s);return this.size=o.size,l}function ty(s){return this.__data__.get(s)}function ry(s){return this.__data__.has(s)}function iy(s,o){var l=this.__data__;if(l instanceof Qn){var A=l.__data__;if(!No||A.length<n-1)return A.push([s,o]),this.size=++l.size,this;l=this.__data__=new Xn(A)}return l.set(s,o),this.size=l.size,this}nn.prototype.clear=Zm,nn.prototype.delete=ey,nn.prototype.get=ty,nn.prototype.has=ry,nn.prototype.set=iy;function L0(s,o){var l=gt(s),A=!l&&na(s),T=!l&&!A&&Ps(s),F=!l&&!A&&!T&&Ka(s),Q=l||A||T||F,X=Q?mh(s.length,dm):[],ie=X.length;for(var he in s)(o||qt.call(s,he))&&!(Q&&(he=="length"||T&&(he=="offset"||he=="parent")||F&&(he=="buffer"||he=="byteLength"||he=="byteOffset")||rs(he,ie)))&&X.push(he);return X}function F0(s){var o=s.length;return o?s[Bh(0,o-1)]:t}function ny(s,o){return Nu(ri(s),ea(o,0,s.length))}function sy(s){return Nu(ri(s))}function xh(s,o,l){(l!==t&&!sn(s[o],l)||l===t&&!(o in s))&&Zn(s,o,l)}function qo(s,o,l){var A=s[o];(!(qt.call(s,o)&&sn(A,l))||l===t&&!(o in s))&&Zn(s,o,l)}function _u(s,o){for(var l=s.length;l--;)if(sn(s[l][0],o))return l;return-1}function ay(s,o,l,A){return Ss(s,function(T,F,Q){o(A,T,l(T),Q)}),A}function z0(s,o){return s&&Dn(o,mr(o),s)}function oy(s,o){return s&&Dn(o,ni(o),s)}function Zn(s,o,l){o=="__proto__"&&gu?gu(s,o,{configurable:!0,enumerable:!0,value:l,writable:!0}):s[o]=l}function Sh(s,o){for(var l=-1,A=o.length,T=oe(A),F=s==null;++l<A;)T[l]=F?t:al(s,o[l]);return T}function ea(s,o,l){return s===s&&(l!==t&&(s=s<=l?s:l),o!==t&&(s=s>=o?s:o)),s}function Ri(s,o,l,A,T,F){var Q,X=o&w,ie=o&O,he=o&C;if(l&&(Q=T?l(s,A,T,F):l(s)),Q!==t)return Q;if(!Zt(s))return s;var de=gt(s);if(de){if(Q=Wy(s),!X)return ri(s,Q)}else{var ge=Lr(s),Ie=ge==ne||ge==ce;if(Ps(s))return hp(s,X);if(ge==Te||ge==I||Ie&&!T){if(Q=ie||Ie?{}:Pp(s),!X)return ie?qy(s,oy(Q,s)):Uy(s,z0(Q,s))}else{if(!Ft[ge])return T?s:{};Q=Yy(s,ge,X)}}F||(F=new nn);var Je=F.get(s);if(Je)return Je;F.set(s,Q),s1(s)?s.forEach(function(ct){Q.add(Ri(ct,o,l,ct,s,F))}):i1(s)&&s.forEach(function(ct,At){Q.set(At,Ri(ct,o,l,At,s,F))});var ot=he?ie?Vh:Kh:ie?ni:mr,wt=de?t:ot(s);return Pi(wt||s,function(ct,At){wt&&(At=ct,ct=s[At]),qo(Q,At,Ri(ct,o,l,At,s,F))}),Q}function cy(s){var o=mr(s);return function(l){return j0(l,s,o)}}function j0(s,o,l){var A=l.length;if(s==null)return!A;for(s=Ht(s);A--;){var T=l[A],F=o[T],Q=s[T];if(Q===t&&!(T in s)||!F(Q))return!1}return!0}function k0(s,o,l){if(typeof s!="function")throw new Oi(c);return Ko(function(){s.apply(t,l)},o)}function Lo(s,o,l,A){var T=-1,F=nu,Q=!0,X=s.length,ie=[],he=o.length;if(!X)return ie;l&&(o=Xt(o,bi(l))),A?(F=lh,Q=!1):o.length>=n&&(F=To,Q=!1,o=new Zs(o));e:for(;++T<X;){var de=s[T],ge=l==null?de:l(de);if(de=A||de!==0?de:0,Q&&ge===ge){for(var Ie=he;Ie--;)if(o[Ie]===ge)continue e;ie.push(de)}else F(o,ge,A)||ie.push(de)}return ie}var Ss=bp(_n),H0=bp(Ih,!0);function uy(s,o){var l=!0;return Ss(s,function(A,T,F){return l=!!o(A,T,F),l}),l}function Du(s,o,l){for(var A=-1,T=s.length;++A<T;){var F=s[A],Q=o(F);if(Q!=null&&(X===t?Q===Q&&!mi(Q):l(Q,X)))var X=Q,ie=F}return ie}function fy(s,o,l,A){var T=s.length;for(l=yt(l),l<0&&(l=-l>T?0:T+l),A=A===t||A>T?T:yt(A),A<0&&(A+=T),A=l>A?0:o1(A);l<A;)s[l++]=o;return s}function K0(s,o){var l=[];return Ss(s,function(A,T,F){o(A,T,F)&&l.push(A)}),l}function xr(s,o,l,A,T){var F=-1,Q=s.length;for(l||(l=Xy),T||(T=[]);++F<Q;){var X=s[F];o>0&&l(X)?o>1?xr(X,o-1,l,A,T):Es(T,X):A||(T[T.length]=X)}return T}var Mh=vp(),V0=vp(!0);function _n(s,o){return s&&Mh(s,o,mr)}function Ih(s,o){return s&&V0(s,o,mr)}function Eu(s,o){return Ds(o,function(l){return is(s[l])})}function ta(s,o){o=Is(o,s);for(var l=0,A=o.length;s!=null&&l<A;)s=s[En(o[l++])];return l&&l==A?s:t}function G0(s,o,l){var A=o(s);return gt(s)?A:Es(A,l(s))}function Hr(s){return s==null?s===t?Ne:we:Qs&&Qs in Ht(s)?Vy(s):s6(s)}function Ch(s,o){return s>o}function hy(s,o){return s!=null&&qt.call(s,o)}function ly(s,o){return s!=null&&o in Ht(s)}function dy(s,o,l){return s>=qr(o,l)&&s<pr(o,l)}function Ph(s,o,l){for(var A=l?lh:nu,T=s[0].length,F=s.length,Q=F,X=oe(F),ie=1/0,he=[];Q--;){var de=s[Q];Q&&o&&(de=Xt(de,bi(o))),ie=qr(de.length,ie),X[Q]=!l&&(o||T>=120&&de.length>=120)?new Zs(Q&&de):t}de=s[0];var ge=-1,Ie=X[0];e:for(;++ge<T&&he.length<ie;){var Je=de[ge],ot=o?o(Je):Je;if(Je=l||Je!==0?Je:0,!(Ie?To(Ie,ot):A(he,ot,l))){for(Q=F;--Q;){var wt=X[Q];if(!(wt?To(wt,ot):A(s[Q],ot,l)))continue e}Ie&&Ie.push(ot),he.push(Je)}}return he}function py(s,o,l,A){return _n(s,function(T,F,Q){o(A,l(T),F,Q)}),A}function Fo(s,o,l){o=Is(o,s),s=Np(s,o);var A=s==null?s:s[En(Bi(o))];return A==null?t:vr(A,s,l)}function J0(s){return tr(s)&&Hr(s)==I}function gy(s){return tr(s)&&Hr(s)==xe}function by(s){return tr(s)&&Hr(s)==G}function zo(s,o,l,A,T){return s===o?!0:s==null||o==null||!tr(s)&&!tr(o)?s!==s&&o!==o:vy(s,o,l,A,zo,T)}function vy(s,o,l,A,T,F){var Q=gt(s),X=gt(o),ie=Q?ee:Lr(s),he=X?ee:Lr(o);ie=ie==I?Te:ie,he=he==I?Te:he;var de=ie==Te,ge=he==Te,Ie=ie==he;if(Ie&&Ps(s)){if(!Ps(o))return!1;Q=!0,de=!1}if(Ie&&!de)return F||(F=new nn),Q||Ka(s)?Mp(s,o,l,A,T,F):Hy(s,o,ie,l,A,T,F);if(!(l&P)){var Je=de&&qt.call(s,"__wrapped__"),ot=ge&&qt.call(o,"__wrapped__");if(Je||ot){var wt=Je?s.value():s,ct=ot?o.value():o;return F||(F=new nn),T(wt,ct,l,A,F)}}return Ie?(F||(F=new nn),Ky(s,o,l,A,T,F)):!1}function my(s){return tr(s)&&Lr(s)==fe}function Oh(s,o,l,A){var T=l.length,F=T,Q=!A;if(s==null)return!F;for(s=Ht(s);T--;){var X=l[T];if(Q&&X[2]?X[1]!==s[X[0]]:!(X[0]in s))return!1}for(;++T<F;){X=l[T];var ie=X[0],he=s[ie],de=X[1];if(Q&&X[2]){if(he===t&&!(ie in s))return!1}else{var ge=new nn;if(A)var Ie=A(he,de,ie,s,o,ge);if(!(Ie===t?zo(de,he,P|q,A,ge):Ie))return!1}}return!0}function W0(s){if(!Zt(s)||e6(s))return!1;var o=is(s)?mm:Br;return o.test(ia(s))}function yy(s){return tr(s)&&Hr(s)==Re}function wy(s){return tr(s)&&Lr(s)==Se}function _y(s){return tr(s)&&Fu(s.length)&&!!zt[Hr(s)]}function Y0(s){return typeof s=="function"?s:s==null?si:typeof s=="object"?gt(s)?Z0(s[0],s[1]):X0(s):m1(s)}function Th(s){if(!Ho(s))return Am(s);var o=[];for(var l in Ht(s))qt.call(s,l)&&l!="constructor"&&o.push(l);return o}function Dy(s){if(!Zt(s))return n6(s);var o=Ho(s),l=[];for(var A in s)A=="constructor"&&(o||!qt.call(s,A))||l.push(A);return l}function Rh(s,o){return s<o}function Q0(s,o){var l=-1,A=ii(s)?oe(s.length):[];return Ss(s,function(T,F,Q){A[++l]=o(T,F,Q)}),A}function X0(s){var o=Jh(s);return o.length==1&&o[0][2]?Tp(o[0][0],o[0][1]):function(l){return l===s||Oh(l,s,o)}}function Z0(s,o){return Yh(s)&&Op(o)?Tp(En(s),o):function(l){var A=al(l,s);return A===t&&A===o?ol(l,s):zo(o,A,P|q)}}function Au(s,o,l,A,T){s!==o&&Mh(o,function(F,Q){if(T||(T=new nn),Zt(F))Ey(s,o,Q,l,Au,A,T);else{var X=A?A(Xh(s,Q),F,Q+"",s,o,T):t;X===t&&(X=F),xh(s,Q,X)}},ni)}function Ey(s,o,l,A,T,F,Q){var X=Xh(s,l),ie=Xh(o,l),he=Q.get(ie);if(he){xh(s,l,he);return}var de=F?F(X,ie,l+"",s,o,Q):t,ge=de===t;if(ge){var Ie=gt(ie),Je=!Ie&&Ps(ie),ot=!Ie&&!Je&&Ka(ie);de=ie,Ie||Je||ot?gt(X)?de=X:ar(X)?de=ri(X):Je?(ge=!1,de=hp(ie,!0)):ot?(ge=!1,de=lp(ie,!0)):de=[]:Vo(ie)||na(ie)?(de=X,na(X)?de=c1(X):(!Zt(X)||is(X))&&(de=Pp(ie))):ge=!1}ge&&(Q.set(ie,de),T(de,ie,A,F,Q),Q.delete(ie)),xh(s,l,de)}function ep(s,o){var l=s.length;if(l)return o+=o<0?l:0,rs(o,l)?s[o]:t}function tp(s,o,l){o.length?o=Xt(o,function(F){return gt(F)?function(Q){return ta(Q,F.length===1?F[0]:F)}:F}):o=[si];var A=-1;o=Xt(o,bi(nt()));var T=Q0(s,function(F,Q,X){var ie=Xt(o,function(he){return he(F)});return{criteria:ie,index:++A,value:F}});return Y2(T,function(F,Q){return $y(F,Q,l)})}function Ay(s,o){return rp(s,o,function(l,A){return ol(s,A)})}function rp(s,o,l){for(var A=-1,T=o.length,F={};++A<T;){var Q=o[A],X=ta(s,Q);l(X,Q)&&jo(F,Is(Q,s),X)}return F}function xy(s){return function(o){return ta(o,s)}}function Nh(s,o,l,A){var T=A?W2:Na,F=-1,Q=o.length,X=s;for(s===o&&(o=ri(o)),l&&(X=Xt(s,bi(l)));++F<Q;)for(var ie=0,he=o[F],de=l?l(he):he;(ie=T(X,de,ie,A))>-1;)X!==s&&pu.call(X,ie,1),pu.call(s,ie,1);return s}function ip(s,o){for(var l=s?o.length:0,A=l-1;l--;){var T=o[l];if(l==A||T!==F){var F=T;rs(T)?pu.call(s,T,1):qh(s,T)}}return s}function Bh(s,o){return s+vu(U0()*(o-s+1))}function Sy(s,o,l,A){for(var T=-1,F=pr(bu((o-s)/(l||1)),0),Q=oe(F);F--;)Q[A?F:++T]=s,s+=l;return Q}function $h(s,o){var l="";if(!s||o<1||o>M)return l;do o%2&&(l+=s),o=vu(o/2),o&&(s+=s);while(o);return l}function Dt(s,o){return Zh(Rp(s,o,si),s+"")}function My(s){return F0(Va(s))}function Iy(s,o){var l=Va(s);return Nu(l,ea(o,0,l.length))}function jo(s,o,l,A){if(!Zt(s))return s;o=Is(o,s);for(var T=-1,F=o.length,Q=F-1,X=s;X!=null&&++T<F;){var ie=En(o[T]),he=l;if(ie==="__proto__"||ie==="constructor"||ie==="prototype")return s;if(T!=Q){var de=X[ie];he=A?A(de,ie,X):t,he===t&&(he=Zt(de)?de:rs(o[T+1])?[]:{})}qo(X,ie,he),X=X[ie]}return s}var np=mu?function(s,o){return mu.set(s,o),s}:si,Cy=gu?function(s,o){return gu(s,"toString",{configurable:!0,enumerable:!1,value:ul(o),writable:!0})}:si;function Py(s){return Nu(Va(s))}function Ni(s,o,l){var A=-1,T=s.length;o<0&&(o=-o>T?0:T+o),l=l>T?T:l,l<0&&(l+=T),T=o>l?0:l-o>>>0,o>>>=0;for(var F=oe(T);++A<T;)F[A]=s[A+o];return F}function Oy(s,o){var l;return Ss(s,function(A,T,F){return l=o(A,T,F),!l}),!!l}function xu(s,o,l){var A=0,T=s==null?A:s.length;if(typeof o=="number"&&o===o&&T<=Z){for(;A<T;){var F=A+T>>>1,Q=s[F];Q!==null&&!mi(Q)&&(l?Q<=o:Q<o)?A=F+1:T=F}return T}return Uh(s,o,si,l)}function Uh(s,o,l,A){var T=0,F=s==null?0:s.length;if(F===0)return 0;o=l(o);for(var Q=o!==o,X=o===null,ie=mi(o),he=o===t;T<F;){var de=vu((T+F)/2),ge=l(s[de]),Ie=ge!==t,Je=ge===null,ot=ge===ge,wt=mi(ge);if(Q)var ct=A||ot;else he?ct=ot&&(A||Ie):X?ct=ot&&Ie&&(A||!Je):ie?ct=ot&&Ie&&!Je&&(A||!wt):Je||wt?ct=!1:ct=A?ge<=o:ge<o;ct?T=de+1:F=de}return qr(F,R)}function sp(s,o){for(var l=-1,A=s.length,T=0,F=[];++l<A;){var Q=s[l],X=o?o(Q):Q;if(!l||!sn(X,ie)){var ie=X;F[T++]=Q===0?0:Q}}return F}function ap(s){return typeof s=="number"?s:mi(s)?p:+s}function vi(s){if(typeof s=="string")return s;if(gt(s))return Xt(s,vi)+"";if(mi(s))return q0?q0.call(s):"";var o=s+"";return o=="0"&&1/s==-S?"-0":o}function Ms(s,o,l){var A=-1,T=nu,F=s.length,Q=!0,X=[],ie=X;if(l)Q=!1,T=lh;else if(F>=n){var he=o?null:jy(s);if(he)return au(he);Q=!1,T=To,ie=new Zs}else ie=o?[]:X;e:for(;++A<F;){var de=s[A],ge=o?o(de):de;if(de=l||de!==0?de:0,Q&&ge===ge){for(var Ie=ie.length;Ie--;)if(ie[Ie]===ge)continue e;o&&ie.push(ge),X.push(de)}else T(ie,ge,l)||(ie!==X&&ie.push(ge),X.push(de))}return X}function qh(s,o){return o=Is(o,s),s=Np(s,o),s==null||delete s[En(Bi(o))]}function op(s,o,l,A){return jo(s,o,l(ta(s,o)),A)}function Su(s,o,l,A){for(var T=s.length,F=A?T:-1;(A?F--:++F<T)&&o(s[F],F,s););return l?Ni(s,A?0:F,A?F+1:T):Ni(s,A?F+1:0,A?T:F)}function cp(s,o){var l=s;return l instanceof Mt&&(l=l.value()),dh(o,function(A,T){return T.func.apply(T.thisArg,Es([A],T.args))},l)}function Lh(s,o,l){var A=s.length;if(A<2)return A?Ms(s[0]):[];for(var T=-1,F=oe(A);++T<A;)for(var Q=s[T],X=-1;++X<A;)X!=T&&(F[T]=Lo(F[T]||Q,s[X],o,l));return Ms(xr(F,1),o,l)}function up(s,o,l){for(var A=-1,T=s.length,F=o.length,Q={};++A<T;){var X=A<F?o[A]:t;l(Q,s[A],X)}return Q}function Fh(s){return ar(s)?s:[]}function zh(s){return typeof s=="function"?s:si}function Is(s,o){return gt(s)?s:Yh(s,o)?[s]:qp($t(s))}var Ty=Dt;function Cs(s,o,l){var A=s.length;return l=l===t?A:l,!o&&l>=A?s:Ni(s,o,l)}var fp=ym||function(s){return Ot.clearTimeout(s)};function hp(s,o){if(o)return s.slice();var l=s.length,A=T0?T0(l):new s.constructor(l);return s.copy(A),A}function jh(s){var o=new s.constructor(s.byteLength);return new lu(o).set(new lu(s)),o}function Ry(s,o){var l=o?jh(s.buffer):s.buffer;return new s.constructor(l,s.byteOffset,s.byteLength)}function Ny(s){var o=new s.constructor(s.source,vt.exec(s));return o.lastIndex=s.lastIndex,o}function By(s){return Uo?Ht(Uo.call(s)):{}}function lp(s,o){var l=o?jh(s.buffer):s.buffer;return new s.constructor(l,s.byteOffset,s.length)}function dp(s,o){if(s!==o){var l=s!==t,A=s===null,T=s===s,F=mi(s),Q=o!==t,X=o===null,ie=o===o,he=mi(o);if(!X&&!he&&!F&&s>o||F&&Q&&ie&&!X&&!he||A&&Q&&ie||!l&&ie||!T)return 1;if(!A&&!F&&!he&&s<o||he&&l&&T&&!A&&!F||X&&l&&T||!Q&&T||!ie)return-1}return 0}function $y(s,o,l){for(var A=-1,T=s.criteria,F=o.criteria,Q=T.length,X=l.length;++A<Q;){var ie=dp(T[A],F[A]);if(ie){if(A>=X)return ie;var he=l[A];return ie*(he=="desc"?-1:1)}}return s.index-o.index}function pp(s,o,l,A){for(var T=-1,F=s.length,Q=l.length,X=-1,ie=o.length,he=pr(F-Q,0),de=oe(ie+he),ge=!A;++X<ie;)de[X]=o[X];for(;++T<Q;)(ge||T<F)&&(de[l[T]]=s[T]);for(;he--;)de[X++]=s[T++];return de}function gp(s,o,l,A){for(var T=-1,F=s.length,Q=-1,X=l.length,ie=-1,he=o.length,de=pr(F-X,0),ge=oe(de+he),Ie=!A;++T<de;)ge[T]=s[T];for(var Je=T;++ie<he;)ge[Je+ie]=o[ie];for(;++Q<X;)(Ie||T<F)&&(ge[Je+l[Q]]=s[T++]);return ge}function ri(s,o){var l=-1,A=s.length;for(o||(o=oe(A));++l<A;)o[l]=s[l];return o}function Dn(s,o,l,A){var T=!l;l||(l={});for(var F=-1,Q=o.length;++F<Q;){var X=o[F],ie=A?A(l[X],s[X],X,l,s):t;ie===t&&(ie=s[X]),T?Zn(l,X,ie):qo(l,X,ie)}return l}function Uy(s,o){return Dn(s,Wh(s),o)}function qy(s,o){return Dn(s,Ip(s),o)}function Mu(s,o){return function(l,A){var T=gt(l)?k2:ay,F=o?o():{};return T(l,s,nt(A,2),F)}}function ja(s){return Dt(function(o,l){var A=-1,T=l.length,F=T>1?l[T-1]:t,Q=T>2?l[2]:t;for(F=s.length>3&&typeof F=="function"?(T--,F):t,Q&&Kr(l[0],l[1],Q)&&(F=T<3?t:F,T=1),o=Ht(o);++A<T;){var X=l[A];X&&s(o,X,A,F)}return o})}function bp(s,o){return function(l,A){if(l==null)return l;if(!ii(l))return s(l,A);for(var T=l.length,F=o?T:-1,Q=Ht(l);(o?F--:++F<T)&&A(Q[F],F,Q)!==!1;);return l}}function vp(s){return function(o,l,A){for(var T=-1,F=Ht(o),Q=A(o),X=Q.length;X--;){var ie=Q[s?X:++T];if(l(F[ie],ie,F)===!1)break}return o}}function Ly(s,o,l){var A=o&K,T=ko(s);function F(){var Q=this&&this!==Ot&&this instanceof F?T:s;return Q.apply(A?l:this,arguments)}return F}function mp(s){return function(o){o=$t(o);var l=Ba(o)?rn(o):t,A=l?l[0]:o.charAt(0),T=l?Cs(l,1).join(""):o.slice(1);return A[s]()+T}}function ka(s){return function(o){return dh(b1(g1(o).replace(Po,"")),s,"")}}function ko(s){return function(){var o=arguments;switch(o.length){case 0:return new s;case 1:return new s(o[0]);case 2:return new s(o[0],o[1]);case 3:return new s(o[0],o[1],o[2]);case 4:return new s(o[0],o[1],o[2],o[3]);case 5:return new s(o[0],o[1],o[2],o[3],o[4]);case 6:return new s(o[0],o[1],o[2],o[3],o[4],o[5]);case 7:return new s(o[0],o[1],o[2],o[3],o[4],o[5],o[6])}var l=za(s.prototype),A=s.apply(l,o);return Zt(A)?A:l}}function Fy(s,o,l){var A=ko(s);function T(){for(var F=arguments.length,Q=oe(F),X=F,ie=Ha(T);X--;)Q[X]=arguments[X];var he=F<3&&Q[0]!==ie&&Q[F-1]!==ie?[]:As(Q,ie);if(F-=he.length,F<l)return Ep(s,o,Iu,T.placeholder,t,Q,he,t,t,l-F);var de=this&&this!==Ot&&this instanceof T?A:s;return vr(de,this,Q)}return T}function yp(s){return function(o,l,A){var T=Ht(o);if(!ii(o)){var F=nt(l,3);o=mr(o),l=function(X){return F(T[X],X,T)}}var Q=s(o,l,A);return Q>-1?T[F?o[Q]:Q]:t}}function wp(s){return ts(function(o){var l=o.length,A=l,T=Ti.prototype.thru;for(s&&o.reverse();A--;){var F=o[A];if(typeof F!="function")throw new Oi(c);if(T&&!Q&&Tu(F)=="wrapper")var Q=new Ti([],!0)}for(A=Q?A:l;++A<l;){F=o[A];var X=Tu(F),ie=X=="wrapper"?Gh(F):t;ie&&Qh(ie[0])&&ie[1]==(_|W|j|N)&&!ie[4].length&&ie[9]==1?Q=Q[Tu(ie[0])].apply(Q,ie[3]):Q=F.length==1&&Qh(F)?Q[X]():Q.thru(F)}return function(){var he=arguments,de=he[0];if(Q&&he.length==1&&gt(de))return Q.plant(de).value();for(var ge=0,Ie=l?o[ge].apply(this,he):de;++ge<l;)Ie=o[ge].call(this,Ie);return Ie}})}function Iu(s,o,l,A,T,F,Q,X,ie,he){var de=o&_,ge=o&K,Ie=o&Y,Je=o&(W|B),ot=o&se,wt=Ie?t:ko(s);function ct(){for(var At=arguments.length,Tt=oe(At),yi=At;yi--;)Tt[yi]=arguments[yi];if(Je)var Vr=Ha(ct),wi=X2(Tt,Vr);if(A&&(Tt=pp(Tt,A,T,Je)),F&&(Tt=gp(Tt,F,Q,Je)),At-=wi,Je&&At<he){var or=As(Tt,Vr);return Ep(s,o,Iu,ct.placeholder,l,Tt,or,X,ie,he-At)}var an=ge?l:this,ss=Ie?an[s]:s;return At=Tt.length,X?Tt=a6(Tt,X):ot&&At>1&&Tt.reverse(),de&&ie<At&&(Tt.length=ie),this&&this!==Ot&&this instanceof ct&&(ss=wt||ko(ss)),ss.apply(an,Tt)}return ct}function _p(s,o){return function(l,A){return py(l,s,o(A),{})}}function Cu(s,o){return function(l,A){var T;if(l===t&&A===t)return o;if(l!==t&&(T=l),A!==t){if(T===t)return A;typeof l=="string"||typeof A=="string"?(l=vi(l),A=vi(A)):(l=ap(l),A=ap(A)),T=s(l,A)}return T}}function kh(s){return ts(function(o){return o=Xt(o,bi(nt())),Dt(function(l){var A=this;return s(o,function(T){return vr(T,A,l)})})})}function Pu(s,o){o=o===t?" ":vi(o);var l=o.length;if(l<2)return l?$h(o,s):o;var A=$h(o,bu(s/$a(o)));return Ba(o)?Cs(rn(A),0,s).join(""):A.slice(0,s)}function zy(s,o,l,A){var T=o&K,F=ko(s);function Q(){for(var X=-1,ie=arguments.length,he=-1,de=A.length,ge=oe(de+ie),Ie=this&&this!==Ot&&this instanceof Q?F:s;++he<de;)ge[he]=A[he];for(;ie--;)ge[he++]=arguments[++X];return vr(Ie,T?l:this,ge)}return Q}function Dp(s){return function(o,l,A){return A&&typeof A!="number"&&Kr(o,l,A)&&(l=A=t),o=ns(o),l===t?(l=o,o=0):l=ns(l),A=A===t?o<l?1:-1:ns(A),Sy(o,l,A,s)}}function Ou(s){return function(o,l){return typeof o=="string"&&typeof l=="string"||(o=$i(o),l=$i(l)),s(o,l)}}function Ep(s,o,l,A,T,F,Q,X,ie,he){var de=o&W,ge=de?Q:t,Ie=de?t:Q,Je=de?F:t,ot=de?t:F;o|=de?j:k,o&=~(de?k:j),o&z||(o&=~(K|Y));var wt=[s,o,T,Je,ge,ot,Ie,X,ie,he],ct=l.apply(t,wt);return Qh(s)&&Bp(ct,wt),ct.placeholder=A,$p(ct,s,o)}function Hh(s){var o=dr[s];return function(l,A){if(l=$i(l),A=A==null?0:qr(yt(A),292),A&&$0(l)){var T=($t(l)+"e").split("e"),F=o(T[0]+"e"+(+T[1]+A));return T=($t(F)+"e").split("e"),+(T[0]+"e"+(+T[1]-A))}return o(l)}}var jy=La&&1/au(new La([,-0]))[1]==S?function(s){return new La(s)}:ll;function Ap(s){return function(o){var l=Lr(o);return l==fe?wh(o):l==Se?sm(o):Q2(o,s(o))}}function es(s,o,l,A,T,F,Q,X){var ie=o&Y;if(!ie&&typeof s!="function")throw new Oi(c);var he=A?A.length:0;if(he||(o&=~(j|k),A=T=t),Q=Q===t?Q:pr(yt(Q),0),X=X===t?X:yt(X),he-=T?T.length:0,o&k){var de=A,ge=T;A=T=t}var Ie=ie?t:Gh(s),Je=[s,o,l,A,T,de,ge,F,Q,X];if(Ie&&i6(Je,Ie),s=Je[0],o=Je[1],l=Je[2],A=Je[3],T=Je[4],X=Je[9]=Je[9]===t?ie?0:s.length:pr(Je[9]-he,0),!X&&o&(W|B)&&(o&=~(W|B)),!o||o==K)var ot=Ly(s,o,l);else o==W||o==B?ot=Fy(s,o,X):(o==j||o==(K|j))&&!T.length?ot=zy(s,o,l,A):ot=Iu.apply(t,Je);var wt=Ie?np:Bp;return $p(wt(ot,Je),s,o)}function xp(s,o,l,A){return s===t||sn(s,qa[l])&&!qt.call(A,l)?o:s}function Sp(s,o,l,A,T,F){return Zt(s)&&Zt(o)&&(F.set(o,s),Au(s,o,t,Sp,F),F.delete(o)),s}function ky(s){return Vo(s)?t:s}function Mp(s,o,l,A,T,F){var Q=l&P,X=s.length,ie=o.length;if(X!=ie&&!(Q&&ie>X))return!1;var he=F.get(s),de=F.get(o);if(he&&de)return he==o&&de==s;var ge=-1,Ie=!0,Je=l&q?new Zs:t;for(F.set(s,o),F.set(o,s);++ge<X;){var ot=s[ge],wt=o[ge];if(A)var ct=Q?A(wt,ot,ge,o,s,F):A(ot,wt,ge,s,o,F);if(ct!==t){if(ct)continue;Ie=!1;break}if(Je){if(!ph(o,function(At,Tt){if(!To(Je,Tt)&&(ot===At||T(ot,At,l,A,F)))return Je.push(Tt)})){Ie=!1;break}}else if(!(ot===wt||T(ot,wt,l,A,F))){Ie=!1;break}}return F.delete(s),F.delete(o),Ie}function Hy(s,o,l,A,T,F,Q){switch(l){case ve:if(s.byteLength!=o.byteLength||s.byteOffset!=o.byteOffset)return!1;s=s.buffer,o=o.buffer;case xe:return!(s.byteLength!=o.byteLength||!F(new lu(s),new lu(o)));case V:case G:case ye:return sn(+s,+o);case H:return s.name==o.name&&s.message==o.message;case Re:case me:return s==o+"";case fe:var X=wh;case Se:var ie=A&P;if(X||(X=au),s.size!=o.size&&!ie)return!1;var he=Q.get(s);if(he)return he==o;A|=q,Q.set(s,o);var de=Mp(X(s),X(o),A,T,F,Q);return Q.delete(s),de;case Pe:if(Uo)return Uo.call(s)==Uo.call(o)}return!1}function Ky(s,o,l,A,T,F){var Q=l&P,X=Kh(s),ie=X.length,he=Kh(o),de=he.length;if(ie!=de&&!Q)return!1;for(var ge=ie;ge--;){var Ie=X[ge];if(!(Q?Ie in o:qt.call(o,Ie)))return!1}var Je=F.get(s),ot=F.get(o);if(Je&&ot)return Je==o&&ot==s;var wt=!0;F.set(s,o),F.set(o,s);for(var ct=Q;++ge<ie;){Ie=X[ge];var At=s[Ie],Tt=o[Ie];if(A)var yi=Q?A(Tt,At,Ie,o,s,F):A(At,Tt,Ie,s,o,F);if(!(yi===t?At===Tt||T(At,Tt,l,A,F):yi)){wt=!1;break}ct||(ct=Ie=="constructor")}if(wt&&!ct){var Vr=s.constructor,wi=o.constructor;Vr!=wi&&"constructor"in s&&"constructor"in o&&!(typeof Vr=="function"&&Vr instanceof Vr&&typeof wi=="function"&&wi instanceof wi)&&(wt=!1)}return F.delete(s),F.delete(o),wt}function ts(s){return Zh(Rp(s,t,jp),s+"")}function Kh(s){return G0(s,mr,Wh)}function Vh(s){return G0(s,ni,Ip)}var Gh=mu?function(s){return mu.get(s)}:ll;function Tu(s){for(var o=s.name+"",l=Fa[o],A=qt.call(Fa,o)?l.length:0;A--;){var T=l[A],F=T.func;if(F==null||F==s)return T.name}return o}function Ha(s){var o=qt.call($,"placeholder")?$:s;return o.placeholder}function nt(){var s=$.iteratee||fl;return s=s===fl?Y0:s,arguments.length?s(arguments[0],arguments[1]):s}function Ru(s,o){var l=s.__data__;return Zy(o)?l[typeof o=="string"?"string":"hash"]:l.map}function Jh(s){for(var o=mr(s),l=o.length;l--;){var A=o[l],T=s[A];o[l]=[A,T,Op(T)]}return o}function ra(s,o){var l=rm(s,o);return W0(l)?l:t}function Vy(s){var o=qt.call(s,Qs),l=s[Qs];try{s[Qs]=t;var A=!0}catch{}var T=fu.call(s);return A&&(o?s[Qs]=l:delete s[Qs]),T}var Wh=Dh?function(s){return s==null?[]:(s=Ht(s),Ds(Dh(s),function(o){return N0.call(s,o)}))}:dl,Ip=Dh?function(s){for(var o=[];s;)Es(o,Wh(s)),s=du(s);return o}:dl,Lr=Hr;(Eh&&Lr(new Eh(new ArrayBuffer(1)))!=ve||No&&Lr(new No)!=fe||Ah&&Lr(Ah.resolve())!=Qe||La&&Lr(new La)!=Se||Bo&&Lr(new Bo)!=be)&&(Lr=function(s){var o=Hr(s),l=o==Te?s.constructor:t,A=l?ia(l):"";if(A)switch(A){case Im:return ve;case Cm:return fe;case Pm:return Qe;case Om:return Se;case Tm:return be}return o});function Gy(s,o,l){for(var A=-1,T=l.length;++A<T;){var F=l[A],Q=F.size;switch(F.type){case"drop":s+=Q;break;case"dropRight":o-=Q;break;case"take":o=qr(o,s+Q);break;case"takeRight":s=pr(s,o-Q);break}}return{start:s,end:o}}function Jy(s){var o=s.match(Ye);return o?o[1].split(ft):[]}function Cp(s,o,l){o=Is(o,s);for(var A=-1,T=o.length,F=!1;++A<T;){var Q=En(o[A]);if(!(F=s!=null&&l(s,Q)))break;s=s[Q]}return F||++A!=T?F:(T=s==null?0:s.length,!!T&&Fu(T)&&rs(Q,T)&&(gt(s)||na(s)))}function Wy(s){var o=s.length,l=new s.constructor(o);return o&&typeof s[0]=="string"&&qt.call(s,"index")&&(l.index=s.index,l.input=s.input),l}function Pp(s){return typeof s.constructor=="function"&&!Ho(s)?za(du(s)):{}}function Yy(s,o,l){var A=s.constructor;switch(o){case xe:return jh(s);case V:case G:return new A(+s);case ve:return Ry(s,l);case qe:case Me:case _e:case He:case Ve:case Ee:case Ke:case ht:case Ge:return lp(s,l);case fe:return new A;case ye:case me:return new A(s);case Re:return Ny(s);case Se:return new A;case Pe:return By(s)}}function Qy(s,o){var l=o.length;if(!l)return s;var A=l-1;return o[A]=(l>1?"& ":"")+o[A],o=o.join(l>2?", ":" "),s.replace(Ue,`{
/* [wrapped with `+o+`] */
`)}function Xy(s){return gt(s)||na(s)||!!(B0&&s&&s[B0])}function rs(s,o){var l=typeof s;return o=o??M,!!o&&(l=="number"||l!="symbol"&&Ur.test(s))&&s>-1&&s%1==0&&s<o}function Kr(s,o,l){if(!Zt(l))return!1;var A=typeof o;return(A=="number"?ii(l)&&rs(o,l.length):A=="string"&&o in l)?sn(l[o],s):!1}function Yh(s,o){if(gt(s))return!1;var l=typeof s;return l=="number"||l=="symbol"||l=="boolean"||s==null||mi(s)?!0:Fe.test(s)||!Ze.test(s)||o!=null&&s in Ht(o)}function Zy(s){var o=typeof s;return o=="string"||o=="number"||o=="symbol"||o=="boolean"?s!=="__proto__":s===null}function Qh(s){var o=Tu(s),l=$[o];if(typeof l!="function"||!(o in Mt.prototype))return!1;if(s===l)return!0;var A=Gh(l);return!!A&&s===A[0]}function e6(s){return!!O0&&O0 in s}var t6=cu?is:pl;function Ho(s){var o=s&&s.constructor,l=typeof o=="function"&&o.prototype||qa;return s===l}function Op(s){return s===s&&!Zt(s)}function Tp(s,o){return function(l){return l==null?!1:l[s]===o&&(o!==t||s in Ht(l))}}function r6(s){var o=qu(s,function(A){return l.size===d&&l.clear(),A}),l=o.cache;return o}function i6(s,o){var l=s[1],A=o[1],T=l|A,F=T<(K|Y|_),Q=A==_&&l==W||A==_&&l==N&&s[7].length<=o[8]||A==(_|N)&&o[7].length<=o[8]&&l==W;if(!(F||Q))return s;A&K&&(s[2]=o[2],T|=l&K?0:z);var X=o[3];if(X){var ie=s[3];s[3]=ie?pp(ie,X,o[4]):X,s[4]=ie?As(s[3],m):o[4]}return X=o[5],X&&(ie=s[5],s[5]=ie?gp(ie,X,o[6]):X,s[6]=ie?As(s[5],m):o[6]),X=o[7],X&&(s[7]=X),A&_&&(s[8]=s[8]==null?o[8]:qr(s[8],o[8])),s[9]==null&&(s[9]=o[9]),s[0]=o[0],s[1]=T,s}function n6(s){var o=[];if(s!=null)for(var l in Ht(s))o.push(l);return o}function s6(s){return fu.call(s)}function Rp(s,o,l){return o=pr(o===t?s.length-1:o,0),function(){for(var A=arguments,T=-1,F=pr(A.length-o,0),Q=oe(F);++T<F;)Q[T]=A[o+T];T=-1;for(var X=oe(o+1);++T<o;)X[T]=A[T];return X[o]=l(Q),vr(s,this,X)}}function Np(s,o){return o.length<2?s:ta(s,Ni(o,0,-1))}function a6(s,o){for(var l=s.length,A=qr(o.length,l),T=ri(s);A--;){var F=o[A];s[A]=rs(F,l)?T[F]:t}return s}function Xh(s,o){if(!(o==="constructor"&&typeof s[o]=="function")&&o!="__proto__")return s[o]}var Bp=Up(np),Ko=_m||function(s,o){return Ot.setTimeout(s,o)},Zh=Up(Cy);function $p(s,o,l){var A=o+"";return Zh(s,Qy(A,o6(Jy(A),l)))}function Up(s){var o=0,l=0;return function(){var A=xm(),T=u-(A-l);if(l=A,T>0){if(++o>=y)return arguments[0]}else o=0;return s.apply(t,arguments)}}function Nu(s,o){var l=-1,A=s.length,T=A-1;for(o=o===t?A:o;++l<o;){var F=Bh(l,T),Q=s[F];s[F]=s[l],s[l]=Q}return s.length=o,s}var qp=r6(function(s){var o=[];return s.charCodeAt(0)===46&&o.push(""),s.replace(ut,function(l,A,T,F){o.push(T?F.replace(Nt,"$1"):A||l)}),o});function En(s){if(typeof s=="string"||mi(s))return s;var o=s+"";return o=="0"&&1/s==-S?"-0":o}function ia(s){if(s!=null){try{return uu.call(s)}catch{}try{return s+""}catch{}}return""}function o6(s,o){return Pi(ae,function(l){var A="_."+l[0];o&l[1]&&!nu(s,A)&&s.push(A)}),s.sort()}function Lp(s){if(s instanceof Mt)return s.clone();var o=new Ti(s.__wrapped__,s.__chain__);return o.__actions__=ri(s.__actions__),o.__index__=s.__index__,o.__values__=s.__values__,o}function c6(s,o,l){(l?Kr(s,o,l):o===t)?o=1:o=pr(yt(o),0);var A=s==null?0:s.length;if(!A||o<1)return[];for(var T=0,F=0,Q=oe(bu(A/o));T<A;)Q[F++]=Ni(s,T,T+=o);return Q}function u6(s){for(var o=-1,l=s==null?0:s.length,A=0,T=[];++o<l;){var F=s[o];F&&(T[A++]=F)}return T}function f6(){var s=arguments.length;if(!s)return[];for(var o=oe(s-1),l=arguments[0],A=s;A--;)o[A-1]=arguments[A];return Es(gt(l)?ri(l):[l],xr(o,1))}var h6=Dt(function(s,o){return ar(s)?Lo(s,xr(o,1,ar,!0)):[]}),l6=Dt(function(s,o){var l=Bi(o);return ar(l)&&(l=t),ar(s)?Lo(s,xr(o,1,ar,!0),nt(l,2)):[]}),d6=Dt(function(s,o){var l=Bi(o);return ar(l)&&(l=t),ar(s)?Lo(s,xr(o,1,ar,!0),t,l):[]});function p6(s,o,l){var A=s==null?0:s.length;return A?(o=l||o===t?1:yt(o),Ni(s,o<0?0:o,A)):[]}function g6(s,o,l){var A=s==null?0:s.length;return A?(o=l||o===t?1:yt(o),o=A-o,Ni(s,0,o<0?0:o)):[]}function b6(s,o){return s&&s.length?Su(s,nt(o,3),!0,!0):[]}function v6(s,o){return s&&s.length?Su(s,nt(o,3),!0):[]}function m6(s,o,l,A){var T=s==null?0:s.length;return T?(l&&typeof l!="number"&&Kr(s,o,l)&&(l=0,A=T),fy(s,o,l,A)):[]}function Fp(s,o,l){var A=s==null?0:s.length;if(!A)return-1;var T=l==null?0:yt(l);return T<0&&(T=pr(A+T,0)),su(s,nt(o,3),T)}function zp(s,o,l){var A=s==null?0:s.length;if(!A)return-1;var T=A-1;return l!==t&&(T=yt(l),T=l<0?pr(A+T,0):qr(T,A-1)),su(s,nt(o,3),T,!0)}function jp(s){var o=s==null?0:s.length;return o?xr(s,1):[]}function y6(s){var o=s==null?0:s.length;return o?xr(s,S):[]}function w6(s,o){var l=s==null?0:s.length;return l?(o=o===t?1:yt(o),xr(s,o)):[]}function _6(s){for(var o=-1,l=s==null?0:s.length,A={};++o<l;){var T=s[o];A[T[0]]=T[1]}return A}function kp(s){return s&&s.length?s[0]:t}function D6(s,o,l){var A=s==null?0:s.length;if(!A)return-1;var T=l==null?0:yt(l);return T<0&&(T=pr(A+T,0)),Na(s,o,T)}function E6(s){var o=s==null?0:s.length;return o?Ni(s,0,-1):[]}var A6=Dt(function(s){var o=Xt(s,Fh);return o.length&&o[0]===s[0]?Ph(o):[]}),x6=Dt(function(s){var o=Bi(s),l=Xt(s,Fh);return o===Bi(l)?o=t:l.pop(),l.length&&l[0]===s[0]?Ph(l,nt(o,2)):[]}),S6=Dt(function(s){var o=Bi(s),l=Xt(s,Fh);return o=typeof o=="function"?o:t,o&&l.pop(),l.length&&l[0]===s[0]?Ph(l,t,o):[]});function M6(s,o){return s==null?"":Em.call(s,o)}function Bi(s){var o=s==null?0:s.length;return o?s[o-1]:t}function I6(s,o,l){var A=s==null?0:s.length;if(!A)return-1;var T=A;return l!==t&&(T=yt(l),T=T<0?pr(A+T,0):qr(T,A-1)),o===o?om(s,o,T):su(s,E0,T,!0)}function C6(s,o){return s&&s.length?ep(s,yt(o)):t}var P6=Dt(Hp);function Hp(s,o){return s&&s.length&&o&&o.length?Nh(s,o):s}function O6(s,o,l){return s&&s.length&&o&&o.length?Nh(s,o,nt(l,2)):s}function T6(s,o,l){return s&&s.length&&o&&o.length?Nh(s,o,t,l):s}var R6=ts(function(s,o){var l=s==null?0:s.length,A=Sh(s,o);return ip(s,Xt(o,function(T){return rs(T,l)?+T:T}).sort(dp)),A});function N6(s,o){var l=[];if(!(s&&s.length))return l;var A=-1,T=[],F=s.length;for(o=nt(o,3);++A<F;){var Q=s[A];o(Q,A,s)&&(l.push(Q),T.push(A))}return ip(s,T),l}function el(s){return s==null?s:Mm.call(s)}function B6(s,o,l){var A=s==null?0:s.length;return A?(l&&typeof l!="number"&&Kr(s,o,l)?(o=0,l=A):(o=o==null?0:yt(o),l=l===t?A:yt(l)),Ni(s,o,l)):[]}function $6(s,o){return xu(s,o)}function U6(s,o,l){return Uh(s,o,nt(l,2))}function q6(s,o){var l=s==null?0:s.length;if(l){var A=xu(s,o);if(A<l&&sn(s[A],o))return A}return-1}function L6(s,o){return xu(s,o,!0)}function F6(s,o,l){return Uh(s,o,nt(l,2),!0)}function z6(s,o){var l=s==null?0:s.length;if(l){var A=xu(s,o,!0)-1;if(sn(s[A],o))return A}return-1}function j6(s){return s&&s.length?sp(s):[]}function k6(s,o){return s&&s.length?sp(s,nt(o,2)):[]}function H6(s){var o=s==null?0:s.length;return o?Ni(s,1,o):[]}function K6(s,o,l){return s&&s.length?(o=l||o===t?1:yt(o),Ni(s,0,o<0?0:o)):[]}function V6(s,o,l){var A=s==null?0:s.length;return A?(o=l||o===t?1:yt(o),o=A-o,Ni(s,o<0?0:o,A)):[]}function G6(s,o){return s&&s.length?Su(s,nt(o,3),!1,!0):[]}function J6(s,o){return s&&s.length?Su(s,nt(o,3)):[]}var W6=Dt(function(s){return Ms(xr(s,1,ar,!0))}),Y6=Dt(function(s){var o=Bi(s);return ar(o)&&(o=t),Ms(xr(s,1,ar,!0),nt(o,2))}),Q6=Dt(function(s){var o=Bi(s);return o=typeof o=="function"?o:t,Ms(xr(s,1,ar,!0),t,o)});function X6(s){return s&&s.length?Ms(s):[]}function Z6(s,o){return s&&s.length?Ms(s,nt(o,2)):[]}function e8(s,o){return o=typeof o=="function"?o:t,s&&s.length?Ms(s,t,o):[]}function tl(s){if(!(s&&s.length))return[];var o=0;return s=Ds(s,function(l){if(ar(l))return o=pr(l.length,o),!0}),mh(o,function(l){return Xt(s,gh(l))})}function Kp(s,o){if(!(s&&s.length))return[];var l=tl(s);return o==null?l:Xt(l,function(A){return vr(o,t,A)})}var t8=Dt(function(s,o){return ar(s)?Lo(s,o):[]}),r8=Dt(function(s){return Lh(Ds(s,ar))}),i8=Dt(function(s){var o=Bi(s);return ar(o)&&(o=t),Lh(Ds(s,ar),nt(o,2))}),n8=Dt(function(s){var o=Bi(s);return o=typeof o=="function"?o:t,Lh(Ds(s,ar),t,o)}),s8=Dt(tl);function a8(s,o){return up(s||[],o||[],qo)}function o8(s,o){return up(s||[],o||[],jo)}var c8=Dt(function(s){var o=s.length,l=o>1?s[o-1]:t;return l=typeof l=="function"?(s.pop(),l):t,Kp(s,l)});function Vp(s){var o=$(s);return o.__chain__=!0,o}function u8(s,o){return o(s),s}function Bu(s,o){return o(s)}var f8=ts(function(s){var o=s.length,l=o?s[0]:0,A=this.__wrapped__,T=function(F){return Sh(F,s)};return o>1||this.__actions__.length||!(A instanceof Mt)||!rs(l)?this.thru(T):(A=A.slice(l,+l+(o?1:0)),A.__actions__.push({func:Bu,args:[T],thisArg:t}),new Ti(A,this.__chain__).thru(function(F){return o&&!F.length&&F.push(t),F}))});function h8(){return Vp(this)}function l8(){return new Ti(this.value(),this.__chain__)}function d8(){this.__values__===t&&(this.__values__=a1(this.value()));var s=this.__index__>=this.__values__.length,o=s?t:this.__values__[this.__index__++];return{done:s,value:o}}function p8(){return this}function g8(s){for(var o,l=this;l instanceof wu;){var A=Lp(l);A.__index__=0,A.__values__=t,o?T.__wrapped__=A:o=A;var T=A;l=l.__wrapped__}return T.__wrapped__=s,o}function b8(){var s=this.__wrapped__;if(s instanceof Mt){var o=s;return this.__actions__.length&&(o=new Mt(this)),o=o.reverse(),o.__actions__.push({func:Bu,args:[el],thisArg:t}),new Ti(o,this.__chain__)}return this.thru(el)}function v8(){return cp(this.__wrapped__,this.__actions__)}var m8=Mu(function(s,o,l){qt.call(s,l)?++s[l]:Zn(s,l,1)});function y8(s,o,l){var A=gt(s)?_0:uy;return l&&Kr(s,o,l)&&(o=t),A(s,nt(o,3))}function w8(s,o){var l=gt(s)?Ds:K0;return l(s,nt(o,3))}var _8=yp(Fp),D8=yp(zp);function E8(s,o){return xr($u(s,o),1)}function A8(s,o){return xr($u(s,o),S)}function x8(s,o,l){return l=l===t?1:yt(l),xr($u(s,o),l)}function Gp(s,o){var l=gt(s)?Pi:Ss;return l(s,nt(o,3))}function Jp(s,o){var l=gt(s)?H2:H0;return l(s,nt(o,3))}var S8=Mu(function(s,o,l){qt.call(s,l)?s[l].push(o):Zn(s,l,[o])});function M8(s,o,l,A){s=ii(s)?s:Va(s),l=l&&!A?yt(l):0;var T=s.length;return l<0&&(l=pr(T+l,0)),zu(s)?l<=T&&s.indexOf(o,l)>-1:!!T&&Na(s,o,l)>-1}var I8=Dt(function(s,o,l){var A=-1,T=typeof o=="function",F=ii(s)?oe(s.length):[];return Ss(s,function(Q){F[++A]=T?vr(o,Q,l):Fo(Q,o,l)}),F}),C8=Mu(function(s,o,l){Zn(s,l,o)});function $u(s,o){var l=gt(s)?Xt:Q0;return l(s,nt(o,3))}function P8(s,o,l,A){return s==null?[]:(gt(o)||(o=o==null?[]:[o]),l=A?t:l,gt(l)||(l=l==null?[]:[l]),tp(s,o,l))}var O8=Mu(function(s,o,l){s[l?0:1].push(o)},function(){return[[],[]]});function T8(s,o,l){var A=gt(s)?dh:x0,T=arguments.length<3;return A(s,nt(o,4),l,T,Ss)}function R8(s,o,l){var A=gt(s)?K2:x0,T=arguments.length<3;return A(s,nt(o,4),l,T,H0)}function N8(s,o){var l=gt(s)?Ds:K0;return l(s,Lu(nt(o,3)))}function B8(s){var o=gt(s)?F0:My;return o(s)}function $8(s,o,l){(l?Kr(s,o,l):o===t)?o=1:o=yt(o);var A=gt(s)?ny:Iy;return A(s,o)}function U8(s){var o=gt(s)?sy:Py;return o(s)}function q8(s){if(s==null)return 0;if(ii(s))return zu(s)?$a(s):s.length;var o=Lr(s);return o==fe||o==Se?s.size:Th(s).length}function L8(s,o,l){var A=gt(s)?ph:Oy;return l&&Kr(s,o,l)&&(o=t),A(s,nt(o,3))}var F8=Dt(function(s,o){if(s==null)return[];var l=o.length;return l>1&&Kr(s,o[0],o[1])?o=[]:l>2&&Kr(o[0],o[1],o[2])&&(o=[o[0]]),tp(s,xr(o,1),[])}),Uu=wm||function(){return Ot.Date.now()};function z8(s,o){if(typeof o!="function")throw new Oi(c);return s=yt(s),function(){if(--s<1)return o.apply(this,arguments)}}function Wp(s,o,l){return o=l?t:o,o=s&&o==null?s.length:o,es(s,_,t,t,t,t,o)}function Yp(s,o){var l;if(typeof o!="function")throw new Oi(c);return s=yt(s),function(){return--s>0&&(l=o.apply(this,arguments)),s<=1&&(o=t),l}}var rl=Dt(function(s,o,l){var A=K;if(l.length){var T=As(l,Ha(rl));A|=j}return es(s,A,o,l,T)}),Qp=Dt(function(s,o,l){var A=K|Y;if(l.length){var T=As(l,Ha(Qp));A|=j}return es(o,A,s,l,T)});function Xp(s,o,l){o=l?t:o;var A=es(s,W,t,t,t,t,t,o);return A.placeholder=Xp.placeholder,A}function Zp(s,o,l){o=l?t:o;var A=es(s,B,t,t,t,t,t,o);return A.placeholder=Zp.placeholder,A}function e1(s,o,l){var A,T,F,Q,X,ie,he=0,de=!1,ge=!1,Ie=!0;if(typeof s!="function")throw new Oi(c);o=$i(o)||0,Zt(l)&&(de=!!l.leading,ge="maxWait"in l,F=ge?pr($i(l.maxWait)||0,o):F,Ie="trailing"in l?!!l.trailing:Ie);function Je(or){var an=A,ss=T;return A=T=t,he=or,Q=s.apply(ss,an),Q}function ot(or){return he=or,X=Ko(At,o),de?Je(or):Q}function wt(or){var an=or-ie,ss=or-he,y1=o-an;return ge?qr(y1,F-ss):y1}function ct(or){var an=or-ie,ss=or-he;return ie===t||an>=o||an<0||ge&&ss>=F}function At(){var or=Uu();if(ct(or))return Tt(or);X=Ko(At,wt(or))}function Tt(or){return X=t,Ie&&A?Je(or):(A=T=t,Q)}function yi(){X!==t&&fp(X),he=0,A=ie=T=X=t}function Vr(){return X===t?Q:Tt(Uu())}function wi(){var or=Uu(),an=ct(or);if(A=arguments,T=this,ie=or,an){if(X===t)return ot(ie);if(ge)return fp(X),X=Ko(At,o),Je(ie)}return X===t&&(X=Ko(At,o)),Q}return wi.cancel=yi,wi.flush=Vr,wi}var j8=Dt(function(s,o){return k0(s,1,o)}),k8=Dt(function(s,o,l){return k0(s,$i(o)||0,l)});function H8(s){return es(s,se)}function qu(s,o){if(typeof s!="function"||o!=null&&typeof o!="function")throw new Oi(c);var l=function(){var A=arguments,T=o?o.apply(this,A):A[0],F=l.cache;if(F.has(T))return F.get(T);var Q=s.apply(this,A);return l.cache=F.set(T,Q)||F,Q};return l.cache=new(qu.Cache||Xn),l}qu.Cache=Xn;function Lu(s){if(typeof s!="function")throw new Oi(c);return function(){var o=arguments;switch(o.length){case 0:return!s.call(this);case 1:return!s.call(this,o[0]);case 2:return!s.call(this,o[0],o[1]);case 3:return!s.call(this,o[0],o[1],o[2])}return!s.apply(this,o)}}function K8(s){return Yp(2,s)}var V8=Ty(function(s,o){o=o.length==1&&gt(o[0])?Xt(o[0],bi(nt())):Xt(xr(o,1),bi(nt()));var l=o.length;return Dt(function(A){for(var T=-1,F=qr(A.length,l);++T<F;)A[T]=o[T].call(this,A[T]);return vr(s,this,A)})}),il=Dt(function(s,o){var l=As(o,Ha(il));return es(s,j,t,o,l)}),t1=Dt(function(s,o){var l=As(o,Ha(t1));return es(s,k,t,o,l)}),G8=ts(function(s,o){return es(s,N,t,t,t,o)});function J8(s,o){if(typeof s!="function")throw new Oi(c);return o=o===t?o:yt(o),Dt(s,o)}function W8(s,o){if(typeof s!="function")throw new Oi(c);return o=o==null?0:pr(yt(o),0),Dt(function(l){var A=l[o],T=Cs(l,0,o);return A&&Es(T,A),vr(s,this,T)})}function Y8(s,o,l){var A=!0,T=!0;if(typeof s!="function")throw new Oi(c);return Zt(l)&&(A="leading"in l?!!l.leading:A,T="trailing"in l?!!l.trailing:T),e1(s,o,{leading:A,maxWait:o,trailing:T})}function Q8(s){return Wp(s,1)}function X8(s,o){return il(zh(o),s)}function Z8(){if(!arguments.length)return[];var s=arguments[0];return gt(s)?s:[s]}function ew(s){return Ri(s,C)}function tw(s,o){return o=typeof o=="function"?o:t,Ri(s,C,o)}function rw(s){return Ri(s,w|C)}function iw(s,o){return o=typeof o=="function"?o:t,Ri(s,w|C,o)}function nw(s,o){return o==null||j0(s,o,mr(o))}function sn(s,o){return s===o||s!==s&&o!==o}var sw=Ou(Ch),aw=Ou(function(s,o){return s>=o}),na=J0(function(){return arguments}())?J0:function(s){return tr(s)&&qt.call(s,"callee")&&!N0.call(s,"callee")},gt=oe.isArray,ow=kr?bi(kr):gy;function ii(s){return s!=null&&Fu(s.length)&&!is(s)}function ar(s){return tr(s)&&ii(s)}function cw(s){return s===!0||s===!1||tr(s)&&Hr(s)==V}var Ps=Dm||pl,uw=tn?bi(tn):by;function fw(s){return tr(s)&&s.nodeType===1&&!Vo(s)}function hw(s){if(s==null)return!0;if(ii(s)&&(gt(s)||typeof s=="string"||typeof s.splice=="function"||Ps(s)||Ka(s)||na(s)))return!s.length;var o=Lr(s);if(o==fe||o==Se)return!s.size;if(Ho(s))return!Th(s).length;for(var l in s)if(qt.call(s,l))return!1;return!0}function lw(s,o){return zo(s,o)}function dw(s,o,l){l=typeof l=="function"?l:t;var A=l?l(s,o):t;return A===t?zo(s,o,t,l):!!A}function nl(s){if(!tr(s))return!1;var o=Hr(s);return o==H||o==D||typeof s.message=="string"&&typeof s.name=="string"&&!Vo(s)}function pw(s){return typeof s=="number"&&$0(s)}function is(s){if(!Zt(s))return!1;var o=Hr(s);return o==ne||o==ce||o==L||o==Ce}function r1(s){return typeof s=="number"&&s==yt(s)}function Fu(s){return typeof s=="number"&&s>-1&&s%1==0&&s<=M}function Zt(s){var o=typeof s;return s!=null&&(o=="object"||o=="function")}function tr(s){return s!=null&&typeof s=="object"}var i1=Ci?bi(Ci):my;function gw(s,o){return s===o||Oh(s,o,Jh(o))}function bw(s,o,l){return l=typeof l=="function"?l:t,Oh(s,o,Jh(o),l)}function vw(s){return n1(s)&&s!=+s}function mw(s){if(t6(s))throw new dt(a);return W0(s)}function yw(s){return s===null}function ww(s){return s==null}function n1(s){return typeof s=="number"||tr(s)&&Hr(s)==ye}function Vo(s){if(!tr(s)||Hr(s)!=Te)return!1;var o=du(s);if(o===null)return!0;var l=qt.call(o,"constructor")&&o.constructor;return typeof l=="function"&&l instanceof l&&uu.call(l)==bm}var sl=wn?bi(wn):yy;function _w(s){return r1(s)&&s>=-M&&s<=M}var s1=Oo?bi(Oo):wy;function zu(s){return typeof s=="string"||!gt(s)&&tr(s)&&Hr(s)==me}function mi(s){return typeof s=="symbol"||tr(s)&&Hr(s)==Pe}var Ka=Ys?bi(Ys):_y;function Dw(s){return s===t}function Ew(s){return tr(s)&&Lr(s)==be}function Aw(s){return tr(s)&&Hr(s)==Oe}var xw=Ou(Rh),Sw=Ou(function(s,o){return s<=o});function a1(s){if(!s)return[];if(ii(s))return zu(s)?rn(s):ri(s);if(Ro&&s[Ro])return nm(s[Ro]());var o=Lr(s),l=o==fe?wh:o==Se?au:Va;return l(s)}function ns(s){if(!s)return s===0?s:0;if(s=$i(s),s===S||s===-S){var o=s<0?-1:1;return o*x}return s===s?s:0}function yt(s){var o=ns(s),l=o%1;return o===o?l?o-l:o:0}function o1(s){return s?ea(yt(s),0,b):0}function $i(s){if(typeof s=="number")return s;if(mi(s))return p;if(Zt(s)){var o=typeof s.valueOf=="function"?s.valueOf():s;s=Zt(o)?o+"":o}if(typeof s!="string")return s===0?s:+s;s=S0(s);var l=Nr.test(s);return l||$r.test(s)?pt(s.slice(2),l?2:8):Rr.test(s)?p:+s}function c1(s){return Dn(s,ni(s))}function Mw(s){return s?ea(yt(s),-M,M):s===0?s:0}function $t(s){return s==null?"":vi(s)}var Iw=ja(function(s,o){if(Ho(o)||ii(o)){Dn(o,mr(o),s);return}for(var l in o)qt.call(o,l)&&qo(s,l,o[l])}),u1=ja(function(s,o){Dn(o,ni(o),s)}),ju=ja(function(s,o,l,A){Dn(o,ni(o),s,A)}),Cw=ja(function(s,o,l,A){Dn(o,mr(o),s,A)}),Pw=ts(Sh);function Ow(s,o){var l=za(s);return o==null?l:z0(l,o)}var Tw=Dt(function(s,o){s=Ht(s);var l=-1,A=o.length,T=A>2?o[2]:t;for(T&&Kr(o[0],o[1],T)&&(A=1);++l<A;)for(var F=o[l],Q=ni(F),X=-1,ie=Q.length;++X<ie;){var he=Q[X],de=s[he];(de===t||sn(de,qa[he])&&!qt.call(s,he))&&(s[he]=F[he])}return s}),Rw=Dt(function(s){return s.push(t,Sp),vr(f1,t,s)});function Nw(s,o){return D0(s,nt(o,3),_n)}function Bw(s,o){return D0(s,nt(o,3),Ih)}function $w(s,o){return s==null?s:Mh(s,nt(o,3),ni)}function Uw(s,o){return s==null?s:V0(s,nt(o,3),ni)}function qw(s,o){return s&&_n(s,nt(o,3))}function Lw(s,o){return s&&Ih(s,nt(o,3))}function Fw(s){return s==null?[]:Eu(s,mr(s))}function zw(s){return s==null?[]:Eu(s,ni(s))}function al(s,o,l){var A=s==null?t:ta(s,o);return A===t?l:A}function jw(s,o){return s!=null&&Cp(s,o,hy)}function ol(s,o){return s!=null&&Cp(s,o,ly)}var kw=_p(function(s,o,l){o!=null&&typeof o.toString!="function"&&(o=fu.call(o)),s[o]=l},ul(si)),Hw=_p(function(s,o,l){o!=null&&typeof o.toString!="function"&&(o=fu.call(o)),qt.call(s,o)?s[o].push(l):s[o]=[l]},nt),Kw=Dt(Fo);function mr(s){return ii(s)?L0(s):Th(s)}function ni(s){return ii(s)?L0(s,!0):Dy(s)}function Vw(s,o){var l={};return o=nt(o,3),_n(s,function(A,T,F){Zn(l,o(A,T,F),A)}),l}function Gw(s,o){var l={};return o=nt(o,3),_n(s,function(A,T,F){Zn(l,T,o(A,T,F))}),l}var Jw=ja(function(s,o,l){Au(s,o,l)}),f1=ja(function(s,o,l,A){Au(s,o,l,A)}),Ww=ts(function(s,o){var l={};if(s==null)return l;var A=!1;o=Xt(o,function(F){return F=Is(F,s),A||(A=F.length>1),F}),Dn(s,Vh(s),l),A&&(l=Ri(l,w|O|C,ky));for(var T=o.length;T--;)qh(l,o[T]);return l});function Yw(s,o){return h1(s,Lu(nt(o)))}var Qw=ts(function(s,o){return s==null?{}:Ay(s,o)});function h1(s,o){if(s==null)return{};var l=Xt(Vh(s),function(A){return[A]});return o=nt(o),rp(s,l,function(A,T){return o(A,T[0])})}function Xw(s,o,l){o=Is(o,s);var A=-1,T=o.length;for(T||(T=1,s=t);++A<T;){var F=s==null?t:s[En(o[A])];F===t&&(A=T,F=l),s=is(F)?F.call(s):F}return s}function Zw(s,o,l){return s==null?s:jo(s,o,l)}function e5(s,o,l,A){return A=typeof A=="function"?A:t,s==null?s:jo(s,o,l,A)}var l1=Ap(mr),d1=Ap(ni);function t5(s,o,l){var A=gt(s),T=A||Ps(s)||Ka(s);if(o=nt(o,4),l==null){var F=s&&s.constructor;T?l=A?new F:[]:Zt(s)?l=is(F)?za(du(s)):{}:l={}}return(T?Pi:_n)(s,function(Q,X,ie){return o(l,Q,X,ie)}),l}function r5(s,o){return s==null?!0:qh(s,o)}function i5(s,o,l){return s==null?s:op(s,o,zh(l))}function n5(s,o,l,A){return A=typeof A=="function"?A:t,s==null?s:op(s,o,zh(l),A)}function Va(s){return s==null?[]:yh(s,mr(s))}function s5(s){return s==null?[]:yh(s,ni(s))}function a5(s,o,l){return l===t&&(l=o,o=t),l!==t&&(l=$i(l),l=l===l?l:0),o!==t&&(o=$i(o),o=o===o?o:0),ea($i(s),o,l)}function o5(s,o,l){return o=ns(o),l===t?(l=o,o=0):l=ns(l),s=$i(s),dy(s,o,l)}function c5(s,o,l){if(l&&typeof l!="boolean"&&Kr(s,o,l)&&(o=l=t),l===t&&(typeof o=="boolean"?(l=o,o=t):typeof s=="boolean"&&(l=s,s=t)),s===t&&o===t?(s=0,o=1):(s=ns(s),o===t?(o=s,s=0):o=ns(o)),s>o){var A=s;s=o,o=A}if(l||s%1||o%1){var T=U0();return qr(s+T*(o-s+jt("1e-"+((T+"").length-1))),o)}return Bh(s,o)}var u5=ka(function(s,o,l){return o=o.toLowerCase(),s+(l?p1(o):o)});function p1(s){return cl($t(s).toLowerCase())}function g1(s){return s=$t(s),s&&s.replace(er,Z2).replace(fh,"")}function f5(s,o,l){s=$t(s),o=vi(o);var A=s.length;l=l===t?A:ea(yt(l),0,A);var T=l;return l-=o.length,l>=0&&s.slice(l,T)==o}function h5(s){return s=$t(s),s&&Xe.test(s)?s.replace(St,em):s}function l5(s){return s=$t(s),s&&ze.test(s)?s.replace(rt,"\\$&"):s}var d5=ka(function(s,o,l){return s+(l?"-":"")+o.toLowerCase()}),p5=ka(function(s,o,l){return s+(l?" ":"")+o.toLowerCase()}),g5=mp("toLowerCase");function b5(s,o,l){s=$t(s),o=yt(o);var A=o?$a(s):0;if(!o||A>=o)return s;var T=(o-A)/2;return Pu(vu(T),l)+s+Pu(bu(T),l)}function v5(s,o,l){s=$t(s),o=yt(o);var A=o?$a(s):0;return o&&A<o?s+Pu(o-A,l):s}function m5(s,o,l){s=$t(s),o=yt(o);var A=o?$a(s):0;return o&&A<o?Pu(o-A,l)+s:s}function y5(s,o,l){return l||o==null?o=0:o&&(o=+o),Sm($t(s).replace(it,""),o||0)}function w5(s,o,l){return(l?Kr(s,o,l):o===t)?o=1:o=yt(o),$h($t(s),o)}function _5(){var s=arguments,o=$t(s[0]);return s.length<3?o:o.replace(s[1],s[2])}var D5=ka(function(s,o,l){return s+(l?"_":"")+o.toLowerCase()});function E5(s,o,l){return l&&typeof l!="number"&&Kr(s,o,l)&&(o=l=t),l=l===t?b:l>>>0,l?(s=$t(s),s&&(typeof o=="string"||o!=null&&!sl(o))&&(o=vi(o),!o&&Ba(s))?Cs(rn(s),0,l):s.split(o,l)):[]}var A5=ka(function(s,o,l){return s+(l?" ":"")+cl(o)});function x5(s,o,l){return s=$t(s),l=l==null?0:ea(yt(l),0,s.length),o=vi(o),s.slice(l,l+o.length)==o}function S5(s,o,l){var A=$.templateSettings;l&&Kr(s,o,l)&&(o=t),s=$t(s),o=ju({},o,A,xp);var T=ju({},o.imports,A.imports,xp),F=mr(T),Q=yh(T,F),X,ie,he=0,de=o.interpolate||Xr,ge="__p += '",Ie=_h((o.escape||Xr).source+"|"+de.source+"|"+(de===et?at:Xr).source+"|"+(o.evaluate||Xr).source+"|$","g"),Je="//# sourceURL="+(qt.call(o,"sourceURL")?(o.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++hh+"]")+`
`;s.replace(Ie,function(ct,At,Tt,yi,Vr,wi){return Tt||(Tt=yi),ge+=s.slice(he,wi).replace(Wi,tm),At&&(X=!0,ge+=`' +
__e(`+At+`) +
'`),Vr&&(ie=!0,ge+=`';
`+Vr+`;
__p += '`),Tt&&(ge+=`' +
((__t = (`+Tt+`)) == null ? '' : __t) +
'`),he=wi+ct.length,ct}),ge+=`';
`;var ot=qt.call(o,"variable")&&o.variable;if(!ot)ge=`with (obj) {
`+ge+`
}
`;else if(Rt.test(ot))throw new dt(f);ge=(ie?ge.replace(_t,""):ge).replace(lt,"$1").replace(We,"$1;"),ge="function("+(ot||"obj")+`) {
`+(ot?"":`obj || (obj = {});
`)+"var __t, __p = ''"+(X?", __e = _.escape":"")+(ie?`, __j = Array.prototype.join;
function print() { __p += __j.call(arguments, '') }
`:`;
`)+ge+`return __p
}`;var wt=v1(function(){return Bt(F,Je+"return "+ge).apply(t,Q)});if(wt.source=ge,nl(wt))throw wt;return wt}function M5(s){return $t(s).toLowerCase()}function I5(s){return $t(s).toUpperCase()}function C5(s,o,l){if(s=$t(s),s&&(l||o===t))return S0(s);if(!s||!(o=vi(o)))return s;var A=rn(s),T=rn(o),F=M0(A,T),Q=I0(A,T)+1;return Cs(A,F,Q).join("")}function P5(s,o,l){if(s=$t(s),s&&(l||o===t))return s.slice(0,P0(s)+1);if(!s||!(o=vi(o)))return s;var A=rn(s),T=I0(A,rn(o))+1;return Cs(A,0,T).join("")}function O5(s,o,l){if(s=$t(s),s&&(l||o===t))return s.replace(it,"");if(!s||!(o=vi(o)))return s;var A=rn(s),T=M0(A,rn(o));return Cs(A,T).join("")}function T5(s,o){var l=le,A=U;if(Zt(o)){var T="separator"in o?o.separator:T;l="length"in o?yt(o.length):l,A="omission"in o?vi(o.omission):A}s=$t(s);var F=s.length;if(Ba(s)){var Q=rn(s);F=Q.length}if(l>=F)return s;var X=l-$a(A);if(X<1)return A;var ie=Q?Cs(Q,0,X).join(""):s.slice(0,X);if(T===t)return ie+A;if(Q&&(X+=ie.length-X),sl(T)){if(s.slice(X).search(T)){var he,de=ie;for(T.global||(T=_h(T.source,$t(vt.exec(T))+"g")),T.lastIndex=0;he=T.exec(de);)var ge=he.index;ie=ie.slice(0,ge===t?X:ge)}}else if(s.indexOf(vi(T),X)!=X){var Ie=ie.lastIndexOf(T);Ie>-1&&(ie=ie.slice(0,Ie))}return ie+A}function R5(s){return s=$t(s),s&&Be.test(s)?s.replace(Et,cm):s}var N5=ka(function(s,o,l){return s+(l?" ":"")+o.toUpperCase()}),cl=mp("toUpperCase");function b1(s,o,l){return s=$t(s),o=l?t:o,o===t?im(s)?hm(s):J2(s):s.match(o)||[]}var v1=Dt(function(s,o){try{return vr(s,t,o)}catch(l){return nl(l)?l:new dt(l)}}),B5=ts(function(s,o){return Pi(o,function(l){l=En(l),Zn(s,l,rl(s[l],s))}),s});function $5(s){var o=s==null?0:s.length,l=nt();return s=o?Xt(s,function(A){if(typeof A[1]!="function")throw new Oi(c);return[l(A[0]),A[1]]}):[],Dt(function(A){for(var T=-1;++T<o;){var F=s[T];if(vr(F[0],this,A))return vr(F[1],this,A)}})}function U5(s){return cy(Ri(s,w))}function ul(s){return function(){return s}}function q5(s,o){return s==null||s!==s?o:s}var L5=wp(),F5=wp(!0);function si(s){return s}function fl(s){return Y0(typeof s=="function"?s:Ri(s,w))}function z5(s){return X0(Ri(s,w))}function j5(s,o){return Z0(s,Ri(o,w))}var k5=Dt(function(s,o){return function(l){return Fo(l,s,o)}}),H5=Dt(function(s,o){return function(l){return Fo(s,l,o)}});function hl(s,o,l){var A=mr(o),T=Eu(o,A);l==null&&!(Zt(o)&&(T.length||!A.length))&&(l=o,o=s,s=this,T=Eu(o,mr(o)));var F=!(Zt(l)&&"chain"in l)||!!l.chain,Q=is(s);return Pi(T,function(X){var ie=o[X];s[X]=ie,Q&&(s.prototype[X]=function(){var he=this.__chain__;if(F||he){var de=s(this.__wrapped__),ge=de.__actions__=ri(this.__actions__);return ge.push({func:ie,args:arguments,thisArg:s}),de.__chain__=he,de}return ie.apply(s,Es([this.value()],arguments))})}),s}function K5(){return Ot._===this&&(Ot._=vm),this}function ll(){}function V5(s){return s=yt(s),Dt(function(o){return ep(o,s)})}var G5=kh(Xt),J5=kh(_0),W5=kh(ph);function m1(s){return Yh(s)?gh(En(s)):xy(s)}function Y5(s){return function(o){return s==null?t:ta(s,o)}}var Q5=Dp(),X5=Dp(!0);function dl(){return[]}function pl(){return!1}function Z5(){return{}}function e4(){return""}function t4(){return!0}function r4(s,o){if(s=yt(s),s<1||s>M)return[];var l=b,A=qr(s,b);o=nt(o),s-=b;for(var T=mh(A,o);++l<s;)o(l);return T}function i4(s){return gt(s)?Xt(s,En):mi(s)?[s]:ri(qp($t(s)))}function n4(s){var o=++gm;return $t(s)+o}var s4=Cu(function(s,o){return s+o},0),a4=Hh("ceil"),o4=Cu(function(s,o){return s/o},1),c4=Hh("floor");function u4(s){return s&&s.length?Du(s,si,Ch):t}function f4(s,o){return s&&s.length?Du(s,nt(o,2),Ch):t}function h4(s){return A0(s,si)}function l4(s,o){return A0(s,nt(o,2))}function d4(s){return s&&s.length?Du(s,si,Rh):t}function p4(s,o){return s&&s.length?Du(s,nt(o,2),Rh):t}var g4=Cu(function(s,o){return s*o},1),b4=Hh("round"),v4=Cu(function(s,o){return s-o},0);function m4(s){return s&&s.length?vh(s,si):0}function y4(s,o){return s&&s.length?vh(s,nt(o,2)):0}return $.after=z8,$.ary=Wp,$.assign=Iw,$.assignIn=u1,$.assignInWith=ju,$.assignWith=Cw,$.at=Pw,$.before=Yp,$.bind=rl,$.bindAll=B5,$.bindKey=Qp,$.castArray=Z8,$.chain=Vp,$.chunk=c6,$.compact=u6,$.concat=f6,$.cond=$5,$.conforms=U5,$.constant=ul,$.countBy=m8,$.create=Ow,$.curry=Xp,$.curryRight=Zp,$.debounce=e1,$.defaults=Tw,$.defaultsDeep=Rw,$.defer=j8,$.delay=k8,$.difference=h6,$.differenceBy=l6,$.differenceWith=d6,$.drop=p6,$.dropRight=g6,$.dropRightWhile=b6,$.dropWhile=v6,$.fill=m6,$.filter=w8,$.flatMap=E8,$.flatMapDeep=A8,$.flatMapDepth=x8,$.flatten=jp,$.flattenDeep=y6,$.flattenDepth=w6,$.flip=H8,$.flow=L5,$.flowRight=F5,$.fromPairs=_6,$.functions=Fw,$.functionsIn=zw,$.groupBy=S8,$.initial=E6,$.intersection=A6,$.intersectionBy=x6,$.intersectionWith=S6,$.invert=kw,$.invertBy=Hw,$.invokeMap=I8,$.iteratee=fl,$.keyBy=C8,$.keys=mr,$.keysIn=ni,$.map=$u,$.mapKeys=Vw,$.mapValues=Gw,$.matches=z5,$.matchesProperty=j5,$.memoize=qu,$.merge=Jw,$.mergeWith=f1,$.method=k5,$.methodOf=H5,$.mixin=hl,$.negate=Lu,$.nthArg=V5,$.omit=Ww,$.omitBy=Yw,$.once=K8,$.orderBy=P8,$.over=G5,$.overArgs=V8,$.overEvery=J5,$.overSome=W5,$.partial=il,$.partialRight=t1,$.partition=O8,$.pick=Qw,$.pickBy=h1,$.property=m1,$.propertyOf=Y5,$.pull=P6,$.pullAll=Hp,$.pullAllBy=O6,$.pullAllWith=T6,$.pullAt=R6,$.range=Q5,$.rangeRight=X5,$.rearg=G8,$.reject=N8,$.remove=N6,$.rest=J8,$.reverse=el,$.sampleSize=$8,$.set=Zw,$.setWith=e5,$.shuffle=U8,$.slice=B6,$.sortBy=F8,$.sortedUniq=j6,$.sortedUniqBy=k6,$.split=E5,$.spread=W8,$.tail=H6,$.take=K6,$.takeRight=V6,$.takeRightWhile=G6,$.takeWhile=J6,$.tap=u8,$.throttle=Y8,$.thru=Bu,$.toArray=a1,$.toPairs=l1,$.toPairsIn=d1,$.toPath=i4,$.toPlainObject=c1,$.transform=t5,$.unary=Q8,$.union=W6,$.unionBy=Y6,$.unionWith=Q6,$.uniq=X6,$.uniqBy=Z6,$.uniqWith=e8,$.unset=r5,$.unzip=tl,$.unzipWith=Kp,$.update=i5,$.updateWith=n5,$.values=Va,$.valuesIn=s5,$.without=t8,$.words=b1,$.wrap=X8,$.xor=r8,$.xorBy=i8,$.xorWith=n8,$.zip=s8,$.zipObject=a8,$.zipObjectDeep=o8,$.zipWith=c8,$.entries=l1,$.entriesIn=d1,$.extend=u1,$.extendWith=ju,hl($,$),$.add=s4,$.attempt=v1,$.camelCase=u5,$.capitalize=p1,$.ceil=a4,$.clamp=a5,$.clone=ew,$.cloneDeep=rw,$.cloneDeepWith=iw,$.cloneWith=tw,$.conformsTo=nw,$.deburr=g1,$.defaultTo=q5,$.divide=o4,$.endsWith=f5,$.eq=sn,$.escape=h5,$.escapeRegExp=l5,$.every=y8,$.find=_8,$.findIndex=Fp,$.findKey=Nw,$.findLast=D8,$.findLastIndex=zp,$.findLastKey=Bw,$.floor=c4,$.forEach=Gp,$.forEachRight=Jp,$.forIn=$w,$.forInRight=Uw,$.forOwn=qw,$.forOwnRight=Lw,$.get=al,$.gt=sw,$.gte=aw,$.has=jw,$.hasIn=ol,$.head=kp,$.identity=si,$.includes=M8,$.indexOf=D6,$.inRange=o5,$.invoke=Kw,$.isArguments=na,$.isArray=gt,$.isArrayBuffer=ow,$.isArrayLike=ii,$.isArrayLikeObject=ar,$.isBoolean=cw,$.isBuffer=Ps,$.isDate=uw,$.isElement=fw,$.isEmpty=hw,$.isEqual=lw,$.isEqualWith=dw,$.isError=nl,$.isFinite=pw,$.isFunction=is,$.isInteger=r1,$.isLength=Fu,$.isMap=i1,$.isMatch=gw,$.isMatchWith=bw,$.isNaN=vw,$.isNative=mw,$.isNil=ww,$.isNull=yw,$.isNumber=n1,$.isObject=Zt,$.isObjectLike=tr,$.isPlainObject=Vo,$.isRegExp=sl,$.isSafeInteger=_w,$.isSet=s1,$.isString=zu,$.isSymbol=mi,$.isTypedArray=Ka,$.isUndefined=Dw,$.isWeakMap=Ew,$.isWeakSet=Aw,$.join=M6,$.kebabCase=d5,$.last=Bi,$.lastIndexOf=I6,$.lowerCase=p5,$.lowerFirst=g5,$.lt=xw,$.lte=Sw,$.max=u4,$.maxBy=f4,$.mean=h4,$.meanBy=l4,$.min=d4,$.minBy=p4,$.stubArray=dl,$.stubFalse=pl,$.stubObject=Z5,$.stubString=e4,$.stubTrue=t4,$.multiply=g4,$.nth=C6,$.noConflict=K5,$.noop=ll,$.now=Uu,$.pad=b5,$.padEnd=v5,$.padStart=m5,$.parseInt=y5,$.random=c5,$.reduce=T8,$.reduceRight=R8,$.repeat=w5,$.replace=_5,$.result=Xw,$.round=b4,$.runInContext=re,$.sample=B8,$.size=q8,$.snakeCase=D5,$.some=L8,$.sortedIndex=$6,$.sortedIndexBy=U6,$.sortedIndexOf=q6,$.sortedLastIndex=L6,$.sortedLastIndexBy=F6,$.sortedLastIndexOf=z6,$.startCase=A5,$.startsWith=x5,$.subtract=v4,$.sum=m4,$.sumBy=y4,$.template=S5,$.times=r4,$.toFinite=ns,$.toInteger=yt,$.toLength=o1,$.toLower=M5,$.toNumber=$i,$.toSafeInteger=Mw,$.toString=$t,$.toUpper=I5,$.trim=C5,$.trimEnd=P5,$.trimStart=O5,$.truncate=T5,$.unescape=R5,$.uniqueId=n4,$.upperCase=N5,$.upperFirst=cl,$.each=Gp,$.eachRight=Jp,$.first=kp,hl($,function(){var s={};return _n($,function(o,l){qt.call($.prototype,l)||(s[l]=o)}),s}(),{chain:!1}),$.VERSION=i,Pi(["bind","bindKey","curry","curryRight","partial","partialRight"],function(s){$[s].placeholder=$}),Pi(["drop","take"],function(s,o){Mt.prototype[s]=function(l){l=l===t?1:pr(yt(l),0);var A=this.__filtered__&&!o?new Mt(this):this.clone();return A.__filtered__?A.__takeCount__=qr(l,A.__takeCount__):A.__views__.push({size:qr(l,b),type:s+(A.__dir__<0?"Right":"")}),A},Mt.prototype[s+"Right"]=function(l){return this.reverse()[s](l).reverse()}}),Pi(["filter","map","takeWhile"],function(s,o){var l=o+1,A=l==h||l==E;Mt.prototype[s]=function(T){var F=this.clone();return F.__iteratees__.push({iteratee:nt(T,3),type:l}),F.__filtered__=F.__filtered__||A,F}}),Pi(["head","last"],function(s,o){var l="take"+(o?"Right":"");Mt.prototype[s]=function(){return this[l](1).value()[0]}}),Pi(["initial","tail"],function(s,o){var l="drop"+(o?"":"Right");Mt.prototype[s]=function(){return this.__filtered__?new Mt(this):this[l](1)}}),Mt.prototype.compact=function(){return this.filter(si)},Mt.prototype.find=function(s){return this.filter(s).head()},Mt.prototype.findLast=function(s){return this.reverse().find(s)},Mt.prototype.invokeMap=Dt(function(s,o){return typeof s=="function"?new Mt(this):this.map(function(l){return Fo(l,s,o)})}),Mt.prototype.reject=function(s){return this.filter(Lu(nt(s)))},Mt.prototype.slice=function(s,o){s=yt(s);var l=this;return l.__filtered__&&(s>0||o<0)?new Mt(l):(s<0?l=l.takeRight(-s):s&&(l=l.drop(s)),o!==t&&(o=yt(o),l=o<0?l.dropRight(-o):l.take(o-s)),l)},Mt.prototype.takeRightWhile=function(s){return this.reverse().takeWhile(s).reverse()},Mt.prototype.toArray=function(){return this.take(b)},_n(Mt.prototype,function(s,o){var l=/^(?:filter|find|map|reject)|While$/.test(o),A=/^(?:head|last)$/.test(o),T=$[A?"take"+(o=="last"?"Right":""):o],F=A||/^find/.test(o);T&&($.prototype[o]=function(){var Q=this.__wrapped__,X=A?[1]:arguments,ie=Q instanceof Mt,he=X[0],de=ie||gt(Q),ge=function(At){var Tt=T.apply($,Es([At],X));return A&&Ie?Tt[0]:Tt};de&&l&&typeof he=="function"&&he.length!=1&&(ie=de=!1);var Ie=this.__chain__,Je=!!this.__actions__.length,ot=F&&!Ie,wt=ie&&!Je;if(!F&&de){Q=wt?Q:new Mt(this);var ct=s.apply(Q,X);return ct.__actions__.push({func:Bu,args:[ge],thisArg:t}),new Ti(ct,Ie)}return ot&&wt?s.apply(this,X):(ct=this.thru(ge),ot?A?ct.value()[0]:ct.value():ct)})}),Pi(["pop","push","shift","sort","splice","unshift"],function(s){var o=ou[s],l=/^(?:push|sort|unshift)$/.test(s)?"tap":"thru",A=/^(?:pop|shift)$/.test(s);$.prototype[s]=function(){var T=arguments;if(A&&!this.__chain__){var F=this.value();return o.apply(gt(F)?F:[],T)}return this[l](function(Q){return o.apply(gt(Q)?Q:[],T)})}}),_n(Mt.prototype,function(s,o){var l=$[o];if(l){var A=l.name+"";qt.call(Fa,A)||(Fa[A]=[]),Fa[A].push({name:o,func:l})}}),Fa[Iu(t,Y).name]=[{name:"wrapper",func:t}],Mt.prototype.clone=Rm,Mt.prototype.reverse=Nm,Mt.prototype.value=Bm,$.prototype.at=f8,$.prototype.chain=h8,$.prototype.commit=l8,$.prototype.next=d8,$.prototype.plant=g8,$.prototype.reverse=b8,$.prototype.toJSON=$.prototype.valueOf=$.prototype.value=v8,$.prototype.first=$.prototype.head,Ro&&($.prototype[Ro]=p8),$},Ua=lm();sr?((sr.exports=Ua)._=Ua,kt._=Ua):Ot._=Ua}).call(ac)})($d,$d.exports);var SB=Object.defineProperty,MB=Object.defineProperties,IB=Object.getOwnPropertyDescriptors,jb=Object.getOwnPropertySymbols,CB=Object.prototype.hasOwnProperty,PB=Object.prototype.propertyIsEnumerable,kb=(r,e,t)=>e in r?SB(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Zu=(r,e)=>{for(var t in e||(e={}))CB.call(e,t)&&kb(r,t,e[t]);if(jb)for(var t of jb(e))PB.call(e,t)&&kb(r,t,e[t]);return r},OB=(r,e)=>MB(r,IB(e));function bn(r,e,t){var i;const n=fc(r);return((i=e.rpcMap)==null?void 0:i[n.reference])||`${F2}?chainId=${n.namespace}:${n.reference}&projectId=${t}`}function Ca(r){return r.includes(":")?r.split(":")[1]:r}function z2(r){return r.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function TB(r,e){const t=Object.keys(e.namespaces).filter(n=>n.includes(r));if(!t.length)return[];const i=[];return t.forEach(n=>{const a=e.namespaces[n].accounts;i.push(...a)}),i}function td(r={},e={}){const t=Hb(r),i=Hb(e);return $d.exports.merge(t,i)}function Hb(r){var e,t,i,n;const a={};if(!_c(r))return a;for(const[c,f]of Object.entries(r)){const g=f0(c)?[c]:f.chains,d=f.methods||[],m=f.events||[],w=f.rpcMap||{},O=uc(c);a[O]=OB(Zu(Zu({},a[O]),f),{chains:rf(g,(e=a[O])==null?void 0:e.chains),methods:rf(d,(t=a[O])==null?void 0:t.methods),events:rf(m,(i=a[O])==null?void 0:i.events),rpcMap:Zu(Zu({},w),(n=a[O])==null?void 0:n.rpcMap)})}return a}function RB(r){return r.includes(":")?r.split(":")[2]:r}function Kb(r){const e={};for(const[t,i]of Object.entries(r)){const n=i.methods||[],a=i.events||[],c=i.accounts||[],f=f0(t)?[t]:i.chains?i.chains:z2(i.accounts);e[t]={chains:f,methods:n,events:a,accounts:c}}return e}function rd(r){return typeof r=="number"?r:r.includes("0x")?parseInt(r,16):(r=r.includes(":")?r.split(":")[1]:r,isNaN(Number(r))?r:Number(r))}const j2={},Ut=r=>j2[r],id=(r,e)=>{j2[r]=e};class NB{constructor(e){this.name="polkadot",this.namespace=e.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(mn.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const n=Ca(t);e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||bn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new vn(new Wn(i,Ut("disableProviderPing")))}}var BB=Object.defineProperty,$B=Object.defineProperties,UB=Object.getOwnPropertyDescriptors,Vb=Object.getOwnPropertySymbols,qB=Object.prototype.hasOwnProperty,LB=Object.prototype.propertyIsEnumerable,Gb=(r,e,t)=>e in r?BB(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Jb=(r,e)=>{for(var t in e||(e={}))qB.call(e,t)&&Gb(r,t,e[t]);if(Vb)for(var t of Vb(e))LB.call(e,t)&&Gb(r,t,e[t]);return r},Wb=(r,e)=>$B(r,UB(e));class FB{constructor(e){this.name="eip155",this.namespace=e.namespace,this.events=Ut("events"),this.client=Ut("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(e);case"wallet_getCallsStatus":return await this.getCallStatus(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(parseInt(e),t),this.chainId=parseInt(e),this.events.emit(mn.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,t){const i=t||bn(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new vn(new Wn(i,Ut("disableProviderPing")))}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const n=parseInt(Ca(t));e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}async handleSwitchChain(e){var t,i;let n=e.request.params?(t=e.request.params[0])==null?void 0:t.chainId:"0x0";n=n.startsWith("0x")?n:`0x${n}`;const a=parseInt(n,16);if(this.isChainApproved(a))this.setDefaultChain(`${a}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:n}]},chainId:(i=this.namespace.chains)==null?void 0:i[0]}),this.setDefaultChain(`${a}`);else throw new Error(`Failed to switch to chain 'eip155:${a}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var t,i,n;const a=(i=(t=e.request)==null?void 0:t.params)==null?void 0:i[0];if(!a)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const c=this.client.session.get(e.topic),f=((n=c==null?void 0:c.sessionProperties)==null?void 0:n.capabilities)||{};if(f!=null&&f[a])return f==null?void 0:f[a];const g=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:Wb(Jb({},c.sessionProperties||{}),{capabilities:Wb(Jb({},f||{}),{[a]:g})})})}catch(d){console.warn("Failed to update session with capabilities",d)}return g}async getCallStatus(e){var t,i;const n=this.client.session.get(e.topic),a=(t=n.sessionProperties)==null?void 0:t.bundler_name;if(a){const f=this.getBundlerUrl(e.chainId,a);try{return await this.getUserOperationReceipt(f,e)}catch(g){console.warn("Failed to fetch call status from bundler",g,f)}}const c=(i=n.sessionProperties)==null?void 0:i.bundler_url;if(c)try{return await this.getUserOperationReceipt(c,e)}catch(f){console.warn("Failed to fetch call status from custom bundler",f,c)}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,t){var i;const n=new URL(e),a=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Fs("eth_getUserOperationReceipt",[(i=t.request.params)==null?void 0:i[0]]))});if(!a.ok)throw new Error(`Failed to fetch user operation receipt - ${a.status}`);return await a.json()}getBundlerUrl(e,t){return`${xB}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${t}`}}class zB{constructor(e){this.name="solana",this.namespace=e.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(mn.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const n=Ca(t);e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||bn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new vn(new Wn(i,Ut("disableProviderPing")))}}class jB{constructor(e){this.name="cosmos",this.namespace=e.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(mn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const n=Ca(t);e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||bn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new vn(new Wn(i,Ut("disableProviderPing")))}}class kB{constructor(e){this.name="algorand",this.namespace=e.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(!this.httpProviders[e]){const i=t||bn(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.chainId=e,this.events.emit(mn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;e[t]=this.createHttpProvider(t,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||bn(e,this.namespace,this.client.core.projectId);return typeof i>"u"?void 0:new vn(new Wn(i,Ut("disableProviderPing")))}}class HB{constructor(e){this.name="cip34",this.namespace=e.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(mn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{const i=this.getCardanoRPCUrl(t),n=Ca(t);e[n]=this.createHttpProvider(n,i)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}getCardanoRPCUrl(e){const t=this.namespace.rpcMap;if(t)return t[e]}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||this.getCardanoRPCUrl(e);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new vn(new Wn(i,Ut("disableProviderPing")))}}class KB{constructor(e){this.name="elrond",this.namespace=e.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(mn.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const n=Ca(t);e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||bn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new vn(new Wn(i,Ut("disableProviderPing")))}}class VB{constructor(e){this.name="multiversx",this.namespace=e.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(mn.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const n=Ca(t);e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||bn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new vn(new Wn(i,Ut("disableProviderPing")))}}class GB{constructor(e){this.name="near",this.namespace=e.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const i=t||bn(`${this.name}:${e}`,this.namespace);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.events.emit(mn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;e[t]=this.createHttpProvider(t,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||bn(e,this.namespace);return typeof i>"u"?void 0:new vn(new Wn(i,Ut("disableProviderPing")))}}class JB{constructor(e){this.name=Za,this.namespace=e.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(mn.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){var e,t;const i={};return(t=(e=this.namespace)==null?void 0:e.accounts)==null||t.forEach(n=>{const a=fc(n);i[`${a.namespace}:${a.reference}`]=this.createHttpProvider(n)}),i}getHttpProvider(e){const t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||bn(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new vn(new Wn(i,Ut("disableProviderPing")))}}var WB=Object.defineProperty,YB=Object.defineProperties,QB=Object.getOwnPropertyDescriptors,Yb=Object.getOwnPropertySymbols,XB=Object.prototype.hasOwnProperty,ZB=Object.prototype.propertyIsEnumerable,Qb=(r,e,t)=>e in r?WB(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ef=(r,e)=>{for(var t in e||(e={}))XB.call(e,t)&&Qb(r,t,e[t]);if(Yb)for(var t of Yb(e))ZB.call(e,t)&&Qb(r,t,e[t]);return r},nd=(r,e)=>YB(r,QB(e));class y0{constructor(e){this.events=new Fd,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=e,this.logger=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:Uc(Zf({level:(e==null?void 0:e.logger)||Fb})),this.disableProviderPing=(e==null?void 0:e.disableProviderPing)||!1}static async init(e){const t=new y0(e);return await t.initialize(),t}async request(e,t,i){const[n,a]=this.validateChain(t);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(n).request({request:ef({},e),chainId:`${n}:${a}`,topic:this.session.topic,expiry:i})}sendAsync(e,t,i,n){const a=new Date().getTime();this.request(e,i,n).then(c=>t(null,th(a,c))).catch(c=>t(c,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(e=this.session)==null?void 0:e.topic,reason:Lt("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,t){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:i,response:n}=await this.client.authenticate(e,t);i&&(this.uri=i,this.events.emit("display_uri",i));const a=await n();if(this.session=a.session,this.session){const c=Kb(this.session.namespaces);this.namespaces=td(this.namespaces,c),this.persist("namespaces",this.namespaces),this.onConnect()}return a}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}removeListener(e,t){this.events.removeListener(e,t)}off(e,t){this.events.off(e,t)}get isWalletConnect(){return!0}async pair(e){this.shouldAbortPairingAttempt=!1;let t=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(t>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:i,approval:n}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});i&&(this.uri=i,this.events.emit("display_uri",i)),await n().then(a=>{this.session=a;const c=Kb(a.namespaces);this.namespaces=td(this.namespaces,c),this.persist("namespaces",this.namespaces)}).catch(a=>{if(a.message!==L2)throw a;t++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(e,t){try{if(!this.session)return;const[i,n]=this.validateChain(e),a=this.getProvider(i);a.name===Za?a.setDefaultChain(`${i}:${n}`,t):a.setDefaultChain(n,t)}catch(i){if(!/Please call connect/.test(i.message))throw i}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const t=this.client.pairing.getAll();if(Hn(t)){for(const i of t)e.deletePairings?this.client.core.expirer.set(i.topic,0):await this.client.core.relayer.subscriber.unsubscribe(i.topic);this.logger.info(`Inactive pairings cleared: ${t.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const e=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[e]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await m0.init({core:this.providerOpts.core,logger:this.providerOpts.logger||Fb,relayUrl:this.providerOpts.relayUrl||DB,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map(t=>uc(t)))];id("client",this.client),id("events",this.events),id("disableProviderPing",this.disableProviderPing),e.forEach(t=>{if(!this.session)return;const i=TB(t,this.session),n=z2(i),a=td(this.namespaces,this.optionalNamespaces),c=nd(ef({},a[t]),{accounts:i,chains:n});switch(t){case"eip155":this.rpcProviders[t]=new FB({namespace:c});break;case"algorand":this.rpcProviders[t]=new kB({namespace:c});break;case"solana":this.rpcProviders[t]=new zB({namespace:c});break;case"cosmos":this.rpcProviders[t]=new jB({namespace:c});break;case"polkadot":this.rpcProviders[t]=new NB({namespace:c});break;case"cip34":this.rpcProviders[t]=new HB({namespace:c});break;case"elrond":this.rpcProviders[t]=new KB({namespace:c});break;case"multiversx":this.rpcProviders[t]=new VB({namespace:c});break;case"near":this.rpcProviders[t]=new GB({namespace:c});break;default:this.rpcProviders[Za]?this.rpcProviders[Za].updateNamespace(c):this.rpcProviders[Za]=new JB({namespace:c})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{const{params:t}=e,{event:i}=t;if(i.name==="accountsChanged"){const n=i.data;n&&Hn(n)&&this.events.emit("accountsChanged",n.map(RB))}else if(i.name==="chainChanged"){const n=t.chainId,a=t.event.data,c=uc(n),f=rd(n)!==rd(a)?`${c}:${rd(a)}`:n;this.onChainChanged(f)}else this.events.emit(i.name,i.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:t})=>{var i;const{namespaces:n}=t,a=(i=this.client)==null?void 0:i.session.get(e);this.session=nd(ef({},a),{namespaces:n}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:t})}),this.client.on("session_delete",async e=>{await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",nd(ef({},Lt("USER_DISCONNECTED")),{data:e.topic}))}),this.on(mn.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[Za]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var t;this.getProvider(e).updateNamespace((t=this.session)==null?void 0:t.namespaces[e])})}setNamespaces(e){const{namespaces:t,optionalNamespaces:i,sessionProperties:n}=e;t&&Object.keys(t).length&&(this.namespaces=t),i&&Object.keys(i).length&&(this.optionalNamespaces=i),this.sessionProperties=n,this.persist("namespaces",t),this.persist("optionalNamespaces",i)}validateChain(e){const[t,i]=(e==null?void 0:e.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[t,i];if(t&&!Object.keys(this.namespaces||{}).map(c=>uc(c)).includes(t))throw new Error(`Namespace '${t}' is not configured. Please call connect() first with namespace config.`);if(t&&i)return[t,i];const n=uc(Object.keys(this.namespaces)[0]),a=this.rpcProviders[n].getDefaultChain();return[n,a]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}onChainChanged(e,t=!1){if(!this.namespaces)return;const[i,n]=this.validateChain(e);n&&(t||this.getProvider(i).setDefaultChain(n),this.namespaces[i]?this.namespaces[i].defaultChain=n:this.namespaces[`${i}:${n}`]?this.namespaces[`${i}:${n}`].defaultChain=n:this.namespaces[`${i}:${n}`]={defaultChain:n},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",n))}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(e,t){this.client.core.storage.setItem(`${zb}/${e}`,t)}async getFromStore(e){return await this.client.core.storage.getItem(`${zb}/${e}`)}}const e$=y0,t$="wc",r$="ethereum_provider",i$=`${t$}@2:${r$}:`,n$="https://rpc.walletconnect.org/v1/",Ud=["eth_sendTransaction","personal_sign"],s$=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_sendCalls","wallet_getCapabilities","wallet_getCallsStatus","wallet_showCallsStatus"],qd=["chainChanged","accountsChanged"],a$=["chainChanged","accountsChanged","message","disconnect","connect"];var o$=Object.defineProperty,c$=Object.defineProperties,u$=Object.getOwnPropertyDescriptors,Xb=Object.getOwnPropertySymbols,f$=Object.prototype.hasOwnProperty,h$=Object.prototype.propertyIsEnumerable,Zb=(r,e,t)=>e in r?o$(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,eo=(r,e)=>{for(var t in e||(e={}))f$.call(e,t)&&Zb(r,t,e[t]);if(Xb)for(var t of Xb(e))h$.call(e,t)&&Zb(r,t,e[t]);return r},sd=(r,e)=>c$(r,u$(e));function Cf(r){return Number(r[0].split(":")[1])}function tf(r){return`0x${r.toString(16)}`}function l$(r){const{chains:e,optionalChains:t,methods:i,optionalMethods:n,events:a,optionalEvents:c,rpcMap:f}=r;if(!Hn(e))throw new Error("Invalid chains");const g={chains:e,methods:i||Ud,events:a||qd,rpcMap:eo({},e.length?{[Cf(e)]:f[Cf(e)]}:{})},d=a==null?void 0:a.filter(C=>!qd.includes(C)),m=i==null?void 0:i.filter(C=>!Ud.includes(C));if(!t&&!c&&!n&&!(d!=null&&d.length)&&!(m!=null&&m.length))return{required:e.length?g:void 0};const w=(d==null?void 0:d.length)&&(m==null?void 0:m.length)||!t,O={chains:[...new Set(w?g.chains.concat(t||[]):t)],methods:[...new Set(g.methods.concat(n!=null&&n.length?n:s$))],events:[...new Set(g.events.concat(c!=null&&c.length?c:a$))],rpcMap:f};return{required:e.length?g:void 0,optional:t.length?O:void 0}}class w0{constructor(){this.events=new Vi.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=i$,this.on=(e,t)=>(this.events.on(e,t),this),this.once=(e,t)=>(this.events.once(e,t),this),this.removeListener=(e,t)=>(this.events.removeListener(e,t),this),this.off=(e,t)=>(this.events.off(e,t),this),this.parseAccount=e=>this.isCompatibleChainId(e)?this.parseAccountId(e).address:e,this.signer={},this.rpc={}}static async init(e){const t=new w0;return await t.initialize(e),t}async request(e,t){return await this.signer.request(e,this.formatChainId(this.chainId),t)}sendAsync(e,t,i){this.signer.sendAsync(e,t,this.formatChainId(this.chainId),i)}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(e){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(e);const{required:t,optional:i}=l$(this.rpc);try{const n=await new Promise(async(c,f)=>{var g;this.rpc.showQrModal&&((g=this.modal)==null||g.subscribeModal(d=>{!d.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),f(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(sd(eo({namespaces:eo({},t&&{[this.namespace]:t})},i&&{optionalNamespaces:{[this.namespace]:i}}),{pairingTopic:e==null?void 0:e.pairingTopic})).then(d=>{c(d)}).catch(d=>{f(new Error(d.message))})});if(!n)return;const a=X1(n.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:a),this.setAccounts(a),this.events.emit("connect",{chainId:tf(this.chainId)})}catch(n){throw this.signer.logger.error(n),n}finally{this.modal&&this.modal.closeModal()}}async authenticate(e,t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts({chains:e==null?void 0:e.chains});try{const i=await new Promise(async(a,c)=>{var f;this.rpc.showQrModal&&((f=this.modal)==null||f.subscribeModal(g=>{!g.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),c(new Error("Connection request reset. Please try again.")))})),await this.signer.authenticate(sd(eo({},e),{chains:this.rpc.chains}),t).then(g=>{a(g)}).catch(g=>{c(new Error(g.message))})}),n=i.session;if(n){const a=X1(n.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:a),this.setAccounts(a),this.events.emit("connect",{chainId:tf(this.chainId)})}return i}catch(i){throw this.signer.logger.error(i),i}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",e=>{const{params:t}=e,{event:i}=t;i.name==="accountsChanged"?(this.accounts=this.parseAccounts(i.data),this.events.emit("accountsChanged",this.accounts)):i.name==="chainChanged"?this.setChainId(this.formatChainId(i.data)):this.events.emit(i.name,i.data),this.events.emit("session_event",e)}),this.signer.on("chainChanged",e=>{const t=parseInt(e);this.chainId=t,this.events.emit("chainChanged",tf(this.chainId)),this.persist()}),this.signer.on("session_update",e=>{this.events.emit("session_update",e)}),this.signer.on("session_delete",e=>{this.reset(),this.events.emit("session_delete",e),this.events.emit("disconnect",sd(eo({},Lt("USER_DISCONNECTED")),{data:e.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",e=>{var t,i;this.rpc.showQrModal&&((t=this.modal)==null||t.closeModal(),(i=this.modal)==null||i.openModal({uri:e})),this.events.emit("display_uri",e)})}switchEthereumChain(e){this.request({method:"wallet_switchEthereumChain",params:[{chainId:e.toString(16)}]})}isCompatibleChainId(e){return typeof e=="string"?e.startsWith(`${this.namespace}:`):!1}formatChainId(e){return`${this.namespace}:${e}`}parseChainId(e){return Number(e.split(":")[1])}setChainIds(e){const t=e.filter(i=>this.isCompatibleChainId(i)).map(i=>this.parseChainId(i));t.length&&(this.chainId=t[0],this.events.emit("chainChanged",tf(this.chainId)),this.persist())}setChainId(e){if(this.isCompatibleChainId(e)){const t=this.parseChainId(e);this.chainId=t,this.switchEthereumChain(t)}}parseAccountId(e){const[t,i,n]=e.split(":");return{chainId:`${t}:${i}`,address:n}}setAccounts(e){this.accounts=e.filter(t=>this.parseChainId(this.parseAccountId(t).chainId)===this.chainId).map(t=>this.parseAccountId(t).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(e){var t,i;const n=(t=e==null?void 0:e.chains)!=null?t:[],a=(i=e==null?void 0:e.optionalChains)!=null?i:[],c=n.concat(a);if(!c.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const f=n.length?(e==null?void 0:e.methods)||Ud:[],g=n.length?(e==null?void 0:e.events)||qd:[],d=(e==null?void 0:e.optionalMethods)||[],m=(e==null?void 0:e.optionalEvents)||[],w=(e==null?void 0:e.rpcMap)||this.buildRpcMap(c,e.projectId),O=(e==null?void 0:e.qrModalOptions)||void 0;return{chains:n==null?void 0:n.map(C=>this.formatChainId(C)),optionalChains:a.map(C=>this.formatChainId(C)),methods:f,events:g,optionalMethods:d,optionalEvents:m,rpcMap:w,showQrModal:!!(e!=null&&e.showQrModal),qrModalOptions:O,projectId:e.projectId,metadata:e.metadata}}buildRpcMap(e,t){const i={};return e.forEach(n=>{i[n]=this.getRpcUrl(n,t)}),i}async initialize(e){if(this.rpc=this.getRpcConfig(e),this.chainId=this.rpc.chains.length?Cf(this.rpc.chains):Cf(this.rpc.optionalChains),this.signer=await e$.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:e.disableProviderPing,relayUrl:e.relayUrl,storageOptions:e.storageOptions,customStoragePrefix:e.customStoragePrefix,telemetryEnabled:e.telemetryEnabled}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let t;try{const{WalletConnectModal:i}=await _4(()=>import("./index-C91wHTLi.js").then(n=>n.i),__vite__mapDeps([0,1,2]));t=i}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(t)try{this.modal=new t(eo({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}catch(i){throw this.signer.logger.error(i),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(e){if(!e)return;const{chains:t,optionalChains:i,rpcMap:n}=e;t&&Hn(t)&&(this.rpc.chains=t.map(a=>this.formatChainId(a)),t.forEach(a=>{this.rpc.rpcMap[a]=(n==null?void 0:n[a])||this.getRpcUrl(a)})),i&&Hn(i)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=i==null?void 0:i.map(a=>this.formatChainId(a)),i.forEach(a=>{this.rpc.rpcMap[a]=(n==null?void 0:n[a])||this.getRpcUrl(a)}))}getRpcUrl(e,t){var i;return((i=this.rpc.rpcMap)==null?void 0:i[e])||`${n$}?chainId=eip155:${e}&projectId=${t||this.rpc.projectId}`}async loadPersistedSession(){if(this.session)try{const e=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),t=this.session.namespaces[`${this.namespace}:${e}`]?this.session.namespaces[`${this.namespace}:${e}`]:this.session.namespaces[this.namespace];this.setChainIds(e?[this.formatChainId(e)]:t==null?void 0:t.accounts),this.setAccounts(t==null?void 0:t.accounts)}catch(e){this.signer.logger.error("Failed to load persisted session, clearing state..."),this.signer.logger.error(e),await this.disconnect().catch(t=>this.signer.logger.warn(t))}}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(e){return typeof e=="string"||e instanceof String?[this.parseAccount(e)]:e.map(t=>this.parseAccount(t))}}const V$=w0;export{V$ as EthereumProvider,a$ as OPTIONAL_EVENTS,s$ as OPTIONAL_METHODS,qd as REQUIRED_EVENTS,Ud as REQUIRED_METHODS,w0 as default};