@walletconnect/utils
Version:
Utilities for WalletConnect Protocol
15 lines (13 loc) • 260 kB
JavaScript
(function(E,ot){typeof exports=="object"&&typeof module<"u"?ot(exports):typeof define=="function"&&define.amd?define(["exports"],ot):(E=typeof globalThis<"u"?globalThis:E||self,ot(E["@walletconnect/utils"]={}))})(this,function(E){"use strict";const ot=":";function Fr(e){const[t,n]=e.split(ot);return{namespace:t,reference:n}}function Hs(e){const{namespace:t,reference:n}=e;return[t,n].join(ot)}function Rr(e){const[t,n,r]=e.split(ot);return{namespace:t,reference:n,address:r}}function Vs(e){const{namespace:t,reference:n,address:r}=e;return[t,n,r].join(ot)}function $r(e,t){const n=[];return e.forEach(r=>{const i=t(r);n.includes(i)||n.push(i)}),n}function qs(e){const{address:t}=Rr(e);return t}function Ks(e){const{namespace:t,reference:n}=Rr(e);return Hs({namespace:t,reference:n})}function el(e,t){const{namespace:n,reference:r}=Fr(t);return Vs({namespace:n,reference:r,address:e})}function tl(e){return $r(e,qs)}function Ws(e){return $r(e,Ks)}function nl(e,t=[]){const n=[];return Object.keys(e).forEach(r=>{if(t.length&&!t.includes(r))return;const i=e[r];n.push(...i.accounts)}),n}function rl(e,t=[]){const n=[];return Object.keys(e).forEach(r=>{if(t.length&&!t.includes(r))return;const i=e[r];n.push(...Ws(i.accounts))}),n}function il(e,t=[]){const n=[];return Object.keys(e).forEach(r=>{if(t.length&&!t.includes(r))return;const i=e[r];n.push(...zn(r,i))}),n}function zn(e,t){return e.includes(":")?[e]:t.chains||[]}var Ys=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))},sl=function(){function e(t,n,r){this.name=t,this.version=n,this.os=r,this.type="browser"}return e}(),ol=function(){function e(t){this.version=t,this.type="node",this.name="node",this.os=process.platform}return e}(),al=function(){function e(t,n,r,i){this.name=t,this.version=n,this.os=r,this.bot=i,this.type="bot-device"}return e}(),cl=function(){function e(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return e}(),fl=function(){function e(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return e}(),ul=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,ll=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Zs=3,dl=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["pie",/^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],["pie",/^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],["netfront",/^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FB[AS]V\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["curl",/^curl\/([0-9\.]+)$/],["searchbot",ul]],Gs=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Windows CE",/Windows CE|WinCE|Microsoft Pocket Internet Explorer/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function hl(e){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new fl:typeof navigator<"u"?pl(navigator.userAgent):wl()}function gl(e){return e!==""&&dl.reduce(function(t,n){var r=n[0],i=n[1];if(t)return t;var s=i.exec(e);return!!s&&[r,s]},!1)}function pl(e){var t=gl(e);if(!t)return null;var n=t[0],r=t[1];if(n==="searchbot")return new cl;var i=r[1]&&r[1].split(".").join("_").split("_").slice(0,3);i?i.length<Zs&&(i=Ys(Ys([],i,!0),yl(Zs-i.length),!0)):i=[];var s=i.join("."),o=bl(e),a=ll.exec(e);return a&&a[1]?new al(n,s,o,a[1]):new sl(n,s,o)}function bl(e){for(var t=0,n=Gs.length;t<n;t++){var r=Gs[t],i=r[0],s=r[1],o=s.exec(e);if(o)return i}return null}function wl(){var e=typeof process<"u"&&process.version;return e?new ol(process.version.slice(1)):null}function yl(e){for(var t=[],n=0;n<e;n++)t.push("0");return t}function ml(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function r(){var i=!1;try{i=this instanceof r}catch{}return i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}),n}var Lr={};/*! *****************************************************************************
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 kr=function(e,t){return kr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)r.hasOwnProperty(i)&&(n[i]=r[i])},kr(e,t)};function El(e,t){kr(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Pr=function(){return Pr=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Pr.apply(this,arguments)};function xl(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function vl(e,t,n,r){var i=arguments.length,s=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s}function Dl(e,t){return function(n,r){t(n,r,e)}}function Al(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function Bl(e,t,n,r){function i(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function a(u){try{f(r.next(u))}catch(l){o(l)}}function c(u){try{f(r.throw(u))}catch(l){o(l)}}function f(u){u.done?s(u.value):i(u.value).then(a,c)}f((r=r.apply(e,t||[])).next())})}function Sl(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(f){return function(u){return c([f,u])}}function c(f){if(r)throw new TypeError("Generator is already executing.");for(;n;)try{if(r=1,i&&(s=f[0]&2?i.return:f[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,f[1])).done)return s;switch(i=0,s&&(f=[f[0]&2,s.value]),f[0]){case 0:case 1:s=f;break;case 4:return n.label++,{value:f[1],done:!1};case 5:n.label++,i=f[1],f=[0];continue;case 7:f=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(f[0]===6||f[0]===2)){n=0;continue}if(f[0]===3&&(!s||f[1]>s[0]&&f[1]<s[3])){n.label=f[1];break}if(f[0]===6&&n.label<s[1]){n.label=s[1],s=f;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(f);break}s[2]&&n.ops.pop(),n.trys.pop();continue}f=t.call(e,n)}catch(u){f=[6,u],i=0}finally{r=s=0}if(f[0]&5)throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}}function _l(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]}function Il(e,t){for(var n in e)n!=="default"&&!t.hasOwnProperty(n)&&(t[n]=e[n])}function zr(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Xs(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,s=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return s}function Ol(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Xs(arguments[t]));return e}function Ul(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),i=0,t=0;t<n;t++)for(var s=arguments[t],o=0,a=s.length;o<a;o++,i++)r[i]=s[o];return r}function cn(e){return this instanceof cn?(this.v=e,this):new cn(e)}function Cl(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(d){r[d]&&(i[d]=function(g){return new Promise(function(h,p){s.push([d,g,h,p])>1||a(d,g)})})}function a(d,g){try{c(r[d](g))}catch(h){l(s[0][3],h)}}function c(d){d.value instanceof cn?Promise.resolve(d.value.v).then(f,u):l(s[0][2],d)}function f(d){a("next",d)}function u(d){a("throw",d)}function l(d,g){d(g),s.shift(),s.length&&a(s[0][0],s[0][1])}}function Nl(e){var t,n;return t={},r("next"),r("throw",function(i){throw i}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(i,s){t[i]=e[i]?function(o){return(n=!n)?{value:cn(e[i](o)),done:i==="return"}:s?s(o):o}:s}}function Tl(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof zr=="function"?zr(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=e[s]&&function(o){return new Promise(function(a,c){o=e[s](o),i(a,c,o.done,o.value)})}}function i(s,o,a,c){Promise.resolve(c).then(function(f){s({value:f,done:a})},o)}}function Fl(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function Rl(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function $l(e){return e&&e.__esModule?e:{default:e}}function Ll(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)}function kl(e,t,n){if(!t.has(e))throw new TypeError("attempted to set private field on non-instance");return t.set(e,n),n}var Pl=Object.freeze({__proto__:null,get __assign(){return Pr},__asyncDelegator:Nl,__asyncGenerator:Cl,__asyncValues:Tl,__await:cn,__awaiter:Bl,__classPrivateFieldGet:Ll,__classPrivateFieldSet:kl,__createBinding:_l,__decorate:vl,__exportStar:Il,__extends:El,__generator:Sl,__importDefault:$l,__importStar:Rl,__makeTemplateObject:Fl,__metadata:Al,__param:Dl,__read:Xs,__rest:xl,__spread:Ol,__spreadArrays:Ul,__values:zr}),Mn=ml(Pl),Mr={},fn={},Js;function zl(){if(Js)return fn;Js=1,Object.defineProperty(fn,"__esModule",{value:!0}),fn.delay=void 0;function e(t){return new Promise(n=>{setTimeout(()=>{n(!0)},t)})}return fn.delay=e,fn}var Ot={},jr={},Ut={},Qs;function Ml(){return Qs||(Qs=1,Object.defineProperty(Ut,"__esModule",{value:!0}),Ut.ONE_THOUSAND=Ut.ONE_HUNDRED=void 0,Ut.ONE_HUNDRED=100,Ut.ONE_THOUSAND=1e3),Ut}var Hr={},eo;function jl(){return eo||(eo=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ONE_YEAR=e.FOUR_WEEKS=e.THREE_WEEKS=e.TWO_WEEKS=e.ONE_WEEK=e.THIRTY_DAYS=e.SEVEN_DAYS=e.FIVE_DAYS=e.THREE_DAYS=e.ONE_DAY=e.TWENTY_FOUR_HOURS=e.TWELVE_HOURS=e.SIX_HOURS=e.THREE_HOURS=e.ONE_HOUR=e.SIXTY_MINUTES=e.THIRTY_MINUTES=e.TEN_MINUTES=e.FIVE_MINUTES=e.ONE_MINUTE=e.SIXTY_SECONDS=e.THIRTY_SECONDS=e.TEN_SECONDS=e.FIVE_SECONDS=e.ONE_SECOND=void 0,e.ONE_SECOND=1,e.FIVE_SECONDS=5,e.TEN_SECONDS=10,e.THIRTY_SECONDS=30,e.SIXTY_SECONDS=60,e.ONE_MINUTE=e.SIXTY_SECONDS,e.FIVE_MINUTES=e.ONE_MINUTE*5,e.TEN_MINUTES=e.ONE_MINUTE*10,e.THIRTY_MINUTES=e.ONE_MINUTE*30,e.SIXTY_MINUTES=e.ONE_MINUTE*60,e.ONE_HOUR=e.SIXTY_MINUTES,e.THREE_HOURS=e.ONE_HOUR*3,e.SIX_HOURS=e.ONE_HOUR*6,e.TWELVE_HOURS=e.ONE_HOUR*12,e.TWENTY_FOUR_HOURS=e.ONE_HOUR*24,e.ONE_DAY=e.TWENTY_FOUR_HOURS,e.THREE_DAYS=e.ONE_DAY*3,e.FIVE_DAYS=e.ONE_DAY*5,e.SEVEN_DAYS=e.ONE_DAY*7,e.THIRTY_DAYS=e.ONE_DAY*30,e.ONE_WEEK=e.SEVEN_DAYS,e.TWO_WEEKS=e.ONE_WEEK*2,e.THREE_WEEKS=e.ONE_WEEK*3,e.FOUR_WEEKS=e.ONE_WEEK*4,e.ONE_YEAR=e.ONE_DAY*365}(Hr)),Hr}var to;function no(){return to||(to=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=Mn;t.__exportStar(Ml(),e),t.__exportStar(jl(),e)}(jr)),jr}var ro;function Hl(){if(ro)return Ot;ro=1,Object.defineProperty(Ot,"__esModule",{value:!0}),Ot.fromMiliseconds=Ot.toMiliseconds=void 0;const e=no();function t(r){return r*e.ONE_THOUSAND}Ot.toMiliseconds=t;function n(r){return Math.floor(r/e.ONE_THOUSAND)}return Ot.fromMiliseconds=n,Ot}var io;function Vl(){return io||(io=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=Mn;t.__exportStar(zl(),e),t.__exportStar(Hl(),e)}(Mr)),Mr}var qt={},so;function ql(){if(so)return qt;so=1,Object.defineProperty(qt,"__esModule",{value:!0}),qt.Watch=void 0;class e{constructor(){this.timestamps=new Map}start(n){if(this.timestamps.has(n))throw new Error(`Watch already started for label: ${n}`);this.timestamps.set(n,{started:Date.now()})}stop(n){const r=this.get(n);if(typeof r.elapsed<"u")throw new Error(`Watch already stopped for label: ${n}`);const i=Date.now()-r.started;this.timestamps.set(n,{started:r.started,elapsed:i})}get(n){const r=this.timestamps.get(n);if(typeof r>"u")throw new Error(`No timestamp found for label: ${n}`);return r}elapsed(n){const r=this.get(n);return r.elapsed||Date.now()-r.started}}return qt.Watch=e,qt.default=e,qt}var Vr={},un={},oo;function Kl(){if(oo)return un;oo=1,Object.defineProperty(un,"__esModule",{value:!0}),un.IWatch=void 0;class e{}return un.IWatch=e,un}var ao;function Wl(){return ao||(ao=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Mn.__exportStar(Kl(),e)}(Vr)),Vr}var co;function Yl(){return co||(co=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=Mn;t.__exportStar(Vl(),e),t.__exportStar(ql(),e),t.__exportStar(Wl(),e),t.__exportStar(no(),e)}(Lr)),Lr}var Kt=Yl(),X={},fo;function uo(){if(fo)return X;fo=1,Object.defineProperty(X,"__esModule",{value:!0}),X.getLocalStorage=X.getLocalStorageOrThrow=X.getCrypto=X.getCryptoOrThrow=X.getLocation=X.getLocationOrThrow=X.getNavigator=X.getNavigatorOrThrow=X.getDocument=X.getDocumentOrThrow=X.getFromWindowOrThrow=X.getFromWindow=void 0;function e(d){let g;return typeof window<"u"&&typeof window[d]<"u"&&(g=window[d]),g}X.getFromWindow=e;function t(d){const g=e(d);if(!g)throw new Error(`${d} is not defined in Window`);return g}X.getFromWindowOrThrow=t;function n(){return t("document")}X.getDocumentOrThrow=n;function r(){return e("document")}X.getDocument=r;function i(){return t("navigator")}X.getNavigatorOrThrow=i;function s(){return e("navigator")}X.getNavigator=s;function o(){return t("location")}X.getLocationOrThrow=o;function a(){return e("location")}X.getLocation=a;function c(){return t("crypto")}X.getCryptoOrThrow=c;function f(){return e("crypto")}X.getCrypto=f;function u(){return t("localStorage")}X.getLocalStorageOrThrow=u;function l(){return e("localStorage")}return X.getLocalStorage=l,X}var qe=uo(),ln={},lo;function Zl(){if(lo)return ln;lo=1,Object.defineProperty(ln,"__esModule",{value:!0}),ln.getWindowMetadata=void 0;const e=uo();function t(){let n,r;try{n=e.getDocumentOrThrow(),r=e.getLocationOrThrow()}catch{return null}function i(){const g=n.getElementsByTagName("link"),h=[];for(let p=0;p<g.length;p++){const m=g[p],x=m.getAttribute("rel");if(x&&x.toLowerCase().indexOf("icon")>-1){const U=m.getAttribute("href");if(U)if(U.toLowerCase().indexOf("https:")===-1&&U.toLowerCase().indexOf("http:")===-1&&U.indexOf("//")!==0){let y=r.protocol+"//"+r.host;if(U.indexOf("/")===0)y+=U;else{const B=r.pathname.split("/");B.pop();const O=B.join("/");y+=O+"/"+U}h.push(y)}else if(U.indexOf("//")===0){const y=r.protocol+U;h.push(y)}else h.push(U)}}return h}function s(...g){const h=n.getElementsByTagName("meta");for(let p=0;p<h.length;p++){const m=h[p],x=["itemprop","property","name"].map(U=>m.getAttribute(U)).filter(U=>U?g.includes(U):!1);if(x.length&&x){const U=m.getAttribute("content");if(U)return U}}return""}function o(){let g=s("name","og:site_name","og:title","twitter:title");return g||(g=n.title),g}function a(){return s("description","og:description","twitter:description","keywords")}const c=o(),f=a(),u=r.origin,l=i();return{description:f,url:u,icons:l,name:c}}return ln.getWindowMetadata=t,ln}var Gl=Zl();const ho={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}},go={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 Pe(e,t){const{message:n,code:r}=go[e];return{message:t?`${n} ${t}`:n,code:r}}function Ct(e,t){const{message:n,code:r}=ho[e];return{message:t?`${n} ${t}`:n,code:r}}const po="ReactNative",pe={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},jn=" ",Xl=":",bo="/",qr=2,Jl=1e3,wo="js";function Kr(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function at(){return!qe.getDocument()&&!!qe.getNavigator()&&navigator.product===po}function Ql(){return at()&&typeof global<"u"&&typeof global?.Platform<"u"&&global?.Platform.OS==="android"}function ed(){return at()&&typeof global<"u"&&typeof global?.Platform<"u"&&global?.Platform.OS==="ios"}function Wt(){return!Kr()&&!!qe.getNavigator()&&!!qe.getDocument()}function Nt(){return at()?pe.reactNative:Kr()?pe.node:Wt()?pe.browser:pe.unknown}function td(){try{return at()&&typeof global<"u"&&typeof global?.Application<"u"?global.Application?.applicationId:void 0}catch{return}}function yo(e,t){const n=new URLSearchParams(e);return Object.entries(t).sort(([r],[i])=>r.localeCompare(i)).forEach(([r,i])=>{i!=null&&n.set(r,String(i))}),n.toString()}function nd(e){const t=mo();try{return e?.url&&t.url&&new URL(e.url).host!==new URL(t.url).host&&(console.warn(`The configured WalletConnect 'metadata.url':${e.url} differs from the actual page url:${t.url}. This is probably unintended and can lead to issues.`),e.url=t.url),e?.icons?.length&&e.icons.length>0&&(e.icons=e.icons.filter(n=>n!=="")),{...t,...e,url:e?.url||t.url,name:e?.name||t.name,description:e?.description||t.description,icons:e?.icons?.length&&e.icons.length>0?e.icons:t.icons}}catch(n){return console.warn("Error populating app metadata",n),e||t}}function mo(){return Gl.getWindowMetadata()||{name:"",description:"",url:"",icons:[""]}}function rd(e,t){const n=Nt(),r={protocol:e,version:t,env:n};return n==="browser"&&(r.host=qe.getLocation()?.host||"unknown"),r}function Eo(){if(Nt()===pe.reactNative&&typeof global<"u"&&typeof global?.Platform<"u"){const{OS:n,Version:r}=global.Platform;return[n,r].join("-")}const e=hl();if(e===null)return"unknown";const t=e.os?e.os.replace(" ","").toLowerCase():"unknown";return e.type==="browser"?[t,e.name,e.version].join("-"):[t,e.version].join("-")}function xo(){const e=Nt();return e===pe.browser?[e,qe.getLocation()?.host||"unknown"].join(":"):e}function vo(e,t,n){const r=Eo(),i=xo();return[[e,t].join("-"),[wo,n].join("-"),r,i].join("/")}function id({protocol:e,version:t,relayUrl:n,sdkVersion:r,auth:i,projectId:s,useOnCloseEvent:o,bundleId:a,packageName:c}){const f=n.split("?"),u=vo(e,t,r),l={auth:i,ua:u,projectId:s,useOnCloseEvent:o||void 0,packageName:c||void 0,bundleId:a||void 0},d=yo(f[1]||"",l);return f[0]+"?"+d}function sd(e){let t=(e.match(/^[^:]+(?=:\/\/)/gi)||[])[0];const n=typeof t<"u"?e.split("://")[1]:e;return t=t==="wss"?"https":"http",[t,n].join("://")}function od(e,t,n){if(!e[t]||typeof e[t]!==n)throw new Error(`Missing or invalid "${t}" param`)}function Do(e,t=qr){return Ao(e.split(bo),t)}function ad(e){return Do(e).join(jn)}function ct(e,t){return e.filter(n=>t.includes(n)).length===e.length}function Ao(e,t=qr){return e.slice(Math.max(e.length-t,0))}function cd(e){return Object.fromEntries(e.entries())}function fd(e){return new Map(Object.entries(e))}function ud(e,t){const n={};return Object.keys(e).forEach(r=>{n[r]=t(e[r])}),n}const ld=e=>e;function Bo(e){return e.trim().replace(/^\w/,t=>t.toUpperCase())}function dd(e){return e.split(jn).map(t=>Bo(t)).join(jn)}function hd(e=Kt.FIVE_MINUTES,t){const n=Kt.toMiliseconds(e||Kt.FIVE_MINUTES);let r,i,s,o;return{resolve:a=>{s&&r&&(clearTimeout(s),r(a),o=Promise.resolve(a))},reject:a=>{s&&i&&(clearTimeout(s),i(a))},done:()=>new Promise((a,c)=>{if(o)return a(o);s=setTimeout(()=>{const f=Pe("EXPIRED"),u=new Error(t||f.message);u.code=f.code,c(u)},n),r=a,i=c})}}function gd(e,t,n){return new Promise(async(r,i)=>{const s=setTimeout(()=>i(new Error(n)),t);try{const o=await e;r(o)}catch(o){i(o)}clearTimeout(s)})}function Wr(e,t){if(typeof t=="string"&&t.startsWith(`${e}:`))return t;if(e.toLowerCase()==="topic"){if(typeof t!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}else if(e.toLowerCase()==="id"){if(typeof t!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${t}`}throw new Error(`Unknown expirer target type: ${e}`)}function pd(e){return Wr("topic",e)}function bd(e){return Wr("id",e)}function wd(e){const[t,n]=e.split(":"),r={id:void 0,topic:void 0};if(t==="topic"&&typeof n=="string")r.topic=n;else if(t==="id"&&Number.isInteger(Number(n)))r.id=Number(n);else throw new Error(`Invalid target, expected id:number or topic:string, got ${t}:${n}`);return r}function yd(e,t){return Kt.fromMiliseconds((t||Date.now())+Kt.toMiliseconds(e))}function md(e){return Date.now()>=Kt.toMiliseconds(e)}function Ed(e,t){return`${e}${t?`:${t}`:""}`}function Ie(e=[],t=[]){return[...new Set([...e,...t])]}async function xd({id:e,topic:t,wcDeepLink:n}){try{if(!n)return;const r=(typeof n=="string"?JSON.parse(n):n)?.href;if(typeof r!="string")return;const i=So(r,e,t),s=Nt();if(s===pe.browser){if(!qe.getDocument()?.hasFocus()){console.warn("Document does not have focus, skipping deeplink.");return}_o(i)}else s===pe.reactNative&&typeof global?.Linking<"u"&&await global.Linking.openURL(i)}catch(r){console.error(r)}}function So(e,t,n){const r=`requestId=${t}&sessionTopic=${n}`;e.endsWith("/")&&(e=e.slice(0,-1));let i=`${e}`;if(e.startsWith("https://t.me")){const s=e.includes("?")?"&startapp=":"?startapp=";i=`${i}${s}${Uo(r,!0)}`}else i=`${i}/wc?${r}`;return i}function _o(e){let t="_self";Oo()?t="_top":(Io()||e.startsWith("https://")||e.startsWith("http://"))&&(t="_blank"),window.open(e,t,"noreferrer noopener")}async function vd(e,t){let n="";try{if(Wt()&&(n=localStorage.getItem(t),n))return n;n=await e.getItem(t)}catch(r){console.error(r)}return n}function Yr(e,t){return e.filter(n=>t.includes(n))}function Dd(e,t){if(!e.includes(t))return null;const n=e.split(/([&,?,=])/),r=n.indexOf(t);return n[r+2]}function Ad(){return typeof crypto<"u"&&crypto?.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function Bd(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function Io(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function Oo(){try{return window.self!==window.top}catch{return!1}}function Uo(e,t=!1){const n=new TextEncoder().encode(e),r=new Array(n.length);for(let s=0;s<n.length;s++)r[s]=String.fromCharCode(n[s]);const i=btoa(r.join(""));return t?i.replace(/[=]/g,""):i}function Zr(e){const t=e+"=".repeat((4-e.length%4)%4),n=atob(t),r=new Uint8Array(n.length);for(let i=0;i<n.length;i++)r[i]=n.charCodeAt(i);return new TextDecoder().decode(r)}function Sd(e){return new Promise(t=>setTimeout(t,e))}class _d{constructor({limit:t}){this.limit=t,this.set=new Set}add(t){if(!this.set.has(t)){if(this.set.size>=this.limit){const n=this.set.values().next().value;n&&this.set.delete(n)}this.set.add(t)}}has(t){return this.set.has(t)}}const Hn=BigInt(2**32-1),Co=BigInt(32);function No(e,t=!1){return t?{h:Number(e&Hn),l:Number(e>>Co&Hn)}:{h:Number(e>>Co&Hn)|0,l:Number(e&Hn)|0}}function To(e,t=!1){const n=e.length;let r=new Uint32Array(n),i=new Uint32Array(n);for(let s=0;s<n;s++){const{h:o,l:a}=No(e[s],t);[r[s],i[s]]=[o,a]}return[r,i]}const Fo=(e,t,n)=>e>>>n,Ro=(e,t,n)=>e<<32-n|t>>>n,ft=(e,t,n)=>e>>>n|t<<32-n,ut=(e,t,n)=>e<<32-n|t>>>n,dn=(e,t,n)=>e<<64-n|t>>>n-32,hn=(e,t,n)=>e>>>n-32|t<<64-n,Id=(e,t)=>t,Od=(e,t)=>e,Ud=(e,t,n)=>e<<n|t>>>32-n,Cd=(e,t,n)=>t<<n|e>>>32-n,Nd=(e,t,n)=>t<<n-32|e>>>64-n,Td=(e,t,n)=>e<<n-32|t>>>64-n;function Ne(e,t,n,r){const i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}const Gr=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Xr=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,Fd=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),Rd=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,$d=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0),Ld=(e,t,n,r,i,s)=>t+n+r+i+s+(e/2**32|0)|0,Yt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Vn(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function ze(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Te(e,...t){if(!Vn(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function qn(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");ze(e.outputLen),ze(e.blockLen)}function lt(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Jr(e,t){Te(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function gn(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Oe(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Qr(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Me(e,t){return e<<32-t|e>>>t}const $o=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Lo(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const Ke=$o?e=>e:e=>Lo(e);function kd(e){for(let t=0;t<e.length;t++)e[t]=Lo(e[t]);return e}const dt=$o?e=>e:kd,ko=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Pd=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Zt(e){if(Te(e),ko)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=Pd[e[n]];return t}const We={_0:48,_9:57,A:65,F:70,a:97,f:102};function Po(e){if(e>=We._0&&e<=We._9)return e-We._0;if(e>=We.A&&e<=We.F)return e-(We.A-10);if(e>=We.a&&e<=We.f)return e-(We.a-10)}function Kn(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(ko)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let i=0,s=0;i<n;i++,s+=2){const o=Po(e.charCodeAt(s)),a=Po(e.charCodeAt(s+1));if(o===void 0||a===void 0){const c=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}r[i]=o*16+a}return r}function zo(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Fe(e){return typeof e=="string"&&(e=zo(e)),Te(e),e}function Ye(...e){let t=0;for(let r=0;r<e.length;r++){const i=e[r];Te(i),t+=i.length}const n=new Uint8Array(t);for(let r=0,i=0;r<e.length;r++){const s=e[r];n.set(s,i),i+=s.length}return n}class Wn{}function pn(e){const t=r=>e().update(Fe(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function zd(e){const t=(r,i)=>e(i).update(Fe(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function ht(e=32){if(Yt&&typeof Yt.getRandomValues=="function")return Yt.getRandomValues(new Uint8Array(e));if(Yt&&typeof Yt.randomBytes=="function")return Uint8Array.from(Yt.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}const Md=BigInt(0),bn=BigInt(1),jd=BigInt(2),Hd=BigInt(7),Vd=BigInt(256),qd=BigInt(113),Mo=[],jo=[],Ho=[];for(let e=0,t=bn,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Mo.push(2*(5*r+n)),jo.push((e+1)*(e+2)/2%64);let i=Md;for(let s=0;s<7;s++)t=(t<<bn^(t>>Hd)*qd)%Vd,t&jd&&(i^=bn<<(bn<<BigInt(s))-bn);Ho.push(i)}const Vo=To(Ho,!0),Kd=Vo[0],Wd=Vo[1],qo=(e,t,n)=>n>32?Nd(e,t,n):Ud(e,t,n),Ko=(e,t,n)=>n>32?Td(e,t,n):Cd(e,t,n);function Yd(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let o=0;o<10;o++)n[o]=e[o]^e[o+10]^e[o+20]^e[o+30]^e[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,f=n[c],u=n[c+1],l=qo(f,u,1)^n[a],d=Ko(f,u,1)^n[a+1];for(let g=0;g<50;g+=10)e[o+g]^=l,e[o+g+1]^=d}let i=e[2],s=e[3];for(let o=0;o<24;o++){const a=jo[o],c=qo(i,s,a),f=Ko(i,s,a),u=Mo[o];i=e[u],s=e[u+1],e[u]=c,e[u+1]=f}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)n[a]=e[o+a];for(let a=0;a<10;a++)e[o+a]^=~n[(a+2)%10]&n[(a+4)%10]}e[0]^=Kd[r],e[1]^=Wd[r]}Oe(n)}class ei extends Wn{constructor(t,n,r,i=!1,s=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=i,this.rounds=s,ze(r),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=gn(this.state)}clone(){return this._cloneInto()}keccak(){dt(this.state32),Yd(this.state32,this.rounds),dt(this.state32),this.posOut=0,this.pos=0}update(t){lt(this),t=Fe(t),Te(t);const{blockLen:n,state:r}=this,i=t.length;for(let s=0;s<i;){const o=Math.min(n-this.pos,i-s);for(let a=0;a<o;a++)r[this.pos++]^=t[s++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:i}=this;t[r]^=n,(n&128)!==0&&r===i-1&&this.keccak(),t[i-1]^=128,this.keccak()}writeInto(t){lt(this,!1),Te(t),this.finish();const n=this.state,{blockLen:r}=this;for(let i=0,s=t.length;i<s;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,s-i);t.set(n.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return ze(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Jr(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Oe(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:i,rounds:s,enableXOF:o}=this;return t||(t=new ei(n,r,i,o,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}}const Zd=(e,t,n)=>pn(()=>new ei(t,e,n)),Wo=Zd(1,136,256/8),Gd="0.1.1";function Xd(){return Gd}class J extends Error{constructor(t,n={}){const r=(()=>{if(n.cause instanceof J){if(n.cause.details)return n.cause.details;if(n.cause.shortMessage)return n.cause.shortMessage}return n.cause&&"details"in n.cause&&typeof n.cause.details=="string"?n.cause.details:n.cause?.message?n.cause.message:n.details})(),i=n.cause instanceof J&&n.cause.docsPath||n.docsPath,o=`https://oxlib.sh${i??""}`,a=[t||"An error occurred.",...n.metaMessages?["",...n.metaMessages]:[],...r||i?["",r?`Details: ${r}`:void 0,i?`See: ${o}`:void 0]:[]].filter(c=>typeof c=="string").join(`
`);super(a,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:`ox@${Xd()}`}),this.cause=n.cause,this.details=r,this.docs=o,this.docsPath=i,this.shortMessage=t}walk(t){return Yo(this,t)}}function Yo(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause?Yo(e.cause,t):t?null:e}function Jd(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const i=BigInt(32),s=BigInt(4294967295),o=Number(n>>i&s),a=Number(n&s),c=r?4:0,f=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+f,a,r)}function Qd(e,t,n){return e&t^~e&n}function eh(e,t,n){return e&t^e&n^t&n}class Zo extends Wn{constructor(t,n,r,i){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=i,this.buffer=new Uint8Array(t),this.view=Qr(this.buffer)}update(t){lt(this),t=Fe(t),Te(t);const{view:n,buffer:r,blockLen:i}=this,s=t.length;for(let o=0;o<s;){const a=Math.min(i-this.pos,s-o);if(a===i){const c=Qr(t);for(;i<=s-o;o+=i)this.process(c,o);continue}r.set(t.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){lt(this),Jr(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:i,isLE:s}=this;let{pos:o}=this;n[o++]=128,Oe(this.buffer.subarray(o)),this.padOffset>i-o&&(this.process(r,0),o=0);for(let l=o;l<i;l++)n[l]=0;Jd(r,i-8,BigInt(this.length*8),s),this.process(r,0);const a=Qr(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=c/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)a.setUint32(4*l,u[l],s)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:r,length:i,finished:s,destroyed:o,pos:a}=this;return t.destroyed=o,t.finished=s,t.length=i,t.pos=a,i%n&&t.buffer.set(r),t}clone(){return this._cloneInto()}}const gt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),fe=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),ue=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),th=Uint32Array.from([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]),pt=new Uint32Array(64);class nh extends Zo{constructor(t=32){super(64,t,8,!1),this.A=gt[0]|0,this.B=gt[1]|0,this.C=gt[2]|0,this.D=gt[3]|0,this.E=gt[4]|0,this.F=gt[5]|0,this.G=gt[6]|0,this.H=gt[7]|0}get(){const{A:t,B:n,C:r,D:i,E:s,F:o,G:a,H:c}=this;return[t,n,r,i,s,o,a,c]}set(t,n,r,i,s,o,a,c){this.A=t|0,this.B=n|0,this.C=r|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(t,n){for(let l=0;l<16;l++,n+=4)pt[l]=t.getUint32(n,!1);for(let l=16;l<64;l++){const d=pt[l-15],g=pt[l-2],h=Me(d,7)^Me(d,18)^d>>>3,p=Me(g,17)^Me(g,19)^g>>>10;pt[l]=p+pt[l-7]+h+pt[l-16]|0}let{A:r,B:i,C:s,D:o,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){const d=Me(a,6)^Me(a,11)^Me(a,25),g=u+d+Qd(a,c,f)+th[l]+pt[l]|0,p=(Me(r,2)^Me(r,13)^Me(r,22))+eh(r,i,s)|0;u=f,f=c,c=a,a=o+g|0,o=s,s=i,i=r,r=g+p|0}r=r+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(r,i,s,o,a,c,f,u)}roundClean(){Oe(pt)}destroy(){this.set(0,0,0,0,0,0,0,0),Oe(this.buffer)}}const Go=To(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),rh=Go[0],ih=Go[1],bt=new Uint32Array(80),wt=new Uint32Array(80);class ti extends Zo{constructor(t=64){super(128,t,16,!1),this.Ah=ue[0]|0,this.Al=ue[1]|0,this.Bh=ue[2]|0,this.Bl=ue[3]|0,this.Ch=ue[4]|0,this.Cl=ue[5]|0,this.Dh=ue[6]|0,this.Dl=ue[7]|0,this.Eh=ue[8]|0,this.El=ue[9]|0,this.Fh=ue[10]|0,this.Fl=ue[11]|0,this.Gh=ue[12]|0,this.Gl=ue[13]|0,this.Hh=ue[14]|0,this.Hl=ue[15]|0}get(){const{Ah:t,Al:n,Bh:r,Bl:i,Ch:s,Cl:o,Dh:a,Dl:c,Eh:f,El:u,Fh:l,Fl:d,Gh:g,Gl:h,Hh:p,Hl:m}=this;return[t,n,r,i,s,o,a,c,f,u,l,d,g,h,p,m]}set(t,n,r,i,s,o,a,c,f,u,l,d,g,h,p,m){this.Ah=t|0,this.Al=n|0,this.Bh=r|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=d|0,this.Gh=g|0,this.Gl=h|0,this.Hh=p|0,this.Hl=m|0}process(t,n){for(let y=0;y<16;y++,n+=4)bt[y]=t.getUint32(n),wt[y]=t.getUint32(n+=4);for(let y=16;y<80;y++){const B=bt[y-15]|0,O=wt[y-15]|0,T=ft(B,O,1)^ft(B,O,8)^Fo(B,O,7),R=ut(B,O,1)^ut(B,O,8)^Ro(B,O,7),$=bt[y-2]|0,N=wt[y-2]|0,P=ft($,N,19)^dn($,N,61)^Fo($,N,6),k=ut($,N,19)^hn($,N,61)^Ro($,N,6),F=Fd(R,k,wt[y-7],wt[y-16]),v=Rd(F,T,P,bt[y-7],bt[y-16]);bt[y]=v|0,wt[y]=F|0}let{Ah:r,Al:i,Bh:s,Bl:o,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:d,Fh:g,Fl:h,Gh:p,Gl:m,Hh:x,Hl:U}=this;for(let y=0;y<80;y++){const B=ft(l,d,14)^ft(l,d,18)^dn(l,d,41),O=ut(l,d,14)^ut(l,d,18)^hn(l,d,41),T=l&g^~l&p,R=d&h^~d&m,$=$d(U,O,R,ih[y],wt[y]),N=Ld($,x,B,T,rh[y],bt[y]),P=$|0,k=ft(r,i,28)^dn(r,i,34)^dn(r,i,39),F=ut(r,i,28)^hn(r,i,34)^hn(r,i,39),v=r&s^r&a^s&a,_=i&o^i&c^o&c;x=p|0,U=m|0,p=g|0,m=h|0,g=l|0,h=d|0,{h:l,l:d}=Ne(f|0,u|0,N|0,P|0),f=a|0,u=c|0,a=s|0,c=o|0,s=r|0,o=i|0;const b=Gr(P,F,_);r=Xr(b,N,k,v),i=b|0}({h:r,l:i}=Ne(this.Ah|0,this.Al|0,r|0,i|0)),{h:s,l:o}=Ne(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=Ne(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=Ne(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:d}=Ne(this.Eh|0,this.El|0,l|0,d|0),{h:g,l:h}=Ne(this.Fh|0,this.Fl|0,g|0,h|0),{h:p,l:m}=Ne(this.Gh|0,this.Gl|0,p|0,m|0),{h:x,l:U}=Ne(this.Hh|0,this.Hl|0,x|0,U|0),this.set(r,i,s,o,a,c,f,u,l,d,g,h,p,m,x,U)}roundClean(){Oe(bt,wt)}destroy(){Oe(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class sh extends ti{constructor(){super(48),this.Ah=fe[0]|0,this.Al=fe[1]|0,this.Bh=fe[2]|0,this.Bl=fe[3]|0,this.Ch=fe[4]|0,this.Cl=fe[5]|0,this.Dh=fe[6]|0,this.Dl=fe[7]|0,this.Eh=fe[8]|0,this.El=fe[9]|0,this.Fh=fe[10]|0,this.Fl=fe[11]|0,this.Gh=fe[12]|0,this.Gl=fe[13]|0,this.Hh=fe[14]|0,this.Hl=fe[15]|0}}const le=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]);class oh extends ti{constructor(){super(32),this.Ah=le[0]|0,this.Al=le[1]|0,this.Bh=le[2]|0,this.Bl=le[3]|0,this.Ch=le[4]|0,this.Cl=le[5]|0,this.Dh=le[6]|0,this.Dl=le[7]|0,this.Eh=le[8]|0,this.El=le[9]|0,this.Fh=le[10]|0,this.Fl=le[11]|0,this.Gh=le[12]|0,this.Gl=le[13]|0,this.Hh=le[14]|0,this.Hl=le[15]|0}}const wn=pn(()=>new nh),ah=pn(()=>new ti),ch=pn(()=>new sh),fh=pn(()=>new oh),Yn=wn;/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ni=BigInt(0),ri=BigInt(1);function yn(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function ii(e){if(!yn(e))throw new Error("Uint8Array expected")}function mn(e,t){if(typeof t!="boolean")throw new Error(e+" boolean expected, got "+t)}function Zn(e){const t=e.toString(16);return t.length&1?"0"+t:t}function Xo(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?ni:BigInt("0x"+e)}const Jo=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",uh=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function En(e){if(ii(e),Jo)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=uh[e[n]];return t}const Ze={_0:48,_9:57,A:65,F:70,a:97,f:102};function Qo(e){if(e>=Ze._0&&e<=Ze._9)return e-Ze._0;if(e>=Ze.A&&e<=Ze.F)return e-(Ze.A-10);if(e>=Ze.a&&e<=Ze.f)return e-(Ze.a-10)}function Gn(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(Jo)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let i=0,s=0;i<n;i++,s+=2){const o=Qo(e.charCodeAt(s)),a=Qo(e.charCodeAt(s+1));if(o===void 0||a===void 0){const c=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}r[i]=o*16+a}return r}function Tt(e){return Xo(En(e))}function ea(e){return ii(e),Xo(En(Uint8Array.from(e).reverse()))}function xn(e,t){return Gn(e.toString(16).padStart(t*2,"0"))}function ta(e,t){return xn(e,t).reverse()}function Ue(e,t,n){let r;if(typeof t=="string")try{r=Gn(t)}catch(s){throw new Error(e+" must be hex string or Uint8Array, cause: "+s)}else if(yn(t))r=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");const i=r.length;if(typeof n=="number"&&i!==n)throw new Error(e+" of length "+n+" expected, got "+i);return r}function Xn(...e){let t=0;for(let r=0;r<e.length;r++){const i=e[r];ii(i),t+=i.length}const n=new Uint8Array(t);for(let r=0,i=0;r<e.length;r++){const s=e[r];n.set(s,i),i+=s.length}return n}const si=e=>typeof e=="bigint"&&ni<=e;function oi(e,t,n){return si(e)&&si(t)&&si(n)&&t<=e&&e<n}function Gt(e,t,n,r){if(!oi(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}function lh(e){let t;for(t=0;e>ni;e>>=ri,t+=1);return t}const Jn=e=>(ri<<BigInt(e))-ri,ai=e=>new Uint8Array(e),na=e=>Uint8Array.from(e);function dh(e,t,n){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=ai(e),i=ai(e),s=0;const o=()=>{r.fill(1),i.fill(0),s=0},a=(...l)=>n(i,r,...l),c=(l=ai(0))=>{i=a(na([0]),l),r=a(),l.length!==0&&(i=a(na([1]),l),r=a())},f=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let l=0;const d=[];for(;l<t;){r=a();const g=r.slice();d.push(g),l+=r.length}return Xn(...d)};return(l,d)=>{o(),c(l);let g;for(;!(g=d(f()));)c();return o(),g}}const hh={bigint:e=>typeof e=="bigint",function:e=>typeof e=="function",boolean:e=>typeof e=="boolean",string:e=>typeof e=="string",stringOrUint8Array:e=>typeof e=="string"||yn(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e=="function"&&Number.isSafeInteger(e.outputLen)};function Qn(e,t,n={}){const r=(i,s,o)=>{const a=hh[s];if(typeof a!="function")throw new Error("invalid validator function");const c=e[i];if(!(o&&c===void 0)&&!a(c,e))throw new Error("param "+String(i)+" is invalid. Expected "+s+", got "+c)};for(const[i,s]of Object.entries(t))r(i,s,!1);for(const[i,s]of Object.entries(n))r(i,s,!0);return e}function ra(e){const t=new WeakMap;return(n,...r)=>{const i=t.get(n);if(i!==void 0)return i;const s=e(n,...r);return t.set(n,s),s}}function gh(e,t){if(la(e)>t)throw new Rh({givenSize:la(e),maxSize:t})}const Ge={zero:48,nine:57,A:65,F:70,a:97,f:102};function ia(e){if(e>=Ge.zero&&e<=Ge.nine)return e-Ge.zero;if(e>=Ge.A&&e<=Ge.F)return e-(Ge.A-10);if(e>=Ge.a&&e<=Ge.f)return e-(Ge.a-10)}function ph(e,t={}){const{dir:n,size:r=32}=t;if(r===0)return e;if(e.length>r)throw new $h({size:e.length,targetSize:r,type:"Bytes"});const i=new Uint8Array(r);for(let s=0;s<r;s++){const o=n==="right";i[o?s:r-s-1]=e[o?s:e.length-s-1]}return i}function sa(e,t){if(yt(e)>t)throw new Bh({givenSize:yt(e),maxSize:t})}function bh(e,t){if(typeof t=="number"&&t>0&&t>yt(e)-1)throw new ua({offset:t,position:"start",size:yt(e)})}function wh(e,t,n){if(typeof t=="number"&&typeof n=="number"&&yt(e)!==n-t)throw new ua({offset:n,position:"end",size:yt(e)})}function oa(e,t={}){const{dir:n,size:r=32}=t;if(r===0)return e;const i=e.replace("0x","");if(i.length>r*2)throw new Sh({size:Math.ceil(i.le