UNPKG

@walletconnect/utils

Version:

Utilities for WalletConnect Protocol

16 lines (14 loc) • 181 kB
(function(b,je){typeof exports=="object"&&typeof module<"u"?je(exports):typeof define=="function"&&define.amd?define(["exports"],je):(b=typeof globalThis<"u"?globalThis:b||self,je(b["@walletconnect/utils"]={}))})(this,function(b){"use strict";const je=":";function Tn(e){const[t,n]=e.split(je);return{namespace:t,reference:n}}function vo(e){const{namespace:t,reference:n}=e;return[t,n].join(je)}function Un(e){const[t,n,r]=e.split(je);return{namespace:t,reference:n,address:r}}function Ao(e){const{namespace:t,reference:n,address:r}=e;return[t,n,r].join(je)}function Rn(e,t){const n=[];return e.forEach(r=>{const o=t(r);n.includes(o)||n.push(o)}),n}function So(e){const{address:t}=Un(e);return t}function _o(e){const{namespace:t,reference:n}=Un(e);return vo({namespace:t,reference:n})}function jc(e,t){const{namespace:n,reference:r}=Tn(t);return Ao({namespace:n,reference:r,address:e})}function Lc(e){return Rn(e,So)}function xo(e){return Rn(e,_o)}function Mc(e,t=[]){const n=[];return Object.keys(e).forEach(r=>{if(t.length&&!t.includes(r))return;const o=e[r];n.push(...o.accounts)}),n}function zc(e,t=[]){const n=[];return Object.keys(e).forEach(r=>{if(t.length&&!t.includes(r))return;const o=e[r];n.push(...xo(o.accounts))}),n}function kc(e,t=[]){const n=[];return Object.keys(e).forEach(r=>{if(t.length&&!t.includes(r))return;const o=e[r];n.push(...en(r,o))}),n}function en(e,t){return e.includes(":")?[e]:t.chains||[]}var Bo=function(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,i;r<o;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))},Vc=function(){function e(t,n,r){this.name=t,this.version=n,this.os=r,this.type="browser"}return e}(),Hc=function(){function e(t){this.version=t,this.type="node",this.name="node",this.os=process.platform}return e}(),qc=function(){function e(t,n,r,o){this.name=t,this.version=n,this.os=r,this.bot=o,this.type="bot-device"}return e}(),Kc=function(){function e(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return e}(),Wc=function(){function e(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return e}(),Yc=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,Gc=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Oo=3,Zc=[["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",Yc]],Co=[["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 Xc(e){return e?No(e):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new Wc:typeof navigator<"u"?No(navigator.userAgent):eu()}function Jc(e){return e!==""&&Zc.reduce(function(t,n){var r=n[0],o=n[1];if(t)return t;var i=o.exec(e);return!!i&&[r,i]},!1)}function No(e){var t=Jc(e);if(!t)return null;var n=t[0],r=t[1];if(n==="searchbot")return new Kc;var o=r[1]&&r[1].split(".").join("_").split("_").slice(0,3);o?o.length<Oo&&(o=Bo(Bo([],o,!0),tu(Oo-o.length),!0)):o=[];var i=o.join("."),s=Qc(e),a=Gc.exec(e);return a&&a[1]?new qc(n,i,s,a[1]):new Vc(n,i,s)}function Qc(e){for(var t=0,n=Co.length;t<n;t++){var r=Co[t],o=r[0],i=r[1],s=i.exec(e);if(s)return o}return null}function eu(){var e=typeof process<"u"&&process.version;return e?new Hc(process.version.slice(1)):null}function tu(e){for(var t=[],n=0;n<e;n++)t.push("0");return t}function nu(e){var t=e.default;if(typeof t=="function"){var n=function(){return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,o.get?o:{enumerable:!0,get:function(){return e[r]}})}),n}var Qe={};/*! ***************************************************************************** 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 Fn=function(e,t){return Fn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)r.hasOwnProperty(o)&&(n[o]=r[o])},Fn(e,t)};function ru(e,t){Fn(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var $n=function(){return $n=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},$n.apply(this,arguments)};function ou(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 o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function iu(e,t,n,r){var o=arguments.length,i=o<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(i=(o<3?s(i):o>3?s(t,n,i):s(t,n))||i);return o>3&&i&&Object.defineProperty(t,n,i),i}function su(e,t){return function(n,r){t(n,r,e)}}function au(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function cu(e,t,n,r){function o(i){return i instanceof n?i:new n(function(s){s(i)})}return new(n||(n=Promise))(function(i,s){function a(f){try{u(r.next(f))}catch(l){s(l)}}function c(f){try{u(r.throw(f))}catch(l){s(l)}}function u(f){f.done?i(f.value):o(f.value).then(a,c)}u((r=r.apply(e,t||[])).next())})}function uu(e,t){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(u){return function(f){return c([u,f])}}function c(u){if(r)throw new TypeError("Generator is already executing.");for(;n;)try{if(r=1,o&&(i=u[0]&2?o.return:u[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,u[1])).done)return i;switch(o=0,i&&(u=[u[0]&2,i.value]),u[0]){case 0:case 1:i=u;break;case 4:return n.label++,{value:u[1],done:!1};case 5:n.label++,o=u[1],u=[0];continue;case 7:u=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(u[0]===6||u[0]===2)){n=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){n.label=u[1];break}if(u[0]===6&&n.label<i[1]){n.label=i[1],i=u;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(u);break}i[2]&&n.ops.pop(),n.trys.pop();continue}u=t.call(e,n)}catch(f){u=[6,f],o=0}finally{r=i=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function fu(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]}function lu(e,t){for(var n in e)n!=="default"&&!t.hasOwnProperty(n)&&(t[n]=e[n])}function Pn(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 Io(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),o,i=[],s;try{for(;(t===void 0||t-- >0)&&!(o=r.next()).done;)i.push(o.value)}catch(a){s={error:a}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(s)throw s.error}}return i}function du(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Io(arguments[t]));return e}function hu(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),o=0,t=0;t<n;t++)for(var i=arguments[t],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r}function Tt(e){return this instanceof Tt?(this.v=e,this):new Tt(e)}function gu(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),o,i=[];return o={},s("next"),s("throw"),s("return"),o[Symbol.asyncIterator]=function(){return this},o;function s(d){r[d]&&(o[d]=function(w){return new Promise(function(h,p){i.push([d,w,h,p])>1||a(d,w)})})}function a(d,w){try{c(r[d](w))}catch(h){l(i[0][3],h)}}function c(d){d.value instanceof Tt?Promise.resolve(d.value.v).then(u,f):l(i[0][2],d)}function u(d){a("next",d)}function f(d){a("throw",d)}function l(d,w){d(w),i.shift(),i.length&&a(i[0][0],i[0][1])}}function bu(e){var t,n;return t={},r("next"),r("throw",function(o){throw o}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(o,i){t[o]=e[o]?function(s){return(n=!n)?{value:Tt(e[o](s)),done:o==="return"}:i?i(s):s}:i}}function pu(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 Pn=="function"?Pn(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(i){n[i]=e[i]&&function(s){return new Promise(function(a,c){s=e[i](s),o(a,c,s.done,s.value)})}}function o(i,s,a,c){Promise.resolve(c).then(function(u){i({value:u,done:a})},s)}}function wu(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function yu(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 mu(e){return e&&e.__esModule?e:{default:e}}function Eu(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)}function Du(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 vu=Object.freeze({__proto__:null,__extends:ru,get __assign(){return $n},__rest:ou,__decorate:iu,__param:su,__metadata:au,__awaiter:cu,__generator:uu,__createBinding:fu,__exportStar:lu,__values:Pn,__read:Io,__spread:du,__spreadArrays:hu,__await:Tt,__asyncGenerator:gu,__asyncDelegator:bu,__asyncValues:pu,__makeTemplateObject:wu,__importStar:yu,__importDefault:mu,__classPrivateFieldGet:Eu,__classPrivateFieldSet:Du}),tn=nu(vu),jn={},Ut={},To;function Au(){if(To)return Ut;To=1,Object.defineProperty(Ut,"__esModule",{value:!0}),Ut.delay=void 0;function e(t){return new Promise(n=>{setTimeout(()=>{n(!0)},t)})}return Ut.delay=e,Ut}var et={},Ln={},tt={},Uo;function Su(){return Uo||(Uo=1,Object.defineProperty(tt,"__esModule",{value:!0}),tt.ONE_THOUSAND=tt.ONE_HUNDRED=void 0,tt.ONE_HUNDRED=100,tt.ONE_THOUSAND=1e3),tt}var Mn={},Ro;function _u(){return Ro||(Ro=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}(Mn)),Mn}var Fo;function $o(){return Fo||(Fo=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=tn;t.__exportStar(Su(),e),t.__exportStar(_u(),e)}(Ln)),Ln}var Po;function xu(){if(Po)return et;Po=1,Object.defineProperty(et,"__esModule",{value:!0}),et.fromMiliseconds=et.toMiliseconds=void 0;const e=$o();function t(r){return r*e.ONE_THOUSAND}et.toMiliseconds=t;function n(r){return Math.floor(r/e.ONE_THOUSAND)}return et.fromMiliseconds=n,et}var jo;function Bu(){return jo||(jo=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=tn;t.__exportStar(Au(),e),t.__exportStar(xu(),e)}(jn)),jn}var ht={},Lo;function Ou(){if(Lo)return ht;Lo=1,Object.defineProperty(ht,"__esModule",{value:!0}),ht.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 o=Date.now()-r.started;this.timestamps.set(n,{started:r.started,elapsed:o})}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 ht.Watch=e,ht.default=e,ht}var zn={},Rt={},Mo;function Cu(){if(Mo)return Rt;Mo=1,Object.defineProperty(Rt,"__esModule",{value:!0}),Rt.IWatch=void 0;class e{}return Rt.IWatch=e,Rt}var zo;function Nu(){return zo||(zo=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),tn.__exportStar(Cu(),e)}(zn)),zn}(function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=tn;t.__exportStar(Bu(),e),t.__exportStar(Ou(),e),t.__exportStar(Nu(),e),t.__exportStar($o(),e)})(Qe);var W={};Object.defineProperty(W,"__esModule",{value:!0}),W.getLocalStorage=W.getLocalStorageOrThrow=W.getCrypto=W.getCryptoOrThrow=Vn=W.getLocation=W.getLocationOrThrow=kn=W.getNavigator=W.getNavigatorOrThrow=nn=W.getDocument=W.getDocumentOrThrow=W.getFromWindowOrThrow=W.getFromWindow=void 0;function nt(e){let t;return typeof window<"u"&&typeof window[e]<"u"&&(t=window[e]),t}W.getFromWindow=nt;function gt(e){const t=nt(e);if(!t)throw new Error(`${e} is not defined in Window`);return t}W.getFromWindowOrThrow=gt;function Iu(){return gt("document")}W.getDocumentOrThrow=Iu;function Tu(){return nt("document")}var nn=W.getDocument=Tu;function Uu(){return gt("navigator")}W.getNavigatorOrThrow=Uu;function Ru(){return nt("navigator")}var kn=W.getNavigator=Ru;function Fu(){return gt("location")}W.getLocationOrThrow=Fu;function $u(){return nt("location")}var Vn=W.getLocation=$u;function Pu(){return gt("crypto")}W.getCryptoOrThrow=Pu;function ju(){return nt("crypto")}W.getCrypto=ju;function Lu(){return gt("localStorage")}W.getLocalStorageOrThrow=Lu;function Mu(){return nt("localStorage")}W.getLocalStorage=Mu;var Hn={};Object.defineProperty(Hn,"__esModule",{value:!0});var ko=Hn.getWindowMetadata=void 0;const Vo=W;function zu(){let e,t;try{e=Vo.getDocumentOrThrow(),t=Vo.getLocationOrThrow()}catch{return null}function n(){const l=e.getElementsByTagName("link"),d=[];for(let w=0;w<l.length;w++){const h=l[w],p=h.getAttribute("rel");if(p&&p.toLowerCase().indexOf("icon")>-1){const g=h.getAttribute("href");if(g)if(g.toLowerCase().indexOf("https:")===-1&&g.toLowerCase().indexOf("http:")===-1&&g.indexOf("//")!==0){let D=t.protocol+"//"+t.host;if(g.indexOf("/")===0)D+=g;else{const E=t.pathname.split("/");E.pop();const y=E.join("/");D+=y+"/"+g}d.push(D)}else if(g.indexOf("//")===0){const D=t.protocol+g;d.push(D)}else d.push(g)}}return d}function r(...l){const d=e.getElementsByTagName("meta");for(let w=0;w<d.length;w++){const h=d[w],p=["itemprop","property","name"].map(g=>h.getAttribute(g)).filter(g=>g?l.includes(g):!1);if(p.length&&p){const g=h.getAttribute("content");if(g)return g}}return""}function o(){let l=r("name","og:site_name","og:title","twitter:title");return l||(l=e.title),l}function i(){return r("description","og:description","twitter:description","keywords")}const s=o(),a=i(),c=t.origin,u=n();return{description:a,url:c,icons:u,name:s}}ko=Hn.getWindowMetadata=zu;var ku=Object.defineProperty,Vu=Object.defineProperties,Hu=Object.getOwnPropertyDescriptors,Ho=Object.getOwnPropertySymbols,qu=Object.prototype.hasOwnProperty,Ku=Object.prototype.propertyIsEnumerable,qo=(e,t,n)=>t in e?ku(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ko=(e,t)=>{for(var n in t||(t={}))qu.call(t,n)&&qo(e,n,t[n]);if(Ho)for(var n of Ho(t))Ku.call(t,n)&&qo(e,n,t[n]);return e},Wu=(e,t)=>Vu(e,Hu(t));const Wo="ReactNative",ce={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},rn=" ",Yu=":",Yo="/",qn=2,Gu=1e3,Go="js";function Kn(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function Le(){return!nn()&&!!kn()&&navigator.product===Wo}function Zu(){return Le()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="android"}function Xu(){return Le()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="ios"}function Ft(){return!Kn()&&!!kn()&&!!nn()}function rt(){return Le()?ce.reactNative:Kn()?ce.node:Ft()?ce.browser:ce.unknown}function Ju(){var e;try{return Le()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(e=global.Application)==null?void 0:e.applicationId:void 0}catch{return}}function Zo(e,t){const n=new URLSearchParams(e);for(const r of Object.keys(t).sort())if(t.hasOwnProperty(r)){const o=t[r];o!==void 0&&n.set(r,o)}return n.toString()}function Qu(e){var t,n;const r=Xo();try{return e!=null&&e.url&&r.url&&e.url!==r.url&&(console.warn(`The configured WalletConnect 'metadata.url':${e.url} differs from the actual page url:${r.url}. This is probably unintended and can lead to issues.`),e.url=r.url),(t=e?.icons)!=null&&t.length&&e.icons.length>0&&(e.icons=e.icons.filter(o=>o!=="")),Wu(Ko(Ko({},r),e),{url:e?.url||r.url,name:e?.name||r.name,description:e?.description||r.description,icons:(n=e?.icons)!=null&&n.length&&e.icons.length>0?e.icons:r.icons})}catch(o){return console.warn("Error populating app metadata",o),e||r}}function Xo(){return ko()||{name:"",description:"",url:"",icons:[""]}}function ef(e,t){var n;const r=rt(),o={protocol:e,version:t,env:r};return r==="browser"&&(o.host=((n=Vn())==null?void 0:n.host)||"unknown"),o}function Jo(){if(rt()===ce.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){const{OS:n,Version:r}=global.Platform;return[n,r].join("-")}const e=Xc();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 Qo(){var e;const t=rt();return t===ce.browser?[t,((e=Vn())==null?void 0:e.host)||"unknown"].join(":"):t}function ei(e,t,n){const r=Jo(),o=Qo();return[[e,t].join("-"),[Go,n].join("-"),r,o].join("/")}function tf({protocol:e,version:t,relayUrl:n,sdkVersion:r,auth:o,projectId:i,useOnCloseEvent:s,bundleId:a,packageName:c}){const u=n.split("?"),f=ei(e,t,r),l={auth:o,ua:f,projectId:i,useOnCloseEvent:s||void 0,packageName:c||void 0,bundleId:a||void 0},d=Zo(u[1]||"",l);return u[0]+"?"+d}function nf(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 rf(e,t,n){if(!e[t]||typeof e[t]!==n)throw new Error(`Missing or invalid "${t}" param`)}function ti(e,t=qn){return ni(e.split(Yo),t)}function of(e){return ti(e).join(rn)}function Me(e,t){return e.filter(n=>t.includes(n)).length===e.length}function ni(e,t=qn){return e.slice(Math.max(e.length-t,0))}function sf(e){return Object.fromEntries(e.entries())}function af(e){return new Map(Object.entries(e))}function cf(e,t){const n={};return Object.keys(e).forEach(r=>{n[r]=t(e[r])}),n}const uf=e=>e;function ri(e){return e.trim().replace(/^\w/,t=>t.toUpperCase())}function ff(e){return e.split(rn).map(t=>ri(t)).join(rn)}function lf(e=Qe.FIVE_MINUTES,t){const n=Qe.toMiliseconds(e||Qe.FIVE_MINUTES);let r,o,i,s;return{resolve:a=>{i&&r&&(clearTimeout(i),r(a),s=Promise.resolve(a))},reject:a=>{i&&o&&(clearTimeout(i),o(a))},done:()=>new Promise((a,c)=>{if(s)return a(s);i=setTimeout(()=>{const u=new Error(t);s=Promise.reject(u),c(u)},n),r=a,o=c})}}function df(e,t,n){return new Promise(async(r,o)=>{const i=setTimeout(()=>o(new Error(n)),t);try{const s=await e;r(s)}catch(s){o(s)}clearTimeout(i)})}function Wn(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 hf(e){return Wn("topic",e)}function gf(e){return Wn("id",e)}function bf(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 pf(e,t){return Qe.fromMiliseconds((t||Date.now())+Qe.toMiliseconds(e))}function wf(e){return Date.now()>=Qe.toMiliseconds(e)}function yf(e,t){return`${e}${t?`:${t}`:""}`}function Oe(e=[],t=[]){return[...new Set([...e,...t])]}async function mf({id:e,topic:t,wcDeepLink:n}){var r;try{if(!n)return;const o=typeof n=="string"?JSON.parse(n):n,i=o?.href;if(typeof i!="string")return;const s=oi(i,e,t),a=rt();if(a===ce.browser){if(!((r=nn())!=null&&r.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}ii(s)}else a===ce.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(s)}catch(o){console.error(o)}}function oi(e,t,n){const r=`requestId=${t}&sessionTopic=${n}`;e.endsWith("/")&&(e=e.slice(0,-1));let o=`${e}`;if(e.startsWith("https://t.me")){const i=e.includes("?")?"&startapp=":"?startapp=";o=`${o}${i}${ci(r,!0)}`}else o=`${o}/wc?${r}`;return o}function ii(e){let t="_self";ai()?t="_top":(si()||e.startsWith("https://")||e.startsWith("http://"))&&(t="_blank"),window.open(e,t,"noreferrer noopener")}async function Ef(e,t){let n="";try{if(Ft()&&(n=localStorage.getItem(t),n))return n;n=await e.getItem(t)}catch(r){console.error(r)}return n}function Yn(e,t){return e.filter(n=>t.includes(n))}function Df(e,t){if(!e.includes(t))return null;const n=e.split(/([&,?,=])/),r=n.indexOf(t);return n[r+2]}function vf(){return typeof crypto<"u"&&crypto!=null&&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 Af(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function si(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function ai(){try{return window.self!==window.top}catch{return!1}}function ci(e,t=!1){const n=Buffer.from(e).toString("base64");return t?n.replace(/[=]/g,""):n}function Gn(e){return Buffer.from(e,"base64").toString("utf-8")}function Sf(e){return new Promise(t=>setTimeout(t,e))}function $t(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function _f(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Pt(e,...t){if(!_f(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 Zn(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");$t(e.outputLen),$t(e.blockLen)}function bt(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 ui(e,t){Pt(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}const on=BigInt(2**32-1),fi=BigInt(32);function xf(e,t=!1){return t?{h:Number(e&on),l:Number(e>>fi&on)}:{h:Number(e>>fi&on)|0,l:Number(e&on)|0}}function Bf(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let o=0;o<e.length;o++){const{h:i,l:s}=xf(e[o],t);[n[o],r[o]]=[i,s]}return[n,r]}const Of=(e,t,n)=>e<<n|t>>>32-n,Cf=(e,t,n)=>t<<n|e>>>32-n,Nf=(e,t,n)=>t<<n-32|e>>>64-n,If=(e,t,n)=>e<<n-32|t>>>64-n,pt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Tf(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Xn(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ve(e,t){return e<<32-t|e>>>t}const li=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Uf(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function di(e){for(let t=0;t<e.length;t++)e[t]=Uf(e[t])}function Rf(e){if(typeof e!="string")throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array(new TextEncoder().encode(e))}function wt(e){return typeof e=="string"&&(e=Rf(e)),Pt(e),e}function Ff(...e){let t=0;for(let r=0;r<e.length;r++){const o=e[r];Pt(o),t+=o.length}const n=new Uint8Array(t);for(let r=0,o=0;r<e.length;r++){const i=e[r];n.set(i,o),o+=i.length}return n}class Jn{clone(){return this._cloneInto()}}function hi(e){const t=r=>e().update(wt(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function ot(e=32){if(pt&&typeof pt.getRandomValues=="function")return pt.getRandomValues(new Uint8Array(e));if(pt&&typeof pt.randomBytes=="function")return pt.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}const gi=[],bi=[],pi=[],$f=BigInt(0),jt=BigInt(1),Pf=BigInt(2),jf=BigInt(7),Lf=BigInt(256),Mf=BigInt(113);for(let e=0,t=jt,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],gi.push(2*(5*r+n)),bi.push((e+1)*(e+2)/2%64);let o=$f;for(let i=0;i<7;i++)t=(t<<jt^(t>>jf)*Mf)%Lf,t&Pf&&(o^=jt<<(jt<<BigInt(i))-jt);pi.push(o)}const[zf,kf]=Bf(pi,!0),wi=(e,t,n)=>n>32?Nf(e,t,n):Of(e,t,n),yi=(e,t,n)=>n>32?If(e,t,n):Cf(e,t,n);function Vf(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let s=0;s<10;s++)n[s]=e[s]^e[s+10]^e[s+20]^e[s+30]^e[s+40];for(let s=0;s<10;s+=2){const a=(s+8)%10,c=(s+2)%10,u=n[c],f=n[c+1],l=wi(u,f,1)^n[a],d=yi(u,f,1)^n[a+1];for(let w=0;w<50;w+=10)e[s+w]^=l,e[s+w+1]^=d}let o=e[2],i=e[3];for(let s=0;s<24;s++){const a=bi[s],c=wi(o,i,a),u=yi(o,i,a),f=gi[s];o=e[f],i=e[f+1],e[f]=c,e[f+1]=u}for(let s=0;s<50;s+=10){for(let a=0;a<10;a++)n[a]=e[s+a];for(let a=0;a<10;a++)e[s+a]^=~n[(a+2)%10]&n[(a+4)%10]}e[0]^=zf[r],e[1]^=kf[r]}n.fill(0)}class Qn extends Jn{constructor(t,n,r,o=!1,i=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,$t(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Tf(this.state)}keccak(){li||di(this.state32),Vf(this.state32,this.rounds),li||di(this.state32),this.posOut=0,this.pos=0}update(t){bt(this);const{blockLen:n,state:r}=this;t=wt(t);const o=t.length;for(let i=0;i<o;){const s=Math.min(n-this.pos,o-i);for(let a=0;a<s;a++)r[this.pos++]^=t[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:o}=this;t[r]^=n,(n&128)!==0&&r===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){bt(this,!1),Pt(t),this.finish();const n=this.state,{blockLen:r}=this;for(let o=0,i=t.length;o<i;){this.posOut>=r&&this.keccak();const s=Math.min(r-this.posOut,i-o);t.set(n.subarray(this.posOut,this.posOut+s),o),this.posOut+=s,o+=s}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return $t(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(ui(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,this.state.fill(0)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:o,rounds:i,enableXOF:s}=this;return t||(t=new Qn(n,r,o,s,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=o,t.enableXOF=s,t.destroyed=this.destroyed,t}}const er=((e,t,n)=>hi(()=>new Qn(t,e,n)))(1,136,256/8);function Lt(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}function mi(e){return Lt(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const Ei="2.23.2";let tr={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:n})=>t?`${e??"https://viem.sh"}${t}${n?`#${n}`:""}`:void 0,version:`viem@${Ei}`};class it extends Error{constructor(t,n={}){const r=n.cause instanceof it?n.cause.details:n.cause?.message?n.cause.message:n.details,o=n.cause instanceof it&&n.cause.docsPath||n.docsPath,i=tr.getDocsUrl?.({...n,docsPath:o}),s=[t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...r?[`Details: ${r}`]:[],...tr.version?[`Version: ${tr.version}`]:[]].join(` `);super(s,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=o,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=t,this.version=Ei}walk(t){return Di(this,t)}}function Di(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?Di(e.cause,t):t?null:e}class vi extends it{constructor({size:t,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${t}) exceeds padding size (${n}).`,{name:"SizeExceedsPaddingSizeError"})}}function yt(e,{dir:t,size:n=32}={}){return typeof e=="string"?Hf(e,{dir:t,size:n}):qf(e,{dir:t,size:n})}function Hf(e,{dir:t,size:n=32}={}){if(n===null)return e;const r=e.replace("0x","");if(r.length>n*2)throw new vi({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r[t==="right"?"padEnd":"padStart"](n*2,"0")}`}function qf(e,{dir:t,size:n=32}={}){if(n===null)return e;if(e.length>n)throw new vi({size:e.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let o=0;o<n;o++){const i=t==="right";r[i?o:n-o-1]=e[i?o:e.length-o-1]}return r}class Kf extends it{constructor({max:t,min:n,signed:r,size:o,value:i}){super(`Number "${i}" is not in safe ${o?`${o*8}-bit ${r?"signed":"unsigned"} `:""}integer range ${t?`(${n} to ${t})`:`(above ${n})`}`,{name:"IntegerOutOfRangeError"})}}class Wf extends it{constructor({givenSize:t,maxSize:n}){super(`Size cannot exceed ${n} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}function mt(e,{size:t}){if(mi(e)>t)throw new Wf({givenSize:mi(e),maxSize:t})}function nr(e,t={}){const{signed:n}=t;t.size&&mt(e,{size:t.size});const r=BigInt(e);if(!n)return r;const o=(e.length-2)/2,i=(1n<<BigInt(o)*8n-1n)-1n;return r<=i?r:r-BigInt(`0x${"f".padStart(o*2,"f")}`)-1n}function Yf(e,t={}){return Number(nr(e,t))}const Gf=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function rr(e,t={}){return typeof e=="number"||typeof e=="bigint"?Si(e,t):typeof e=="string"?Jf(e,t):typeof e=="boolean"?Zf(e,t):Ai(e,t)}function Zf(e,t={}){const n=`0x${Number(e)}`;return typeof t.size=="number"?(mt(n,{size:t.size}),yt(n,{size:t.size})):n}function Ai(e,t={}){let n="";for(let o=0;o<e.length;o++)n+=Gf[e[o]];const r=`0x${n}`;return typeof t.size=="number"?(mt(r,{size:t.size}),yt(r,{dir:"right",size:t.size})):r}function Si(e,t={}){const{signed:n,size:r}=t,o=BigInt(e);let i;r?n?i=(1n<<BigInt(r)*8n-1n)-1n:i=2n**(BigInt(r)*8n)-1n:typeof e=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));const s=typeof i=="bigint"&&n?-i-1n:0;if(i&&o>i||o<s){const c=typeof e=="bigint"?"n":"";throw new Kf({max:i?`${i}${c}`:void 0,min:`${s}${c}`,signed:n,size:r,value:`${e}${c}`})}const a=`0x${(n&&o<0?(1n<<BigInt(r*8))+BigInt(o):o).toString(16)}`;return r?yt(a,{size:r}):a}const Xf=new TextEncoder;function Jf(e,t={}){const n=Xf.encode(e);return Ai(n,t)}const Qf=new TextEncoder;function el(e,t={}){return typeof e=="number"||typeof e=="bigint"?nl(e,t):typeof e=="boolean"?tl(e,t):Lt(e)?xi(e,t):Bi(e,t)}function tl(e,t={}){const n=new Uint8Array(1);return n[0]=Number(e),typeof t.size=="number"?(mt(n,{size:t.size}),yt(n,{size:t.size})):n}const Ce={zero:48,nine:57,A:65,F:70,a:97,f:102};function _i(e){if(e>=Ce.zero&&e<=Ce.nine)return e-Ce.zero;if(e>=Ce.A&&e<=Ce.F)return e-(Ce.A-10);if(e>=Ce.a&&e<=Ce.f)return e-(Ce.a-10)}function xi(e,t={}){let n=e;t.size&&(mt(n,{size:t.size}),n=yt(n,{dir:"right",size:t.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const o=r.length/2,i=new Uint8Array(o);for(let s=0,a=0;s<o;s++){const c=_i(r.charCodeAt(a++)),u=_i(r.charCodeAt(a++));if(c===void 0||u===void 0)throw new it(`Invalid byte sequence ("${r[a-2]}${r[a-1]}" in "${r}").`);i[s]=c*16+u}return i}function nl(e,t){const n=Si(e,t);return xi(n)}function Bi(e,t={}){const n=Qf.encode(e);return typeof t.size=="number"?(mt(n,{size:t.size}),yt(n,{dir:"right",size:t.size})):n}function Oi(e,t){const n=t||"hex",r=er(Lt(e,{strict:!1})?el(e):e);return n==="bytes"?r:rr(r)}class Ci extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){const n=super.get(t);return super.has(t)&&n!==void 0&&(this.delete(t),super.set(t,n)),n}set(t,n){if(super.set(t,n),this.maxSize&&this.size>this.maxSize){const r=this.keys().next().value;r&&this.delete(r)}return this}}const or=new Ci(8192);function rl(e,t){if(or.has(`${e}.${t}`))return or.get(`${e}.${t}`);const n=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),r=Oi(Bi(n),"bytes"),o=(t?n.substring(`${t}0x`.length):n).split("");for(let s=0;s<40;s+=2)r[s>>1]>>4>=8&&o[s]&&(o[s]=o[s].toUpperCase()),(r[s>>1]&15)>=8&&o[s+1]&&(o[s+1]=o[s+1].toUpperCase());const i=`0x${o.join("")}`;return or.set(`${e}.${t}`,i),i}function ol(e){const t=Oi(`0x${e.substring(4)}`).substring(26);return rl(`0x${t}`)}async function il({hash:e,signature:t}){const n=Lt(e)?e:rr(e),{secp256k1:r}=await Promise.resolve().then(function(){return Pd});return`0x${(()=>{if(typeof t=="object"&&"r"in t&&"s"in t){const{r:u,s:f,v:l,yParity:d}=t,w=Number(d??l),h=Ni(w);return new r.Signature(nr(u),nr(f)).addRecoveryBit(h)}const s=Lt(t)?t:rr(t),a=Yf(`0x${s.slice(130)}`),c=Ni(a);return r.Signature.fromCompact(s.substring(2,130)).addRecoveryBit(c)})().recoverPublicKey(n.substring(2)).toHex(!1)}`}function Ni(e){if(e===0||e===1)return e;if(e===27)return 0;if(e===28)return 1;throw new Error("Invalid yParityOrV value")}async function sl({hash:e,signature:t}){return ol(await il({hash:e,signature:t}))}function al(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),a=Number(n&i),c=r?4:0,u=r?0:4;e.setUint32(t+c,s,r),e.setUint32(t+u,a,r)}function cl(e,t,n){return e&t^~e&n}function ul(e,t,n){return e&t^e&n^t&n}class fl extends Jn{constructor(t,n,r,o){super(),this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Xn(this.buffer)}update(t){bt(this);const{view:n,buffer:r,blockLen:o}=this;t=wt(t);const i=t.length;for(let s=0;s<i;){const a=Math.min(o-this.pos,i-s);if(a===o){const c=Xn(t);for(;o<=i-s;s+=o)this.process(c,s);continue}r.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){bt(this),ui(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:o,isLE:i}=this;let{pos:s}=this;n[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(r,0),s=0);for(let l=s;l<o;l++)n[l]=0;al(r,o-8,BigInt(this.length*8),i),this.process(r,0);const a=Xn(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)a.setUint32(4*l,f[l],i)}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:o,finished:i,destroyed:s,pos:a}=this;return t.length=o,t.pos=a,t.finished=i,t.destroyed=s,o%n&&t.buffer.set(r),t}}const ll=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ze=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ke=new Uint32Array(64);class dl extends fl{constructor(){super(64,32,8,!1),this.A=ze[0]|0,this.B=ze[1]|0,this.C=ze[2]|0,this.D=ze[3]|0,this.E=ze[4]|0,this.F=ze[5]|0,this.G=ze[6]|0,this.H=ze[7]|0}get(){const{A:t,B:n,C:r,D:o,E:i,F:s,G:a,H:c}=this;return[t,n,r,o,i,s,a,c]}set(t,n,r,o,i,s,a,c){this.A=t|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(t,n){for(let l=0;l<16;l++,n+=4)ke[l]=t.getUint32(n,!1);for(let l=16;l<64;l++){const d=ke[l-15],w=ke[l-2],h=ve(d,7)^ve(d,18)^d>>>3,p=ve(w,17)^ve(w,19)^w>>>10;ke[l]=p+ke[l-7]+h+ke[l-16]|0}let{A:r,B:o,C:i,D:s,E:a,F:c,G:u,H:f}=this;for(let l=0;l<64;l++){const d=ve(a,6)^ve(a,11)^ve(a,25),w=f+d+cl(a,c,u)+ll[l]+ke[l]|0,p=(ve(r,2)^ve(r,13)^ve(r,22))+ul(r,o,i)|0;f=u,u=c,c=a,a=s+w|0,s=i,i=o,o=r,r=w+p|0}r=r+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(r,o,i,s,a,c,u,f)}roundClean(){ke.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Ne=hi(()=>new dl);new Ci(128);const hl=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Ii=new Uint8Array(new Array(16).fill(0).map((e,t)=>t)),gl=Ii.map(e=>(9*e+5)%16);let bl=[Ii],pl=[gl];for(let e=0;e<4;e++)for(let t of[bl,pl])t.push(t[e].map(n=>hl[n]));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const sn=BigInt(0),an=BigInt(1),wl=BigInt(2);function st(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Ae(e){if(!st(e))throw new Error("Uint8Array expected")}function Et(e,t){if(typeof t!="boolean")throw new Error(e+" boolean expected, got "+t)}const yl=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Dt(e){Ae(e);let t="";for(let n=0;n<e.length;n++)t+=yl[e[n]];return t}function vt(e){const t=e.toString(16);return t.length&1?"0"+t:t}function ir(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?sn:BigInt("0x"+e)}const Ie={_0:48,_9:57,A:65,F:70,a:97,f:102};function Ti(e){if(e>=Ie._0&&e<=Ie._9)return e-Ie._0;if(e>=Ie.A&&e<=Ie.F)return e-(Ie.A-10);if(e>=Ie.a&&e<=Ie.f)return e-(Ie.a-10)}function At(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof 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 o=0,i=0;o<n;o++,i+=2){const s=Ti(e.charCodeAt(i)),a=Ti(e.charCodeAt(i+1));if(s===void 0||a===void 0){const c=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}r[o]=s*16+a}return r}function Se(e){return ir(Dt(e))}function Mt(e){return Ae(e),ir(Dt(Uint8Array.from(e).reverse()))}function Ve(e,t){return At(e.toString(16).padStart(t*2,"0"))}function cn(e,t){return Ve(e,t).reverse()}function ml(e){return At(vt(e))}function ne(e,t,n){let r;if(typeof t=="string")try{r=At(t)}catch(i){throw new Error(e+" must be hex string or Uint8Array, cause: "+i)}else if(st(t))r=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");const o=r.length;if(typeof n=="number"&&o!==n)throw new Error(e+" of length "+n+" expected, got "+o);return r}function de(...e){let t=0;for(let r=0;r<e.length;r++){const o=e[r];Ae(o),t+=o.length}const n=new Uint8Array(t);for(let r=0,o=0;r<e.length;r++){const i=e[r];n.set(i,o),o+=i.length}return n}function El(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}function un(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}const sr=e=>typeof e=="bigint"&&sn<=e;function St(e,t,n){return sr(e)&&sr(t)&&sr(n)&&t<=e&&e<n}function _e(e,t,n,r){if(!St(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}function Ui(e){let t;for(t=0;e>sn;e>>=an,t+=1);return t}function Dl(e,t){return e>>BigInt(t)&an}function vl(e,t,n){return e|(n?an:sn)<<BigInt(t)}const ar=e=>(wl<<BigInt(e-1))-an,cr=e=>new Uint8Array(e),Ri=e=>Uint8Array.from(e);function Fi(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=cr(e),o=cr(e),i=0;const s=()=>{r.fill(1),o.fill(0),i=0},a=(...l)=>n(o,r,...l),c=(l=cr())=>{o=a(Ri([0]),l),r=a(),l.length!==0&&(o=a(Ri([1]),l),r=a())},u=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let l=0;const d=[];for(;l<t;){r=a();const w=r.slice();d.push(w),l+=r.length}return de(...d)};return(l,d)=>{s(),c(l);let w;for(;!(w=d(u()));)c();return s(),w}}const Al={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"||st(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 at(e,t,n={}){const r=(o,i,s)=>{const a=Al[i];if(typeof a!="function")throw new Error("invalid validator function");const c=e[o];if(!(s&&c===void 0)&&!a(c,e))throw new Error("param "+String(o)+" is invalid. Expected "+i+", got "+c)};for(const[o,i]of Object.entries(t))r(o,i,!1);for(const[o,i]of Object.entries(n))r(o,i,!0);return e}const Sl=()=>{throw new Error("not implemented")};function ur(e){const t=new WeakMap;return(n,...r)=>{const o=t.get(n);if(o!==void 0)return o;const i=e(n,...r);return t.set(n,i),i}}var _l=Object.freeze({__proto__:null,isBytes:st,abytes:Ae,abool:Et,bytesToHex:Dt,numberToHexUnpadded:vt,hexToNumber:ir,hexToBytes:At,bytesToNumberBE:Se,bytesToNumberLE:Mt,numberToBytesBE:Ve,numberToBytesLE:cn,numberToVarBytesBE:ml,ensureBytes:ne,concatBytes:de,equalBytes:El,utf8ToBytes:un,inRange:St,aInRange:_e,bitLen:Ui,bitGet:Dl,bitSet:vl,bitMask:ar,createHmacDrbg:Fi,validateObject:at,notImplemented:Sl,memoized:ur});const xl="0.1.1";function Bl(){return xl}class ue extends Error{constructor(t,n={}){const r=(()=>{if(n.cause instanceof ue){if(n.cause.details)return n.cause.details;if(n.cause.shortMessage)return n.cause.shortMessage}return n.cause?.message?n.cause.message:n.details})(),o=n.cause instanceof ue&&n.cause.docsPath||n.docsPath,s=`https://oxlib.sh${o??""}`,a=[t||"An error occurred.",...n.metaMessages?["",...n.metaMessages]:[],...r||o?["",r?`Details: ${r}`:void 0,o?`See: ${s}`: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@${Bl()}`}),this.cause=n.cause,this.details=r,this.docs=s,this.docsPath=o,this.shortMessage=t}walk(t){return $i(this,t)}}function $i(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause?$i(e.cause,t):t?null:e}function Ol(e,t){if(Li(e)>t)throw new $l({givenSize:Li(e),maxSize:t})}const Te={zero:48,nine:57,A:65,F:70,a:97,f:102};function Pi(e){if(e>=Te.zero&&e<=Te.nine)return e-Te.zero;if(e>=Te.A&&e<=Te.F)return e-(Te.A-10);if(e>=Te.a&&e<=Te.f)return e-(Te.a-10)}function Cl(e,t={}){const{dir:n,size:r=32}=t;if(r===0)return e;if(e.length>r)throw new Pl({size:e.length,targetSize:r,type:"Bytes"});const o=new Uint8Array(r);for(let i=0;i<r;i++){const s=n==="right";o[s?i:r-i-1]=e[s?i:e.length-i-1]}return o}function fr(e,t){if(dr(e)>t)throw new Hl({givenSize:dr(e),maxSize:t})}function ji(e,t={}){const{dir:n,size:r=32}=t;if(r===0)return e;const o=e.replace("0x","");if(o.length>r*2)throw new ql({size:Math.ceil(o.length/2),targetSize:r,type:"Hex"});return`0x${o[n==="right"?"padEnd":"padStart"](r*2,"0")}`}const Nl=new TextEncoder;function Il(e){return e instanceof Uint8Array?e:typeof e=="string"?Ul(e):Tl(e)}function Tl(e){return e instanceof Uint8Array?e:new Uint8Array(e)}function Ul(e,t={}){const{size:n}=t;let r=e;n&&(fr(e,n),r=lr(e,n));let o=r.slice(2);o.length%2&&(o=`0${o}`);const i=o.length/2,s=new Uint8Array(i);for(let a=0,c=0;a<i;a++){const u=Pi(o.charCodeAt(c++)),f=Pi(o.charCodeAt(c++));if(u===void 0||f===void 0)throw new ue(`Invalid byte sequence ("${o[c-2]}${o[c-1]}" in "${o}").`);s[a]=u*16+f}return s}function Rl(e,t={}){const{size:n}=t,r=Nl.encode(e);return typeof n=="number"?(Ol(r,n),Fl(r,n)):r}function Fl(e,t){return Cl(e,{dir:"right",size:t})}function Li(e){return e.length}class $l extends ue{constructor({givenSize:t,maxSize:n}){super(`Size cannot exceed \`${n}\` bytes. Given size: \`${t}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}}class Pl extends ue{constructor({size:t,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (\`${t}\`) exceeds padding size (\`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeExceedsPaddingSizeError"})}}const jl=new TextEncoder,Ll=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Mi(...e){return`0x${e.reduce((t,n)=>t+n.replace("0x",""),"")}`}function Ml(e,t={}){const n=`0x${Number(e)}`;return typeof t.size=="numbe