vendor: 11,311 bytes, lines 1-15
1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/secp256k1-CFAP755V.js","assets/index-DC4IDbpk.js","assets/index-Coj-m6it.css","assets/events-DJxiHJrG.js","assets/index-QStLE_5U.js"])))=>i.map(i=>d[i]); 2import{V as Xh,_ as eu,g as tu,n as vt}from"./index-DC4IDbpk.js";import{e as rt,N as Po}from"./events-DJxiHJrG.js";var aa=function(t,e,r){if(r||arguments.length===2)for(var i=0,s=e.length,n;i<s;i++)(n||!(i in e))&&(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))},Bd=function(){function t(e,r,i){this.name=e,this.version=r,this.os=i,this.type="browser"}return t}(),jd=function(){function t(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return t}(),Ud=function(){function t(e,r,i,s){this.name=e,this.version=r,this.os=i,this.bot=s,this.type="bot-device"}return t}(),Fd=function(){function t(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return t}(),Ld=function(){function t(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return t}(),Md=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,qd=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,ca=3,kd=[["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",Md]],ha=[["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 zd(t){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new Ld:typeof navigator<"u"?Vd(navigator.userAgent):Wd()}function Hd(t){return t!==""&&kd.reduce(function(e,r){var i=r[0],s=r[1];if(e)return e;var n=s.exec(t);return!!n&&[i,n]},!1)}function Vd(t){var e=Hd(t);if(!e)return null;var r=e[0],i=e[1];if(r==="searchbot")return new Fd;var s=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);s?s.length<ca&&(s=aa(aa([],s,!0),Gd(ca-s.length),!0)):s=[];var n=s.join("."),o=Kd(t),a=qd.exec(t);return a&&a[1]?new Ud(r,n,o,a[1]):new Bd(r,n,o)}function Kd(t){for(var e=0,r=ha.length;e<r;e++){var i=ha[e],s=i[0],n=i[1],o=n.exec(t);if(o)return s}return null}function Wd(){var t=typeof process<"u"&&process.version;return t?new jd(process.version.slice(1)):null}function Gd(t){for(var e=[],r=0;r<t;r++)e.push("0");return e}var N={};/*! ***************************************************************************** 3Copyright (c) Microsoft Corporation. 4 5Permission to use, copy, modify, and/or distribute this software for any 6purpose with or without fee is hereby granted. 7 8THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 9REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 10AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 11INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 12LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 13OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 14PERFORMANCE OF THIS SOFTWARE. 15***************************************************************************** */var Un=function(t,e){return Un=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var s in i)i.hasOwnProperty(s)&&(r[s]=i[s])},Un(t,e)};function Yd(t,e){Un(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var Fn=function(){return Fn=Object.assign||function(e){for(var r,i=1,s=arguments.length;i<s;i++){r=arguments[i];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Fn.apply(this,arguments)};function Jd(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]]);return r}function Zd(t,e,r,i){var s=arguments.length,n=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(n=(s<3?o(n):s>3?o(e,r,n):o(e,r))||n);return s>3&&n&&Object.defineProperty(e,r,n),n}function Qd(t,e){return function(r,i){e(r,i,t)}}function Xd(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function ep(t,e,r,i){function s(n){return n instanceof r?n:new r(function(o){o(n)})}return new(r||(r=Promise))(function(n,o){function a(u){try{h(i.next(u))}catch(l){o(l)}}function c(u){try{h(i.throw(u))}catch(l){o(l)}}function h(u){u.done?n(u.value):s(u.value).then(a,c)}h((i=i.apply(t,e||[])).next())})}function tp(t,e){var r={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},i,s,n,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(h){return function(u){return c([h,u])}}function c(h){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,s&&(n=h[0]&2?s.return:h[0]?s.throw||((n=s.return)&&n.call(s),0):s.next)&&!(n=n.call(s,h[1])).done)return n;switch(s=0,n&&(h=[h[0]&2,n.value]),h[0]){case 0:case 1:n=h;break;case 4:return r.label++,{value:h[1],done:!1};case 5:r.label++,s=h[1],h=[0];continue;case 7:h=r.ops.pop(),r.trys.pop();continue;default:if(n=r.trys,!(n=n.length>0&&n[n.length-1])&&(h[0]===6||h[0]===2)){r=0;continue}if(h[0]===3&&(!n||h[1]>n[0]&&h[1]<n[3])){r.label=h[1];break}if(h[0]===6&&r.label<n[1]){r.label=n[1],n=h;break}if(n&&r.label<n[2]){r.label=n[2],r.ops.push(h);break}n[2]&&r.ops.pop(),r.trys.pop();continue}h=e.call(t,r)}catch(u){h=[6,u],s=0}finally{i=n=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function rp(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}function ip(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function Ln(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function ru(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var i=r.call(t),s,n=[],o;try{for(;(e===void 0||e-- >0)&&!(s=i.next()).done;)n.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return n}function sp(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(ru(arguments[e]));return t}function np(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var i=Array(t),s=0,e=0;e<r;e++)for(var n=arguments[e],o=0,a=n.length;o<a;o++,s++)i[s]=n[o];return i}function Ei(t){return this instanceof Ei?(this.v=t,this):new Ei(t)}function op(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=r.apply(t,e||[]),s,n=[];return s={},o("next"),o("throw"),o("return"),s[Symbol.asyncIterator]=function(){return this},s;function o(d){i[d]&&(s[d]=function(f){return new Promise(function(p,y){n.push([d,f,p,y])>1||a(d,f)})})}function a(d,f){try{c(i[d](f))}catch(p){l(n[0][3],p)}}function c(d){d.value instanceof Ei?Promise.resolve(d.value.v).then(h,u):l(n[0][2],d)}function h(d){a("next",d)}function u(d){a("throw",d)}function l(d,f){d(f),n.shift(),n.length&&a(n[0][0],n[0][1])}}function ap(t){var e,r;return e={},i("next"),i("throw",function(s){throw s}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(s,n){e[s]=t[s]?function(o){return(r=!r)?{value:Ei(t[s](o)),done:s==="return"}:n?n(o):o}:n}}function cp(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof Ln=="function"?Ln(t):t[Symbol.iterator](),r={},i("next"),i("throw"),i("return"),r[Symbol.asyncIterator]=function(){return this},r);function i(n){r[n]=t[n]&&function(o){return new Promise(function(a,c){o=t[n](o),s(a,c,o.done,o.value)})}}function s(n,o,a,c){Promise.resolve(c).then(function(h){n({value:h,done:a})},o)}}function hp(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function up(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function lp(t){return t&&t.__esModule?t:{default:t}}function dp(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function pp(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}const fp=Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return Fn},__asyncDelegator:ap,__asyncGenerator:op,__asyncValues:cp,__await:Ei,__awaiter:ep,__classPrivateFieldGet:dp,__classPrivateFieldSet:pp,__createBinding:rp,__decorate:Zd,__exportStar:ip,__extends:Yd,__generator:tp,__importDefault:lp,__importStar:up,__makeTemplateOb
15ject:hp,__metadata:Xd,__param:Qd,__read:ru,__rest:Jd,__spread:sp,__spreadArrays:np,__values:Ln},Symbol.toStringTag,{value:"Module"})),As=Xh(fp);var Ys={},ri={},ua;function gp(){if(ua)return ri;ua=1,Object.defineProperty(ri,"__esModule",{value:!0}),ri.delay=void 0;function t(e){return new Promise(r=>{setTimeout(()=>{r(!0)},e)})}return ri.delay=t,ri}var Kt={},Js={},Wt={},la;function yp(){return la||(la=1,Object.defineProperty(Wt,"__esModule",{value:!0}),Wt.ONE_THOUSAND=Wt.ONE_HUNDRED=void 0,Wt.ONE_HUNDRED=100,Wt.ONE_THOUSAND=1e3),Wt}var Zs={},da;function mp(){return da||(da=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ONE_YEAR=t.FOUR_WEEKS=t.THREE_WEEKS=t.TWO_WEEKS=t.ONE_WEEK=t.THIRTY_DAYS=t.SEVEN_DAYS=t.FIVE_DAYS=t.THREE_DAYS=t.ONE_DAY=t.TWENTY_FOUR_HOURS=t.TWELVE_HOURS=t.SIX_HOURS=t.THREE_HOURS=t.ONE_HOUR=t.SIXTY_MINUTES=t.THIRTY_MINUTES=t.TEN_MINUTES=t.FIVE_MINUTES=t.ONE_MINUTE=t.SIXTY_SECONDS=t.THIRTY_SECONDS=t.TEN_SECONDS=t.FIVE_SECONDS=t.ONE_SECOND=void 0,t.ONE_SECOND=1,t.FIVE_SECONDS=5,t.TEN_SECONDS=10,t.THIRTY_SECONDS=30,t.SIXTY_SECONDS=60,t.ONE_MINUTE=t.SIXTY_SECONDS,t.FIVE_MINUTES=t.ONE_MINUTE*5,t.TEN_MINUTES=t.ONE_MINUTE*10,t.THIRTY_MINUTES=t.ONE_MINUTE*30,t.SIXTY_MINUTES=t.ONE_MINUTE*60,t.ONE_HOUR=t.SIXTY_MINUTES,t.THREE_HOURS=t.ONE_HOUR*3,t.SIX_HOURS=t.ONE_HOUR*6,t.TWELVE_HOURS=t.ONE_HOUR*12,t.TWENTY_FOUR_HOURS=t.ONE_HOUR*24,t.ONE_DAY=t.TWENTY_FOUR_HOURS,t.THREE_DAYS=t.ONE_DAY*3,t.FIVE_DAYS=t.ONE_DAY*5,t.SEVEN_DAYS=t.ONE_DAY*7,t.THIRTY_DAYS=t.ONE_DAY*30,t.ONE_WEEK=t.SEVEN_DAYS,t.TWO_WEEKS=t.ONE_WEEK*2,t.THREE_WEEKS=t.ONE_WEEK*3,t.FOUR_WEEKS=t.ONE_WEEK*4,t.ONE_YEAR=t.ONE_DAY*365}(Zs)),Zs}var pa;function iu(){return pa||(pa=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=As;e.__exportStar(yp(),t),e.__exportStar(mp(),t)}(Js)),Js}var fa;function wp(){if(fa)return Kt;fa=1,Object.defineProperty(Kt,"__esModule",{value:!0}),Kt.fromMiliseconds=Kt.toMiliseconds=void 0;const t=iu();function e(i){return i*t.ONE_THOUSAND}Kt.toMiliseconds=e;function r(i){return Math.floor(i/t.ONE_THOUSAND)}return Kt.fromMiliseconds=r,Kt}var ga;function bp(){return ga||(ga=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=As;e.__exportStar(gp(),t),e.__exportStar(wp(),t)}(Ys)),Ys}var gr={},ya;function vp(){if(ya)return gr;ya=1,Object.defineProperty(gr,"__esModule",{value:!0}),gr.Watch=void 0;class t{constructor(){this.timestamps=new Map}start(r){if(this.timestamps.has(r))throw new Error(`Watch already started for label: ${r}`);this.timestamps.set(r,{started:Date.now()})}stop(r){const i=this.get(r);if(typeof i.elapsed<"u")throw new Error(`Watch already stopped for label: ${r}`);const s=Date.now()-i.started;this.timestamps.set(r,{started:i.started,elapsed:s})}get(r){const i=this.timestamps.get(r);if(typeof i>"u")throw new Error(`No timestamp found for label: ${r}`);return i}elapsed(r){const i=this.get(r);return i.elapsed||Date.now()-i.started}}return gr.Watch=t,gr.default=t,gr}var Qs={},ii={},ma;function Ep(){if(ma)return ii;ma=1,Object.defineProperty(ii,"__esModule",{value:!0}),ii.IWatch=void 0;class t{}return ii.IWatch=t,ii}var wa;function _p(){return wa||(wa=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),As.__exportStar(Ep(),t)}(Qs)),Qs}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=As;e.__exportStar(bp(),t),e.__exportStar(vp(),t),e.__exportStar(_p(),t),e.__exportStar(iu(),t)})(N);var oe={};Object.defineProperty(oe,"__esModule",{value:!0});oe.getLocalStorage=oe.getLocalStorageOrThrow=oe.getCrypto=oe.getCryptoOrThrow=su=oe.getLocation=oe.getLocationOrThrow=Ao=oe.getNavigator=oe.getNavigatorOrThrow=Ti=oe.getDocument=oe.getDocumentOrThrow=oe.getFromWindowOrThrow=oe.getFromWindow=void 0;function hr(t){let e;return typeof window<"u"&&typeof window[t]<"u"&&(e=window[t]),e}oe.getFromWindow=hr;function Gr(t){const e=hr(t);if(!e)throw new Error(`${t} is not defined in Window`);return e}oe.getFromWindowOrThrow=Gr;function Ip(){return Gr("document")}oe.getDocumentOrThrow=Ip;function $p(){return hr("document")}var Ti=oe.getDocument=$p;function Dp(){return Gr("navigator")}oe.getNavigatorOrThrow=Dp;function Sp(){return hr("navigator")}var Ao=oe.getNavigator=Sp;function Op(){return Gr("location")}oe.getLocationOrThrow=Op;function Pp(){return hr("location")}var su=oe.getLocation=Pp;function Ap(){return Gr("crypto")}oe.getCryptoOrThrow=Ap;function xp(){return hr("crypto")}oe.getCrypto=xp;function Cp(){return Gr("localStorage")}oe.getLocalStorageOrThrow=Cp;function Tp(){return hr("localStorage")}oe.getLocalStorage=Tp;var xo={};Object.defineProperty(xo,"__esModule",{value:!0});var nu=xo.getWindowMetadata=void 0;const ba=oe;function Rp(){let t,e;
15try{t=ba.getDocumentOrThrow(),e=ba.getLocationOrThrow()}catch{return null}function r(){const l=t.getElementsByTagName("link"),d=[];for(let f=0;f<l.length;f++){const p=l[f],y=p.getAttribute("rel");if(y&&y.toLowerCase().indexOf("icon")>-1){const w=p.getAttribute("href");if(w)if(w.toLowerCase().indexOf("https:")===-1&&w.toLowerCase().indexOf("http:")===-1&&w.indexOf("//")!==0){let v=e.protocol+"//"+e.host;if(w.indexOf("/")===0)v+=w;else{const b=e.pathname.split("/");b.pop();const E=b.join("/");v+=E+"/"+w}d.push(v)}else if(w.indexOf("//")===0){const v=e.protocol+w;d.push(v)}else d.push(w)}}return d}function i(...l){const d=t.getElementsByTagName("meta");for(let f=0;f<d.length;f++){const p=d[f],y=["itemprop","property","name"].map(w=>p.getAttribute(w)).filter(w=>w?l.includes(w):!1);if(y.length&&y){const w=p.getAttribute("content");if(w)return w}}return""}function s(){let l=i("name","og:site_name","og:title","twitter:title");return l||(l=t.title),l}function n(){return i("description","og:description","twitter:description","keywords")}const o=s(),a=n(),c=e.origin,h=r();return{description:a,url:c,icons:h,name:o}}nu=xo.getWindowMetadata=Rp;function _i(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function va(t){return _i(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const ou="2.23.2";let si={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:r})=>e?`${t??"https://viem.sh"}${e}${r?`#${r}`:""}`:void 0,version:`viem@${ou}`};class sr extends Error{constructor(e,r={}){var a;const i=(()=>{var c;return r.cause instanceof sr?r.cause.details:(c=r.cause)!=null&&c.message?r.cause.message:r.details})(),s=r.cause instanceof sr&&r.cause.docsPath||r.docsPath,n=(a=si.getDocsUrl)==null?void 0:a.call(si,{...r,docsPath:s}),o=[e||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...n?[`Docs: ${n}`]:[],...i?[`Details: ${i}`]:[],...si.version?[`Version: ${si.version}`]:[]].join(` 16`);super(o,r.cause?{cause:r.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=i,this.docsPath=s,this.metaMessages=r.metaMessages,this.name=r.name??this.name,this.shortMessage=e,this.version=ou}walk(e){return au(this,e)}}function au(t,e){return e!=null&&e(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?au(t.cause,e):e?null:t}class cu extends sr{constructor({size:e,targetSize:r,type:i}){super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (${e}) exceeds padding size (${r}).`,{name:"SizeExceedsPaddingSizeError"})}}function Yr(t,{dir:e,size:r=32}={}){return typeof t=="string"?Np(t,{dir:e,size:r}):Bp(t,{dir:e,size:r})}function Np(t,{dir:e,size:r=32}={}){if(r===null)return t;const i=t.replace("0x","");if(i.length>r*2)throw new cu({size:Math.ceil(i.length/2),targetSize:r,type:"hex"});return`0x${i[e==="right"?"padEnd":"padStart"](r*2,"0")}`}function Bp(t,{dir:e,size:r=32}={}){if(r===null)return t;if(t.length>r)throw new cu({size:t.length,targetSize:r,type:"bytes"});const i=new Uint8Array(r);for(let s=0;s<r;s++){const n=e==="right";i[n?s:r-s-1]=t[n?s:t.length-s-1]}return i}class jp extends sr{constructor({max:e,min:r,signed:i,size:s,value:n}){super(`Number "${n}" is not in safe ${s?`${s*8}-bit ${i?"signed":"unsigned"} `:""}integer range ${e?`(${r} to ${e})`:`(above ${r})`}`,{name:"IntegerOutOfRangeError"})}}class Up extends sr{constructor({givenSize:e,maxSize:r}){super(`Size cannot exceed ${r} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function Jr(t,{size:e}){if(va(t)>e)throw new Up({givenSize:va(t),maxSize:e})}function Mn(t,e={}){const{signed:r}=e;e.size&&Jr(t,{size:e.size});const i=BigInt(t);if(!r)return i;const s=(t.length-2)/2,n=(1n<<BigInt(s)*8n-1n)-1n;return i<=n?i:i-BigInt(`0x${"f".padStart(s*2,"f")}`)-1n}function Fp(t,e={}){return Number(Mn(t,e))}const Lp=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function qn(t,e={}){return typeof t=="number"||typeof t=="bigint"?uu(t,e):typeof t=="string"?kp(t,e):typeof t=="boolean"?Mp(t,e):hu(t,e)}function Mp(t,e={}){const r=`0x${Number(t)}`;return typeof e.size=="number"?(Jr(r,{size:e.size}),Yr(r,{size:e.size})):r}function hu(t,e={}){let r="";for(let s=0;s<t.length;s++)r+=Lp[t[s]];const i=`0x${r}`;return typeof e.size=="number"?(Jr(i,{size:e.size}),Yr(i,{dir:"right",size:e.size})):i}function uu(t,e={}){const{signed:r,size:i}=e,s=BigInt(t);let n;
16i?r?n=(1n<<BigInt(i)*8n-1n)-1n:n=2n**(BigInt(i)*8n)-1n:typeof t=="number"&&(n=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof n=="bigint"&&r?-n-1n:0;if(n&&s>n||s<o){const c=typeof t=="bigint"?"n":"";throw new jp({max:n?`${n}${c}`:void 0,min:`${o}${c}`,signed:r,size:i,value:`${t}${c}`})}const a=`0x${(r&&s<0?(1n<<BigInt(i*8))+BigInt(s):s).toString(16)}`;return i?Yr(a,{size:i}):a}const qp=new TextEncoder;function kp(t,e={}){const r=qp.encode(t);return hu(r,e)}const zp=new TextEncoder;function Hp(t,e={}){return typeof t=="number"||typeof t=="bigint"?Kp(t,e):typeof t=="boolean"?Vp(t,e):_i(t)?lu(t,e):du(t,e)}function Vp(t,e={}){const r=new Uint8Array(1);return r[0]=Number(t),typeof e.size=="number"?(Jr(r,{size:e.size}),Yr(r,{size:e.size})):r}const $t={zero:48,nine:57,A:65,F:70,a:97,f:102};function Ea(t){if(t>=$t.zero&&t<=$t.nine)return t-$t.zero;if(t>=$t.A&&t<=$t.F)return t-($t.A-10);if(t>=$t.a&&t<=$t.f)return t-($t.a-10)}function lu(t,e={}){let r=t;e.size&&(Jr(r,{size:e.size}),r=Yr(r,{dir:"right",size:e.size}));let i=r.slice(2);i.length%2&&(i=`0${i}`);const s=i.length/2,n=new Uint8Array(s);for(let o=0,a=0;o<s;o++){const c=Ea(i.charCodeAt(a++)),h=Ea(i.charCodeAt(a++));if(c===void 0||h===void 0)throw new sr(`Invalid byte sequence ("${i[a-2]}${i[a-1]}" in "${i}").`);n[o]=c*16+h}return n}function Kp(t,e){const r=uu(t,e);return lu(r)}function du(t,e={}){const r=zp.encode(t);return typeof e.size=="number"?(Jr(r,{size:e.size}),Yr(r,{dir:"right",size:e.size})):r}function ys(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Wp(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function xs(t,...e){if(!Wp(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function wO(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");ys(t.outputLen),ys(t.blockLen)}function _a(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Gp(t,e){xs(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const Ki=BigInt(2**32-1),Ia=BigInt(32);function Yp(t,e=!1){return e?{h:Number(t&Ki),l:Number(t>>Ia&Ki)}:{h:Number(t>>Ia&Ki)|0,l:Number(t&Ki)|0}}function Jp(t,e=!1){let r=new Uint32Array(t.length),i=new Uint32Array(t.length);for(let s=0;s<t.length;s++){const{h:n,l:o}=Yp(t[s],e);[r[s],i[s]]=[n,o]}return[r,i]}const Zp=(t,e,r)=>t<<r|e>>>32-r,Qp=(t,e,r)=>e<<r|t>>>32-r,Xp=(t,e,r)=>e<<r-32|t>>>64-r,ef=(t,e,r)=>t<<r-32|e>>>64-r,yr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function tf(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function bO(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function vO(t,e){return t<<32-e|t>>>e}const $a=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function rf(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Da(t){for(let e=0;e<t.length;e++)t[e]=rf(t[e])}function sf(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function pu(t){return typeof t=="string"&&(t=sf(t)),xs(t),t}function EO(...t){let e=0;for(let i=0;i<t.length;i++){const s=t[i];xs(s),e+=s.length}const r=new Uint8Array(e);for(let i=0,s=0;i<t.length;i++){const n=t[i];r.set(n,s),s+=n.length}return r}class nf{clone(){return this._cloneInto()}}function of(t){const e=i=>t().update(pu(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function _O(t=32){if(yr&&typeof yr.getRandomValues=="function")return yr.getRandomValues(new Uint8Array(t));if(yr&&typeof yr.randomBytes=="function")return yr.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const fu=[],gu=[],yu=[],af=BigInt(0),ni=BigInt(1),cf=BigInt(2),hf=BigInt(7),uf=BigInt(256),lf=BigInt(113);for(let t=0,e=ni,r=1,i=0;t<24;t++){[r,i]=[i,(2*r+3*i)%5],fu.push(2*(5*i+r)),gu.push((t+1)*(t+2)/2%64);let s=af;for(let n=0;n<7;n++)e=(e<<ni^(e>>hf)*lf)%uf,e&cf&&(s^=ni<<(ni<<BigInt(n))-ni);yu.push(s)}const[df,pf]=Jp(yu,!0),Sa=(t,e,r)=>r>32?Xp(t,e,r):Zp(t,e,r),Oa=(t,e,r)=>r>32?ef(t,e,r):Qp(t,e,r);
16function ff(t,e=24){const r=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)r[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,h=r[c],u=r[c+1],l=Sa(h,u,1)^r[a],d=Oa(h,u,1)^r[a+1];for(let f=0;f<50;f+=10)t[o+f]^=l,t[o+f+1]^=d}let s=t[2],n=t[3];for(let o=0;o<24;o++){const a=gu[o],c=Sa(s,n,a),h=Oa(s,n,a),u=fu[o];s=t[u],n=t[u+1],t[u]=c,t[u+1]=h}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)r[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~r[(a+2)%10]&r[(a+4)%10]}t[0]^=df[i],t[1]^=pf[i]}r.fill(0)}class Co extends nf{constructor(e,r,i,s=!1,n=24){if(super(),this.blockLen=e,this.suffix=r,this.outputLen=i,this.enableXOF=s,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,ys(i),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(){$a||Da(this.state32),ff(this.state32,this.rounds),$a||Da(this.state32),this.posOut=0,this.pos=0}update(e){_a(this);const{blockLen:r,state:i}=this;e=pu(e);const s=e.length;for(let n=0;n<s;){const o=Math.min(r-this.pos,s-n);for(let a=0;a<o;a++)i[this.pos++]^=e[n++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:r,pos:i,blockLen:s}=this;e[i]^=r,r&128&&i===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){_a(this,!1),xs(e),this.finish();const r=this.state,{blockLen:i}=this;for(let s=0,n=e.length;s<n;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,n-s);e.set(r.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return ys(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Gp(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:r,suffix:i,outputLen:s,rounds:n,enableXOF:o}=this;return e||(e=new Co(r,i,s,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=i,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}}const gf=(t,e,r)=>of(()=>new Co(e,t,r)),yf=gf(1,136,256/8);function mu(t,e){const r=e||"hex",i=yf(_i(t,{strict:!1})?Hp(t):t);return r==="bytes"?i:qn(i)}class mf extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const r=super.get(e);return super.has(e)&&r!==void 0&&(this.delete(e),super.set(e,r)),r}set(e,r){if(super.set(e,r),this.maxSize&&this.size>this.maxSize){const i=this.keys().next().value;i&&this.delete(i)}return this}}const Xs=new mf(8192);function wf(t,e){if(Xs.has(`${t}.${e}`))return Xs.get(`${t}.${e}`);const r=t.substring(2).toLowerCase(),i=mu(du(r),"bytes"),s=r.split("");for(let o=0;o<40;o+=2)i[o>>1]>>4>=8&&s[o]&&(s[o]=s[o].toUpperCase()),(i[o>>1]&15)>=8&&s[o+1]&&(s[o+1]=s[o+1].toUpperCase());const n=`0x${s.join("")}`;return Xs.set(`${t}.${e}`,n),n}function bf(t){const e=mu(`0x${t.substring(4)}`).substring(26);return wf(`0x${e}`)}async function vf({hash:t,signature:e}){const r=_i(t)?t:qn(t),{secp256k1:i}=await eu(async()=>{const{secp256k1:o}=await import("./secp256k1-CFAP755V.js");return{secp256k1:o}},__vite__mapDeps([0,1,2,3]));return`0x${(()=>{if(typeof e=="object"&&"r"in e&&"s"in e){const{r:h,s:u,v:l,yParity:d}=e,f=Number(d??l),p=Pa(f);return new i.Signature(Mn(h),Mn(u)).addRecoveryBit(p)}const o=_i(e)?e:qn(e),a=Fp(`0x${o.slice(130)}`),c=Pa(a);return i.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(c)})().recoverPublicKey(r.substring(2)).toHex(!1)}`}function Pa(t){if(t===0||t===1)return t;if(t===27)return 0;if(t===28)return 1;throw new Error("Invalid yParityOrV value")}async function Ef({hash:t,signature:e}){return bf(await vf({hash:t,signature:e}))}function _f(t){if(t.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let h=0;h<e.length;h++)e[h]=255;for(let h=0;h<t.length;h++){const u=t.charAt(h),l=u.charCodeAt(0);if(e[l]!==255)throw new TypeError(u+" is ambiguous");e[l]=h}const r=t.length,i=t.charAt(0),s=Math.log(r)/Math.log(256),n=Math.log(256)/Math.log(r);
16function o(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";let u=0,l=0,d=0;const f=h.length;for(;d!==f&&h[d]===0;)d++,u++;const p=(f-d)*n+1>>>0,y=new Uint8Array(p);for(;d!==f;){let b=h[d],E=0;for(let I=p-1;(b!==0||E<l)&&I!==-1;I--,E++)b+=256*y[I]>>>0,y[I]=b%r>>>0,b=b/r>>>0;if(b!==0)throw new Error("Non-zero carry");l=E,d++}let w=p-l;for(;w!==p&&y[w]===0;)w++;let v=i.repeat(u);for(;w<p;++w)v+=t.charAt(y[w]);return v}function a(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;let u=0,l=0,d=0;for(;h[u]===i;)l++,u++;const f=(h.length-u)*s+1>>>0,p=new Uint8Array(f);for(;u<h.length;){const b=h.charCodeAt(u);if(b>255)return;let E=e[b];if(E===255)return;let I=0;for(let P=f-1;(E!==0||I<d)&&P!==-1;P--,I++)E+=r*p[P]>>>0,p[P]=E%256>>>0,E=E/256>>>0;if(E!==0)throw new Error("Non-zero carry");d=I,u++}let y=f-d;for(;y!==f&&p[y]===0;)y++;const w=new Uint8Array(l+(f-y));let v=l;for(;y!==f;)w[v++]=p[y++];return w}function c(h){const u=a(h);if(u)return u;throw new Error("Non-base"+r+" character")}return{encode:o,decodeUnsafe:a,decode:c}}var If="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const $f=_f(If),Df=t=>JSON.stringify(t,(e,r)=>typeof r=="bigint"?r.toString()+"n":r),Sf=t=>{const e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,r=t.replace(e,'$1"$2n"$3');return JSON.parse(r,(i,s)=>typeof s=="string"&&s.match(/^\d+n$/)?BigInt(s.substring(0,s.length-1)):s)};function nr(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return Sf(t)}catch{return t}}function Bt(t){return typeof t=="string"?t:Df(t)||""}function Of(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function wu(t,...e){if(!Of(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Aa(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Pf(t,e){wu(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const mr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const en=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);function Af(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function bu(t){return typeof t=="string"&&(t=Af(t)),wu(t),t}let xf=class{clone(){return this._cloneInto()}};function Cf(t){const e=i=>t().update(bu(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function vu(t=32){if(mr&&typeof mr.getRandomValues=="function")return mr.getRandomValues(new Uint8Array(t));if(mr&&typeof mr.randomBytes=="function")return mr.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}function Tf(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);const s=BigInt(32),n=BigInt(4294967295),o=Number(r>>s&n),a=Number(r&n),c=i?4:0,h=i?0:4;t.setUint32(e+c,o,i),t.setUint32(e+h,a,i)}let Rf=class extends xf{constructor(e,r,i,s){super(),this.blockLen=e,this.outputLen=r,this.padOffset=i,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=en(this.buffer)}update(e){Aa(this);const{view:r,buffer:i,blockLen:s}=this;e=bu(e);const n=e.length;for(let o=0;o<n;){const a=Math.min(s-this.pos,n-o);if(a===s){const c=en(e);for(;s<=n-o;o+=s)this.process(c,o);continue}i.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===s&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Aa(this),Pf(e,this),this.finished=!0;const{buffer:r,view:i,blockLen:s,isLE:n}=this;let{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>s-o&&(this.process(i,0),o=0);for(let l=o;l<s;l++)r[l]=0;Tf(i,s-8,BigInt(this.length*8),n),this.process(i,0);const a=en(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const h=c/4,u=this.get();if(h>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<h;l++)a.setUint32(4*l,u[l],n)}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const i=e.slice(0,r);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:r,buffer:i,length:s,finished:n,destroyed:o,pos:a}=this;return e.length=s,e.pos=a,e.finished=n,e.destroyed=o,s%r&&e.buffer.set(i),e}};const Wi=BigInt(2**32-1),kn=BigInt(32);function Eu(t,e=!1){return e?{h:Number(t&Wi),l:Number(t>>kn&Wi)}:{h:Number(t>>kn&Wi)|0,l:Number(t&Wi)|0}}function Nf(t,e=!1){let r=new Uint32Array(t.length),i=new Uint32Array(t.length);for(let s=0;s<t.length;s++){const{h:n,l:o}=Eu(t[s],e);[r[s],i[s]]=[n,o]}return[r,i]}const Bf=(t,e)=>BigInt(t>>>0)<<kn|BigInt(e>>>0),jf=(t,e,r)=>t>>>r,Uf=(t,e,r)=>t<<32-r|e>>
vendor: 1,792 bytes, line 16
16>r,Ff=(t,e,r)=>t>>>r|e<<32-r,Lf=(t,e,r)=>t<<32-r|e>>>r,Mf=(t,e,r)=>t<<64-r|e>>>r-32,qf=(t,e,r)=>t>>>r-32|e<<64-r,kf=(t,e)=>e,zf=(t,e)=>t,Hf=(t,e,r)=>t<<r|e>>>32-r,Vf=(t,e,r)=>e<<r|t>>>32-r,Kf=(t,e,r)=>e<<r-32|t>>>64-r,Wf=(t,e,r)=>t<<r-32|e>>>64-r;function Gf(t,e,r,i){const s=(e>>>0)+(i>>>0);return{h:t+r+(s/2**32|0)|0,l:s|0}}const Yf=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),Jf=(t,e,r,i)=>e+r+i+(t/2**32|0)|0,Zf=(t,e,r,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0),Qf=(t,e,r,i,s)=>e+r+i+s+(t/2**32|0)|0,Xf=(t,e,r,i,s)=>(t>>>0)+(e>>>0)+(r>>>0)+(i>>>0)+(s>>>0),eg=(t,e,r,i,s,n)=>e+r+i+s+n+(t/2**32|0)|0,V={fromBig:Eu,split:Nf,toBig:Bf,shrSH:jf,shrSL:Uf,rotrSH:Ff,rotrSL:Lf,rotrBH:Mf,rotrBL:qf,rotr32H:kf,rotr32L:zf,rotlSH:Hf,rotlSL:Vf,rotlBH:Kf,rotlBL:Wf,add:Gf,add3L:Yf,add3H:Jf,add4L:Zf,add4H:Qf,add5H:eg,add5L:Xf},[tg,rg]=V.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e3585
165771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),jt=new Uint32Array(80),Ut=new Uint32Array(80);let ig=class extends Rf{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:r,Bh:i,Bl:s,Ch:n,Cl:o,Dh:a,Dl:c,Eh:h,El:u,Fh:l,Fl:d,Gh:f,Gl:p,Hh:y,Hl:w}=this;return[e,r,i,s,n,o,a,c,h,u,l,d,f,p,y,w]}set(e,r,i,s,n,o,a,c,h,u,l,d,f,p,y,w){this.Ah=e|0,this.Al=r|0,this.Bh=i|0,this.Bl=s|0,this.Ch=n|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=h|0,this.El=u|0,this.Fh=l|0,this.Fl=d|0,this.Gh=f|0,this.Gl=p|0,this.Hh=y|0,this.Hl=w|0}process(e,r){for(let E=0;E<16;E++,r+=4)jt[E]=e.getUint32(r),Ut[E]=e.getUint32(r+=4);for(let E=16;E<80;E++){const I=jt[E-15]|0,P=Ut[E-15]|0,A=V.rotrSH(I,P,1)^V.rotrSH(I,P,8)^V.shrSH(I,P,7),O=V.rotrSL(I,P,1)^V.rotrSL(I,P,8)^V.shrSL(I,P,7),C=jt[E-2]|0,D=Ut[E-2]|0,q=V.rotrSH(C,D,19)^V.rotrBH(C,D,61)^V.shrSH(C,D,6),U=V.rotrSL(C,D,19)^V.rotrBL(C,D,61)^V.shrSL(C,D,6),j=V.add4L(O,U,Ut[E-7],Ut[E-16]),k=V.add4H(j,A,q,jt[E-7],jt[E-16]);jt[E]=k|0,Ut[E]=j|0}let{Ah:i,Al:s,Bh:n,Bl:o,Ch:a,Cl:c,Dh:h,Dl:u,Eh:l,El:d,Fh:f,Fl:p,Gh:y,Gl:w,Hh:v,Hl:b}=this;for(let E=0;E<80;E++){const I=V.rotrSH(l,d,14)^V.rotrSH(l,d,18)^V.rotrBH(l,d,41),P=V.rotrSL(l,d,14)^V.rotrSL(l,d,18)^V.rotrBL(l,d,41),A=l&f^~l&y,O=d&p^~d&w,C=V.add5L(b,P,O,rg[E],Ut[E]),D=V.add5H(C,v,I,A,tg[E],jt[E]),q=C|0,U=V.rotrSH(i,s,28)^V.rotrBH(i,s,34)^V.rotrBH(i,s,39),j=V.rotrSL(i,s,28)^V.rotrBL(i,s,34)^V.rotrBL(i,s,39),k=i&n^i&a^n&a,T=s&o^s&c^o&c;v=y|0,b=w|0,y=f|0,w=p|0,f=l|0,p=d|0,{h:l,l:d}=V.add(h|0,u|0,D|0,q|0),h=a|0,u=c|0,a=n|0,c=o|0,n=i|0,o=s|0;const g=V.add3L(q,j,T);i=V.add3H(g,D,U,k),s=g|0}({h:i,l:s}=V.add(this.Ah|0,this.Al|0,i|0,s|0)),{h:n,l:o}=V.add(this.Bh|0,this.Bl|0,n|0,o|0),{h:a,l:c}=V.add(this.Ch|0,this.Cl|0,a|0,c|0),{h,l:u}=V.add(this.Dh|0,this.Dl|0,h|0,u|0),{h:l,l:d}=V.add(this.Eh|0,this.El|0,l|0,d|0),{h:f,l:p}=V.add(this.Fh|0,this.Fl|0,f|0,p|0),{h:y,l:w}=V.add(this.Gh|0,this.Gl|0,y|0,w|0),{h:v,l:b}=V.add(this.Hh|0,this.Hl|0,v|0,b|0),this.set(i,s,n,o,a,c,h,u,l,d,f,p,y,w,v,b)}roundClean(){jt.fill(0),Ut.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};const sg=Cf(()=>new ig);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const To=BigInt(0),_u=BigInt(1),ng=BigInt(2);function Ro(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function No(t){if(!Ro(t))throw new Error("Uint8Array expected")}function tn(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const og=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Bo(t){No(t);let e="";for(let r=0;r<t.length;r++)e+=og[t[r]];return e}function Iu(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?To:BigInt("0x"+t)}const Dt={_0:48,_9:57,A:65,F:70,a:97,f:102};function xa(t){if(t>=Dt._0&&t<=Dt._9)return t-Dt._0;if(t>=Dt.A&&t<=Dt.F)return t-(Dt.A-10);if(t>=Dt.a&&t<=Dt.f)return t-(Dt.a-10)}function $u(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const i=new Uint8Array(r);for(let s=0,n=0;s<r;s++,n+=2){const o=xa(t.charCodeAt(n)),a=xa(t.charCodeAt(n+1));if(o===void 0||a===void 0){const c=t[n]+t[n+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+n)}i[s]=o*16+a}return i}function ag(t){return Iu(Bo(t))}function cs(t){return No(t),Iu(Bo(Uint8Array.from(t).reverse()))}function Du(t,e){return $u(t.toString(16).padStart(e*2,"0"))}function zn(t,e){return Du(t,e).reverse()}function St(t,e,r){let i;if(typeof e=="string")try{i=$u(e)}catch(n){throw new Error(t+" must be hex string or Uint8Array, cause: "+n)}else if(Ro(e))i=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const s=i.length;if(typeof r=="number"&&s!==r)throw new Error(t+" of length "+r+" expected, got "+s);return i}function Ca(...t){let e=0;for(let i=0;i<t.length;i++){const s=t[i];No(s),e+=s.length}
vendor: 21,354 bytes, line 16
16const r=new Uint8Array(e);for(let i=0,s=0;i<t.length;i++){const n=t[i];r.set(n,s),s+=n.length}return r}const rn=t=>typeof t=="bigint"&&To<=t;function cg(t,e,r){return rn(t)&&rn(e)&&rn(r)&&e<=t&&t<r}function oi(t,e,r,i){if(!cg(e,r,i))throw new Error("expected valid "+t+": "+r+" <= n < "+i+", got "+e)}function hg(t){let e;for(e=0;t>To;t>>=_u,e+=1);return e}const ug=t=>(ng<<BigInt(t-1))-_u,lg={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||Ro(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function jo(t,e,r={}){const i=(s,n,o)=>{const a=lg[n];if(typeof a!="function")throw new Error("invalid validator function");const c=t[s];if(!(o&&c===void 0)&&!a(c,t))throw new Error("param "+String(s)+" is invalid. Expected "+n+", got "+c)};for(const[s,n]of Object.entries(e))i(s,n,!1);for(const[s,n]of Object.entries(r))i(s,n,!0);return t}function Ta(t){const e=new WeakMap;return(r,...i)=>{const s=e.get(r);if(s!==void 0)return s;const n=t(r,...i);return e.set(r,n),n}}const be=BigInt(0),ce=BigInt(1),Zt=BigInt(2),dg=BigInt(3),Hn=BigInt(4),Ra=BigInt(5),Na=BigInt(8);function pe(t,e){const r=t%e;return r>=be?r:e+r}function pg(t,e,r){if(e<be)throw new Error("invalid exponent, negatives unsupported");if(r<=be)throw new Error("invalid modulus");if(r===ce)return be;let i=ce;for(;e>be;)e&ce&&(i=i*t%r),t=t*t%r,e>>=ce;return i}function pt(t,e,r){let i=t;for(;e-- >be;)i*=i,i%=r;return i}function Ba(t,e){if(t===be)throw new Error("invert: expected non-zero number");if(e<=be)throw new Error("invert: expected positive modulus, got "+e);let r=pe(t,e),i=e,s=be,n=ce;for(;r!==be;){const o=i/r,a=i%r,c=s-n*o;i=r,r=a,s=n,n=c}if(i!==ce)throw new Error("invert: does not exist");return pe(s,e)}function fg(t){const e=(t-ce)/Zt;let r,i,s;for(r=t-ce,i=0;r%Zt===be;r/=Zt,i++);for(s=Zt;s<t&&pg(s,e,t)!==t-ce;s++)if(s>1e3)throw new Error("Cannot find square root: likely non-prime P");if(i===1){const o=(t+ce)/Hn;return function(a,c){const h=a.pow(c,o);if(!a.eql(a.sqr(h),c))throw new Error("Cannot find square root");return h}}const n=(r+ce)/Zt;return function(o,a){if(o.pow(a,e)===o.neg(o.ONE))throw new Error("Cannot find square root");let c=i,h=o.pow(o.mul(o.ONE,s),r),u=o.pow(a,n),l=o.pow(a,r);for(;!o.eql(l,o.ONE);){if(o.eql(l,o.ZERO))return o.ZERO;let d=1;for(let p=o.sqr(l);d<c&&!o.eql(p,o.ONE);d++)p=o.sqr(p);const f=o.pow(h,ce<<BigInt(c-d-1));h=o.sqr(f),u=o.mul(u,f),l=o.mul(l,h),c=d}return u}}function gg(t){if(t%Hn===dg){const e=(t+ce)/Hn;return function(r,i){const s=r.pow(i,e);if(!r.eql(r.sqr(s),i))throw new Error("Cannot find square root");return s}}if(t%Na===Ra){const e=(t-Ra)/Na;return function(r,i){const s=r.mul(i,Zt),n=r.pow(s,e),o=r.mul(i,n),a=r.mul(r.mul(o,Zt),n),c=r.mul(o,r.sub(a,r.ONE));if(!r.eql(r.sqr(c),i))throw new Error("Cannot find square root");return c}}return fg(t)}const yg=(t,e)=>(pe(t,e)&ce)===ce,mg=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function wg(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=mg.reduce((i,s)=>(i[s]="function",i),e);return jo(t,r)}function bg(t,e,r){if(r<be)throw new Error("invalid exponent, negatives unsupported");if(r===be)return t.ONE;if(r===ce)return e;let i=t.ONE,s=e;for(;r>be;)r&ce&&(i=t.mul(i,s)),s=t.sqr(s),r>>=ce;return i}function vg(t,e){const r=new Array(e.length),i=e.reduce((n,o,a)=>t.is0(o)?n:(r[a]=n,t.mul(n,o)),t.ONE),s=t.inv(i);return e.reduceRight((n,o,a)=>t.is0(o)?n:(r[a]=t.mul(n,r[a]),t.mul(n,o)),s),r}function Su(t,e){const r=e!==void 0?e:t.toString(2).length,i=Math.ceil(r/8);return{nBitLength:r,nByteLength:i}}function Ou(t,e,r=!1,i={}){if(t<=be)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:s,nByteLength:n}=Su(t,e);if(n>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:t,isLE:r,BITS:s,BYTES:n,MASK:ug(s),ZERO:be,ONE:ce,create:c=>pe(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return be<=c&&c<t},is0:c=>c===be,isOdd:c=>(c&ce)===ce,neg:c=>pe(-c,t),eql:(c,h)=>c===h,sqr:c=>pe(c*c,t),add:(c,h)=>pe(c+h,t),sub:(c,h)=>pe(c-h,t),mul:(c,h)=>pe(c*h,t),pow:(c,h)=>bg(a,c,h),div:(c,h)=>pe(c*Ba(h,t),t),sqrN:c=>c*c,addN:(c,h)=>c+h,subN:(c,h)=>c-h,mulN:(c,h)=>c*h,inv:c=>Ba(c,t),sqrt:i.sqrt||(c=>(o||(o=gg(t)),o(a,c))),invertBatch:c=>vg(a,c),cmov:(c,h,u)=>u?h:c,toBytes:c=>r?zn(c,n):Du(c,n),fromBytes:c=>{if(c.length!==n)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+c.length);return r?cs(c):ag(c)}});return Object.freeze(a)}const ja=BigInt(0),Gi=BigInt(1);function sn(t,e){const r=e.negate();return t?r:e}function Pu(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function nn(t,e){Pu(t,e);const r=Math.ceil(e/t)+1,i=2**(t-1);return{windows:r,windowSize:i}}function Eg(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((r,i)=>{if(!(r instanceof e))throw new Error("invalid point at index "+i)})}function _g(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,i)=>{if(!e.isValid(r))throw new Error("invalid scalar at index "+i)})}const on=new WeakMap,Au=new WeakMap;function an(t){return Au.get(t)||1}function Ig(t,e){return{constTimeNegate:sn,hasPrecomputes(r){return an(r)!==1},unsafeLadder(r,i,s=t.ZERO){let n=r;for(;i>ja;)i&Gi&&(s=s.add(n)),n=n.double(),i>>=Gi;return s},precomputeWindow(r,i){const{windows:s,windowSize:n}=nn(i,e),o=[];let a=r,c=a;for(let h=0;h<s;h++){c=a,o.push(c);for(let u=1;u<n;u++)c=c.add(a),o.push(c);a=c.double()}return o},wNAF(r,i,s){const{windows:n,windowSize:o}=nn(r,e);let a=t.ZERO,c=t.BASE;const h=BigInt(2**r-1),u=2**r,l=BigInt(r);for(let d=0;d<n;d++){const f=d*o;let p=Number(s&h);s>>=l,p>o&&(p-=u,s+=Gi);const y=f,w=f+Math.abs(p)-1,v=d%2!==0,b=p<0;p===0?c=c.add(sn(v,i[y])):a=a.add(sn(b,i[w]))}return{p:a,f:c}},wNAFUnsafe(r,i,s,n=t.ZERO){const{windows:o,windowSize:a}=nn(r,e),c=BigInt(2**r-1),h=2**r,u=BigInt(r);for(let l=0;l<o;l++){const d=l*a;if(s===ja)break;let f=Number(s&c);if(s>>=u,f>a&&(f-=h,s+=Gi),f===0)continue;let p=i[d+Math.abs(f)-1];f<0&&(p=p.negate()),n=n.add(p)}return n},getPrecomputes(r,i,s){let n=on.get(i);return n||(n=this.precomputeWindow(i,r),r!==1&&on.set(i,s(n))),n},wNAFCached(r,i,s){const n=an(r);return this.wNAF(n,this.getPrecomputes(n,r,s),i)},wNAFCachedUnsafe(r,i,s,n){const o=an(r);return o===1?this.unsafeLadder(r,i,n):this.wNAFUnsafe(o,this.getPrecomputes(o,r,s),i,n)},setWindowSize(r,i){Pu(i,e),Au.set(r,i),on.delete(r)}}}function $g(t,e,r,i){if(Eg(r,t),_g(i,e),r.length!==i.length)throw new Error("arrays of points and scalars must have equal length");const s=t.ZERO,n=hg(BigInt(r.length)),o=n>12?n-3:n>4?n-2:n?2:1,a=(1<<o)-1,c=new Array(a+1).fill(s),h=Math.floor((e.BITS-1)/o)*o;let u=s;for(let l=h;l>=0;l-=o){c.fill(s);for(let f=0;f<i.length;f++){const p=i[f],y=Number(p>>BigInt(l)&BigInt(a));c[y]=c[y].add(r[f])}let d=s;for(let f=c.length-1,p=s;f>0;f--)p=p.add(c[f]),d=d.add(p);if(u=u.add(d),l!==0)for(let f=0;f<o;f++)u=u.double()}return u}function Dg(t){return wg(t.Fp),jo(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Su(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}const nt=BigInt(0),Be=BigInt(1),Yi=BigInt(2),Sg=BigInt(8),Og={zip215:!0};function Pg(t){const e=Dg(t);return jo(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Ag(t){const e=Pg(t),{Fp:r,n:i,prehash:s,hash:n,randomBytes:o,nByteLength:a,h:c}=e,h=Yi<<BigInt(a*8)-Be,u=r.create,l=Ou(e.n,e.nBitLength),d=e.uvRatio||((g,m)=>{try{return{isValid:!0,value:r.sqrt(g*r.inv(m))}}catch{return{isValid:!1,value:nt}}}),f=e.adjustScalarBytes||(g=>g),p=e.domain||((g,m,_)=>{if(tn("phflag",_),m.length||_)throw new Error("Contexts/pre-hash are not supported");return g});function y(g,m){oi("coordinate "+g,m,nt,h)}function w(g){if(!(g instanceof E))throw new Error("ExtendedPoint expected")}const v=Ta((g,m)=>{const{ex:_,ey:S,ez:$}=g,x=g.is0();m==null&&(m=x?Sg:r.inv($));const F=u(_*m),M=u(S*m),z=u($*m);if(x)return{x:nt,y:Be};if(z!==Be)throw new Error("invZ was invalid");return{x:F,y:M}}),b=Ta(g=>{const{a:m,d:_}=e;if(g.is0())throw new Error("bad point: ZERO");const{ex:S,ey:$,ez:x,et:F}=g,M=u(S*S),z=u($*$),L=u(x*x),H=u(L*L),G=u(M*m),se=u(L*u(G+z)),ee=u(H+u(_*u(M*z)));if(se!==ee)throw new Error("bad point: equation left != right (1)");const Y=u(S*$),Pe=u(x*F);if(Y!==Pe)throw new Error("bad point: equation left != right (2)");return!0});class E{constructor(m,_,S,$){this.ex=m,this.ey=_,this.ez=S,this.et=$,y("x",m),y("y",_),y("z",S),y("t",$),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(m){if(m instanceof E)throw new Error("extended point not allowed");const{x:_,y:S}=m||{};return y("x",_),y("y",S),new E(_,S,Be,u(_*S))}static normalizeZ(m){const _=r.invertBatch(m.map(S=>S.ez));return m.map((S,$)=>S.toAffine(_[$])).map(E.fromAffine)}static msm(m,_){return $g(E,l,m,_)}_setWindowSize(m){A.setWindowSize(this,m)}assertValidity(){b(this)}equals(m){w(m);const{ex:_,ey:S,ez:$}=this,{ex:x,ey:F,ez:M}=m,z=u(_*M),L=u(x*$),H=u(S*M),G=u(F*$);return z===L&&H===G}is0(){return this.equals(E.ZERO)}negate(){return new E(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){const{a:m}=e,{ex:_,ey:S,ez:$}=this,x=u(_*_),F=u(S*S),M=u(Yi*u($*$)),z=u(m*x),L=_+S,H=u(u(L*L)-x-F),G=z+F,se=G-M,ee=z-F,Y=u(H*se),Pe=u(G*ee),Ee=u(H*ee),Ce=u(se*G);return new E(Y,Pe,Ce,Ee)}add(m){w(m);const{a:_,d:S}=e,{ex:$,ey:x,ez:F,et:M}=this,{ex:z,ey:L,ez:H,et:G}=m;if(_===BigInt(-1)){const ea=u((x-$)*(L+z)),ta=u((x+$)*(L-z)),Gs=u(ta-ea);if(Gs===nt)return this.double();const ra=u(F*Yi*G),ia=u(M*Yi*H),sa=ia+ra,na=ta+ea,oa=ia-ra,Cd=u(sa*Gs),Td=u(na*oa),Rd=u(sa*oa),Nd=u(Gs*na);return new E(Cd,Td,Nd,Rd)}const se=u($*z),ee=u(x*L),Y=u(M*S*G),Pe=u(F*H),Ee=u(($+x)*(z+L)-se-ee),Ce=Pe-Y,Ye=Pe+Y,Je=u(ee-_*se),fr=u(Ee*Ce),Pd=u(Ye*Je),Ad=u(Ee*Je),xd=u(Ce*Ye);return new E(fr,Pd,xd,Ad)}subtract(m){return this.add(m.negate())}wNAF(m){return A.wNAFCached(this,m,E.normalizeZ)}multiply(m){const _=m;oi("scalar",_,Be,i);const{p:S,f:$}=this.wNAF(_);return E.normalizeZ([S,$])[0]}multiplyUnsafe(m,_=E.ZERO){const S=m;return oi("scalar",S,nt,i),S===nt?P:this.is0()||S===Be?this:A.wNAFCachedUnsafe(this,S,E.normalizeZ,_)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return A.unsafeLadder(this,i).is0()}toAffine(m){return v(this,m)}clearCofactor(){const{h:m}=e;return m===Be?this:this.multiplyUnsafe(m)}static fromHex(m,_=!1){const{d:S,a:$}=e,x=r.BYTES;m=St("pointHex",m,x),tn("zip215",_);const F=m.slice(),M=m[x-1];F[x-1]=M&-129;const z=cs(F),L=_?h:r.ORDER;oi("pointHex.y",z,nt,L);const H=u(z*z),G=u(H-Be),se=u(S*H-$);let{isValid:ee,value:Y}=d(G,se);if(!ee)throw new Error("Point.fromHex: invalid y coordinate");const Pe=(Y&Be)===Be,Ee=(M&128)!==0;if(!_&&Y===nt&&Ee)throw new Error("Point.fromHex: x=0 and x_0=1");return Ee!==Pe&&(Y=u(-Y)),E.fromAffine({x:Y,y:z})}static fromPrivateKey(m){return D(m).point}toRawBytes(){const{x:m,y:_}=this.toAffine(),S=zn(_,r.BYTES);return S[S.length-1]|=m&Be?128:0,S}toHex(){return Bo(this.toRawBytes())}}E.BASE=new E(e.Gx,e.Gy,Be,u(e.Gx*e.Gy)),E.ZERO=new E(nt,Be,Be,nt);const{BASE:I,ZERO:P}=E,A=Ig(E,a*8);function O(g){return pe(g,i)}function C(g){return O(cs(g))}function D(g){const m=r.BYTES;g=St("private key",g,m);const _=St("hashed private key",n(g),2*m),S=f(_.slice(0,m)),$=_.slice(m,2*m),x=C(S),F=I.multiply(x),M=F.toRawBytes();return{head:S,prefix:$,scalar:x,point:F,pointBytes:M}}function q(g){return D(g).pointBytes}function U(g=new Uint8Array,...m){const _=Ca(...m);return C(n(p(_,St("context",g),!!s)))}function j(g,m,_={}){g=St("message",g),s&&(g=s(g));const{prefix:S,scalar:$,pointBytes:x}=D(m),F=U(_.context,S,g),M=I.multiply(F).toRawBytes(),z=U(_.context,M,x,g),L=O(F+z*$);oi("signature.s",L,nt,i);const H=Ca(M,zn(L,r.BYTES));return St("result",H,r.BYTES*2)}const k=Og;function T(g,m,_,S=k){const{context:$,zip215:x}=S,F=r.BYTES;g=St("signature",g,2*F),m=St("message",m),_=St("publicKey",_,F),x!==void 0&&tn("zip215",x),s&&(m=s(m));const M=cs(g.slice(F,2*F));let z,L,H;try{z=E.fromHex(_,x),L=E.fromHex(g.slice(0,F),x),H=I.multiplyUnsafe(M)}catch{return!1}if(!x&&z.isSmallOrder())return!1;const G=U($,L.toRawBytes(),z.toRawBytes(),m);return L.add(z.multiplyUnsafe(G)).subtract(H).clearCofactor().equals(E.ZERO)}return I._setWindowSize(8),{CURVE:e,getPublicKey:q,sign:j,verify:T,ExtendedPoint:E,utils:{getExtendedPublicKey:D,randomPrivateKey:()=>o(r.BYTES),precompute(g=8,m=E.BASE){return m._setWindowSize(g),m.multiply(BigInt(3)),m}}}}BigInt(0),BigInt(1);const Uo=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Ua=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const xg=BigInt(1),Fa=BigInt(2);BigInt(3);const Cg=BigInt(5),Tg=BigInt(8);function Rg(t){const e=BigInt(10),r=BigInt(20),i=BigInt(40),s=BigInt(80),n=Uo,o=t*t%n*t%n,a=pt(o,Fa,n)*o%n,c=pt(a,xg,n)*t%n,h=pt(c,Cg,n)*c%n,u=pt(h,e,n)*h%n,l=pt(u,r,n)*u%n,d=pt(l,i,n)*l%n,f=pt(d,s,n)*d%n,p=pt(f,s,n)*d%n,y=pt(p,e,n)*h%n;return{pow_p_5_8:pt(y,Fa,n)*t%n,b2:o}}function Ng(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function Bg(t,e){const r=Uo,i=pe(e*e*e,r),s=pe(i*i*e,r),n=Rg(t*s).pow_p_5_8;let o=pe(t*i*n,r);const a=pe(e*o*o,r),c=o,h=pe(o*Ua,r),u=a===t,l=a===pe(-t,r),d=a===pe(-t*Ua,r);return u&&(o=c),(l||d)&&(o=h),yg(o,r)&&(o=pe(-o,r)),{isValid:u||l,value:o}}const jg=Ou(Uo,void 0,!0),Ug={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:jg,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Tg,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:sg,randomBytes:vu,adjustScalarBytes:Ng,uvRatio:Bg},xu=Ag(Ug),Fg="EdDSA",Lg="JWT",ms=".",Cs="base64url",Cu="utf8",Tu="utf8",Mg=":",qg="did",kg="key",La="base58btc",zg="z",Hg="K36",Vg=32;function Fo(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function Ru(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?Fo(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function Nu(t,e){e||(e=t.reduce((s,n)=>s+n.length,0));const r=Ru(e);let i=0;for(const s of t)r.set(s,i),i+=s.length;return Fo(r)}function Kg(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var s=0;s<t.length;s++){var n=t.charAt(s),o=n.charCodeAt(0);if(r[o]!==255)throw new TypeError(n+" is ambiguous");r[o]=s}var a=t.length,c=t.charAt(0),h=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var y=0,w=0,v=0,b=p.length;v!==b&&p[v]===0;)v++,y++;for(var E=(b-v)*u+1>>>0,I=new Uint8Array(E);v!==b;){for(var P=p[v],A=0,O=E-1;(P!==0||A<w)&&O!==-1;O--,A++)P+=256*I[O]>>>0,I[O]=P%a>>>0,P=P/a>>>0;if(P!==0)throw new Error("Non-zero carry");w=A,v++}for(var C=E-w;C!==E&&I[C]===0;)C++;for(var D=c.repeat(y);C<E;++C)D+=t.charAt(I[C]);return D}function d(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var y=0;if(p[y]!==" "){for(var w=0,v=0;p[y]===c;)w++,y++;for(var b=(p.length-y)*h+1>>>0,E=new Uint8Array(b);p[y];){var I=r[p.charCodeAt(y)];if(I===255)return;for(var P=0,A=b-1;(I!==0||P<v)&&A!==-1;A--,P++)I+=a*E[A]>>>0,E[A]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");v=P,y++}if(p[y]!==" "){for(var O=b-v;O!==b&&E[O]===0;)O++;for(var C=new Uint8Array(w+(b-O)),D=w;O!==b;)C[D++]=E[O++];return C}}}function f(p){var y=d(p);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:d,decode:f}}var Wg=Kg,Gg=Wg;const Bu=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},Yg=t=>new TextEncoder().encode(t),Jg=t=>new TextDecoder().decode(t);let Zg=class{constructor(e,r,i){this.name=e,this.prefix=r,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Qg=class{constructor(e,r,i){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return ju(this,e)}},Xg=class{constructor(e){this.decoders=e}or(e){return ju(this,e)}decode(e){const r=e[0],i=this.decoders[r];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};const ju=(t,e)=>new Xg({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});let ey=class{constructor(e,r,i,s){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=s,this.encoder=new Zg(e,r,i),this.decoder=new Qg(e,r,s)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};const Ts=({name:t,prefix:e,encode:r,decode:i})=>new ey(t,e,r,i),Ri=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:s}=Gg(r,e);return Ts({prefix:t,name:e,encode:i,decode:n=>Bu(s(n))})},ty=(t,e,r,i)=>{const s={};for(let u=0;u<e.length;++u)s[e[u]]=u;let n=t.length;for(;t[n-1]==="=";)--n;const o=new Uint8Array(n*r/8|0);let a=0,c=0,h=0;for(let u=0;u<n;++u){const l=s[t[u]];if(l===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<r|l,a+=r,a>=8&&(a-=8,o[h++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},ry=(t,e,r)=>{const i=e[e.length-1]==="=",s=(1<<r)-1;let n="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>r;)o-=r,n+=e[s&a>>o];if(o&&(n+=e[s&a<<r-o]),i)for(;n.length*r&7;)n+="=";return n},De=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>Ts({prefix:e,name:t,encode(s){return ry(s,i,r)},decode(s){return ty(s,i,r,t)}}),iy=Ts({prefix:"\0",name:"identity",encode:t=>Jg(t),decode:t=>Yg(t)});var sy=Object.freeze({__proto__:null,identity:iy});const ny=De({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var oy=Object.freeze({__proto__:null,base2:ny});const ay=De({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var cy=Object.freeze({__proto__:null,base8:ay});const hy=Ri({prefix:"9",name:"base10",alphabet:"0123456789"});var uy=Object.freeze({__proto__:null,base10:hy});const ly=De({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),dy=De({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var py=Object.freeze({__proto__:null,base16:ly,base16upper:dy});const fy=De({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),gy=De({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),yy=De({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),my=De({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),wy=De({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),by=De({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),vy=De({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ey=De({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),_y=De({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Iy=Object.freeze({__proto__:null,base32:fy,base32upper:gy,base32pad:yy,base32padupper:my,base32hex:wy,base32hexupper:by,base32hexpad:vy,base32hexpadupper:Ey,base32z:_y});const $y=Ri({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Dy=Ri({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Sy=Object.freeze({__proto__:null,base36:$y,base36upper:Dy});const Oy=Ri({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Py=Ri({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ay=Object.freeze({__proto__:null,base58btc:Oy,base58flickr:Py});const xy=De({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
16+/",bitsPerChar:6}),Cy=De({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ty=De({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ry=De({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ny=Object.freeze({__proto__:null,base64:xy,base64pad:Cy,base64url:Ty,base64urlpad:Ry});const Uu=Array.from("ððªâð°ðððððððððððððâð»ð¥ð¾ð¿ðâ¤ðð¤£ððððððð
ððð¥ð¥°ðððð¢ð¤ðððªðâºðð¤ððððð¹ð¤¦ððââ¨ð¤·ð±ðð¸ððððððððð¤©ððð¤ðð¯ððð¶ðð¤â£ððððªðð¥ððð©ð¡ð¤ªðð¥³ð¥ð¤¤ððð³âððð´ðð¬ððð·ð»ðââ
ð¥ºððð¤ð¦âð£ððâ¹ððð âððºðð»ððððð¹ð£ð«ðððµð¤ðð´ð¤ð¼ð«â½ð¤âðð¤«ðð®ðð»ðð¶ðð²ð¿ð§¡ðâ¡ððââðð°ð¤¨ð¶ð¤ð¶ð°ðð¢ð¤ðð¨ð¨ð¤¬âððºð¤ððð±ðð¶ð¥´â¶â¡âðð¸â¬ð¨ðð¦ð·ðºâ ð
ððµðð¤²ð¤ ð¤§ððµð
ð§ð¾ððð¤ðð¤¯ð·âð§ð¯ððð¤ððâð´ð£ð¸ððð¥ð¤¢ð
ð¡ð©ðð¸ð»ð¤ð¤®ð¼ð¥µð©ððð¼ðð£ð¥"),By=Uu.reduce((t,e,r)=>(t[r]=e,t),[]),jy=Uu.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function Uy(t){return t.reduce((e,r)=>(e+=By[r],e),"")}function Fy(t){const e=[];for(const r of t){const i=jy[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const Ly=Ts({prefix:"ð",name:"base256emoji",encode:Uy,decode:Fy});var My=Object.freeze({__proto__:null,base256emoji:Ly}),qy=Fu,Ma=128,ky=127,zy=~ky,Hy=Math.pow(2,31);function Fu(t,e,r){e=e||[],r=r||0;for(var i=r;t>=Hy;)e[r++]=t&255|Ma,t/=128;for(;t&zy;)e[r++]=t&255|Ma,t>>>=7;return e[r]=t|0,Fu.bytes=r-i+1,e}var Vy=Vn,Ky=128,qa=127;function Vn(t,i){var r=0,i=i||0,s=0,n=i,o,a=t.length;do{if(n>=a)throw Vn.bytes=0,new RangeError("Could not decode varint");o=t[n++],r+=s<28?(o&qa)<<s:(o&qa)*Math.pow(2,s),s+=7}while(o>=Ky);return Vn.bytes=n-i,r}var Wy=Math.pow(2,7),Gy=Math.pow(2,14),Yy=Math.pow(2,21),Jy=Math.pow(2,28),Zy=Math.pow(2,35),Qy=Math.pow(2,42),Xy=Math.pow(2,49),em=Math.pow(2,56),tm=Math.pow(2,63),rm=function(t){return t<Wy?1:t<Gy?2:t<Yy?3:t<Jy?4:t<Zy?5:t<Qy?6:t<Xy?7:t<em?8:t<tm?9:10},im={encode:qy,decode:Vy,encodingLength:rm},Lu=im;const ka=(t,e,r=0)=>(Lu.encode(t,e,r),e),za=t=>Lu.encodingLength(t),Kn=(t,e)=>{const r=e.byteLength,i=za(t),s=i+za(r),n=new Uint8Array(s+r);return ka(t,n,0),ka(r,n,i),n.set(e,s),new sm(t,r,e,n)};let sm=class{constructor(e,r,i,s){this.code=e,this.size=r,this.digest=i,this.bytes=s}};const Mu=({name:t,code:e,encode:r})=>new nm(t,e,r);let nm=class{constructor(e,r,i){this.name=e,this.code=r,this.encode=i}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?Kn(this.code,r):r.then(i=>Kn(this.code,i))}else throw Error("Unknown type, must be binary type")}};const qu=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),om=Mu({name:"sha2-256",code:18,encode:qu("SHA-256")}),am=Mu({name:"sha2-512",code:19,encode:qu("SHA-512")});var cm=Object.freeze({__proto__:null,sha256:om,sha512:am});const ku=0,hm="identity",zu=Bu,um=t=>Kn(ku,zu(t)),lm={code:ku,name:hm,encode:zu,digest:um};var dm=Object.freeze({__proto__:null,identity:lm});new TextEncoder,new TextDecoder;const Ha={...sy,...oy,...cy,...uy,...py,...Iy,...Sy,...Ay,...Ny,...My};({...cm,...dm});function Hu(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const Va=Hu("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),cn=Hu("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=Ru(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Vu={utf8:Va,"utf-8":Va,hex:Ha.base16,latin1:cn,ascii:cn,binary:cn,...Ha};function Rs(t,e="utf8"){const r=Vu[e];
vendor: 8,554 bytes, line 16
16if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}function Zr(t,e="utf8"){const r=Vu[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Fo(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}function Ka(t){return nr(Rs(Zr(t,Cs),Cu))}function ws(t){return Rs(Zr(Bt(t),Cu),Cs)}function Ku(t){const e=Zr(Hg,La),r=zg+Rs(Nu([e,t]),La);return[qg,kg,r].join(Mg)}function pm(t){return Rs(t,Cs)}function fm(t){return Zr(t,Cs)}function gm(t){return Zr([ws(t.header),ws(t.payload)].join(ms),Tu)}function ym(t){return[ws(t.header),ws(t.payload),pm(t.signature)].join(ms)}function Wn(t){const e=t.split(ms),r=Ka(e[0]),i=Ka(e[1]),s=fm(e[2]),n=Zr(e.slice(0,2).join(ms),Tu);return{header:r,payload:i,signature:s,data:n}}function Wa(t=vu(Vg)){const e=xu.getPublicKey(t);return{secretKey:Nu([t,e]),publicKey:e}}async function mm(t,e,r,i,s=N.fromMiliseconds(Date.now())){const n={alg:Fg,typ:Lg},o=Ku(i.publicKey),a=s+r,c={iss:o,sub:t,aud:e,iat:s,exp:a},h=gm({header:n,payload:c}),u=xu.sign(h,i.secretKey.slice(0,32));return ym({header:n,payload:c,signature:u})}function Wu(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function yi(t,e){e||(e=t.reduce((s,n)=>s+n.length,0));const r=Wu(e);let i=0;for(const s of t)r.set(s,i),i+=s.length;return r}function wm(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var s=0;s<t.length;s++){var n=t.charAt(s),o=n.charCodeAt(0);if(r[o]!==255)throw new TypeError(n+" is ambiguous");r[o]=s}var a=t.length,c=t.charAt(0),h=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var y=0,w=0,v=0,b=p.length;v!==b&&p[v]===0;)v++,y++;for(var E=(b-v)*u+1>>>0,I=new Uint8Array(E);v!==b;){for(var P=p[v],A=0,O=E-1;(P!==0||A<w)&&O!==-1;O--,A++)P+=256*I[O]>>>0,I[O]=P%a>>>0,P=P/a>>>0;if(P!==0)throw new Error("Non-zero carry");w=A,v++}for(var C=E-w;C!==E&&I[C]===0;)C++;for(var D=c.repeat(y);C<E;++C)D+=t.charAt(I[C]);return D}function d(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var y=0;if(p[y]!==" "){for(var w=0,v=0;p[y]===c;)w++,y++;for(var b=(p.length-y)*h+1>>>0,E=new Uint8Array(b);p[y];){var I=r[p.charCodeAt(y)];if(I===255)return;for(var P=0,A=b-1;(I!==0||P<v)&&A!==-1;A--,P++)I+=a*E[A]>>>0,E[A]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");v=P,y++}if(p[y]!==" "){for(var O=b-v;O!==b&&E[O]===0;)O++;for(var C=new Uint8Array(w+(b-O)),D=w;O!==b;)C[D++]=E[O++];return C}}}function f(p){var y=d(p);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:d,decode:f}}var bm=wm,vm=bm;const Em=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},_m=t=>new TextEncoder().encode(t),Im=t=>new TextDecoder().decode(t);class $m{constructor(e,r,i){this.name=e,this.prefix=r,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class Dm{constructor(e,r,i){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Gu(this,e)}}class Sm{constructor(e){this.decoders=e}or(e){return Gu(this,e)}decode(e){const r=e[0],i=this.decoders[r];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Gu=(t,e)=>new Sm({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class Om{constructor(e,r,i,s){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=s,this.encoder=new $m(e,r,i),this.decoder=new Dm(e,r,s)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Ns=({name:t,prefix:e,encode:r,decode:i})=>new Om(t,e,r,i),Ni=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:s}=vm(r,e);return Ns({prefix:t,name:e,encode:i,decode:n=>Em(s(n))})},Pm=(t,e,r,i)=>{const s={};for(let u=0;u<e.length;++u)s[e[u]]=u;let n=t.length;for(;t[n-1]==="=";)--n;const o=new Uint8Array(n*r/8|0);let a=0,c=0,h=0;for(let u=0;u<n;++u){const l=s[t[u]];if(l===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<r|l,a+=r,a>=8&&(a-=8,o[h++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},Am=(t,e,r)=>{const i=e[e.length-1]==="=",s=(1<<r)-1;let n="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>r;)o-=r,n+=e[s&a>>o];if(o&&(n+=e[s&a<<r-o]),i)for(;n.length*r&7;)n+="=";return n},Se=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>Ns({prefix:e,name:t,encode(s){return Am(s,i,r)},decode(s){return Pm(s,i,r,t)}}),xm=Ns({prefix:"\0",name:"identity",encode:t=>Im(t),decode:t=>_m(t)}),Cm=Object.freeze(Object.defineProperty({__proto__:null,identity:xm},Symbol.toStringTag,{value:"Module"})),Tm=Se({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),Rm=Object.freeze(Object.defineProperty({__proto__:null,base2:Tm},Symbol.toStringTag,{value:"Module"})),Nm=Se({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),Bm=Object.freeze(Object.defineProperty({__proto__:null,base8:Nm},Symbol.toStringTag,{value:"Module"})),jm=Ni({prefix:"9",name:"base10",alphabet:"0123456789"}),Um=Object.freeze(Object.defineProperty({__proto__:null,base10:jm},Symbol.toStringTag,{value:"Module"})),Fm=Se({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Lm=Se({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),Mm=Object.freeze(Object.defineProperty({__proto__:null,base16:Fm,base16upper:Lm},Symbol.toStringTag,{value:"Module"})),qm=Se({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),km=Se({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),zm=Se({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Hm=Se({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Vm=Se({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Km=Se({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Wm=Se({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Gm=Se({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ym=Se({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),Jm=Object.freeze(Object.defineProperty({__proto__:null,base32:qm,base32hex:Vm,base32hexpad:Wm,base32hexpadupper:Gm,base32hexupper:Km,base32pad:zm,base32padupper:Hm,base32upper:km,base32z:Ym},Symbol.toStringTag,{value:"Module"})),Zm=Ni({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Qm=Ni({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),Xm=Object.freeze(Object.defineProperty({__proto__:null,base36:Zm,base36upper:Qm},Symbol.toStringTag,{value:"Module"})),ew=Ni({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),tw=Ni({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),rw=Object.freeze(Object.defineProperty({__proto__:null,base58btc:ew,base58flickr:tw},Symbol.toStringTag,{value:"Module"})),iw=Se({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
16+/",bitsPerChar:6}),sw=Se({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),nw=Se({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ow=Se({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),aw=Object.freeze(Object.defineProperty({__proto__:null,base64:iw,base64pad:sw,base64url:nw,base64urlpad:ow},Symbol.toStringTag,{value:"Module"})),Yu=Array.from("ððªâð°ðððððððððððððâð»ð¥ð¾ð¿ðâ¤ðð¤£ððððððð
ððð¥ð¥°ðððð¢ð¤ðððªðâºðð¤ððððð¹ð¤¦ððââ¨ð¤·ð±ðð¸ððððððððð¤©ððð¤ðð¯ððð¶ðð¤â£ððððªðð¥ððð©ð¡ð¤ªðð¥³ð¥ð¤¤ððð³âððð´ðð¬ððð·ð»ðââ
ð¥ºððð¤ð¦âð£ððâ¹ððð âððºðð»ððððð¹ð£ð«ðððµð¤ðð´ð¤ð¼ð«â½ð¤âðð¤«ðð®ðð»ðð¶ðð²ð¿ð§¡ðâ¡ððââðð°ð¤¨ð¶ð¤ð¶ð°ðð¢ð¤ðð¨ð¨ð¤¬âððºð¤ððð±ðð¶ð¥´â¶â¡âðð¸â¬ð¨ðð¦ð·ðºâ ð
ððµðð¤²ð¤ ð¤§ððµð
ð§ð¾ððð¤ðð¤¯ð·âð§ð¯ððð¤ððâð´ð£ð¸ððð¥ð¤¢ð
ð¡ð©ðð¸ð»ð¤ð¤®ð¼ð¥µð©ððð¼ðð£ð¥"),cw=Yu.reduce((t,e,r)=>(t[r]=e,t),[]),hw=Yu.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function uw(t){return t.reduce((e,r)=>(e+=cw[r],e),"")}function lw(t){const e=[];for(const r of t){const i=hw[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const dw=Ns({prefix:"ð",name:"base256emoji",encode:uw,decode:lw}),pw=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:dw},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const Ga={...Cm,...Rm,...Bm,...Um,...Mm,...Jm,...Xm,...rw,...aw,...pw};function Ju(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const Ya=Ju("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),hn=Ju("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=Wu(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Zu={utf8:Ya,"utf-8":Ya,hex:Ga.base16,latin1:hn,ascii:hn,binary:hn,...Ga};function tt(t,e="utf8"){const r=Zu[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t,"utf8"):r.decoder.decode(`${r.prefix}${t}`)}function Me(t,e="utf8"){const r=Zu[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}const fw={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}};var gw={};const yw=":";function Mr(t){const[e,r]=t.split(yw);return{namespace:e,reference:r}}function Ja(t,e=[]){const r=[];return Object.keys(t).forEach(i=>
16{if(e.length&&!e.includes(i))return;const s=t[i];r.push(...s.accounts)}),r}function Qu(t,e){return t.includes(":")?[t]:e.chains||[]}var mw=Object.defineProperty,ww=Object.defineProperties,bw=Object.getOwnPropertyDescriptors,Za=Object.getOwnPropertySymbols,vw=Object.prototype.hasOwnProperty,Ew=Object.prototype.propertyIsEnumerable,Qa=(t,e,r)=>e in t?mw(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Xa=(t,e)=>{for(var r in e||(e={}))vw.call(e,r)&&Qa(t,r,e[r]);if(Za)for(var r of Za(e))Ew.call(e,r)&&Qa(t,r,e[r]);return t},_w=(t,e)=>ww(t,bw(e));const Iw="ReactNative",We={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},$w="js";function bs(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function Vt(){return!Ti()&&!!Ao()&&navigator.product===Iw}function Dw(){return Vt()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="android"}function Sw(){return Vt()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="ios"}function Bi(){return!bs()&&!!Ao()&&!!Ti()}function ji(){return Vt()?We.reactNative:bs()?We.node:Bi()?We.browser:We.unknown}function ec(){var t;try{return Vt()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(t=global.Application)==null?void 0:t.applicationId:void 0}catch{return}}function Ow(t,e){const r=new URLSearchParams(t);for(const i of Object.keys(e).sort())if(e.hasOwnProperty(i)){const s=e[i];s!==void 0&&r.set(i,s)}return r.toString()}function Pw(t){var e,r;const i=Xu();try{return t!=null&&t.url&&i.url&&t.url!==i.url&&(console.warn(`The configured WalletConnect 'metadata.url':${t.url} differs from the actual page url:${i.url}. This is probably unintended and can lead to issues.`),t.url=i.url),(e=t==null?void 0:t.icons)!=null&&e.length&&t.icons.length>0&&(t.icons=t.icons.filter(s=>s!=="")),_w(Xa(Xa({},i),t),{url:(t==null?void 0:t.url)||i.url,name:(t==null?void 0:t.name)||i.name,description:(t==null?void 0:t.description)||i.description,icons:(r=t==null?void 0:t.icons)!=null&&r.length&&t.icons.length>0?t.icons:i.icons})}catch(s){return console.warn("Error populating app metadata",s),t||i}}function Xu(){return nu()||{name:"",description:"",url:"",icons:[""]}}function Aw(){if(ji()===We.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){const{OS:r,Version:i}=global.Platform;return[r,i].join("-")}const t=zd();if(t===null)return"unknown";const e=t.os?t.os.replace(" ","").toLowerCase():"unknown";return t.type==="browser"?[e,t.name,t.version].join("-"):[e,t.version].join("-")}function xw(){var t;const e=ji();return e===We.browser?[e,((t=su())==null?void 0:t.host)||"unknown"].join(":"):e}function el(t,e,r){const i=Aw(),s=xw();return[[t,e].join("-"),[$w,r].join("-"),i,s].join("/")}function Cw({protocol:t,version:e,relayUrl:r,sdkVersion:i,auth:s,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:c}){const h=r.split("?"),u=el(t,e,i),l={auth:s,ua:u,projectId:n,useOnCloseEvent:o||void 0,packageName:c||void 0,bundleId:a||void 0},d=Ow(h[1]||"",l);return h[0]+"?"+d}function tr(t,e){return t.filter(r=>e.includes(r)).length===t.length}function Gn(t){return Object.fromEntries(t.entries())}function Yn(t){return new Map(Object.entries(t))}function Jt(t=N.FIVE_MINUTES,e){const r=N.toMiliseconds(t||N.FIVE_MINUTES);let i,s,n,o;return{resolve:a=>{n&&i&&(clearTimeout(n),i(a),o=Promise.resolve(a))},reject:a=>{n&&s&&(clearTimeout(n),s(a))},done:()=>new Promise((a,c)=>{if(o)return a(o);n=setTimeout(()=>{const h=new Error(e);o=Promise.reject(h),c(h)},r),i=a,s=c})}}function kt(t,e,r){return new Promise(async(i,s)=>{const n=setTimeout(()=>s(new Error(r)),e);try{const o=await t;i(o)}catch(o){s(o)}clearTimeout(n)})}function tl(t,e){if(typeof e=="string"&&e.startsWith(`${t}:`))return e;if(t.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(t.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${t}`)}function Tw(t){return tl("topic",t)}function Rw(t){return tl("id",t)}function rl(t){const[e,r]=t.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof r=="string")i.topic=r;else if(e==="id"&&Number.isInteger(Number(r)))i.id=Number(r);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${r}`);return i}function de(t,e){return N.fromMiliseconds(Date.now()+N.toMiliseconds(t))}function Mt(t){return Date.now()>=N.toMiliseconds(t)}function X(t,e){return`${t}${e?`:${e}`:""}`}function hs(t=[],e=[]){return[...new Set([...t,...e])]}async function Nw({id:t,topic:e,wcDeepLink:r}){var i;try{if(!r)return;const s=typeof r=="string"?JSON.parse(r):r,n=s==null?void 0:s.href;
vendor: 10,750 bytes, lines 16-19
16if(typeof n!="string")return;const o=Bw(n,t,e),a=ji();if(a===We.browser){if(!((i=Ti())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}jw(o)}else a===We.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(s){console.error(s)}}function Bw(t,e,r){const i=`requestId=${e}&sessionTopic=${r}`;t.endsWith("/")&&(t=t.slice(0,-1));let s=`${t}`;if(t.startsWith("https://t.me")){const n=t.includes("?")?"&startapp=":"?startapp=";s=`${s}${n}${Mw(i,!0)}`}else s=`${s}/wc?${i}`;return s}function jw(t){let e="_self";Lw()?e="_top":(Fw()||t.startsWith("https://")||t.startsWith("http://"))&&(e="_blank"),window.open(t,e,"noreferrer noopener")}async function Uw(t,e){let r="";try{if(Bi()&&(r=localStorage.getItem(e),r))return r;r=await t.getItem(e)}catch(i){console.error(i)}return r}function tc(t,e){if(!t.includes(e))return null;const r=t.split(/([&,?,=])/),i=r.indexOf(e);return r[i+2]}function rc(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function Lo(){return typeof process<"u"&&gw.IS_VITEST==="true"}function Fw(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function Lw(){try{return window.self!==window.top}catch{return!1}}function Mw(t,e=!1){const r=Buffer.from(t).toString("base64");return e?r.replace(/[=]/g,""):r}function il(t){return Buffer.from(t,"base64").toString("utf-8")}function qw(t){return new Promise(e=>setTimeout(e,t))}function Ii(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function kw(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Ui(t,...e){if(!kw(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Mo(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ii(t.outputLen),Ii(t.blockLen)}function qr(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function sl(t,e){Ui(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const Ji=BigInt(2**32-1),ic=BigInt(32);function zw(t,e=!1){return e?{h:Number(t&Ji),l:Number(t>>ic&Ji)}:{h:Number(t>>ic&Ji)|0,l:Number(t&Ji)|0}}function Hw(t,e=!1){let r=new Uint32Array(t.length),i=new Uint32Array(t.length);for(let s=0;s<t.length;s++){const{h:n,l:o}=zw(t[s],e);[r[s],i[s]]=[n,o]}return[r,i]}const Vw=(t,e,r)=>t<<r|e>>>32-r,Kw=(t,e,r)=>e<<r|t>>>32-r,Ww=(t,e,r)=>e<<r-32|t>>>64-r,Gw=(t,e,r)=>t<<r-32|e>>>64-r,wr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Yw(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function un(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function ft(t,e){return t<<32-e|t>>>e}const sc=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Jw(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function nc(t){for(let e=0;e<t.length;e++)t[e]=Jw(t[e])}function Zw(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function kr(t){return typeof t=="string"&&(t=Zw(t)),Ui(t),t}function Qw(...t){let e=0;for(let i=0;i<t.length;i++){const s=t[i];Ui(s),e+=s.length}const r=new Uint8Array(e);for(let i=0,s=0;i<t.length;i++){const n=t[i];r.set(n,s),s+=n.length}return r}let qo=class{clone(){return this._cloneInto()}};function nl(t){const e=i=>t().update(kr(i)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Qr(t=32){if(wr&&typeof wr.getRandomValues=="function")return wr.getRandomValues(new Uint8Array(t));if(wr&&typeof wr.randomBytes=="function")return wr.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const ol=[],al=[],cl=[],Xw=BigInt(0),ai=BigInt(1),eb=BigInt(2),tb=BigInt(7),rb=BigInt(256),ib=BigInt(113);for(let t=0,e=ai,r=1,i=0;t<24;t++){[r,i]=[i,(2*r+3*i)%5],ol.push(2*(5*i+r)),al.push((t+1)*(t+2)/2%64);let s=Xw;for(let n=0;n<7;n++)e=(e<<ai^(e>>tb)*ib)%rb,e&eb&&(s^=ai<<(ai<<BigInt(n))-ai);cl.push(s)}const[sb,nb]=Hw(cl,!0),oc=(t,e,r)=>r>32?Ww(t,e,r):Vw(t,e,r),ac=(t,e,r)=>r>32?Gw(t,e,r):Kw(t,e,r);function ob(t,e=24){const r=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)r[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,h=r[c],u=r[c+1],l=oc(h,u,1)^r[a],d=ac(h,u,1)^r[a+1];for(let f=0;f<50;f+=10)t[o+f]^=l,t[o+f+1]^=d}let s=t[2],n=t[3];for(let o=0;o<24;o++){const a=al[o],c=oc(s,n,a),h=ac(s,n,a),u=ol[o];s=t[u],n=t[u+1],t[u]=c,t[u+1]=h}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)r[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~r[(a+2)%10]&r[(a+4)%10]}t[0]^=sb[i],t[1]^=nb[i]}r.fill(0)}let ab=class hl extends qo{constructor(e,r,i,s=!1,n=24){if(super(),this.blockLen=e,this.suffix=r,this.outputLen=i,this.enableXOF=s,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Ii(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Yw(this.state)}keccak(){sc||nc(this.state32),ob(this.state32,this.rounds),sc||nc(this.state32),this.posOut=0,this.pos=0}update(e){qr(this);const{blockLen:r,state:i}=this;e=kr(e);const s=e.length;for(let n=0;n<s;){const o=Math.min(r-this.pos,s-n);for(let a=0;a<o;a++)i[this.pos++]^=e[n++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:r,pos:i,blockLen:s}=this;e[i]^=r,r&128&&i===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){qr(this,!1),Ui(e),this.finish();const r=this.state,{blockLen:i}=this;for(let s=0,n=e.length;s<n;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,n-s);e.set(r.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Ii(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(sl(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:r,suffix:i,outputLen:s,rounds:n,enableXOF:o}=this;return e||(e=new hl(r,i,s,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=i,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}};const cb=(t,e,r)=>nl(()=>new ab(e,t,r)),hb=cb(1,136,256/8),ub="https://rpc.walletconnect.org/v1";function ul(t){const e=`�Ethereum Signed Message: 17${t.length}`,r=new TextEncoder().encode(e+t);return"0x"+Buffer.from(hb(r)).toString("hex")}async function lb(t,e,r,i,s,n){switch(r.t){case"eip191":return await db(t,e,r.s);case"eip1271":return await pb(t,e,r.s,i,s,n);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r.t}`)}}async function db(t,e,r){return(await Ef({hash:ul(e),signature:r})).toLowerCase()===t.toLowerCase()}async function pb(t,e,r,i,s,n){const o=Mr(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{const a="0x1626ba7e",c="0000000000000000000000000000000000000000000000000000000000000040",h="0000000000000000000000000000000000000000000000000000000000000041",u=r.substring(2),l=ul(e).substring(2),d=a+l+c+h+u,f=await fetch(`${n||ub}/?chainId=${i}&projectId=${s}`,{method:"POST",body:JSON.stringify({id:fb(),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:d},"latest"]})}),{result:p}=await f.json();return p?p.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function fb(){return Date.now()+Math.floor(Math.random()*1e3)}function gb(t){const e=atob(t),r=new Uint8Array(e.length);for(let o=0;o<e.length;o++)r[o]=e.charCodeAt(o);const i=r[0];if(i===0)throw new Error("No signatures found");const s=1+i*64;if(r.length<s)throw new Error("Transaction data too short for claimed signature count");if(r.length<100)throw new Error("Transaction too short");const n=Buffer.from(t,"base64").slice(1,65);return $f.encode(n)}var yb=Object.defineProperty,mb=Object.defineProperties,wb=Object.getOwnPropertyDescriptors,cc=Object.getOwnPropertySymbols,bb=Object.prototype.hasOwnProperty,vb=Object.prototype.propertyIsEnumerable,hc=(t,e,r)=>e in t?yb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Eb=(t,e)=>{for(var r in e||(e={}))bb.call(e,r)&&hc(t,r,e[r]);if(cc)for(var r of cc(e))vb.call(e,r)&&hc(t,r,e[r]);return t},_b=(t,e)=>mb(t,wb(e));const Ib="did:pkh:",ko=t=>t==null?void 0:t.split(":"),$b=t=>{const e=t&&ko(t);if(e)return t.includes(Ib)?e[3]:e[1]},Jn=t=>{const e=t&&ko(t);if(e)return e[2]+":"+e[3]},vs=t=>{const e=t&&ko(t);if(e)return e.pop()};async function uc(t){const{cacao:e,projectId:r}=t,{s:i,p:s}=e,n=ll(s,s.iss),o=vs(s.iss);return await lb(o,n,i,Jn(s.iss),r)}const ll=(t,e)=>{const r=`${t.domain} wants you to sign in with your Ethereum account:`,i=vs(e);if(!t.aud&&!t.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let s=t.statement||void 0;const n=`URI: ${t.aud||t.uri}`,o=`Version: ${t.version}`,a=`Chain ID: ${$b(e)}`,c=`Nonce: ${t.nonce}`,h=`Issued At: ${t.iat}`,u=t.exp?`Expiration Time: ${t.exp}`:void 0,l=t.nbf?`Not Before: ${t.nbf}`:void 0,d=t.requestId?`Request ID: ${t.requestId}`:void 0,f=t.resources?`Resources:${t.resources.map(y=>` 18- ${y}`).join("")}`:void 0,p=us(t.resources);if(p){const y=$i(p);s=Rb(s,y)}return[r,i,"",s,"",n,o,a,c,h,u,l,d,f].filter(y=>y!=null).join(` 19`)};function Db(t){return Buffer.from(JSON.stringify(t)).toString("base64")}function Sb(t){return JSON.parse(Buffer.from(t,"base64").toString("utf-8"))}function or(t){if(!t)throw new Error("No recap provided, value is undefined");if(!t.att)throw new Error("No `att` property found");const e=Object.keys(t.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(r=>{const i=t.att[r];if(Array.isArray(i))throw new Error(`Resource must be an object: ${r}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${r}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${r}`);
19Object.keys(i).forEach(s=>{const n=i[s];if(!Array.isArray(n))throw new Error(`Ability limits ${s} must be an array of objects, found: ${n}`);if(!n.length)throw new Error(`Value of ${s} is empty array, must be an array with objects`);n.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${s}) must be an array of objects, found: ${o}`)})})})}function Ob(t,e,r,i={}){return r==null||r.sort((s,n)=>s.localeCompare(n)),{att:{[t]:Pb(e,r,i)}}}function Pb(t,e,r={}){e=e==null?void 0:e.sort((s,n)=>s.localeCompare(n));const i=e.map(s=>({[`${t}/${s}`]:[r]}));return Object.assign({},...i)}function dl(t){return or(t),`urn:recap:${Db(t).replace(/=/g,"")}`}function $i(t){const e=Sb(t.replace("urn:recap:",""));return or(e),e}function Ab(t,e,r){const i=Ob(t,e,r);return dl(i)}function xb(t){return t&&t.includes("urn:recap:")}function Cb(t,e){const r=$i(t),i=$i(e),s=Tb(r,i);return dl(s)}function Tb(t,e){or(t),or(e);const r=Object.keys(t.att).concat(Object.keys(e.att)).sort((s,n)=>s.localeCompare(n)),i={att:{}};return r.forEach(s=>{var n,o;Object.keys(((n=t.att)==null?void 0:n[s])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[s])||{})).sort((a,c)=>a.localeCompare(c)).forEach(a=>{var c,h;i.att[s]=_b(Eb({},i.att[s]),{[a]:((c=t.att[s])==null?void 0:c[a])||((h=e.att[s])==null?void 0:h[a])})})}),i}function Rb(t="",e){or(e);const r="I further authorize the stated URI to perform the following actions on my behalf: ";if(t.includes(r))return t;const i=[];let s=0;Object.keys(e.att).forEach(a=>{const c=Object.keys(e.att[a]).map(l=>({ability:l.split("/")[0],action:l.split("/")[1]}));c.sort((l,d)=>l.action.localeCompare(d.action));const h={};c.forEach(l=>{h[l.ability]||(h[l.ability]=[]),h[l.ability].push(l.action)});const u=Object.keys(h).map(l=>(s++,`(${s}) '${l}': '${h[l].join("', '")}' for '${a}'.`));i.push(u.join(", ").replace(".,","."))});const n=i.join(" "),o=`${r}${n}`;return`${t?t+" ":""}${o}`}function lc(t){var e;const r=$i(t);or(r);const i=(e=r.att)==null?void 0:e.eip155;return i?Object.keys(i).map(s=>s.split("/")[1]):[]}function dc(t){const e=$i(t);or(e);const r=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(s=>{var n;(n=s==null?void 0:s[0])!=null&&n.chains&&r.push(s[0].chains)})}),[...new Set(r.flat())]}function us(t){if(!t)return;const e=t==null?void 0:t[t.length-1];return xb(e)?e:void 0}function ln(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function pl(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Ke(t,...e){if(!pl(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function pc(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Nb(t,e){Ke(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function fc(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}const Ht=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),Bb=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),jb=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!jb)throw new Error("Non little-endian hardware is not supported");function Ub(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Zn(t){if(typeof t=="string")t=Ub(t);else if(pl(t))t=Qn(t);else throw new Error("Uint8Array expected, got "+typeof t);return t}function Fb(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function Lb(t,e){if(t.length!==e.length)return!1;let r=0;for(let i=0;i<t.length;i++)r|=t[i]^e[i];return r===0}const Mb=(t,e)=>{function r(i,...s){if(Ke(i),t.nonceLength!==void 0){const h=s[0];if(!h)throw new Error("nonce / iv required");t.varSizeNonce?Ke(h):Ke(h,t.nonceLength)}const n=t.tagLength;n&&s[1]!==void 0&&Ke(s[1]);const o=e(i,...s),a=(h,u)=>{if(u!==void 0){if(h!==2)throw new Error("cipher output not supported");Ke(u)}};let c=!1;
vendor: 24,115 bytes, line 19
19return{encrypt(h,u){if(c)throw new Error("cannot encrypt() twice with same key + nonce");return c=!0,Ke(h),a(o.encrypt.length,u),o.encrypt(h,u)},decrypt(h,u){if(Ke(h),n&&h.length<n)throw new Error("invalid ciphertext length: smaller than tagLength="+n);return a(o.decrypt.length,u),o.decrypt(h,u)}}}return Object.assign(r,t),r};function gc(t,e,r=!0){if(e===void 0)return new Uint8Array(t);if(e.length!==t)throw new Error("invalid output length, expected "+t+", got: "+e.length);if(r&&!qb(e))throw new Error("invalid output, must be aligned");return e}function yc(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);const s=BigInt(32),n=BigInt(4294967295),o=Number(r>>s&n),a=Number(r&n);t.setUint32(e+4,o,i),t.setUint32(e+0,a,i)}function qb(t){return t.byteOffset%4===0}function Qn(t){return Uint8Array.from(t)}function zr(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const fl=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),kb=fl("expand 16-byte k"),zb=fl("expand 32-byte k"),Hb=Ht(kb),Vb=Ht(zb);function J(t,e){return t<<e|t>>>32-e}function Xn(t){return t.byteOffset%4===0}const Zi=64,Kb=16,gl=2**32-1,mc=new Uint32Array;function Wb(t,e,r,i,s,n,o,a){const c=s.length,h=new Uint8Array(Zi),u=Ht(h),l=Xn(s)&&Xn(n),d=l?Ht(s):mc,f=l?Ht(n):mc;for(let p=0;p<c;o++){if(t(e,r,i,u,o,a),o>=gl)throw new Error("arx: counter overflow");const y=Math.min(Zi,c-p);if(l&&y===Zi){const w=p/4;if(p%4!==0)throw new Error("arx: invalid block position");for(let v=0,b;v<Kb;v++)b=w+v,f[b]=d[b]^u[v];p+=Zi;continue}for(let w=0,v;w<y;w++)v=p+w,n[v]=s[v]^h[w];p+=y}}function Gb(t,e){const{allowShortKeys:r,extendNonceFn:i,counterLength:s,counterRight:n,rounds:o}=Fb({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return ln(s),ln(o),fc(n),fc(r),(a,c,h,u,l=0)=>{Ke(a),Ke(c),Ke(h);const d=h.length;if(u===void 0&&(u=new Uint8Array(d)),Ke(u),ln(l),l<0||l>=gl)throw new Error("arx: counter overflow");if(u.length<d)throw new Error(`arx: output (${u.length}) is shorter than data (${d})`);const f=[];let p=a.length,y,w;if(p===32)f.push(y=Qn(a)),w=Vb;else if(p===16&&r)y=new Uint8Array(32),y.set(a),y.set(a,16),w=Hb,f.push(y);else throw new Error(`arx: invalid 32-byte key, got length=${p}`);Xn(c)||f.push(c=Qn(c));const v=Ht(y);if(i){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");i(w,v,Ht(c.subarray(0,16)),v),c=c.subarray(16)}const b=16-s;if(b!==c.length)throw new Error(`arx: nonce must be ${b} or 16 bytes`);if(b!==12){const I=new Uint8Array(12);I.set(c,n?0:12-c.length),c=I,f.push(c)}const E=Ht(c);return Wb(t,w,v,E,h,u,l,o),zr(...f),u}}const _e=(t,e)=>t[e++]&255|(t[e++]&255)<<8;class Yb{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,e=Zn(e),Ke(e,32);const r=_e(e,0),i=_e(e,2),s=_e(e,4),n=_e(e,6),o=_e(e,8),a=_e(e,10),c=_e(e,12),h=_e(e,14);this.r[0]=r&8191,this.r[1]=(r>>>13|i<<3)&8191,this.r[2]=(i>>>10|s<<6)&7939,this.r[3]=(s>>>7|n<<9)&8191,this.r[4]=(n>>>4|o<<12)&255,this.r[5]=o>>>1&8190,this.r[6]=(o>>>14|a<<2)&8191,this.r[7]=(a>>>11|c<<5)&8065,this.r[8]=(c>>>8|h<<8)&8191,this.r[9]=h>>>5&127;for(let u=0;u<8;u++)this.pad[u]=_e(e,16+2*u)}process(e,r,i=!1){const s=i?0:2048,{h:n,r:o}=this,a=o[0],c=o[1],h=o[2],u=o[3],l=o[4],d=o[5],f=o[6],p=o[7],y=o[8],w=o[9],v=_e(e,r+0),b=_e(e,r+2),E=_e(e,r+4),I=_e(e,r+6),P=_e(e,r+8),A=_e(e,r+10),O=_e(e,r+12),C=_e(e,r+14);let D=n[0]+(v&8191),q=n[1]+((v>>>13|b<<3)&8191),U=n[2]+((b>>>10|E<<6)&8191),j=n[3]+((E>>>7|I<<9)&8191),k=n[4]+((I>>>4|P<<12)&8191),T=n[5]+(P>>>1&8191),g=n[6]+((P>>>14|A<<2)&8191),m=n[7]+((A>>>11|O<<5)&8191),_=n[8]+((O>>>8|C<<8)&8191),S=n[9]+(C>>>5|s),$=0,x=$+D*a+q*(5*w)+U*(5*y)+j*(5*p)+k*(5*f);$=x>>>13,x&=8191,x+=T*(5*d)+g*(5*l)+m*(5*u)+_*(5*h)+S*(5*c),$+=x>>>13,x&=8191;let F=$+D*c+q*a+U*(5*w)+j*(5*y)+k*(5*p);$=F>>>13,F&=8191,F+=T*(5*f)+g*(5*d)+m*(5*l)+_*(5*u)+S*(5*h),$+=F>>>13,F&=8191;let M=$+D*h+q*c+U*a+j*(5*w)+k*(5*y);$=M>>>13,M&=8191,M+=T*(5*p)+g*(5*f)+m*(5*d)+_*(5*l)+S*(5*u),$+=M>>>13,M&=8191;let z=$+D*u+q*h+U*c+j*a+k*(5*w);$=z>>>13,z&=8191,z+=T*(5*y)+g*(5*p)+m*(5*f)+_*(5*d)+S*(5*l),$+=z>>>13,z&=8191;let L=$+D*l+q*u+U*h+j*c+k*a;$=L>>>13,L&=8191,L+=T*(5*w)+g*(5*y)+m*(5*p)+_*(5*f)+S*(5*d),$+=L>>>13,L&=8191;let H=$+D*d+q*l+U*u+j*h+k*c;$=H>>>13,H&=8191,H+=T*a+g*(5*w)+m*(5*y)+_*(5*p)+S*(5*f),$+=H>>>13,H&=8191;let G=$+D*f+q*d+U*l+j*u+k*h;$=G>>>13,G&=8191,G+=T*c+g*a+m*(5*w)+_*(5*y)+S*(5*p),$+=G>>>13,G&=8191;let se=$+D*p+q*f+U*d+j*l+k*u;$=se>>>13,se&=8191,se+=T*h+g*c+m*a+_*(5*w)+S*(5*y),$+=se>>>13,se&=8191;let ee=$+D*y+q*p+U*f+j*d+k*l;$=ee>>>13,ee&=8191,ee+=T*u+g*h+m*c+_*a+S*(5*w),$+=ee>>>13,ee&=8191;let Y=$+D*w+q*y+U*p+j*f+k*d;$=Y>>>13,Y&=8191,Y+=T*l+g*u+m*h+_*c+S*a,$+=Y>>>13,Y&=8191,$=($<<2)+$|0,$=$+x|0,x=$&8191,$=$>>>13,F+=$,n[0]=x,n[1]=F,n[2]=M,n[3]=z,n[4]=L,n[5]=H,n[6]=G,n[7]=se,n[8]=ee,n[9]=Y}finalize(){const{h:e,pad:r}=this,i=new Uint16Array(10);let s=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=s,s=e[a]>>>13,e[a]&=8191;e[0]+=s*5,s=e[0]>>>13,e[0]&=8191,e[1]+=s,s=e[1]>>>13,e[1]&=8191,e[2]+=s,i[0]=e[0]+5,s=i[0]>>>13,i[0]&=8191;for(let a=1;a<10;a++)i[a]=e[a]+s,s=i[a]>>>13,i[a]&=8191;i[9]-=8192;let n=(s^1)-1;for(let a=0;a<10;a++)i[a]&=n;n=~n;for(let a=0;a<10;a++)e[a]=e[a]&n|i[a];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let o=e[0]+r[0];e[0]=o&65535;for(let a=1;a<8;a++)o=(e[a]+r[a]|0)+(o>>>16)|0,e[a]=o&65535;zr(i)}update(e){pc(this);const{buffer:r,blockLen:i}=this;e=Zn(e);const s=e.length;for(let n=0;n<s;){const o=Math.min(i-this.pos,s-n);if(o===i){for(;i<=s-n;n+=i)this.process(e,n);continue}r.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===i&&(this.process(r,0,!1),this.pos=0)}return this}destroy(){zr(this.h,this.r,this.buffer,this.pad)}digestInto(e){pc(this),Nb(e,this),this.finished=!0;const{buffer:r,h:i}=this;let{pos:s}=this;if(s){for(r[s++]=1;s<16;s++)r[s]=0;this.process(r,0,!0)}this.finalize();let n=0;for(let o=0;o<8;o++)e[n++]=i[o]>>>0,e[n++]=i[o]>>>8;return e}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const i=e.slice(0,r);return this.destroy(),i}}function Jb(t){const e=(i,s)=>t(s).update(Zn(i)).digest(),r=t(new Uint8Array(32));return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=i=>t(i),e}const Zb=Jb(t=>new Yb(t));function Qb(t,e,r,i,s,n=20){let o=t[0],a=t[1],c=t[2],h=t[3],u=e[0],l=e[1],d=e[2],f=e[3],p=e[4],y=e[5],w=e[6],v=e[7],b=s,E=r[0],I=r[1],P=r[2],A=o,O=a,C=c,D=h,q=u,U=l,j=d,k=f,T=p,g=y,m=w,_=v,S=b,$=E,x=I,F=P;for(let z=0;z<n;z+=2)A=A+q|0,S=J(S^A,16),T=T+S|0,q=J(q^T,12),A=A+q|0,S=J(S^A,8),T=T+S|0,q=J(q^T,7),O=O+U|0,$=J($^O,16),g=g+$|0,U=J(U^g,12),O=O+U|0,$=J($^O,8),g=g+$|0,U=J(U^g,7),C=C+j|0,x=J(x^C,16),m=m+x|0,j=J(j^m,12),C=C+j|0,x=J(x^C,8),m=m+x|0,j=J(j^m,7),D=D+k|0,F=J(F^D,16),_=_+F|0,k=J(k^_,12),D=D+k|0,F=J(F^D,8),_=_+F|0,k=J(k^_,7),A=A+U|0,F=J(F^A,16),m=m+F|0,U=J(U^m,12),A=A+U|0,F=J(F^A,8),m=m+F|0,U=J(U^m,7),O=O+j|0,S=J(S^O,16),_=_+S|0,j=J(j^_,12),O=O+j|0,S=J(S^O,8),_=_+S|0,j=J(j^_,7),C=C+k|0,$=J($^C,16),T=T+$|0,k=J(k^T,12),C=C+k|0,$=J($^C,8),T=T+$|0,k=J(k^T,7),D=D+q|0,x=J(x^D,16),g=g+x|0,q=J(q^g,12),D=D+q|0,x=J(x^D,8),g=g+x|0,q=J(q^g,7);let M=0;i[M++]=o+A|0,i[M++]=a+O|0,i[M++]=c+C|0,i[M++]=h+D|0,i[M++]=u+q|0,i[M++]=l+U|0,i[M++]=d+j|0,i[M++]=f+k|0,i[M++]=p+T|0,i[M++]=y+g|0,i[M++]=w+m|0,i[M++]=v+_|0,i[M++]=b+S|0,i[M++]=E+$|0,i[M++]=I+x|0,i[M++]=P+F|0}const Xb=Gb(Qb,{counterRight:!1,counterLength:4,allowShortKeys:!1}),ev=new Uint8Array(16),wc=(t,e)=>{t.update(e);const r=e.length%16;r&&t.update(ev.subarray(r))},tv=new Uint8Array(32);function bc(t,e,r,i,s){const n=t(e,r,tv),o=Zb.create(n);s&&wc(o,s),wc(o,i);const a=new Uint8Array(16),c=Bb(a);yc(c,0,BigInt(s?s.length:0),!0),yc(c,8,BigInt(i.length),!0),o.update(a);const h=o.digest();return zr(n,a),h}const rv=t=>(e,r,i)=>({encrypt(s,n){const o=s.length;n=gc(o+16,n,!1),n.set(s);const a=n.subarray(0,-16);t(e,r,a,a,1);const c=bc(t,e,r,a,i);return n.set(c,o),zr(c),n},decrypt(s,n){n=gc(s.length-16,n,!1);const o=s.subarray(0,-16),a=s.subarray(-16),c=bc(t,e,r,o,i);if(!Lb(a,c))throw new Error("invalid tag");return n.set(s.subarray(0,-16)),t(e,r,n,n,1),zr(c),n}}),yl=Mb({blockSize:64,nonceLength:12,tagLength:16},rv(Xb));let ml=class extends qo{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,Mo(e);const i=kr(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,n=new Uint8Array(s);n.set(i.length>s?e.create().update(i).digest():i);for(let o=0;o<n.length;o++)n[o]^=54;this.iHash.update(n),this.oHash=e.create();for(let o=0;o<n.length;o++)n[o]^=106;this.oHash.update(n),n.fill(0)}update(e){return qr(this),this.iHash.update(e),this}digestInto(e){qr(this),Ui(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:r,iHash:i,finished:s,destroyed:n,blockLen:o,outputLen:a}=this;return e=e,e.finished=s,e.destroyed=n,e.blockLen=o,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=i._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const Bs=(t,e,r)=>new ml(t,e).update(r).digest();Bs.create=(t,e)=>new ml(t,e);function iv(t,e,r){return Mo(t),r===void 0&&(r=new Uint8Array(t.outputLen)),Bs(t,kr(r),kr(e))}const dn=new Uint8Array([0]),vc=new Uint8Array;function sv(t,e,r,i=32){if(Mo(t),Ii(i),i>255*t.outputLen)throw new Error("Length should be <= 255*HashLen");const s=Math.ceil(i/t.outputLen);r===void 0&&(r=vc);const n=new Uint8Array(s*t.outputLen),o=Bs.create(t,e),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let h=0;h<s;h++)dn[0]=h+1,a.update(h===0?vc:c).update(r).update(dn).digestInto(c),n.set(c,t.outputLen*h),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),dn.fill(0),n.slice(0,i)}const nv=(t,e,r,i,s)=>sv(t,iv(t,e,r),i,s);function ov(t,e,r,i){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,i);const s=BigInt(32),n=BigInt(4294967295),o=Number(r>>s&n),a=Number(r&n),c=i?4:0,h=i?0:4;t.setUint32(e+c,o,i),t.setUint32(e+h,a,i)}function av(t,e,r){return t&e^~t&r}function cv(t,e,r){return t&e^t&r^e&r}let hv=class extends qo{constructor(e,r,i,s){super(),this.blockLen=e,this.outputLen=r,this.padOffset=i,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=un(this.buffer)}update(e){qr(this);const{view:r,buffer:i,blockLen:s}=this;e=kr(e);const n=e.length;for(let o=0;o<n;){const a=Math.min(s-this.pos,n-o);if(a===s){const c=un(e);for(;s<=n-o;o+=s)this.process(c,o);continue}i.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===s&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){qr(this),sl(e,this),this.finished=!0;const{buffer:r,view:i,blockLen:s,isLE:n}=this;let{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>s-o&&(this.process(i,0),o=0);for(let l=o;l<s;l++)r[l]=0;ov(i,s-8,BigInt(this.length*8),n),this.process(i,0);const a=un(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const h=c/4,u=this.get();if(h>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<h;l++)a.setUint32(4*l,u[l],n)}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const i=e.slice(0,r);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:r,buffer:i,length:s,finished:n,destroyed:o,pos:a}=this;return e.length=s,e.pos=a,e.finished=n,e.destroyed=o,s%r&&e.buffer.set(i),e}};const uv=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]),Ft=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Lt=new Uint32Array(64);class lv extends hv{constructor(){super(64,32,8,!1),this.A=Ft[0]|0,this.B=Ft[1]|0,this.C=Ft[2]|0,this.D=Ft[3]|0,this.E=Ft[4]|0,this.F=Ft[5]|0,this.G=Ft[6]|0,this.H=Ft[7]|0}get(){const{A:e,B:r,C:i,D:s,E:n,F:o,G:a,H:c}=this;return[e,r,i,s,n,o,a,c]}set(e,r,i,s,n,o,a,c){this.A=e|0,this.B=r|0,this.C=i|0,this.D=s|0,this.E=n|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,r){for(let l=0;l<16;l++,r+=4)Lt[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){const d=Lt[l-15],f=Lt[l-2],p=ft(d,7)^ft(d,18)^d>>>3,y=ft(f,17)^ft(f,19)^f>>>10;Lt[l]=y+Lt[l-7]+p+Lt[l-16]|0}let{A:i,B:s,C:n,D:o,E:a,F:c,G:h,H:u}=this;for(let l=0;l<64;l++){const d=ft(a,6)^ft(a,11)^ft(a,25),f=u+d+av(a,c,h)+uv[l]+Lt[l]|0,p=(ft(i,2)^ft(i,13)^ft(i,22))+cv(i,s,n)|0;u=h,h=c,c=a,a=o+f|0,o=n,n=s,s=i,i=f+p|0}i=i+this.A|0,s=s+this.B|0,n=n+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,h=h+this.G|0,u=u+this.H|0,this.set(i,s,n,o,a,c,h,u)}roundClean(){Lt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Fi=nl(()=>new lv);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const js=BigInt(0),Us=BigInt(1),dv=BigInt(2);function ar(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Li(t){if(!ar(t))throw new Error("Uint8Array expected")}function Hr(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const pv=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Vr(t){Li(t);let e="";for(let r=0;r<t.length;r++)e+=pv[t[r]];return e}function Fr(t){const e=t.toString(16);return e.length&1?"0"+e:e}function zo(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?js:BigInt("0x"+t)}const Ot={_0:48,_9:57,A:65,F:70,a:97,f:102};function Ec(t){if(t>=Ot._0&&t<=Ot._9)return t-Ot._0;if(t>=Ot.A&&t<=Ot.F)return t-(Ot.A-10);if(t>=Ot.a&&t<=Ot.f)return t-(Ot.a-10)}function Kr(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const i=new Uint8Array(r);for(let s=0,n=0;s<r;s++,n+=2){const o=Ec(t.charCodeAt(n)),a=Ec(t.charCodeAt(n+1));if(o===void 0||a===void 0){const c=t[n]+t[n+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+n)}i[s]=o*16+a}return i}function ir(t){return zo(Vr(t))}function Di(t){return Li(t),zo(Vr(Uint8Array.from(t).reverse()))}function Wr(t,e){return Kr(t.toString(16).padStart(e*2,"0"))}function Fs(t,e){return Wr(t,e).reverse()}function fv(t){return Kr(Fr(t))}function Ve(t,e,r){let i;if(typeof e=="string")try{i=Kr(e)}catch(n){throw new Error(t+" must be hex string or Uint8Array, cause: "+n)}else if(ar(e))i=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const s=i.length;if(typeof r=="number"&&s!==r)throw new Error(t+" of length "+r+" expected, got "+s);return i}function Si(...t){let e=0;for(let i=0;i<t.length;i++){const s=t[i];Li(s),e+=s.length}const r=new Uint8Array(e);for(let i=0,s=0;i<t.length;i++){const n=t[i];r.set(n,s),s+=n.length}return r}function gv(t,e){if(t.length!==e.length)return!1;let r=0;for(let i=0;i<t.length;i++)r|=t[i]^e[i];return r===0}function yv(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}const pn=t=>typeof t=="bigint"&&js<=t;function Ls(t,e,r){return pn(t)&&pn(e)&&pn(r)&&e<=t&&t<r}function Rt(t,e,r,i){if(!Ls(e,r,i))throw new Error("expected valid "+t+": "+r+" <= n < "+i+", got "+e)}function wl(t){let e;for(e=0;t>js;t>>=Us,e+=1);return e}function mv(t,e){return t>>BigInt(e)&Us}function wv(t,e,r){return t|(r?Us:js)<<BigInt(e)}const Ho=t=>(dv<<BigInt(t-1))-Us,fn=t=>new Uint8Array(t),_c=t=>Uint8Array.from(t);function bl(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let i=fn(t),s=fn(t),n=0;const o=()=>{i.fill(1),s.fill(0),n=0},a=(...u)=>r(s,i,...u),c=(u=fn())=>{s=a(_c([0]),u),i=a(),u.length!==0&&(s=a(_c([1]),u),i=a())},h=()=>{if(n++>=1e3)throw new Error("drbg: tried 1000 values");let u=0;const l=[];for(;u<e;){i=a();const d=i.slice();l.push(d),u+=i.length}return Si(...l)};return(u,l)=>{o(),c(u);let d;for(;!(d=l(h()));)c();return o(),d}}const bv={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||ar(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function Xr(t,e,r={}){const i=(s,n,o)=>{const a=bv[n];if(typeof a!="function")throw new Error("invalid validator function");const c=t[s];if(!(o&&c===void 0)&&!a(c,t))throw new Error("param "+String(s)+" is invalid. Expected "+n+", got "+c)};for(const[s,n]of Object.entries(e))i(s,n,!1);for(const[s,n]of Object.entries(r))i(s,n,!0);return t}const vv=()=>{throw new Error("not implemented")};function eo(t){const e=new WeakMap;return(r,...i)=>{const s=e.get(r);if(s!==void 0)return s;const n=t(r,...i);return e.set(r,n),n}}var Ev=Object.freeze({__proto__:null,isBytes:ar,abytes:Li,abool:Hr,bytesToHex:Vr,numberToHexUnpadded:Fr,hexToNumber:zo,hexToBytes:Kr,bytesToNumberBE:ir,bytesToNumberLE:Di,numberToBytesBE:Wr,numberToBytesLE:Fs,numberToVarBytesBE:fv,ensureBytes:Ve,concatBytes:Si,equalBytes:gv,utf8ToBytes:yv,inRange:Ls,aInRange:Rt,bitLen:wl,bitGet:mv,bitSet:wv,bitMask:Ho,createHmacDrbg:bl,validateObject:Xr,notImplemented:vv,memoized:eo});const ve=BigInt(0),he=BigInt(1),Qt=BigInt(2),_v=BigInt(3),to=BigInt(4),Ic=BigInt(5),$c=BigInt(8);function Le(t,e){const r=t%e;return r>=ve?r:e+r}function vl(t,e,r){if(e<ve)throw new Error("invalid exponent, negatives unsupported");if(r<=ve)throw new Error("invalid modulus");if(r===he)return ve;let i=he;for(;e>ve;)e&he&&(i=i*t%r),t=t*t%r,e>>=he;return i}function ht(t,e,r){let i=t;for(;e-- >ve;)i*=i,i%=r;return i}function ro(t,e){if(t===ve)throw new Error("invert: expected non-zero number");if(e<=ve)throw new Error("invert: expected positive modulus, got "+e);let r=Le(t,e),i=e,s=ve,n=he;for(;r!==ve;){const o=i/r,a=i%r,c=s-n*o;i=r,r=a,s=n,n=c}if(i!==he)throw new Error("invert: does not exist");return Le(s,e)}function Iv(t){const e=(t-he)/Qt;let r,i,s;for(r=t-he,i=0;r%Qt===ve;r/=Qt,i++);for(s=Qt;s<t&&vl(s,e,t)!==t-he;s++)if(s>1e3)throw new Error("Cannot find square root: likely non-prime P");if(i===1){const o=(t+he)/to;return function(a,c){const h=a.pow(c,o);if(!a.eql(a.sqr(h),c))throw new Error("Cannot find square root");return h}}const n=(r+he)/Qt;return function(o,a){if(o.pow(a,e)===o.neg(o.ONE))throw new Error("Cannot find square root");let c=i,h=o.pow(o.mul(o.ONE,s),r),u=o.pow(a,n),l=o.pow(a,r);for(;!o.eql(l,o.ONE);){if(o.eql(l,o.ZERO))return o.ZERO;let d=1;for(let p=o.sqr(l);d<c&&!o.eql(p,o.ONE);d++)p=o.sqr(p);const f=o.pow(h,he<<BigInt(c-d-1));h=o.sqr(f),u=o.mul(u,f),l=o.mul(l,h),c=d}return u}}function $v(t){if(t%to===_v){const e=(t+he)/to;return function(r,i){const s=r.pow(i,e);if(!r.eql(r.sqr(s),i))throw new Error("Cannot find square root");return s}}if(t%$c===Ic){const e=(t-Ic)/$c;return function(r,i){const s=r.mul(i,Qt),n=r.pow(s,e),o=r.mul(i,n),a=r.mul(r.mul(o,Qt),n),c=r.mul(o,r.sub(a,r.ONE));if(!r.eql(r.sqr(c),i))throw new Error("Cannot find square root");return c}}return Iv(t)}const Dv=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Sv(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=Dv.reduce((i,s)=>(i[s]="function",i),e);return Xr(t,r)}function Ov(t,e,r){if(r<ve)throw new Error("invalid exponent, negatives unsupported");if(r===ve)return t.ONE;if(r===he)return e;let i=t.ONE,s=e;for(;r>ve;)r&he&&(i=t.mul(i,s)),s=t.sqr(s),r>>=he;return i}function Pv(t,e){const r=new Array(e.length),i=e.reduce((n,o,a)=>t.is0(o)?n:(r[a]=n,t.mul(n,o)),t.ONE),s=t.inv(i);return e.reduceRight((n,o,a)=>t.is0(o)?n:(r[a]=t.mul(n,r[a]),t.mul(n,o)),s),r}function El(t,e){const r=e!==void 0?e:t.toString(2).length,i=Math.ceil(r/8);return{nBitLength:r,nByteLength:i}}function _l(t,e,r=!1,i={}){if(t<=ve)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:s,nByteLength:n}=El(t,e);if(n>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:t,isLE:r,BITS:s,BYTES:n,MASK:Ho(s),ZERO:ve,ONE:he,create:c=>Le(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return ve<=c&&c<t},is0:c=>c===ve,isOdd:c=>(c&he)===he,neg:c=>Le(-c,t),eql:(c,h)=>c===h,sqr:c=>Le(c*c,t),add:(c,h)=>Le(c+h,t),sub:(c,h)=>Le(c-h,t),mul:(c,h)=>Le(c*h,t),pow:(c,h)=>Ov(a,c,h),div:(c,h)=>Le(c*ro(h,t),t),sqrN:c=>c*c,addN:(c,h)=>c+h,subN:(c,h)=>c-h,mulN:(c,h)=>c*h,inv:c=>ro(c,t),sqrt:i.sqrt||(c=>(o||(o=$v(t)),o(a,c))),invertBatch:c=>Pv(a,c),cmov:(c,h,u)=>u?h:c,toBytes:c=>r?Fs(c,n):Wr(c,n),fromBytes:c=>{if(c.length!==n)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+c.length);return r?Di(c):ir(c)}});return Object.freeze(a)}function Il(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function $l(t){const e=Il(t);return e+Math.ceil(e/2)}function Av(t,e,r=!1){const i=t.length,s=Il(e),n=$l(e);if(i<16||i<n||i>1024)throw new Error("expected "+n+"-1024 bytes of input, got "+i);const o=r?Di(t):ir(t),a=Le(o,e-he)+he;return r?Fs(a,s):Wr(a,s)}const Dc=BigInt(0),Qi=BigInt(1);function gn(t,e){const r=e.negate();return t?r:e}function Dl(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function yn(t,e){Dl(t,e);const r=Math.ceil(e/t)+1,i=2**(t-1);return{windows:r,windowSize:i}}function xv(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((r,i)=>{if(!(r instanceof e))throw new Error("invalid point at index "+i)})}function Cv(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,i)=>{if(!e.isValid(r))throw new Error("invalid scalar at index "+i)})}const mn=new WeakMap,Sl=new WeakMap;function wn(t){return Sl.get(t)||1}function Tv(t,e){return{constTimeNegate:gn,hasPrecomputes(r){return wn(r)!==1},unsafeLadder(r,i,s=t.ZERO){let n=r;for(;i>Dc;)i&Qi&&(s=s.add(n)),n=n.double(),i>>=Qi;return s},precomputeWindow(r,i){const{windows:s,windowSize:n}=yn(i,e),o=[];let a=r,c=a;for(let h=0;h<s;h++){c=a,o.push(c);for(let u=1;u<n;u++)c=c.add(a),o.push(c);a=c.double()}return o},wNAF(r,i,s){const{windows:n,windowSize:o}=yn(r,e);let a=t.ZERO,c=t.BASE;const h=BigInt(2**r-1),u=2**r,l=BigInt(r);for(let d=0;d<n;d++){const f=d*o;let p=Number(s&h);s>>=l,p>o&&(p-=u,s+=Qi);const y=f,w=f+Math.abs(p)-1,v=d%2!==0,b=p<0;p===0?c=c.add(gn(v,i[y])):a=a.add(gn(b,i[w]))}return{p:a,f:c}},wNAFUnsafe(r,i,s,n=t.ZERO){const{windows:o,windowSize:a}=yn(r,e),c=BigInt(2**r-1),h=2**r,u=BigInt(r);for(let l=0;l<o;l++){const d=l*a;if(s===Dc)break;let f=Number(s&c);if(s>>=u,f>a&&(f-=h,s+=Qi),f===0)continue;let p=i[d+Math.abs(f)-1];f<0&&(p=p.negate()),n=n.add(p)}return n},getPrecomputes(r,i,s){let n=mn.get(i);
19return n||(n=this.precomputeWindow(i,r),r!==1&&mn.set(i,s(n))),n},wNAFCached(r,i,s){const n=wn(r);return this.wNAF(n,this.getPrecomputes(n,r,s),i)},wNAFCachedUnsafe(r,i,s,n){const o=wn(r);return o===1?this.unsafeLadder(r,i,n):this.wNAFUnsafe(o,this.getPrecomputes(o,r,s),i,n)},setWindowSize(r,i){Dl(i,e),Sl.set(r,i),mn.delete(r)}}}function Rv(t,e,r,i){if(xv(r,t),Cv(i,e),r.length!==i.length)throw new Error("arrays of points and scalars must have equal length");const s=t.ZERO,n=wl(BigInt(r.length)),o=n>12?n-3:n>4?n-2:n?2:1,a=(1<<o)-1,c=new Array(a+1).fill(s),h=Math.floor((e.BITS-1)/o)*o;let u=s;for(let l=h;l>=0;l-=o){c.fill(s);for(let f=0;f<i.length;f++){const p=i[f],y=Number(p>>BigInt(l)&BigInt(a));c[y]=c[y].add(r[f])}let d=s;for(let f=c.length-1,p=s;f>0;f--)p=p.add(c[f]),d=d.add(p);if(u=u.add(d),l!==0)for(let f=0;f<o;f++)u=u.double()}return u}function Ol(t){return Sv(t.Fp),Xr(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...El(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}BigInt(0),BigInt(1),BigInt(2),BigInt(8);const br=BigInt(0),bn=BigInt(1);function Nv(t){return Xr(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function Bv(t){const e=Nv(t),{P:r}=e,i=b=>Le(b,r),s=e.montgomeryBits,n=Math.ceil(s/8),o=e.nByteLength,a=e.adjustScalarBytes||(b=>b),c=e.powPminus2||(b=>vl(b,r-BigInt(2),r));function h(b,E,I){const P=i(b*(E-I));return E=i(E-P),I=i(I+P),[E,I]}const u=(e.a-BigInt(2))/BigInt(4);function l(b,E){Rt("u",b,br,r),Rt("scalar",E,br,r);const I=E,P=b;let A=bn,O=br,C=b,D=bn,q=br,U;for(let k=BigInt(s-1);k>=br;k--){const T=I>>k&bn;q^=T,U=h(q,A,C),A=U[0],C=U[1],U=h(q,O,D),O=U[0],D=U[1],q=T;const g=A+O,m=i(g*g),_=A-O,S=i(_*_),$=m-S,x=C+D,F=C-D,M=i(F*g),z=i(x*_),L=M+z,H=M-z;C=i(L*L),D=i(P*i(H*H)),A=i(m*S),O=i($*(m+i(u*$)))}U=h(q,A,C),A=U[0],C=U[1],U=h(q,O,D),O=U[0],D=U[1];const j=c(O);return i(A*j)}function d(b){return Fs(i(b),n)}function f(b){const E=Ve("u coordinate",b,n);return o===32&&(E[31]&=127),Di(E)}function p(b){const E=Ve("scalar",b),I=E.length;if(I!==n&&I!==o){let P=""+n+" or "+o;throw new Error("invalid scalar, expected "+P+" bytes, got "+I)}return Di(a(E))}function y(b,E){const I=f(E),P=p(b),A=l(I,P);if(A===br)throw new Error("invalid private or public key received");return d(A)}const w=d(e.Gu);function v(b){return y(b,w)}return{scalarMult:y,scalarMultBase:v,getSharedSecret:(b,E)=>y(b,E),getPublicKey:b=>v(b),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:w}}const io=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const jv=BigInt(1),Sc=BigInt(2),Uv=BigInt(3),Fv=BigInt(5);BigInt(8);function Lv(t){const e=BigInt(10),r=BigInt(20),i=BigInt(40),s=BigInt(80),n=io,o=t*t%n*t%n,a=ht(o,Sc,n)*o%n,c=ht(a,jv,n)*t%n,h=ht(c,Fv,n)*c%n,u=ht(h,e,n)*h%n,l=ht(u,r,n)*u%n,d=ht(l,i,n)*l%n,f=ht(d,s,n)*d%n,p=ht(f,s,n)*d%n,y=ht(p,e,n)*h%n;return{pow_p_5_8:ht(y,Sc,n)*t%n,b2:o}}function Mv(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const so=Bv({P:io,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{const e=io,{pow_p_5_8:r,b2:i}=Lv(t);return Le(ht(r,Uv,e)*i,e)},adjustScalarBytes:Mv,randomBytes:Qr});function Oc(t){t.lowS!==void 0&&Hr("lowS",t.lowS),t.prehash!==void 0&&Hr("prehash",t.prehash)}function qv(t){const e=Ol(t);Xr(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:r,Fp:i,a:s}=e;if(r){if(!i.eql(s,i.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:kv,hexToBytes:zv}=Ev;class Hv extends Error{constructor(e=""){super(e)}}const Ct={Err:Hv,_tlv:{encode:(t,e)=>{const{Err:r}=Ct;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");const i=e.length/2,s=Fr(i);if(s.length/2&128)throw new r("tlv.encode: long form length too big");const n=i>127?Fr(s.length/2|128):"";return Fr(t)+n+s+e},decode(t,e){const{Err:r}=Ct;let i=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[i++]!==t)throw new r("tlv.decode: wrong tlv");const s=e[i++],n=!!(s&128);let o=0;if(!n)o=s;else{const c=s&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");const h=e.subarray(i,i+c);
vendor: 6,573 bytes, line 19
19if(h.length!==c)throw new r("tlv.decode: length bytes not complete");if(h[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(const u of h)o=o<<8|u;if(i+=c,o<128)throw new r("tlv.decode(long): not minimal encoding")}const a=e.subarray(i,i+o);if(a.length!==o)throw new r("tlv.decode: wrong value length");return{v:a,l:e.subarray(i+o)}}},_int:{encode(t){const{Err:e}=Ct;if(t<Tt)throw new e("integer: negative integers are not allowed");let r=Fr(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){const{Err:e}=Ct;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return kv(t)}},toSig(t){const{Err:e,_int:r,_tlv:i}=Ct,s=typeof t=="string"?zv(t):t;Li(s);const{v:n,l:o}=i.decode(48,s);if(o.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:c}=i.decode(2,n),{v:h,l:u}=i.decode(2,c);if(u.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(h)}},hexFromSig(t){const{_tlv:e,_int:r}=Ct,i=e.encode(2,r.encode(t.r)),s=e.encode(2,r.encode(t.s)),n=i+s;return e.encode(48,n)}},Tt=BigInt(0),me=BigInt(1);BigInt(2);const Pc=BigInt(3);BigInt(4);function Vv(t){const e=qv(t),{Fp:r}=e,i=_l(e.n,e.nBitLength),s=e.toBytes||((y,w,v)=>{const b=w.toAffine();return Si(Uint8Array.from([4]),r.toBytes(b.x),r.toBytes(b.y))}),n=e.fromBytes||(y=>{const w=y.subarray(1),v=r.fromBytes(w.subarray(0,r.BYTES)),b=r.fromBytes(w.subarray(r.BYTES,2*r.BYTES));return{x:v,y:b}});function o(y){const{a:w,b:v}=e,b=r.sqr(y),E=r.mul(b,y);return r.add(r.add(E,r.mul(y,w)),v)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function a(y){return Ls(y,me,e.n)}function c(y){const{allowedPrivateKeyLengths:w,nByteLength:v,wrapPrivateKey:b,n:E}=e;if(w&&typeof y!="bigint"){if(ar(y)&&(y=Vr(y)),typeof y!="string"||!w.includes(y.length))throw new Error("invalid private key");y=y.padStart(v*2,"0")}let I;try{I=typeof y=="bigint"?y:ir(Ve("private key",y,v))}catch{throw new Error("invalid private key, expected hex or "+v+" bytes, got "+typeof y)}return b&&(I=Le(I,E)),Rt("private key",I,me,E),I}function h(y){if(!(y instanceof d))throw new Error("ProjectivePoint expected")}const u=eo((y,w)=>{const{px:v,py:b,pz:E}=y;if(r.eql(E,r.ONE))return{x:v,y:b};const I=y.is0();w==null&&(w=I?r.ONE:r.inv(E));const P=r.mul(v,w),A=r.mul(b,w),O=r.mul(E,w);if(I)return{x:r.ZERO,y:r.ZERO};if(!r.eql(O,r.ONE))throw new Error("invZ was invalid");return{x:P,y:A}}),l=eo(y=>{if(y.is0()){if(e.allowInfinityPoint&&!r.is0(y.py))return;throw new Error("bad point: ZERO")}const{x:w,y:v}=y.toAffine();if(!r.isValid(w)||!r.isValid(v))throw new Error("bad point: x or y not FE");const b=r.sqr(v),E=o(w);if(!r.eql(b,E))throw new Error("bad point: equation left != right");if(!y.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class d{constructor(w,v,b){if(this.px=w,this.py=v,this.pz=b,w==null||!r.isValid(w))throw new Error("x required");if(v==null||!r.isValid(v))throw new Error("y required");if(b==null||!r.isValid(b))throw new Error("z required");Object.freeze(this)}static fromAffine(w){const{x:v,y:b}=w||{};if(!w||!r.isValid(v)||!r.isValid(b))throw new Error("invalid affine point");if(w instanceof d)throw new Error("projective point not allowed");const E=I=>r.eql(I,r.ZERO);return E(v)&&E(b)?d.ZERO:new d(v,b,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(w){const v=r.invertBatch(w.map(b=>b.pz));return w.map((b,E)=>b.toAffine(v[E])).map(d.fromAffine)}static fromHex(w){const v=d.fromAffine(n(Ve("pointHex",w)));return v.assertValidity(),v}static fromPrivateKey(w){return d.BASE.multiply(c(w))}static msm(w,v){return Rv(d,i,w,v)}_setWindowSize(w){p.setWindowSize(this,w)}assertValidity(){l(this)}hasEvenY(){const{y:w}=this.toAffine();if(r.isOdd)return!r.isOdd(w);throw new Error("Field doesn't support isOdd")}equals(w){h(w);const{px:v,py:b,pz:E}=this,{px:I,py:P,pz:A}=w,O=r.eql(r.mul(v,A),r.mul(I,E)),C=r.eql(r.mul(b,A),r.mul(P,E));return O&&C}negate(){return new d(this.px,r.neg(this.py),this.pz)}double(){const{a:w,b:v}=e,b=r.mul(v,Pc),{px:E,py:I,pz:P}=this;let A=r.ZERO,O=r.ZERO,C=r.ZERO,D=r.mul(E,E),q=r.mul(I,I),U=r.mul(P,P),j=r.mul(E,I);return j=r.add(j,j),C=r.mul(E,P),C=r.add(C,C),A=r.mul(w,C),O=r.mul(b,U),O=r.add(A,O),A=r.sub(q,O),O=r.add(q,O),O=r.mul(A,O),A=r.mul(j,A),C=r.mul(b,C),U=r.mul(w,U),j=r.sub(D,U),j=r.mul(w,j),j=r.add(j,C),C=r.add(D,D),D=r.add(C,D),D=r.add(D,U),D=r.mul(D,j),O=r.add(O,D),U=r.mul(I,P),U=r.add(U,U),D=r.mul(U,j),A=r.sub(A,D),C=r.mul(U,q),C=r.add(C,C),C=r.add(C,C),new d(A,O,C)}add(w){h(w);const{px:v,py:b,pz:E}=this,{px:I,py:P,pz:A}=w;let O=r.ZERO,C=r.ZERO,D=r.ZERO;const q=e.a,U=r.mul(e.b,Pc);let j=r.mul(v,I),k=r.mul(b,P),T=r.mul(E,A),g=r.add(v,b),m=r.add(I,P);g=r.mul(g,m),m=r.add(j,k),g=r.sub(g,m),m=r.add(v,E);let _=r.add(I,A);return m=r.mul(m,_),_=r.add(j,T),m=r.sub(m,_),_=r.add(b,E),O=r.add(P,A),_=r.mul(_,O),O=r.add(k,T),_=r.sub(_,O),D=r.mul(q,m),O=r.mul(U,T),D=r.add(O,D),O=r.sub(k,D),D=r.add(k,D),C=r.mul(O,D),k=r.add(j,j),k=r.add(k,j),T=r.mul(q,T),m=r.mul(U,m),k=r.add(k,T),T=r.sub(j,T),T=r.mul(q,T),m=r.add(m,T),j=r.mul(k,m),C=r.add(C,j),j=r.mul(_,m),O=r.mul(g,O),O=r.sub(O,j),j=r.mul(g,k),D=r.mul(_,D),D=r.add(D,j),new d(O,C,D)}subtract(w){return this.add(w.negate())}is0(){return this.equals(d.ZERO)}wNAF(w){return p.wNAFCached(this,w,d.normalizeZ)}multiplyUnsafe(w){const{endo:v,n:b}=e;Rt("scalar",w,Tt,b);const E=d.ZERO;if(w===Tt)return E;if(this.is0()||w===me)return this;if(!v||p.hasPrecomputes(this))return p.wNAFCachedUnsafe(this,w,d.normalizeZ);let{k1neg:I,k1:P,k2neg:A,k2:O}=v.splitScalar(w),C=E,D=E,q=this;for(;P>Tt||O>Tt;)P&me&&(C=C.add(q)),O&me&&(D=D.add(q)),q=q.double(),P>>=me,O>>=me;return I&&(C=C.negate()),A&&(D=D.negate()),D=new d(r.mul(D.px,v.beta),D.py,D.pz),C.add(D)}multiply(w){const{endo:v,n:b}=e;Rt("scalar",w,me,b);let E,I;if(v){const{k1neg:P,k1:A,k2neg:O,k2:C}=v.splitScalar(w);let{p:D,f:q}=this.wNAF(A),{p:U,f:j}=this.wNAF(C);D=p.constTimeNegate(P,D),U=p.constTimeNegate(O,U),U=new d(r.mul(U.px,v.beta),U.py,U.pz),E=D.add(U),I=q.add(j)}else{const{p:P,f:A}=this.wNAF(w);E=P,I=A}return d.normalizeZ([E,I])[0]}multiplyAndAddUnsafe(w,v,b){const E=d.BASE,I=(A,O)=>O===Tt||O===me||!A.equals(E)?A.multiplyUnsafe(O):A.multiply(O),P=I(this,v).add(I(w,b));return P.is0()?void 0:P}toAffine(w){return u(this,w)}isTorsionFree(){const{h:w,isTorsionFree:v}=e;if(w===me)return!0;
19if(v)return v(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:w,clearCofactor:v}=e;return w===me?this:v?v(d,this):this.multiplyUnsafe(e.h)}toRawBytes(w=!0){return Hr("isCompressed",w),this.assertValidity(),s(d,this,w)}toHex(w=!0){return Hr("isCompressed",w),Vr(this.toRawBytes(w))}}d.BASE=new d(e.Gx,e.Gy,r.ONE),d.ZERO=new d(r.ZERO,r.ONE,r.ZERO);const f=e.nBitLength,p=Tv(d,e.endo?Math.ceil(f/2):f);return{CURVE:e,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:a}}function Kv(t){const e=Ol(t);return Xr(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Wv(t){const e=Kv(t),{Fp:r,n:i}=e,s=r.BYTES+1,n=2*r.BYTES+1;function o(T){return Le(T,i)}function a(T){return ro(T,i)}const{ProjectivePoint:c,normPrivateKeyToScalar:h,weierstrassEquation:u,isWithinCurveOrder:l}=Vv({...e,toBytes(T,g,m){const _=g.toAffine(),S=r.toBytes(_.x),$=Si;return Hr("isCompressed",m),m?$(Uint8Array.from([g.hasEvenY()?2:3]),S):$(Uint8Array.from([4]),S,r.toBytes(_.y))},fromBytes(T){const g=T.length,m=T[0],_=T.subarray(1);if(g===s&&(m===2||m===3)){const S=ir(_);if(!Ls(S,me,r.ORDER))throw new Error("Point is not on curve");const $=u(S);let x;try{x=r.sqrt($)}catch(M){const z=M instanceof Error?": "+M.message:"";throw new Error("Point is not on curve"+z)}const F=(x&me)===me;return(m&1)===1!==F&&(x=r.neg(x)),{x:S,y:x}}else if(g===n&&m===4){const S=r.fromBytes(_.subarray(0,r.BYTES)),$=r.fromBytes(_.subarray(r.BYTES,2*r.BYTES));return{x:S,y:$}}else{const S=s,$=n;throw new Error("invalid Point, expected length of "+S+", or uncompressed "+$+", got "+g)}}}),d=T=>Vr(Wr(T,e.nByteLength));function f(T){const g=i>>me;return T>g}function p(T){return f(T)?o(-T):T}const y=(T,g,m)=>ir(T.slice(g,m));class w{constructor(g,m,_){this.r=g,this.s=m,this.recovery=_,this.assertValidity()}static fromCompact(g){const m=e.nByteLength;return g=Ve("compactSignature",g,m*2),new w(y(g,0,m),y(g,m,2*m))}static fromDER(g){const{r:m,s:_}=Ct.toSig(Ve("DER",g));return new w(m,_)}assertValidity(){Rt("r",this.r,me,i),Rt("s",this.s,me,i)}addRecoveryBit(g){return new w(this.r,this.s,g)}recoverPublicKey(g){const{r:m,s:_,recovery:S}=this,$=A(Ve("msgHash",g));if(S==null||![0,1,2,3].includes(S))throw new Error("recovery id invalid");const x=S===2||S===3?m+e.n:m;if(x>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");const F=S&1?"03":"02",M=c.fromHex(F+d(x)),z=a(x),L=o(-$*z),H=o(_*z),G=c.BASE.multiplyAndAddUnsafe(M,L,H);if(!G)throw new Error("point at infinify");return G.assertValidity(),G}hasHighS(){return f(this.s)}normalizeS(){return this.hasHighS()?new w(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Kr(this.toDERHex())}toDERHex(){return Ct.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Kr(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}const v={isValidPrivateKey(T){try{return h(T),!0}catch{return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{const T=$l(e.n);return Av(e.randomBytes(T),e.n)},precompute(T=8,g=c.BASE){return g._setWindowSize(T),g.multiply(BigInt(3)),g}};function b(T,g=!0){return c.fromPrivateKey(T).toRawBytes(g)}function E(T){const g=ar(T),m=typeof T=="string",_=(g||m)&&T.length;return g?_===s||_===n:m?_===2*s||_===2*n:T instanceof c}function I(T,g,m=!0){if(E(T))throw new Error("first arg must be private key");if(!E(g))throw new Error("second arg must be public key");return c.fromHex(g).multiply(h(T)).toRawBytes(m)}const P=e.bits2int||function(T){if(T.length>8192)throw new Error("input is too large");const g=ir(T),m=T.length*8-e.nBitLength;return m>0?g>>BigInt(m):g},A=e.bits2int_modN||function(T){return o(P(T))},O=Ho(e.nBitLength);function C(T){return Rt("num < 2^"+e.nBitLength,T,Tt,O),Wr(T,e.nByteLength)}function D(T,g,m=q){if(["recovered","canonical"].some(ee=>ee in m))throw new Error("sign() legacy options not supported");const{hash:_,randomBytes:S}=e;let{lowS:$,prehash:x,extraEntropy:F}=m;$==null&&($=!0),T=Ve("msgHash",T),Oc(m),x&&(T=Ve("prehashed msgHash",_(T)));const M=A(T),z=h(g),L=[C(z),C(M)];if(F!=null&&F!==!1){const ee=F===!0?S(r.BYTES):F;L.push(Ve("extraEntropy",ee))}const H=Si(...L),G=M;function se(ee){const Y=P(ee);if(!l(Y))return;const Pe=a(Y),Ee=c.BASE.multiply(Y).toAffine(),Ce=o(Ee.x);if(Ce===Tt)return;const Ye=o(Pe*o(G+Ce*z));if(Ye===Tt)return;let Je=(Ee.x===Ce?0:2)|Number(Ee.y&me),fr=Ye;return $&&f(Ye)&&(fr=p(Ye),Je^=1),new w(Ce,fr,Je)}return{seed:H,k2sig:se}}const q={lowS:e.lowS,prehash:!1},U={lowS:e.lowS,prehash:!1};function j(T,g,m=q){const{seed:_,k2sig:S}=D(T,g,m),$=e;return bl($.hash.outputLen,$.nByteLength,$.hmac)(_,S)}c.BASE._setWindowSize(8);function k(T,g,m,_=U){var Ye;const S=T;g=Ve("msgHash",g),m=Ve("publicKey",m);const{lowS:$,prehash:x,format:F}=_;if(Oc(_),"strict"in _)throw new Error("options.strict was renamed to lowS");if(F!==void 0&&F!=="compact"&&F!=="der")throw new Error("format must be compact or der");const M=typeof S=="string"||ar(S),z=!M&&!F&&typeof S=="object"&&S!==null&&typeof S.r
19=="bigint"&&typeof S.s=="bigint";if(!M&&!z)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let L,H;try{if(z&&(L=new w(S.r,S.s)),M){try{F!=="compact"&&(L=w.fromDER(S))}catch(Je){if(!(Je instanceof Ct.Err))throw Je}!L&&F!=="der"&&(L=w.fromCompact(S))}H=c.fromHex(m)}catch{return!1}if(!L||$&&L.hasHighS())return!1;x&&(g=e.hash(g));const{r:G,s:se}=L,ee=A(g),Y=a(se),Pe=o(ee*Y),Ee=o(G*Y),Ce=(Ye=c.BASE.multiplyAndAddUnsafe(H,Pe,Ee))==null?void 0:Ye.toAffine();return Ce?o(Ce.x)===G:!1}return{CURVE:e,getPublicKey:b,getSharedSecret:I,sign:j,verify:k,ProjectivePoint:c,Signature:w,utils:v}}function Gv(t){return{hash:t,hmac:(e,...r)=>Bs(t,e,Qw(...r)),randomBytes:Qr}}function Yv(t,e){const r=i=>Wv({...t,...Gv(i)});return{...r(e),create:r}}const Pl=_l(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),Jv=Pl.create(BigInt("-3")),Zv=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Qv=Yv({a:Jv,b:Zv,Fp:Pl,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},Fi),Al="base10",Re="base16",ut="base64pad",qt="base64url",Mi="utf8",xl=0,Nt=1,qi=2,Xv=0,Ac=1,mi=12,Vo=32;function e0(){const t=so.utils.randomPrivateKey(),e=so.getPublicKey(t);return{privateKey:Me(t,Re),publicKey:Me(e,Re)}}function no(){const t=Qr(Vo);return Me(t,Re)}function t0(t,e){const r=so.getSharedSecret(tt(t,Re),tt(e,Re)),i=nv(Fi,r,void 0,void 0,Vo);return Me(i,Re)}function ls(t){const e=Fi(tt(t,Re));return Me(e,Re)}function Et(t){const e=Fi(tt(t,Mi));return Me(e,Re)}function Cl(t){return tt(`${t}`,Al)}function cr(t){return Number(Me(t,Al))}function Tl(t){return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Rl(t){const e=t.replace(/-/g,"+").replace(/_/g,"/"),r=(4-e.length%4)%4;return e+"=".repeat(r)}function r0(t){const e=Cl(typeof t.type<"u"?t.type:xl);if(cr(e)===Nt&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof t.senderPublicKey<"u"?tt(t.senderPublicKey,Re):void 0,i=typeof t.iv<"u"?tt(t.iv,Re):Qr(mi),s=tt(t.symKey,Re),n=yl(s,i).encrypt(tt(t.message,Mi)),o=Nl({type:e,sealed:n,iv:i,senderPublicKey:r});return t.encoding===qt?Tl(o):o}function i0(t){const e=tt(t.symKey,Re),{sealed:r,iv:i}=Oi({encoded:t.encoded,encoding:t.encoding}),s=yl(e,i).decrypt(r);if(s===null)throw new Error("Failed to decrypt");return Me(s,Mi)}function s0(t,e){const r=Cl(qi),i=Qr(mi),s=tt(t,Mi),n=Nl({type:r,sealed:s,iv:i});return e===qt?Tl(n):n}function n0(t,e){const{sealed:r}=Oi({encoded:t,encoding:e});return Me(r,Mi)}function Nl(t){if(cr(t.type)===qi)return Me(yi([t.type,t.sealed]),ut);if(cr(t.type)===Nt){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return Me(yi([t.type,t.senderPublicKey,t.iv,t.sealed]),ut)}return Me(yi([t.type,t.iv,t.sealed]),ut)}function Oi(t){const e=(t.encoding||ut)===qt?Rl(t.encoded):t.encoded,r=tt(e,ut),i=r.slice(Xv,Ac),s=Ac;if(cr(i)===Nt){const c=s+Vo,h=c+mi,u=r.slice(s,c),l=r.slice(c,h),d=r.slice(h);return{type:i,sealed:d,iv:l,senderPublicKey:u}}if(cr(i)===qi){const c=r.slice(s),h=Qr(mi);return{type:i,sealed:c,iv:h}}const n=s+mi,o=r.slice(s,n),a=r.slice(n);return{type:i,sealed:a,iv:o}}function o0(t,e){const r=Oi({encoded:t,encoding:e==null?void 0:e.encoding});return Bl({type:cr(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?Me(r.senderPublicKey,Re):void 0,receiverPublicKey:e==null?void 0:e.receiverPublicKey})}function Bl(t){const e=(t==null?void 0:t.type)||xl;if(e===Nt){if(typeof(t==null?void 0:t.senderPublicKey)>"u")throw new Error("missing sender public key");if(typeof(t==null?void 0:t.receiverPublicKey)>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:t==null?void 0:t.senderPublicKey,receiverPublicKey:t==null?void 0:t.receiverPublicKey}}function xc(t){return t.type===Nt&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}function Cc(t){return t.type===qi}function a0(t){const e=Buffer.from(t.x,"base64"),r=Buffer.from(t.y,"base64");return yi([new Uint8Array([4]),e,r])}function c0(t,e){const[r,i,s]=t.split("."),n=Buffer.from(Rl(s),"base64");if(n.length!==64)throw new Error("Invalid signature length");
19const o=n.slice(0,32),a=n.slice(32,64),c=`${r}.${i}`,h=Fi(c),u=a0(e);if(!Qv.verify(yi([o,a]),h,u))throw new Error("Invalid signature");return Wn(t).payload}const h0="irn";function Es(t){return(t==null?void 0:t.relay)||{protocol:h0}}function pi(t){const e=fw[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}function u0(t,e="-"){const r={},i="relay"+e;return Object.keys(t).forEach(s=>{if(s.startsWith(i)){const n=s.replace(i,""),o=t[s];r[n]=o}}),r}function Tc(t){if(!t.includes("wc:")){const h=il(t);h!=null&&h.includes("wc:")&&(t=h)}t=t.includes("wc://")?t.replace("wc://",""):t,t=t.includes("wc:")?t.replace("wc:",""):t;const e=t.indexOf(":"),r=t.indexOf("?")!==-1?t.indexOf("?"):void 0,i=t.substring(0,e),s=t.substring(e+1,r).split("@"),n=typeof r<"u"?t.substring(r):"",o=new URLSearchParams(n),a={};o.forEach((h,u)=>{a[u]=h});const c=typeof a.methods=="string"?a.methods.split(","):void 0;return{protocol:i,topic:l0(s[0]),version:parseInt(s[1],10),symKey:a.symKey,relay:u0(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function l0(t){return t.startsWith("//")?t.substring(2):t}function d0(t,e="-"){const r="relay",i={};return Object.keys(t).forEach(s=>{const n=s,o=r+e+n;t[n]&&(i[o]=t[n])}),i}function Rc(t){const e=new URLSearchParams,r=d0(t.relay);Object.keys(r).sort().forEach(s=>{e.set(s,r[s])}),e.set("symKey",t.symKey),t.expiryTimestamp&&e.set("expiryTimestamp",t.expiryTimestamp.toString()),t.methods&&e.set("methods",t.methods.join(","));const i=e.toString();return`${t.protocol}:${t.topic}@${t.version}?${i}`}function Xi(t,e,r){return`${t}?wc_ev=${r}&topic=${e}`}function ei(t){const e=[];return t.forEach(r=>{const[i,s]=r.split(":");e.push(`${i}:${s}`)}),e}function p0(t){const e=[];return Object.values(t).forEach(r=>{e.push(...ei(r.accounts))}),e}function f0(t,e){const r=[];return Object.values(t).forEach(i=>{ei(i.accounts).includes(e)&&r.push(...i.methods)}),r}function g0(t,e){const r=[];return Object.values(t).forEach(i=>{ei(i.accounts).includes(e)&&r.push(...i.events)}),r}function Ko(t){return t.includes(":")}function fi(t){return Ko(t)?t.split(":")[0]:t}function y0(t){const e={};return t==null||t.forEach(r=>{var i;const[s,n]=r.split(":");e[s]||(e[s]={accounts:[],chains:[],events:[],methods:[]}),e[s].accounts.push(r),(i=e[s].chains)==null||i.push(`${s}:${n}`)}),e}function Nc(t,e){e=e.map(i=>i.replace("did:pkh:",""));const r=y0(e);for(const[i,s]of Object.entries(r))s.methods?s.methods=hs(s.methods,t):s.methods=t,s.events=["chainChanged","accountsChanged"];return r}const m0={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}},w0={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 B(t,e){const{message:r,code:i}=w0[t];return{message:e?`${r} ${e}`:r,code:i}}function te(t,e){const{message:r,code:i}=m0[t];return{message:e?`${r} ${e}`:r,code:i}}function lt(t,e){return!!Array.isArray(t)}function Pi(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function xe(t){return typeof t>"u"}function le(t,e){return e&&xe(t)?!0:typeof t=="string"&&!!t.trim().length}function Wo(t,e){return typeof t=="number"&&!isNaN(t)}function b0(t,e){const{requiredNamespaces:r}=e,i=Object.keys(t.namespaces),s=Object.keys(r);let n=!0;return tr(s,i)?(i.forEach(o=>{const{accounts:a,methods:c,events:h}=t.namespaces[o],u=ei(a),l=r[o];(!tr(Qu(o,l),u)||!tr(l.methods,c)||!tr(l.events,h))&&(n=!1)}),n):!1}function _s(t){return le(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function v0(t){if(le(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const r=e[0]+":"+e[1];return!!e[2]&&_s(r)}}return!1}function E0(t){function e(r){try{return typeof new URL(r)<"u"}catch{return!1}}try{if(le(t,!1)){if(e(t))return!0;const r=il(t);return e(r)}}catch{}return!1}function _0(t){var e;return(e=t==null?void 0:t.proposer)==null?void 0:e.publicKey}function I0(t){return t==null?void 0:t.topic}function $0(t,e){let r=null;return le(t==null?void 0:t.publicKey,!1)||(r=B("MISSING_OR_INVALID",`${e} controller public key should be a string`)),r}function Bc(t){let e=!0;return lt(t)?t.length&&(e=t.every(r=>le(r,!1))):e=!1,e}function D0(t,e,r){let i=null;return lt(e)&&e.length?e.forEach(s=>{i||_s(s)||(i=te("UNSUPPORTED_CHAINS",`${r}, chain ${s} should be a string and conform to "namespace:chainId" format`))}):_s(t)||(i=te("UNSUPPORTED_CHAINS",`${r}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:
195"] }`)),i}function S0(t,e,r){let i=null;return Object.entries(t).forEach(([s,n])=>{if(i)return;const o=D0(s,Qu(s,n),`${e} ${r}`);o&&(i=o)}),i}function O0(t,e){let r=null;return lt(t)?t.forEach(i=>{r||v0(i)||(r=te("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):r=te("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function P0(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const s=O0(i==null?void 0:i.accounts,`${e} namespace`);s&&(r=s)}),r}function A0(t,e){let r=null;return Bc(t==null?void 0:t.methods)?Bc(t==null?void 0:t.events)||(r=te("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):r=te("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),r}function jl(t,e){let r=null;return Object.values(t).forEach(i=>{if(r)return;const s=A0(i,`${e}, namespace`);s&&(r=s)}),r}function x0(t,e,r){let i=null;if(t&&Pi(t)){const s=jl(t,e);s&&(i=s);const n=S0(t,e,r);n&&(i=n)}else i=B("MISSING_OR_INVALID",`${e}, ${r} should be an object with data`);return i}function vn(t,e){let r=null;if(t&&Pi(t)){const i=jl(t,e);i&&(r=i);const s=P0(t,e);s&&(r=s)}else r=B("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function Ul(t){return le(t.protocol,!0)}function C0(t,e){let r=!1;return t?t&<(t)&&t.length&&t.forEach(i=>{r=Ul(i)}):r=!0,r}function T0(t){return typeof t=="number"}function Fe(t){return typeof t<"u"&&typeof t!==null}function R0(t){return!(!t||typeof t!="object"||!t.code||!Wo(t.code)||!t.message||!le(t.message,!1))}function N0(t){return!(xe(t)||!le(t.method,!1))}function B0(t){return!(xe(t)||xe(t.result)&&xe(t.error)||!Wo(t.id)||!le(t.jsonrpc,!1))}function j0(t){return!(xe(t)||!le(t.name,!1))}function jc(t,e){return!(!_s(e)||!p0(t).includes(e))}function U0(t,e,r){return le(r,!1)?f0(t,e).includes(r):!1}function F0(t,e,r){return le(r,!1)?g0(t,e).includes(r):!1}function Uc(t,e,r){let i=null;const s=L0(t),n=M0(e),o=Object.keys(s),a=Object.keys(n),c=Fc(Object.keys(t)),h=Fc(Object.keys(e)),u=c.filter(l=>!h.includes(l));return u.length&&(i=B("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces. 20 Required: ${u.toString()} 21 Received: ${Object.keys(e).toString()}`)),tr(o,a)||(i=B("NON_CONFORMING_NAMESPACES",`${r} namespaces chains don't satisfy required namespaces. 22 Required: ${o.toString()} 23 Approved: ${a.toString()}`)),Object.keys(e).forEach(l=>{if(!l.includes(":")||i)return;const d=ei(e[l].accounts);d.includes(l)||(i=B("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${l} 24 Required: ${l} 25 Approved: ${d.toString()}`))}),o.forEach(l=>{i||(tr(s[l].methods,n[l].methods)?tr(s[l].events,n[l].events)||(i=B("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${l}`)):i=B("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${l}`))}),i}function L0(t){const e={};return Object.keys(t).forEach(r=>{var i;r.includes(":")?e[r]=t[r]:(i=t[r].chains)==null||i.forEach(s=>{e[s]={methods:t[r].methods,events:t[r].events}})}),e}function Fc(t){return[...new Set(t.map(e=>e.includes(":")?e.split(":")[0]:e))]}function M0(t){const e={};return Object.keys(t).forEach(r=>{if(r.includes(":"))e[r]=t[r];else{const i=ei(t[r].accounts);i==null||i.forEach(s=>{e[s]={accounts:t[r].accounts.filter(n=>n.includes(`${s}:`)),methods:t[r].methods,events:t[r].events}})}}),e}function q0(t,e){return Wo(t)&&t<=e.max&&t>=e.min}function Lc(){const t=ji();return new Promise(e=>{switch(t){case We.browser:e(k0());break;case We.reactNative:e(z0());break;case We.node:e(H0());break;default:e(!0)}})}function k0(){return Bi()&&(navigator==null?void 0:navigator.onLine)}async function z0(){if(Vt()&&typeof global<"u"&&global!=null&&global.NetInfo){const t=await(global==null?void 0:global.NetInfo.fetch());return t==null?void 0:t.isConnected}return!0}function H0(){return!0}function V0(t){switch(ji()){case We.browser:K0(t);break;case We.reactNative:W0(t);break}}function K0(t){!Vt()&&Bi()&&(window.addEventListener("online",()=>t(!0)),window.addEventListener("offline",()=>t(!1)))}function W0(t){Vt()&&typeof global<"u"&&global!=null&&global.NetInfo&&(global==null||global.NetInfo.addEventListener(e=>t(e==null?void 0:e.isConnected)))}const En={};class ci{static get(e){return En[e]}static set(e,r){En[e]=r}static delete(e){delete En[e]}}class ur{}let G0=class extends ur{constructor(e){super()}};const Mc=N.FIVE_SECONDS,ti={pulse:"heartbeat_pulse"};let Y0=class Fl extends G0{constructor(e){super(e),this.events=new rt.EventEmitter,this.interval=Mc,this.interval=(e==null?void 0:e.interval)||Mc}static async init(e){const r=new Fl(e);return await r.init(),r}
vendor: 14,920 bytes, line 25
25async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),N.toMiliseconds(this.interval))}pulse(){this.events.emit(ti.pulse)}};const J0=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,Z0=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,Q0=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function X0(t,e){if(t==="__proto__"||t==="constructor"&&e&&typeof e=="object"&&"prototype"in e){e1(t);return}return e}function e1(t){console.warn(`[destr] Dropping "${t}" key to prevent prototype pollution.`)}function es(t,e={}){if(typeof t!="string")return t;if(t[0]==='"'&&t[t.length-1]==='"'&&t.indexOf("\\")===-1)return t.slice(1,-1);const r=t.trim();if(r.length<=9)switch(r.toLowerCase()){case"true":return!0;case"false":return!1;case"undefined":return;case"null":return null;case"nan":return Number.NaN;case"infinity":return Number.POSITIVE_INFINITY;case"-infinity":return Number.NEGATIVE_INFINITY}if(!Q0.test(t)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return t}try{if(J0.test(t)||Z0.test(t)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(t,X0)}return JSON.parse(t)}catch(i){if(e.strict)throw i;return t}}function t1(t){return!t||typeof t.then!="function"?Promise.resolve(t):t}function ye(t,...e){try{return t1(t(...e))}catch(r){return Promise.reject(r)}}function r1(t){const e=typeof t;return t===null||e!=="object"&&e!=="function"}function i1(t){const e=Object.getPrototypeOf(t);return!e||e.isPrototypeOf(Object)}function ds(t){if(r1(t))return String(t);if(i1(t)||Array.isArray(t))return JSON.stringify(t);if(typeof t.toJSON=="function")return ds(t.toJSON());throw new Error("[unstorage] Cannot stringify value!")}const oo="base64:";function s1(t){return typeof t=="string"?t:oo+a1(t)}function n1(t){return typeof t!="string"||!t.startsWith(oo)?t:o1(t.slice(oo.length))}function o1(t){return globalThis.Buffer?Buffer.from(t,"base64"):Uint8Array.from(globalThis.atob(t),e=>e.codePointAt(0))}function a1(t){return globalThis.Buffer?Buffer.from(t).toString("base64"):globalThis.btoa(String.fromCodePoint(...t))}function Ue(t){var e;return t&&((e=t.split("?")[0])==null?void 0:e.replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""))||""}function c1(...t){return Ue(t.join(":"))}function ts(t){return t=Ue(t),t?t+":":""}function h1(t,e){if(e===void 0)return!0;let r=0,i=t.indexOf(":");for(;i>-1;)r++,i=t.indexOf(":",i+1);return r<=e}function u1(t,e){return e?t.startsWith(e)&&t[t.length-1]!=="$":t[t.length-1]!=="$"}const l1="memory",d1=()=>{const t=new Map;return{name:l1,getInstance:()=>t,hasItem(e){return t.has(e)},getItem(e){return t.get(e)??null},getItemRaw(e){return t.get(e)??null},setItem(e,r){t.set(e,r)},setItemRaw(e,r){t.set(e,r)},removeItem(e){t.delete(e)},getKeys(){return[...t.keys()]},clear(){t.clear()},dispose(){t.clear()}}};function p1(t={}){const e={mounts:{"":t.driver||d1()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},r=h=>{for(const u of e.mountpoints)if(h.startsWith(u))return{base:u,relativeKey:h.slice(u.length),driver:e.mounts[u]};return{base:"",relativeKey:h,driver:e.mounts[""]}},i=(h,u)=>e.mountpoints.filter(l=>l.startsWith(h)||u&&h.startsWith(l)).map(l=>({relativeBase:h.length>l.length?h.slice(l.length):void 0,mountpoint:l,driver:e.mounts[l]})),s=(h,u)=>{if(e.watching){u=Ue(u);for(const l of e.watchListeners)l(h,u)}},n=async()=>{if(!e.watching){e.watching=!0;for(const h in e.mounts)e.unwatch[h]=await qc(e.mounts[h],s,h)}},o=async()=>{if(e.watching){for(const h in e.unwatch)await e.unwatch[h]();e.unwatch={},e.watching=!1}},a=(h,u,l)=>{const d=new Map,f=p=>{let y=d.get(p.base);return y||(y={driver:p.driver,base:p.base,items:[]},d.set(p.base,y)),y};for(const p of h){const y=typeof p=="string",w=Ue(y?p:p.key),v=y?void 0:p.value,b=y||!p.options?u:{...u,...p.options},E=r(w);f(E).items.push({key:w,value:v,relativeKey:E.relativeKey,options:b})}return Promise.all([...d.values()].map(p=>l(p))).then(p=>p.flat())},c={hasItem(h,u={}){h=Ue(h);const{relativeKey:l,driver:d}=r(h);return ye(d.hasItem,l,u)},getItem(h,u={}){h=Ue(h);const{relativeKey:l,driver:d}=r(h);return ye(d.getItem,l,u).then(f=>es(f))},getItems(h,u={}){return a(h,u,l=>l.driver.getItems?ye(l.driver.getItems,l.items.map(d=>({key:d.relativeKey,options:d.options})),u).then(d=>d.map(f=>({key:c1(l.base,f.key),value:es(f.value)}))):Promise.all(l.items.map(d=>ye(l.driver.getItem,d.relativeKey,d.options).then(f=>({key:d.key,value:es(f)})))))},getItemRaw(h,u={}){h=Ue(h);const{relativeKey:l,driver:d}=r(h);return d.getItemRaw?ye(d.getItemRaw,l,u):ye(d.getItem,l,u).then(f=>n1(f))},async setItem(h,u,l={}){if(u===void 0)return c.removeItem(h);h=Ue(h);const{relativeKey:d,driver:f}=r(h);f.setItem&&(await ye(f.setItem,d,ds(u),l),f.watch||s("update",h))},async setItems(h,u){await a(h,u,async l=>{if(l.driver.setItems)return ye(l.driver.setItems,l.items.map(d=>({key:d.relativeKey,value:ds(d.value),options:d.options})),u);l.driver.setItem&&await Promise.all(l.items.map(d=>ye(l.driver.setItem,d.relativeKey,ds(d.value),d.options)))})},async setItemRaw(h,u,l={}){if(u===void 0)return c.removeItem(h,l);h=Ue(h);const{relativeKey:d,driver:f}=r(h);if(f.setItemRaw)await ye(f.setItemRaw,d,u,l);else if(f.setItem)await ye(f.setItem,d,s1(u),l);else return;f.watch||s("update",h)},async removeItem(h,u={}){typeof u=="boolean"&&(u={removeMeta:u}),h=Ue(h);const{relativeKey:l,driver:d}=r(h);d.removeItem&&(await ye(d.removeItem,l,u),(u.removeMeta||u.removeMata)&&await ye(d.removeItem,l+"$",u),d.watch||s("remove",h))},async getMeta(h,u={}){typeof u=="boolean"&&(u={nativeOnly:u}),h=Ue(h);const{relativeKey:l,driver:d}=r(h),f=Object.create(null);if(d.getMeta&&Object.assign(f,await ye(d.getMeta,l,u)),!u.nativeOnly){const p=await ye(d.getItem,l+"$",u).then(y=>es(y));p&&typeof p=="object"&&(typeof p.atime=="string"&&(p.atime=new Date(p.atime)),typeof p.mtime=="string"&&(p.mtime=new Date(p.mtime)),Object.assign(f,p))}return f},setMeta(h,u,l={}){return this.setItem(h+"$",u,l)},removeMeta(h,u={}){return this.removeItem(h+"$",u)},async getKeys(h,u={}){var w;h=ts(h);const l=i(h,!0);let d=[];const f=[];let p=!0;for(const v of l){(w=v.driver.flags)!=null&&w.maxDepth||(p=!1);const b=await ye(v.driver.getKeys,v.relativeBase,u);for(const E of b){const I=v.mountpoint+Ue(E);d.some(P=>I.startsWith(P))||f.push(I)}d=[v.mountpoint,...d.filter(E=>!E.startsWith(v.mountpoint))]}const y=u.maxDepth!==void 0&&!p;return f.filter(v=>(!y||h1(v,u.maxDepth))&&u1(v,h))},async clear(h,u={}){h=ts(h),await Promise.all(i(h,!1).map(async l=>{if(l.driver.clear)return ye(l.driver.clear,l.relativeBase,u);if(l.driver.removeItem){const d=await l.driver.getKeys(l.relativeBase||"",u);return Promise.all(d.map(f=>l.driver.removeItem(f,u)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(h=>kc(h)))},async watch(h){return await n(),e.watchListeners.push(h),async()=>{e.watchListeners=e.watchListeners.filter(u=>u!==h),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(h,u){if(h=ts(h),h&&e.mounts[h])throw new Error(`already mounted at ${h}`);return h&&(e.mountpoints.push(h),e.mountpoints.sort((l,d)=>d.length-l.length)),e.mounts[h]=u,e.watching&&Promise.resolve(qc(u,s,h)).then(l=>{e.unwatch[h]=l}).catch(console.error),c},async unmount(h,u=!0){var l,d;h=ts(h),!(!h||!e.mounts[h])&&(e.watching&&h in e.unwatch&&((d=(l=e.unwatch)[h])==null||d.call(l),delete e.unwatch[h]),u&&await kc(e.mounts[h]),e.mountpoints=e.mountpoints.filter(f=>f!==h),delete e.mounts[h])},getMount(h=""){h=Ue(h)+":";const u=r(h);return{driver:u.driver,base:u.base}},getMounts(h="",u={}){return h=Ue(h),i(h,u.parents).map(d=>({driver:d.driver,base:d.mountpoint}))},keys:(h,u={})=>c.getKeys(h,u),get:(h,u={})=>c.getItem(h,u),set:(h,u,l={})=>c.setItem(h,u,l),has:(h,u={})=>c.hasItem(h,u),del:(h,u={})=>c.removeItem(h,u),remove:(h,u={})=>c.removeItem(h,u)};return c}function qc(t,e,r){return t.watch?t.watch((i,s)=>e(i,r+s)):()=>{}}async function kc(t){typeof t.dispose=="function"&&await ye(t.dispose)}function lr(t){return new Promise((e,r)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>r(t.error)})}function Ll(t,e){let r;const i=()=>{if(r)return r;const s=indexedDB.open(t);return s.onupgradeneeded=()=>s.result.createObjectStore(e),r=lr(s),r.then(n=>{n.onclose=()=>r=void 0},()=>{}),r};return(s,n)=>i().then(o=>n(o.transaction(e,s).objectStore(e)))}let _n;function ki(){return _n||(_n=Ll("keyval-store","keyval")),_n}function zc(t,e=ki()){return e("readonly",r=>lr(r.get(t)))}function f1(t,e,r=ki()){return r("readwrite",i=>(i.put(e,t),lr(i.transaction)))}function g1(t,e=ki()){return e("readwrite",r=>(r.delete(t),lr(r.transaction)))}function y1(t=ki()){return t("readwrite",e=>(e.clear(),lr(e.transaction)))}function m1(t,e){return t.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},lr(t.transaction)}function w1(t=ki()){return t("readonly",e=>{if(e.getAllKeys)return lr(e.getAllKeys());const r=[];return m1(e,i=>r.push(i.key)).then(()=>r)})}const b1="idb-keyval";var v1=(t={})=>{const e=t.base&&t.base.length>0?`${t.base}:`:"",r=s=>e+s;let i;return t.dbName&&t.storeName&&(i=Ll(t.dbName,t.storeName)),{name:b1,options:t,async hasItem(s){return!(typeof await zc(r(s),i)>"u")},async getItem(s){return await zc(r(s),i)??null},setItem(s,n){return f1(r(s),n,i)},removeItem(s){return g1(r(s),i)},getKeys(){return w1(i)},clear(){return y1(i)}}};const E1="WALLET_CONNECT_V2_INDEXED_DB",_1="keyvaluestorage";let I1=class{constructor(){this.indexedDb=p1({driver:v1({dbName:E1,storeName:_1})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){const r=await this.indexedDb.getItem(e);if(r!==null)return r}async setItem(e,r){await this.indexedDb.setItem(e,Bt(r))}async removeItem(e){await this.indexedDb.removeItem(e)}};var In=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},ps={exports:{}};(function(){let t;function e(){}t=e,t.prototype.getItem=function(r){return this.hasOwnProperty(r)?String(this[r]):null},t.prototype.setItem=function(r,i){this[r]=String(i)},t.prototype.removeItem=function(r){delete this[r]},t.prototype.clear=function(){const r=this;Object.keys(r).forEach(function(i){r[i]=void 0,delete r[i]})},t.prototype.key=function(r){return r=r||0,Object.keys(this)[r]},t.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof In<"u"&&In.localStorage?ps.exports=In.localStorage:typeof window<"u"&&window.localStorage?ps.exports=window.localStorage:ps.exports=new e})();function $1(t){var e;return[t[0],nr((e=t[1])!=null?e:"")]}let D1=class{constructor(){this.localStorage=ps.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map($1)}async getItem(e){const r=this.localStorage.getItem(e);if(r!==null)return nr(r)}async setItem(e,r){this.localStorage.setItem(e,Bt(r))}async removeItem(e){this.localStorage.removeItem(e)}};const S1="wc_storage_version",Hc=1,O1=async(t,e,r)=>{const i=S1,s=await e.getItem(i);if(s&&s>=Hc){r(e);return}const n=await t.getKeys();if(!n.length){r(e);return}const o=[];for(;n.length;){const a=n.shift();if(!a)continue;const c=a.toLowerCase();if(c.includes("wc@")||c.includes("walletconnect")||c.includes("wc_")||c.includes("wallet_connect")){const h=await t.getItem(a);await e.setItem(a,h),o.push(a)}}await e.setItem(i,Hc),r(e),P1(t,o)},P1=async(t,e)=>{e.length&&e.forEach(async r=>{await t.removeItem(r)})};let A1=class{constructor(){this.initialized=!1,this.setInitialized=r=>{this.storage=r,this.initialized=!0};const e=new D1;this.storage=e;try{const r=new I1;O1(e,r,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,r){return await this.initialize(),this.storage.setItem(e,r)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{const r=setInterval(()=>{this.initialized&&(clearInterval(r),e())},20)})}};function x1(t){try{return JSON.stringify(t)}catch{return'"[Circular]"'}}var C1=T1;function T1(t,e,r){var i=r&&r.stringify||x1,s=1;if(typeof t=="object"&&t!==null){var n=e.length+s;if(n===1)return t;var o=new Array(n);o[0]=i(t);for(var a=1;a<n;a++)o[a]=i(e[a]);return o.join(" ")}if(typeof t!="string")return t;var c=e.length;if(c===0)return t;for(var h="",u=1-s,l=-1,d=t&&t.length||0,f=0;f<d;){if(t.charCodeAt(f)===37&&f+1<d){switch(l=l>-1?l:0,t.charCodeAt(f+1)){case 100:case 102:if(u>=c||e[u]==null)break;l<f&&(h+=t.slice(l,f)),h+=Number(e[u]),l=f+2,f++;break;case 105:if(u>=c||e[u]==null)break;l<f&&(h+=t.slice(l,f)),h+=Math.floor(Number(e[u])),l=f+2,f++;break;case 79:case 111:case 106:if(u>=c||e[u]===void 0)break;l<f&&(h+=t.slice(l,f));var p=typeof e[u];if(p==="string"){h+="'"+e[u]+"'",l=f+2,f++;break}if(p==="function"){h+=e[u].name||"<anonymous>",l=f+2,f++;break}h+=i(e[u]),l=f+2,f++;break;case 115:if(u>=c)break;l<f&&(h+=t.slice(l,f)),h+=String(e[u]),l=f+2,f++;break;case 37:l<f&&(h+=t.slice(l,f)),h+="%",l=f+2,f++,u--;break}++u}++f}return l===-1?t:(l<d&&(h+=t.slice(l)),h)}const Vc=C1;var Br=_t;const Ai=k1().console||{},R1={mapHttpRequest:rs,mapHttpResponse:rs,wrapRequestSerializer:$n,wrapResponseSerializer:$n,wrapErrorSerializer:$n,req:rs,res:rs,err:F1};function N1(t,e){return Array.isArray(t)?t.filter(function(i){return i!=="!stdSerializers.err"}):t===!0?Object.keys(e):!1}function _t(t){t=t||{},t.browser=t.browser||{};const e=t.browser.transmit;if(e&&typeof e.send!="function")throw Error("pino: transmit option must have a send function");const r=t.browser.write||Ai;t.browser.write&&(t.browser.asObject=!0);const i=t.serializers||{},s=N1(t.browser.serialize,i);let n=t.browser.serialize;Array.isArray(t.browser.serialize)&&t.browser.serialize.indexOf("!stdSerializers.err")>-1&&(n=!1);const o=["error","fatal","warn","info","debug","trace"];typeof r=="function"&&(r.error=r.fatal=r.warn=r.info=r.debug=r.trace=r),t.enabled===!1&&(t.level="silent");const a=t.level||"info",c=Object.create(r);c.log||(c.log=xi),Object.defineProperty(c,"levelVal",{get:u}),Object.defineProperty(c,"level",{get:l,set:d});const h={transmit:e,serialize:s,asObject:t.browser.asObject,levels:o,timestamp:L1(t)};
25c.levels=_t.levels,c.level=a,c.setMaxListeners=c.getMaxListeners=c.emit=c.addListener=c.on=c.prependListener=c.once=c.prependOnceListener=c.removeListener=c.removeAllListeners=c.listeners=c.listenerCount=c.eventNames=c.write=c.flush=xi,c.serializers=i,c._serialize=s,c._stdErrSerialize=n,c.child=f,e&&(c._logEvent=ao());function u(){return this.level==="silent"?1/0:this.levels.values[this.level]}function l(){return this._level}function d(p){if(p!=="silent"&&!this.levels.values[p])throw Error("unknown level "+p);this._level=p,vr(h,c,"error","log"),vr(h,c,"fatal","error"),vr(h,c,"warn","error"),vr(h,c,"info","log"),vr(h,c,"debug","log"),vr(h,c,"trace","log")}function f(p,y){if(!p)throw new Error("missing bindings for child Pino");y=y||{},s&&p.serializers&&(y.serializers=p.serializers);const w=y.serializers;if(s&&w){var v=Object.assign({},i,w),b=t.browser.serialize===!0?Object.keys(v):s;delete p.serializers,Ms([p],b,v,this._stdErrSerialize)}function E(I){this._childLevel=(I._childLevel|0)+1,this.error=Er(I,p,"error"),this.fatal=Er(I,p,"fatal"),this.warn=Er(I,p,"warn"),this.info=Er(I,p,"info"),this.debug=Er(I,p,"debug"),this.trace=Er(I,p,"trace"),v&&(this.serializers=v,this._serialize=b),e&&(this._logEvent=ao([].concat(I._logEvent.bindings,p)))}return E.prototype=this,new E(this)}return c}_t.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}};_t.stdSerializers=R1;_t.stdTimeFunctions=Object.assign({},{nullTime:Ml,epochTime:ql,unixTime:M1,isoTime:q1});function vr(t,e,r,i){const s=Object.getPrototypeOf(e);e[r]=e.levelVal>e.levels.values[r]?xi:s[r]?s[r]:Ai[r]||Ai[i]||xi,B1(t,e,r)}function B1(t,e,r){!t.transmit&&e[r]===xi||(e[r]=function(i){return function(){const n=t.timestamp(),o=new Array(arguments.length),a=Object.getPrototypeOf&&Object.getPrototypeOf(this)===Ai?Ai:this;for(var c=0;c<o.length;c++)o[c]=arguments[c];if(t.serialize&&!t.asObject&&Ms(o,this._serialize,this.serializers,this._stdErrSerialize),t.asObject?i.call(a,j1(this,r,o,n)):i.apply(a,o),t.transmit){const h=t.transmit.level||e.level,u=_t.levels.values[h],l=_t.levels.values[r];if(l<u)return;U1(this,{ts:n,methodLevel:r,methodValue:l,transmitLevel:h,transmitValue:_t.levels.values[t.transmit.level||e.level],send:t.transmit.send,val:e.levelVal},o)}}}(e[r]))}function j1(t,e,r,i){t._serialize&&Ms(r,t._serialize,t.serializers,t._stdErrSerialize);const s=r.slice();let n=s[0];const o={};i&&(o.time=i),o.level=_t.levels.values[e];let a=(t._childLevel|0)+1;if(a<1&&(a=1),n!==null&&typeof n=="object"){for(;a--&&typeof s[0]=="object";)Object.assign(o,s.shift());n=s.length?Vc(s.shift(),s):void 0}else typeof n=="string"&&(n=Vc(s.shift(),s));return n!==void 0&&(o.msg=n),o}function Ms(t,e,r,i){for(const s in t)if(i&&t[s]instanceof Error)t[s]=_t.stdSerializers.err(t[s]);else if(typeof t[s]=="object"&&!Array.isArray(t[s]))for(const n in t[s])e&&e.indexOf(n)>-1&&n in r&&(t[s][n]=r[n](t[s][n]))}function Er(t,e,r){return function(){const i=new Array(1+arguments.length);i[0]=e;for(var s=1;s<i.length;s++)i[s]=arguments[s-1];return t[r].apply(this,i)}}function U1(t,e,r){const i=e.send,s=e.ts,n=e.methodLevel,o=e.methodValue,a=e.val,c=t._logEvent.bindings;Ms(r,t._serialize||Object.keys(t.serializers),t.serializers,t._stdErrSerialize===void 0?!0:t._stdErrSerialize),t._logEvent.ts=s,t._logEvent.messages=r.filter(function(h){return c.indexOf(h)===-1}),t._logEvent.level.label=n,t._logEvent.level.value=o,i(n,t._logEvent,a),t._logEvent=ao(c)}function ao(t){return{ts:0,messages:[],bindings:t||[],level:{label:"",value:0}}}function F1(t){const e={type:t.constructor.name,msg:t.message,stack:t.stack};for(const r in t)e[r]===void 0&&(e[r]=t[r]);return e}function L1(t){return typeof t.timestamp=="function"?t.timestamp:t.timestamp===!1?Ml:ql}function rs(){return{}}function $n(t){return t}function xi(){}function Ml(){return!1}function ql(){return Date.now()}function M1(){return Math.round(Date.now()/1e3)}function q1(){return new Date(Date.now()).toISOString()}function k1(){function t(e){return typeof e<"u"&&e}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return t(self)||t(window)||t(this)||{}}}const zi=tu(Br),z1={level:"info"},Hi="custom_context",Go=1e3*1024;let H1=class{constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}},Kc=class{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){const r=new H1(e);if(r.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${r.size}`);for(;this.size+r.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=r),this.tail=r):(this.head=r,this.tail=r),this.lengthInNodes++,this.sizeInBytes+=r.
25size}shift(){if(!this.head)return;const e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){const e=[];let r=this.head;for(;r!==null;)e.push(r.value),r=r.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};const r=e.value;return e=e.next,{done:!1,value:r}}}}},kl=class{constructor(e,r=Go){this.level=e??"error",this.levelValue=Br.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=r,this.logs=new Kc(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,r){r===Br.levels.values.error?console.error(e):r===Br.levels.values.warn?console.warn(e):r===Br.levels.values.debug?console.debug(e):r===Br.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(Bt({timestamp:new Date().toISOString(),log:e}));const r=typeof e=="string"?JSON.parse(e).level:e.level;r>=this.levelValue&&this.forwardToConsole(e,r)}getLogs(){return this.logs}clearLogs(){this.logs=new Kc(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const r=this.getLogArray();return r.push(Bt({extraMetadata:e})),new Blob(r,{type:"application/json"})}},V1=class{constructor(e,r=Go){this.baseChunkLogger=new kl(e,r)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){const r=URL.createObjectURL(this.logsToBlob(e)),i=document.createElement("a");i.href=r,i.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}},K1=class{constructor(e,r=Go){this.baseChunkLogger=new kl(e,r)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}};var W1=Object.defineProperty,G1=Object.defineProperties,Y1=Object.getOwnPropertyDescriptors,Wc=Object.getOwnPropertySymbols,J1=Object.prototype.hasOwnProperty,Z1=Object.prototype.propertyIsEnumerable,Gc=(t,e,r)=>e in t?W1(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Is=(t,e)=>{for(var r in e||(e={}))J1.call(e,r)&&Gc(t,r,e[r]);if(Wc)for(var r of Wc(e))Z1.call(e,r)&&Gc(t,r,e[r]);return t},$s=(t,e)=>G1(t,Y1(e));function qs(t){return $s(Is({},t),{level:(t==null?void 0:t.level)||z1.level})}function Q1(t,e=Hi){return t[e]||""}function X1(t,e,r=Hi){return t[r]=e,t}function qe(t,e=Hi){let r="";return typeof t.bindings>"u"?r=Q1(t,e):r=t.bindings().context||"",r}function eE(t,e,r=Hi){const i=qe(t,r);return i.trim()?`${i}/${e}`:e}function Ne(t,e,r=Hi){const i=eE(t,e,r),s=t.child({context:i});return X1(s,i,r)}function tE(t){var e,r;const i=new V1((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:zi($s(Is({},t.opts),{level:"trace",browser:$s(Is({},(r=t.opts)==null?void 0:r.browser),{write:s=>i.write(s)})})),chunkLoggerController:i}}function rE(t){var e;const r=new K1((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:zi($s(Is({},t.opts),{level:"trace"}),r),chunkLoggerController:r}}function iE(t){return typeof t.loggerOverride<"u"&&typeof t.loggerOverride!="string"?{logger:t.loggerOverride,chunkLoggerController:null}:typeof window<"u"?tE(t):rE(t)}var sE=Object.defineProperty,nE=(t,e,r)=>e in t?sE(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Yc=(t,e,r)=>nE(t,typeof e!="symbol"?e+"":e,r);let oE=class extends ur{constructor(e){super(),this.opts=e,Yc(this,"protocol","wc"),Yc(this,"version",2)}};var aE=Object.defineProperty,cE=(t,e,r)=>e in t?aE(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,hE=(t,e,r)=>cE(t,e+"",r);let uE=class extends ur{constructor(e,r){super(),this.core=e,this.logger=r,hE(this,"records",new Map)}},lE=class{constructor(e,r){this.logger=e,this.core=r}},dE=class extends ur{constructor(e,r){super(),this.relayer=e,this.logger=r}},pE=class extends ur{constructor(e){super()}},fE=class{constructor(e,r,i,s){this.core=e,this.logger=r,this.name=i}},gE=class extends ur{constructor(e,r){super(),this.relayer=e,this.logger=r}},yE=class extends ur{constructor(e,r){super(),this.core=e,this.logger=r}},mE=class{constructor(e,r,i){this.core=e,this.logger=r,this.store=i}},wE=class{constructor(e,r){this.projectId=e,this.logger=r}},bE=class{constructor(e,r,i){this.core=e,this.logger=r,this.telemetryEnabled=i}};var vE=Object.defineProperty,EE=(t,e,r)=>e in t?vE(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Jc=(t,e,r)=>EE(t,typeof e!="symbol"?e+"":e,r);let _E=class{constructor(e){this.opts=e,Jc(this,"protocol","wc"),Jc(this,"version",2)}},IE=class{constructor(e){this.client=e}};const $E="PARSE_ERROR",DE="INVALID_REQUEST",SE="METHOD_NOT_FOUND",OE="INVALID_PARAMS",zl="INTERNAL_ERROR",Yo="SERVER_ERROR",PE=[-32700,-32600,-32601,-32602,-32603],wi={[$E]:{code:-32700,message:"Parse error"},[DE]:{code:-32600,message:"Invalid Request"},[SE]:{code:-32601,message:"Method not found"},[OE]:{code:-32602,message:"Invalid params"},[zl]:{code:-32603,message:"Internal error"},[Yo]:{code:-32e3,message:"Server error"}},Hl=Yo;function AE(t){return PE.includes(t)}function Zc(t){return Object.keys(wi).includes(t)?wi[t]:wi[Hl]}function xE(t){const e=Object.values(wi).find(r=>r.code===t);return e||wi[Hl]}function Vl(t,e,r){return t.message.includes("getaddrinfo ENOTFOUND")||t.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${e}`):t}var Kl={};/*! ***************************************************************************** 26Copyright (c) Microsoft Corporation. 27 28Permission to use, copy, modify, and/or distribute this software for any 29purpose with or without fee is hereby granted. 30 31THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 32REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 33AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 34INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 35LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 36OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 37PERFORMANCE OF THIS SOFTWARE. 38***************************************************************************** */var co=function(t,e){return co=Object.
vendor: 12,328 bytes, line 38
38setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var s in i)i.hasOwnProperty(s)&&(r[s]=i[s])},co(t,e)};function CE(t,e){co(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var ho=function(){return ho=Object.assign||function(e){for(var r,i=1,s=arguments.length;i<s;i++){r=arguments[i];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},ho.apply(this,arguments)};function TE(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]]);return r}function RE(t,e,r,i){var s=arguments.length,n=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(t,e,r,i);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(n=(s<3?o(n):s>3?o(e,r,n):o(e,r))||n);return s>3&&n&&Object.defineProperty(e,r,n),n}function NE(t,e){return function(r,i){e(r,i,t)}}function BE(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function jE(t,e,r,i){function s(n){return n instanceof r?n:new r(function(o){o(n)})}return new(r||(r=Promise))(function(n,o){function a(u){try{h(i.next(u))}catch(l){o(l)}}function c(u){try{h(i.throw(u))}catch(l){o(l)}}function h(u){u.done?n(u.value):s(u.value).then(a,c)}h((i=i.apply(t,e||[])).next())})}function UE(t,e){var r={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},i,s,n,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(h){return function(u){return c([h,u])}}function c(h){if(i)throw new TypeError("Generator is already executing.");for(;r;)try{if(i=1,s&&(n=h[0]&2?s.return:h[0]?s.throw||((n=s.return)&&n.call(s),0):s.next)&&!(n=n.call(s,h[1])).done)return n;switch(s=0,n&&(h=[h[0]&2,n.value]),h[0]){case 0:case 1:n=h;break;case 4:return r.label++,{value:h[1],done:!1};case 5:r.label++,s=h[1],h=[0];continue;case 7:h=r.ops.pop(),r.trys.pop();continue;default:if(n=r.trys,!(n=n.length>0&&n[n.length-1])&&(h[0]===6||h[0]===2)){r=0;continue}if(h[0]===3&&(!n||h[1]>n[0]&&h[1]<n[3])){r.label=h[1];break}if(h[0]===6&&r.label<n[1]){r.label=n[1],n=h;break}if(n&&r.label<n[2]){r.label=n[2],r.ops.push(h);break}n[2]&&r.ops.pop(),r.trys.pop();continue}h=e.call(t,r)}catch(u){h=[6,u],s=0}finally{i=n=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function FE(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}function LE(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&(e[r]=t[r])}function uo(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Wl(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var i=r.call(t),s,n=[],o;try{for(;(e===void 0||e-- >0)&&!(s=i.next()).done;)n.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return n}function ME(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Wl(arguments[e]));return t}function qE(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var i=Array(t),s=0,e=0;e<r;e++)for(var n=arguments[e],o=0,a=n.length;o<a;o++,s++)i[s]=n[o];return i}function Ci(t){return this instanceof Ci?(this.v=t,this):new Ci(t)}function kE(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=r.apply(t,e||[]),s,n=[];return s={},o("next"),o("throw"),o("return"),s[Symbol.asyncIterator]=function(){return this},s;function o(d){i[d]&&(s[d]=function(f){return new Promise(function(p,y){n.push([d,f,p,y])>1||a(d,f)})})}function a(d,f){try{c(i[d](f))}catch(p){l(n[0][3],p)}}function c(d){d.value instanceof Ci?Promise.resolve(d.value.v).then(h,u):l(n[0][2],d)}function h(d){a("next",d)}function u(d){a("throw",d)}function l(d,f){d(f),n.shift(),n.length&&a(n[0][0],n[0][1])}}function zE(t){var e,r;return e={},i("next"),i("throw",function(s){throw s}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(s,n){e[s]=t[s]?function(o){return(r=!r)?{value:Ci(t[s](o)),done:s==="return"}:n?n(o):o}:n}}function HE(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof uo=="function"?uo(t):t[Symbol.iterator](),r={},i("next"),i("throw"),i("return"),r[Symbol.asyncIterator]=function(){return this},r);function i(n){r[n]=t[n]&&function(o){return new Promise(function(a,c){o=t[n](o),s(a,c,o.done,o.value)})}}function s(n,o,a,c){Promise.resolve(c).then(function(h){n({value:h,done:a})},o)}}function VE(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function KE(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function WE(t){return t&&t.__esModule?t:{default:t}}function GE(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function YE(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}const JE=Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return ho},__asyncDelegator:zE,__asyncGenerator:kE,__asyncValues:HE,__await:Ci,__awaiter:jE,__classPrivateFieldGet:GE,__classPrivateFieldSet:YE,__createBinding:FE,__decorate:RE,__exportStar:LE,__extends:CE,__generator:UE,__importDefault:WE,__importStar:KE,__makeTemplateObject:VE,__metadata:BE,__param:NE,__read:Wl,__rest:TE,__spread:ME,__spreadArrays:qE,__values:uo},Symbol.toStringTag,{value:"Module"})),ZE=Xh(JE);var Pt={},Qc;function QE(){if(Qc)return Pt;Qc=1,Object.defineProperty(Pt,"__esModule",{value:!0}),Pt.isBrowserCryptoAvailable=Pt.getSubtleCrypto=Pt.getBrowerCrypto=void 0;function t(){return(vt===null||vt===void 0?void 0:vt.crypto)||(vt===null||vt===void 0?void 0:vt.msCrypto)||{}}Pt.getBrowerCrypto=t;function e(){const i=t();return i.subtle||i.webkitSubtle}Pt.getSubtleCrypto=e;function r(){return!!t()&&!!e()}return Pt.isBrowserCryptoAvailable=r,Pt}var At={},Xc;function XE(){if(Xc)return At;Xc=1,Object.defineProperty(At,"__esModule",{value:!0}),At.isBrowser=At.isNode=At.isReactNative=void 0;function t(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}At.isReactNative=t;function e(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}At.isNode=e;function r(){return!t()&&!e()}return At.isBrowser=r,At}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=ZE;e.__exportStar(QE(),t),e.__exportStar(XE(),t)})(Kl);function wt(t=3){const e=Date.now()*Math.pow(10,t),r=Math.floor(Math.random()*Math.pow(10,t));return e+r}function rr(t=6){return BigInt(wt(t))}function zt(t,e,r){return{id:r||wt(),jsonrpc:"2.0",method:t,params:e}}function ks(t,e){return{id:t,jsonrpc:"2.0",result:e}}function zs(t,e,r){return{id:t,jsonrpc:"2.0",error:e_(e)}}function e_(t,e){return typeof t>"u"?Zc(zl):(typeof t=="string"&&(t=Object.assign(Object.assign({},Zc(Yo)),{message:t})),AE(t.code)&&(t=xE(t.code)),t)}class t_{}class r_ extends t_{constructor(){super()}}class i_ extends r_{constructor(e){super()}}const s_="^https?:",n_="^wss?:";function o_(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function Gl(t,e){const r=o_(t);return typeof r>"u"?!1:new RegExp(e).test(r)}function eh(t){return Gl(t,s_)}function th(t){return Gl(t,n_)}function a_(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function Yl(t){return typeof t=="object"&&"id"in t&&"jsonrpc"in t&&t.jsonrpc==="2.0"}function Jo(t){return Yl(t)&&"method"in t}function Hs(t){return Yl(t)&&(bt(t)||et(t))}function bt(t){return"result"in t}function et(t){return"error"in t}let it=class extends i_{constructor(e){super(e),this.events=new rt.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async request(e,r){return this.requestStrict(zt(e.method,e.params||[],e.id||rr().toString()),r)}async requestStrict(e,r){return new Promise(async(i,s)=>{if(!this.connection.connected)try{await this.open()}catch(n){s(n)}this.events.on(`${e.id}`,n=>{et(n)?s(n.error):i(n.result)});try{await this.connection.send(e,r)}catch(n){s(n)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Hs(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}};const c_=()=>typeof WebSocket<"u"?WebSocket:typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),h_=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",rh=t=>t.split("?")[0],ih=10,u_=c_();let l_=class{constructor(e){if(this.url=e,this.events=new rt.EventEmitter,this.registering=!1,!th(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,r)=>{if(typeof this.socket>"u"){r(new Error("Connection already closed"));return}this.socket.onclose=i=>{this.onClose(i),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(Bt(e))}catch(r){this.onError(e.id,r)}}register(e=this.url){if(!th(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((i,s)=>{this.events.once("register_error",n=>{this.resetMaxListeners(),s(n)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return s(new Error("WebSocket connection is missing or invalid"));i(this.socket)})})}return this.url=e,this.registering=!0,new Promise((r,i)=>{const s=Kl.isReactNative()?void 0:{rejectUnauthorized:!a_(e)},n=new u_(e,[],s);h_()?n.onerror=o=>{const a=o;i(this.emitError(a.error))}:n.on("error",o=>{i(this.emitError(o))}),n.onopen=()=>{this.onOpen(n),r(n)}})}onOpen(e){e.onmessage=r=>this.onPayload(r),e.onclose=r=>this.onClose(r),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;
38const r=typeof e.data=="string"?nr(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const i=this.parseError(r),s=i.message||i.toString(),n=zs(e,s);this.events.emit("payload",n)}parseError(e,r=this.url){return Vl(e,rh(r),"WS")}resetMaxListeners(){this.events.getMaxListeners()>ih&&this.events.setMaxListeners(ih)}emitError(e){const r=this.parseError(new Error((e==null?void 0:e.message)||`WebSocket connection failed for host: ${rh(this.url)}`));return this.events.emit("register_error",r),r}};var d_={};const Jl="wc",Zl=2,Ds="core",It=`${Jl}@2:${Ds}:`,p_={name:Ds,logger:"error"},f_={database:":memory:"},g_="crypto",sh="client_ed25519_seed",y_=N.ONE_DAY,m_="keychain",w_="0.3",b_="messages",v_="0.3",nh=N.SIX_HOURS,E_="publisher",Ql="irn",__="error",Xl="wss://relay.walletconnect.org",I_="relayer",we={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},$_="_subscription",Ze={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},D_=.1,lo="2.19.2",ae={link_mode:"link_mode",relay:"relay"},fs={inbound:"inbound",outbound:"outbound"},S_="0.3",O_="WALLETCONNECT_CLIENT_ID",oh="WALLETCONNECT_LINK_MODE_APPS",He={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},P_="subscription",A_="0.3",x_="pairing",C_="0.3",hi={wc_pairingDelete:{req:{ttl:N.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:N.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:N.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:N.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:N.ONE_DAY,prompt:!1,tag:0},res:{ttl:N.ONE_DAY,prompt:!1,tag:0}}},Xt={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},ot={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},T_="history",R_="0.3",N_="expirer",Xe={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},B_="0.3",j_="verify-api",U_="https://verify.walletconnect.com",ed="https://verify.walletconnect.org",bi=ed,F_=`${bi}/v3`,L_=[U_,ed],M_="echo",q_="https://echo.walletconnect.com",mt={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},xt={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},at={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},Gt={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},Yt={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},ui={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},k_=.1,z_="event-client",H_=86400,V_="https://pulse.walletconnect.org/batch";function K_(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");
vendor: 6,474 bytes, line 38
38for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var s=0;s<t.length;s++){var n=t.charAt(s),o=n.charCodeAt(0);if(r[o]!==255)throw new TypeError(n+" is ambiguous");r[o]=s}var a=t.length,c=t.charAt(0),h=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var y=0,w=0,v=0,b=p.length;v!==b&&p[v]===0;)v++,y++;for(var E=(b-v)*u+1>>>0,I=new Uint8Array(E);v!==b;){for(var P=p[v],A=0,O=E-1;(P!==0||A<w)&&O!==-1;O--,A++)P+=256*I[O]>>>0,I[O]=P%a>>>0,P=P/a>>>0;if(P!==0)throw new Error("Non-zero carry");w=A,v++}for(var C=E-w;C!==E&&I[C]===0;)C++;for(var D=c.repeat(y);C<E;++C)D+=t.charAt(I[C]);return D}function d(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var y=0;if(p[y]!==" "){for(var w=0,v=0;p[y]===c;)w++,y++;for(var b=(p.length-y)*h+1>>>0,E=new Uint8Array(b);p[y];){var I=r[p.charCodeAt(y)];if(I===255)return;for(var P=0,A=b-1;(I!==0||P<v)&&A!==-1;A--,P++)I+=a*E[A]>>>0,E[A]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");v=P,y++}if(p[y]!==" "){for(var O=b-v;O!==b&&E[O]===0;)O++;for(var C=new Uint8Array(w+(b-O)),D=w;O!==b;)C[D++]=E[O++];return C}}}function f(p){var y=d(p);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:d,decode:f}}var W_=K_,G_=W_;const td=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},Y_=t=>new TextEncoder().encode(t),J_=t=>new TextDecoder().decode(t);class Z_{constructor(e,r,i){this.name=e,this.prefix=r,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class Q_{constructor(e,r,i){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return rd(this,e)}}class X_{constructor(e){this.decoders=e}or(e){return rd(this,e)}decode(e){const r=e[0],i=this.decoders[r];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const rd=(t,e)=>new X_({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class eI{constructor(e,r,i,s){this.name=e,this.prefix=r,this.baseEncode=i,this.baseDecode=s,this.encoder=new Z_(e,r,i),this.decoder=new Q_(e,r,s)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Vs=({name:t,prefix:e,encode:r,decode:i})=>new eI(t,e,r,i),Vi=({prefix:t,name:e,alphabet:r})=>{const{encode:i,decode:s}=G_(r,e);return Vs({prefix:t,name:e,encode:i,decode:n=>td(s(n))})},tI=(t,e,r,i)=>{const s={};for(let u=0;u<e.length;++u)s[e[u]]=u;let n=t.length;for(;t[n-1]==="=";)--n;const o=new Uint8Array(n*r/8|0);let a=0,c=0,h=0;for(let u=0;u<n;++u){const l=s[t[u]];if(l===void 0)throw new SyntaxError(`Non-${i} character`);c=c<<r|l,a+=r,a>=8&&(a-=8,o[h++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},rI=(t,e,r)=>{const i=e[e.length-1]==="=",s=(1<<r)-1;let n="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>r;)o-=r,n+=e[s&a>>o];if(o&&(n+=e[s&a<<r-o]),i)for(;n.length*r&7;)n+="=";return n},Oe=({name:t,prefix:e,bitsPerChar:r,alphabet:i})=>Vs({prefix:e,name:t,encode(s){return rI(s,i,r)},decode(s){return tI(s,i,r,t)}}),iI=Vs({prefix:"\0",name:"identity",encode:t=>J_(t),decode:t=>Y_(t)});var sI=Object.freeze({__proto__:null,identity:iI});const nI=Oe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var oI=Object.freeze({__proto__:null,base2:nI});const aI=Oe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var cI=Object.freeze({__proto__:null,base8:aI});const hI=Vi({prefix:"9",name:"base10",alphabet:"0123456789"});var uI=Object.freeze({__proto__:null,base10:hI});const lI=Oe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),dI=Oe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var pI=Object.freeze({__proto__:null,base16:lI,base16upper:dI});const fI=Oe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),gI=Oe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),yI=Oe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),mI=Oe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),wI=Oe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),bI=Oe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),vI=Oe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),EI=Oe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),_I=Oe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var II=Object.freeze({__proto__:null,base32:fI,base32upper:gI,base32pad:yI,base32padupper:mI,base32hex:wI,base32hexupper:bI,base32hexpad:vI,base32hexpadupper:EI,base32z:_I});const $I=Vi({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),DI=Vi({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var SI=Object.freeze({__proto__:null,base36:$I,base36upper:DI});const OI=Vi({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),PI=Vi({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var AI=Object.freeze({__proto__:null,base58btc:OI,base58flickr:PI});const xI=Oe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
38+/",bitsPerChar:6}),CI=Oe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),TI=Oe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),RI=Oe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var NI=Object.freeze({__proto__:null,base64:xI,base64pad:CI,base64url:TI,base64urlpad:RI});const id=Array.from("ððªâð°ðððððððððððððâð»ð¥ð¾ð¿ðâ¤ðð¤£ððððððð
ððð¥ð¥°ðððð¢ð¤ðððªðâºðð¤ððððð¹ð¤¦ððââ¨ð¤·ð±ðð¸ððððððððð¤©ððð¤ðð¯ððð¶ðð¤â£ððððªðð¥ððð©ð¡ð¤ªðð¥³ð¥ð¤¤ððð³âððð´ðð¬ððð·ð»ðââ
ð¥ºððð¤ð¦âð£ððâ¹ððð âððºðð»ððððð¹ð£ð«ðððµð¤ðð´ð¤ð¼ð«â½ð¤âðð¤«ðð®ðð»ðð¶ðð²ð¿ð§¡ðâ¡ððââðð°ð¤¨ð¶ð¤ð¶ð°ðð¢ð¤ðð¨ð¨ð¤¬âððºð¤ððð±ðð¶ð¥´â¶â¡âðð¸â¬ð¨ðð¦ð·ðºâ ð
ððµðð¤²ð¤ ð¤§ððµð
ð§ð¾ððð¤ðð¤¯ð·âð§ð¯ððð¤ððâð´ð£ð¸ððð¥ð¤¢ð
ð¡ð©ðð¸ð»ð¤ð¤®ð¼ð¥µð©ððð¼ðð£ð¥"),BI=id.reduce((t,e,r)=>(t[r]=e,t),[]),jI=id.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function UI(t){return t.reduce((e,r)=>(e+=BI[r],e),"")}function FI(t){const e=[];for(const r of t){const i=jI[r.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(i)}return new Uint8Array(e)}const LI=Vs({prefix:"ð",name:"base256emoji",encode:UI,decode:FI});var MI=Object.freeze({__proto__:null,base256emoji:LI}),qI=sd,ah=128,kI=127,zI=~kI,HI=Math.pow(2,31);function sd(t,e,r){e=e||[],r=r||0;for(var i=r;t>=HI;)e[r++]=t&255|ah,t/=128;for(;t&zI;)e[r++]=t&255|ah,t>>>=7;return e[r]=t|0,sd.bytes=r-i+1,e}var VI=po,KI=128,ch=127;function po(t,i){var r=0,i=i||0,s=0,n=i,o,a=t.length;do{if(n>=a)throw po.bytes=0,new RangeError("Could not decode varint");o=t[n++],r+=s<28?(o&ch)<<s:(o&ch)*Math.pow(2,s),s+=7}while(o>=KI);return po.bytes=n-i,r}var WI=Math.pow(2,7),GI=Math.pow(2,14),YI=Math.pow(2,21),JI=Math.pow(2,28),ZI=Math.pow(2,35),QI=Math.pow(2,42),XI=Math.pow(2,49),e2=Math.pow(2,56),t2=Math.pow(2,63),r2=function(t){return t<WI?1:t<GI?2:t<YI?3:t<JI?4:t<ZI?5:t<QI?6:t<XI?7:t<e2?8:t<t2?9:10},i2={encode:qI,decode:VI,encodingLength:r2},nd=i2;const hh=(t,e,r=0)=>(nd.encode(t,e,r),e),uh=t=>nd.encodingLength(t),fo=(t,e)=>{const r=e.byteLength,i=uh(t),s=i+uh(r),n=new Uint8Array(s+r);return hh(t,n,0),hh(r,n,i),n.set(e,s),new s2(t,r,e,n)};class s2{constructor(e,r,i,s){this.code=e,this.size=r,this.digest=i,this.bytes=s}}const od=({name:t,code:e,encode:r})=>new n2(t,e,r);class n2{constructor(e,r,i){this.name=e,this.code=r,this.encode=i}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?fo(this.code,r):r.then(i=>fo(this.code,i))}else throw Error("Unknown type, must be binary type")}}const ad=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),o2=od({name:"sha2-256",code:18,encode:ad("SHA-256")}),a2=od({name:"sha2-512",code:19,encode:ad("SHA-512")});var c2=Object.freeze({__proto__:null,sha256:o2,sha512:a2});const cd=0,h2="identity",hd=td,u2=t=>fo(cd,hd(t)),l2={code:cd,name:h2,encode:hd,digest:u2};var d2=Object.freeze({__proto__:null,identity:l2});new TextEncoder,new TextDecoder;const lh={...sI,...oI,...cI,...uI,...pI,...II,...SI,...AI,...NI,...MI};({...c2,...d2});function p2(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function ud(t,e,r,i){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:i}}}const dh=ud("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Dn=ud("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=p2(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),f2={utf8:dh,"utf-8":dh,hex:lh.base16,latin1:Dn,ascii:Dn,binary:Dn,...lh};function g2(t,e="utf8"){const r=f2[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t,"utf8"):r.decoder.decode(`${r.prefix}${t}`)}var y2=Object.defineProperty,m2=(t,e,r)=>e in t?y2(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,gt=(t,e,r)=>m2(t,typeof e!="symbol"?e+"":e,r);class w2{constructor(e,r){this.core=e,this.logger=r,gt(this,"keychain",new Map),gt(this,"name",m_),gt(this,"version",w_),gt(this,"initialized",!1),gt(this,"storagePrefix",It),gt(this,"init",async()=>
vendor: 4,254 bytes, line 38
38{if(!this.initialized){const i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}}),gt(this,"has",i=>(this.isInitialized(),this.keychain.has(i))),gt(this,"set",async(i,s)=>{this.isInitialized(),this.keychain.set(i,s),await this.persist()}),gt(this,"get",i=>{this.isInitialized();const s=this.keychain.get(i);if(typeof s>"u"){const{message:n}=B("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(n)}return s}),gt(this,"del",async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()}),this.core=e,this.logger=Ne(r,this.name)}get context(){return qe(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,Gn(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Yn(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=B("NOT_INITIALIZED",this.name);throw new Error(e)}}}var b2=Object.defineProperty,v2=(t,e,r)=>e in t?b2(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ie=(t,e,r)=>v2(t,typeof e!="symbol"?e+"":e,r);class E2{constructor(e,r,i){this.core=e,this.logger=r,Ie(this,"name",g_),Ie(this,"keychain"),Ie(this,"randomSessionIdentifier",no()),Ie(this,"initialized",!1),Ie(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)}),Ie(this,"hasKeys",s=>(this.isInitialized(),this.keychain.has(s))),Ie(this,"getClientId",async()=>{this.isInitialized();const s=await this.getClientSeed(),n=Wa(s);return Ku(n.publicKey)}),Ie(this,"generateKeyPair",()=>{this.isInitialized();const s=e0();return this.setPrivateKey(s.publicKey,s.privateKey)}),Ie(this,"signJWT",async s=>{this.isInitialized();const n=await this.getClientSeed(),o=Wa(n),a=this.randomSessionIdentifier;return await mm(a,s,y_,o)}),Ie(this,"generateSharedKey",(s,n,o)=>{this.isInitialized();const a=this.getPrivateKey(s),c=t0(a,n);return this.setSymKey(c,o)}),Ie(this,"setSymKey",async(s,n)=>{this.isInitialized();const o=n||ls(s);return await this.keychain.set(o,s),o}),Ie(this,"deleteKeyPair",async s=>{this.isInitialized(),await this.keychain.del(s)}),Ie(this,"deleteSymKey",async s=>{this.isInitialized(),await this.keychain.del(s)}),Ie(this,"encode",async(s,n,o)=>{this.isInitialized();const a=Bl(o),c=Bt(n);if(Cc(a))return s0(c,o==null?void 0:o.encoding);if(xc(a)){const d=a.senderPublicKey,f=a.receiverPublicKey;s=await this.generateSharedKey(d,f)}const h=this.getSymKey(s),{type:u,senderPublicKey:l}=a;return r0({type:u,symKey:h,message:c,senderPublicKey:l,encoding:o==null?void 0:o.encoding})}),Ie(this,"decode",async(s,n,o)=>{this.isInitialized();const a=o0(n,o);if(Cc(a)){const c=n0(n,o==null?void 0:o.encoding);return nr(c)}if(xc(a)){const c=a.receiverPublicKey,h=a.senderPublicKey;s=await this.generateSharedKey(c,h)}try{const c=this.getSymKey(s),h=i0({symKey:c,encoded:n,encoding:o==null?void 0:o.encoding});return nr(h)}catch(c){this.logger.error(`Failed to decode message from topic: '${s}', clientId: '${await this.getClientId()}'`),this.logger.error(c)}}),Ie(this,"getPayloadType",(s,n=ut)=>{const o=Oi({encoded:s,encoding:n});return cr(o.type)}),Ie(this,"getPayloadSenderPublicKey",(s,n=ut)=>{const o=Oi({encoded:s,encoding:n});return o.senderPublicKey?Me(o.senderPublicKey,Re):void 0}),this.core=e,this.logger=Ne(r,this.name),this.keychain=i||new w2(this.core,this.logger)}get context(){return qe(this.logger)}async setPrivateKey(e,r){return await this.keychain.set(e,r),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(sh)}catch{e=no(),await this.keychain.set(sh,e)}return g2(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=B("NOT_INITIALIZED",this.name);throw new Error(e)}}}var _2=Object.defineProperty,I2=Object.defineProperties,$2=Object.getOwnPropertyDescriptors,ph=Object.getOwnPropertySymbols,D2=Object.prototype.hasOwnProperty,S2=Object.prototype.propertyIsEnumerable,go=(t,e,r)=>e in t?_2(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,O2=(t,e)=>{for(var r in e||(e={}))D2.call(e,r)&&go(t,r,e[r]);
38if(ph)for(var r of ph(e))S2.call(e,r)&&go(t,r,e[r]);return t},P2=(t,e)=>I2(t,$2(e)),ke=(t,e,r)=>go(t,typeof e!="symbol"?e+"":e,r);class A2 extends lE{constructor(e,r){super(e,r),this.logger=e,this.core=r,ke(this,"messages",new Map),ke(this,"messagesWithoutClientAck",new Map),ke(this,"name",b_),ke(this,"version",v_),ke(this,"initialized",!1),ke(this,"storagePrefix",It),ke(this,"init",async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i);const s=await this.getRelayerMessagesWithoutClientAck();typeof s<"u"&&(this.messagesWithoutClientAck=s),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i)}finally{this.initialized=!0}}}),ke(this,"set",async(i,s,n)=>{this.isInitialized();const o=Et(s);let a=this.messages.get(i);if(typeof a>"u"&&(a={}),typeof a[o]<"u")return o;if(a[o]=s,this.messages.set(i,a),n===fs.inbound){const c=this.messagesWithoutClientAck.get(i)||{};this.messagesWithoutClientAck.set(i,P2(O2({},c),{[o]:s}))}return await this.persist(),o}),ke(this,"get",i=>{this.isInitialized();let s=this.messages.get(i);return typeof s>"u"&&(s={}),s}),ke(this,"getWithoutAck",i=>{this.isInitialized();const s={};for(const n of i){const o=this.messagesWithoutClientAck.get(n)||{};s[n]=Object.values(o)}return s}),ke(this,"has",(i,s)=>{this.isInitialized();const n=this.get(i),o=Et(s);return typeof n[o]<"u"}),ke(this,"ack",async(i,s)=>{this.isInitialized();const n=this.messagesWithoutClientAck.get(i);if(typeof n>"u")return;const o=Et(s);delete n[o],Object.keys(n).length===0?this.messagesWithoutClientAck.delete(i):this.messagesWithoutClientAck.set(i,n),await this.persist()}),ke(this,"del",async i=>{this.isInitialized(),this.messages.delete(i),this.messagesWithoutClientAck.delete(i),await this.persist()}),this.logger=Ne(e,this.name),this.core=r}get context(){return qe(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get storageKeyWithoutClientAck(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name+"_withoutClientAck"}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,Gn(e))}async setRelayerMessagesWithoutClientAck(e){await this.core.storage.setItem(this.storageKeyWithoutClientAck,Gn(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Yn(e):void 0}async getRelayerMessagesWithoutClientAck(){const e=await this.core.storage.getItem(this.storageKeyWithoutClientAck);return typeof e<"u"?Yn(e):void 0}async persist(){await this.setRelayerMessages(this.messages),await this.setRelayerMessagesWithoutClientAck(this.messagesWithoutClientAck)}isInitialized(){if(!this.initialized){const{message:e}=B("NOT_INITIALIZED",this.name);throw new Error(e)}}}var x2=Object.defineProperty,C2=Object.defineProperties,T2=Object.getOwnPropertyDescriptors,fh=Object.getOwnPropertySymbols,R2=Object.prototype.hasOwnProperty,N2=Object.prototype.propertyIsEnumerable,yo=(t,e,r)=>e in t?x2(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,is=(t,e)=>{for(var r in e||(e={}))R2.call(e,r)&&yo(t,r,e[r]);if(fh)for(var r of fh(e))N2.call(e,r)&&yo(t,r,e[r]);return t},Sn=(t,e)=>C2(t,T2(e)),ct=(t,e,r)=>yo(t,typeof e!="symbol"?e+"":e,r);class B2 extends dE{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,ct(this,"events",new rt.EventEmitter),ct(this,"name",E_),ct(this,"queue",new Map),ct(this,"publishTimeout",N.toMiliseconds(N.ONE_MINUTE)),ct(this,"initialPublishTimeout",N.toMiliseconds(N.ONE_SECOND*15)),ct(this,"needsTransportRestart",!1),ct(this,"publish",async(i,s,n)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:s,opts:n}});const a=(n==null?void 0:n.ttl)||nh,c=Es(n),h=(n==null?void 0:n.prompt)||!1,u=(n==null?void 0:n.tag)||0,l=(n==null?void 0:n.id)||rr().toString(),d={topic:i,message:s,opts:{ttl:a,relay:c,prompt:h,tag:u,id:l,attestation:n==null?void 0:n.attestation,tvf:n==null?void 0:n.tvf}},f=`Failed to publish payload, please try again. id:${l} tag:${u}`;try{const p=new Promise(async y=>{const w=({id:b})=>{d.opts.id===b&&(this.removeRequestFromQueue(b),this.relayer.events.removeListener(we.publish,w),y(d))};this.relayer.events.on(we.publish,w);const v=kt(new Promise((b,E)=>{this.rpcPublish({topic:i,message:s,ttl:a,prompt:h,tag:u,id:l,attestation:n==null?void 0:n.attestation,tvf:n==null?void 0:n.tvf}).then(b).catch(I=>{this.logger.warn(I,I==null?void 0:I.message),E(I)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${l} tag:${u}`);try{await v,this.events.removeListener(we.publish,w)}catch(b){this.queue.set(l,Sn(is({},d),{attempt:1})),this.logger.warn(b,b==null?void 0:b.message)}});this.logger.trace({type:"method",method:"publish",params:{id:l,topic:i,message:s,opts:n}}),await kt(p,this.publishTimeout,f)}catch(p){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(p),(o=n==null?void 0:n.internal)!=null&&o.throwOnFailedPublish)throw p}finally{this.queue.delete(l)}}),ct(this,"on",(i,s)=>{this.events.on(i,s)}),ct(this,"once",(i,s)=>{this.events.once(i,s)}),ct(this,"off",(i,s)=>{this.events.off(i,s)}),ct(this,"removeListener",(i,s)=>{this.events.removeListener(i,s)}),this.relayer=e,this.logger=Ne(r,this.name),this.registerEventListeners()}get context(){return qe(this.logger)}async rpcPublish(e){var r,i,s,n;const{topic:o,message:a,ttl:c=nh,prompt:h,tag:u,id:l,attestation:d,tvf:f}=e,p={method:pi(Es().protocol).publish,params:is({topic:o,message:a,ttl:c,prompt:h,tag:u,attestation:d},f),id:l};xe((r=p.params)==null?void 0:r.prompt)&&((i=p.params)==null||delete i.prompt),xe((s=p.params)==null?void 0:s.tag)&&((n=p.params)==null||delete n.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:p});const y=await this.relayer.request(p);return this.relayer.events.emit(we.publish,e),this.logger.debug("Successfully Published Payload"),y}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,r)=>{const i=e.attempt+1;this.queue.set(r,Sn(is({},e),{attempt:i}));const{topic:s,message:n,opts:o,attestation:a}=e;this.logger.warn({},`Publisher: queue->publishing: ${e.opts.id}, tag: ${e.opts.tag}, attempt: ${i}`),await this.rpcPublish(Sn(is({},e),{topic:s,message:n,ttl:o.ttl,prompt:o.prompt,tag:o.tag,id:o.id,attestation:a,tvf:o.tvf})),this.logger.warn({},`Publisher: queue->published: ${e.opts.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(ti.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(we.connection_stalled);return}this.checkQueue()}),this.relayer.on(we.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}var j2=Object.defineProperty,U2=(t,e,r)=>e in t?j2(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,_r=(t,e,r)=>U2(t,typeof e!="symbol"?e+"":e,r);class F2{constructor(){_r(this,"map",new Map),_r(this,"set",(e,r)=>{const i=this.get(e);this.exists(e,r)||this.map.set(e,[...i,r])}),_r(this,"get",e=>this.map.get(e)||[]),_r(this,"exists",(e,r)=>this.get(e).includes(r)),_r(this,"delete",(e,r)=>{if(typeof r>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const i=this.get(e);if(!this.exists(e,r))return;const s=i.filter(n=>n!==r);if(!s.length){this.map.delete(e);return}this.map.set(e,s)}),_r(this,"clear",()=>{this.map.clear()})}
vendor: 9,585 bytes, line 38
38get topics(){return Array.from(this.map.keys())}}var L2=Object.defineProperty,M2=Object.defineProperties,q2=Object.getOwnPropertyDescriptors,gh=Object.getOwnPropertySymbols,k2=Object.prototype.hasOwnProperty,z2=Object.prototype.propertyIsEnumerable,mo=(t,e,r)=>e in t?L2(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,li=(t,e)=>{for(var r in e||(e={}))k2.call(e,r)&&mo(t,r,e[r]);if(gh)for(var r of gh(e))z2.call(e,r)&&mo(t,r,e[r]);return t},On=(t,e)=>M2(t,q2(e)),re=(t,e,r)=>mo(t,typeof e!="symbol"?e+"":e,r);class H2 extends gE{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,re(this,"subscriptions",new Map),re(this,"topicMap",new F2),re(this,"events",new rt.EventEmitter),re(this,"name",P_),re(this,"version",A_),re(this,"pending",new Map),re(this,"cached",[]),re(this,"initialized",!1),re(this,"storagePrefix",It),re(this,"subscribeTimeout",N.toMiliseconds(N.ONE_MINUTE)),re(this,"initialSubscribeTimeout",N.toMiliseconds(N.ONE_SECOND*15)),re(this,"clientId"),re(this,"batchSubscribeTopicsLimit",500),re(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0}),re(this,"subscribe",async(i,s)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:s}});try{const n=Es(s),o={topic:i,relay:n,transportType:s==null?void 0:s.transportType};this.pending.set(i,o);const a=await this.rpcSubscribe(i,n,s);return typeof a=="string"&&(this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:s}})),a}catch(n){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(n),n}}),re(this,"unsubscribe",async(i,s)=>{this.isInitialized(),typeof(s==null?void 0:s.id)<"u"?await this.unsubscribeById(i,s.id,s):await this.unsubscribeByTopic(i,s)}),re(this,"isSubscribed",i=>new Promise(s=>{s(this.topicMap.topics.includes(i))})),re(this,"isKnownTopic",i=>new Promise(s=>{s(this.topicMap.topics.includes(i)||this.pending.has(i)||this.cached.some(n=>n.topic===i))})),re(this,"on",(i,s)=>{this.events.on(i,s)}),re(this,"once",(i,s)=>{this.events.once(i,s)}),re(this,"off",(i,s)=>{this.events.off(i,s)}),re(this,"removeListener",(i,s)=>{this.events.removeListener(i,s)}),re(this,"start",async()=>{await this.onConnect()}),re(this,"stop",async()=>{await this.onDisconnect()}),re(this,"restart",async()=>{await this.restore(),await this.onRestart()}),re(this,"checkPending",async()=>{if(this.pending.size===0&&(!this.initialized||!this.relayer.connected))return;const i=[];this.pending.forEach(s=>{i.push(s)}),await this.batchSubscribe(i)}),re(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(ti.pulse,async()=>{await this.checkPending()}),this.events.on(He.created,async i=>{const s=He.created;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:i}),await this.persist()}),this.events.on(He.deleted,async i=>{const s=He.deleted;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:i}),await this.persist()})}),this.relayer=e,this.logger=Ne(r,this.name),this.clientId=""}get context(){return qe(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}get hasAnyTopics(){return this.topicMap.topics.length>0||this.pending.size>0||this.cached.length>0||this.subscriptions.size>0}hasSubscription(e,r){let i=!1;try{i=this.getSubscription(e).topic===r}catch{}return i}reset(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,r){const i=this.topicMap.get(e);await Promise.all(i.map(async s=>await this.unsubscribeById(e,s,r)))}async unsubscribeById(e,r,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:i}});try{const s=Es(i);await this.restartToComplete({topic:e,id:r,relay:s}),await this.rpcUnsubscribe(e,r,s);const n=te("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,r,n),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:i}})}catch(s){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(s),s}}async rpcSubscribe(e,r,i){var s;(!i||(i==null?void 0:i.transportType)===ae.relay)&&await this.restartToComplete({topic:e,id:e,relay:r});const n={method:pi(r.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});const o=(s=i==null?void 0:i.internal)==null?void 0:s.throwOnFailedPublish;try{const a=await this.getSubscriptionId(e);if((i==null?void 0:i.transportType)===ae.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(n).catch(u=>this.logger.warn(u))},N.toMiliseconds(N.ONE_SECOND)),a;const c=new Promise(async u=>{const l=d=>{d.topic===e&&(this.events.removeListener(He.created,l),u(d.id))};this.events.on(He.created,l);try{const d=await kt(new Promise((f,p)=>{this.relayer.request(n).catch(y=>{this.logger.warn(y,y==null?void 0:y.message),p(y)}).then(f)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(He.created,l),u(d)}catch{}}),h=await kt(c,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!h&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return h?a:null}catch(a){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(we.connection_stalled),o)throw a}return null}async rpcBatchSubscribe(e){if(!e.length)return;const r=e[0].relay,i={method:pi(r.protocol).batchSubscribe,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{await await kt(new Promise(s=>{this.relayer.request(i).catch(n=>this.logger.warn(n)).then(s)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(we.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const r=e[0].relay,i={method:pi(r.protocol).batchFetchMessages,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let s;try{s=await await kt(new Promise((n,o)=>{this.relayer.request(i).catch(a=>{this.logger.warn(a),o(a)}).then(n)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(we.connection_stalled)}return s}rpcUnsubscribe(e,r,i){const s={method:pi(i.protocol).unsubscribe,params:{topic:e,id:r}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s}),this.relayer.request(s)}onSubscribe(e,r){this.setSubscription(e,On(li({},r),{id:e})),this.pending.delete(r.topic)}onBatchSubscribe(e){e.length&&e.forEach(r=>{this.setSubscription(r.id,li({},r)),this.pending.delete(r.topic)})}async onUnsubscribe(e,r,i){this.events.removeAllListeners(r),this.hasSubscription(r,e)&&this.deleteSubscription(r,i),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,r){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:r}),this.addSubscription(e,r)}addSubscription(e,r){this.subscriptions.set(e,li({},r)),this.topicMap.set(r.topic,e),this.events.emit(He.created,r)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const r=this.subscriptions.get(e);if(!r){const{message:i}=B("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return r}deleteSubscription(e,r){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:r});const i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(He.deleted,On(li({},i),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(He.sync)}async onRestart(){if(this.cached.length){const e=[...this.cached],r=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let i=0;i<r;i++){const s=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(s)}}this.events.emit(He.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:r}=B("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){e.length&&(await this.rpcBatchSubscribe(e),this.onBatchSubscribe(await Promise.all(e.map(async r=>On(li({}
38,r),{id:await this.getSubscriptionId(r.topic)})))))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const r=await this.rpcBatchFetchMessages(e);r&&r.messages&&(await qw(N.toMiliseconds(N.ONE_SECOND)),await this.relayer.handleBatchMessageEvents(r.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){const{message:e}=B("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(e){!this.relayer.connected&&!this.relayer.connecting&&(this.cached.push(e),await this.relayer.transportOpen())}async getClientId(){return this.clientId||(this.clientId=await this.relayer.core.crypto.getClientId()),this.clientId}async getSubscriptionId(e){return Et(e+await this.getClientId())}}var V2=Object.defineProperty,yh=Object.getOwnPropertySymbols,K2=Object.prototype.hasOwnProperty,W2=Object.prototype.propertyIsEnumerable,wo=(t,e,r)=>e in t?V2(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,mh=(t,e)=>{for(var r in e||(e={}))K2.call(e,r)&&wo(t,r,e[r]);if(yh)for(var r of yh(e))W2.call(e,r)&&wo(t,r,e[r]);return t},Z=(t,e,r)=>wo(t,typeof e!="symbol"?e+"":e,r);class G2 extends pE{constructor(e){super(e),Z(this,"protocol","wc"),Z(this,"version",2),Z(this,"core"),Z(this,"logger"),Z(this,"events",new rt.EventEmitter),Z(this,"provider"),Z(this,"messages"),Z(this,"subscriber"),Z(this,"publisher"),Z(this,"name",I_),Z(this,"transportExplicitlyClosed",!1),Z(this,"initialized",!1),Z(this,"connectionAttemptInProgress",!1),Z(this,"relayUrl"),Z(this,"projectId"),Z(this,"packageName"),Z(this,"bundleId"),Z(this,"hasExperiencedNetworkDisruption",!1),Z(this,"pingTimeout"),Z(this,"heartBeatTimeout",N.toMiliseconds(N.THIRTY_SECONDS+N.FIVE_SECONDS)),Z(this,"reconnectTimeout"),Z(this,"connectPromise"),Z(this,"reconnectInProgress",!1),Z(this,"requestsInFlight",[]),Z(this,"connectTimeout",N.toMiliseconds(N.ONE_SECOND*15)),Z(this,"request",async r=>{var i,s;this.logger.debug("Publishing Request Payload");const n=r.id||rr().toString();await this.toEstablishConnection();try{this.logger.trace({id:n,method:r.method,topic:(i=r.params)==null?void 0:i.topic},"relayer.request - publishing...");const o=`${n}:${((s=r.params)==null?void 0:s.tag)||""}`;this.requestsInFlight.push(o);const a=await this.provider.request(r);return this.requestsInFlight=this.requestsInFlight.filter(c=>c!==o),a}catch(o){throw this.logger.debug(`Failed to Publish Request: ${n}`),o}}),Z(this,"resetPingTimeout",()=>{bs()&&(clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var r,i,s,n;try{this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),(n=(s=(i=(r=this.provider)==null?void 0:r.connection)==null?void 0:i.socket)==null?void 0:s.terminate)==null||n.call(s)}catch(o){this.logger.warn(o,o==null?void 0:o.message)}},this.heartBeatTimeout))}),Z(this,"onPayloadHandler",r=>{this.onProviderPayload(r),this.resetPingTimeout()}),Z(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected ð"),this.startPingTimeout(),this.events.emit(we.connect)}),Z(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected ð"),this.requestsInFlight=[],this.onProviderDisconnect()}),Z(this,"onProviderErrorHandler",r=>{this.logger.fatal(`Fatal socket error: ${r.message}`),this.events.emit(we.error,r),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()}),Z(this,"registerProviderListeners",()=>{this.provider.on(Ze.payload,this.onPayloadHandler),this.provider.on(Ze.connect,this.onConnectHandler),this.provider.on(Ze.disconnect,this.onDisconnectHandler),this.provider.on(Ze.error,this.onProviderErrorHandler)}),this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?Ne(e.logger,this.name):zi(qs({level:e.logger||__})),this.messages=new A2(this.logger,e.core),this.subscriber=new H2(this,this.logger),this.publisher=new B2(this,this.logger),this.relayUrl=(e==null?void 0:e.relayUrl)||Xl,this.projectId=e.projectId,Dw()?this.packageName=ec():Sw()&&(this.bundleId=ec()),this.provider={}}
38async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.hasAnyTopics)try{await this.transportOpen()}catch(e){this.logger.warn(e,e==null?void 0:e.message)}}get context(){return qe(this.logger)}get connected(){var e,r,i;return((i=(r=(e=this.provider)==null?void 0:e.connection)==null?void 0:r.socket)==null?void 0:i.readyState)===1||!1}get connecting(){var e,r,i;return((i=(r=(e=this.provider)==null?void 0:e.connection)==null?void 0:r.socket)==null?void 0:i.readyState)===0||this.connectPromise!==void 0||!1}async publish(e,r,i){this.isInitialized(),await this.publisher.publish(e,r,i),await this.recordMessageEvent({topic:e,message:r,publishedAt:Date.now(),transportType:ae.relay},fs.outbound)}async subscribe(e,r){var i,s,n;this.isInitialized(),(!(r!=null&&r.transportType)||(r==null?void 0:r.transportType)==="relay")&&await this.toEstablishConnection();const o=typeof((i=r==null?void 0:r.internal)==null?void 0:i.throwOnFailedPublish)>"u"?!0:(s=r==null?void 0:r.internal)==null?void 0:s.throwOnFailedPublish;let a=((n=this.subscriber.topicMap.get(e))==null?void 0:n[0])||"",c;const h=u=>{u.topic===e&&(this.subscriber.off(He.created,h),c())};return await Promise.all([new Promise(u=>{c=u,this.subscriber.on(He.created,h)}),new Promise(async(u,l)=>{a=await this.subscriber.subscribe(e,mh({internal:{throwOnFailedPublish:o}},r)).catch(d=>{o&&l(d)})||a,u()})]),a}async unsubscribe(e,r){this.isInitialized(),await this.subscriber.unsubscribe(e,r)}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await kt(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){if(!this.subscriber.hasAnyTopics){this.logger.warn("Starting WS connection skipped because the client has no topics to work with.");return}if(this.connectPromise?(this.logger.debug({},"Waiting for existing connection attempt to resolve..."),await this.connectPromise,this.logger.debug({},"Existing connection attempt resolved")):(this.connectPromise=new Promise(async(r,i)=>{await this.connect(e).then(r).catch(i).finally(()=>{this.connectPromise=void 0})}),await this.connectPromise),!this.connected)throw new Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}async restartTransport(e){this.logger.debug({},"Restarting transport..."),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await Lc())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if((e==null?void 0:e.length)===0){this.logger.trace("Batch message events is empty. Ignoring...");return}const r=e.sort((i,s)=>i.publishedAt-s.publishedAt);this.logger.debug(`Batch of ${r.length} message events sorted`);for(const i of r)try{await this.onMessageEvent(i)}catch(s){this.logger.warn(s,"Error while processing batch message event: "+(s==null?void 0:s.message))}this.logger.trace(`Batch of ${r.length} message events processed`)}async onLinkMessageEvent(e,r){const{topic:i}=e;if(!r.sessionExists){const s=de(N.FIVE_MINUTES),n={topic:i,expiry:s,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,n)}this.events.emit(we.message,e),await this.recordMessageEvent(e,fs.inbound)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let r=1;for(;r<6;){try{if(this.transportExplicitlyClosed)break;this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${r}...`),await this.createProvider(),await new Promise(async(i,s)=>{const n=()=>
vendor: 20,520 bytes, line 38
38{s(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(Ze.disconnect,n),await kt(new Promise((o,a)=>{this.provider.connect().then(o).catch(a)}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(o=>{s(o)}).finally(()=>{this.provider.off(Ze.disconnect,n),clearTimeout(this.reconnectTimeout)}),await new Promise(async(o,a)=>{const c=()=>{a(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(Ze.disconnect,c),await this.subscriber.start().then(o).catch(a).finally(()=>{this.provider.off(Ze.disconnect,c)})}),this.hasExperiencedNetworkDisruption=!1,i()})}catch(i){await this.subscriber.stop();const s=i;this.logger.warn({},s.message),this.hasExperiencedNetworkDisruption=!0}finally{this.connectionAttemptInProgress=!1}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${r}`);break}await new Promise(i=>setTimeout(i,N.toMiliseconds(r*1))),r++}}startPingTimeout(){var e,r,i,s,n;if(bs())try{(r=(e=this.provider)==null?void 0:e.connection)!=null&&r.socket&&((n=(s=(i=this.provider)==null?void 0:i.connection)==null?void 0:s.socket)==null||n.on("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o,o==null?void 0:o.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new it(new l_(Cw({sdkVersion:lo,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId,packageName:this.packageName}))),this.registerProviderListeners()}async recordMessageEvent(e,r){const{topic:i,message:s}=e;await this.messages.set(i,s,r)}async shouldIgnoreMessageEvent(e){const{topic:r,message:i}=e;if(!i||i.length===0)return this.logger.warn(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isKnownTopic(r))return this.logger.warn(`Ignoring message for unknown topic ${r}`),!0;const s=this.messages.has(r,i);return s&&this.logger.warn(`Ignoring duplicate message: ${i}`),s}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Jo(e)){if(!e.method.endsWith($_))return;const r=e.params,{topic:i,message:s,publishedAt:n,attestation:o}=r.data,a={topic:i,message:s,publishedAt:n,transportType:ae.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(mh({type:"event",event:r.id},a)),this.events.emit(r.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else Hs(e)&&this.events.emit(we.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(await this.recordMessageEvent(e,fs.inbound),this.events.emit(we.message,e))}async acknowledgePayload(e){const r=ks(e.id,!0);await this.provider.connection.send(r)}unregisterProviderListeners(){this.provider.off(Ze.payload,this.onPayloadHandler),this.provider.off(Ze.connect,this.onConnectHandler),this.provider.off(Ze.disconnect,this.onDisconnectHandler),this.provider.off(Ze.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await Lc();V0(async r=>{e!==r&&(e=r,r?await this.transportOpen().catch(i=>this.logger.error(i,i==null?void 0:i.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){clearTimeout(this.pingTimeout),this.events.emit(we.disconnect),this.connectionAttemptInProgress=!1,!this.reconnectInProgress&&(this.reconnectInProgress=!0,await this.subscriber.stop(),this.subscriber.hasAnyTopics&&(this.transportExplicitlyClosed||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e,e==null?void 0:e.message)),this.reconnectTimeout=void 0,this.reconnectInProgress=!1},N.toMiliseconds(D_)))))}isInitialized(){if(!this.initialized){const{message:e}=B("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&await this.connect()}}function Y2(){}function wh(t){if(!t||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);return e===null||e===Object.prototype||Object.getPrototypeOf(e)===null?Object.prototype.toString.call(t)==="[object Object]":!1}function bh(t){return Object.getOwnPropertySymbols(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}function vh(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const J2="[object RegExp]",Z2="[object String]",Q2="[object Number]",X2="[object Boolean]",Eh="[object Arguments]",e$="[object Symbol]",t$="[object Date]",r$="[object Map]",i$="[object Set]",s$="[object Array]",n$="[object Function]",o$="[object ArrayBuffer]",Pn="[object Object]",a$="[object Error]",c$="[object DataView]",h$="[object Uint8Array]",u$="[object Uint8ClampedArray]",l$="[object Uint16Array]",d$="[object Uint32Array]",p$="[object BigUint64Array]",f$="[object Int8Array]",g$="[object Int16Array]",y$="[object Int32Array]",m$="[object BigInt64Array]",w$="[object Float32Array]",b$="[object Float64Array]";function v$(t,e){return t===e||Number.isNaN(t)&&Number.isNaN(e)}function E$(t,e,r){return gi(t,e,void 0,void 0,void 0,void 0,r)}function gi(t,e,r,i,s,n,o){const a=o(t,e,r,i,s,n);if(a!==void 0)return a;if(typeof t==typeof e)switch(typeof t){case"bigint":case"string":case"boolean":case"symbol":case"undefined":return t===e;case"number":return t===e||Object.is(t,e);case"function":return t===e;case"object":return vi(t,e,n,o)}return vi(t,e,n,o)}function vi(t,e,r,i){if(Object.is(t,e))return!0;let s=vh(t),n=vh(e);if(s===Eh&&(s=Pn),n===Eh&&(n=Pn),s!==n)return!1;switch(s){case Z2:return t.toString()===e.toString();case Q2:{const c=t.valueOf(),h=e.valueOf();return v$(c,h)}case X2:case t$:case e$:return Object.is(t.valueOf(),e.valueOf());case J2:return t.source===e.source&&t.flags===e.flags;case n$:return t===e}r=r??new Map;const o=r.get(t),a=r.get(e);if(o!=null&&a!=null)return o===e;r.set(t,e),r.set(e,t);try{switch(s){case r$:{if(t.size!==e.size)return!1;for(const[c,h]of t.entries())if(!e.has(c)||!gi(h,e.get(c),c,t,e,r,i))return!1;return!0}case i$:{if(t.size!==e.size)return!1;const c=Array.from(t.values()),h=Array.from(e.values());for(let u=0;u<c.length;u++){const l=c[u],d=h.findIndex(f=>gi(l,f,void 0,t,e,r,i));if(d===-1)return!1;h.splice(d,1)}return!0}case s$:case h$:case u$:case l$:case d$:case p$:case f$:case g$:case y$:case m$:case w$:case b$:{if(typeof Buffer<"u"&&Buffer.isBuffer(t)!==Buffer.isBuffer(e)||t.length!==e.length)return!1;for(let c=0;c<t.length;c++)if(!gi(t[c],e[c],c,t,e,r,i))return!1;return!0}case o$:return t.byteLength!==e.byteLength?!1:vi(new Uint8Array(t),new Uint8Array(e),r,i);case c$:return t.byteLength!==e.byteLength||t.byteOffset!==e.byteOffset?!1:vi(new Uint8Array(t),new Uint8Array(e),r,i);case a$:return t.name===e.name&&t.message===e.message;case Pn:{if(!(vi(t.constructor,e.constructor,r,i)||wh(t)&&wh(e)))return!1;const c=[...Object.keys(t),...bh(t)],h=[...Object.keys(e),...bh(e)];if(c.length!==h.length)return!1;for(let u=0;u<c.length;u++){const l=c[u],d=t[l];if(!Object.hasOwn(e,l))return!1;const f=e[l];if(!gi(d,f,l,t,e,r,i))return!1}return!0}default:return!1}}finally{r.delete(t),r.delete(e)}}function _$(t,e){return E$(t,e,Y2)}var I$=Object.defineProperty,_h=Object.getOwnPropertySymbols,$$=Object.prototype.hasOwnProperty,D$=Object.prototype.propertyIsEnumerable,bo=(t,e,r)=>e in t?I$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ih=(t,e)=>{for(var r in e||(e={}))$$.call(e,r)&&bo(t,r,e[r]);if(_h)for(var r of _h(e))D$.call(e,r)&&bo(t,r,e[r]);return t},je=(t,e,r)=>bo(t,typeof e!="symbol"?e+"":e,r);class dr extends fE{constructor(e,r,i,s=It,n=void 0){super(e,r,i,s),this.core=e,this.logger=r,this.name=i,je(this,"map",new Map),je(this,"version",S_),je(this,"cached",[]),je(this,"initialized",!1),je(this,"getKey"),je(this,"storagePrefix",It),je(this,"recentlyDeleted",[]),je(this,"recentlyDeletedLimit",200),je(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!xe(o)?this.map.set(this.getKey(o),o):_0(o)?this.map.set(o.id,o):I0(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)}),je(this,"set",async(o,a)=>{this.isInitialized(),this.map.has(o)?await this.update(o,a):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:a}),this.map.set(o,a),await this.persist())}),je(this,"get",o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o))),je(this,"getAll",o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(c=>_$(a[c],o[c]))):this.values)),je(this,"update",async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});const c=Ih(Ih({},this.getData(o)),a);this.map.set(o,c),await this.persist()}),je(this,"delete",async(o,a)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:a}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())}),this.logger=Ne(r,this.name),this.storagePrefix=s,this.getKey=n}get context(){return qe(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const r=this.map.get(e);if(!r){if(this.recentlyDeleted.includes(e)){const{message:s}=B("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(s),new Error(s)}const{message:i}=B("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return r}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:r}=B("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=B("NOT_INITIALIZED",this.name);throw new Error(e)}}}var S$=Object.defineProperty,O$=(t,e,r)=>e in t?S$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,K=(t,e,r)=>O$(t,typeof e!="symbol"?e+"":e,r);class P${constructor(e,r){this.core=e,this.logger=r,K(this,"name",x_),K(this,"version",C_),K(this,"events",new Po),K(this,"pairings"),K(this,"initialized",!1),K(this,"storagePrefix",It),K(this,"ignoredPayloadTypes",[Nt]),K(this,"registeredMethods",[]),K(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))}),K(this,"register",({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]}),K(this,"create",async i=>{this.isInitialized();const s=no(),n=await this.core.crypto.setSymKey(s),o=de(N.FIVE_MINUTES),a={protocol:Ql},c={topic:n,expiry:o,relay:a,active:!1,methods:i==null?void 0:i.methods},h=Rc({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:s,relay:a,expiryTimestamp:o,methods:i==null?void 0:i.methods});return this.events.emit(Xt.create,c),this.core.expirer.set(n,o),await this.pairings.set(n,c),await this.core.relayer.subscribe(n,{transportType:i==null?void 0:i.transportType}),{topic:n,uri:h}}),K(this,"pair",async i=>{this.isInitialized();const s=this.core.eventClient.createEvent({properties:{topic:i==null?void 0:i.uri,trace:[mt.pairing_started]}});this.isValidPair(i,s);const{topic:n,symKey:o,relay:a,expiryTimestamp:c,methods:h}=Tc(i.uri);s.props.properties.topic=n,s.addTrace(mt.pairing_uri_validation_success),s.addTrace(mt.pairing_uri_not_expired);let u;if(this.pairings.keys.includes(n)){if(u=this.pairings.get(n),s.addTrace(mt.existing_pairing),u.active)throw s.setError(xt.active_pairing_already_exists),new Error(`Pairing already exists: ${n}. Please try again with a new connection URI.`);s.addTrace(mt.pairing_not_expired)}const l=c||de(N.FIVE_MINUTES),d={topic:n,relay:a,expiry:l,active:!1,methods:h};this.core.expirer.set(n,l),await this.pairings.set(n,d),s.addTrace(mt.store_new_pairing),i.activatePairing&&await this.activate({topic:n}),this.events.emit(Xt.create,d),s.addTrace(mt.emit_inactive_pairing),this.core.crypto.keychain.has(n)||await this.core.crypto.setSymKey(o,n),s.addTrace(mt.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{s.setError(xt.no_internet_connection)}try{await this.core.relayer.subscribe(n,{relay:a})}catch(f){throw s.setError(xt.subscribe_pairing_topic_failure),f}return s.addTrace(mt.subscribe_pairing_topic_success),d}),K(this,"activate",async({topic:i})=>{this.isInitialized();const s=de(N.FIVE_MINUTES);this.core.expirer.set(i,s),await this.pairings.update(i,{active:!0,expiry:s})}),K(this,"ping",async i=>{this.isInitialized(),await this.isValidPing(i),this.logger.warn("ping() is deprecated and will be removed in the next major release.");const{topic:s}=i;if(this.pairings.keys.includes(s)){const n=await this.sendRequest(s,"wc_pairingPing",{}),{done:o,resolve:a,reject:c}=Jt();this.events.once(X("pairing_ping",n),({error:h})=>{h?c(h):a()}),await o()}}),K(this,"updateExpiry",async({topic:i,expiry:s})=>{this.isInitialized(),await this.pairings.update(i,{expiry:s})}),K(this,"updateMetadata",async({topic:i,metadata:s})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:s})}),K(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),K(this,"disconnect",async i=>{this.isInitialized(),await this.isValidDisconnect(i);const{topic:s}=i;this.pairings.keys.includes(s)&&(await this.sendRequest(s,"wc_pairingDelete",te("USER_DISCONNECTED")),await this.deletePairing(s))}),K(this,"formatUriFromPairing",i=>{this.isInitialized();const{topic:s,relay:n,expiry:o,methods:a}=i,c=this.core.crypto.keychain.get(s);return Rc({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:c,relay:n,expiryTimestamp:o,methods:a})}),K(this,"sendRequest",async(i,s,n)=>{const o=zt(s,n),a=await this.core.crypto.encode(i,o),c=hi[s].req;return this.core.history.set(i,o),this.core.relayer.publish(i,a,c),o.id}),K(this,"sendResult",async(i,s,n)=>{const o=ks(i,n),a=await this.core.crypto.encode(s,o),c=(await this.core.history.get(s,i)).request.method,h=hi[c].res;await this.core.relayer.publish(s,a,h),await this.core.history.resolve(o)}),K(this,"sendError",async(i,s,n)=>{const o=zs(i,n),a=await this.core.crypto.encode(s,o),c=(await this.core.history.get(s,i)).request.method,h=hi[c]?hi[c].res:hi.unregistered_method.res;await this.core.relayer.publish(s,a,h),await this.core.history.resolve(o)}),K(this,"deletePairing",async(i,s)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,te("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),s?Promise.resolve():this.core.expirer.del(i)])}),K(this,"cleanup",async()=>{const i=this.pairings.getAll().filter(s=>Mt(s.expiry));await Promise.all(i.map(s=>this.deletePairing(s.topic)))}),K(this,"onRelayEventRequest",async i=>{const{topic:s,payload:n}=i;switch(n.method){case"wc_pairingPing":return await this.onPairingPingRequest(s,n);case"wc_pairingDelete":return await this.onPairingDeleteRequest(s,n);default:return await this.onUnknownRpcMethodRequest(s,n)}}),K(this,"onRelayEventResponse",async i=>{const{topic:s,payload:n}=i,o=(await this.core.history.get(s,n.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(s,n);default:return this.onUnknownRpcMethodResponse(o)}}),K(this,"onPairingPingRequest",async(i,s)=>{const{id:n}=s;try{this.isValidPing({topic:i}),await this.sendResult(n,i,!0),this.events.emit(Xt.ping,{id:n,topic:i})}catch(o){await this.sendError(n,i,o),this.logger.error(o)}}),K(this,"onPairingPingResponse",(i,s)=>{const{id:n}=s;setTimeout(()=>{bt(s)?this.events.emit(X("pairing_ping",n),{}):et(s)&&this.events.emit(X("pairing_ping",n),{error:s.error})},500)}),K(this,"onPairingDeleteRequest",async(i,s)=>{const{id:n}=s;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(Xt.delete,{id:n,topic:i})}catch(o){await this.sendError(n,i,o),this.logger.error(o)}}),K(this,"onUnknownRpcMethodRequest",async(i,s)=>{const{id:n,method:o}=s;try{if(this.registeredMethods.includes(o))return;const a=te("WC_METHOD_UNSUPPORTED",o);await this.sendError(n,i,a),this.logger.error(a)}catch(a){await this.sendError(n,i,a),this.logger.error(a)}}),K(this,"onUnknownRpcMethodResponse",i=>{this.registeredMethods.includes(i)||this.logger.error(te("WC_METHOD_UNSUPPORTED",i))}),K(this,"isValidPair",(i,s)=>{var n;if(!Fe(i)){const{message:a}=B("MISSING_OR_INVALID",`pair() params: ${i}`);throw s.setError(xt.malformed_pairing_uri),new Error(a)}if(!E0(i.uri)){const{message:a}=B("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw s.setError(xt.malformed_pairing_uri),new Error(a)}const o=Tc(i==null?void 0:i.uri);if(!((n=o==null?void 0:o.relay)!=null&&n.protocol)){const{message:a}=B("MISSING_OR_INVALID","pair() uri#relay-protocol");throw s.setError(xt.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){const{message:a}=B("MISSING_OR_INVALID","pair() uri#symKey");throw s.setError(xt.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&N.toMiliseconds(o==null?void 0:o.expiryTimestamp)<Date.now()){s.setError(xt.pairing_expired);const{message:a}=B("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(a)}}),K(this,"isValidPing",async i=>{if(!Fe(i)){const{message:n}=B("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(n)}const{topic:s}=i;await this.isValidPairingTopic(s)}),K(this,"isValidDisconnect",async i=>{if(!Fe(i)){const{message:n}=B("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(n)}const{topic:s}=i;await this.isValidPairingTopic(s)}),K(this,"isValidPairingTopic",async i=>{if(!le(i,!1)){const{message:s}=B("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(s)}if(!this.pairings.keys.includes(i)){const{message:s}=B("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(s)}if(Mt(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:s}=B("EXPIRED",`pairing topic: ${i}`);throw new Error(s)}}),this.core=e,this.logger=Ne(r,this.name),this.pairings=new dr(this.core,this.logger,this.name,this.storagePrefix)}get context(){return qe(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=B("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(we.message,async e=>{const{topic:r,message:i,transportType:s}=e;if(this.pairings.keys.includes(r)&&s!==ae.link_mode&&!this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))try{const n=await this.core.crypto.decode(r,i);Jo(n)?(this.core.history.set(r,n),await this.onRelayEventRequest({topic:r,payload:n})):Hs(n)&&(await this.core.history.resolve(n),await this.onRelayEventResponse({topic:r,payload:n}),this.core.history.delete(r,n.id)),await this.core.relayer.messages.ack(r,i)}catch(n){this.logger.error(n)}})}registerExpirerEvents(){this.core.expirer.on(Xe.expired,async e=>{const{topic:r}=rl(e.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit(Xt.expire,{topic:r}))})}}var A$=Object.defineProperty,x$=(t,e,r)=>e in t?A$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,$e=(t,e,r)=>x$(t,typeof e!="symbol"?e+"":e,r);class C$ extends uE{constructor(e,r){super(e,r),this.core=e,this.logger=r,$e(this,"records",new Map),$e(this,"events",new rt.EventEmitter),$e(this,"name",T_),$e(this,"version",R_),$e(this,"cac
38hed",[]),$e(this,"initialized",!1),$e(this,"storagePrefix",It),$e(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),$e(this,"set",(i,s,n)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:s,chainId:n}),this.records.has(s.id))return;const o={id:s.id,topic:i,request:{method:s.method,params:s.params||null},chainId:n,expiry:de(N.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(ot.created,o)}),$e(this,"resolve",async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;const s=await this.getRecord(i.id);typeof s.response>"u"&&(s.response=et(i)?{error:i.error}:{result:i.result},this.records.set(s.id,s),this.persist(),this.events.emit(ot.updated,s))}),$e(this,"get",async(i,s)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:s}),await this.getRecord(s))),$e(this,"delete",(i,s)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:s}),this.values.forEach(n=>{if(n.topic===i){if(typeof s<"u"&&n.id!==s)return;this.records.delete(n.id),this.events.emit(ot.deleted,n)}}),this.persist()}),$e(this,"exists",async(i,s)=>(this.isInitialized(),this.records.has(s)?(await this.getRecord(s)).topic===i:!1)),$e(this,"on",(i,s)=>{this.events.on(i,s)}),$e(this,"once",(i,s)=>{this.events.once(i,s)}),$e(this,"off",(i,s)=>{this.events.off(i,s)}),$e(this,"removeListener",(i,s)=>{this.events.removeListener(i,s)}),this.logger=Ne(r,this.name)}get context(){return qe(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(r=>{if(typeof r.response<"u")return;const i={topic:r.topic,request:zt(r.request.method,r.request.params,r.id),chainId:r.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const r=this.records.get(e);if(!r){const{message:i}=B("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(ot.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:r}=B("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(ot.created,e=>{const r=ot.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(ot.updated,e=>{const r=ot.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(ot.deleted,e=>{const r=ot.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.core.heartbeat.on(ti.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(r=>{N.toMiliseconds(r.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${r.id}`),this.records.delete(r.id),this.events.emit(ot.deleted,r,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=B("NOT_INITIALIZED",this.name);throw new Error(e)}}}var T$=Object.defineProperty,R$=(t,e,r)=>e in t?T$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ae=(t,e,r)=>R$(t,typeof e!="symbol"?e+"":e,r);class N$ extends yE{constructor(e,r){super(e,r),this.core=e,this.logger=r,Ae(this,"expirations",new Map),Ae(this,"events",new rt.EventEmitter),Ae(this,"name",N_),Ae(this,"version",B_),Ae(this,"cac
38hed",[]),Ae(this,"initialized",!1),Ae(this,"storagePrefix",It),Ae(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),Ae(this,"has",i=>{try{const s=this.formatTarget(i);return typeof this.getExpiration(s)<"u"}catch{return!1}}),Ae(this,"set",(i,s)=>{this.isInitialized();const n=this.formatTarget(i),o={target:n,expiry:s};this.expirations.set(n,o),this.checkExpiry(n,o),this.events.emit(Xe.created,{target:n,expiration:o})}),Ae(this,"get",i=>{this.isInitialized();const s=this.formatTarget(i);return this.getExpiration(s)}),Ae(this,"del",i=>{if(this.isInitialized(),this.has(i)){const s=this.formatTarget(i),n=this.getExpiration(s);this.expirations.delete(s),this.events.emit(Xe.deleted,{target:s,expiration:n})}}),Ae(this,"on",(i,s)=>{this.events.on(i,s)}),Ae(this,"once",(i,s)=>{this.events.once(i,s)}),Ae(this,"off",(i,s)=>{this.events.off(i,s)}),Ae(this,"removeListener",(i,s)=>{this.events.removeListener(i,s)}),this.logger=Ne(r,this.name)}get context(){return qe(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return Tw(e);if(typeof e=="number")return Rw(e);const{message:r}=B("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(r)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Xe.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:r}=B("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const r=this.expirations.get(e);if(!r){const{message:i}=B("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return r}checkExpiry(e,r){const{expiry:i}=r;N.toMiliseconds(i)-Date.now()<=0&&this.expire(e,r)}expire(e,r){this.expirations.delete(e),this.events.emit(Xe.expired,{target:e,expiration:r})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,r)=>this.checkExpiry(r,e))}registerEventListeners(){this.core.heartbeat.on(ti.pulse,()=>this.checkExpirations()),this.events.on(Xe.created,e=>{const r=Xe.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(Xe.expired,e=>{const r=Xe.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(Xe.deleted,e=>{const r=Xe.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=B("NOT_INITIALIZED",this.name);throw new Error(e)}}}var B$=Object.defineProperty,j$=(t,e,r)=>e in t?B$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ue=(t,e,r)=>j$(t,typeof e!="symbol"?e+"":e,r);class U$ extends mE{constructor(e,r,i){super(e,r,i),this.core=e,this.logger=r,this.store=i,ue(this,"name",j_),ue(this,"abortController"),ue(this,"isDevEnv"),ue(this,"verifyUrlV3",F_),ue(this,"storagePrefix",It),ue(this,"version",Zl),ue(this,"publicKey"),ue(this,"fetchPromise"),ue(this,"init",async()=>{var s;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&N.toMiliseconds((s=this.publicKey)==null?void 0:s.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))}),ue(this,"register",async s=>{if(!Bi()||this.isDevEnv)return;const n=window.location.origin,{id:o,decryptedId:a}=s,c=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${n}&id=${o}&decryptedId=${a}`;try{const h=Ti(),u=this.startAbortTimer(N.ONE_SECOND*5),l=await new Promise((d,f)=>{const p=()=>{window.removeEventListener("message",w),h.body.removeChild(y),f("attestation aborted")};this.abortController.signal.addEventListener("abort",p);const y=h.createElement("iframe");y.src=c,y.style.display="none",y.addEventListener("error",p,{signal:this.abortController.signal});const w=v=>
vendor: 11,583 bytes, line 38
38{if(v.data&&typeof v.data=="string")try{const b=JSON.parse(v.data);if(b.type==="verify_attestation"){if(Wn(b.attestation).payload.id!==o)return;clearInterval(u),h.body.removeChild(y),this.abortController.signal.removeEventListener("abort",p),window.removeEventListener("message",w),d(b.attestation===null?"":b.attestation)}}catch(b){this.logger.warn(b)}};h.body.appendChild(y),window.addEventListener("message",w,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",l),l}catch(h){this.logger.warn(h)}return""}),ue(this,"resolve",async s=>{if(this.isDevEnv)return"";const{attestationId:n,hash:o,encryptedId:a}=s;if(n===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(n){if(Wn(n).payload.id!==a)return;const h=await this.isValidJwtAttestation(n);if(h){if(!h.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return h}}if(!o)return;const c=this.getVerifyUrl(s==null?void 0:s.verifyUrl);return this.fetchAttestation(o,c)}),ue(this,"fetchAttestation",async(s,n)=>{this.logger.debug(`resolving attestation: ${s} from url: ${n}`);const o=this.startAbortTimer(N.ONE_SECOND*5),a=await fetch(`${n}/attestation/${s}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?await a.json():void 0}),ue(this,"getVerifyUrl",s=>{let n=s||bi;return L_.includes(n)||(this.logger.info(`verify url: ${n}, not included in trusted list, assigning default: ${bi}`),n=bi),n}),ue(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const s=this.startAbortTimer(N.FIVE_SECONDS),n=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(s),await n.json()}catch(s){this.logger.warn(s)}}),ue(this,"persistPublicKey",async s=>{this.logger.debug("persisting public key to local storage",s),await this.store.setItem(this.storeKey,s),this.publicKey=s}),ue(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0}),ue(this,"isValidJwtAttestation",async s=>{const n=await this.getPublicKey();try{if(n)return this.validateAttestation(s,n)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}const o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(s,o)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}}),ue(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),ue(this,"fetchAndPersistPublicKey",async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async n=>{const o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),n(o))});const s=await this.fetchPromise;return this.fetchPromise=void 0,s}),ue(this,"validateAttestation",(s,n)=>{const o=c0(s,n.publicKey),a={hasExpired:N.toMiliseconds(o.exp)<Date.now(),payload:o};if(a.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:a.payload.origin,isScam:a.payload.isScam,isVerified:a.payload.isVerified}}),this.logger=Ne(r,this.name),this.abortController=new AbortController,this.isDevEnv=Lo(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return qe(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),N.toMiliseconds(e))}}var F$=Object.defineProperty,L$=(t,e,r)=>e in t?F$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,$h=(t,e,r)=>L$(t,typeof e!="symbol"?e+"":e,r);class M$ extends wE{constructor(e,r){super(e,r),this.projectId=e,this.logger=r,$h(this,"context",M_),$h(this,"registerDeviceToken",async i=>{const{clientId:s,token:n,notificationType:o,enableEncrypted:a=!1}=i,c=`${q_}/${this.projectId}/clients`;await fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:s,type:o,token:n,always_raw:a})})}),this.logger=Ne(r,this.context)}}var q$=Object.defineProperty,Dh=Object.getOwnPropertySymbols,k$=Object.prototype.hasOwnProperty,z$=Object.prototype.propertyIsEnumerable,vo=(t,e,r)=>e in t?q$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,di=(t,e)=>{for(var r in e||(e={}))k$.call(e,r)&&vo(t,r,e[r]);if(Dh)for(var r of Dh(e))z$.call(e,r)&&vo(t,r,e[r]);return t},fe=(t,e,r)=>vo(t,typeof e!="symbol"?e+"":e,r);class H$ extends bE{constructor(e,r,i=!0){super(e,r,i),this.core=e,this.logger=r,fe(this,"context",z_),fe(this,"storagePrefix",It),fe(this,"storageVersion",k_),fe(this,"events",new Map),fe(this,"shouldPersist",!1),fe(this,"init",async()=>{if(!Lo())try{const s={eventId:rc(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:el(this.core.relayer.protocol,this.core.relayer.version,lo)}}};await this.sendEvent([s])}catch(s){this.logger.warn(s)}}),fe(this,"createEvent",s=>{const{event:n="ERROR",type:o="",properties:{topic:a,trace:c}}=s,h=rc(),u=this.core.projectId||"",l=Date.now(),d=di({eventId:h,timestamp:l,props:{event:n,type:o,properties:{topic:a,trace:c}},bundleId:u,domain:this.getAppDomain()},this.setMethods(h));return this.telemetryEnabled&&(this.events.set(h,d),this.shouldPersist=!0),d}),fe(this,"getEvent",s=>{const{eventId:n,topic:o}=s;if(n)return this.events.get(n);const a=Array.from(this.events.values()).find(c=>c.props.properties.topic===o);if(a)return di(di({},a),this.setMethods(a.eventId))}),fe(this,"deleteEvent",s=>{const{eventId:n}=s;this.events.delete(n),this.shouldPersist=!0}),fe(this,"setEventListeners",()=>{this.core.heartbeat.on(ti.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(s=>{N.fromMiliseconds(Date.now())-N.fromMiliseconds(s.timestamp)>H_&&(this.events.delete(s.eventId),this.shouldPersist=!0)})})}),fe(this,"setMethods",s=>({addTrace:n=>this.addTrace(s,n),setError:n=>this.setError(s,n)})),fe(this,"addTrace",(s,n)=>{const o=this.events.get(s);o&&(o.props.properties.trace.push(n),this.events.set(s,o),this.shouldPersist=!0)}),fe(this,"setError",(s,n)=>{const o=this.events.get(s);o&&(o.props.type=n,o.timestamp=Date.now(),this.events.set(s,o),this.shouldPersist=!0)}),fe(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1}),fe(this,"restore",async()=>{try{const s=await this.core.storage.getItem(this.storageKey)||[];if(!s.length)return;s.forEach(n=>{this.events.set(n.eventId,di(di({},n),this.setMethods(n.eventId)))})}catch(s){this.logger.warn(s)}}),fe(this,"submit",async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const s=[];for(const[n,o]of this.events)o.props.type&&s.push(o);if(s.length!==0)try{if((await this.sendEvent(s)).ok)for(const n of s)this.events.delete(n.eventId),this.shouldPersist=!0}catch(n){this.logger.warn(n)}}),fe(this,"sendEvent",async s=>{const n=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${V_}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${lo}${n}`,{method:"POST",body:JSON.stringify(s)})}),fe(this,"getAppDomain",()=>Xu().url),this.logger=Ne(r,this.context),this.telemetryEnabled=i,i?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var V$=Object.defineProperty,Sh=Object.getOwnPropertySymbols,K$=Object.prototype.hasOwnProperty,W$=Object.prototype.propertyIsEnumerable,Eo=(t,e,r)=>e in t?V$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Oh=(t,e)=>{for(var r in e||(e={}))K$.call(e,r)&&Eo(t,r,e[r]);if(Sh)for(var r of Sh(e))W$.call(e,r)&&Eo(t,r,e[r]);return t},ne=(t,e,r)=>Eo(t,typeof e!="symbol"?e+"":e,r);let G$=class ld extends oE{constructor(e){var r;super(e),ne(this,"protocol",Jl),ne(this,"version",Zl),ne(this,"name",Ds),ne(this,"relayUrl"),ne(this,"projectId"),ne(this,"customStoragePrefix"),ne(this,"events",new rt.EventEmitter),ne(this,"logger"),ne(this,"heartbeat"),ne(this,"relayer"),ne(this,"crypto"),ne(this,"storage"),ne(this,"history"),ne(this,"expirer"),ne(this,"pairing"),ne(this,"verify"),ne(this,"echoClient"),ne(this,"linkModeSupportedApps"),ne(this,"eventClient"),ne(this,"initialized",!1),ne(this,"logChunkController"),ne(this,"on",(a,c)=>this.events.on(a,c)),ne(this,"once",(a,c)=>this.events.once(a,c)),ne(this,"off",(a,c)=>this.events.off(a,c)),ne(this,"removeListener",(a,c)=>this.events.removeListener(a,c)),ne(this,"dispatchEnvelope",({topic:a,message:c,sessionExists:h})=>{if(!a||!c)return;const u={topic:a,message:c,publishedAt:Date.now(),transportType:ae.link_mode};this.relayer.onLinkMessageEvent(u,{sessionExists:h})});const i=this.getGlobalCore(e==null?void 0:e.customStoragePrefix);if(i)try{return this.customStoragePrefix=i.customStoragePrefix,this.logger=i.logger,this.heartbeat=i.heartbeat,this.crypto=i.crypto,this.history=i.history,this.expirer=i.expirer,this.storage=i.storage,this.relayer=i.relayer,this.pairing=i.pairing,this.verify=i.verify,this.echoClient=i.echoClient,this.linkModeSupportedApps=i.linkModeSupportedApps,this.eventClient=i.eventClient,this.initialized=i.initialized,this.logChunkController=i.logChunkController,i}catch(a){console.warn("Failed to copy global core",a)}this.projectId=e==null?void 0:e.projectId,this.relayUrl=(e==null?void 0:e.relayUrl)||Xl,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const s=qs({level:typeof(e==null?void 0:e.logger)=="string"&&e.logger?e.logger:p_.logger,name:Ds}),{logger:n,chunkLoggerController:o}=iE({opts:s,maxSizeInBytes:e==null?void 0:e.maxLogBlobSizeInBytes,loggerOverride:e==null?void 0:e.logger});this.logChunkController=o,(r=this.logChunkController)!=null&&r.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var a,c;(a=this.logChunkController)!=null&&a.downloadLogsBlobInBrowser&&((c=this.logChunkController)==null||c.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=Ne(n,this.name),this.heartbeat=new Y0,this.crypto=new E2(this,this.logger,e==null?void 0:e.keychain),this.history=new C$(this,this.logger),this.expirer=new N$(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new A1(Oh(Oh({},f_),e==null?void 0:e.storageOptions)),this.relayer=new G2({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new P$(this,this.logger),this.verify=new U$(this,this.logger,this.storage),this.echoClient=new M$(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new H$(this,this.logger,e==null?void 0:e.telemetryEnabled),this.setGlobalCore(this)}static async init(e){const r=new ld(e);await r.initialize();const i=await r.crypto.getClientId();return await r.storage.setItem(O_,i),r}get context(){return qe(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(oh,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(
38),await this.pairing.init(),this.linkModeSupportedApps=await this.storage.getItem(oh)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}getGlobalCore(e=""){try{if(this.isGlobalCoreDisabled())return;const r=`_walletConnectCore_${e}`,i=`${r}_count`;return globalThis[i]=(globalThis[i]||0)+1,globalThis[i]>1&&console.warn(`WalletConnect Core is already initialized. This is probably a mistake and can lead to unexpected behavior. Init() was called ${globalThis[i]} times.`),globalThis[r]}catch(r){console.warn("Failed to get global WalletConnect core",r);return}}setGlobalCore(e){var r;try{if(this.isGlobalCoreDisabled())return;const i=`_walletConnectCore_${((r=e.opts)==null?void 0:r.customStoragePrefix)||""}`;globalThis[i]=e}catch(i){console.warn("Failed to set global WalletConnect core",i)}}isGlobalCoreDisabled(){try{return typeof process<"u"&&d_.DISABLE_GLOBAL_CORE==="true"}catch{return!0}}};const Y$=G$,dd="wc",pd=2,fd="client",Zo=`${dd}@${pd}:${fd}:`,An={name:fd,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"},Ph="WALLETCONNECT_DEEPLINK_CHOICE",J$="proposal",Ah="Proposal expired",Z$="session",Ir=N.SEVEN_DAYS,Q$="engine",ge={wc_sessionPropose:{req:{ttl:N.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:N.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:N.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:N.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:N.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:N.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:N.ONE_DAY,prompt:!1,tag:1104},res:{ttl:N.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:N.ONE_DAY,prompt:!1,tag:1106},res:{ttl:N.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:N.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:N.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:N.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:N.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:N.ONE_DAY,prompt:!1,tag:1112},res:{ttl:N.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:N.ONE_DAY,prompt:!1,tag:1114},res:{ttl:N.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:N.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:N.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:N.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:N.FIVE_MINUTES,prompt:!1,tag:1119}}},xn={min:N.FIVE_MINUTES,max:N.SEVEN_DAYS},yt={idle:"IDLE",active:"ACTIVE"},xh={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"}},X$="request",eD=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],tD="wc",rD="auth",iD="authKeys",sD="pairingTopics",nD="requests",Ks=`${tD}@${1.5}:${rD}:`,gs=`${Ks}:PUB_KEY`;var oD=Object.defineProperty,aD=Object.defineProperties,cD=Object.getOwnPropertyDescriptors,Ch=Object.getOwnPropertySymbols,hD=Object.prototype.hasOwnProperty,uD=Object.prototype.propertyIsEnumerable,_o=(t,e,r)=>e in t?oD(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ie=(t,e)=>{for(var r in e||(e={}))hD.call(e,r)&&_o(t,r,e[r]);if(Ch)for(var r of Ch(e))uD.call(e,r)&&_o(t,r,e[r]);return t},Te=(t,e)=>aD(t,cD(e)),R=(t,e,r)=>_o(t,typeof e!="symbol"?e+"":e,r);class lD extends IE{constructor(e){super(e),R(this,"name",Q$),R(this,"events",new Po),R(this,"initialized",!1),R(this,"requestQueue",{state:yt.idle,queue:[]}),R(this,"sessionRequestQueue",{state:yt.idle,queue:[]}),R(this,"requestQueueDelay",N.ONE_SECOND),R(this,"expectedPairingMethodMap",new Map),R(this,"recentlyDeletedMap",new Map),R(this,"recentlyDeletedLimit",200),R(this,"relayMessageCache",[]),R(this,"pendingSessions",new Map),R(this,"init",async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(ge)}),this.initialized=!0,setTimeout(async()=>{await this.processPendingMessageEvents(),this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},N.toMiliseconds(this.requestQueueDelay)))}),R(this,"connect",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const i=Te(ie({},r),{requiredNamespaces:r.requiredNamespaces||{},optionalNamespaces:r.optionalNamespaces||{}});await this.isValidConnect(i);const{pairingTopic:s,requiredNamespaces:n,optionalNamespaces:o,sessionProperties:a,scopedProperties:c,relays:h}=i;let u=s,l,d=!1;try{if(u){const A=this.client.core.pairing.pairings.get(u);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),d=A.active}}catch(A){throw this.client.logger.error(`connect() -> pairing.get(${u}) failed`),A}if(!u||!d){const{topic:A,uri:O}=await this.client.core.pairing.create();u=A,l=O}if(!u){const{message:A}=B("NO_MATCHING_KEY",`connect() pairing topic: ${u}`);throw new Error(A)}const f=await this.client.core.crypto.generateKeyPair(),p=ge.wc_sessionPropose.req.ttl||N.FIVE_MINUTES,y=de(p),w=Te(ie(ie({requiredNamespaces:n,optionalNamespaces:o,relays:h??[{protocol:Ql}],proposer:{publicKey:f,metadata:this.client.metadata},expiryTimestamp:y,pairingTopic:u},a&&{sessionProperties:a}),c&&{scopedProperties:c}),{id:wt()}),v=X("session_connect",w.id),{reject:b,resolve:E,done:I}=Jt(p,Ah),P=({id:A})=>{A===w.id&&(this.client.events.off("proposal_expire",P),this.pendingSessions.delete(w.id),this.events.emit(v,{error:{message:Ah,code:0}}))};return this.client.events.on("proposal_expire",P),this.events.once(v,({error:A,session:O})=>{this.client.events.off("proposal_expire",P),A?b(A):O&&E(O)}),await this.sendRequest({topic:u,method:"wc_sessionPropose",params:w,throwOnFailedPublish:!0,clientRpcId:w.id}),await this.setProposal(w.id,w),{uri:l,approval:I}}),R(this,"pair",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(r)}catch(i){throw this.client.logger.error("pair() failed"),i}}),R(this,"approve",async r=>{var i,s,n;const o=this.client.core.eventClient.createEvent({properties:{topic:(i=r==null?void 0:r.id)==null?void 0:i.toString(),trace:[at.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(D){throw o.setError(Gt.no_internet_connection),D}try{await this.isValidProposalId(r==null?void 0:r.id)}catch(D){throw this.client.logger.error(`approve() -> proposal.get(${r==null?void 0:r.id}) failed`),o.setError(Gt.proposal_not_found),D}try{await this.isValidApprove(r)}catch(D){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(Gt.session_approve_namespace_validation_failure),D}const{id:a,relayProtocol:c,namespaces:h,sessionProperties:u,scopedProperties:l,sessionConfig:d}=r,f=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:o.eventId});const{pairingTopic:p,proposer:y,requiredNamespaces:w,optionalNamespaces:v}=f;let b=(s=this.client.core.eventClient)==null?void 0:s.getEvent({topic:p});b||(b=(n=this.client.core.eventClient)==null?void 0:n.createEvent({type:at.session_approve_started,properties:{topic:p,trace:[at.session_approve_started,at.session_namespaces_validation_success]}}));const E=await this.client.core.crypto.generateKeyPair(),I=y.publicKey,P=await this.client.core.crypto.generateSharedKey(E,I),A=ie(ie(ie({relay:{protocol:c??"irn"},namespaces:h,controller:{publicKey:E,metadata:this.client.metadata},expiry:de(Ir)},u&&{sessionProperties:u}),l&&{scopedProperties:l}),d&&{sessionConfig:d}),O=ae.relay;b.addTrace(at.subscribing_session_topic);try{await this.client.core.relayer.subscribe(P,{transportType:O})}catch(D){throw b.setError(Gt.subscribe_session_topic_failure),D}b.addTrace(at.subscribe_session_topic_success);const C=Te(ie({},A),{topic:P,requiredNamespaces:w,optionalNamespaces:v,pairingTopic:p,acknowledged:!1,self:A.controller,peer:{publicKey:y.publicKey,metadata:y.metadata},controller:E,transportType:ae.relay});await this.client.session.set(P,C),b.addTrace(at.store_session);try{b.addTrace(at.publishing_session_settle),await this.sendRequest({topic:P,method:"wc_sessionSettle",params:A,throwOnFailedPublish:!0}).catch(D=>{throw b==null||b.setError(Gt.session_settle_publish_failure),D}),b.addTrace(at.session_settle_publish_success),b.addTrace(at.publishing_session_approve),await this.sendResult({id:a,topic:p,result:{relay:{protocol:c??"irn"},responderPublicKey:E},throwOnFailedPublish:!0}).catch(D=>{throw b==null||b.setError(Gt.session_approve_publish_failure),D}),b.addTrace(at.session_approve_publish_success)}catch(D){throw this.client.logger.error(D),this.client.session.delete(P,te("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(P),D}return this.client.core.eventClient.deleteEvent({eventId:b.eventId}),await this.client.core.pairing.updateMetadata({topic:p,metadata:y.metadata}),await this.client.proposal.delete(a,te("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:p}),await this.setExpiry(P,de(Ir)),{topic:P,acknowledged:()=>Promise.resolve(this.client.session.get(P))}}),R(this,"reject",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(r)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}const{id:i,reason:s}=r;let n;try{n=this.client.proposal.get(i).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),o}
38n&&(await this.sendError({id:i,topic:n,error:s,rpcOpts:ge.wc_sessionPropose.reject}),await this.client.proposal.delete(i,te("USER_DISCONNECTED")))}),R(this,"update",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(r)}catch(l){throw this.client.logger.error("update() -> isValidUpdate() failed"),l}const{topic:i,namespaces:s}=r,{done:n,resolve:o,reject:a}=Jt(),c=wt(),h=rr().toString(),u=this.client.session.get(i).namespaces;return this.events.once(X("session_update",c),({error:l})=>{l?a(l):o()}),await this.client.session.update(i,{namespaces:s}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:s},throwOnFailedPublish:!0,clientRpcId:c,relayRpcId:h}).catch(l=>{this.client.logger.error(l),this.client.session.update(i,{namespaces:u}),a(l)}),{acknowledged:n}}),R(this,"extend",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(r)}catch(c){throw this.client.logger.error("extend() -> isValidExtend() failed"),c}const{topic:i}=r,s=wt(),{done:n,resolve:o,reject:a}=Jt();return this.events.once(X("session_extend",s),({error:c})=>{c?a(c):o()}),await this.setExpiry(i,de(Ir)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:s,throwOnFailedPublish:!0}).catch(c=>{a(c)}),{acknowledged:n}}),R(this,"request",async r=>{this.isInitialized();try{await this.isValidRequest(r)}catch(v){throw this.client.logger.error("request() -> isValidRequest() failed"),v}const{chainId:i,request:s,topic:n,expiry:o=ge.wc_sessionRequest.req.ttl}=r,a=this.client.session.get(n);(a==null?void 0:a.transportType)===ae.relay&&await this.confirmOnlineStateOrThrow();const c=wt(),h=rr().toString(),{done:u,resolve:l,reject:d}=Jt(o,"Request expired. Please try again.");this.events.once(X("session_request",c),({error:v,result:b})=>{v?d(v):l(b)});const f="wc_sessionRequest",p=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);if(p)return await this.sendRequest({clientRpcId:c,relayRpcId:h,topic:n,method:f,params:{request:Te(ie({},s),{expiryTimestamp:de(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0,appLink:p}).catch(v=>d(v)),this.client.events.emit("session_request_sent",{topic:n,request:s,chainId:i,id:c}),await u();const y={request:Te(ie({},s),{expiryTimestamp:de(o)}),chainId:i},w=this.shouldSetTVF(f,y);return await Promise.all([new Promise(async v=>{await this.sendRequest(ie({clientRpcId:c,relayRpcId:h,topic:n,method:f,params:y,expiry:o,throwOnFailedPublish:!0},w&&{tvf:this.getTVFParams(c,y)})).catch(b=>d(b)),this.client.events.emit("session_request_sent",{topic:n,request:s,chainId:i,id:c}),v()}),new Promise(async v=>{var b;if(!((b=a.sessionConfig)!=null&&b.disableDeepLink)){const E=await Uw(this.client.core.storage,Ph);await Nw({id:c,topic:n,wcDeepLink:E})}v()}),u()]).then(v=>v[2])}),R(this,"respond",async r=>{this.isInitialized(),await this.isValidRespond(r);const{topic:i,response:s}=r,{id:n}=s,o=this.client.session.get(i);o.transportType===ae.relay&&await this.confirmOnlineStateOrThrow();const a=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);bt(s)?await this.sendResult({id:n,topic:i,result:s.result,throwOnFailedPublish:!0,appLink:a}):et(s)&&await this.sendError({id:n,topic:i,error:s.error,appLink:a}),this.cleanupAfterResponse(r)}),R(this,"ping",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(r)}catch(s){throw this.client.logger.error("ping() -> isValidPing() failed"),s}const{topic:i}=r;if(this.client.session.keys.includes(i)){const s=wt(),n=rr().toString(),{done:o,resolve:a,reject:c}=Jt();this.events.once(X("session_ping",s),({error:h})=>{h?c(h):a()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:s,relayRpcId:n}),o()])}else this.client.core.pairing.pairings.keys.includes(i)&&(this.client.logger.warn("ping() on pairing topic is deprecated and will be removed in the next major release."),await this.client.core.pairing.ping({topic:i}))}),R(this,"emit",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(r);const{topic:i,event:s,chainId:n}=r,o=rr().toString(),a=wt();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:s,chainId:n},throwOnFailedPublish:!0,relayRpcId:o,clientRpcId:a})}),R(this,"disconnect",async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(r);const{topic:i}=r;if(this.client.session.keys.includes(i))await this.sendRequest({topic:i,method:"wc_sessionDelete",params:te("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:i,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(i))await this.client.core.pairing.disconnect({topic:i});else{const{message:s}=B("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(s)}}),R(this,"find",r=>(this.isInitialized(),this.client.session.getAll().filter(i=>b0(i,r)))),R(this,"getPendingSessionRequests",()=>
vendor: 9,775 bytes, line 38
38this.client.pendingRequest.getAll()),R(this,"authenticate",async(r,i)=>{var s;this.isInitialized(),this.isValidAuthenticate(r);const n=i&&this.client.core.linkModeSupportedApps.includes(i)&&((s=this.client.metadata.redirect)==null?void 0:s.linkMode),o=n?ae.link_mode:ae.relay;o===ae.relay&&await this.confirmOnlineStateOrThrow();const{chains:a,statement:c="",uri:h,domain:u,nonce:l,type:d,exp:f,nbf:p,methods:y=[],expiry:w}=r,v=[...r.resources||[]],{topic:b,uri:E}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:b,uri:E}});const I=await this.client.core.crypto.generateKeyPair(),P=ls(I);if(await Promise.all([this.client.auth.authKeys.set(gs,{responseTopic:P,publicKey:I}),this.client.auth.pairingTopics.set(P,{topic:P,pairingTopic:b})]),await this.client.core.relayer.subscribe(P,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${b}`),y.length>0){const{namespace:$}=Mr(a[0]);let x=Ab($,"request",y);us(v)&&(x=Cb(x,v.pop())),v.push(x)}const A=w&&w>ge.wc_sessionAuthenticate.req.ttl?w:ge.wc_sessionAuthenticate.req.ttl,O={authPayload:{type:d??"caip122",chains:a,statement:c,aud:h,domain:u,version:"1",nonce:l,iat:new Date().toISOString(),exp:f,nbf:p,resources:v},requester:{publicKey:I,metadata:this.client.metadata},expiryTimestamp:de(A)},C={eip155:{chains:a,methods:[...new Set(["personal_sign",...y])],events:["chainChanged","accountsChanged"]}},D={requiredNamespaces:{},optionalNamespaces:C,relays:[{protocol:"irn"}],pairingTopic:b,proposer:{publicKey:I,metadata:this.client.metadata},expiryTimestamp:de(ge.wc_sessionPropose.req.ttl),id:wt()},{done:q,resolve:U,reject:j}=Jt(A,"Request expired"),k=wt(),T=X("session_connect",D.id),g=X("session_request",k),m=async({error:$,session:x})=>{this.events.off(g,_),$?j($):x&&U({session:x})},_=async $=>{var x,F,M;if(await this.deletePendingAuthRequest(k,{message:"fulfilled",code:0}),$.error){const Y=te("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return $.error.code===Y.code?void 0:(this.events.off(T,m),j($.error.message))}await this.deleteProposal(D.id),this.events.off(T,m);const{cacaos:z,responder:L}=$.result,H=[],G=[];for(const Y of z){await uc({cacao:Y,projectId:this.client.core.projectId})||(this.client.logger.error(Y,"Signature verification failed"),j(te("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:Pe}=Y,Ee=us(Pe.resources),Ce=[Jn(Pe.iss)],Ye=vs(Pe.iss);if(Ee){const Je=lc(Ee),fr=dc(Ee);H.push(...Je),Ce.push(...fr)}for(const Je of Ce)G.push(`${Je}:${Ye}`)}const se=await this.client.core.crypto.generateSharedKey(I,L.publicKey);let ee;H.length>0&&(ee={topic:se,acknowledged:!0,self:{publicKey:I,metadata:this.client.metadata},peer:L,controller:L.publicKey,expiry:de(Ir),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:b,namespaces:Nc([...new Set(H)],[...new Set(G)]),transportType:o},await this.client.core.relayer.subscribe(se,{transportType:o}),await this.client.session.set(se,ee),b&&await this.client.core.pairing.updateMetadata({topic:b,metadata:L.metadata}),ee=this.client.session.get(se)),(x=this.client.metadata.redirect)!=null&&x.linkMode&&(F=L.metadata.redirect)!=null&&F.linkMode&&(M=L.metadata.redirect)!=null&&M.universal&&i&&(this.client.core.addLinkModeSupportedApp(L.metadata.redirect.universal),this.client.session.update(se,{transportType:ae.link_mode})),U({auths:z,session:ee})};this.events.once(T,m),this.events.once(g,_);let S;try{if(n){const $=zt("wc_sessionAuthenticate",O,k);this.client.core.history.set(b,$);const x=await this.client.core.crypto.encode("",$,{type:qi,encoding:qt});S=Xi(i,b,x)}else await Promise.all([this.sendRequest({topic:b,method:"wc_sessionAuthenticate",params:O,expiry:r.expiry,throwOnFailedPublish:!0,clientRpcId:k}),this.sendRequest({topic:b,method:"wc_sessionPropose",params:D,expiry:ge.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:D.id})])}catch($){throw this.events.off(T,m),this.events.off(g,_),$}return await this.setProposal(D.id,D),await this.setAuthRequest(k,{request:Te(ie({},O),{verifyContext:{}}),pairingTopic:b,transportType:o}),{uri:S??E,response:q}}),R(this,"approveSessionAuthenticate",async r=>{const{id:i,auths:s}=r,n=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[Yt.authenticated_session_approve_started]}});try{this.isInitialized()}catch(w){throw n.setError(ui.no_internet_connection),w}const o=this.getPendingAuthRequest(i);if(!o)throw n.setError(ui.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);const a=o.transportType||ae.relay;a===ae.relay&&await this.confirmOnlineStateOrThrow();const c=o.requester.publicKey,h=await this.client.core.crypto.generateKeyPair(),u=ls(c),l={type:Nt,receiverPublicKey:c,senderPublicKey:h},d=[],f=[];for(const w of s){if(!await uc({cacao:w,projectId:this.client.core.projectId})){n.setError(ui.invalid_cacao);const P=te("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:u,error:P,encodeOpts:l}),new Error(P.message)}n.addTrace(Yt.cacaos_verified);const{p:v}=w,b=us(v.resources),E=[Jn(v.iss)],I=vs(v.iss);if(b){const P=lc(b),A=dc(b);d.push(...P),E.push(...A)}for(const P of E)f.push(`${P}:${I}`)}const p=await this.client.core.crypto.generateSharedKey(h,c);n.addTrace(Yt.create_authenticated_session_topic);let y;if((d==null?void 0:d.length)>0){y={topic:p,acknowledged:!0,self:{publicKey:h,metadata:this.client.metadata},peer:{publicKey:c,metadata:o.requester.metadata},controller:c,expiry:de(Ir),authentication:s,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:Nc([...new Set(d)],[...new Set(f)]),transportType:a},n.addTrace(Yt.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(p,{transportType:a})}catch(w){throw n.setError(ui.subscribe_authenticated_session_topic_failure),w}n.addTrace(Yt.subscribe_authenticated_session_topic_success),await this.client.session.set(p,y),n.addTrace(Yt.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}n.addTrace(Yt.publishing_authenticated_session_approve);try{await this.sendResult({topic:u,id:i,result:{cacaos:s,responder:{publicKey:h,metadata:this.client.metadata}},encodeOpts:l,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,a)})}catch(w){throw n.setError(ui.authenticated_session_approve_publish_failure),w}return await this.client.auth.requests.delete(i,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:n.eventId}),{session:y}}),R(this,"rejectSessionAuthenticate",async r=>{this.isInitialized();const{id:i,reason:s}=r,n=this.getPendingAuthRequest(i);if(!n)throw new Error(`Could not find pending auth request with id ${i}`);n.transportType===ae.relay&&await this.confirmOnlineStateOrThrow();const o=n.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),c=ls(o),h={type:Nt,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:i,topic:c,error:s,encodeOpts:h,rpcOpts:ge.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(n.requester.metadata,n.transportType)}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.client.proposal.delete(i,te("USER_DISCONNECTED"))}),R(this,"formatAuthMessage",r=>{this.isInitialized();const{request:i,iss:s}=r;return ll(i,s)}),R(this,"processRelayMessageCache",()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{const r=this.relayMessageCache.shift();r&&await this.onRelayMessage(r)}catch(r){this.client.logger.error(r)}},50)}),R(this,"cleanupDuplicatePairings",async r=>{if(r.pairingTopic)try{const i=this.client.core.pairing.pairings.get(r.pairingTopic),s=this.client.core.pairing.pairings.getAll().filter(n=>{var o,a;return((o=n.peerMetadata)==null?void 0:o.url)&&((a=n.peerMetadata)==null?void 0:a.url)===r.peer.metadata.url&&n.topic&&n.topic!==i.topic});if(s.length===0)return;this.client.logger.info(`Cleaning up ${s.length} duplicate pairing(s)`),await Promise.all(s.map(n=>this.client.core.pairing.disconnect({topic:n.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(i){this.client.logger.error(i)}}),R(this,"deleteSession",async r=>{var i;const{topic:s,expirerHasDeleted:n=!1,emitEvent:o=!0,id:a=0}=r,{self:c}=this.client.session.get(s);await this.client.core.relayer.unsubscribe(s),await this.client.session.delete(s,te("USER_DISCONNECTED")),this.addToRecentlyDeleted(s,"session"),this.client.core.crypto.keychain.has(c.publicKey)&&await this.client.core.crypto.deleteKeyPair(c.publicKey),this.client.core.crypto.keychain.has(s)&&await this.client.core.crypto.deleteSymKey(s),n||this.client.core.expirer.del(s),this.client.core.storage.removeItem(Ph).catch(h=>this.client.logger.warn(h)),this.getPendingSessionRequests().forEach(h=>{h.topic===s&&this.deletePendingSessionRequest(h.id,te("USER_DISCONNECTED"))}),s===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=yt.idle),o&&this.client.events.emit("session_delete",{id:a,topic:s})}),R(this,"deleteProposal",async(r,i)=>{if(i)try{const s=this.client.proposal.get(r),n=this.client.core.eventClient.getEvent({topic:s.pairingTopic});n==null||n.setError(Gt.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(r,te("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"proposal")}),R(this,"deletePendingSessionRequest",async(r,i,s=!1)=>
38{await Promise.all([this.client.pendingRequest.delete(r,i),s?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(n=>n.id!==r),s&&(this.sessionRequestQueue.state=yt.idle,this.client.events.emit("session_request_expire",{id:r}))}),R(this,"deletePendingAuthRequest",async(r,i,s=!1)=>{await Promise.all([this.client.auth.requests.delete(r,i),s?Promise.resolve():this.client.core.expirer.del(r)])}),R(this,"setExpiry",async(r,i)=>{this.client.session.keys.includes(r)&&(this.client.core.expirer.set(r,i),await this.client.session.update(r,{expiry:i}))}),R(this,"setProposal",async(r,i)=>{this.client.core.expirer.set(r,de(ge.wc_sessionPropose.req.ttl)),await this.client.proposal.set(r,i)}),R(this,"setAuthRequest",async(r,i)=>{const{request:s,pairingTopic:n,transportType:o=ae.relay}=i;this.client.core.expirer.set(r,s.expiryTimestamp),await this.client.auth.requests.set(r,{authPayload:s.authPayload,requester:s.requester,expiryTimestamp:s.expiryTimestamp,id:r,pairingTopic:n,verifyContext:s.verifyContext,transportType:o})}),R(this,"setPendingSessionRequest",async r=>{const{id:i,topic:s,params:n,verifyContext:o}=r,a=n.request.expiryTimestamp||de(ge.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,a),await this.client.pendingRequest.set(i,{id:i,topic:s,params:n,verifyContext:o})}),R(this,"sendRequest",async r=>{const{topic:i,method:s,params:n,expiry:o,relayRpcId:a,clientRpcId:c,throwOnFailedPublish:h,appLink:u,tvf:l}=r,d=zt(s,n,c);let f;const p=!!u;try{const v=p?qt:ut;f=await this.client.core.crypto.encode(i,d,{encoding:v})}catch(v){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),v}let y;if(eD.includes(s)){const v=Et(JSON.stringify(d)),b=Et(f);y=await this.client.core.verify.register({id:b,decryptedId:v})}const w=ge[s].req;if(w.attestation=y,o&&(w.ttl=o),a&&(w.id=a),this.client.core.history.set(i,d),p){const v=Xi(u,i,f);await global.Linking.openURL(v,this.client.name)}else{const v=ge[s].req;o&&(v.ttl=o),a&&(v.id=a),v.tvf=Te(ie({},l),{correlationId:d.id}),h?(v.internal=Te(ie({},v.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,f,v)):this.client.core.relayer.publish(i,f,v).catch(b=>this.client.logger.error(b))}return d.id}),R(this,"sendResult",async r=>{const{id:i,topic:s,result:n,throwOnFailedPublish:o,encodeOpts:a,appLink:c}=r,h=ks(i,n);let u;const l=c&&typeof(global==null?void 0:global.Linking)<"u";try{const p=l?qt:ut;u=await this.client.core.crypto.encode(s,h,Te(ie({},a||{}),{encoding:p}))}catch(p){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${s} failed`),p}let d,f;try{d=await this.client.core.history.get(s,i);const p=d.request;try{this.shouldSetTVF(p.method,p.params)&&(f=this.getTVFParams(i,p.params,n))}catch(y){this.client.logger.warn("sendResult() -> getTVFParams() failed",y)}}catch(p){throw this.client.logger.error(`sendResult() -> history.get(${s}, ${i}) failed`),p}if(l){const p=Xi(c,s,u);await global.Linking.openURL(p,this.client.name)}else{const p=d.request.method,y=ge[p].res;y.tvf=Te(ie({},f),{correlationId:i}),o?(y.internal=Te(ie({},y.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(s,u,y)):this.client.core.relayer.publish(s,u,y).catch(w=>this.client.logger.error(w))}await this.client.core.history.resolve(h)}),R(this,"sendError",async r=>{const{id:i,topic:s,error:n,encodeOpts:o,rpcOpts:a,appLink:c}=r,h=zs(i,n);let u;const l=c&&typeof(global==null?void 0:global.Linking)<"u";try{const f=l?qt:ut;u=await this.client.core.crypto.encode(s,h,Te(ie({},o||{}),{encoding:f}))}catch(f){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${s} failed`),f}let d;try{d=await this.client.core.history.get(s,i)}catch(f){throw this.client.logger.error(`sendError() -> history.get(${s}, ${i}) failed`),f}if(l){const f=Xi(c,s,u);await global.Linking.openURL(f,this.client.name)}else{const f=d.request.method,p=a||ge[f].res;this.client.core.relayer.publish(s,u,p)}await this.client.core.history.resolve(h)}),R(this,"cleanup",async()=>{const r=[],i=[];
vendor: 12,531 bytes, line 38
38this.client.session.getAll().forEach(s=>{let n=!1;Mt(s.expiry)&&(n=!0),this.client.core.crypto.keychain.has(s.topic)||(n=!0),n&&r.push(s.topic)}),this.client.proposal.getAll().forEach(s=>{Mt(s.expiryTimestamp)&&i.push(s.id)}),await Promise.all([...r.map(s=>this.deleteSession({topic:s})),...i.map(s=>this.deleteProposal(s))])}),R(this,"onProviderMessageEvent",async r=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(r):await this.onRelayMessage(r)}),R(this,"onRelayEventRequest",async r=>{this.requestQueue.queue.push(r),await this.processRequestsQueue()}),R(this,"processRequestsQueue",async()=>{if(this.requestQueue.state===yt.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=yt.active;const r=this.requestQueue.queue.shift();if(r)try{await this.processRequest(r)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=yt.idle}),R(this,"processRequest",async r=>{const{topic:i,payload:s,attestation:n,transportType:o,encryptedId:a}=r,c=s.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:c}))switch(c){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:s,attestation:n,encryptedId:a});case"wc_sessionSettle":return await this.onSessionSettleRequest(i,s);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(i,s);case"wc_sessionExtend":return await this.onSessionExtendRequest(i,s);case"wc_sessionPing":return await this.onSessionPingRequest(i,s);case"wc_sessionDelete":return await this.onSessionDeleteRequest(i,s);case"wc_sessionRequest":return await this.onSessionRequest({topic:i,payload:s,attestation:n,encryptedId:a,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(i,s);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:i,payload:s,attestation:n,encryptedId:a,transportType:o});default:return this.client.logger.info(`Unsupported request method ${c}`)}}),R(this,"onRelayEventResponse",async r=>{const{topic:i,payload:s,transportType:n}=r,o=(await this.client.core.history.get(i,s.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(i,s,n);case"wc_sessionSettle":return this.onSessionSettleResponse(i,s);case"wc_sessionUpdate":return this.onSessionUpdateResponse(i,s);case"wc_sessionExtend":return this.onSessionExtendResponse(i,s);case"wc_sessionPing":return this.onSessionPingResponse(i,s);case"wc_sessionRequest":return this.onSessionRequestResponse(i,s);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(i,s);default:return this.client.logger.info(`Unsupported response method ${o}`)}}),R(this,"onRelayEventUnknownPayload",r=>{const{topic:i}=r,{message:s}=B("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(s)}),R(this,"shouldIgnorePairingRequest",r=>{const{topic:i,requestMethod:s}=r,n=this.expectedPairingMethodMap.get(i);return!n||n.includes(s)?!1:!!(n.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)}),R(this,"onSessionProposeRequest",async r=>{const{topic:i,payload:s,attestation:n,encryptedId:o}=r,{params:a,id:c}=s;try{const h=this.client.core.eventClient.getEvent({topic:i});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),h==null||h.setError(xt.proposal_listener_not_found)),this.isValidConnect(ie({},s.params));const u=a.expiryTimestamp||de(ge.wc_sessionPropose.req.ttl),l=ie({id:c,pairingTopic:i,expiryTimestamp:u},a);await this.setProposal(c,l);const d=await this.getVerifyContext({attestationId:n,hash:Et(JSON.stringify(s)),encryptedId:o,metadata:l.proposer.metadata});h==null||h.addTrace(mt.emit_session_proposal),this.client.events.emit("session_proposal",{id:c,params:l,verifyContext:d})}catch(h){await this.sendError({id:c,topic:i,error:h,rpcOpts:ge.wc_sessionPropose.autoReject}),this.client.logger.error(h)}}),R(this,"onSessionProposeResponse",async(r,i,s)=>{const{id:n}=i;if(bt(i)){const{result:o}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});const a=this.client.proposal.get(n);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:a});const c=a.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:c});const h=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:h});const u=await this.client.core.crypto.generateSharedKey(c,h);this.pendingSessions.set(n,{sessionTopic:u,pairingTopic:r,proposalId:n,publicKey:c});const l=await this.client.core.relayer.subscribe(u,{transportType:s});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:l}),await this.client.core.pairing.activate({topic:r})}else if(et(i)){await this.client.proposal.delete(n,te("USER_DISCONNECTED"));const o=X("session_connect",n);if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(o,{error:i.error})}}),R(this,"onSessionSettleRequest",async(r,i)=>{const{id:s,params:n}=i;try{this.isValidSessionSettleRequest(n);const{relay:o,controller:a,expiry:c,namespaces:h,sessionProperties:u,scopedProperties:l,sessionConfig:d}=i.params,f=[...this.pendingSessions.values()].find(w=>w.sessionTopic===r);if(!f)return this.client.logger.error(`Pending session not found for topic ${r}`);const p=this.client.proposal.get(f.proposalId),y=Te(ie(ie(ie({topic:r,relay:o,expiry:c,namespaces:h,acknowledged:!0,pairingTopic:f.pairingTopic,requiredNamespaces:p.requiredNamespaces,optionalNamespaces:p.optionalNamespaces,controller:a.publicKey,self:{publicKey:f.publicKey,metadata:this.client.metadata},peer:{publicKey:a.publicKey,metadata:a.metadata}},u&&{sessionProperties:u}),l&&{scopedProperties:l}),d&&{sessionConfig:d}),{transportType:ae.relay});await this.client.session.set(y.topic,y),await this.setExpiry(y.topic,y.expiry),await this.client.core.pairing.updateMetadata({topic:f.pairingTopic,metadata:y.peer.metadata}),this.client.events.emit("session_connect",{session:y}),this.events.emit(X("session_connect",f.proposalId),{session:y}),this.pendingSessions.delete(f.proposalId),this.deleteProposal(f.proposalId,!1),this.cleanupDuplicatePairings(y),await this.sendResult({id:i.id,topic:r,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:s,topic:r,error:o}),this.client.logger.error(o)}}),R(this,"onSessionSettleResponse",async(r,i)=>{const{id:s}=i;bt(i)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(X("session_approve",s),{})):et(i)&&(await this.client.session.delete(r,te("USER_DISCONNECTED")),this.events.emit(X("session_approve",s),{error:i.error}))}),R(this,"onSessionUpdateRequest",async(r,i)=>{const{params:s,id:n}=i;try{const o=`${r}_session_update`,a=ci.get(o);if(a&&this.isRequestOutOfSync(a,n)){this.client.logger.warn(`Discarding out of sync request - ${n}`),this.sendError({id:n,topic:r,error:te("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(ie({topic:r},s));try{ci.set(o,n),await this.client.session.update(r,{namespaces:s.namespaces}),await this.sendResult({id:n,topic:r,result:!0,throwOnFailedPublish:!0})}catch(c){throw ci.delete(o),c}this.client.events.emit("session_update",{id:n,topic:r,params:s})}catch(o){await this.sendError({id:n,topic:r,error:o}),this.client.logger.error(o)}}),R(this,"isRequestOutOfSync",(r,i)=>i.toString().slice(0,-3)<r.toString().slice(0,-3)),R(this,"onSessionUpdateResponse",(r,i)=>{const{id:s}=i,n=X("session_update",s);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);bt(i)?this.events.emit(X("session_update",s),{}):et(i)&&this.events.emit(X("session_update",s),{error:i.error})}),R(this,"onSessionExtendRequest",async(r,i)=>{const{id:s}=i;try{this.isValidExtend({topic:r}),await this.setExpiry(r,de(Ir)),await this.sendResult({id:s,topic:r,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:s,topic:r})}catch(n){await this.sendError({id:s,topic:r,error:n}),this.client.logger.error(n)}}),R(this,"onSessionExtendResponse",(r,i)=>{const{id:s}=i,n=X("session_extend",s);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);bt(i)?this.events.emit(X("session_extend",s),{}):et(i)&&this.events.emit(X("session_extend",s),{error:i.error})}),R(this,"onSessionPingRequest",async(r,i)=>{const{id:s}=i;try{this.isValidPing({topic:r}),await this.sendResult({id:s,topic:r,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:s,topic:r})}catch(n){await this.sendError({id:s,topic:r,error:n}),this.client.logger.error(n)}}),R(this,"onSessionPingResponse",(r,i)=>{const{id:s}=i,n=X("session_ping",s);setTimeout(()=>{if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners 2176`);bt(i)?this.events.emit(X("session_ping",s),{}):et(i)&&this.events.emit(X("session_ping",s),{error:i.error})},500)}),R(this,"onSessionDeleteRequest",async(r,i)=>{const{id:s}=i;try{this.isValidDisconnect({topic:r,reason:i.params}),Promise.all([new Promise(n=>{this.client.core.relayer.once(we.publish,async()=>{n(await this.deleteSession({topic:r,id:s}))})}),this.sendResult({id:s,topic:r,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:r,error:te("USER_DISCONNECTED")})]).catch(n=>this.client.logger.error(n))}catch(n){this.client.logger.error(n)}}),R(this,"onSessionRequest",async r=>{var i,s,n;const{topic:o,payload:a,attestation:c,encryptedId:h,transportType:u}=r,{id:l,params:d}=a;try{await this.isValidRequest(ie({topic:o},d));const f=this.client.session.get(o),p=await this.getVerifyContext({attestationId:c,hash:Et(JSON.stringify(zt("wc_sessionRequest",d,l))),encryptedId:h,metadata:f.peer.metadata,transportType:u}),y={id:l,topic:o,params:d,verifyContext:p};await this.setPendingSessionRequest(y),u===ae.link_mode&&(i=f.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((s=f.peer.metadata.redirect)==null?void 0:s.universal),(n=this.client.signConfig)!=null&&n.disableRequestQueue?this.emitSessionRequest(y):(this.addSessionRequestToSessionRequestQueue(y),this.processSessionRequestQueue())}catch(f){await this.sendError({id:l,topic:o,error:f}),this.client.logger.error(f)}}),R(this,"onSessionRequestResponse",(r,i)=>{const{id:s}=i,n=X("session_request",s);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);bt(i)?this.events.emit(X("session_request",s),{result:i.result}):et(i)&&this.events.emit(X("session_request",s),{error:i.error})}),R(this,"onSessionEventRequest",async(r,i)=>{const{id:s,params:n}=i;try{const o=`${r}_session_event_${n.event.name}`,a=ci.get(o);if(a&&this.isRequestOutOfSync(a,s)){this.client.logger.info(`Discarding out of sync request - ${s}`);return}this.isValidEmit(ie({topic:r},n)),this.client.events.emit("session_event",{id:s,topic:r,params:n}),ci.set(o,s)}catch(o){await this.sendError({id:s,topic:r,error:o}),this.client.logger.error(o)}}),R(this,"onSessionAuthenticateResponse",(r,i)=>{const{id:s}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:r,payload:i}),bt(i)?this.events.emit(X("session_request",s),{result:i.result}):et(i)&&this.events.emit(X("session_request",s),{error:i.error})}),R(this,"onSessionAuthenticateRequest",async r=>{var i;const{topic:s,payload:n,attestation:o,encryptedId:a,transportType:c}=r;try{const{requester:h,authPayload:u,expiryTimestamp:l}=n.params,d=await this.getVerifyContext({attestationId:o,hash:Et(JSON.stringify(n)),encryptedId:a,metadata:h.metadata,transportType:c}),f={requester:h,pairingTopic:s,id:n.id,authPayload:u,verifyContext:d,expiryTimestamp:l};await this.setAuthRequest(n.id,{request:f,pairingTopic:s,transportType:c}),c===ae.link_mode&&(i=h.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(h.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:s,params:n.params,id:n.id,verifyContext:d})}catch(h){this.client.logger.error(h);const u=n.params.requester.publicKey,l=await this.client.core.crypto.generateKeyPair(),d=this.getAppLinkIfEnabled(n.params.requester.metadata,c),f={type:Nt,receiverPublicKey:u,senderPublicKey:l};
38await this.sendError({id:n.id,topic:s,error:h,encodeOpts:f,rpcOpts:ge.wc_sessionAuthenticate.autoReject,appLink:d})}}),R(this,"addSessionRequestToSessionRequestQueue",r=>{this.sessionRequestQueue.queue.push(r)}),R(this,"cleanupAfterResponse",r=>{this.deletePendingSessionRequest(r.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=yt.idle,this.processSessionRequestQueue()},N.toMiliseconds(this.requestQueueDelay))}),R(this,"cleanupPendingSentRequestsForTopic",({topic:r,error:i})=>{const s=this.client.core.history.pending;s.length>0&&s.filter(n=>n.topic===r&&n.request.method==="wc_sessionRequest").forEach(n=>{const o=n.request.id,a=X("session_request",o);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);this.events.emit(X("session_request",n.request.id),{error:i})})}),R(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===yt.active){this.client.logger.info("session request queue is already active.");return}const r=this.sessionRequestQueue.queue[0];if(!r){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=yt.active,this.emitSessionRequest(r)}catch(i){this.client.logger.error(i)}}),R(this,"emitSessionRequest",r=>{this.client.events.emit("session_request",r)}),R(this,"onPairingCreated",r=>{if(r.methods&&this.expectedPairingMethodMap.set(r.topic,r.methods),r.active)return;const i=this.client.proposal.getAll().find(s=>s.pairingTopic===r.topic);
38i&&this.onSessionProposeRequest({topic:r.topic,payload:zt("wc_sessionPropose",Te(ie({},i),{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties,scopedProperties:i.scopedProperties}),i.id)})}),R(this,"isValidConnect",async r=>{if(!Fe(r)){const{message:h}=B("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(h)}const{pairingTopic:i,requiredNamespaces:s,optionalNamespaces:n,sessionProperties:o,scopedProperties:a,relays:c}=r;if(xe(i)||await this.isValidPairingTopic(i),!C0(c)){const{message:h}=B("MISSING_OR_INVALID",`connect() relays: ${c}`);throw new Error(h)}if(!xe(s)&&Pi(s)!==0&&this.validateNamespaces(s,"requiredNamespaces"),!xe(n)&&Pi(n)!==0&&this.validateNamespaces(n,"optionalNamespaces"),xe(o)||this.validateSessionProps(o,"sessionProperties"),!xe(a)){this.validateSessionProps(a,"scopedProperties");const h=Object.keys(s||{}).concat(Object.keys(n||{}));if(!Object.keys(a).every(u=>h.includes(u)))throw new Error(`Scoped properties must be a subset of required/optional namespaces, received: ${JSON.stringify(a)}, required/optional namespaces: ${JSON.stringify(h)}`)}}),R(this,"validateNamespaces",(r,i)=>{const s=x0(r,"connect()",i);if(s)throw new Error(s.message)}),R(this,"isValidApprove",async r=>{if(!Fe(r))throw new Error(B("MISSING_OR_INVALID",`approve() params: ${r}`).message);const{id:i,namespaces:s,relayProtocol:n,sessionProperties:o,scopedProperties:a}=r;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);const c=this.client.proposal.get(i),h=vn(s,"approve()");if(h)throw new Error(h.message);const u=Uc(c.requiredNamespaces,s,"approve()");if(u)throw new Error(u.message);if(!le(n,!0)){const{message:l}=B("MISSING_OR_INVALID",`approve() relayProtocol: ${n}`);throw new Error(l)}if(xe(o)||this.validateSessionProps(o,"sessionProperties"),!xe(a)){this.validateSessionProps(a,"scopedProperties");const l=new Set(Object.keys(s));if(!Object.keys(a).every(d=>l.has(d)))throw new Error(`Scoped properties must be a subset of approved namespaces, received: ${JSON.stringify(a)}, approved namespaces: ${Array.from(l).join(", ")}`)}}),R(this,"isValidReject",async r=>{if(!Fe(r)){const{message:n}=B("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(n)}const{id:i,reason:s}=r;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!R0(s)){const{message:n}=B("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(s)}`);throw new Error(n)}}),R(this,"isValidSessionSettleRequest",r=>{if(!Fe(r)){const{message:h}=B("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(h)}const{relay:i,controller:s,namespaces:n,expiry:o}=r;if(!Ul(i)){const{message:h}=B("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(h)}const a=$0(s,"onSessionSettleRequest()");if(a)throw new Error(a.message);const c=vn(n,"onSessionSettleRequest()");if(c)throw new Error(c.message);if(Mt(o)){const{message:h}=B("EXPIRED","onSessionSettleRequest()");throw new Error(h)}}),R(this,"isValidUpdate",async r=>{if(!Fe(r)){const{message:c}=B("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(c)}const{topic:i,namespaces:s}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const n=this.client.session.get(i),o=vn(s,"update()");if(o)throw new Error(o.message);const a=Uc(n.requiredNamespaces,s,"update()");if(a)throw new Error(a.message)}),R(this,"isValidExtend",async r=>{if(!Fe(r)){const{message:s}=B("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(s)}const{topic:i}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)}),R(this,"isValidRequest",async r=>{if(!Fe(r)){const{message:c}=B("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(c)}const{topic:i,request:s,chainId:n,expiry:o}=r;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const{namespaces:a}=this.client.session.get(i);if(!jc(a,n)){const{message:c}=B("MISSING_OR_INVALID",`request() chainId: ${n}`);throw new Error(c)}if(!N0(s)){const{message:c}=B("MISSING_OR_INVALID",`request() ${JSON.stringify(s)}`);throw new Error(c)}if(!U0(a,n,s.method)){const{message:c}=B("MISSING_OR_INVALID",`request() method: ${s.method}`);throw new Error(c)}if(o&&!q0(o,xn)){const{message:c}=B("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${xn.min} and ${xn.max}`);throw new Error(c)}}),R(this,"isValidRespond",async r=>{var i;if(!Fe(r)){const{message:o}=B("MISSING_OR_INVALID",`respond() params: ${r}`);throw new Error(o)}const{topic:s,response:n}=r;try{await this.isValidSessionTopic(s)}catch(o){throw(i=r==null?void 0:r.response)!=null&&i.id&&this.cleanupAfterResponse(r),o}
vendor: 4,164 bytes, line 38
38if(!B0(n)){const{message:o}=B("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(n)}`);throw new Error(o)}}),R(this,"isValidPing",async r=>{if(!Fe(r)){const{message:s}=B("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(s)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)}),R(this,"isValidEmit",async r=>{if(!Fe(r)){const{message:a}=B("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(a)}const{topic:i,event:s,chainId:n}=r;await this.isValidSessionTopic(i);const{namespaces:o}=this.client.session.get(i);if(!jc(o,n)){const{message:a}=B("MISSING_OR_INVALID",`emit() chainId: ${n}`);throw new Error(a)}if(!j0(s)){const{message:a}=B("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(a)}if(!F0(o,n,s.name)){const{message:a}=B("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(a)}}),R(this,"isValidDisconnect",async r=>{if(!Fe(r)){const{message:s}=B("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(s)}const{topic:i}=r;await this.isValidSessionOrPairingTopic(i)}),R(this,"isValidAuthenticate",r=>{const{chains:i,uri:s,domain:n,nonce:o}=r;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!le(s,!1))throw new Error("uri is required parameter");if(!le(n,!1))throw new Error("domain is required parameter");if(!le(o,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(c=>Mr(c).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:a}=Mr(i[0]);if(a!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),R(this,"getVerifyContext",async r=>{const{attestationId:i,hash:s,encryptedId:n,metadata:o,transportType:a}=r,c={verified:{verifyUrl:o.verifyUrl||bi,validation:"UNKNOWN",origin:o.url||""}};try{if(a===ae.link_mode){const u=this.getAppLinkIfEnabled(o,a);return c.verified.validation=u&&new URL(u).origin===new URL(o.url).origin?"VALID":"INVALID",c}const h=await this.client.core.verify.resolve({attestationId:i,hash:s,encryptedId:n,verifyUrl:o.verifyUrl});h&&(c.verified.origin=h.origin,c.verified.isScam=h.isScam,c.verified.validation=h.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(h){this.client.logger.warn(h)}return this.client.logger.debug(`Verify context: ${JSON.stringify(c)}`),c}),R(this,"validateSessionProps",(r,i)=>{Object.values(r).forEach((s,n)=>{if(s==null){const{message:o}=B("MISSING_OR_INVALID",`${i} must contain an existing value for each key. Received: ${s} for key ${Object.keys(r)[n]}`);throw new Error(o)}})}),R(this,"getPendingAuthRequest",r=>{const i=this.client.auth.requests.get(r);return typeof i=="object"?i:void 0}),R(this,"addToRecentlyDeleted",(r,i)=>{if(this.recentlyDeletedMap.set(r,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let s=0;const n=this.recentlyDeletedLimit/2;for(const o of this.recentlyDeletedMap.keys()){if(s++>=n)break;this.recentlyDeletedMap.delete(o)}}}),R(this,"checkRecentlyDeleted",r=>{const i=this.recentlyDeletedMap.get(r);if(i){const{message:s}=B("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${r}`);throw new Error(s)}}),R(this,"isLinkModeEnabled",(r,i)=>{var s,n,o,a,c,h,u,l,d;return!r||i!==ae.link_mode?!1:((n=(s=this.client.metadata)==null?void 0:s.redirect)==null?void 0:n.linkMode)===!0&&((a=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:a.universal)!==void 0&&((h=(c=this.client.metadata)==null?void 0:c.redirect)==null?void 0:h.universal)!==""&&((u=r==null?void 0:r.redirect)==null?void 0:u.universal)!==void 0&&((l=r==null?void 0:r.redirect)==null?void 0:l.universal)!==""&&((d=r==null?void 0:r.redirect)==null?void 0:d.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(r.redirect.universal)&&typeof(global==null?void 0:global.Linking)<"u"}),R(this,"getAppLinkIfEnabled",(r,i)=>{var s;return this.isLinkModeEnabled(r,i)?(s=r==null?void 0:r.redirect)==null?void 0:s.universal:void 0}),R(this,"handleLinkModeMessage",({url:r})=>{if(!r||!r.includes("wc_ev")||!r.includes("topic"))return;
38const i=tc(r,"topic")||"",s=decodeURIComponent(tc(r,"wc_ev")||""),n=this.client.session.keys.includes(i);n&&this.client.session.update(i,{transportType:ae.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:s,sessionExists:n})}),R(this,"registerLinkModeListeners",async()=>{var r;if(Lo()||Vt()&&(r=this.client.metadata.redirect)!=null&&r.linkMode){const i=global==null?void 0:global.Linking;if(typeof i<"u"){i.addEventListener("url",this.handleLinkModeMessage,this.client.name);const s=await i.getInitialURL();s&&setTimeout(()=>{this.handleLinkModeMessage({url:s})},50)}}}),R(this,"shouldSetTVF",(r,i)=>{if(!i||r!=="wc_sessionRequest")return!1;const{request:s}=i;return Object.keys(xh).includes(s.method)}),R(this,"getTVFParams",(r,i,s)=>{var n,o;try{const a=i.request.method,c=this.extractTxHashesFromResult(a,s);return Te(ie({correlationId:r,rpcMethods:[a],chainId:i.chainId},this.isValidContractData(i.request.params)&&{contractAddresses:[(o=(n=i.request.params)==null?void 0:n[0])==null?void 0:o.to]}),{txHashes:c})}catch(a){this.client.logger.warn("Error getting TVF params",a)}return{}}),R(this,"isValidContractData",r=>{var i;if(!r)return!1;try{const s=(r==null?void 0:r.data)||((i=r==null?void 0:r[0])==null?void 0:i.data);if(!s.startsWith("0x"))return!1;const n=s.slice(2);return/^[0-9a-fA-F]*$/.test(n)?n.length%2===0:!1}catch{}return!1}),R(this,"extractTxHashesFromResult",(r,i)=>{try{const s=xh[r];if(typeof i=="string")return[i];const n=i[s.key];if(lt(n))return r==="solana_signAllTransactions"?n.map(o=>gb(o)):n;if(typeof n=="string")return[n]}catch(s){this.client.logger.warn("Error extracting tx hashes from result",s)}return[]})}async processPendingMessageEvents(){try{const e=this.client.session.keys,r=this.client.core.relayer.messages.getWithoutAck(e);for(const[i,s]of Object.entries(r))for(const n of s)try{await this.onProviderMessageEvent({topic:i,message:n,publishedAt:Date.now()})}catch{this.client.logger.warn(`Error processing pending message event for topic: ${i}, message: ${n}`)}}catch(e){this.client.logger.warn("processPendingMessageEvents failed",e)}}isInitialized(){if(!this.initialized){const{message:e}=B("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(we.message,e=>{this.onProviderMessageEvent(e)})}async onRelayMessage(e){const{topic:r,message:i,attestation:s,transportType:n}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(gs)?this.client.auth.authKeys.get(gs):{responseTopic:void 0,publicKey:void 0};try{const a=await this.client.core.crypto.decode(r,i,{receiverPublicKey:o,encoding:n===ae.link_mode?qt:ut});Jo(a)?(this.client.core.history.set(r,a),await this.onRelayEventRequest({topic:r,payload:a,attestation:s,transportType:n,encryptedId:Et(i)})):Hs(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:r,payload:a,transportType:n}),this.client.core.history.delete(r,a.id)):await this.onRelayEventUnknownPayload({topic:r,payload:a,transportType:n}),await this.client.core.relayer.messages.ack(r,i)}catch(a){this.client.logger.error(a)}}registerExpirerEvents(){this.client.core.expirer.on(Xe.expired,async e=>{const{topic:r,id:i}=rl(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,B("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,B("EXPIRED"),!0);r?this.client.session.keys.includes(r)&&(await this.deleteSession({topic:r,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:r})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))})}registerPairingEvents(){this.client.core.pairing.events.on(Xt.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(Xt.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!le(e,!1)){const{message:r}=B("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(r)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:r}=B("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(r)}if(Mt(this.client.core.pairing.pairings.get(e).expiry)){const{message:r}=B("EXPIRED",`pairing topic: ${e}`);throw new Error(r)}}async isValidSessionTopic(e){if(!le(e,!1)){const{message:r}=B("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(r)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:r}=B("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(r)}if(Mt(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:r}=B("EXPIRED",`session topic: ${e}`);throw new Error(r)}if(!this.client.core.crypto.keychain.has(e)){const{message:r}=B("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(r)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(le(e,!1)){const{message:r}=B("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(r)}else{const{message:r}=B("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(r)}}async isValidProposalId(e){if(!T0(e)){const{message:r}=B("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(r)}if(!this.client.proposal.keys.includes(e)){const{message:r}=B("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(r)}if(Mt(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:r}=B("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}}class dD extends dr{constructor(e,r){super(e,r,J$,Zo),this.core=e,this.logger=r}}let pD=class extends dr{constructor(e,r){super(e,r,Z$,Zo),this.core=e,this.logger=r}};class fD extends dr{constructor(e,r){super(e,r,X$,Zo,i=>i.id),this.core=e,this.logger=r}}class gD extends dr{constructor(e,r){super(e,r,iD,Ks,()=>gs),this.core=e,this.logger=r}}class yD extends dr{constructor(e,r){super(e,r,sD,Ks),this.core=e,this.logger=r}}class mD extends dr{constructor(e,r){super(e,r,nD,Ks,i=>i.id),this.core=e,this.logger=r}}var wD=Object.defineProperty,bD=(t,e,r)=>e in t?wD(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Cn=(t,e,r)=>bD(t,typeof e!="symbol"?e+"":e,r);class vD{constructor(e,r){this.core=e,this.logger=r,Cn(this,"authKeys"),Cn(this,"pairingTopics"),Cn(this,"requests"),this.authKeys=new gD(this.core,this.logger),this.pairingTopics=new yD(this.core,this.logger),this.requests=new mD(this.core,this.logger)}
38async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}var ED=Object.defineProperty,_D=(t,e,r)=>e in t?ED(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,W=(t,e,r)=>_D(t,typeof e!="symbol"?e+"":e,r);let ID=class gd extends _E{constructor(e){super(e),W(this,"protocol",dd),W(this,"version",pd),W(this,"name",An.name),W(this,"metadata"),W(this,"core"),W(this,"logger"),W(this,"events",new rt.EventEmitter),W(this,"engine"),W(this,"session"),W(this,"proposal"),W(this,"pendingRequest"),W(this,"auth"),W(this,"signConfig"),W(this,"on",(i,s)=>this.events.on(i,s)),W(this,"once",(i,s)=>this.events.once(i,s)),W(this,"off",(i,s)=>this.events.off(i,s)),W(this,"removeListener",(i,s)=>this.events.removeListener(i,s)),W(this,"removeAllListeners",i=>this.events.removeAllListeners(i)),W(this,"connect",async i=>{try{return await this.engine.connect(i)}catch(s){throw this.logger.error(s.message),s}}),W(this,"pair",async i=>{try{return await this.engine.pair(i)}catch(s){throw this.logger.error(s.message),s}}),W(this,"approve",async i=>{try{return await this.engine.approve(i)}catch(s){throw this.logger.error(s.message),s}}),W(this,"reject",async i=>{try{return await this.engine.reject(i)}catch(s){throw this.logger.error(s.message),s}}),W(this,"update",async i=>{try{return await this.engine.update(i)}catch(s){throw this.logger.error(s.message),s}}),W(this,"extend",async i=>{try{return await this.engine.extend(i)}catch(s){throw this.logger.error(s.message),s}}),W(this,"request",async i=>{try{return await this.engine.request(i)}catch(s){throw this.logger.error(s.message),s}}),W(this,"respond",async i=>{try{return await this.engine.respond(i)}catch(s){throw this.logger.error(s.message),s}}),W(this,"ping",async i=>{try{return await this.engine.ping(i)}catch(s){throw this.logger.error(s.message),s}}),W(this,"emit",async i=>{try{return await this.engine.emit(i)}catch(s){throw this.logger.error(s.message),s}}),W(this,"disconnect",async i=>{try{return await this.engine.disconnect(i)}catch(s){throw this.logger.error(s.message),s}}),W(this,"find",i=>{try{return this.engine.find(i)}catch(s){throw this.logger.error(s.message),s}}),W(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}}),W(this,"authenticate",async(i,s)=>{try{return await this.engine.authenticate(i,s)}catch(n){throw this.logger.error(n.message),n}}),W(this,"formatAuthMessage",i=>{try{return this.engine.formatAuthMessage(i)}catch(s){throw this.logger.error(s.message),s}}),W(this,"approveSessionAuthenticate",async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(s){throw this.logger.error(s.message),s}}),W(this,"rejectSessionAuthenticate",async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(s){throw this.logger.error(s.message),s}}),this.name=(e==null?void 0:e.name)||An.name,this.metadata=Pw(e==null?void 0:e.metadata),this.signConfig=e==null?void 0:e.signConfig;const r=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:zi(qs({level:(e==null?void 0:e.logger)||An.logger}));this.core=(e==null?void 0:e.core)||new Y$(e),this.logger=Ne(r,this.name),this.session=new pD(this.core,this.logger),this.proposal=new dD(this.core,this.logger),this.pendingRequest=new fD(this.core,this.logger),this.engine=new lD(this),this.auth=new vD(this.core,this.logger)}static async init(e){const r=new gd(e);return await r.initialize(),r}get context(){return qe(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),setTimeout(()=>{this.engine.processRelayMessageCache()},N.toMiliseconds(N.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}};var Io={exports:{}};(function(t,e){var r=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof vt<"u"&&vt,i=function(){function n(){this.fetch=!1,this.DOMException=r.DOMException}return n.prototype=r,new n}();(function(n){(function(o){var a=typeof n<"u"&&n||typeof self<"u"&&self||typeof vt<"u"&&vt||{},c={searchParams:"URLSearchParams"in a,iterable:"Symbol"in a&&"iterator"in Symbol,blob:"FileReader"in a&&"Blob"in a&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in a,arrayBuffer:"ArrayBuffer"in a};function h(g){return g&&DataView.prototype.isPrototypeOf(g)}if(c.arrayBuffer)var u=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array
38]"],l=ArrayBuffer.isView||function(g){return g&&u.indexOf(Object.prototype.toString.call(g))>-1};function d(g){if(typeof g!="string"&&(g=String(g)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(g)||g==="")throw new TypeError('Invalid character in header field name: "'+g+'"');return g.toLowerCase()}function f(g){return typeof g!="string"&&(g=String(g)),g}function p(g){var m={next:function(){var _=g.shift();return{done:_===void 0,value:_}}};return c.iterable&&(m[Symbol.iterator]=function(){return m}),m}function y(g){this.map={},g instanceof y?g.forEach(function(m,_){this.append(_,m)},this):Array.isArray(g)?g.forEach(function(m){if(m.length!=2)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+m.length);this.append(m[0],m[1])},this):g&&Object.getOwnPropertyNames(g).forEach(function(m){this.append(m,g[m])},this)}y.prototype.append=function(g,m){g=d(g),m=f(m);var _=this.map[g];this.map[g]=_?_+", "+m:m},y.prototype.delete=function(g){delete this.map[d(g)]},y.prototype.get=function(g){return g=d(g),this.has(g)?this.map[g]:null},y.prototype.has=function(g){return this.map.hasOwnProperty(d(g))},y.prototype.set=function(g,m){this.map[d(g)]=f(m)},y.prototype.forEach=function(g,m){for(var _ in this.map)this.map.hasOwnProperty(_)&&g.call(m,this.map[_],_,this)},y.prototype.keys=function(){var g=[];return this.forEach(function(m,_){g.push(_)}),p(g)},y.prototype.values=function(){var g=[];return this.forEach(function(m){g.push(m)}),p(g)},y.prototype.entries=function(){var g=[];return this.forEach(function(m,_){g.push([_,m])}),p(g)},c.iterable&&(y.prototype[Symbol.iterator]=y.prototype.entries);function w(g){if(!g._noBody){if(g.bodyUsed)return Promise.reject(new TypeError("Already read"));g.bodyUsed=!0}}function v(g){return new Promise(function(m,_){g.onload=function(){m(g.result)},g.onerror=function(){_(g.error)}})}function b(g){var m=new FileReader,_=v(m);return m.readAsArrayBuffer(g),_}function E(g){var m=new FileReader,_=v(m),S=/charset=([A-Za-z0-9_-]+)/.exec(g.type),$=S?S[1]:"utf-8";return m.readAsText(g,$),_}function I(g){for(var m=new Uint8Array(g),_=new Array(m.length),S=0;S<m.length;S++)_[S]=String.fromCharCode(m[S]);return _.join("")}function P(g){if(g.slice)return g.slice(0);var m=new Uint8Array(g.byteLength);return m.set(new Uint8Array(g)),m.buffer}function A(){return this.bodyUsed=!1,this._initBody=function(g){this.bodyUsed=this.bodyUsed,this._bodyInit=g,g?typeof g=="string"?this._bodyText=g:c.blob&&Blob.prototype.isPrototypeOf(g)?this._bodyBlob=g:c.formData&&FormData.prototype.isPrototypeOf(g)?this._bodyFormData=g:c.searchParams&&URLSearchParams.prototype.isPrototypeOf(g)?this._bodyText=g.toString():c.arrayBuffer&&c.blob&&h(g)?(this._bodyArrayBuffer=P(g.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):c.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(g)||l(g))?this._bodyArrayBuffer=P(g):this._bodyText=g=Object.prototype.toString.call(g):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||(typeof g=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):c.searchParams&&URLSearchParams.prototype.isPrototypeOf(g)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},c.blob&&(this.blob=function(){var g=w(this);if(g)return g;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var g=w(this);return g||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else{if(c.blob)return this.blob().then(b);throw new Error("could not read as ArrayBuffer")}},this.text=function(){var g=w(this);if(g)return g;if(this._bodyBlob)return E(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(I(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},c.formData&&(this.formData=function(){return this.text().then(q)}),this.json=function(){return this.text().then(JSON.parse)},this}var O=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function C(g){var m=g.toUpperCase();return O.indexOf(m)>-1?m:g}function D(g,m){if(!(this instanceof D))throw new TypeError('Please use the "new" operator, this DOM object c
38onstructor cannot be called as a function.');m=m||{};var _=m.body;if(g instanceof D){if(g.bodyUsed)throw new TypeError("Already read");this.url=g.url,this.credentials=g.credentials,m.headers||(this.headers=new y(g.headers)),this.method=g.method,this.mode=g.mode,this.signal=g.signal,!_&&g._bodyInit!=null&&(_=g._bodyInit,g.bodyUsed=!0)}else this.url=String(g);if(this.credentials=m.credentials||this.credentials||"same-origin",(m.headers||!this.headers)&&(this.headers=new y(m.headers)),this.method=C(m.method||this.method||"GET"),this.mode=m.mode||this.mode||null,this.signal=m.signal||this.signal||function(){if("AbortController"in a){var x=new AbortController;return x.signal}}(),this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&_)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(_),(this.method==="GET"||this.method==="HEAD")&&(m.cache==="no-store"||m.cache==="no-cache")){var S=/([?&])_=[^&]*/;if(S.test(this.url))this.url=this.url.replace(S,"$1_="+new Date().getTime());else{var $=/\?/;this.url+=($.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}D.prototype.clone=function(){return new D(this,{body:this._bodyInit})};function q(g){var m=new FormData;return g.trim().split("&").forEach(function(_){if(_){var S=_.split("="),$=S.shift().replace(/\+/g," "),x=S.join("=").replace(/\+/g," ");m.append(decodeURIComponent($),decodeURIComponent(x))}}),m}function U(g){var m=new y,_=g.replace(/\r?\n[\t ]+/g," ");return _.split("\r").map(function(S){return S.indexOf(` 39`)===0?S.substr(1,S.length):S}).forEach(function(S){var $=S.split(":"),x=$.shift().trim();if(x){var F=$.join(":").trim();try{m.append(x,F)}catch(M){console.warn("Response "+M.message)}}}),m}A.call(D.prototype);function j(g,m){if(!(this instanceof j))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(m||(m={}),this.type="default",this.status=m.status===void 0?200:m.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=m.statusText===void 0?"":""+m.statusText,this.headers=new y(m.headers),this.url=m.url||"",this._initBody(g)}A.call(j.prototype),j.prototype.clone=function(){return new j(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new y(this.headers),url:this.url})},j.error=function(){var g=new j(null,{status:200,statusText:""});return g.ok=!1,g.status=0,g.type="error",g};var k=[301,302,303,307,308];j.redirect=function(g,m){if(k.indexOf(m)===-1)throw new RangeError("Invalid status code");return new j(null,{status:m,headers:{location:g}})},o.DOMException=a.DOMException;try{new o.DOMException}catch{o.DOMException=function(m,_){this.message=m,this.name=_;var S=Error(m);this.stack=S.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function T(g,m){return new Promise(function(_,S){var $=new D(g,m);if($.signal&&$.signal.aborted)return S(new o.DOMException("Aborted","AbortError"));var x=new XMLHttpRequest;function F(){x.abort()}x.onload=function(){var L={statusText:x.statusText,headers:U(x.getAllResponseHeaders()||"")};$.url.indexOf("file://")===0&&(x.status<200||x.status>599)?L.status=200:L.status=x.status,L.url="responseURL"in x?x.responseURL:L.headers.get("X-Request-URL");var H="response"in x?x.response:x.responseText;setTimeout(function(){_(new j(H,L))},0)},x.onerror=function(){setTimeout(function(){S(new TypeError("Network request failed"))},0)},x.ontimeout=function(){setTimeout(function(){S(new TypeError("Network request timed out"))},0)},x.onabort=function(){setTimeout(function(){S(new o.DOMException("Aborted","AbortError"))},0)};function M(L){try{return L===""&&a.location.href?a.location.href:L}catch{return L}}if(x.open($.method,M($.url),!0),$.credentials==="include"?x.withCredentials=!0:$.credentials==="omit"&&(x.withCredentials=!1),"responseType"in x&&(c.blob?x.responseType="blob":c.arrayBuffer&&(x.responseType="arraybuffer")),m&&typeof m.headers=="object"&&!(m.headers instanceof y||a.Headers&&m.headers instanceof a.Headers)){var z=[];
vendor: 17,832 bytes, line 39
39Object.getOwnPropertyNames(m.headers).forEach(function(L){z.push(d(L)),x.setRequestHeader(L,f(m.headers[L]))}),$.headers.forEach(function(L,H){z.indexOf(H)===-1&&x.setRequestHeader(H,L)})}else $.headers.forEach(function(L,H){x.setRequestHeader(H,L)});$.signal&&($.signal.addEventListener("abort",F),x.onreadystatechange=function(){x.readyState===4&&$.signal.removeEventListener("abort",F)}),x.send(typeof $._bodyInit>"u"?null:$._bodyInit)})}return T.polyfill=!0,a.fetch||(a.fetch=T,a.Headers=y,a.Request=D,a.Response=j),o.Headers=y,o.Request=D,o.Response=j,o.fetch=T,Object.defineProperty(o,"__esModule",{value:!0}),o})({})})(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var s=r.fetch?r:i;e=s.fetch,e.default=s.fetch,e.fetch=s.fetch,e.Headers=s.Headers,e.Request=s.Request,e.Response=s.Response,t.exports=e})(Io,Io.exports);var $D=Io.exports;const Th=tu($D);var DD=Object.defineProperty,SD=Object.defineProperties,OD=Object.getOwnPropertyDescriptors,Rh=Object.getOwnPropertySymbols,PD=Object.prototype.hasOwnProperty,AD=Object.prototype.propertyIsEnumerable,Nh=(t,e,r)=>e in t?DD(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Bh=(t,e)=>{for(var r in e||(e={}))PD.call(e,r)&&Nh(t,r,e[r]);if(Rh)for(var r of Rh(e))AD.call(e,r)&&Nh(t,r,e[r]);return t},jh=(t,e)=>SD(t,OD(e));const xD={Accept:"application/json","Content-Type":"application/json"},CD="POST",Uh={headers:xD,method:CD},Fh=10;class dt{constructor(e,r=!1){if(this.url=e,this.disableProviderPing=r,this.events=new rt.EventEmitter,this.isAvailable=!1,this.registering=!1,!eh(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);this.url=e,this.disableProviderPing=r}get connected(){return this.isAvailable}get connecting(){return this.registering}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async open(e=this.url){await this.register(e)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(e){this.isAvailable||await this.register();try{const r=Bt(e),i=await(await Th(this.url,jh(Bh({},Uh),{body:r}))).json();this.onPayload({data:i})}catch(r){this.onError(e.id,r)}}async register(e=this.url){if(!eh(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((i,s)=>{this.events.once("register_error",n=>{this.resetMaxListeners(),s(n)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return s(new Error("HTTP connection is missing or invalid"));i()})})}this.url=e,this.registering=!0;try{if(!this.disableProviderPing){const r=Bt({id:1,jsonrpc:"2.0",method:"test",params:[]});await Th(e,jh(Bh({},Uh),{body:r}))}this.onOpen()}catch(r){const i=this.parseError(r);throw this.events.emit("register_error",i),this.onClose(),i}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(e){if(typeof e.data>"u")return;const r=typeof e.data=="string"?nr(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const i=this.parseError(r),s=i.message||i.toString(),n=zs(e,s);this.events.emit("payload",n)}parseError(e,r=this.url){return Vl(e,r,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>Fh&&this.events.setMaxListeners(Fh)}}const Lh="error",TD="wss://relay.walletconnect.org",RD="wc",ND="universal_provider",ss=`${RD}@2:${ND}:`,yd="https://rpc.walletconnect.org/v1/",jr="generic",BD=`${yd}bundler`,st={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};function jD(){}function Qo(t){return t==null||typeof t!="object"&&typeof t!="function"}function Xo(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function UD(t){if(Qo(t))return t;if(Array.isArray(t)||Xo(t)||t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer)return t.slice(0);const e=Object.getPrototypeOf(t),r=e.constructor;if(t instanceof Date||t instanceof Map||t instanceof Set)return new r(t);if(t instanceof RegExp){const i=new r(t);return i.lastIndex=t.lastIndex,i}if(t instanceof DataView)return new r(t.buffer.slice(0));if(t instanceof Error){const i=new r(t.message);return i.stack=t.stack,i.name=t.name,i.cause=t.cause,i}if(typeof File<"u"&&t instanceof File)return new r([t],t.name,{type:t.type,lastModified:t.lastModified});if(typeof t=="object"){const i=Object.create(e);return Object.assign(i,t)}return t}function Mh(t){return typeof t=="object"&&t!==null}function md(t){return Object.getOwnPropertySymbols(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}function wd(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const FD="[object RegExp]",bd="[object String]",vd="[object Number]",Ed="[object Boolean]",_d="[object Arguments]",LD="[object Symbol]",MD="[object Date]",qD="[object Map]",kD="[object Set]",zD="[object Array]",HD="[object ArrayBuffer]",VD="[object Object]",KD="[object DataView]",WD="[object Uint8Array]",GD="[object Uint8ClampedArray]",YD="[object Uint16Array]",JD="[object Uint32Array]",ZD="[object Int8Array]",QD="[object Int16Array]",XD="[object Int32Array]",eS="[object Float32Array]",tS="[object Float64Array]";function rS(t,e){return Lr(t,void 0,t,new Map,e)}function Lr(t,e,r,i=new Map,s=void 0){const n=s==null?void 0:s(t,e,r,i);if(n!=null)return n;if(Qo(t))return t;if(i.has(t))return i.get(t);if(Array.isArray(t)){const o=new Array(t.length);i.set(t,o);for(let a=0;a<t.length;a++)o[a]=Lr(t[a],a,r,i,s);return Object.hasOwn(t,"index")&&(o.index=t.index),Object.hasOwn(t,"input")&&(o.input=t.input),o}if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp){const o=new RegExp(t.source,t.flags);return o.lastIndex=t.lastIndex,o}if(t instanceof Map){const o=new Map;i.set(t,o);for(const[a,c]of t)o.set(a,Lr(c,a,r,i,s));return o}if(t instanceof Set){const o=new Set;i.set(t,o);for(const a of t)o.add(Lr(a,void 0,r,i,s));return o}if(typeof Buffer<"u"&&Buffer.isBuffer(t))return t.subarray();if(Xo(t)){const o=new(Object.getPrototypeOf(t)).constructor(t.length);i.set(t,o);for(let a=0;a<t.length;a++)o[a]=Lr(t[a],a,r,i,s);return o}if(t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer)return t.slice(0);if(t instanceof DataView){const o=new DataView(t.buffer.slice(0),t.byteOffset,t.byteLength);return i.set(t,o),er(o,t,r,i,s),o}if(typeof File<"u"&&t instanceof File){const o=new File([t],t.name,{type:t.type});return i.set(t,o),er(o,t,r,i,s),o}if(t instanceof Blob){const o=new Blob([t],{type:t.type});return i.set(t,o),er(o,t,r,i,s),o}if(t instanceof Error){const o=new t.constructor;return i.set(t,o),o.message=t.message,o.name=t.name,o.stack=t.stack,o.cause=t.cause,er(o,t,r,i,s),o}if(typeof t=="object"&&iS(t)){const o=Object.create(Object.getPrototypeOf(t));return i.set(t,o),er(o,t,r,i,s),o}return t}function er(t,e,r=t,i,s){const n=[...Object.keys(e),...md(e)];for(let o=0;o<n.length;o++){const a=n[o],c=Object.getOwnPropertyDescriptor(t,a);(c==null||c.writable)&&(t[a]=Lr(e[a],a,r,i,s))}}function iS(t){switch(wd(t)){case _d:case zD:case HD:case KD:case Ed:case MD:case eS:case tS:case ZD:case QD:case XD:case qD:case vd:case VD:case FD:case kD:case bd:case LD:case WD:case GD:case YD:case JD:return!0;default:return!1}}function sS(t,e){return rS(t,(r,i,s,n)=>{if(typeof t=="object")switch(Object.prototype.toString.call(t)){case vd:case bd:case Ed:{const o=new t.constructor(t==null?void 0:t.valueOf());return er(o,t),o}case _d:{const o={};return er(o,t),o.length=t.length,o[Symbol.iterator]=t[Symbol.iterator],o}default:return}})}function qh(t){return sS(t)}function kh(t){return t!==null&&typeof t=="object"&&wd(t)==="[object Arguments]"}function nS(t){return Xo(t)}function oS(t){var r;if(typeof t!="object"||t==null)return!1;if(Object.getPrototypeOf(t)===null)return!0;if(Object.prototype.toString.call(t)!=="[object Object]"){const i=t[Symbol.toStringTag];return i==null||!((r=Object.getOwnPropertyDescriptor(t,Symbol.toStringTag))!=null&&r.writable)?!1:t.toString()===`[object ${i}]`}let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function aS(t,...e){const r=e.slice(0,-1),i=e[e.length-1];let s=t;for(let n=0;n<r.length;n++){const o=r[n];s=$o(s,o,i,new Map)}return s}function $o(t,e,r,i){if(Qo(t)&&(t=Object(t)),e==null||typeof e!="object")return t;if(i.has(e))return UD(i.get(e));if(i.set(e,t),Array.isArray(e)){e=e.slice();for(let n=0;n<e.length;n++)e[n]=e[n]??void 0}const s=[...Object.keys(e),...md(e)];for(let n=0;n<s.length;n++){const o=s[n];let a=e[o],c=t[o];if(kh(a)&&(a={...a}),kh(c)&&(c={...c}),typeof Buffer<"u"&&Buffer.isBuffer(a)&&(a=qh(a)),Array.isArray(a))if(typeof c=="object"&&c!=null){const u=[],l=Reflect.ownKeys(c);for(let d=0;d<l.length;d++){const f=l[d];u[f]=c[f]}c=u}else c=[];const h=r(c,a,o,t,e,i);h!=null?t[o]=h:Array.isArray(a)||Mh(c)&&Mh(a)?t[o]=$o(c,a,r,i):c==null&&oS(a)?t[o]=$o({},a,r,i):c==null&&nS(a)?t[o]=qh(a):(c===void 0||a!==void 0)&&(t[o]=a)}return t}function cS(t,...e){return aS(t,...e,jD)}var hS=Object.defineProperty,uS=Object.defineProperties,lS=Object.getOwnPropertyDescriptors,zh=Object.getOwnPropertySymbols,dS=Object.prototype.hasOwnProperty,pS=Object.prototype.propertyIsEnumerable,Hh=(t,e,r)=>e in t?hS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ns=(t,e)=>{for(var r in e||(e={}))dS.call(e,r)&&Hh(t,r,e[r]);if(zh)for(var r of zh(e))pS.call(e,r)&&Hh(t,r,e[r]);return t},fS=(t,e)=>uS(t,lS(e));function Ge(t,e,r){var i;const s=Mr(t);return((i=e.rpcMap)==null?void 0:i[s.reference])||`${yd}?chainId=${s.namespace}:${s.reference}&projectId=${r}`}function pr(t){return t.includes(":")?t.split(":")[1]:t}function Id(t){return t.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function gS(t,e){const r=Object.keys(e.namespaces).filter(s=>s.includes(t));if(!r.length)return[];const i=[];return r.forEach(s=>{const n=e.namespaces[s].accounts;i.push(...n)}),i}function Tn(t={},e={}){const r=Vh(t),i=Vh(e);return cS(r,i)}function Vh(t){var e,r,i,s;const n={};if(!Pi(t))return n;for(const[o,a]of Object.entries(t)){const c=Ko(o)?[o]:a.chains,h=a.methods||[],u=a.events||[],l=a.rpcMap||{},d=fi(o);n[d]=fS(ns(ns({},n[d]),a),{chains:hs(c,(e=n[d])==null?void 0:e.chains),methods:hs(h,(r=n[d])==null?void 0:r.methods),events:hs(u,(i=n[d])==null?void 0:i.events),rpcMap:ns(ns({},l),(s=n[d])==null?void 0:s.rpcMap)})}return n}function Kh(t){return t.includes(":")?t.split(":")[2]:t}function Wh(t){const e={};for(const[r,i]of Object.entries(t)){const s=i.methods||[],n=i.events||[],o=i.accounts||[],a=Ko(r)?[r]:i.chains?i.chains:Id(i.accounts);e[r]={chains:a,methods:s,events:n,accounts:o}}return e}function Rn(t){return typeof t=="number"?t:t.includes("0x")?parseInt(t,16):(t=t.includes(":")?t.split(":")[1]:t,isNaN(Number(t))?t:Number(t))}const $d={},Q=t=>$d[t],Nn=(t,e)=>{$d[t]=e};var yS=Object.defineProperty,mS=(t,e,r)=>e in t?yS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,$r=(t,e,r)=>mS(t,typeof e!="symbol"?e+"":e,r);class wS{constructor(e){$r(this,"name","polkadot"),$r(this,"client"),$r(this,"httpProviders"),$r(this,"events"),$r(this,"namespace"),$r(this,"chainId"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(st.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var i;const s=pr(r);e[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||Ge(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new it(new dt(i,Q("disableProviderPing")))}}var bS=Object.defineProperty,vS=Object.defineProperties,ES=Object.getOwnPropertyDescriptors,Gh=Object.getOwnPropertySymbols,_S=Object.prototype.hasOwnProperty,IS=Object.prototype.propertyIsEnumerable,Do=(t,e,r)=>e in t?bS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Yh=(t,e)=>{for(var r in e||(e={}))_S.call(e,r)&&Do(t,r,e[r]);if(Gh)for(var r of Gh(e))IS.call(e,r)&&Do(t,r,e[r]);return t},Jh=(t,e)=>vS(t,ES(e)),Dr=(t,e,r)=>Do(t,typeof e!="symbol"?e+"":e,r);class $S{constructor(e){Dr(this,"name","eip155"),Dr(this,"client"),Dr(this,"chainId"),Dr(this,"namespace"),Dr(this,"httpProviders"),Dr(this,"events"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(e);case"wallet_getCallsStatus":return await this.getCallStatus(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(parseInt(e),r),this.chainId=parseInt(e),this.events.emit(st.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,r){const i=r||Ge(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new it(new dt(i,Q("disableProviderPing")))}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var i;const s=parseInt(pr(r));e[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[r])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}async handleSwitchChain(e){var r,i;let s=e.request.params?(r=e.request.params[0])==null?void 0:r.chainId:"0x0";s=s.startsWith("0x")?s:`0x${s}`;const n=parseInt(s,16);if(this.isChainApproved(n))this.setDefaultChain(`${n}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:s}]},chainId:(i=this.namespace.chains)==null?void 0:i[0]}),this.setDefaultChain(`${n}`);else throw new Error(`Failed to switch to chain 'eip155:${n}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var r,i,s;const n=(i=(r=e.request)==null?void 0:r.params)==null?void 0:i[0];if(!n)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const o=this.client.session.get(e.topic),a=((s=o==null?void 0:o.sessionProperties)==null?void 0:s.capabilities)||{};if(a!=null&&a[n])return a==null?void 0:a[n];const c=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:Jh(Yh({},o.sessionProperties||{}),{capabilities:Jh(Yh({},a||{}),{[n]:c})})})}catch(h){console.warn("Failed to update session with capabilities",h)}return c}async getCallStatus(e){var r,i;const s=this.client.session.get(e.topic),n=(r=s.sessionProperties)==null?void 0:r.bundler_name;if(n){const a=this.getBundlerUrl(e.chainId,n);try{return await this.getUserOperationReceipt(a,e)}catch(c){console.warn("Failed to fetch call status from bundler",c,a)}}const o=(i=s.sessionProperties)==null?void 0:i.bundler_url;if(o)try{return await this.getUserOperationReceipt(o,e)}catch(a){console.warn("Failed to fetch call status from custom bundler",a,o)}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,r){var i;const s=new URL(e),n=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(zt("eth_getUserOperationReceipt",[(i=r.request.params)==null?void 0:i[0]]))});if(!n.ok)throw new Error(`Failed to fetch user operation receipt - ${n.status}`);return await n.json()}
39getBundlerUrl(e,r){return`${BD}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${r}`}}var DS=Object.defineProperty,SS=(t,e,r)=>e in t?DS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Sr=(t,e,r)=>SS(t,typeof e!="symbol"?e+"":e,r);class OS{constructor(e){Sr(this,"name","solana"),Sr(this,"client"),Sr(this,"httpProviders"),Sr(this,"events"),Sr(this,"namespace"),Sr(this,"chainId"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(st.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var i;const s=pr(r);e[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||Ge(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new it(new dt(i,Q("disableProviderPing")))}}var PS=Object.defineProperty,AS=(t,e,r)=>e in t?PS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Or=(t,e,r)=>AS(t,typeof e!="symbol"?e+"":e,r);class xS{constructor(e){Or(this,"name","cosmos"),Or(this,"client"),Or(this,"httpProviders"),Or(this,"events"),Or(this,"namespace"),Or(this,"chainId"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(st.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var i;const s=pr(r);e[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||Ge(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new it(new dt(i,Q("disableProviderPing")))}}var CS=Object.defineProperty,TS=(t,e,r)=>e in t?CS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Pr=(t,e,r)=>TS(t,typeof e!="symbol"?e+"":e,r);class RS{constructor(e){Pr(this,"name","algorand"),Pr(this,"client"),Pr(this,"httpProviders"),Pr(this,"events"),Pr(this,"namespace"),Pr(this,"chainId"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){if(!this.httpProviders[e]){const i=r||Ge(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.chainId=e,this.events.emit(st.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var i;e[r]=this.createHttpProvider(r,(i=this.namespace.rpcMap)==null?void 0:i[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||Ge(e,this.namespace,this.client.core.projectId);return typeof i>"u"?void 0:new it(new dt(i,Q("disableProviderPing")))}}var NS=Object.defineProperty,BS=(t,e,r)=>e in t?NS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ar=(t,e,r)=>BS(t,typeof e!="symbol"?e+"":e,r);class jS{constructor(e){Ar(this,"name","cip34"),Ar(this,"client"),Ar(this,"httpProviders"),Ar(this,"events"),Ar(this,"namespace"),Ar(this,"chainId"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(st.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{const i=this.getCardanoRPCUrl(r),s=pr(r);e[s]=this.createHttpProvider(s,i)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}getCardanoRPCUrl(e){const r=this.namespace.rpcMap;if(r)return r[e]}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||this.getCardanoRPCUrl(e);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new it(new dt(i,Q("disableProviderPing")))}}var US=Object.defineProperty,FS=(t,e,r)=>e in t?US(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,xr=(t,e,r)=>FS(t,typeof e!="symbol"?e+"":e,r);class LS{constructor(e){xr(this,"name","elrond"),xr(this,"client"),xr(this,"httpProviders"),xr(this,"events"),xr(this,"namespace"),xr(this,"chainId"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(st.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var i;const s=pr(r);e[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||Ge(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new it(new dt(i,Q("disableProviderPing")))}}var MS=Object.defineProperty,qS=(t,e,r)=>e in t?MS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Cr=(t,e,r)=>qS(t,typeof e!="symbol"?e+"":e,r);class kS{constructor(e){Cr(this,"name","multiversx"),Cr(this,"client"),Cr(this,"httpProviders"),Cr(this,"events"),Cr(this,"namespace"),Cr(this,"chainId"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(st.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var i;const s=pr(r);e[s]=this.createHttpProvider(s,(i=this.namespace.rpcMap)==null?void 0:i[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||Ge(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new it(new dt(i,Q("disableProviderPing")))}}var zS=Object.defineProperty,HS=(t,e,r)=>e in t?zS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Tr=(t,e,r)=>HS(t,typeof e!="symbol"?e+"":e,r);class VS{constructor(e){Tr(this,"name","near"),Tr(this,"client"),Tr(this,"httpProviders"),Tr(this,"events"),Tr(this,"namespace"),Tr(this,"chainId"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){if(this.chainId=e,!this.httpProviders[e]){const i=r||Ge(`${this.name}:${e}`,this.namespace);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.events.emit(st.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var i;e[r]=this.createHttpProvider(r,(i=this.namespace.rpcMap)==null?void 0:i[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||Ge(e,this.namespace);return typeof i>"u"?void 0:new it(new dt(i,Q("disableProviderPing")))}}var KS=Object.defineProperty,WS=(t,e,r)=>e in t?KS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Rr=(t,e,r)=>WS(t,typeof e!="symbol"?e+"":e,r);class GS{constructor(e){Rr(this,"name","tezos"),Rr(this,"client"),Rr(this,"httpProviders"),Rr(this,"events"),Rr(this,"namespace"),Rr(this,"chainId"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){if(this.chainId=e,!this.httpProviders[e]){const i=r||Ge(`${this.name}:${e}`,this.namespace);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.events.emit(st.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{e[r]=this.createHttpProvider(r)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||Ge(e,this.namespace);return typeof i>"u"?void 0:new it(new dt(i))}}var YS=Object.defineProperty,JS=(t,e,r)=>e in t?YS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Nr=(t,e,r)=>JS(t,typeof e!="symbol"?e+"":e,r);class ZS{constructor(e){Nr(this,"name",jr),Nr(this,"client"),Nr(this,"httpProviders"),Nr(this,"events"),Nr(this,"namespace"),Nr(this,"chainId"),this.namespace=e.namespace,this.events=Q("events"),this.client=Q("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(st.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.c
39hains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){var e,r;const i={};return(r=(e=this.namespace)==null?void 0:e.accounts)==null||r.forEach(s=>{const n=Mr(s);i[`${n.namespace}:${n.reference}`]=this.createHttpProvider(s)}),i}getHttpProvider(e){const r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const i=this.createHttpProvider(e,r);i&&(this.httpProviders[e]=i)}createHttpProvider(e,r){const i=r||Ge(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new it(new dt(i,Q("disableProviderPing")))}}var QS=Object.defineProperty,XS=Object.defineProperties,eO=Object.getOwnPropertyDescriptors,Zh=Object.getOwnPropertySymbols,tO=Object.prototype.hasOwnProperty,rO=Object.prototype.propertyIsEnumerable,So=(t,e,r)=>e in t?QS(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,os=(t,e)=>{for(var r in e||(e={}))tO.call(e,r)&&So(t,r,e[r]);if(Zh)for(var r of Zh(e))rO.call(e,r)&&So(t,r,e[r]);return t},Bn=(t,e)=>XS(t,eO(e)),Qe=(t,e,r)=>So(t,typeof e!="symbol"?e+"":e,r);let iO=class Dd{constructor(e){Qe(this,"client"),Qe(this,"namespaces"),Qe(this,"optionalNamespaces"),Qe(this,"sessionProperties"),Qe(this,"scopedProperties"),Qe(this,"events",new Po),Qe(this,"rpcProviders",{}),Qe(this,"session"),Qe(this,"providerOpts"),Qe(this,"logger"),Qe(this,"uri"),Qe(this,"disableProviderPing",!1),this.providerOpts=e,this.logger=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:zi(qs({level:(e==null?void 0:e.logger)||Lh})),this.disableProviderPing=(e==null?void 0:e.disableProviderPing)||!1}static async init(e){const r=new Dd(e);return await r.initialize(),r}async request(e,r,i){const[s,n]=this.validateChain(r);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(s).request({request:os({},e),chainId:`${s}:${n}`,topic:this.session.topic,expiry:i})}sendAsync(e,r,i,s){const n=new Date().getTime();this.request(e,i,s).then(o=>r(null,ks(n,o))).catch(o=>r(o,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(e=this.session)==null?void 0:e.topic,reason:te("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,r){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:i,response:s}=await this.client.authenticate(e,r);i&&(this.uri=i,this.events.emit("display_uri",i));const n=await s();if(this.session=n.session,this.session){const o=Wh(this.session.namespaces);this.namespaces=Tn(this.namespaces,o),await this.persist("namespaces",this.namespaces),this.onConnect()}return n}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}removeListener(e,r){this.events.removeListener(e,r)}off(e,r){this.events.off(e,r)}get isWalletConnect(){return!0}async pair(e){const{uri:r,approval:i}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties});r&&(this.uri=r,this.events.emit("display_uri",r));const s=await i();this.session=s;const n=Wh(s.namespaces);return this.namespaces=Tn(this.namespaces,n),await this.persist("namespaces",this.namespaces),await this.persist("optionalNamespaces",this.optionalNamespaces),this.onConnect(),this.session}setDefaultChain(e,r){try{if(!this.session)return;const[i,s]=this.validateChain(e),n=this.getProvider(i);n.name===jr?n.setDefaultChain(`${i}:${s}`,r):n.setDefaultChain(s,r)}catch(i){if(!/Please call connect/.test(i.message))throw i}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const r=this.client.pairing.getAll();if(lt(r)){for(const i of r)e.deletePairings?this.client.core.expirer.set(i.topic,0):await this.client.core.relayer.subscriber.unsubscribe(i.topic);this.logger.info(`Inactive pairings cleared: ${r.length}`)}}abortPairingAttempt(){this.logger.warn("abortPairingAttempt is deprecated. This is now a no-op.")}async checkStorage(){this.namespaces=await this.getFromStore("namespaces")||{},this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.session&&this.createProviders()}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){var e,r;if(this.client=this.providerOpts.client||await ID.init({core:this.providerOpts.core,logger:this.providerOpts.logger||Lh,relayUrl:this.providerOpts.relayUrl||TD,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.providerOpts.session)try{this.session=this.client.session.get(this.providerOpts.session.topic)}catch(i){throw this.logger.error("Failed to get session",i),new Error(`The provided session: ${(r=(e=this.providerOpts)==null?void 0:e.session)==null?void 0:r.topic} doesn't exist in the Sign client`)}else{const i=this.client.session.getAll();this.session=i[0]}this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map(r=>fi(r)))];Nn("client",this.client),Nn("events",this.events),Nn("disableProviderPing",this.disableProviderPing),e.forEach(r=>{if(!this.session)return;const i=gS(r,this.session),s=Id(i),n=Tn(this.namespaces,this.optionalNamespaces),o=Bn(os({},n[r]),{accounts:i,chains:s});switch(r){case"eip155":this.rpcProviders[r]=new $S({namespace:o});break;case"algorand":this.rpcProviders[r]=new RS({namespace:o});break;case"solana":this.rpcProviders[r]=new OS({namespace:o});break;
39case"cosmos":this.rpcProviders[r]=new xS({namespace:o});break;case"polkadot":this.rpcProviders[r]=new wS({namespace:o});break;case"cip34":this.rpcProviders[r]=new jS({namespace:o});break;case"elrond":this.rpcProviders[r]=new LS({namespace:o});break;case"multiversx":this.rpcProviders[r]=new kS({namespace:o});break;case"near":this.rpcProviders[r]=new VS({namespace:o});break;case"tezos":this.rpcProviders[r]=new GS({namespace:o});break;default:this.rpcProviders[jr]?this.rpcProviders[jr].updateNamespace(o):this.rpcProviders[jr]=new ZS({namespace:o})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{var r;const{topic:i}=e;i===((r=this.session)==null?void 0:r.topic)&&this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{var r;const{params:i,topic:s}=e;if(s!==((r=this.session)==null?void 0:r.topic))return;const{event:n}=i;if(n.name==="accountsChanged"){const o=n.data;o&<(o)&&this.events.emit("accountsChanged",o.map(Kh))}else if(n.name==="chainChanged"){const o=i.chainId,a=i.event.data,c=fi(o),h=Rn(o)!==Rn(a)?`${c}:${Rn(a)}`:o;this.onChainChanged(h)}else this.events.emit(n.name,n.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:r})=>{var i,s;if(e!==((i=this.session)==null?void 0:i.topic))return;const{namespaces:n}=r,o=(s=this.client)==null?void 0:s.session.get(e);this.session=Bn(os({},o),{namespaces:n}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:r})}),this.client.on("session_delete",async e=>{var r;e.topic===((r=this.session)==null?void 0:r.topic)&&(await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",Bn(os({},te("USER_DISCONNECTED")),{data:e.topic})))}),this.on(st.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[jr]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var r;this.getProvider(e).updateNamespace((r=this.session)==null?void 0:r.namespaces[e])})}setNamespaces(e){const{namespaces:r,optionalNamespaces:i,sessionProperties:s,scopedProperties:n}=e;r&&Object.keys(r).length&&(this.namespaces=r),i&&Object.keys(i).length&&(this.optionalNamespaces=i),this.sessionProperties=s,this.scopedProperties=n}validateChain(e){const[r,i]=(e==null?void 0:e.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[r,i];if(r&&!Object.keys(this.namespaces||{}).map(o=>fi(o)).includes(r))throw new Error(`Namespace '${r}' is not configured. Please call connect() first with namespace config.`);if(r&&i)return[r,i];const s=fi(Object.keys(this.namespaces)[0]),n=this.rpcProviders[s].getDefaultChain();return[s,n]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}async onChainChanged(e,r=!1){if(!this.namespaces)return;const[i,s]=this.validateChain(e);if(!s)return;this.updateNamespaceChain(i,s),this.events.emit("chainChanged",s);const n=this.getProvider(i).getDefaultChain();r||this.getProvider(i).setDefaultChain(s),this.emitAccountsChangedOnChainChange({namespace:i,previousChainId:n,newChainId:e}),await this.persist("namespaces",this.namespaces)}emitAccountsChangedOnChainChange({namespace:e,previousChainId:r,newChainId:i}){var s,n;try{if(r===i)return;const o=(n=(s=this.session)==null?void 0:s.namespaces[e])==null?void 0:n.accounts;if(!o)return;const a=o.filter(c=>c.includes(`${i}:`)).map(Kh);if(!lt(a))return;this.events.emit("accountsChanged",a)}catch(o){this.logger.warn("Failed to emit accountsChanged on chain change",o)}}updateNamespaceChain(e,r){if(!this.namespaces)return;const i=this.namespaces[e]?e:`${e}:${r}`,s={chains:[],methods:[],events:[],defaultChain:r};this.namespaces[i]?this.namespaces[i]&&(this.namespaces[i].defaultChain=r):this.namespaces[i]=s}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,await this.deleteFromStore("namespaces"),await this.deleteFromStore("optionalNamespaces"),await this.deleteFromStore("sessionProperties"),this.session=void 0,await this.cleanupPendingPairings({deletePairings:!0}),await this.cleanupStorage()}async persist(e,r){var i;const s=((i=this.session)==null?void 0:i.topic)||"";await this.client.core.storage.setItem(`${ss}/${e}${s}`,r)}async getFromStore(e){var r;const i=((r=this.session)==null?void 0:r.topic)||"";return await this.client.core.storage.getItem(`${ss}/${e}${i}`)}async deleteFromStore(e){var r;const i=((r=this.session)==null?void 0:r.topic)||"";await this.client.core.storage.removeItem(`${ss}/${e}${i}`)}async cleanupStorage(){var e;try{if(((e=this.client)==null?void 0:e.session.length)>0)return;const r=await this.client.core.storage.getKeys();for(const i of r)i.startsWith(ss)&&await this.client.core.storage.removeItem(i)}catch(r){this.logger.warn("Failed to cleanup storage",r)}}};const sO=iO,nO="wc",oO="ethereum_provider",aO=`${nO}@2:${oO}:`,cO="https://rpc.walletconnect.org/v1/",Ss=["eth_sendTransaction","personal_sign"],Sd=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_sendCalls","wallet_getCapabilities","wallet_getCallsStatus","wallet_showCallsStatus"],Os=["chainChanged","accountsChanged"],Od=["chainChanged","accountsChanged","message","disconnect","connect"];var hO=Object.defineProperty,uO=Object.defineProperties,lO=Object.getOwnPropertyDescriptors,Qh=Object.getOwnPropertySymbols,dO=Object.prototype.hasOwnProperty,pO=Object.prototype.propertyIsEnumerable,Oo=(t,e,r)=>e in t?hO(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ur=(t,e)=>{for(var r in e||(e={}))dO.call(e,r)&&Oo(t,r,e[r]);if(Qh)for(var r of Qh(e))pO.call(e,r)&&Oo(t,r,e[r]);return t},jn=(t,e)=>uO(t,lO(e)),ze=(t,e,r)=>Oo(t,typeof e!="symbol"?e+"":e,r);function Ps(t){return Number(t[0].split(":")[1])}function as(t){return`0x${t.toString(16)}`}function fO(t){const{chains:e,optionalChains:r,methods:i,optionalMethods:s,events:n,optionalEvents:o,rpcMap:a}=t;if(!lt(e))throw new Error("Invalid chains");const c={chains:e,methods:i||Ss,events:n||Os,rpcMap:Ur({},e.length?{[Ps(e)]:a[Ps(e)]}:{})},h=n==null?void 0:n.filter(f=>!Os.includes(f)),u=i==null?void 0:i.filter(f=>!Ss.includes(f));if(!r&&!o&&!s&&!(h!=null&&h.length)&&!(u!=null&&u.length))return{required:e.length?c:void 0};const l=(h==null?void 0:h.length)&&(u==null?void 0:u.length)||!r,d={chains:[...new Set(l?c.chains.concat(r||[]):r)],methods:[...new Set(c.methods.concat(s!=null&&s.length?s:Sd))],events:[...new Set(c.events.concat(o!=null&&o.length?o:Od))],rpcMap:a};return{required:e.length?c:void 0,optional:r.length?d:void 0}}class Ws{constructor(){ze(this,"events",new rt.EventEmitter),ze(this,"namespace","eip155"),ze(this,"accounts",[]),ze(this,"signer"),ze(this,"chainId",1),ze(this,"modal"),ze(this,"rpc"),ze(this,"STORAGE_KEY",aO),ze(this,"on",(e,r)=>(this.events.on(e,r),this)),ze(this,"once",(e,r)=>(this.events.once(e,r),this)),ze(this,"removeListener",(e,r)=>(this.events.removeListener(e,r),this)),ze(this,"off",(e,r)=>(this.events.off(e,r),this)),ze(this,"parseAccount",e=>this.isCompatibleChainId(e)?this.parseAccountId(e).address:e),this.signer={},this.rpc={}}static async init(e){const r=new Ws;return await r.initialize(e),r}async request(e,r){return await this.signer.request(e,this.formatChainId(this.chainId),r)}sendAsync(e,r,i){this.signer.sendAsync(e,r,this.formatChainId(this.chainId),i)}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(e){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(e);const{required:r,optional:i}=fO(this.rpc);try{const s=await new Promise(async(o,a)=>{var c;this.rpc.showQrModal&&((c=this.modal)==null||c.subscribeModal(u=>{!u.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),a(new Error("Connection request reset. Please try again.")))}));const h=e!=null&&e.scopedProperties?{[this.namespace]:e.scopedProperties}:void 0;await this.signer.connect(jn(Ur({namespaces:Ur({},r&&{[this.namespace]:r})},i&&{optionalNamespaces:{[this.namespace]:i}}),{pairingTopic:e==null?void 0:e.pairingTopic,scopedProperties:h})).then(u=>{o(u)}).catch(u=>{a(new Error(u.message))})});if(!s)return;const n=Ja(s.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:n),this.setAccounts(n),this.events.emit("connect",{chainId:as(this.chainId)})}catch(s){throw this.signer.logger.error(s),s}finally{this.modal&&this.modal.closeModal()}}async authenticate(e,r){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts({chains:e==null?void 0:e.chains});try{const i=await new Promise(async(n,o)=>{var a;this.rpc.showQrModal&&((a=this.modal)==null||a.subscribeModal(c=>{!c.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),o(new Error("Connection request reset. Please try again.")))})),await this.signer.authenticate(jn(Ur({},e),{chains:this.rpc.chains}),r).then(c=>{n(c)}).catch(c=>{o(new Error(c.message))})}),s=i.session;if(s){const n=Ja(s.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:n),this.setAccounts(n),this.events.emit("connect",{chainId:as(this.chainId)})}return i}catch(i){throw this.signer.logger.error(i),i}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",e=>{const{params:r}=e,{event:i}=r;i.name==="accountsChanged"?(this.accounts=this.parseAccounts(i.data),this.events.emit("accountsChanged",this.accounts)):i.name==="chainChanged"?this.setChainId(this.formatChainId(i.data)):this.events.emit(i.name,i.data),this.events.emit("session_event",e)}),this.signer.on("accountsChanged",e=>{this.accounts=this.parseAccounts(e),this.events.emit("accountsChanged",this.accounts)}),this.signer.on("chainChanged",e=>{const r=parseInt(e);this.chainId=r,this.events.emit("chainChanged",as(this.chainId)),this.persist()}),this.signer.on("session_update",e=>{this.events.emit("session_update",e)}),this.signer.on("session_delete",e=>{this.reset(),this.events.emit("session_delete",e),this.events.emit("disconnect",jn(Ur({},te("USER_DISCONNECTED")),{data:e.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",e=>{var r,i;this.rpc.showQrModal&&((r=this.modal)==null||r.closeModal(),(i=this.modal)==null||i.openModal({uri:e})),this.events.emit("display_uri",e)})}switchEthereumChain(e){this.request({method:"wallet_switchEthereumChain",params:[{chainId:e.toString(16)}]})}isCompatibleChainId(e){return typeof e=="string"?e.startsWith(`${this.namespace}:`):!1}formatChainId(e){return`${this.namespace}:${e}`}parseChainId(e){return Number(e.split(":")[1])}setChainIds(e){const r=e.filter(i=>this.isCompatibleChainId(i)).map(i=>this.parseChainId(i));r.length&&(this.chainId=r[0],this.events.emit("chainChanged",as(this.chainId)),this.persist())}setChainId(e){if(this.isCompatibleChainId(e)){const r=this.parseChainId(e);this.chainId=r,this.switchEthereumChain(r)}}parseAccountId(e){const[r,i,s]=e.split(":");return{chainId:`${r}:${i}`,address:s}}setAccounts(e){this.accounts=e.filter(r=>this.parseChainId(this.parseAccountId(r).chainId)===this.chainId).map(r=>this.parseAccountId(r).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(e){var r,i;const s=(r=e==null?void 0:e.chains)!=null?r:[],n=(i=e==null?void 0:e.optionalChains)!=null?i:[],o=s.concat(n);if(!o.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const a=s.length?(e==null?void 0:e.methods)||Ss:[],c=s.length?(e==null?void 0:e.events)||Os:[],h=(e==null?void 0:e.optionalMethods)||[],u=(e==null?void 0:e.optionalEvents)||[],l=(e==null?void 0:e.rpcMap)||this.buildRpcMap(o,e.projectId),d=(e==null?void 0:e.qrModalOptions)||void 0;return{chains:s==null?void 0:s.map(f=>this.formatChainId(f)),optionalChains:n.map(f=>this.formatChainId(f)),methods:a,events:c,optionalMethods:h,optionalEvents:u,rpcMap:l,showQrModal:!!(e!=null&&e.showQrModal),qrModalOptions:d,projectId:e.projectId,metadata:e.metadata}}buildRpcMap(e,r){const i={};return e.forEach(s=>{i[s]=this.getRpcUrl(s,r)}),i}async initialize(e){if(this.rpc=this.getRpcConfig(e),this.chainId=this.rpc.chains.length?Ps(this.rpc.chains):Ps(this.rpc.optionalChains),this.signer=await sO.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:e.disableProviderPing,relayUrl:e.relayUrl,storage:e.storage,storageOptions:e.storageOptions,customStoragePrefix:e.customStoragePrefix,telemetryEnabled:e.telemetryEnabled,logger:e.logger}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let r;
39try{const{WalletConnectModal:i}=await eu(()=>import("./index-QStLE_5U.js").then(s=>s.i),__vite__mapDeps([4,1,2]));r=i}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(r)try{this.modal=new r(Ur({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}catch(i){throw this.signer.logger.error(i),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(e){if(!e)return;const{chains:r,optionalChains:i,rpcMap:s}=e;r&<(r)&&(this.rpc.chains=r.map(n=>this.formatChainId(n)),r.forEach(n=>{this.rpc.rpcMap[n]=(s==null?void 0:s[n])||this.getRpcUrl(n)})),i&<(i)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=i==null?void 0:i.map(n=>this.formatChainId(n)),i.forEach(n=>{this.rpc.rpcMap[n]=(s==null?void 0:s[n])||this.getRpcUrl(n)}))}getRpcUrl(e,r){var i;return((i=this.rpc.rpcMap)==null?void 0:i[e])||`${cO}?chainId=eip155:${e}&projectId=${r||this.rpc.projectId}`}async loadPersistedSession(){if(this.session)try{const e=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),r=this.session.namespaces[`${this.namespace}:${e}`]?this.session.namespaces[`${this.namespace}:${e}`]:this.session.namespaces[this.namespace];this.setChainIds(e?[this.formatChainId(e)]:r==null?void 0:r.accounts),this.setAccounts(r==null?void 0:r.accounts)}catch(e){this.signer.logger.error("Failed to load persisted session, clearing state..."),this.signer.logger.error(e),await this.disconnect().catch(r=>this.signer.logger.warn(r))}}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(e){return typeof e=="string"||e instanceof String?[this.parseAccount(e)]:e.map(r=>this.parseAccount(r))}}const gO=Ws,oP=Object.freeze(Object.defineProperty({__proto__:null,EthereumProvider:gO,OPTIONAL_EVENTS:Od,OPTIONAL_METHODS:Sd,REQUIRED_EVENTS:Os,REQUIRED_METHODS:Ss,default:Ws},Symbol.toStringTag,{value:"Module"}));export{nf as H,_a as a,Gp as b,bO as c,wO as d,xs as e,EO as f,_O as g,oP as i,vO as r,pu as t,of as w};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.