/*! For license information please see bundle.22e5a4833bca7cb8775b.js.LICENSE.txt */ "use strict";(self.webpackChunkfrog=self.webpackChunkfrog||[]).push([[6525],{36525:(t,e,n)=>{n.d(e,{$Bq:()=>fr,$hI:()=>V,ADD:()=>_,ALl:()=>Vn,AYU:()=>Sr,Alu:()=>Cr,AwN:()=>Qn,BdH:()=>v,C5G:()=>Zn,CTo:()=>Ar,EHS:()=>_n,EN$:()=>Kn,EWt:()=>Ln,F$L:()=>Xn,FR8:()=>Vr,FiO:()=>Tr,GuA:()=>wr,HNf:()=>Ur,Hbs:()=>Xr,Hjj:()=>br,IjX:()=>qt,K3g:()=>j,Lln:()=>b,Lp_:()=>Pn,M8n:()=>Kr,OP1:()=>mr,PUk:()=>$,Pa8:()=>$n,QJh:()=>ar,Qhg:()=>vr,R7U:()=>U,TRk:()=>H,TZl:()=>Dn,TeY:()=>Dr,Tw2:()=>zn,U0i:()=>nr,V7m:()=>tr,V9G:()=>Rr,VBM:()=>oe,Van:()=>pr,WWN:()=>re,Wx8:()=>k,X3c:()=>Hr,XqR:()=>Wr,Xw0:()=>R,YcA:()=>Wn,_Yb:()=>d,_dF:()=>C,aF0:()=>Er,aRZ:()=>I,aa1:()=>sr,b07:()=>Ir,bEt:()=>xn,c82:()=>B,e8_:()=>Zt,esh:()=>_r,gOF:()=>T,gZm:()=>F,h0Y:()=>L,hEn:()=>D,hVC:()=>te,hwK:()=>Wt,iV1:()=>Mr,iui:()=>Yn,jTh:()=>K,jUZ:()=>A,kob:()=>dr,kuU:()=>Br,lFF:()=>N,lVv:()=>m,m01:()=>E,mr0:()=>xr,n3s:()=>M,n6V:()=>or,nWe:()=>lr,nyL:()=>Qr,oKp:()=>Gr,ojD:()=>S,ovp:()=>Mn,ps1:()=>er,q_h:()=>Gt,sc7:()=>Jr,sc_:()=>ne,tLy:()=>Fr,tk0:()=>Lr,two:()=>Hn,uym:()=>Yr,w8K:()=>G,wYp:()=>cr,wa2:()=>qn,x0t:()=>Gn,xkc:()=>Ft,yy4:()=>W,z2N:()=>qr});var r=n(48468),o=n(88900),s=n(38196),i=n(42063),c=n(18278),u=n(38236),a=n(65661),f=n(94112),h=n(43228);const l=":";function d(t){const[e,n]=t.split(l);return{namespace:e,reference:n}}function p(t,e){return t.includes(":")?[t]:e.chains||[]}const y="ReactNative",g={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},w="js";function b(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function m(){return!(0,s.getDocument)()&&!!(0,s.getNavigator)()&&navigator.product===y}function E(){return m()&&typeof n.g<"u"&&typeof(null==n.g?void 0:n.g.Platform)<"u"&&"android"===(null==n.g?void 0:n.g.Platform.OS)}function I(){return m()&&typeof n.g<"u"&&typeof(null==n.g?void 0:n.g.Platform)<"u"&&"ios"===(null==n.g?void 0:n.g.Platform.OS)}function v(){return!b()&&!!(0,s.getNavigator)()&&!!(0,s.getDocument)()}function O(){return m()?g.reactNative:b()?g.node:v()?g.browser:g.unknown}function U(){var t;try{return m()&&typeof n.g<"u"&&typeof(null==n.g?void 0:n.g.Application)<"u"?null==(t=n.g.Application)?void 0:t.applicationId:void 0}catch{return}}function N(){return(0,i.g)()||{name:"",description:"",url:"",icons:[""]}}function S(t,e,o){const i=function(){if(O()===g.reactNative&&typeof n.g<"u"&&typeof(null==n.g?void 0:n.g.Platform)<"u"){const{OS:t,Version:e}=n.g.Platform;return[t,e].join("-")}const t=(0,r.o0)();if(null===t)return"unknown";const e=t.os?t.os.replace(" ","").toLowerCase():"unknown";return"browser"===t.type?[e,t.name,t.version].join("-"):[e,t.version].join("-")}(),c=function(){var t;const e=O();return e===g.browser?[e,(null==(t=(0,s.getLocation)())?void 0:t.host)||"unknown"].join(":"):e}();return[[t,e].join("-"),[w,o].join("-"),i,c].join("/")}function A({protocol:t,version:e,relayUrl:n,sdkVersion:r,auth:o,projectId:s,useOnCloseEvent:i,bundleId:c,packageName:u}){const a=n.split("?"),f={auth:o,ua:S(t,e,r),projectId:s,useOnCloseEvent:i||void 0,packageName:u||void 0,bundleId:c||void 0},h=function(t,e){const n=new URLSearchParams(t);for(const t of Object.keys(e).sort())if(e.hasOwnProperty(t)){const r=e[t];void 0!==r&&n.set(t,r)}return n.toString()}(a[1]||"",f);return a[0]+"?"+h}function x(t,e){return t.filter((t=>e.includes(t))).length===t.length}function L(t){return Object.fromEntries(t.entries())}function $(t){return new Map(Object.entries(t))}function k(t=o.FIVE_MINUTES,e){const n=(0,o.toMiliseconds)(t||o.FIVE_MINUTES);let r,s,i,c;return{resolve:t=>{i&&r&&(clearTimeout(i),r(t),c=Promise.resolve(t))},reject:t=>{i&&s&&(clearTimeout(i),s(t))},done:()=>new Promise(((t,o)=>{if(c)return t(c);i=setTimeout((()=>{const t=new Error(e);c=Promise.reject(t),o(t)}),n),r=t,s=o}))}}function j(t,e,n){return new Promise((async(r,o)=>{const s=setTimeout((()=>o(new Error(n))),e);try{r(await t)}catch(t){o(t)}clearTimeout(s)}))}function P(t,e){if("string"==typeof e&&e.startsWith(`${t}:`))return e;if("topic"===t.toLowerCase()){if("string"!=typeof e)throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}if("id"===t.toLowerCase()){if("number"!=typeof e)throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${t}`)}function _(t){return P("topic",t)}function T(t){return P("id",t)}function B(t){const[e,n]=t.split(":"),r={id:void 0,topic:void 0};if("topic"===e&&"string"==typeof n)r.topic=n;else{if("id"!==e||!Number.isInteger(Number(n)))throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${n}`);r.id=Number(n)}return r}function R(t,e){return(0,o.fromMiliseconds)((e||Date.now())+(0,o.toMiliseconds)(t))}function C(t){return Date.now()>=(0,o.toMiliseconds)(t)}function D(t,e){return`${t}${e?`:${e}`:""}`}function H(t=[],e=[]){return[...new Set([...t,...e])]}async function M({id:t,topic:e,wcDeepLink:r}){var o;try{if(!r)return;const i="string"==typeof r?JSON.parse(r):r,c=i?.href;if("string"!=typeof c)return;const u=function(t,e,n){const r=`requestId=${e}&sessionTopic=${n}`;t.endsWith("/")&&(t=t.slice(0,-1));let o=`${t}`;if(t.startsWith("https://t.me")){o=`${o}${t.includes("?")?"&startapp=":"?startapp="}${function(t,e=!1){const n=Buffer.from(t).toString("base64");return e?n.replace(/[=]/g,""):n}(r,!0)}`}else o=`${o}/wc?${r}`;return o}(c,t,e),a=O();if(a===g.browser){if(null==(o=(0,s.getDocument)())||!o.hasFocus())return;!function(t){let e="_self";!function(){try{return window.self!==window.top}catch{return!1}}()?(typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)||t.startsWith("https://")||t.startsWith("http://"))&&(e="_blank"):e="_top",window.open(t,e,"noreferrer noopener")}(u)}else a===g.reactNative&&typeof(null==n.g?void 0:n.g.Linking)<"u"&&await n.g.Linking.openURL(u)}catch(t){}}async function K(t,e){let n="";try{if(v()&&(n=localStorage.getItem(e),n))return n;n=await t.getItem(e)}catch(t){}return n}function V(t,e){if(!t.includes(e))return null;const n=t.split(/([&,?,=])/),r=n.indexOf(e);return n[r+2]}function F(){return typeof crypto<"u"&&null!=crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,(t=>{const e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))}function G(){return typeof process<"u"&&"true"===process.env.IS_VITEST}function q(t){return Buffer.from(t,"base64").toString("utf-8")}function W(t){return new Promise((e=>setTimeout(e,t)))}function z(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function X(t,...e){if(!function(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}(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 J(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");z(t.outputLen),z(t.blockLen)}function Y(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 Z(t,e){X(t);const n=e.outputLen;if(t.length>tt&Q)}:{h:0|Number(t>>tt&Q),l:0|Number(t&Q)}}const nt="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function rt(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function ot(t,e){return t<<32-e|t>>>e}const st=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];function it(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function ct(t){for(let e=0;et().update(ut(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function ht(t=32){if(nt&&"function"==typeof nt.getRandomValues)return nt.getRandomValues(new Uint8Array(t));if(nt&&"function"==typeof nt.randomBytes)return nt.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const lt=[],dt=[],pt=[],yt=BigInt(0),gt=BigInt(1),wt=BigInt(2),bt=BigInt(7),mt=BigInt(256),Et=BigInt(113);for(let t=0,e=gt,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],lt.push(2*(5*r+n)),dt.push((t+1)*(t+2)/2%64);let o=yt;for(let t=0;t<7;t++)e=(e<>bt)*Et)%mt,e&wt&&(o^=gt<<(gt<n>32?((t,e,n)=>e<>>64-n)(t,e,n):((t,e,n)=>t<>>32-n)(t,e,n),Ut=(t,e,n)=>n>32?((t,e,n)=>t<>>64-n)(t,e,n):((t,e,n)=>e<>>32-n)(t,e,n);class Nt extends at{constructor(t,e,n,r=!1,o=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=n,this.enableXOF=r,this.rounds=o,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,z(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var s;this.state=new Uint8Array(200),this.state32=(s=this.state,new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4)))}keccak(){st||ct(this.state32),function(t,e=24){const n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let e=0;e<10;e++)n[e]=t[e]^t[e+10]^t[e+20]^t[e+30]^t[e+40];for(let e=0;e<10;e+=2){const r=(e+8)%10,o=(e+2)%10,s=n[o],i=n[o+1],c=Ot(s,i,1)^n[r],u=Ut(s,i,1)^n[r+1];for(let n=0;n<50;n+=10)t[e+n]^=c,t[e+n+1]^=u}let e=t[2],o=t[3];for(let n=0;n<24;n++){const r=dt[n],s=Ot(e,o,r),i=Ut(e,o,r),c=lt[n];e=t[c],o=t[c+1],t[c]=s,t[c+1]=i}for(let e=0;e<50;e+=10){for(let r=0;r<10;r++)n[r]=t[e+r];for(let r=0;r<10;r++)t[e+r]^=~n[(r+2)%10]&n[(r+4)%10]}t[0]^=It[r],t[1]^=vt[r]}n.fill(0)}(this.state32,this.rounds),st||ct(this.state32),this.posOut=0,this.pos=0}update(t){Y(this);const{blockLen:e,state:n}=this,r=(t=ut(t)).length;for(let o=0;o=n&&this.keccak();const s=Math.min(n-this.posOut,o-r);t.set(e.subarray(this.posOut,this.posOut+s),r),this.posOut+=s,r+=s}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return z(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Z(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:n,outputLen:r,rounds:o,enableXOF:s}=this;return t||(t=new Nt(e,n,r,s,o)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=n,t.outputLen=r,t.enableXOF=s,t.destroyed=this.destroyed,t}}const St=(xt=1,Lt=136,$t=32,ft((()=>new Nt(Lt,xt,$t)))),At="https://rpc.walletconnect.org/v1";var xt,Lt,$t;function kt(t){const e=`Ethereum Signed Message:\n${t.length}`,n=(new TextEncoder).encode(e+t);return"0x"+Buffer.from(St(n)).toString("hex")}async function jt(t,e,n,r,o,s){switch(n.t){case"eip191":return function(t,e,n){return(0,c.x_)(kt(e),n).toLowerCase()===t.toLowerCase()}(t,e,n.s);case"eip1271":return await async function(t,e,n,r,o,s){const i=d(r);if(!i.namespace||!i.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${r}`);try{const i="0x1626ba7e",c="0000000000000000000000000000000000000000000000000000000000000040",u="0000000000000000000000000000000000000000000000000000000000000041",a=n.substring(2),f=i+kt(e).substring(2)+c+u+a,h=await fetch(`${s||At}/?chainId=${r}&projectId=${o}`,{method:"POST",body:JSON.stringify({id:Pt(),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:f},"latest"]})}),{result:l}=await h.json();return!!l&&l.slice(0,i.length).toLowerCase()===i.toLowerCase()}catch(t){return!1}}(t,e,n.s,r,o,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${n.t}`)}}function Pt(){return Date.now()+Math.floor(1e3*Math.random())}var _t=Object.defineProperty,Tt=Object.defineProperties,Bt=Object.getOwnPropertyDescriptors,Rt=Object.getOwnPropertySymbols,Ct=Object.prototype.hasOwnProperty,Dt=Object.prototype.propertyIsEnumerable,Ht=(t,e,n)=>e in t?_t(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Mt=(t,e)=>{for(var n in e||(e={}))Ct.call(e,n)&&Ht(t,n,e[n]);if(Rt)for(var n of Rt(e))Dt.call(e,n)&&Ht(t,n,e[n]);return t},Kt=(t,e)=>Tt(t,Bt(e));const Vt=t=>t?.split(":"),Ft=t=>{const e=t&&Vt(t);if(e)return e[2]+":"+e[3]},Gt=t=>{const e=t&&Vt(t);if(e)return e.pop()};async function qt(t){const{cacao:e,projectId:n}=t,{s:r,p:o}=e,s=Wt(o,o.iss),i=Gt(o.iss);return await jt(i,s,r,Ft(o.iss),n)}const Wt=(t,e)=>{const n=`${t.domain} wants you to sign in with your Ethereum account:`,r=Gt(e);if(!t.aud&&!t.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let o=t.statement||void 0;const s=`URI: ${t.aud||t.uri}`,i=`Version: ${t.version}`,c=`Chain ID: ${(t=>{const e=t&&Vt(t);if(e)return t.includes("did:pkh:")?e[3]:e[1]})(e)}`,u=`Nonce: ${t.nonce}`,a=`Issued At: ${t.iat}`,f=t.exp?`Expiration Time: ${t.exp}`:void 0,h=t.nbf?`Not Before: ${t.nbf}`:void 0,l=t.requestId?`Request ID: ${t.requestId}`:void 0,d=t.resources?`Resources:${t.resources.map((t=>`\n- ${t}`)).join("")}`:void 0,p=oe(t.resources);if(p){o=ee(o,Yt(p))}return[n,r,"",o,"",s,i,c,u,a,f,h,l,d].filter((t=>null!=t)).join("\n")};function zt(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(null==e||!e.length)throw new Error("No resources found in `att` property");e.forEach((e=>{const n=t.att[e];if(Array.isArray(n))throw new Error(`Resource must be an object: ${e}`);if("object"!=typeof n)throw new Error(`Resource must be an object: ${e}`);if(!Object.keys(n).length)throw new Error(`Resource object is empty: ${e}`);Object.keys(n).forEach((t=>{const e=n[t];if(!Array.isArray(e))throw new Error(`Ability limits ${t} must be an array of objects, found: ${e}`);if(!e.length)throw new Error(`Value of ${t} is empty array, must be an array with objects`);e.forEach((e=>{if("object"!=typeof e)throw new Error(`Ability limits (${t}) must be an array of objects, found: ${e}`)}))}))}))}function Xt(t,e,n={}){e=e?.sort(((t,e)=>t.localeCompare(e)));const r=e.map((e=>({[`${t}/${e}`]:[n]})));return Object.assign({},...r)}function Jt(t){return zt(t),`urn:recap:${function(t){return Buffer.from(JSON.stringify(t)).toString("base64")}(t).replace(/=/g,"")}`}function Yt(t){const e=function(t){return JSON.parse(Buffer.from(t,"base64").toString("utf-8"))}(t.replace("urn:recap:",""));return zt(e),e}function Zt(t,e,n){const r=function(t,e,n,r={}){return n?.sort(((t,e)=>t.localeCompare(e))),{att:{[t]:Xt(e,n,r)}}}(t,e,n);return Jt(r)}function Qt(t){return t&&t.includes("urn:recap:")}function te(t,e){const n=function(t,e){zt(t),zt(e);const n=Object.keys(t.att).concat(Object.keys(e.att)).sort(((t,e)=>t.localeCompare(e))),r={att:{}};return n.forEach((n=>{var o,s;Object.keys((null==(o=t.att)?void 0:o[n])||{}).concat(Object.keys((null==(s=e.att)?void 0:s[n])||{})).sort(((t,e)=>t.localeCompare(e))).forEach((o=>{var s,i;r.att[n]=Kt(Mt({},r.att[n]),{[o]:(null==(s=t.att[n])?void 0:s[o])||(null==(i=e.att[n])?void 0:i[o])})}))})),r}(Yt(t),Yt(e));return Jt(n)}function ee(t="",e){zt(e);const n="I further authorize the stated URI to perform the following actions on my behalf: ";if(t.includes(n))return t;const r=[];let o=0;Object.keys(e.att).forEach((t=>{const n=Object.keys(e.att[t]).map((t=>({ability:t.split("/")[0],action:t.split("/")[1]})));n.sort(((t,e)=>t.action.localeCompare(e.action)));const s={};n.forEach((t=>{s[t.ability]||(s[t.ability]=[]),s[t.ability].push(t.action)}));const i=Object.keys(s).map((e=>(o++,`(${o}) '${e}': '${s[e].join("', '")}' for '${t}'.`)));r.push(i.join(", ").replace(".,","."))}));return`${t?t+" ":""}${`${n}${r.join(" ")}`}`}function ne(t){var e;const n=Yt(t);zt(n);const r=null==(e=n.att)?void 0:e.eip155;return r?Object.keys(r).map((t=>t.split("/")[1])):[]}function re(t){const e=Yt(t);zt(e);const n=[];return Object.values(e.att).forEach((t=>{Object.values(t).forEach((t=>{var e;null!=(e=t?.[0])&&e.chains&&n.push(t[0].chains)}))})),[...new Set(n.flat())]}function oe(t){if(!t)return;const e=t?.[t.length-1];return Qt(e)?e:void 0}function se(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function ie(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}function ce(t,...e){if(!ie(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 ue(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 ae(t){if("boolean"!=typeof t)throw new Error(`boolean expected, not ${t}`)}const fe=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");function he(t){if("string"==typeof t)t=function(t){if("string"!=typeof t)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(t))}(t);else{if(!ie(t))throw new Error("Uint8Array expected, got "+typeof t);t=pe(t)}return t}function le(t,e,n=!0){if(void 0===e)return new Uint8Array(t);if(e.length!==t)throw new Error("invalid output length, expected "+t+", got: "+e.length);if(n&&!function(t){return t.byteOffset%4==0}(e))throw new Error("invalid output, must be aligned");return e}function de(t,e,n,r){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,n,r);const o=BigInt(32),s=BigInt(4294967295),i=Number(n>>o&s),c=Number(n&s),u=r?4:0,a=r?0:4;t.setUint32(e+u,i,r),t.setUint32(e+a,c,r)}function pe(t){return Uint8Array.from(t)}function ye(...t){for(let e=0;eUint8Array.from(t.split("").map((t=>t.charCodeAt(0)))),we=ge("expand 16-byte k"),be=ge("expand 32-byte k"),me=fe(we),Ee=fe(be);function Ie(t,e){return t<>>32-e}function ve(t){return t.byteOffset%4==0}const Oe=2**32-1,Ue=new Uint32Array;const Ne=(t,e)=>255&t[e++]|(255&t[e++])<<8;class Se{constructor(t){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,ce(t=he(t),32);const e=Ne(t,0),n=Ne(t,2),r=Ne(t,4),o=Ne(t,6),s=Ne(t,8),i=Ne(t,10),c=Ne(t,12),u=Ne(t,14);this.r[0]=8191&e,this.r[1]=8191&(e>>>13|n<<3),this.r[2]=7939&(n>>>10|r<<6),this.r[3]=8191&(r>>>7|o<<9),this.r[4]=255&(o>>>4|s<<12),this.r[5]=s>>>1&8190,this.r[6]=8191&(s>>>14|i<<2),this.r[7]=8065&(i>>>11|c<<5),this.r[8]=8191&(c>>>8|u<<8),this.r[9]=u>>>5&127;for(let e=0;e<8;e++)this.pad[e]=Ne(t,16+2*e)}process(t,e,n=!1){const r=n?0:2048,{h:o,r:s}=this,i=s[0],c=s[1],u=s[2],a=s[3],f=s[4],h=s[5],l=s[6],d=s[7],p=s[8],y=s[9],g=Ne(t,e+0),w=Ne(t,e+2),b=Ne(t,e+4),m=Ne(t,e+6),E=Ne(t,e+8),I=Ne(t,e+10),v=Ne(t,e+12),O=Ne(t,e+14);let U=o[0]+(8191&g),N=o[1]+(8191&(g>>>13|w<<3)),S=o[2]+(8191&(w>>>10|b<<6)),A=o[3]+(8191&(b>>>7|m<<9)),x=o[4]+(8191&(m>>>4|E<<12)),L=o[5]+(E>>>1&8191),$=o[6]+(8191&(E>>>14|I<<2)),k=o[7]+(8191&(I>>>11|v<<5)),j=o[8]+(8191&(v>>>8|O<<8)),P=o[9]+(O>>>5|r),_=0,T=_+U*i+N*(5*y)+S*(5*p)+A*(5*d)+x*(5*l);_=T>>>13,T&=8191,T+=L*(5*h)+$*(5*f)+k*(5*a)+j*(5*u)+P*(5*c),_+=T>>>13,T&=8191;let B=_+U*c+N*i+S*(5*y)+A*(5*p)+x*(5*d);_=B>>>13,B&=8191,B+=L*(5*l)+$*(5*h)+k*(5*f)+j*(5*a)+P*(5*u),_+=B>>>13,B&=8191;let R=_+U*u+N*c+S*i+A*(5*y)+x*(5*p);_=R>>>13,R&=8191,R+=L*(5*d)+$*(5*l)+k*(5*h)+j*(5*f)+P*(5*a),_+=R>>>13,R&=8191;let C=_+U*a+N*u+S*c+A*i+x*(5*y);_=C>>>13,C&=8191,C+=L*(5*p)+$*(5*d)+k*(5*l)+j*(5*h)+P*(5*f),_+=C>>>13,C&=8191;let D=_+U*f+N*a+S*u+A*c+x*i;_=D>>>13,D&=8191,D+=L*(5*y)+$*(5*p)+k*(5*d)+j*(5*l)+P*(5*h),_+=D>>>13,D&=8191;let H=_+U*h+N*f+S*a+A*u+x*c;_=H>>>13,H&=8191,H+=L*i+$*(5*y)+k*(5*p)+j*(5*d)+P*(5*l),_+=H>>>13,H&=8191;let M=_+U*l+N*h+S*f+A*a+x*u;_=M>>>13,M&=8191,M+=L*c+$*i+k*(5*y)+j*(5*p)+P*(5*d),_+=M>>>13,M&=8191;let K=_+U*d+N*l+S*h+A*f+x*a;_=K>>>13,K&=8191,K+=L*u+$*c+k*i+j*(5*y)+P*(5*p),_+=K>>>13,K&=8191;let V=_+U*p+N*d+S*l+A*h+x*f;_=V>>>13,V&=8191,V+=L*a+$*u+k*c+j*i+P*(5*y),_+=V>>>13,V&=8191;let F=_+U*y+N*p+S*d+A*l+x*h;_=F>>>13,F&=8191,F+=L*f+$*a+k*u+j*c+P*i,_+=F>>>13,F&=8191,_=(_<<2)+_|0,_=_+T|0,T=8191&_,_>>>=13,B+=_,o[0]=T,o[1]=B,o[2]=R,o[3]=C,o[4]=D,o[5]=H,o[6]=M,o[7]=K,o[8]=V,o[9]=F}finalize(){const{h:t,pad:e}=this,n=new Uint16Array(10);let r=t[1]>>>13;t[1]&=8191;for(let e=2;e<10;e++)t[e]+=r,r=t[e]>>>13,t[e]&=8191;t[0]+=5*r,r=t[0]>>>13,t[0]&=8191,t[1]+=r,r=t[1]>>>13,t[1]&=8191,t[2]+=r,n[0]=t[0]+5,r=n[0]>>>13,n[0]&=8191;for(let e=1;e<10;e++)n[e]=t[e]+r,r=n[e]>>>13,n[e]&=8191;n[9]-=8192;let o=(1^r)-1;for(let t=0;t<10;t++)n[t]&=o;o=~o;for(let e=0;e<10;e++)t[e]=t[e]&o|n[e];t[0]=65535&(t[0]|t[1]<<13),t[1]=65535&(t[1]>>>3|t[2]<<10),t[2]=65535&(t[2]>>>6|t[3]<<7),t[3]=65535&(t[3]>>>9|t[4]<<4),t[4]=65535&(t[4]>>>12|t[5]<<1|t[6]<<14),t[5]=65535&(t[6]>>>2|t[7]<<11),t[6]=65535&(t[7]>>>5|t[8]<<8),t[7]=65535&(t[8]>>>8|t[9]<<5);let s=t[0]+e[0];t[0]=65535&s;for(let n=1;n<8;n++)s=(t[n]+e[n]|0)+(s>>>16)|0,t[n]=65535&s;ye(n)}update(t){ue(this);const{buffer:e,blockLen:n}=this,r=(t=he(t)).length;for(let o=0;o>>0,t[o++]=n[e]>>>8;return t}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}}const Ae=function(t){const e=(e,n)=>t(n).update(he(e)).digest(),n=t(new Uint8Array(32));return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=e=>t(e),e}((t=>new Se(t)));const xe=function(t,e){const{allowShortKeys:n,extendNonceFn:r,counterLength:o,counterRight:s,rounds:i}=function(t,e){if(null==e||"object"!=typeof e)throw new Error("options must be defined");return Object.assign(t,e)}({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if("function"!=typeof t)throw new Error("core must be a function");return se(o),se(i),ae(s),ae(n),(e,c,u,a,f=0)=>{ce(e),ce(c),ce(u);const h=u.length;if(void 0===a&&(a=new Uint8Array(h)),ce(a),se(f),f<0||f>=Oe)throw new Error("arx: counter overflow");if(a.length=Oe)throw new Error("arx: counter overflow");const y=Math.min(64,u-p);if(h&&64===y){const t=p/4;if(p%4!=0)throw new Error("arx: invalid block position");for(let e,n=0;n<16;n++)e=t+n,d[e]=l[e]^f[n];p+=64}else{for(let t,e=0;e{t.update(e);const n=e.length%16;n&&t.update(Le.subarray(n))},ke=new Uint8Array(32);function je(t,e,n,r,o){const s=t(e,n,ke),i=Ae.create(s);o&&$e(i,o),$e(i,r);const c=new Uint8Array(16),u=(t=>new DataView(t.buffer,t.byteOffset,t.byteLength))(c);de(u,0,BigInt(o?o.length:0),!0),de(u,8,BigInt(r.length),!0),i.update(c);const a=i.digest();return ye(s,c),a}const Pe=((t,e)=>{function n(n,...r){if(ce(n),void 0!==t.nonceLength){const e=r[0];if(!e)throw new Error("nonce / iv required");t.varSizeNonce?ce(e):ce(e,t.nonceLength)}const o=t.tagLength;o&&void 0!==r[1]&&ce(r[1]);const s=e(n,...r),i=(t,e)=>{if(void 0!==e){if(2!==t)throw new Error("cipher output not supported");ce(e)}};let c=!1;return{encrypt(t,e){if(c)throw new Error("cannot encrypt() twice with same key + nonce");return c=!0,ce(t),i(s.encrypt.length,e),s.encrypt(t,e)},decrypt(t,e){if(ce(t),o&&t.lengthr?t.create().update(n).digest():n);for(let t=0;tnew _e(t,e).update(n).digest();Te.create=(t,e)=>new _e(t,e);const Be=new Uint8Array([0]),Re=new Uint8Array;const Ce=(t,e,n,r,o)=>function(t,e,n,r=32){if(J(t),z(r),r>255*t.outputLen)throw new Error("Length should be <= 255*HashLen");const o=Math.ceil(r/t.outputLen);void 0===n&&(n=Re);const s=new Uint8Array(o*t.outputLen),i=Te.create(t,e),c=i._cloneInto(),u=new Uint8Array(i.outputLen);for(let e=0;er-s&&(this.process(n,0),s=0);for(let t=s;t>o&s),c=Number(n&s),u=r?4:0,a=r?0:4;t.setUint32(e+u,i,r),t.setUint32(e+a,c,r)})(n,r-8,BigInt(8*this.length),o),this.process(n,0);const i=rt(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,a=this.get();if(u>a.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t>>3,o=ot(n,17)^ot(n,19)^n>>>10;Fe[t]=o+Fe[t-7]+r+Fe[t-16]|0}let{A:n,B:r,C:o,D:s,E:i,F:c,G:u,H:a}=this;for(let t=0;t<64;t++){const e=a+(ot(i,6)^ot(i,11)^ot(i,25))+De(i,c,u)+Ke[t]+Fe[t]|0,f=(ot(n,2)^ot(n,13)^ot(n,22))+He(n,r,o)|0;a=u,u=c,c=i,i=s+e|0,s=o,o=r,r=n,n=e+f|0}n=n+this.A|0,r=r+this.B|0,o=o+this.C|0,s=s+this.D|0,i=i+this.E|0,c=c+this.F|0,u=u+this.G|0,a=a+this.H|0,this.set(n,r,o,s,i,c,u,a)}roundClean(){Fe.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const qe=ft((()=>new Ge)),We=BigInt(0);function ze(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}function Xe(t){if(!ze(t))throw new Error("Uint8Array expected")}const Je=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));const Ye=48,Ze=57,Qe=65,tn=70,en=97,nn=102;function rn(t){return t>=Ye&&t<=Ze?t-Ye:t>=Qe&&t<=tn?t-(Qe-10):t>=en&&t<=nn?t-(en-10):void 0}function on(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);const e=t.length,n=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let e=0,o=0;e"bigint"==typeof t&&We<=t;function fn(t,e,n,r){if(!function(t,e,n){return an(t)&&an(e)&&an(n)&&e<=t&&t"bigint"==typeof t,function:t=>"function"==typeof t,boolean:t=>"boolean"==typeof t,string:t=>"string"==typeof t,stringOrUint8Array:t=>"string"==typeof t||ze(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>"function"==typeof t&&Number.isSafeInteger(t.outputLen)};const ln=BigInt(0),dn=BigInt(1);function pn(t,e){const n=t%e;return n>=ln?n:e+n}function yn(t,e,n){let r=t;for(;e-- >ln;)r*=r,r%=n;return r}BigInt(0),BigInt(1),BigInt(0),BigInt(1),BigInt(2),BigInt(8);const gn=BigInt(0),wn=BigInt(1);function bn(t){return function(t,e,n={}){const r=(e,n,r)=>{const o=hn[n];if("function"!=typeof o)throw new Error("invalid validator function");const s=t[e];if(!(r&&void 0===s||o(s,t)))throw new Error("param "+String(e)+" is invalid. Expected "+n+", got "+s)};for(const[t,n]of Object.entries(e))r(t,n,!1);for(const[t,e]of Object.entries(n))r(t,e,!0)}(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function mn(t){const e=bn(t),{P:n}=e,r=t=>pn(t,n),o=e.montgomeryBits,s=Math.ceil(o/8),i=e.nByteLength,c=e.adjustScalarBytes||(t=>t),u=e.powPminus2||(t=>function(t,e,n){if(eln;)e&dn&&(r=r*t%n),t=t*t%n,e>>=dn;return r}(t,n-BigInt(2),n));function a(t,e,n){const o=r(t*(e-n));return[e=r(e-o),n=r(n+o)]}const f=(e.a-BigInt(2))/BigInt(4);function h(t){return cn(r(t),s)}function l(t,e){const l=function(t){const e=un("u coordinate",t,s);return 32===i&&(e[31]&=127),sn(e)}(e),d=function(t){const e=un("scalar",t),n=e.length;if(n!==s&&n!==i)throw new Error("invalid scalar, expected "+s+" or "+i+" bytes, got "+n);return sn(c(e))}(t),p=function(t,e){fn("u",t,gn,n),fn("scalar",e,gn,n);const s=e,i=t;let c,h=wn,l=gn,d=t,p=wn,y=gn;for(let t=BigInt(o-1);t>=gn;t--){const e=s>>t&wn;y^=e,c=a(y,h,d),h=c[0],d=c[1],c=a(y,l,p),l=c[0],p=c[1],y=e;const n=h+l,o=r(n*n),u=h-l,g=r(u*u),w=o-g,b=d+p,m=r((d-p)*n),E=r(b*u),I=m+E,v=m-E;d=r(I*I),p=r(i*r(v*v)),h=r(o*g),l=r(w*(o+r(f*w)))}c=a(y,h,d),h=c[0],d=c[1],c=a(y,l,p),l=c[0],p=c[1];const g=u(l);return r(h*g)}(l,d);if(p===gn)throw new Error("invalid private or public key received");return h(p)}const d=h(e.Gu);function p(t){return l(t,d)}return{scalarMult:l,scalarMultBase:p,getSharedSecret:(t,e)=>l(t,e),getPublicKey:t=>p(t),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:d}}const En=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const In=BigInt(1),vn=BigInt(2),On=BigInt(3),Un=BigInt(5);function Nn(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}BigInt(8);const Sn=mn({P:En,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{const e=En,{pow_p_5_8:n,b2:r}=function(t){const e=BigInt(10),n=BigInt(20),r=BigInt(40),o=BigInt(80),s=En,i=t*t%s*t%s,c=yn(i,vn,s)*i%s,u=yn(c,In,s)*t%s,a=yn(u,Un,s)*u%s,f=yn(a,e,s)*a%s,h=yn(f,n,s)*f%s,l=yn(h,r,s)*h%s,d=yn(l,o,s)*l%s,p=yn(d,o,s)*l%s,y=yn(p,e,s)*a%s;return{pow_p_5_8:yn(y,vn,s)*t%s,b2:i}}(t);return pn(yn(n,On,e)*r,e)},adjustScalarBytes:Nn,randomBytes:ht}),An="base10",xn="base16",Ln="base64pad",$n="base64url",kn="utf8",jn=0,Pn=1,_n=2,Tn=0,Bn=1,Rn=12,Cn=32;function Dn(){const t=Sn.utils.randomPrivateKey(),e=Sn.getPublicKey(t);return{privateKey:(0,a.dI)(t,xn),publicKey:(0,a.dI)(e,xn)}}function Hn(){const t=ht(Cn);return(0,a.dI)(t,xn)}function Mn(t,e){const n=Sn.getSharedSecret((0,a.sH)(t,xn),(0,a.sH)(e,xn)),r=Ce(qe,n,void 0,void 0,Cn);return(0,a.dI)(r,xn)}function Kn(t){const e=qe((0,a.sH)(t,xn));return(0,a.dI)(e,xn)}function Vn(t){const e=qe((0,a.sH)(t,kn));return(0,a.dI)(e,xn)}function Fn(t){return(0,a.sH)(`${t}`,An)}function Gn(t){return Number((0,a.dI)(t,An))}function qn(t){const e=Fn(typeof t.type<"u"?t.type:jn);if(Gn(e)===Pn&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const n=typeof t.senderPublicKey<"u"?(0,a.sH)(t.senderPublicKey,xn):void 0,r=typeof t.iv<"u"?(0,a.sH)(t.iv,xn):ht(Rn),o=(0,a.sH)(t.symKey,xn);return Jn({type:e,sealed:Pe(o,r).encrypt((0,a.sH)(t.message,kn)),iv:r,senderPublicKey:n,encoding:t.encoding})}function Wn(t){const e=(0,a.sH)(t.symKey,xn),{sealed:n,iv:r}=Yn(t),o=Pe(e,r).decrypt(n);if(null===o)throw new Error("Failed to decrypt");return(0,a.dI)(o,kn)}function zn(t,e){const n=Fn(_n),r=ht(Rn);return Jn({type:n,sealed:(0,a.sH)(t,kn),iv:r,encoding:e})}function Xn(t,e){const{sealed:n}=Yn({encoded:t,encoding:e});return(0,a.dI)(n,kn)}function Jn(t){const{encoding:e=Ln}=t;if(Gn(t.type)===_n)return(0,a.dI)((0,a.xW)([t.type,t.sealed]),e);if(Gn(t.type)===Pn){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return(0,a.dI)((0,a.xW)([t.type,t.senderPublicKey,t.iv,t.sealed]),e)}return(0,a.dI)((0,a.xW)([t.type,t.iv,t.sealed]),e)}function Yn(t){const{encoded:e,encoding:n=Ln}=t,r=(0,a.sH)(e,n),o=r.slice(Tn,Bn),s=Bn;if(Gn(o)===Pn){const t=s+Cn,e=t+Rn,n=r.slice(s,t),i=r.slice(t,e);return{type:o,sealed:r.slice(e),iv:i,senderPublicKey:n}}if(Gn(o)===_n){return{type:o,sealed:r.slice(s),iv:ht(Rn)}}const i=s+Rn,c=r.slice(s,i);return{type:o,sealed:r.slice(i),iv:c}}function Zn(t,e){const n=Yn({encoded:t,encoding:e?.encoding});return Qn({type:Gn(n.type),senderPublicKey:typeof n.senderPublicKey<"u"?(0,a.dI)(n.senderPublicKey,xn):void 0,receiverPublicKey:e?.receiverPublicKey})}function Qn(t){const e=t?.type||jn;if(e===Pn){if(typeof t?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof t?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:t?.senderPublicKey,receiverPublicKey:t?.receiverPublicKey}}function tr(t){return t.type===Pn&&"string"==typeof t.senderPublicKey&&"string"==typeof t.receiverPublicKey}function er(t){return t.type===_n}function nr(t,e){const[n,r,o]=t.split("."),s=function(t){return Buffer.from(function(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");const n=e.length%4;return n>0&&(e+="=".repeat(4-n)),e}(t),"base64")}(o);if(64!==s.length)throw new Error("Invalid signature length");const i=s.slice(0,32).toString("hex"),c=s.slice(32,64).toString("hex"),h=qe(`${n}.${r}`),l=function(t){return new f.ec("p256").keyFromPublic({x:Buffer.from(t.x,"base64").toString("hex"),y:Buffer.from(t.y,"base64").toString("hex")},"hex")}(e),d=(0,a.dI)(h,xn);if(!l.verify(d,{r:i,s:c}))throw new Error("Invalid signature");return(0,u.Cq)(t).payload}const rr="irn";function or(t){return t?.relay||{protocol:rr}}function sr(t){const e=h.CG[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}function ir(t,e="-"){const n={},r="relay"+e;return Object.keys(t).forEach((e=>{if(e.startsWith(r)){const o=e.replace(r,""),s=t[e];n[o]=s}})),n}function cr(t){if(!t.includes("wc:")){const e=q(t);null!=e&&e.includes("wc:")&&(t=e)}const e=(t=(t=t.includes("wc://")?t.replace("wc://",""):t).includes("wc:")?t.replace("wc:",""):t).indexOf(":"),n=-1!==t.indexOf("?")?t.indexOf("?"):void 0,r=t.substring(0,e),o=t.substring(e+1,n).split("@"),s=typeof n<"u"?t.substring(n):"",i=new URLSearchParams(s),c={};i.forEach(((t,e)=>{c[e]=t}));const u="string"==typeof c.methods?c.methods.split(","):void 0;return{protocol:r,topic:ur(o[0]),version:parseInt(o[1],10),symKey:c.symKey,relay:ir(c),methods:u,expiryTimestamp:c.expiryTimestamp?parseInt(c.expiryTimestamp,10):void 0}}function ur(t){return t.startsWith("//")?t.substring(2):t}function ar(t){const e=new URLSearchParams,n=function(t,e="-"){const n={};return Object.keys(t).forEach((r=>{const o="relay"+e+r;t[r]&&(n[o]=t[r])})),n}(t.relay);Object.keys(n).sort().forEach((t=>{e.set(t,n[t])})),e.set("symKey",t.symKey),t.expiryTimestamp&&e.set("expiryTimestamp",t.expiryTimestamp.toString()),t.methods&&e.set("methods",t.methods.join(","));const r=e.toString();return`${t.protocol}:${t.topic}@${t.version}?${r}`}function fr(t,e,n){return`${t}?wc_ev=${n}&topic=${e}`}Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;function hr(t){const e=[];return t.forEach((t=>{const[n,r]=t.split(":");e.push(`${n}:${r}`)})),e}function lr(t){return t.includes(":")}function dr(t){return lr(t)?t.split(":")[0]:t}function pr(t,e){const n=function(t){const e={};return t?.forEach((t=>{const[n,r]=t.split(":");e[n]||(e[n]={accounts:[],chains:[],events:[]}),e[n].accounts.push(t),e[n].chains.push(`${n}:${r}`)})),e}(e=e.map((t=>t.replace("did:pkh:",""))));for(const[e,r]of Object.entries(n))r.methods?r.methods=H(r.methods,t):r.methods=t,r.events=["chainChanged","accountsChanged"];return n}const yr={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}},gr={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 wr(t,e){const{message:n,code:r}=gr[t];return{message:e?`${n} ${e}`:n,code:r}}function br(t,e){const{message:n,code:r}=yr[t];return{message:e?`${n} ${e}`:n,code:r}}function mr(t,e){return!!Array.isArray(t)&&(!(typeof e<"u"&&t.length)||t.every(e))}function Er(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function Ir(t){return typeof t>"u"}function vr(t,e){return!(!e||!Ir(t))||"string"==typeof t&&!!t.trim().length}function Or(t,e){return!(!e||!Ir(t))||"number"==typeof t&&!isNaN(t)}function Ur(t,e){const{requiredNamespaces:n}=e,r=Object.keys(t.namespaces),o=Object.keys(n);let s=!0;return!!x(o,r)&&(r.forEach((e=>{const{accounts:r,methods:o,events:i}=t.namespaces[e],c=hr(r),u=n[e];x(p(e,u),c)&&x(u.methods,o)&&x(u.events,i)||(s=!1)})),s)}function Nr(t){return!(!vr(t,!1)||!t.includes(":"))&&2===t.split(":").length}function Sr(t){function e(t){try{return typeof new URL(t)<"u"}catch{return!1}}try{if(vr(t,!1)){if(e(t))return!0;return e(q(t))}}catch{}return!1}function Ar(t){var e;return null==(e=t?.proposer)?void 0:e.publicKey}function xr(t){return t?.topic}function Lr(t,e){let n=null;return vr(t?.publicKey,!1)||(n=wr("MISSING_OR_INVALID",`${e} controller public key should be a string`)),n}function $r(t){let e=!0;return mr(t)?t.length&&(e=t.every((t=>vr(t,!1)))):e=!1,e}function kr(t,e,n){let r=null;return Object.entries(t).forEach((([t,o])=>{if(r)return;const s=function(t,e,n){let r=null;return mr(e)&&e.length?e.forEach((t=>{r||Nr(t)||(r=br("UNSUPPORTED_CHAINS",`${n}, chain ${t} should be a string and conform to "namespace:chainId" format`))})):Nr(t)||(r=br("UNSUPPORTED_CHAINS",`${n}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),r}(t,p(t,o),`${e} ${n}`);s&&(r=s)})),r}function jr(t,e){let n=null;return mr(t)?t.forEach((t=>{n||function(t){if(vr(t,!1)&&t.includes(":")){const e=t.split(":");if(3===e.length){const t=e[0]+":"+e[1];return!!e[2]&&Nr(t)}}return!1}(t)||(n=br("UNSUPPORTED_ACCOUNTS",`${e}, account ${t} should be a string and conform to "namespace:chainId:address" format`))})):n=br("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),n}function Pr(t,e){let n=null;return Object.values(t).forEach((t=>{if(n)return;const r=function(t,e){let n=null;return $r(t?.methods)?$r(t?.events)||(n=br("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):n=br("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),n}(t,`${e}, namespace`);r&&(n=r)})),n}function _r(t,e,n){let r=null;if(t&&Er(t)){const o=Pr(t,e);o&&(r=o);const s=kr(t,e,n);s&&(r=s)}else r=wr("MISSING_OR_INVALID",`${e}, ${n} should be an object with data`);return r}function Tr(t,e){let n=null;if(t&&Er(t)){const r=Pr(t,e);r&&(n=r);const o=function(t,e){let n=null;return Object.values(t).forEach((t=>{if(n)return;const r=jr(t?.accounts,`${e} namespace`);r&&(n=r)})),n}(t,e);o&&(n=o)}else n=wr("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return n}function Br(t){return vr(t.protocol,!0)}function Rr(t,e){let n=!1;return e&&!t?n=!0:t&&mr(t)&&t.length&&t.forEach((t=>{n=Br(t)})),n}function Cr(t){return"number"==typeof t}function Dr(t){return typeof t<"u"&&null!==typeof t}function Hr(t){return!!(t&&"object"==typeof t&&t.code&&Or(t.code,!1)&&t.message&&vr(t.message,!1))}function Mr(t){return!(Ir(t)||!vr(t.method,!1))}function Kr(t){return!(Ir(t)||Ir(t.result)&&Ir(t.error)||!Or(t.id,!1)||!vr(t.jsonrpc,!1))}function Vr(t){return!(Ir(t)||!vr(t.name,!1))}function Fr(t,e){return!(!Nr(e)||!function(t){const e=[];return Object.values(t).forEach((t=>{e.push(...hr(t.accounts))})),e}(t).includes(e))}function Gr(t,e,n){return!!vr(n,!1)&&function(t,e){const n=[];return Object.values(t).forEach((t=>{hr(t.accounts).includes(e)&&n.push(...t.methods)})),n}(t,e).includes(n)}function qr(t,e,n){return!!vr(n,!1)&&function(t,e){const n=[];return Object.values(t).forEach((t=>{hr(t.accounts).includes(e)&&n.push(...t.events)})),n}(t,e).includes(n)}function Wr(t,e,n){let r=null;const o=function(t){const e={};return Object.keys(t).forEach((n=>{var r;n.includes(":")?e[n]=t[n]:null==(r=t[n].chains)||r.forEach((r=>{e[r]={methods:t[n].methods,events:t[n].events}}))})),e}(t),s=function(t){const e={};return Object.keys(t).forEach((n=>{if(n.includes(":"))e[n]=t[n];else{const r=hr(t[n].accounts);r?.forEach((r=>{e[r]={accounts:t[n].accounts.filter((t=>t.includes(`${r}:`))),methods:t[n].methods,events:t[n].events}}))}})),e}(e),i=Object.keys(o),c=Object.keys(s),u=zr(Object.keys(t)),a=zr(Object.keys(e)),f=u.filter((t=>!a.includes(t)));return f.length&&(r=wr("NON_CONFORMING_NAMESPACES",`${n} namespaces keys don't satisfy requiredNamespaces.\n Required: ${f.toString()}\n Received: ${Object.keys(e).toString()}`)),x(i,c)||(r=wr("NON_CONFORMING_NAMESPACES",`${n} namespaces chains don't satisfy required namespaces.\n Required: ${i.toString()}\n Approved: ${c.toString()}`)),Object.keys(e).forEach((t=>{if(!t.includes(":")||r)return;const o=hr(e[t].accounts);o.includes(t)||(r=wr("NON_CONFORMING_NAMESPACES",`${n} namespaces accounts don't satisfy namespace accounts for ${t}\n Required: ${t}\n Approved: ${o.toString()}`))})),i.forEach((t=>{r||(x(o[t].methods,s[t].methods)?x(o[t].events,s[t].events)||(r=wr("NON_CONFORMING_NAMESPACES",`${n} namespaces events don't satisfy namespace events for ${t}`)):r=wr("NON_CONFORMING_NAMESPACES",`${n} namespaces methods don't satisfy namespace methods for ${t}`))})),r}function zr(t){return[...new Set(t.map((t=>t.includes(":")?t.split(":")[0]:t)))]}function Xr(t,e){return Or(t,!1)&&t<=e.max&&t>=e.min}function Jr(){const t=O();return new Promise((e=>{switch(t){case g.browser:e(v()&&navigator?.onLine);break;case g.reactNative:e(async function(){if(m()&&typeof n.g<"u"&&null!=n.g&&n.g.NetInfo){const t=await(null==n.g?void 0:n.g.NetInfo.fetch());return t?.isConnected}return!0}());break;case g.node:default:e(!0)}}))}function Yr(t){switch(O()){case g.browser:!function(t){!m()&&v()&&(window.addEventListener("online",(()=>t(!0))),window.addEventListener("offline",(()=>t(!1))))}(t);break;case g.reactNative:!function(t){m()&&typeof n.g<"u"&&null!=n.g&&n.g.NetInfo&&n.g?.NetInfo.addEventListener((e=>t(e?.isConnected)))}(t);case g.node:}}const Zr={};class Qr{static get(t){return Zr[t]}static set(t,e){Zr[t]=e}static delete(t){delete Zr[t]}}}}]);