@skip-go/widget-web-component 3.14.3 → 3.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/1125.index.js +3 -0
- package/build/1133.index.js +8 -0
- package/build/1136.index.js +9 -0
- package/build/1139.index.js +18 -0
- package/build/1171.index.js +1 -1
- package/build/1189.index.js +1 -1
- package/build/1203.index.js +1 -1
- package/build/1207.index.js +1 -1
- package/build/1211.index.js +8 -0
- package/build/1226.index.js +8 -0
- package/build/1349.index.js +1 -1
- package/build/1361.index.js +1 -1
- package/build/1363.index.js +1 -1
- package/build/1370.index.js +1 -1
- package/build/1415.index.js +8 -0
- package/build/1426.index.js +3 -0
- package/build/1470.index.js +1 -1
- package/build/1572.index.js +11 -0
- package/build/1716.index.js +1 -1
- package/build/1776.index.js +8 -0
- package/build/1852.index.js +1 -1
- package/build/1881.index.js +1 -1
- package/build/1894.index.js +1 -1
- package/build/1911.index.js +1 -1
- package/build/1951.index.js +18 -0
- package/build/1979.index.js +30 -0
- package/build/2034.index.js +1 -1
- package/build/2131.index.js +1 -1
- package/build/2166.index.js +1 -1
- package/build/2202.index.js +61 -0
- package/build/2242.index.js +1 -1
- package/build/2289.index.js +8 -0
- package/build/2301.index.js +1 -1
- package/build/2410.index.js +1 -1
- package/build/2422.index.js +1 -0
- package/build/245.index.js +1 -1
- package/build/2496.index.js +1 -1
- package/build/2557.index.js +17 -0
- package/build/2699.index.js +1 -1
- package/build/2715.index.js +8 -0
- package/build/283.index.js +8 -0
- package/build/2844.index.js +13 -0
- package/build/2851.index.js +1 -0
- package/build/2902.index.js +15 -0
- package/build/3070.index.js +1 -1
- package/build/3099.index.js +8 -0
- package/build/3105.index.js +8 -0
- package/build/3131.index.js +6 -0
- package/build/3148.index.js +1 -1
- package/build/3472.index.js +1 -1
- package/build/3550.index.js +8 -0
- package/build/3574.index.js +1 -1
- package/build/362.index.js +12 -0
- package/build/3646.index.js +32 -0
- package/build/3726.index.js +1 -1
- package/build/3828.index.js +14 -0
- package/build/385.index.js +1 -1
- package/build/3857.index.js +14 -0
- package/build/3874.index.js +17 -0
- package/build/4028.index.js +1 -1
- package/build/4150.index.js +620 -0
- package/build/4194.index.js +317 -0
- package/build/4203.index.js +1 -1
- package/build/4226.index.js +14 -0
- package/build/4249.index.js +8 -0
- package/build/4264.index.js +1 -0
- package/build/428.index.js +1 -0
- package/build/4289.index.js +1 -1
- package/build/4319.index.js +1 -1
- package/build/4379.index.js +2069 -0
- package/build/4446.index.js +2 -0
- package/build/4683.index.js +1 -1
- package/build/4693.index.js +2 -2
- package/build/4729.index.js +1 -1
- package/build/4733.index.js +12 -0
- package/build/4857.index.js +12 -0
- package/build/4969.index.js +1 -1
- package/build/5069.index.js +1 -1
- package/build/5090.index.js +8 -0
- package/build/5193.index.js +1 -1
- package/build/5206.index.js +14 -0
- package/build/5218.index.js +6 -0
- package/build/5330.index.js +8 -0
- package/build/537.index.js +1 -1
- package/build/5438.index.js +9 -0
- package/build/5526.index.js +1 -1
- package/build/5572.index.js +1 -1
- package/build/5619.index.js +1 -1
- package/build/5642.index.js +2 -0
- package/build/5647.index.js +1 -1
- package/build/5737.index.js +1 -1
- package/build/577.index.js +8 -0
- package/build/5880.index.js +1 -1
- package/build/590.index.js +1 -1
- package/build/5972.index.js +622 -0
- package/build/602.index.js +9 -0
- package/build/6024.index.js +1 -1
- package/build/6036.index.js +8 -0
- package/build/6075.index.js +1 -1
- package/build/6123.index.js +1 -1
- package/build/6127.index.js +1 -1
- package/build/6138.index.js +18 -0
- package/build/6148.index.js +1 -1
- package/build/6151.index.js +1 -1
- package/build/6175.index.js +4 -0
- package/build/631.index.js +18 -0
- package/build/6323.index.js +1 -1
- package/build/6442.index.js +1 -1
- package/build/6484.index.js +1 -1
- package/build/6543.index.js +1 -1
- package/build/6553.index.js +8 -0
- package/build/6558.index.js +1 -0
- package/build/6573.index.js +1 -1
- package/build/6611.index.js +12 -0
- package/build/6639.index.js +8 -0
- package/build/6654.index.js +1 -0
- package/build/6705.index.js +12 -0
- package/build/6715.index.js +12 -0
- package/build/674.index.js +317 -0
- package/build/674.index.js.LICENSE.txt +17 -0
- package/build/6753.index.js +1 -1
- package/build/6811.index.js +8 -0
- package/build/6813.index.js +4 -0
- package/build/6869.index.js +1 -1
- package/build/6969.index.js +12 -0
- package/build/7172.index.js +1 -1
- package/build/7176.index.js +16 -0
- package/build/7201.index.js +878 -0
- package/build/7272.index.js +6 -0
- package/build/7311.index.js +11 -0
- package/build/7409.index.js +1 -0
- package/build/7428.index.js +4 -0
- package/build/7540.index.js +8 -0
- package/build/7618.index.js +1 -1
- package/build/7762.index.js +1 -1
- package/build/7780.index.js +3 -0
- package/build/7981.index.js +1 -1
- package/build/8000.index.js +1 -1
- package/build/8029.index.js +8 -0
- package/build/8036.index.js +1 -1
- package/build/8147.index.js +16 -0
- package/build/8249.index.js +8 -0
- package/build/8318.index.js +1 -1
- package/build/8367.index.js +1 -1
- package/build/8373.index.js +2082 -0
- package/build/8373.index.js.LICENSE.txt +5 -0
- package/build/8467.index.js +1 -1
- package/build/8483.index.js +1 -1
- package/build/8631.index.js +8 -0
- package/build/8645.index.js +2 -0
- package/build/8645.index.js.LICENSE.txt +11 -0
- package/build/8714.index.js +8 -0
- package/build/8717.index.js +6 -0
- package/build/8904.index.js +1 -1
- package/build/896.index.js +1 -1
- package/build/8964.index.js +26 -0
- package/build/897.index.js +11 -0
- package/build/9081.index.js +8 -0
- package/build/9120.index.js +8 -0
- package/build/913.index.js +15 -0
- package/build/9192.index.js +1 -0
- package/build/9194.index.js +878 -4
- package/build/9309.index.js +15 -0
- package/build/9313.index.js +8 -0
- package/build/9372.index.js +1 -1
- package/build/9396.index.js +12 -0
- package/build/9476.index.js +1 -1
- package/build/9607.index.js +8 -0
- package/build/967.index.js +5 -0
- package/build/984.index.js +8 -0
- package/build/9850.index.js +14 -0
- package/build/9884.index.js +1 -1
- package/build/index.js +769 -1633
- package/build/index.js.LICENSE.txt +6 -16
- package/package.json +1 -1
- package/build/1179.index.js +0 -2
- package/build/1256.index.js +0 -317
- package/build/1934.index.js +0 -2
- package/build/1934.index.js.LICENSE.txt +0 -17
- package/build/4619.index.js +0 -622
- package/build/4833.index.js +0 -2
- package/build/5902.index.js +0 -2
- package/build/6319.index.js +0 -2069
- package/build/6700.index.js +0 -1
- package/build/7084.index.js +0 -2
- package/build/7544.index.js +0 -1
- package/build/7591.index.js +0 -1
- package/build/8780.index.js +0 -1
- /package/build/{1256.index.js.LICENSE.txt → 4194.index.js.LICENSE.txt} +0 -0
- /package/build/{6319.index.js.LICENSE.txt → 4379.index.js.LICENSE.txt} +0 -0
- /package/build/{4833.index.js.LICENSE.txt → 4446.index.js.LICENSE.txt} +0 -0
- /package/build/{1179.index.js.LICENSE.txt → 5642.index.js.LICENSE.txt} +0 -0
- /package/build/{5902.index.js.LICENSE.txt → 7201.index.js.LICENSE.txt} +0 -0
- /package/build/{7084.index.js.LICENSE.txt → 9194.index.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1,878 @@
|
|
|
1
|
+
/*! For license information please see 7201.index.js.LICENSE.txt */
|
|
2
|
+
export const __webpack_esm_id__=7201;export const __webpack_esm_ids__=[7201];export const __webpack_esm_modules__={1057:(e,t,s)=>{s.d(t,{A:()=>Xe});var i=s(37876),r=s(47431),n=s(70255),o=s(64264),a=s(93786),c=s(14350),h=s(50046),l=s.n(h),p=s(48526).hp;const d="error",u="wc@2:universal_provider:",g="https://rpc.walletconnect.org/v1/",f="generic",m=`${g}bundler`,w="default_chain_changed";function y(){}function b(e){return null==e||"object"!=typeof e&&"function"!=typeof e}function v(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function E(e){return"object"==typeof e&&null!==e}function I(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}function _(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const N="[object String]",A="[object Number]",C="[object Boolean]",P="[object Arguments]";function S(e,t,s,i=new Map,r=void 0){const n=r?.(e,t,s,i);if(null!=n)return n;if(b(e))return e;if(i.has(e))return i.get(e);if(Array.isArray(e)){const t=new Array(e.length);i.set(e,t);for(let n=0;n<e.length;n++)t[n]=S(e[n],n,s,i,r);return Object.hasOwn(e,"index")&&(t.index=e.index),Object.hasOwn(e,"input")&&(t.input=e.input),t}if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){const t=new RegExp(e.source,e.flags);return t.lastIndex=e.lastIndex,t}if(e instanceof Map){const t=new Map;i.set(e,t);for(const[n,o]of e)t.set(n,S(o,n,s,i,r));return t}if(e instanceof Set){const t=new Set;i.set(e,t);for(const n of e)t.add(S(n,void 0,s,i,r));return t}if(typeof p<"u"&&p.isBuffer(e))return e.subarray();if(v(e)){const t=new(Object.getPrototypeOf(e).constructor)(e.length);i.set(e,t);for(let n=0;n<e.length;n++)t[n]=S(e[n],n,s,i,r);return t}if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer)return e.slice(0);if(e instanceof DataView){const t=new DataView(e.buffer.slice(0),e.byteOffset,e.byteLength);return i.set(e,t),O(t,e,s,i,r),t}if(typeof File<"u"&&e instanceof File){const t=new File([e],e.name,{type:e.type});return i.set(e,t),O(t,e,s,i,r),t}if(e instanceof Blob){const t=new Blob([e],{type:e.type});return i.set(e,t),O(t,e,s,i,r),t}if(e instanceof Error){const t=new e.constructor;return i.set(e,t),t.message=e.message,t.name=e.name,t.stack=e.stack,t.cause=e.cause,O(t,e,s,i,r),t}if("object"==typeof e&&function(e){switch(_(e)){case P:case"[object Array]":case"[object ArrayBuffer]":case"[object DataView]":case C:case"[object Date]":case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Map]":case A:case"[object Object]":case"[object RegExp]":case"[object Set]":case N:case"[object Symbol]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return!0;default:return!1}}(e)){const t=Object.create(Object.getPrototypeOf(e));return i.set(e,t),O(t,e,s,i,r),t}return e}function O(e,t,s=e,i,r){const n=[...Object.keys(t),...I(t)];for(let o=0;o<n.length;o++){const a=n[o],c=Object.getOwnPropertyDescriptor(e,a);(null==c||c.writable)&&(e[a]=S(t[a],a,s,i,r))}}function T(e){return function(e,t){return function(e,t){return S(e,void 0,e,new Map,t)}(e,(s,i,r,n)=>{const o=t?.(s,i,r,n);if(null!=o)return o;if("object"==typeof e)switch(Object.prototype.toString.call(e)){case A:case N:case C:{const t=new e.constructor(e?.valueOf());return O(t,e),t}case P:{const t={};return O(t,e),t.length=e.length,t[Symbol.iterator]=e[Symbol.iterator],t}default:return}})}(e)}function k(e){return null!==e&&"object"==typeof e&&"[object Arguments]"===_(e)}function x(e){return v(e)}function R(e){if("object"!=typeof e||null==e)return!1;if(null===Object.getPrototypeOf(e))return!0;if("[object Object]"!==Object.prototype.toString.call(e)){const t=e[Symbol.toStringTag];return!(null==t||!Object.getOwnPropertyDescriptor(e,Symbol.toStringTag)?.writable)&&e.toString()===`[object ${t}]`}let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function U(e,t,s,i){if(b(e)&&(e=Object(e)),null==t||"object"!=typeof t)return e;if(i.has(t))return function(e){if(b(e))return e;if(Array.isArray(e)||v(e)||e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer)return e.slice(0);const t=Object.getPrototypeOf(e),s=t.constructor;if(e instanceof Date||e instanceof Map||e instanceof Set)return new s(e);if(e instanceof RegExp){const t=new s(e);return t.lastIndex=e.lastIndex,t}if(e instanceof DataView)return new s(e.buffer.slice(0));if(e instanceof Error){const t=new s(e.message);return t.stack=e.stack,t.name=e.name,t.cause=e.cause,t}if(typeof File<"u"&&e instanceof File)return new s([e],e.name,{type:e.type,lastModified:e.lastModified});if("object"==typeof e){const s=Object.create(t);return Object.assign(s,e)}return e}(i.get(t));if(i.set(t,e),Array.isArray(t)){t=t.slice();for(let e=0;e<t.length;e++)t[e]=t[e]??void 0}const r=[...Object.keys(t),...I(t)];for(let n=0;n<r.length;n++){const o=r[n];let a=t[o],c=e[o];if(k(a)&&(a={...a}),k(c)&&(c={...c}),typeof p<"u"&&p.isBuffer(a)&&(a=T(a)),Array.isArray(a))if("object"==typeof c&&null!=c){const e=[],t=Reflect.ownKeys(c);for(let s=0;s<t.length;s++){const i=t[s];e[i]=c[i]}c=e}else c=[];const h=s(c,a,o,e,t,i);null!=h?e[o]=h:Array.isArray(a)||E(c)&&E(a)?e[o]=U(c,a,s,i):null==c&&R(a)?e[o]=U({},a,s,i):null==c&&x(a)?e[o]=T(a):(void 0===c||void 0!==a)&&(e[o]=a)}return e}var D=Object.defineProperty,j=Object.defineProperties,M=Object.getOwnPropertyDescriptors,L=Object.getOwnPropertySymbols,q=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable,B=(e,t,s)=>t in e?D(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,H=(e,t)=>{for(var s in t||(t={}))q.call(t,s)&&B(e,s,t[s]);if(L)for(var s of L(t))$.call(t,s)&&B(e,s,t[s]);return e},W=(e,t)=>j(e,M(t));function z(e,t,s){var i;const n=(0,r._Yb)(e);return(null==(i=t.rpcMap)?void 0:i[n.reference])||`${g}?chainId=${n.namespace}:${n.reference}&projectId=${s}`}function V(e){return e.includes(":")?e.split(":")[1]:e}function F(e){return e.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function K(e={},t={}){return function(e,...t){return function(e,...t){const s=t.slice(0,-1),i=t[t.length-1];let r=e;for(let e=0;e<s.length;e++)r=U(r,s[e],i,new Map);return r}(e,...t,y)}(G(e),G(t))}function G(e){var t,s,i,n;const o={};if(!(0,r.aF0)(e))return o;for(const[a,c]of Object.entries(e)){const e=(0,r.nWe)(a)?[a]:c.chains,h=c.methods||[],l=c.events||[],p=c.rpcMap||{},d=(0,r.kob)(a);o[d]=W(H(H({},o[d]),c),{chains:(0,r.TRk)(e,null==(t=o[d])?void 0:t.chains),methods:(0,r.TRk)(h,null==(s=o[d])?void 0:s.methods),events:(0,r.TRk)(l,null==(i=o[d])?void 0:i.events),rpcMap:H(H({},p),null==(n=o[d])?void 0:n.rpcMap)})}return o}function J(e){return e.includes(":")?e.split(":")[2]:e}function Y(e){const t={};for(const[s,i]of Object.entries(e)){const e=i.methods||[],n=i.events||[],o=i.accounts||[],a=(0,r.nWe)(s)?[s]:i.chains?i.chains:F(i.accounts);t[s]={chains:a,methods:e,events:n,accounts:o}}return t}function Q(e){return"number"==typeof e?e:e.includes("0x")?parseInt(e,16):(e=e.includes(":")?e.split(":")[1]:e,isNaN(Number(e))?e:Number(e))}const X={},Z=e=>X[e],ee=(e,t)=>{X[e]=t};var te=Object.defineProperty,se=(e,t,s)=>((e,t,s)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class ie{constructor(e){se(this,"name","polkadot"),se(this,"client"),se(this,"httpProviders"),se(this,"events"),se(this,"namespace"),se(this,"chainId"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(w,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e&&e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;const i=V(t);e[i]=this.createHttpProvider(i,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||z(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(s,Z("disableProviderPing")))}}var re=Object.defineProperty,ne=Object.defineProperties,oe=Object.getOwnPropertyDescriptors,ae=Object.getOwnPropertySymbols,ce=Object.prototype.hasOwnProperty,he=Object.prototype.propertyIsEnumerable,le=(e,t,s)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,pe=(e,t)=>{for(var s in t||(t={}))ce.call(t,s)&&le(e,s,t[s]);if(ae)for(var s of ae(t))he.call(t,s)&&le(e,s,t[s]);return e},de=(e,t)=>ne(e,oe(t)),ue=(e,t,s)=>le(e,"symbol"!=typeof t?t+"":t,s);class ge{constructor(e){ue(this,"name","eip155"),ue(this,"client"),ue(this,"chainId"),ue(this,"namespace"),ue(this,"httpProviders"),ue(this,"events"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(e);case"wallet_getCallsStatus":return await this.getCallStatus(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(parseInt(e),t),this.chainId=parseInt(e),this.events.emit(w,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,t){const s=t||z(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.V(s,Z("disableProviderPing")))}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;const i=parseInt(V(t));e[i]=this.createHttpProvider(i,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}async handleSwitchChain(e){var t,s;let i=e.request.params?null==(t=e.request.params[0])?void 0:t.chainId:"0x0";i=i.startsWith("0x")?i:`0x${i}`;const r=parseInt(i,16);if(this.isChainApproved(r))this.setDefaultChain(`${r}`);else{if(!this.namespace.methods.includes("wallet_switchEthereumChain"))throw new Error(`Failed to switch to chain 'eip155:${r}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:i}]},chainId:null==(s=this.namespace.chains)?void 0:s[0]}),this.setDefaultChain(`${r}`)}return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var t,s,i;const r=null==(s=null==(t=e.request)?void 0:t.params)?void 0:s[0];if(!r)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const n=this.client.session.get(e.topic),o=(null==(i=n?.sessionProperties)?void 0:i.capabilities)||{};if(null!=o&&o[r])return o?.[r];const a=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:de(pe({},n.sessionProperties||{}),{capabilities:de(pe({},o||{}),{[r]:a})})})}catch(e){console.warn("Failed to update session with capabilities",e)}return a}async getCallStatus(e){var t,s;const i=this.client.session.get(e.topic),r=null==(t=i.sessionProperties)?void 0:t.bundler_name;if(r){const t=this.getBundlerUrl(e.chainId,r);try{return await this.getUserOperationReceipt(t,e)}catch(e){console.warn("Failed to fetch call status from bundler",e,t)}}const n=null==(s=i.sessionProperties)?void 0:s.bundler_url;if(n)try{return await this.getUserOperationReceipt(n,e)}catch(e){console.warn("Failed to fetch call status from custom bundler",e,n)}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,t){var s;const i=new URL(e),r=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify((0,c.formatJsonRpcRequest)("eth_getUserOperationReceipt",[null==(s=t.request.params)?void 0:s[0]]))});if(!r.ok)throw new Error(`Failed to fetch user operation receipt - ${r.status}`);return await r.json()}getBundlerUrl(e,t){return`${m}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${t}`}}var fe=Object.defineProperty,me=(e,t,s)=>((e,t,s)=>t in e?fe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class we{constructor(e){me(this,"name","solana"),me(this,"client"),me(this,"httpProviders"),me(this,"events"),me(this,"namespace"),me(this,"chainId"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(w,`${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(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;const i=V(t);e[i]=this.createHttpProvider(i,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||z(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(s,Z("disableProviderPing")))}}var ye=Object.defineProperty,be=(e,t,s)=>((e,t,s)=>t in e?ye(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class ve{constructor(e){be(this,"name","cosmos"),be(this,"client"),be(this,"httpProviders"),be(this,"events"),be(this,"namespace"),be(this,"chainId"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(w,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;const i=V(t);e[i]=this.createHttpProvider(i,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||z(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(s,Z("disableProviderPing")))}}var Ee=Object.defineProperty,Ie=(e,t,s)=>((e,t,s)=>t in e?Ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class _e{constructor(e){Ie(this,"name","algorand"),Ie(this,"client"),Ie(this,"httpProviders"),Ie(this,"events"),Ie(this,"namespace"),Ie(this,"chainId"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(!this.httpProviders[e]){const s=t||z(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,s)}this.chainId=e,this.events.emit(w,`${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(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;e[t]=this.createHttpProvider(t,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||z(e,this.namespace,this.client.core.projectId);return typeof s>"u"?void 0:new a.F(new o.A(s,Z("disableProviderPing")))}}var Ne=Object.defineProperty,Ae=(e,t,s)=>((e,t,s)=>t in e?Ne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Ce{constructor(e){Ae(this,"name","cip34"),Ae(this,"client"),Ae(this,"httpProviders"),Ae(this,"events"),Ae(this,"namespace"),Ae(this,"chainId"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(w,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{const s=this.getCardanoRPCUrl(t),i=V(t);e[i]=this.createHttpProvider(i,s)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}getCardanoRPCUrl(e){const t=this.namespace.rpcMap;if(t)return t[e]}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||this.getCardanoRPCUrl(e);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(s,Z("disableProviderPing")))}}var Pe=Object.defineProperty,Se=(e,t,s)=>((e,t,s)=>t in e?Pe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Oe{constructor(e){Se(this,"name","elrond"),Se(this,"client"),Se(this,"httpProviders"),Se(this,"events"),Se(this,"namespace"),Se(this,"chainId"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(w,`${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(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;const i=V(t);e[i]=this.createHttpProvider(i,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||z(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(s,Z("disableProviderPing")))}}var Te=Object.defineProperty,ke=(e,t,s)=>((e,t,s)=>t in e?Te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class xe{constructor(e){ke(this,"name","multiversx"),ke(this,"client"),ke(this,"httpProviders"),ke(this,"events"),ke(this,"namespace"),ke(this,"chainId"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(w,`${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(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;const i=V(t);e[i]=this.createHttpProvider(i,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||z(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(s,Z("disableProviderPing")))}}var Re=Object.defineProperty,Ue=(e,t,s)=>((e,t,s)=>t in e?Re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class De{constructor(e){Ue(this,"name","near"),Ue(this,"client"),Ue(this,"httpProviders"),Ue(this,"events"),Ue(this,"namespace"),Ue(this,"chainId"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const s=t||z(`${this.name}:${e}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,s)}this.events.emit(w,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e&&e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;e[t]=this.createHttpProvider(t,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||z(e,this.namespace);return typeof s>"u"?void 0:new a.F(new o.A(s,Z("disableProviderPing")))}}var je=Object.defineProperty,Me=(e,t,s)=>((e,t,s)=>t in e?je(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Le{constructor(e){Me(this,"name","tezos"),Me(this,"client"),Me(this,"httpProviders"),Me(this,"events"),Me(this,"namespace"),Me(this,"chainId"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const s=t||z(`${this.name}:${e}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,s)}this.events.emit(w,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e&&e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{e[t]=this.createHttpProvider(t)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||z(e,this.namespace);return typeof s>"u"?void 0:new a.F(new o.A(s))}}var qe=Object.defineProperty,$e=(e,t,s)=>((e,t,s)=>t in e?qe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Be{constructor(e){$e(this,"name",f),$e(this,"client"),$e(this,"httpProviders"),$e(this,"events"),$e(this,"namespace"),$e(this,"chainId"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(w,`${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(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){var e,t;const s={};return null==(t=null==(e=this.namespace)?void 0:e.accounts)||t.forEach(e=>{const t=(0,r._Yb)(e);s[`${t.namespace}:${t.reference}`]=this.createHttpProvider(e)}),s}getHttpProvider(e){const t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||z(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(s,Z("disableProviderPing")))}}var He=Object.defineProperty,We=Object.defineProperties,ze=Object.getOwnPropertyDescriptors,Ve=Object.getOwnPropertySymbols,Fe=Object.prototype.hasOwnProperty,Ke=Object.prototype.propertyIsEnumerable,Ge=(e,t,s)=>t in e?He(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Je=(e,t)=>{for(var s in t||(t={}))Fe.call(t,s)&&Ge(e,s,t[s]);if(Ve)for(var s of Ve(t))Ke.call(t,s)&&Ge(e,s,t[s]);return e},Ye=(e,t)=>We(e,ze(t)),Qe=(e,t,s)=>Ge(e,"symbol"!=typeof t?t+"":t,s);class Xe{constructor(e){Qe(this,"client"),Qe(this,"namespaces"),Qe(this,"optionalNamespaces"),Qe(this,"sessionProperties"),Qe(this,"scopedProperties"),Qe(this,"events",new(l())),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?.logger<"u"&&"string"!=typeof e?.logger?e.logger:(0,n.h6)((0,n.iP)({level:e?.logger||d})),this.disableProviderPing=e?.disableProviderPing||!1}static async init(e){const t=new Xe(e);return await t.initialize(),t}async request(e,t,s){const[i,r]=this.validateChain(t);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(i).request({request:Je({},e),chainId:`${i}:${r}`,topic:this.session.topic,expiry:s})}sendAsync(e,t,s,i){const r=(new Date).getTime();this.request(e,s,i).then(e=>t(null,(0,c.formatJsonRpcResult)(r,e))).catch(e=>t(e,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:null==(e=this.session)?void 0:e.topic,reason:(0,r.Hjj)("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,t){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:s,response:i}=await this.client.authenticate(e,t);s&&(this.uri=s,this.events.emit("display_uri",s));const r=await i();if(this.session=r.session,this.session){const e=Y(this.session.namespaces);this.namespaces=K(this.namespaces,e),await this.persist("namespaces",this.namespaces),this.onConnect()}return r}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}removeListener(e,t){this.events.removeListener(e,t)}off(e,t){this.events.off(e,t)}get isWalletConnect(){return!0}async pair(e){const{uri:t,approval:s}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties});t&&(this.uri=t,this.events.emit("display_uri",t));const i=await s();this.session=i;const r=Y(i.namespaces);return this.namespaces=K(this.namespaces,r),await this.persist("namespaces",this.namespaces),await this.persist("optionalNamespaces",this.optionalNamespaces),this.onConnect(),this.session}setDefaultChain(e,t){try{if(!this.session)return;const[s,i]=this.validateChain(e),r=this.getProvider(s);r.name===f?r.setDefaultChain(`${s}:${i}`,t):r.setDefaultChain(i,t)}catch(e){if(!/Please call connect/.test(e.message))throw e}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const t=this.client.pairing.getAll();if((0,r.OP1)(t)){for(const s of t)e.deletePairings?this.client.core.expirer.set(s.topic,0):await this.client.core.relayer.subscriber.unsubscribe(s.topic);this.logger.info(`Inactive pairings cleared: ${t.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,t;if(this.client=this.providerOpts.client||await i.Ay.init({core:this.providerOpts.core,logger:this.providerOpts.logger||d,relayUrl:this.providerOpts.relayUrl||"wss://relay.walletconnect.org",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(s){throw this.logger.error("Failed to get session",s),new Error(`The provided session: ${null==(t=null==(e=this.providerOpts)?void 0:e.session)?void 0:t.topic} doesn't exist in the Sign client`)}else{const e=this.client.session.getAll();this.session=e[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(e=>(0,r.kob)(e)))];ee("client",this.client),ee("events",this.events),ee("disableProviderPing",this.disableProviderPing),e.forEach(e=>{if(!this.session)return;const t=function(e,t){const s=Object.keys(t.namespaces).filter(t=>t.includes(e));if(!s.length)return[];const i=[];return s.forEach(e=>{const s=t.namespaces[e].accounts;i.push(...s)}),i}(e,this.session),s=F(t),i=K(this.namespaces,this.optionalNamespaces),r=Ye(Je({},i[e]),{accounts:t,chains:s});switch(e){case"eip155":this.rpcProviders[e]=new ge({namespace:r});break;case"algorand":this.rpcProviders[e]=new _e({namespace:r});break;case"solana":this.rpcProviders[e]=new we({namespace:r});break;case"cosmos":this.rpcProviders[e]=new ve({namespace:r});break;case"polkadot":this.rpcProviders[e]=new ie({namespace:r});break;case"cip34":this.rpcProviders[e]=new Ce({namespace:r});break;case"elrond":this.rpcProviders[e]=new Oe({namespace:r});break;case"multiversx":this.rpcProviders[e]=new xe({namespace:r});break;case"near":this.rpcProviders[e]=new De({namespace:r});break;case"tezos":this.rpcProviders[e]=new Le({namespace:r});break;default:this.rpcProviders[f]?this.rpcProviders[f].updateNamespace(r):this.rpcProviders[f]=new Be({namespace:r})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{var t;const{topic:s}=e;s===(null==(t=this.session)?void 0:t.topic)&&this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{var t;const{params:s,topic:i}=e;if(i!==(null==(t=this.session)?void 0:t.topic))return;const{event:n}=s;if("accountsChanged"===n.name){const e=n.data;e&&(0,r.OP1)(e)&&this.events.emit("accountsChanged",e.map(J))}else if("chainChanged"===n.name){const e=s.chainId,t=s.event.data,i=(0,r.kob)(e),n=Q(e)!==Q(t)?`${i}:${Q(t)}`:e;this.onChainChanged(n)}else this.events.emit(n.name,n.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:t})=>{var s,i;if(e!==(null==(s=this.session)?void 0:s.topic))return;const{namespaces:r}=t,n=null==(i=this.client)?void 0:i.session.get(e);this.session=Ye(Je({},n),{namespaces:r}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:t})}),this.client.on("session_delete",async e=>{var t;e.topic===(null==(t=this.session)?void 0:t.topic)&&(await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",Ye(Je({},(0,r.Hjj)("USER_DISCONNECTED")),{data:e.topic})))}),this.on(w,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[f]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var t;this.getProvider(e).updateNamespace(null==(t=this.session)?void 0:t.namespaces[e])})}setNamespaces(e){const{namespaces:t,optionalNamespaces:s,sessionProperties:i,scopedProperties:r}=e;t&&Object.keys(t).length&&(this.namespaces=t),s&&Object.keys(s).length&&(this.optionalNamespaces=s),this.sessionProperties=i,this.scopedProperties=r}validateChain(e){const[t,s]=e?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[t,s];if(t&&!Object.keys(this.namespaces||{}).map(e=>(0,r.kob)(e)).includes(t))throw new Error(`Namespace '${t}' is not configured. Please call connect() first with namespace config.`);if(t&&s)return[t,s];const i=(0,r.kob)(Object.keys(this.namespaces)[0]);return[i,this.rpcProviders[i].getDefaultChain()]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}async onChainChanged(e,t=!1){if(!this.namespaces)return;const[s,i]=this.validateChain(e);i&&(t||this.getProvider(s).setDefaultChain(i),this.namespaces[s]?this.namespaces[s].defaultChain=i:this.namespaces[`${s}:${i}`]?this.namespaces[`${s}:${i}`].defaultChain=i:this.namespaces[`${s}:${i}`]={defaultChain:i},this.events.emit("chainChanged",i),await this.persist("namespaces",this.namespaces))}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,t){var s;const i=(null==(s=this.session)?void 0:s.topic)||"";await this.client.core.storage.setItem(`${u}/${e}${i}`,t)}async getFromStore(e){var t;const s=(null==(t=this.session)?void 0:t.topic)||"";return await this.client.core.storage.getItem(`${u}/${e}${s}`)}async deleteFromStore(e){var t;const s=(null==(t=this.session)?void 0:t.topic)||"";await this.client.core.storage.removeItem(`${u}/${e}${s}`)}async cleanupStorage(){var e;try{if((null==(e=this.client)?void 0:e.session.length)>0)return;const t=await this.client.core.storage.getKeys();for(const e of t)e.startsWith(u)&&await this.client.core.storage.removeItem(e)}catch(e){this.logger.warn("Failed to cleanup storage",e)}}}},3496:(e,t,s)=>{s.d(t,{r:()=>h});var i=s(23464),r=s(38851),n=s(25562),o=s(93384);i.extend(n),i.extend(o);const a={...r,name:"en-web3-modal",relativeTime:{future:"in %s",past:"%s ago",s:"%d sec",m:"1 min",mm:"%d min",h:"1 hr",hh:"%d hrs",d:"1 d",dd:"%d d",M:"1 mo",MM:"%d mo",y:"1 yr",yy:"%d yr"}},c=["January","February","March","April","May","June","July","August","September","October","November","December"];i.locale("en-web3-modal",a);const h={getMonthNameByIndex:e=>c[e],getYear:(e=(new Date).toISOString())=>i(e).year(),getRelativeDateFromNow:e=>i(e).locale("en-web3-modal").fromNow(!0),formatDate:(e,t="DD MMM")=>i(e).format(t)}},3665:(e,t,s)=>{s.d(t,{$Q:()=>b,GF:()=>y,S9:()=>I,Vx:()=>m,ZP:()=>c,dQ:()=>p,lZ:()=>l,m5:()=>u,mF:()=>f,pi:()=>g,qE:()=>d,yJ:()=>_,zl:()=>w});var i=s(94549),r=s(50046),n=s.n(r),o=Object.defineProperty,a=(e,t,s)=>((e,t,s)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class c extends i.H{constructor(e){super(),this.opts=e,a(this,"protocol","wc"),a(this,"version",2)}}var h=Object.defineProperty;class l extends i.H{constructor(e,t){super(),this.core=e,this.logger=t,((e,t,s)=>{((e,t,s)=>{t in e?h(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s})(e,"symbol"!=typeof t?t+"":t,s)})(this,"records",new Map)}}class p{constructor(e,t){this.logger=e,this.core=t}}class d extends i.H{constructor(e,t){super(),this.relayer=e,this.logger=t}}class u extends i.H{constructor(e){super()}}class g{constructor(e,t,s,i){this.core=e,this.logger=t,this.name=s}}Object.defineProperty;class f extends i.H{constructor(e,t){super(),this.relayer=e,this.logger=t}}class m extends i.H{constructor(e,t){super(),this.core=e,this.logger=t}}class w{constructor(e,t,s){this.core=e,this.logger=t,this.store=s}}class y{constructor(e,t){this.projectId=e,this.logger=t}}class b{constructor(e,t,s){this.core=e,this.logger=t,this.telemetryEnabled=s}}var v=Object.defineProperty,E=(e,t,s)=>((e,t,s)=>t in e?v(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);n();class I{constructor(e){this.opts=e,E(this,"protocol","wc"),E(this,"version",2)}}r.EventEmitter;class _{constructor(e){this.client=e}}},5813:(e,t,s)=>{s.d(t,{w:()=>o});var i=s(95191),r=s(84253),n=s(11553);const o={isMobile(){return!!this.isClient()&&Boolean(window?.matchMedia("(pointer:coarse)")?.matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent))},checkCaipNetwork:(e,t="")=>e?.caipNetworkId.toLocaleLowerCase().includes(t.toLowerCase()),isAndroid(){if(!this.isMobile())return!1;const e=window?.navigator.userAgent.toLowerCase();return o.isMobile()&&e.includes("android")},isIos(){if(!this.isMobile())return!1;const e=window?.navigator.userAgent.toLowerCase();return e.includes("iphone")||e.includes("ipad")},isSafari(){if(!this.isClient())return!1;const e=window?.navigator.userAgent.toLowerCase();return e.includes("safari")},isClient:()=>"undefined"!=typeof window,isPairingExpired:e=>!e||e-Date.now()<=r.oU.TEN_SEC_MS,isAllowedRetry:(e,t=r.oU.ONE_SEC_MS)=>Date.now()-e>=t,copyToClopboard(e){navigator.clipboard.writeText(e)},isIframe(){try{return window?.self!==window?.top}catch(e){return!1}},getPairingExpiry:()=>Date.now()+r.oU.FOUR_MINUTES_MS,getNetworkId:e=>e?.split(":")[1],getPlainAddress:e=>e?.split(":")[2],wait:async e=>new Promise(t=>{setTimeout(t,e)}),debounce(e,t=500){let s;return(...i)=>{s&&clearTimeout(s),s=setTimeout(function(){e(...i)},t)}},isHttpUrl:e=>e.startsWith("http://")||e.startsWith("https://"),formatNativeUrl(e,t){if(o.isHttpUrl(e))return this.formatUniversalUrl(e,t);let s=e;return s.includes("://")||(s=e.replaceAll("/","").replaceAll(":",""),s=`${s}://`),s.endsWith("/")||(s=`${s}/`),this.isTelegram()&&this.isAndroid()&&(t=encodeURIComponent(t)),{redirect:`${s}wc?uri=${encodeURIComponent(t)}`,href:s}},formatUniversalUrl(e,t){if(!o.isHttpUrl(e))return this.formatNativeUrl(e,t);let s=e;return s.endsWith("/")||(s=`${s}/`),{redirect:`${s}wc?uri=${encodeURIComponent(t)}`,href:s}},getOpenTargetForPlatform(e){return"popupWindow"===e?e:this.isTelegram()?n.i.getTelegramSocialProvider()?"_top":"_blank":e},openHref(e,t,s){window?.open(e,this.getOpenTargetForPlatform(t),s||"noreferrer noopener")},returnOpenHref(e,t,s){return window?.open(e,this.getOpenTargetForPlatform(t),s||"noreferrer noopener")},isTelegram:()=>"undefined"!=typeof window&&(Boolean(window.TelegramWebviewProxy)||Boolean(window.Telegram)||Boolean(window.TelegramWebviewProxyProto)),async preloadImage(e){const t=new Promise((t,s)=>{const i=new Image;i.onload=t,i.onerror=s,i.crossOrigin="anonymous",i.src=e});return Promise.race([t,o.wait(2e3)])},formatBalance(e,t){let s="0.000";if("string"==typeof e){const t=Number(e);if(t){const e=Math.floor(1e3*t)/1e3;e&&(s=e.toString())}}return`${s}${t?` ${t}`:""}`},formatBalance2(e,t){let s;if("0"===e)s="0";else if("string"==typeof e){const t=Number(e);t&&(s=t.toString().match(/^-?\d+(?:\.\d{0,3})?/u)?.[0])}return{value:s??"0",rest:"0"===s?"000":"",symbol:t}},getApiUrl:()=>i.o.W3M_API_URL,getBlockchainApiUrl:()=>i.o.BLOCKCHAIN_API_RPC_URL,getAnalyticsUrl:()=>i.o.PULSE_API_URL,getUUID:()=>crypto?.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}),parseError:e=>"string"==typeof e?e:"string"==typeof e?.issues?.[0]?.message?e.issues[0].message:e instanceof Error?e.message:"Unknown error",sortRequestedNetworks(e,t=[]){const s={};return t&&e&&(e.forEach((e,t)=>{s[e]=t}),t.sort((e,t)=>{const i=s[e.id],r=s[t.id];return void 0!==i&&void 0!==r?i-r:void 0!==i?-1:void 0!==r?1:0})),t},calculateBalance(e){let t=0;for(const s of e)t+=s.value??0;return t},formatTokenBalance(e){const t=e.toFixed(2),[s,i]=t.split(".");return{dollars:s,pennies:i}},isAddress(e,t="eip155"){switch(t){case"eip155":return!(!/^(?:0x)?[0-9a-f]{40}$/iu.test(e)||!/^(?:0x)?[0-9a-f]{40}$/iu.test(e)&&!/^(?:0x)?[0-9A-F]{40}$/iu.test(e));case"solana":return/[1-9A-HJ-NP-Za-km-z]{32,44}$/iu.test(e);default:return!1}},uniqueBy(e,t){const s=new Set;return e.filter(e=>{const i=e[t];return!s.has(i)&&(s.add(i),!0)})},generateSdkVersion:(e,t,s)=>`${t}-${0===e.length?r.oU.ADAPTER_TYPES.UNIVERSAL:e.map(e=>e.adapterType).join(",")}-${s}`,createAccount:(e,t,s,i,r)=>({namespace:e,address:t,type:s,publicKey:i,path:r}),isCaipAddress(e){if("string"!=typeof e)return!1;const t=e.split(":"),s=t[0];return 3===t.filter(Boolean).length&&s in i.o.CHAIN_NAME_MAP},isMac(){const e=window?.navigator.userAgent.toLowerCase();return e.includes("macintosh")&&!e.includes("safari")},formatTelegramSocialLoginUrl(e){const t=`--${encodeURIComponent(window?.location.href)}`,s="state=";if("auth.magic.link"===new URL(e).host){const i="provider_authorization_url=",r=e.substring(e.indexOf(i)+i.length),n=this.injectIntoUrl(decodeURIComponent(r),s,t);return e.replace(r,encodeURIComponent(n))}return this.injectIntoUrl(e,s,t)},injectIntoUrl(e,t,s){const i=e.indexOf(t);if(-1===i)throw new Error(`${t} parameter not found in the URL: ${e}`);const r=e.indexOf("&",i),n=t.length,o=-1!==r?r:e.length;return e.substring(0,i+n)+(e.substring(i+n,o)+s)+e.substring(r)}}},8834:(e,t,s)=>{s.d(t,{v:()=>a});var i=s(10550),r=s(49009),n=s(55770),o=s(95191);const a={getERC20Abi:e=>o.o.USDT_CONTRACT_ADDRESSES.includes(e)?n.r:i.F,getSwapAbi:()=>r.Q}},9663:(e,t,s)=>{s.d(t,{Vl:()=>r});var i=s(39907);void 0!==i&&void 0!==i.env&&i.env.NEXT_PUBLIC_SECURE_SITE_SDK_URL,void 0!==i&&void 0!==i.env&&i.env.NEXT_PUBLIC_DEFAULT_LOG_LEVEL,void 0!==i&&void 0!==i.env&&i.env.NEXT_PUBLIC_SECURE_SITE_SDK_VERSION;const r={SAFE_RPC_METHODS:["eth_accounts","eth_blockNumber","eth_call","eth_chainId","eth_estimateGas","eth_feeHistory","eth_gasPrice","eth_getAccount","eth_getBalance","eth_getBlockByHash","eth_getBlockByNumber","eth_getBlockReceipts","eth_getBlockTransactionCountByHash","eth_getBlockTransactionCountByNumber","eth_getCode","eth_getFilterChanges","eth_getFilterLogs","eth_getLogs","eth_getProof","eth_getStorageAt","eth_getTransactionByBlockHashAndIndex","eth_getTransactionByBlockNumberAndIndex","eth_getTransactionByHash","eth_getTransactionCount","eth_getTransactionReceipt","eth_getUncleCountByBlockHash","eth_getUncleCountByBlockNumber","eth_maxPriorityFeePerGas","eth_newBlockFilter","eth_newFilter","eth_newPendingTransactionFilter","eth_sendRawTransaction","eth_syncing","eth_uninstallFilter","wallet_getCapabilities","wallet_getCallsStatus","eth_getUserOperationReceipt","eth_estimateUserOperationGas","eth_getUserOperationByHash","eth_supportedEntryPoints","wallet_getAssets"],NOT_SAFE_RPC_METHODS:["personal_sign","eth_signTypedData_v4","eth_sendTransaction","solana_signMessage","solana_signTransaction","solana_signAllTransactions","solana_signAndSendTransaction","wallet_sendCalls","wallet_grantPermissions","wallet_revokePermissions","eth_sendUserOperation"],GET_CHAIN_ID:"eth_chainId",RPC_METHOD_NOT_ALLOWED_MESSAGE:"Requested RPC call is not allowed",RPC_METHOD_NOT_ALLOWED_UI_MESSAGE:"Action not allowed",ACCOUNT_TYPES:{EOA:"eoa",SMART_ACCOUNT:"smartAccount"}}},10550:(e,t,s)=>{s.d(t,{F:()=>i});const i=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]}]},11553:(e,t,s)=>{s.d(t,{i:()=>r});var i=s(32681);const r={cacheExpiry:{portfolio:3e4,nativeBalance:3e4,ens:3e5,identity:3e5},isCacheExpired:(e,t)=>Date.now()-e>t,getActiveNetworkProps(){const e=r.getActiveNamespace(),t=r.getActiveCaipNetworkId(),s=t?t.split(":")[1]:void 0;return{namespace:e,caipNetworkId:t,chainId:s?isNaN(Number(s))?s:Number(s):void 0}},setWalletConnectDeepLink({name:e,href:t}){try{i.Ud.setItem(i.Ws.DEEPLINK_CHOICE,JSON.stringify({href:t,name:e}))}catch{console.info("Unable to set WalletConnect deep link")}},getWalletConnectDeepLink(){try{const e=i.Ud.getItem(i.Ws.DEEPLINK_CHOICE);if(e)return JSON.parse(e)}catch{console.info("Unable to get WalletConnect deep link")}},deleteWalletConnectDeepLink(){try{i.Ud.removeItem(i.Ws.DEEPLINK_CHOICE)}catch{console.info("Unable to delete WalletConnect deep link")}},setActiveNamespace(e){try{i.Ud.setItem(i.Ws.ACTIVE_NAMESPACE,e)}catch{console.info("Unable to set active namespace")}},setActiveCaipNetworkId(e){try{i.Ud.setItem(i.Ws.ACTIVE_CAIP_NETWORK_ID,e),r.setActiveNamespace(e.split(":")[0])}catch{console.info("Unable to set active caip network id")}},getActiveCaipNetworkId(){try{return i.Ud.getItem(i.Ws.ACTIVE_CAIP_NETWORK_ID)}catch{return void console.info("Unable to get active caip network id")}},deleteActiveCaipNetworkId(){try{i.Ud.removeItem(i.Ws.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to delete active caip network id")}},deleteConnectedConnectorId(e){try{const t=(0,i.T8)(e);i.Ud.removeItem(t)}catch{console.info("Unable to delete connected connector id")}},setAppKitRecent(e){try{const t=r.getRecentWallets();t.find(t=>t.id===e.id)||(t.unshift(e),t.length>2&&t.pop(),i.Ud.setItem(i.Ws.RECENT_WALLETS,JSON.stringify(t)))}catch{console.info("Unable to set AppKit recent")}},getRecentWallets(){try{const e=i.Ud.getItem(i.Ws.RECENT_WALLETS);return e?JSON.parse(e):[]}catch{console.info("Unable to get AppKit recent")}return[]},setConnectedConnectorId(e,t){try{const s=(0,i.T8)(e);i.Ud.setItem(s,t)}catch{console.info("Unable to set Connected Connector Id")}},getActiveNamespace(){try{return i.Ud.getItem(i.Ws.ACTIVE_NAMESPACE)}catch{console.info("Unable to get active namespace")}},getConnectedConnectorId(e){if(e)try{const t=(0,i.T8)(e);return i.Ud.getItem(t)}catch(t){console.info("Unable to get connected connector id in namespace ",e)}},setConnectedSocialProvider(e){try{i.Ud.setItem(i.Ws.CONNECTED_SOCIAL,e)}catch{console.info("Unable to set connected social provider")}},getConnectedSocialProvider(){try{return i.Ud.getItem(i.Ws.CONNECTED_SOCIAL)}catch{console.info("Unable to get connected social provider")}},deleteConnectedSocialProvider(){try{i.Ud.removeItem(i.Ws.CONNECTED_SOCIAL)}catch{console.info("Unable to delete connected social provider")}},getConnectedSocialUsername(){try{return i.Ud.getItem(i.Ws.CONNECTED_SOCIAL_USERNAME)}catch{console.info("Unable to get connected social username")}},getStoredActiveCaipNetworkId(){const e=i.Ud.getItem(i.Ws.ACTIVE_CAIP_NETWORK_ID),t=e?.split(":")?.[1];return t},setConnectionStatus(e){try{i.Ud.setItem(i.Ws.CONNECTION_STATUS,e)}catch{console.info("Unable to set connection status")}},getConnectionStatus(){try{return i.Ud.getItem(i.Ws.CONNECTION_STATUS)}catch{return}},getConnectedNamespaces(){try{const e=i.Ud.getItem(i.Ws.CONNECTED_NAMESPACES);return e?.length?e.split(","):[]}catch{return[]}},setConnectedNamespaces(e){try{const t=Array.from(new Set(e));i.Ud.setItem(i.Ws.CONNECTED_NAMESPACES,t.join(","))}catch{console.info("Unable to set namespaces in storage")}},addConnectedNamespace(e){try{const t=r.getConnectedNamespaces();t.includes(e)||(t.push(e),r.setConnectedNamespaces(t))}catch{console.info("Unable to add connected namespace")}},removeConnectedNamespace(e){try{const t=r.getConnectedNamespaces(),s=t.indexOf(e);s>-1&&(t.splice(s,1),r.setConnectedNamespaces(t))}catch{console.info("Unable to remove connected namespace")}},getTelegramSocialProvider(){try{return i.Ud.getItem(i.Ws.TELEGRAM_SOCIAL_PROVIDER)}catch{return console.info("Unable to get telegram social provider"),null}},setTelegramSocialProvider(e){try{i.Ud.setItem(i.Ws.TELEGRAM_SOCIAL_PROVIDER,e)}catch{console.info("Unable to set telegram social provider")}},removeTelegramSocialProvider(){try{i.Ud.removeItem(i.Ws.TELEGRAM_SOCIAL_PROVIDER)}catch{console.info("Unable to remove telegram social provider")}},getBalanceCache(){let e={};try{const t=i.Ud.getItem(i.Ws.PORTFOLIO_CACHE);e=t?JSON.parse(t):{}}catch{console.info("Unable to get balance cache")}return e},removeAddressFromBalanceCache(e){try{const t=r.getBalanceCache();i.Ud.setItem(i.Ws.PORTFOLIO_CACHE,JSON.stringify({...t,[e]:void 0}))}catch{console.info("Unable to remove address from balance cache",e)}},getBalanceCacheForCaipAddress(e){try{const t=r.getBalanceCache()[e];if(t&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.portfolio))return t.balance;r.removeAddressFromBalanceCache(e)}catch{console.info("Unable to get balance cache for address",e)}},updateBalanceCache(e){try{const t=r.getBalanceCache();t[e.caipAddress]=e,i.Ud.setItem(i.Ws.PORTFOLIO_CACHE,JSON.stringify(t))}catch{console.info("Unable to update balance cache",e)}},getNativeBalanceCache(){let e={};try{const t=i.Ud.getItem(i.Ws.NATIVE_BALANCE_CACHE);e=t?JSON.parse(t):{}}catch{console.info("Unable to get balance cache")}return e},removeAddressFromNativeBalanceCache(e){try{const t=r.getBalanceCache();i.Ud.setItem(i.Ws.NATIVE_BALANCE_CACHE,JSON.stringify({...t,[e]:void 0}))}catch{console.info("Unable to remove address from balance cache",e)}},getNativeBalanceCacheForCaipAddress(e){try{const t=r.getNativeBalanceCache()[e];if(t&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.nativeBalance))return t;console.info("Discarding cache for address",e),r.removeAddressFromBalanceCache(e)}catch{console.info("Unable to get balance cache for address",e)}},updateNativeBalanceCache(e){try{const t=r.getNativeBalanceCache();t[e.caipAddress]=e,i.Ud.setItem(i.Ws.NATIVE_BALANCE_CACHE,JSON.stringify(t))}catch{console.info("Unable to update balance cache",e)}},getEnsCache(){let e={};try{const t=i.Ud.getItem(i.Ws.ENS_CACHE);e=t?JSON.parse(t):{}}catch{console.info("Unable to get ens name cache")}return e},getEnsFromCacheForAddress(e){try{const t=r.getEnsCache()[e];if(t&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.ens))return t.ens;r.removeEnsFromCache(e)}catch{console.info("Unable to get ens name from cache",e)}},updateEnsCache(e){try{const t=r.getEnsCache();t[e.address]=e,i.Ud.setItem(i.Ws.ENS_CACHE,JSON.stringify(t))}catch{console.info("Unable to update ens name cache",e)}},removeEnsFromCache(e){try{const t=r.getEnsCache();i.Ud.setItem(i.Ws.ENS_CACHE,JSON.stringify({...t,[e]:void 0}))}catch{console.info("Unable to remove ens name from cache",e)}},getIdentityCache(){let e={};try{const t=i.Ud.getItem(i.Ws.IDENTITY_CACHE);e=t?JSON.parse(t):{}}catch{console.info("Unable to get identity cache")}return e},getIdentityFromCacheForAddress(e){try{const t=r.getIdentityCache()[e];if(t&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.identity))return t.identity;r.removeIdentityFromCache(e)}catch{console.info("Unable to get identity from cache",e)}},updateIdentityCache(e){try{const t=r.getIdentityCache();t[e.address]={identity:e.identity,timestamp:e.timestamp},i.Ud.setItem(i.Ws.IDENTITY_CACHE,JSON.stringify(t))}catch{console.info("Unable to update identity cache",e)}},removeIdentityFromCache(e){try{const t=r.getIdentityCache();i.Ud.setItem(i.Ws.IDENTITY_CACHE,JSON.stringify({...t,[e]:void 0}))}catch{console.info("Unable to remove identity from cache",e)}},clearAddressCache(){try{i.Ud.removeItem(i.Ws.PORTFOLIO_CACHE),i.Ud.removeItem(i.Ws.NATIVE_BALANCE_CACHE),i.Ud.removeItem(i.Ws.ENS_CACHE),i.Ud.removeItem(i.Ws.IDENTITY_CACHE)}catch{console.info("Unable to clear address cache")}}}},11629:(e,t,s)=>{s.d(t,{$I:()=>Q,$w:()=>J,Jf:()=>S,S$:()=>Y,Tn:()=>ee,U:()=>X,U$:()=>Z,WB:()=>F,cV:()=>U,iJ:()=>Ys,il:()=>ys,sD:()=>C,wn:()=>z,zN:()=>$});var i=s(50046),r=s.n(i),n=s(37147),o=s(81030),a=s(70255),c=s(3665),h=s(91315),l=s(25607),p=s(97353),d=s(76754),u=s(1030),g=s(93786),f=s(14350),m=s(63342),w=s(18677),y=s.n(w),b=s(20635);const v="core",E=`wc@2:${v}:`,I={database:":memory:"},_="client_ed25519_seed",N=h.ONE_DAY,A=h.SIX_HOURS,C="irn",P="wss://relay.walletconnect.org",S={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"},O="payload",T="connect",k="disconnect",x="error",R="2.19.0",U={link_mode:"link_mode",relay:"relay"},D="WALLETCONNECT_LINK_MODE_APPS",j="subscription_created",M="subscription_deleted",L=1e3*h.FIVE_SECONDS,q={wc_pairingDelete:{req:{ttl:h.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:h.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:h.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:h.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:h.ONE_DAY,prompt:!1,tag:0},res:{ttl:h.ONE_DAY,prompt:!1,tag:0}}},$={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},B="history_created",H="history_updated",W="history_deleted",z={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},V="https://verify.walletconnect.org",F=V,K=`${F}/v3`,G=["https://verify.walletconnect.com",V],J={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"},Y={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"},Q={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"},X={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"},Z={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"},ee={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"};const te=e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")};class se{constructor(e,t,s){this.name=e,this.prefix=t,this.baseEncode=s}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class ie{constructor(e,t,s){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=s}decode(e){if("string"==typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return ne(this,e)}}class re{constructor(e){this.decoders=e}or(e){return ne(this,e)}decode(e){const t=e[0],s=this.decoders[t];if(s)return s.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const ne=(e,t)=>new re({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class oe{constructor(e,t,s,i){this.name=e,this.prefix=t,this.baseEncode=s,this.baseDecode=i,this.encoder=new se(e,t,s),this.decoder=new ie(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const ae=({name:e,prefix:t,encode:s,decode:i})=>new oe(e,t,s,i),ce=({prefix:e,name:t,alphabet:s})=>{const{encode:i,decode:r}=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var s=new Uint8Array(256),i=0;i<s.length;i++)s[i]=255;for(var r=0;r<e.length;r++){var n=e.charAt(r),o=n.charCodeAt(0);if(255!==s[o])throw new TypeError(n+" is ambiguous");s[o]=r}var a=e.length,c=e.charAt(0),h=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function p(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var i=0,r=0;e[t]===c;)i++,t++;for(var n=(e.length-t)*h+1>>>0,o=new Uint8Array(n);e[t];){var l=s[e.charCodeAt(t)];if(255===l)return;for(var p=0,d=n-1;(0!==l||p<r)&&-1!==d;d--,p++)l+=a*o[d]>>>0,o[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");r=p,t++}if(" "!==e[t]){for(var u=n-r;u!==n&&0===o[u];)u++;for(var g=new Uint8Array(i+(n-u)),f=i;u!==n;)g[f++]=o[u++];return g}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var s=0,i=0,r=0,n=t.length;r!==n&&0===t[r];)r++,s++;for(var o=(n-r)*l+1>>>0,h=new Uint8Array(o);r!==n;){for(var p=t[r],d=0,u=o-1;(0!==p||d<i)&&-1!==u;u--,d++)p+=256*h[u]>>>0,h[u]=p%a>>>0,p=p/a>>>0;if(0!==p)throw new Error("Non-zero carry");i=d,r++}for(var g=o-i;g!==o&&0===h[g];)g++;for(var f=c.repeat(s);g<o;++g)f+=e.charAt(h[g]);return f},decodeUnsafe:p,decode:function(e){var s=p(e);if(s)return s;throw new Error(`Non-${t} character`)}}}(s,t);return ae({prefix:e,name:t,encode:i,decode:e=>te(r(e))})},he=({name:e,prefix:t,bitsPerChar:s,alphabet:i})=>ae({prefix:t,name:e,encode:e=>((e,t,s)=>{const i="="===t[t.length-1],r=(1<<s)-1;let n="",o=0,a=0;for(let i=0;i<e.length;++i)for(a=a<<8|e[i],o+=8;o>s;)o-=s,n+=t[r&a>>o];if(o&&(n+=t[r&a<<s-o]),i)for(;n.length*s&7;)n+="=";return n})(e,i,s),decode:t=>((e,t,s,i)=>{const r={};for(let e=0;e<t.length;++e)r[t[e]]=e;let n=e.length;for(;"="===e[n-1];)--n;const o=new Uint8Array(n*s/8|0);let a=0,c=0,h=0;for(let t=0;t<n;++t){const n=r[e[t]];if(void 0===n)throw new SyntaxError(`Non-${i} character`);c=c<<s|n,a+=s,a>=8&&(a-=8,o[h++]=255&c>>a)}if(a>=s||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o})(t,i,s,e)}),le=ae({prefix:"\0",name:"identity",encode:e=>(e=>(new TextDecoder).decode(e))(e),decode:e=>(e=>(new TextEncoder).encode(e))(e)});var pe=Object.freeze({__proto__:null,identity:le});const de=he({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ue=Object.freeze({__proto__:null,base2:de});const ge=he({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var fe=Object.freeze({__proto__:null,base8:ge});const me=ce({prefix:"9",name:"base10",alphabet:"0123456789"});var we=Object.freeze({__proto__:null,base10:me});const ye=he({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),be=he({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ve=Object.freeze({__proto__:null,base16:ye,base16upper:be});const Ee=he({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ie=he({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),_e=he({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ne=he({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ae=he({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ce=he({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Pe=he({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Se=he({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Oe=he({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Te=Object.freeze({__proto__:null,base32:Ee,base32upper:Ie,base32pad:_e,base32padupper:Ne,base32hex:Ae,base32hexupper:Ce,base32hexpad:Pe,base32hexpadupper:Se,base32z:Oe});const ke=ce({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),xe=ce({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Re=Object.freeze({__proto__:null,base36:ke,base36upper:xe});const Ue=ce({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),De=ce({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var je=Object.freeze({__proto__:null,base58btc:Ue,base58flickr:De});const Me=he({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Le=he({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),qe=he({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),$e=he({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Be=Object.freeze({__proto__:null,base64:Me,base64pad:Le,base64url:qe,base64urlpad:$e});const He=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),We=He.reduce((e,t,s)=>(e[s]=t,e),[]),ze=He.reduce((e,t,s)=>(e[t.codePointAt(0)]=s,e),[]),Ve=ae({prefix:"🚀",name:"base256emoji",encode:function(e){return e.reduce((e,t)=>e+We[t],"")},decode:function(e){const t=[];for(const s of e){const e=ze[s.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${s}`);t.push(e)}return new Uint8Array(t)}});var Fe=Object.freeze({__proto__:null,base256emoji:Ve}),Ke=128,Ge=-128,Je=Math.pow(2,31),Ye=Math.pow(2,7),Qe=Math.pow(2,14),Xe=Math.pow(2,21),Ze=Math.pow(2,28),et=Math.pow(2,35),tt=Math.pow(2,42),st=Math.pow(2,49),it=Math.pow(2,56),rt=Math.pow(2,63),nt=function e(t,s,i){s=s||[];for(var r=i=i||0;t>=Je;)s[i++]=255&t|Ke,t/=128;for(;t&Ge;)s[i++]=255&t|Ke,t>>>=7;return s[i]=0|t,e.bytes=i-r+1,s},ot=function(e){return e<Ye?1:e<Qe?2:e<Xe?3:e<Ze?4:e<et?5:e<tt?6:e<st?7:e<it?8:e<rt?9:10};const at=(e,t,s=0)=>(nt(e,t,s),t),ct=e=>ot(e),ht=(e,t)=>{const s=t.byteLength,i=ct(e),r=i+ct(s),n=new Uint8Array(r+s);return at(e,n,0),at(s,n,i),n.set(t,r),new lt(e,s,t,n)};class lt{constructor(e,t,s,i){this.code=e,this.size=t,this.digest=s,this.bytes=i}}const pt=({name:e,code:t,encode:s})=>new dt(e,t,s);class dt{constructor(e,t,s){this.name=e,this.code=t,this.encode=s}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?ht(this.code,t):t.then(e=>ht(this.code,e))}throw Error("Unknown type, must be binary type")}}const ut=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),gt=pt({name:"sha2-256",code:18,encode:ut("SHA-256")}),ft=pt({name:"sha2-512",code:19,encode:ut("SHA-512")});Object.freeze({__proto__:null,sha256:gt,sha512:ft});const mt=te,wt={code:0,name:"identity",encode:mt,digest:e=>ht(0,mt(e))};Object.freeze({__proto__:null,identity:wt}),new TextEncoder,new TextDecoder;const yt={...pe,...ue,...fe,...we,...ve,...Te,...Re,...je,...Be,...Fe};function bt(e,t,s,i){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:s},decoder:{decode:i}}}const vt=bt("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>(new TextEncoder).encode(e.substring(1))),Et=bt("ascii","a",e=>{let t="a";for(let s=0;s<e.length;s++)t+=String.fromCharCode(e[s]);return t},e=>{const t=function(e=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?globalThis.Buffer.allocUnsafe(e):new Uint8Array(e)}((e=e.substring(1)).length);for(let s=0;s<e.length;s++)t[s]=e.charCodeAt(s);return t}),It={utf8:vt,"utf-8":vt,hex:yt.base16,latin1:Et,ascii:Et,binary:Et,...yt};var _t=Object.defineProperty,Nt=(e,t,s)=>((e,t,s)=>t in e?_t(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class At{constructor(e,t){this.core=e,this.logger=t,Nt(this,"keychain",new Map),Nt(this,"name","keychain"),Nt(this,"version","0.3"),Nt(this,"initialized",!1),Nt(this,"storagePrefix",E),Nt(this,"init",async()=>{if(!this.initialized){const e=await this.getKeyChain();typeof e<"u"&&(this.keychain=e),this.initialized=!0}}),Nt(this,"has",e=>(this.isInitialized(),this.keychain.has(e))),Nt(this,"set",async(e,t)=>{this.isInitialized(),this.keychain.set(e,t),await this.persist()}),Nt(this,"get",e=>{this.isInitialized();const t=this.keychain.get(e);if(typeof t>"u"){const{message:t}=(0,d.GuA)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}),Nt(this,"del",async e=>{this.isInitialized(),this.keychain.delete(e),await this.persist()}),this.core=e,this.logger=(0,a.U5)(t,this.name)}get context(){return(0,a.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,(0,d.h0Y)(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?(0,d.PUk)(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Ct=Object.defineProperty,Pt=(e,t,s)=>((e,t,s)=>t in e?Ct(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class St{constructor(e,t,s){this.core=e,this.logger=t,Pt(this,"name","crypto"),Pt(this,"keychain"),Pt(this,"randomSessionIdentifier",(0,d.two)()),Pt(this,"initialized",!1),Pt(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)}),Pt(this,"hasKeys",e=>(this.isInitialized(),this.keychain.has(e))),Pt(this,"getClientId",async()=>{this.isInitialized();const e=await this.getClientSeed(),t=p.TZ(e);return p.UF(t.publicKey)}),Pt(this,"generateKeyPair",()=>{this.isInitialized();const e=(0,d.TZl)();return this.setPrivateKey(e.publicKey,e.privateKey)}),Pt(this,"signJWT",async e=>{this.isInitialized();const t=await this.getClientSeed(),s=p.TZ(t),i=this.randomSessionIdentifier,r=N;return await p.FA(i,e,r,s)}),Pt(this,"generateSharedKey",(e,t,s)=>{this.isInitialized();const i=this.getPrivateKey(e),r=(0,d.ovp)(i,t);return this.setSymKey(r,s)}),Pt(this,"setSymKey",async(e,t)=>{this.isInitialized();const s=t||(0,d.EN$)(e);return await this.keychain.set(s,e),s}),Pt(this,"deleteKeyPair",async e=>{this.isInitialized(),await this.keychain.del(e)}),Pt(this,"deleteSymKey",async e=>{this.isInitialized(),await this.keychain.del(e)}),Pt(this,"encode",async(e,t,s)=>{this.isInitialized();const i=(0,d.AwN)(s),r=(0,l.h)(t);if((0,d.ps1)(i))return(0,d.Tw2)(r,s?.encoding);if((0,d.V7m)(i)){const t=i.senderPublicKey,s=i.receiverPublicKey;e=await this.generateSharedKey(t,s)}const n=this.getSymKey(e),{type:o,senderPublicKey:a}=i;return(0,d.wa2)({type:o,symKey:n,message:r,senderPublicKey:a,encoding:s?.encoding})}),Pt(this,"decode",async(e,t,s)=>{this.isInitialized();const i=(0,d.C5G)(t,s);if((0,d.ps1)(i)){const e=(0,d.F$L)(t,s?.encoding);return(0,l.j)(e)}if((0,d.V7m)(i)){const t=i.receiverPublicKey,s=i.senderPublicKey;e=await this.generateSharedKey(t,s)}try{const i=this.getSymKey(e),r=(0,d.YcA)({symKey:i,encoded:t,encoding:s?.encoding});return(0,l.j)(r)}catch(t){this.logger.error(`Failed to decode message from topic: '${e}', clientId: '${await this.getClientId()}'`),this.logger.error(t)}}),Pt(this,"getPayloadType",(e,t=d.EWt)=>{const s=(0,d.iui)({encoded:e,encoding:t});return(0,d.x0t)(s.type)}),Pt(this,"getPayloadSenderPublicKey",(e,t=d.EWt)=>{const s=(0,d.iui)({encoded:e,encoding:t});return s.senderPublicKey?(0,u.dI)(s.senderPublicKey,d.bEt):void 0}),this.core=e,this.logger=(0,a.U5)(t,this.name),this.keychain=s||new At(this.core,this.logger)}get context(){return(0,a.oI)(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(_)}catch{e=(0,d.two)(),await this.keychain.set(_,e)}return function(e,t="utf8"){const s=It[t];if(!s)throw new Error(`Unsupported encoding "${t}"`);return"utf8"!==t&&"utf-8"!==t||null==globalThis.Buffer||null==globalThis.Buffer.from?s.decoder.decode(`${s.prefix}${e}`):globalThis.Buffer.from(e,"utf8")}(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Ot=Object.defineProperty,Tt=(e,t,s)=>((e,t,s)=>t in e?Ot(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class kt extends c.dQ{constructor(e,t){super(e,t),this.logger=e,this.core=t,Tt(this,"messages",new Map),Tt(this,"name","messages"),Tt(this,"version","0.3"),Tt(this,"initialized",!1),Tt(this,"storagePrefix",E),Tt(this,"init",async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const e=await this.getRelayerMessages();typeof e<"u"&&(this.messages=e),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}finally{this.initialized=!0}}}),Tt(this,"set",async(e,t)=>{this.isInitialized();const s=(0,d.ALl)(t);let i=this.messages.get(e);return typeof i>"u"&&(i={}),typeof i[s]<"u"||(i[s]=t,this.messages.set(e,i),await this.persist()),s}),Tt(this,"get",e=>{this.isInitialized();let t=this.messages.get(e);return typeof t>"u"&&(t={}),t}),Tt(this,"has",(e,t)=>(this.isInitialized(),typeof this.get(e)[(0,d.ALl)(t)]<"u")),Tt(this,"del",async e=>{this.isInitialized(),this.messages.delete(e),await this.persist()}),this.logger=(0,a.U5)(e,this.name),this.core=t}get context(){return(0,a.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,(0,d.h0Y)(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?(0,d.PUk)(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var xt=Object.defineProperty,Rt=Object.defineProperties,Ut=Object.getOwnPropertyDescriptors,Dt=Object.getOwnPropertySymbols,jt=Object.prototype.hasOwnProperty,Mt=Object.prototype.propertyIsEnumerable,Lt=(e,t,s)=>t in e?xt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,qt=(e,t)=>{for(var s in t||(t={}))jt.call(t,s)&&Lt(e,s,t[s]);if(Dt)for(var s of Dt(t))Mt.call(t,s)&&Lt(e,s,t[s]);return e},$t=(e,t)=>Rt(e,Ut(t)),Bt=(e,t,s)=>Lt(e,"symbol"!=typeof t?t+"":t,s);class Ht extends c.qE{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,Bt(this,"events",new i.EventEmitter),Bt(this,"name","publisher"),Bt(this,"queue",new Map),Bt(this,"publishTimeout",(0,h.toMiliseconds)(h.ONE_MINUTE)),Bt(this,"initialPublishTimeout",(0,h.toMiliseconds)(15*h.ONE_SECOND)),Bt(this,"needsTransportRestart",!1),Bt(this,"publish",async(e,t,s)=>{var i;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:e,message:t,opts:s}});const r=s?.ttl||A,n=(0,d.n6V)(s),o=s?.prompt||!1,a=s?.tag||0,c=s?.id||(0,f.getBigIntRpcId)().toString(),h={topic:e,message:t,opts:{ttl:r,relay:n,prompt:o,tag:a,id:c,attestation:s?.attestation,tvf:s?.tvf}},l=`Failed to publish payload, please try again. id:${c} tag:${a}`;try{const i=new Promise(async i=>{const n=({id:e})=>{h.opts.id===e&&(this.removeRequestFromQueue(e),this.relayer.events.removeListener(S.publish,n),i(h))};this.relayer.events.on(S.publish,n);const l=(0,d.K3g)(new Promise((i,n)=>{this.rpcPublish({topic:e,message:t,ttl:r,prompt:o,tag:a,id:c,attestation:s?.attestation,tvf:s?.tvf}).then(i).catch(e=>{this.logger.warn(e,e?.message),n(e)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${c} tag:${a}`);try{await l,this.events.removeListener(S.publish,n)}catch(e){this.queue.set(c,$t(qt({},h),{attempt:1})),this.logger.warn(e,e?.message)}});this.logger.trace({type:"method",method:"publish",params:{id:c,topic:e,message:t,opts:s}}),await(0,d.K3g)(i,this.publishTimeout,l)}catch(e){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(e),null!=(i=s?.internal)&&i.throwOnFailedPublish)throw e}finally{this.queue.delete(c)}}),Bt(this,"on",(e,t)=>{this.events.on(e,t)}),Bt(this,"once",(e,t)=>{this.events.once(e,t)}),Bt(this,"off",(e,t)=>{this.events.off(e,t)}),Bt(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.relayer=e,this.logger=(0,a.U5)(t,this.name),this.registerEventListeners()}get context(){return(0,a.oI)(this.logger)}async rpcPublish(e){var t,s,i,r;const{topic:n,message:o,ttl:a=A,prompt:c,tag:h,id:l,attestation:p,tvf:u}=e,g={method:(0,d.aa1)((0,d.n6V)().protocol).publish,params:qt({topic:n,message:o,ttl:a,prompt:c,tag:h,attestation:p},u),id:l};(0,d.b07)(null==(t=g.params)?void 0:t.prompt)&&(null==(s=g.params)||delete s.prompt),(0,d.b07)(null==(i=g.params)?void 0:i.tag)&&(null==(r=g.params)||delete r.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:g});const f=await this.relayer.request(g);return this.relayer.events.emit(S.publish,e),this.logger.debug("Successfully Published Payload"),f}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,t)=>{const s=e.attempt+1;this.queue.set(t,$t(qt({},e),{attempt:s}));const{topic:i,message:r,opts:n,attestation:o}=e;this.logger.warn({},`Publisher: queue->publishing: ${e.opts.id}, tag: ${e.opts.tag}, attempt: ${s}`),await this.rpcPublish($t(qt({},e),{topic:i,message:r,ttl:n.ttl,prompt:n.prompt,tag:n.tag,id:n.id,attestation:o,tvf:n.tvf})),this.logger.warn({},`Publisher: queue->published: ${e.opts.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(n.li.pulse,()=>{if(this.needsTransportRestart)return this.needsTransportRestart=!1,void this.relayer.events.emit(S.connection_stalled);this.checkQueue()}),this.relayer.on(S.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}var Wt=Object.defineProperty,zt=(e,t,s)=>((e,t,s)=>t in e?Wt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Vt{constructor(){zt(this,"map",new Map),zt(this,"set",(e,t)=>{const s=this.get(e);this.exists(e,t)||this.map.set(e,[...s,t])}),zt(this,"get",e=>this.map.get(e)||[]),zt(this,"exists",(e,t)=>this.get(e).includes(t)),zt(this,"delete",(e,t)=>{if(typeof t>"u")return void this.map.delete(e);if(!this.map.has(e))return;const s=this.get(e);if(!this.exists(e,t))return;const i=s.filter(e=>e!==t);i.length?this.map.set(e,i):this.map.delete(e)}),zt(this,"clear",()=>{this.map.clear()})}get topics(){return Array.from(this.map.keys())}}var Ft=Object.defineProperty,Kt=Object.defineProperties,Gt=Object.getOwnPropertyDescriptors,Jt=Object.getOwnPropertySymbols,Yt=Object.prototype.hasOwnProperty,Qt=Object.prototype.propertyIsEnumerable,Xt=(e,t,s)=>t in e?Ft(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Zt=(e,t)=>{for(var s in t||(t={}))Yt.call(t,s)&&Xt(e,s,t[s]);if(Jt)for(var s of Jt(t))Qt.call(t,s)&&Xt(e,s,t[s]);return e},es=(e,t)=>Kt(e,Gt(t)),ts=(e,t,s)=>Xt(e,"symbol"!=typeof t?t+"":t,s);class ss extends c.mF{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,ts(this,"subscriptions",new Map),ts(this,"topicMap",new Vt),ts(this,"events",new i.EventEmitter),ts(this,"name","subscription"),ts(this,"version","0.3"),ts(this,"pending",new Map),ts(this,"cached",[]),ts(this,"initialized",!1),ts(this,"pendingSubscriptionWatchLabel","pending_sub_watch_label"),ts(this,"pollingInterval",20),ts(this,"storagePrefix",E),ts(this,"subscribeTimeout",(0,h.toMiliseconds)(h.ONE_MINUTE)),ts(this,"initialSubscribeTimeout",(0,h.toMiliseconds)(15*h.ONE_SECOND)),ts(this,"clientId"),ts(this,"batchSubscribeTopicsLimit",500),ts(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0}),ts(this,"subscribe",async(e,t)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}});try{const s=(0,d.n6V)(t),i={topic:e,relay:s,transportType:t?.transportType};this.pending.set(e,i);const r=await this.rpcSubscribe(e,s,t);return"string"==typeof r&&(this.onSubscribe(r,i),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}})),r}catch(e){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(e),e}}),ts(this,"unsubscribe",async(e,t)=>{this.isInitialized(),typeof t?.id<"u"?await this.unsubscribeById(e,t.id,t):await this.unsubscribeByTopic(e,t)}),ts(this,"isSubscribed",async e=>{if(this.topics.includes(e))return!0;const t=`${this.pendingSubscriptionWatchLabel}_${e}`;return await new Promise((s,i)=>{const r=new h.Watch;r.start(t);const n=setInterval(()=>{(!this.pending.has(e)&&this.topics.includes(e)||this.cached.some(t=>t.topic===e))&&(clearInterval(n),r.stop(t),s(!0)),r.elapsed(t)>=L&&(clearInterval(n),r.stop(t),i(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)}),ts(this,"on",(e,t)=>{this.events.on(e,t)}),ts(this,"once",(e,t)=>{this.events.once(e,t)}),ts(this,"off",(e,t)=>{this.events.off(e,t)}),ts(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),ts(this,"start",async()=>{await this.onConnect()}),ts(this,"stop",async()=>{await this.onDisconnect()}),ts(this,"restart",async()=>{await this.restore(),await this.onRestart()}),ts(this,"checkPending",async()=>{if(!(0!==this.pending.size||this.initialized&&this.relayer.connected))return;const e=[];this.pending.forEach(t=>{e.push(t)}),await this.batchSubscribe(e)}),ts(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(n.li.pulse,async()=>{await this.checkPending()}),this.events.on(j,async e=>{const t=j;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}),this.events.on(M,async e=>{const t=M;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})}),this.relayer=e,this.logger=(0,a.U5)(t,this.name),this.clientId=""}get context(){return(0,a.oI)(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,t){let s=!1;try{s=this.getSubscription(e).topic===t}catch{}return s}reset(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){const s=this.topicMap.get(e);await Promise.all(s.map(async s=>await this.unsubscribeById(e,s,t)))}async unsubscribeById(e,t,s){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:s}});try{const i=(0,d.n6V)(s);await this.restartToComplete({topic:e,id:t,relay:i}),await this.rpcUnsubscribe(e,t,i);const r=(0,d.Hjj)("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,r),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:s}})}catch(e){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(e),e}}async rpcSubscribe(e,t,s){var i;(!s||s?.transportType===U.relay)&&await this.restartToComplete({topic:e,id:e,relay:t});const r={method:(0,d.aa1)(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r});const n=null==(i=s?.internal)?void 0:i.throwOnFailedPublish;try{const t=await this.getSubscriptionId(e);if(s?.transportType===U.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(r).catch(e=>this.logger.warn(e))},(0,h.toMiliseconds)(h.ONE_SECOND)),t;const i=new Promise(async t=>{const s=i=>{i.topic===e&&(this.events.removeListener(j,s),t(i.id))};this.events.on(j,s);try{const i=await(0,d.K3g)(new Promise((e,t)=>{this.relayer.request(r).catch(e=>{this.logger.warn(e,e?.message),t(e)}).then(e)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(j,s),t(i)}catch{}}),o=await(0,d.K3g)(i,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!o&&n)throw new Error(`Subscribing to ${e} failed, please try again`);return o?t:null}catch(e){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(S.connection_stalled),n)throw e}return null}async rpcBatchSubscribe(e){if(!e.length)return;const t=e[0].relay,s={method:(0,d.aa1)(t.protocol).batchSubscribe,params:{topics:e.map(e=>e.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});try{await await(0,d.K3g)(new Promise(e=>{this.relayer.request(s).catch(e=>this.logger.warn(e)).then(e)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(S.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const t=e[0].relay,s={method:(0,d.aa1)(t.protocol).batchFetchMessages,params:{topics:e.map(e=>e.topic)}};let i;this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});try{i=await await(0,d.K3g)(new Promise((e,t)=>{this.relayer.request(s).catch(e=>{this.logger.warn(e),t(e)}).then(e)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(S.connection_stalled)}return i}rpcUnsubscribe(e,t,s){const i={method:(0,d.aa1)(s.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i}),this.relayer.request(i)}onSubscribe(e,t){this.setSubscription(e,es(Zt({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(e=>{this.setSubscription(e.id,Zt({},e)),this.pending.delete(e.topic)})}async onUnsubscribe(e,t,s){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,s),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t)}addSubscription(e,t){this.subscriptions.set(e,Zt({},t)),this.topicMap.set(t.topic,e),this.events.emit(j,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const{message:t}=(0,d.GuA)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const s=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(s.topic,e),this.events.emit(M,es(Zt({},s),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit("subscription_sync")}async onRestart(){if(this.cached.length){const e=[...this.cached],t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let s=0;s<t;s++){const t=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(t)}}this.events.emit("subscription_resubscribed")}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:e}=(0,d.GuA)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(e)}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 e=>es(Zt({},e),{id:await this.getSubscriptionId(e.topic)})))))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(await(0,d.yy4)((0,h.toMiliseconds)(h.ONE_SECOND)),await this.relayer.handleBatchMessageEvents(t.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("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(0,d.ALl)(e+await this.getClientId())}}var is=Object.defineProperty,rs=Object.getOwnPropertySymbols,ns=Object.prototype.hasOwnProperty,os=Object.prototype.propertyIsEnumerable,as=(e,t,s)=>t in e?is(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,cs=(e,t)=>{for(var s in t||(t={}))ns.call(t,s)&&as(e,s,t[s]);if(rs)for(var s of rs(t))os.call(t,s)&&as(e,s,t[s]);return e},hs=(e,t,s)=>as(e,"symbol"!=typeof t?t+"":t,s);class ls extends c.m5{constructor(e){super(e),hs(this,"protocol","wc"),hs(this,"version",2),hs(this,"core"),hs(this,"logger"),hs(this,"events",new i.EventEmitter),hs(this,"provider"),hs(this,"messages"),hs(this,"subscriber"),hs(this,"publisher"),hs(this,"name","relayer"),hs(this,"transportExplicitlyClosed",!1),hs(this,"initialized",!1),hs(this,"connectionAttemptInProgress",!1),hs(this,"relayUrl"),hs(this,"projectId"),hs(this,"packageName"),hs(this,"bundleId"),hs(this,"hasExperiencedNetworkDisruption",!1),hs(this,"pingTimeout"),hs(this,"heartBeatTimeout",(0,h.toMiliseconds)(h.THIRTY_SECONDS+h.FIVE_SECONDS)),hs(this,"reconnectTimeout"),hs(this,"connectPromise"),hs(this,"reconnectInProgress",!1),hs(this,"requestsInFlight",[]),hs(this,"connectTimeout",(0,h.toMiliseconds)(15*h.ONE_SECOND)),hs(this,"request",async e=>{var t,s;this.logger.debug("Publishing Request Payload");const i=e.id||(0,f.getBigIntRpcId)().toString();await this.toEstablishConnection();try{this.logger.trace({id:i,method:e.method,topic:null==(t=e.params)?void 0:t.topic},"relayer.request - publishing...");const r=`${i}:${(null==(s=e.params)?void 0:s.tag)||""}`;this.requestsInFlight.push(r);const n=await this.provider.request(e);return this.requestsInFlight=this.requestsInFlight.filter(e=>e!==r),n}catch(e){throw this.logger.debug(`Failed to Publish Request: ${i}`),e}}),hs(this,"resetPingTimeout",()=>{if((0,d.Lln)())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var e,t,s;this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),null==(s=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)||s.terminate()},this.heartBeatTimeout)}catch(e){this.logger.warn(e,e?.message)}}),hs(this,"onPayloadHandler",e=>{this.onProviderPayload(e),this.resetPingTimeout()}),hs(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected 🛜"),this.startPingTimeout(),this.events.emit(S.connect)}),hs(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected 🛑"),this.requestsInFlight=[],this.onProviderDisconnect()}),hs(this,"onProviderErrorHandler",e=>{this.logger.fatal(`Fatal socket error: ${e.message}`),this.events.emit(S.error,e),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()}),hs(this,"registerProviderListeners",()=>{this.provider.on(O,this.onPayloadHandler),this.provider.on(T,this.onConnectHandler),this.provider.on(k,this.onDisconnectHandler),this.provider.on(x,this.onProviderErrorHandler)}),this.core=e.core,this.logger=typeof e.logger<"u"&&"string"!=typeof e.logger?(0,a.U5)(e.logger,this.name):(0,a.h6)((0,a.iP)({level:e.logger||"error"})),this.messages=new kt(this.logger,e.core),this.subscriber=new ss(this,this.logger),this.publisher=new Ht(this,this.logger),this.relayUrl=e?.relayUrl||P,this.projectId=e.projectId,(0,d.m01)()?this.packageName=(0,d.R7U)():(0,d.aRZ)()&&(this.bundleId=(0,d.R7U)()),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.hasAnyTopics)try{await this.transportOpen()}catch(e){this.logger.warn(e,e?.message)}}get context(){return(0,a.oI)(this.logger)}get connected(){var e,t,s;return 1===(null==(s=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:s.readyState)||!1}get connecting(){var e,t,s;return 0===(null==(s=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:s.readyState)||void 0!==this.connectPromise||!1}async publish(e,t,s){this.isInitialized(),await this.publisher.publish(e,t,s),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:U.relay})}async subscribe(e,t){var s,i,r;this.isInitialized(),(null==t||!t.transportType||"relay"===t?.transportType)&&await this.toEstablishConnection();const n=typeof(null==(s=t?.internal)?void 0:s.throwOnFailedPublish)>"u"||(null==(i=t?.internal)?void 0:i.throwOnFailedPublish);let o,a=(null==(r=this.subscriber.topicMap.get(e))?void 0:r[0])||"";const c=t=>{t.topic===e&&(this.subscriber.off(j,c),o())};return await Promise.all([new Promise(e=>{o=e,this.subscriber.on(j,c)}),new Promise(async(s,i)=>{a=await this.subscriber.subscribe(e,cs({internal:{throwOnFailedPublish:n}},t)).catch(e=>{n&&i(e)})||a,s()})]),a}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await(0,d.K3g)(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){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(t,s)=>{await this.connect(e).then(t).catch(s).finally(()=>{this.connectPromise=void 0})}),await this.connectPromise),!this.connected)throw new Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}else this.logger.warn("Starting WS connection skipped because the client has no topics to work with.")}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(0,d.sc7)())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(0===e?.length)return void this.logger.trace("Batch message events is empty. Ignoring...");const t=e.sort((e,t)=>e.publishedAt-t.publishedAt);this.logger.debug(`Batch of ${t.length} message events sorted`);for(const e of t)try{await this.onMessageEvent(e)}catch(e){this.logger.warn(e,"Error while processing batch message event: "+e?.message)}this.logger.trace(`Batch of ${t.length} message events processed`)}async onLinkMessageEvent(e,t){const{topic:s}=e;if(!t.sessionExists){const e={topic:s,expiry:(0,d.Xw0)(h.FIVE_MINUTES),relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(s,e)}this.events.emit(S.message,e),await this.recordMessageEvent(e)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let t=1;for(;t<6;){try{if(this.transportExplicitlyClosed)break;this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${t}...`),await this.createProvider(),await new Promise(async(e,t)=>{const s=()=>{t(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(k,s),await(0,d.K3g)(new Promise((e,t)=>{this.provider.connect().then(e).catch(t)}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(e=>{t(e)}).finally(()=>{this.provider.off(k,s),clearTimeout(this.reconnectTimeout)}),await new Promise(async(e,t)=>{const s=()=>{t(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(k,s),await this.subscriber.start().then(e).catch(t).finally(()=>{this.provider.off(k,s)})}),this.hasExperiencedNetworkDisruption=!1,e()})}catch(e){await this.subscriber.stop();const t=e;this.logger.warn({},t.message),this.hasExperiencedNetworkDisruption=!0}finally{this.connectionAttemptInProgress=!1}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${t}`);break}await new Promise(e=>setTimeout(e,(0,h.toMiliseconds)(1*t))),t++}}startPingTimeout(){var e,t,s,i,r;if((0,d.Lln)())try{null!=(t=null==(e=this.provider)?void 0:e.connection)&&t.socket&&(null==(r=null==(i=null==(s=this.provider)?void 0:s.connection)?void 0:i.socket)||r.on("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(e){this.logger.warn(e,e?.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new g.F(new m.A((0,d.jUZ)({sdkVersion:R,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){const{topic:t,message:s}=e;await this.messages.set(t,s)}async shouldIgnoreMessageEvent(e){const{topic:t,message:s}=e;if(!s||0===s.length)return this.logger.warn(`Ignoring invalid/empty message: ${s}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.warn(`Ignoring message for non-subscribed topic ${t}`),!0;const i=this.messages.has(t,s);return i&&this.logger.warn(`Ignoring duplicate message: ${s}`),i}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),(0,f.isJsonRpcRequest)(e)){if(!e.method.endsWith("_subscription"))return;const t=e.params,{topic:s,message:i,publishedAt:r,attestation:n}=t.data,o={topic:s,message:i,publishedAt:r,transportType:U.relay,attestation:n};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(cs({type:"event",event:t.id},o)),this.events.emit(t.id,o),await this.acknowledgePayload(e),await this.onMessageEvent(o)}else(0,f.isJsonRpcResponse)(e)&&this.events.emit(S.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(S.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const t=(0,f.formatJsonRpcResult)(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(O,this.onPayloadHandler),this.provider.off(T,this.onConnectHandler),this.provider.off(k,this.onDisconnectHandler),this.provider.off(x,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await(0,d.sc7)();(0,d.uym)(async t=>{e!==t&&(e=t,t?await this.transportOpen().catch(e=>this.logger.error(e,e?.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){clearTimeout(this.pingTimeout),this.events.emit(S.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?.message)),this.reconnectTimeout=void 0,this.reconnectInProgress=!1},(0,h.toMiliseconds)(.1)))))}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&await this.connect()}}var ps=Object.defineProperty,ds=Object.getOwnPropertySymbols,us=Object.prototype.hasOwnProperty,gs=Object.prototype.propertyIsEnumerable,fs=(e,t,s)=>t in e?ps(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,ms=(e,t)=>{for(var s in t||(t={}))us.call(t,s)&&fs(e,s,t[s]);if(ds)for(var s of ds(t))gs.call(t,s)&&fs(e,s,t[s]);return e},ws=(e,t,s)=>fs(e,"symbol"!=typeof t?t+"":t,s);class ys extends c.pi{constructor(e,t,s,i=E,r=void 0){super(e,t,s,i),this.core=e,this.logger=t,this.name=s,ws(this,"map",new Map),ws(this,"version","0.3"),ws(this,"cached",[]),ws(this,"initialized",!1),ws(this,"getKey"),ws(this,"storagePrefix",E),ws(this,"recentlyDeleted",[]),ws(this,"recentlyDeletedLimit",200),ws(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(e=>{this.getKey&&null!==e&&!(0,d.b07)(e)?this.map.set(this.getKey(e),e):(0,d.CTo)(e)?this.map.set(e.id,e):(0,d.mr0)(e)&&this.map.set(e.topic,e)}),this.cached=[],this.initialized=!0)}),ws(this,"set",async(e,t)=>{this.isInitialized(),this.map.has(e)?await this.update(e,t):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:e,value:t}),this.map.set(e,t),await this.persist())}),ws(this,"get",e=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:e}),this.getData(e))),ws(this,"getAll",e=>(this.isInitialized(),e?this.values.filter(t=>Object.keys(e).every(s=>y()(t[s],e[s]))):this.values)),ws(this,"update",async(e,t)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:e,update:t});const s=ms(ms({},this.getData(e)),t);this.map.set(e,s),await this.persist()}),ws(this,"delete",async(e,t)=>{this.isInitialized(),this.map.has(e)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:e,reason:t}),this.map.delete(e),this.addToRecentlyDeleted(e),await this.persist())}),this.logger=(0,a.U5)(t,this.name),this.storagePrefix=i,this.getKey=r}get context(){return(0,a.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){const{message:t}=(0,d.GuA)("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(t),new Error(t)}const{message:t}=(0,d.GuA)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(t),new Error(t)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:e}=(0,d.GuA)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}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}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var bs=Object.defineProperty,vs=(e,t,s)=>((e,t,s)=>t in e?bs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Es{constructor(e,t){this.core=e,this.logger=t,vs(this,"name","pairing"),vs(this,"version","0.3"),vs(this,"events",new(r())),vs(this,"pairings"),vs(this,"initialized",!1),vs(this,"storagePrefix",E),vs(this,"ignoredPayloadTypes",[d.Lp_]),vs(this,"registeredMethods",[]),vs(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))}),vs(this,"register",({methods:e})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...e])]}),vs(this,"create",async e=>{this.isInitialized();const t=(0,d.two)(),s=await this.core.crypto.setSymKey(t),i=(0,d.Xw0)(h.FIVE_MINUTES),r={protocol:C},n={topic:s,expiry:i,relay:r,active:!1,methods:e?.methods},o=(0,d.QJh)({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:t,relay:r,expiryTimestamp:i,methods:e?.methods});return this.events.emit($.create,n),this.core.expirer.set(s,i),await this.pairings.set(s,n),await this.core.relayer.subscribe(s,{transportType:e?.transportType}),{topic:s,uri:o}}),vs(this,"pair",async e=>{this.isInitialized();const t=this.core.eventClient.createEvent({properties:{topic:e?.uri,trace:[J.pairing_started]}});this.isValidPair(e,t);const{topic:s,symKey:i,relay:r,expiryTimestamp:n,methods:o}=(0,d.wYp)(e.uri);let a;if(t.props.properties.topic=s,t.addTrace(J.pairing_uri_validation_success),t.addTrace(J.pairing_uri_not_expired),this.pairings.keys.includes(s)){if(a=this.pairings.get(s),t.addTrace(J.existing_pairing),a.active)throw t.setError(Y.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);t.addTrace(J.pairing_not_expired)}const c=n||(0,d.Xw0)(h.FIVE_MINUTES),l={topic:s,relay:r,expiry:c,active:!1,methods:o};this.core.expirer.set(s,c),await this.pairings.set(s,l),t.addTrace(J.store_new_pairing),e.activatePairing&&await this.activate({topic:s}),this.events.emit($.create,l),t.addTrace(J.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(i,s),t.addTrace(J.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{t.setError(Y.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:r})}catch(e){throw t.setError(Y.subscribe_pairing_topic_failure),e}return t.addTrace(J.subscribe_pairing_topic_success),l}),vs(this,"activate",async({topic:e})=>{this.isInitialized();const t=(0,d.Xw0)(h.FIVE_MINUTES);this.core.expirer.set(e,t),await this.pairings.update(e,{active:!0,expiry:t})}),vs(this,"ping",async e=>{this.isInitialized(),await this.isValidPing(e),this.logger.warn("ping() is deprecated and will be removed in the next major release.");const{topic:t}=e;if(this.pairings.keys.includes(t)){const e=await this.sendRequest(t,"wc_pairingPing",{}),{done:s,resolve:i,reject:r}=(0,d.Wx8)();this.events.once((0,d.hEn)("pairing_ping",e),({error:e})=>{e?r(e):i()}),await s()}}),vs(this,"updateExpiry",async({topic:e,expiry:t})=>{this.isInitialized(),await this.pairings.update(e,{expiry:t})}),vs(this,"updateMetadata",async({topic:e,metadata:t})=>{this.isInitialized(),await this.pairings.update(e,{peerMetadata:t})}),vs(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),vs(this,"disconnect",async e=>{this.isInitialized(),await this.isValidDisconnect(e);const{topic:t}=e;this.pairings.keys.includes(t)&&(await this.sendRequest(t,"wc_pairingDelete",(0,d.Hjj)("USER_DISCONNECTED")),await this.deletePairing(t))}),vs(this,"formatUriFromPairing",e=>{this.isInitialized();const{topic:t,relay:s,expiry:i,methods:r}=e,n=this.core.crypto.keychain.get(t);return(0,d.QJh)({protocol:this.core.protocol,version:this.core.version,topic:t,symKey:n,relay:s,expiryTimestamp:i,methods:r})}),vs(this,"sendRequest",async(e,t,s)=>{const i=(0,f.formatJsonRpcRequest)(t,s),r=await this.core.crypto.encode(e,i),n=q[t].req;return this.core.history.set(e,i),this.core.relayer.publish(e,r,n),i.id}),vs(this,"sendResult",async(e,t,s)=>{const i=(0,f.formatJsonRpcResult)(e,s),r=await this.core.crypto.encode(t,i),n=(await this.core.history.get(t,e)).request.method,o=q[n].res;await this.core.relayer.publish(t,r,o),await this.core.history.resolve(i)}),vs(this,"sendError",async(e,t,s)=>{const i=(0,f.formatJsonRpcError)(e,s),r=await this.core.crypto.encode(t,i),n=(await this.core.history.get(t,e)).request.method,o=q[n]?q[n].res:q.unregistered_method.res;await this.core.relayer.publish(t,r,o),await this.core.history.resolve(i)}),vs(this,"deletePairing",async(e,t)=>{await this.core.relayer.unsubscribe(e),await Promise.all([this.pairings.delete(e,(0,d.Hjj)("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(e),t?Promise.resolve():this.core.expirer.del(e)])}),vs(this,"cleanup",async()=>{const e=this.pairings.getAll().filter(e=>(0,d._dF)(e.expiry));await Promise.all(e.map(e=>this.deletePairing(e.topic)))}),vs(this,"onRelayEventRequest",e=>{const{topic:t,payload:s}=e;switch(s.method){case"wc_pairingPing":return this.onPairingPingRequest(t,s);case"wc_pairingDelete":return this.onPairingDeleteRequest(t,s);default:return this.onUnknownRpcMethodRequest(t,s)}}),vs(this,"onRelayEventResponse",async e=>{const{topic:t,payload:s}=e,i=(await this.core.history.get(t,s.id)).request.method;return"wc_pairingPing"===i?this.onPairingPingResponse(t,s):this.onUnknownRpcMethodResponse(i)}),vs(this,"onPairingPingRequest",async(e,t)=>{const{id:s}=t;try{this.isValidPing({topic:e}),await this.sendResult(s,e,!0),this.events.emit($.ping,{id:s,topic:e})}catch(t){await this.sendError(s,e,t),this.logger.error(t)}}),vs(this,"onPairingPingResponse",(e,t)=>{const{id:s}=t;setTimeout(()=>{(0,f.isJsonRpcResult)(t)?this.events.emit((0,d.hEn)("pairing_ping",s),{}):(0,f.isJsonRpcError)(t)&&this.events.emit((0,d.hEn)("pairing_ping",s),{error:t.error})},500)}),vs(this,"onPairingDeleteRequest",async(e,t)=>{const{id:s}=t;try{this.isValidDisconnect({topic:e}),await this.deletePairing(e),this.events.emit($.delete,{id:s,topic:e})}catch(t){await this.sendError(s,e,t),this.logger.error(t)}}),vs(this,"onUnknownRpcMethodRequest",async(e,t)=>{const{id:s,method:i}=t;try{if(this.registeredMethods.includes(i))return;const t=(0,d.Hjj)("WC_METHOD_UNSUPPORTED",i);await this.sendError(s,e,t),this.logger.error(t)}catch(t){await this.sendError(s,e,t),this.logger.error(t)}}),vs(this,"onUnknownRpcMethodResponse",e=>{this.registeredMethods.includes(e)||this.logger.error((0,d.Hjj)("WC_METHOD_UNSUPPORTED",e))}),vs(this,"isValidPair",(e,t)=>{var s;if(!(0,d.TeY)(e)){const{message:s}=(0,d.GuA)("MISSING_OR_INVALID",`pair() params: ${e}`);throw t.setError(Y.malformed_pairing_uri),new Error(s)}if(!(0,d.AYU)(e.uri)){const{message:s}=(0,d.GuA)("MISSING_OR_INVALID",`pair() uri: ${e.uri}`);throw t.setError(Y.malformed_pairing_uri),new Error(s)}const i=(0,d.wYp)(e?.uri);if(null==(s=i?.relay)||!s.protocol){const{message:e}=(0,d.GuA)("MISSING_OR_INVALID","pair() uri#relay-protocol");throw t.setError(Y.malformed_pairing_uri),new Error(e)}if(null==i||!i.symKey){const{message:e}=(0,d.GuA)("MISSING_OR_INVALID","pair() uri#symKey");throw t.setError(Y.malformed_pairing_uri),new Error(e)}if(null!=i&&i.expiryTimestamp&&(0,h.toMiliseconds)(i?.expiryTimestamp)<Date.now()){t.setError(Y.pairing_expired);const{message:e}=(0,d.GuA)("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(e)}}),vs(this,"isValidPing",async e=>{if(!(0,d.TeY)(e)){const{message:t}=(0,d.GuA)("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidPairingTopic(t)}),vs(this,"isValidDisconnect",async e=>{if(!(0,d.TeY)(e)){const{message:t}=(0,d.GuA)("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidPairingTopic(t)}),vs(this,"isValidPairingTopic",async e=>{if(!(0,d.Qhg)(e,!1)){const{message:t}=(0,d.GuA)("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.pairings.keys.includes(e)){const{message:t}=(0,d.GuA)("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if((0,d._dF)(this.pairings.get(e).expiry)){await this.deletePairing(e);const{message:t}=(0,d.GuA)("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}),this.core=e,this.logger=(0,a.U5)(t,this.name),this.pairings=new ys(this.core,this.logger,this.name,this.storagePrefix)}get context(){return(0,a.oI)(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(S.message,async e=>{const{topic:t,message:s,transportType:i}=e;if(!this.pairings.keys.includes(t)||i===U.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(s)))return;const r=await this.core.crypto.decode(t,s);try{(0,f.isJsonRpcRequest)(r)?(this.core.history.set(t,r),this.onRelayEventRequest({topic:t,payload:r})):(0,f.isJsonRpcResponse)(r)&&(await this.core.history.resolve(r),await this.onRelayEventResponse({topic:t,payload:r}),this.core.history.delete(t,r.id))}catch(e){this.logger.error(e)}})}registerExpirerEvents(){this.core.expirer.on(z.expired,async e=>{const{topic:t}=(0,d.c82)(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit($.expire,{topic:t}))})}}var Is=Object.defineProperty,_s=(e,t,s)=>((e,t,s)=>t in e?Is(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Ns extends c.lZ{constructor(e,t){super(e,t),this.core=e,this.logger=t,_s(this,"records",new Map),_s(this,"events",new i.EventEmitter),_s(this,"name","history"),_s(this,"version","0.3"),_s(this,"cached",[]),_s(this,"initialized",!1),_s(this,"storagePrefix",E),_s(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(e=>this.records.set(e.id,e)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),_s(this,"set",(e,t,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:e,request:t,chainId:s}),this.records.has(t.id))return;const i={id:t.id,topic:e,request:{method:t.method,params:t.params||null},chainId:s,expiry:(0,d.Xw0)(h.THIRTY_DAYS)};this.records.set(i.id,i),this.persist(),this.events.emit(B,i)}),_s(this,"resolve",async e=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:e}),!this.records.has(e.id))return;const t=await this.getRecord(e.id);typeof t.response>"u"&&(t.response=(0,f.isJsonRpcError)(e)?{error:e.error}:{result:e.result},this.records.set(t.id,t),this.persist(),this.events.emit(H,t))}),_s(this,"get",async(e,t)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:e,id:t}),await this.getRecord(t))),_s(this,"delete",(e,t)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:t}),this.values.forEach(s=>{if(s.topic===e){if(typeof t<"u"&&s.id!==t)return;this.records.delete(s.id),this.events.emit(W,s)}}),this.persist()}),_s(this,"exists",async(e,t)=>(this.isInitialized(),!!this.records.has(t)&&(await this.getRecord(t)).topic===e)),_s(this,"on",(e,t)=>{this.events.on(e,t)}),_s(this,"once",(e,t)=>{this.events.once(e,t)}),_s(this,"off",(e,t)=>{this.events.off(e,t)}),_s(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.logger=(0,a.U5)(t,this.name)}get context(){return(0,a.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(t=>{if(typeof t.response<"u")return;const s={topic:t.topic,request:(0,f.formatJsonRpcRequest)(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(s)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const t=this.records.get(e);if(!t){const{message:t}=(0,d.GuA)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit("history_sync")}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:e}=(0,d.GuA)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}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(B,e=>{const t=B;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(H,e=>{const t=H;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(W,e=>{const t=W;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.core.heartbeat.on(n.li.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{(0,h.toMiliseconds)(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(W,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var As=Object.defineProperty,Cs=(e,t,s)=>((e,t,s)=>t in e?As(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Ps extends c.Vx{constructor(e,t){super(e,t),this.core=e,this.logger=t,Cs(this,"expirations",new Map),Cs(this,"events",new i.EventEmitter),Cs(this,"name","expirer"),Cs(this,"version","0.3"),Cs(this,"cached",[]),Cs(this,"initialized",!1),Cs(this,"storagePrefix",E),Cs(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(e=>this.expirations.set(e.target,e)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),Cs(this,"has",e=>{try{const t=this.formatTarget(e);return typeof this.getExpiration(t)<"u"}catch{return!1}}),Cs(this,"set",(e,t)=>{this.isInitialized();const s=this.formatTarget(e),i={target:s,expiry:t};this.expirations.set(s,i),this.checkExpiry(s,i),this.events.emit(z.created,{target:s,expiration:i})}),Cs(this,"get",e=>{this.isInitialized();const t=this.formatTarget(e);return this.getExpiration(t)}),Cs(this,"del",e=>{if(this.isInitialized(),this.has(e)){const t=this.formatTarget(e),s=this.getExpiration(t);this.expirations.delete(t),this.events.emit(z.deleted,{target:t,expiration:s})}}),Cs(this,"on",(e,t)=>{this.events.on(e,t)}),Cs(this,"once",(e,t)=>{this.events.once(e,t)}),Cs(this,"off",(e,t)=>{this.events.off(e,t)}),Cs(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.logger=(0,a.U5)(t,this.name)}get context(){return(0,a.oI)(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("string"==typeof e)return(0,d.ADD)(e);if("number"==typeof e)return(0,d.gOF)(e);const{message:t}=(0,d.GuA)("UNKNOWN_TYPE","Target type: "+typeof e);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(z.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:e}=(0,d.GuA)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const t=this.expirations.get(e);if(!t){const{message:t}=(0,d.GuA)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(t),new Error(t)}return t}checkExpiry(e,t){const{expiry:s}=t;(0,h.toMiliseconds)(s)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(z.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(n.li.pulse,()=>this.checkExpirations()),this.events.on(z.created,e=>{const t=z.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(z.expired,e=>{const t=z.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(z.deleted,e=>{const t=z.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Ss=Object.defineProperty,Os=(e,t,s)=>((e,t,s)=>t in e?Ss(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Ts extends c.zl{constructor(e,t,s){super(e,t,s),this.core=e,this.logger=t,this.store=s,Os(this,"name","verify-api"),Os(this,"abortController"),Os(this,"isDevEnv"),Os(this,"verifyUrlV3",K),Os(this,"storagePrefix",E),Os(this,"version",2),Os(this,"publicKey"),Os(this,"fetchPromise"),Os(this,"init",async()=>{var e;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&(0,h.toMiliseconds)(null==(e=this.publicKey)?void 0:e.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))}),Os(this,"register",async e=>{if(!(0,d.BdH)()||this.isDevEnv)return;const t=window.location.origin,{id:s,decryptedId:i}=e,r=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${t}&id=${s}&decryptedId=${i}`;try{const e=(0,b.getDocument)(),t=this.startAbortTimer(5*h.ONE_SECOND),i=await new Promise((i,n)=>{const o=()=>{window.removeEventListener("message",c),e.body.removeChild(a),n("attestation aborted")};this.abortController.signal.addEventListener("abort",o);const a=e.createElement("iframe");a.src=r,a.style.display="none",a.addEventListener("error",o,{signal:this.abortController.signal});const c=r=>{if(r.data&&"string"==typeof r.data)try{const n=JSON.parse(r.data);if("verify_attestation"===n.type){if((0,p.Cq)(n.attestation).payload.id!==s)return;clearInterval(t),e.body.removeChild(a),this.abortController.signal.removeEventListener("abort",o),window.removeEventListener("message",c),i(null===n.attestation?"":n.attestation)}}catch(e){this.logger.warn(e)}};e.body.appendChild(a),window.addEventListener("message",c,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",i),i}catch(e){this.logger.warn(e)}return""}),Os(this,"resolve",async e=>{if(this.isDevEnv)return"";const{attestationId:t,hash:s,encryptedId:i}=e;if(""===t)return void this.logger.debug("resolve: attestationId is empty, skipping");if(t){if((0,p.Cq)(t).payload.id!==i)return;const e=await this.isValidJwtAttestation(t);if(e)return e.isVerified?e:void this.logger.warn("resolve: jwt attestation: origin url not verified")}if(!s)return;const r=this.getVerifyUrl(e?.verifyUrl);return this.fetchAttestation(s,r)}),Os(this,"fetchAttestation",async(e,t)=>{this.logger.debug(`resolving attestation: ${e} from url: ${t}`);const s=this.startAbortTimer(5*h.ONE_SECOND),i=await fetch(`${t}/attestation/${e}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(s),200===i.status?await i.json():void 0}),Os(this,"getVerifyUrl",e=>{let t=e||F;return G.includes(t)||(this.logger.info(`verify url: ${t}, not included in trusted list, assigning default: ${F}`),t=F),t}),Os(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const e=this.startAbortTimer(h.FIVE_SECONDS),t=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(e),await t.json()}catch(e){this.logger.warn(e)}}),Os(this,"persistPublicKey",async e=>{this.logger.debug("persisting public key to local storage",e),await this.store.setItem(this.storeKey,e),this.publicKey=e}),Os(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0}),Os(this,"isValidJwtAttestation",async e=>{const t=await this.getPublicKey();try{if(t)return this.validateAttestation(e,t)}catch(e){this.logger.error(e),this.logger.warn("error validating attestation")}const s=await this.fetchAndPersistPublicKey();try{if(s)return this.validateAttestation(e,s)}catch(e){this.logger.error(e),this.logger.warn("error validating attestation")}}),Os(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),Os(this,"fetchAndPersistPublicKey",async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async e=>{const t=await this.fetchPublicKey();t&&(await this.persistPublicKey(t),e(t))});const e=await this.fetchPromise;return this.fetchPromise=void 0,e}),Os(this,"validateAttestation",(e,t)=>{const s=(0,d.U0i)(e,t.publicKey),i={hasExpired:(0,h.toMiliseconds)(s.exp)<Date.now(),payload:s};if(i.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:i.payload.origin,isScam:i.payload.isScam,isVerified:i.payload.isVerified}}),this.logger=(0,a.U5)(t,this.name),this.abortController=new AbortController,this.isDevEnv=(0,d.w8K)(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return(0,a.oI)(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),(0,h.toMiliseconds)(e))}}var ks=Object.defineProperty,xs=(e,t,s)=>((e,t,s)=>t in e?ks(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Rs extends c.GF{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,xs(this,"context","echo"),xs(this,"registerDeviceToken",async e=>{const{clientId:t,token:s,notificationType:i,enableEncrypted:r=!1}=e,n=`https://echo.walletconnect.com/${this.projectId}/clients`;await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:t,type:i,token:s,always_raw:r})})}),this.logger=(0,a.U5)(t,this.context)}}var Us=Object.defineProperty,Ds=Object.getOwnPropertySymbols,js=Object.prototype.hasOwnProperty,Ms=Object.prototype.propertyIsEnumerable,Ls=(e,t,s)=>t in e?Us(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,qs=(e,t)=>{for(var s in t||(t={}))js.call(t,s)&&Ls(e,s,t[s]);if(Ds)for(var s of Ds(t))Ms.call(t,s)&&Ls(e,s,t[s]);return e},$s=(e,t,s)=>Ls(e,"symbol"!=typeof t?t+"":t,s);class Bs extends c.$Q{constructor(e,t,s=!0){super(e,t,s),this.core=e,this.logger=t,$s(this,"context","event-client"),$s(this,"storagePrefix",E),$s(this,"storageVersion",.1),$s(this,"events",new Map),$s(this,"shouldPersist",!1),$s(this,"init",async()=>{if(!(0,d.w8K)())try{const e={eventId:(0,d.gZm)(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:(0,d.ojD)(this.core.relayer.protocol,this.core.relayer.version,R)}}};await this.sendEvent([e])}catch(e){this.logger.warn(e)}}),$s(this,"createEvent",e=>{const{event:t="ERROR",type:s="",properties:{topic:i,trace:r}}=e,n=(0,d.gZm)(),o=this.core.projectId||"",a=Date.now(),c=qs({eventId:n,timestamp:a,props:{event:t,type:s,properties:{topic:i,trace:r}},bundleId:o,domain:this.getAppDomain()},this.setMethods(n));return this.telemetryEnabled&&(this.events.set(n,c),this.shouldPersist=!0),c}),$s(this,"getEvent",e=>{const{eventId:t,topic:s}=e;if(t)return this.events.get(t);const i=Array.from(this.events.values()).find(e=>e.props.properties.topic===s);return i?qs(qs({},i),this.setMethods(i.eventId)):void 0}),$s(this,"deleteEvent",e=>{const{eventId:t}=e;this.events.delete(t),this.shouldPersist=!0}),$s(this,"setEventListeners",()=>{this.core.heartbeat.on(n.li.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(e=>{(0,h.fromMiliseconds)(Date.now())-(0,h.fromMiliseconds)(e.timestamp)>86400&&(this.events.delete(e.eventId),this.shouldPersist=!0)})})}),$s(this,"setMethods",e=>({addTrace:t=>this.addTrace(e,t),setError:t=>this.setError(e,t)})),$s(this,"addTrace",(e,t)=>{const s=this.events.get(e);s&&(s.props.properties.trace.push(t),this.events.set(e,s),this.shouldPersist=!0)}),$s(this,"setError",(e,t)=>{const s=this.events.get(e);s&&(s.props.type=t,s.timestamp=Date.now(),this.events.set(e,s),this.shouldPersist=!0)}),$s(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1}),$s(this,"restore",async()=>{try{const e=await this.core.storage.getItem(this.storageKey)||[];if(!e.length)return;e.forEach(e=>{this.events.set(e.eventId,qs(qs({},e),this.setMethods(e.eventId)))})}catch(e){this.logger.warn(e)}}),$s(this,"submit",async()=>{if(!this.telemetryEnabled||0===this.events.size)return;const e=[];for(const[t,s]of this.events)s.props.type&&e.push(s);if(0!==e.length)try{if((await this.sendEvent(e)).ok)for(const t of e)this.events.delete(t.eventId),this.shouldPersist=!0}catch(e){this.logger.warn(e)}}),$s(this,"sendEvent",async e=>{const t=this.getAppDomain()?"":"&sp=desktop";return await fetch(`https://pulse.walletconnect.org/batch?projectId=${this.core.projectId}&st=events_sdk&sv=js-${R}${t}`,{method:"POST",body:JSON.stringify(e)})}),$s(this,"getAppDomain",()=>(0,d.lFF)().url),this.logger=(0,a.U5)(t,this.context),this.telemetryEnabled=s,s?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var Hs=Object.defineProperty,Ws=Object.getOwnPropertySymbols,zs=Object.prototype.hasOwnProperty,Vs=Object.prototype.propertyIsEnumerable,Fs=(e,t,s)=>t in e?Hs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Ks=(e,t)=>{for(var s in t||(t={}))zs.call(t,s)&&Fs(e,s,t[s]);if(Ws)for(var s of Ws(t))Vs.call(t,s)&&Fs(e,s,t[s]);return e},Gs=(e,t,s)=>Fs(e,"symbol"!=typeof t?t+"":t,s);class Js extends c.ZP{constructor(e){var t;super(e),Gs(this,"protocol","wc"),Gs(this,"version",2),Gs(this,"name",v),Gs(this,"relayUrl"),Gs(this,"projectId"),Gs(this,"customStoragePrefix"),Gs(this,"events",new i.EventEmitter),Gs(this,"logger"),Gs(this,"heartbeat"),Gs(this,"relayer"),Gs(this,"crypto"),Gs(this,"storage"),Gs(this,"history"),Gs(this,"expirer"),Gs(this,"pairing"),Gs(this,"verify"),Gs(this,"echoClient"),Gs(this,"linkModeSupportedApps"),Gs(this,"eventClient"),Gs(this,"initialized",!1),Gs(this,"logChunkController"),Gs(this,"on",(e,t)=>this.events.on(e,t)),Gs(this,"once",(e,t)=>this.events.once(e,t)),Gs(this,"off",(e,t)=>this.events.off(e,t)),Gs(this,"removeListener",(e,t)=>this.events.removeListener(e,t)),Gs(this,"dispatchEnvelope",({topic:e,message:t,sessionExists:s})=>{if(!e||!t)return;const i={topic:e,message:t,publishedAt:Date.now(),transportType:U.link_mode};this.relayer.onLinkMessageEvent(i,{sessionExists:s})}),this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||P,this.customStoragePrefix=null!=e&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const s=(0,a.iP)({level:"string"==typeof e?.logger&&e.logger?e.logger:"error",name:v}),{logger:r,chunkLoggerController:c}=(0,a.D5)({opts:s,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=c,null!=(t=this.logChunkController)&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var e,t;null!=(e=this.logChunkController)&&e.downloadLogsBlobInBrowser&&(null==(t=this.logChunkController)||t.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=(0,a.U5)(r,this.name),this.heartbeat=new n.VH,this.crypto=new St(this,this.logger,e?.keychain),this.history=new Ns(this,this.logger),this.expirer=new Ps(this,this.logger),this.storage=null!=e&&e.storage?e.storage:new o.A(Ks(Ks({},I),e?.storageOptions)),this.relayer=new ls({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new Es(this,this.logger),this.verify=new Ts(this,this.logger,this.storage),this.echoClient=new Rs(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new Bs(this,this.logger,e?.telemetryEnabled)}static async init(e){const t=new Js(e);await t.initialize();const s=await t.crypto.getClientId();return await t.storage.setItem("WALLETCONNECT_CLIENT_ID",s),t}get context(){return(0,a.oI)(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return null==(e=this.logChunkController)?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(D,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.linkModeSupportedApps=await this.storage.getItem(D)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}}const Ys=Js},11807:(e,t,s)=>{function i(e,t){return"light"===t?{"--w3m-accent":e?.["--w3m-accent"]||"hsla(231, 100%, 70%, 1)","--w3m-background":"#fff"}:{"--w3m-accent":e?.["--w3m-accent"]||"hsla(230, 100%, 67%, 1)","--w3m-background":"#121313"}}s.d(t,{o:()=>i})},12472:(e,t,s)=>{s.d(t,{j:()=>o});var i=s(89168),r=s(39150);const n=(0,i.BX)({walletImages:{},networkImages:{},chainImages:{},connectorImages:{},tokenImages:{},currencyImages:{}}),o={state:n,subscribeNetworkImages:e=>(0,i.B1)(n.networkImages,()=>e(n.networkImages)),subscribeKey:(e,t)=>(0,r.u$)(n,e,t),subscribe:e=>(0,i.B1)(n,()=>e(n)),setWalletImage(e,t){n.walletImages[e]=t},setNetworkImage(e,t){n.networkImages[e]=t},setChainImage(e,t){n.chainImages[e]=t},setConnectorImage(e,t){n.connectorImages={...n.connectorImages,[e]:t}},setTokenImage(e,t){n.tokenImages[e]=t},setCurrencyImage(e,t){n.currencyImages[e]=t}}},14133:(e,t,s)=>{s.d(t,{Rn:()=>r.R,gT:()=>n.g,tW:()=>i.t});var i=s(33937),r=s(50047),n=s(18354)},14479:(e,t,s)=>{s.d(t,{E:()=>f});var i=s(89168),r=s(95191),n=s(32681),o=s(5813),a=s(19760),c=s(16279),h=s(27938),l=s(16158);const p=o.w.getAnalyticsUrl(),d=new a.Z({baseUrl:p,clientId:null}),u=["MODAL_CREATED"],g=(0,i.BX)({timestamp:Date.now(),reportedErrors:{},data:{type:"track",event:"MODAL_CREATED"}}),f={state:g,subscribe:e=>(0,i.B1)(g,()=>e(g)),getSdkProperties(){const{projectId:e,sdkType:t,sdkVersion:s}=l.H.state;return{projectId:e,st:t,sv:s||"html-wagmi-4.2.2"}},async _sendAnalyticsEvent(e){try{const t=c.U.state.address;if(u.includes(e.data.event)||"undefined"==typeof window)return;await d.post({path:"/e",params:f.getSdkProperties(),body:{eventId:o.w.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:e.timestamp,props:{...e.data,address:t}}}),g.reportedErrors.FORBIDDEN=!1}catch(e){e instanceof Error&&e.cause instanceof Response&&e.cause.status===r.o.HTTP_STATUS_CODES.FORBIDDEN&&!g.reportedErrors.FORBIDDEN&&(h.h.open({shortMessage:"Invalid App Configuration",longMessage:`Origin ${(0,n.IP)()?window.origin:"uknown"} not found on Allowlist - update configuration on cloud.reown.com`},"error"),g.reportedErrors.FORBIDDEN=!0)}},sendEvent(e){g.timestamp=Date.now(),g.data=e,l.H.state.features?.analytics&&f._sendAnalyticsEvent(g)}}},15406:(e,t,s)=>{s.d(t,{t:()=>c});var i=s(16279),r=s(27006),n=s(99013),o=s(89058),a=s(36641);const c={async getMyTokensWithBalance(e){const t=i.U.state.address,s=n.W.state.activeCaipNetwork;if(!t||!s)return[];if("eip155"===s.chainNamespace){const e=await this.getEIP155Balances(t,s);if(e)return this.filterLowQualityTokens(e)}const o=await r.T.getBalance(t,s.caipNetworkId,e);return this.filterLowQualityTokens(o.balances)},async getEIP155Balances(e,t){try{const s=a.T.getChainIdHexFromCAIP2ChainId(t.caipNetworkId),i=await o.x.getCapabilities(e);if(!i?.[s]?.assetDiscovery?.supported)return null;const r=await o.x.walletGetAssets({account:e,chainFilter:[s]});return a.T.isWalletGetAssetsResponse(r)?(r[s]||[]).map(e=>a.T.createBalance(e,t.caipNetworkId)):null}catch(e){return null}},filterLowQualityTokens:e=>e.filter(e=>"0"!==e.quantity.decimals),mapBalancesToSwapTokens:e=>e?.map(e=>({...e,address:e?.address?e.address:n.W.getActiveNetworkTokenAddress(),decimals:parseInt(e.quantity.decimals,10),logoUri:e.iconUrl,eip2612:!1}))||[]}},15579:(e,t,s)=>{s.d(t,{R:()=>l});var i=s(4443),r=s(30393),n=s(95191),o=s(99013),a=s(11553),c=s(40770);const h=["near:mainnet","solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp","eip155:1101","eip155:56","eip155:42161","eip155:7777777","eip155:59144","eip155:324","solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1","eip155:5000","solana:4sgjmw1sunhzsxgspuhpqldx6wiyjntz","eip155:80084","eip155:5003","eip155:100","eip155:8453","eip155:42220","eip155:1313161555","eip155:17000","eip155:1","eip155:300","eip155:1313161554","eip155:1329","eip155:84532","eip155:421614","eip155:11155111","eip155:8217","eip155:43114","solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z","eip155:999999999","eip155:11155420","eip155:80002","eip155:97","eip155:43113","eip155:137","eip155:10","eip155:1301","bip122:000000000019d6689c085ae165831e93","bip122:000000000933ea01ad0ee984209779ba"],l={extendRpcUrlWithProjectId(e,t){let s=!1;try{s="rpc.walletconnect.org"===new URL(e).host}catch(e){s=!1}if(s){const s=new URL(e);return s.searchParams.has("projectId")||s.searchParams.set("projectId",t),s.toString()}return e},isCaipNetwork:e=>"chainNamespace"in e&&"caipNetworkId"in e,getChainNamespace(e){return this.isCaipNetwork(e)?e.chainNamespace:n.o.CHAIN.EVM},getCaipNetworkId(e){return this.isCaipNetwork(e)?e.caipNetworkId:`${n.o.CHAIN.EVM}:${e.id}`},getDefaultRpcUrl(e,t,s){const i=e.rpcUrls?.default?.http?.[0];return h.includes(t)?function(e,t){const s=new URL("https://rpc.walletconnect.org/v1/");return s.searchParams.set("chainId",e),s.searchParams.set("projectId",t),s.toString()}(t,s):i||""},extendCaipNetwork(e,{customNetworkImageUrls:t,projectId:s,customRpcUrls:i}){const r=this.getChainNamespace(e),n=this.getCaipNetworkId(e),o=e.rpcUrls.default.http?.[0],a=this.getDefaultRpcUrl(e,n,s),h=e?.rpcUrls?.chainDefault?.http?.[0]||o,l=i?.[n]?.map(e=>e.url)||[],p=[...l,a],d=[...l];return h&&!d.includes(h)&&d.push(h),{...e,chainNamespace:r,caipNetworkId:n,assets:{imageId:c.L.NetworkImageIds[e.id],imageUrl:t?.[e.id]},rpcUrls:{...e.rpcUrls,default:{http:p},chainDefault:{http:d}}}},extendCaipNetworks:(e,{customNetworkImageUrls:t,projectId:s,customRpcUrls:i})=>e.map(e=>l.extendCaipNetwork(e,{customNetworkImageUrls:t,customRpcUrls:i,projectId:s})),getViemTransport(e,t,s){const n=[];if(s?.forEach(e=>{n.push((0,r.L)(e.url,e.config))}),h.includes(e.caipNetworkId)){const s=this.getDefaultRpcUrl(e,e.caipNetworkId,t);n.push((0,r.L)(s,{fetchOptions:{headers:{"Content-Type":"text/plain"}}}))}return(0,i.Np)(n)},extendWagmiTransports(e,t,s){if(h.includes(e.caipNetworkId)){const n=this.getDefaultRpcUrl(e,e.caipNetworkId,t);return(0,i.Np)([s,(0,r.L)(n)])}return s},getUnsupportedNetwork:e=>({id:e.split(":")[1],caipNetworkId:e,name:n.o.UNSUPPORTED_NETWORK_NAME,chainNamespace:e.split(":")[0],nativeCurrency:{name:"",decimals:0,symbol:""},rpcUrls:{default:{http:[]}}}),getCaipNetworkFromStorage(e){const t=a.i.getActiveCaipNetworkId(),s=o.W.getAllRequestedCaipNetworks(),i=Array.from(o.W.state.chains?.keys()||[]),r=t?.split(":")[0],n=!!r&&i.includes(r),c=s?.find(e=>e.caipNetworkId===t);return n&&!c&&t?this.getUnsupportedNetwork(t):c||e||s?.[0]}}},16158:(e,t,s)=>{s.d(t,{H:()=>c});var i=s(89168),r=s(39150),n=s(84253),o=s(91310);const a=(0,i.BX)({features:n.oU.DEFAULT_FEATURES,projectId:"",sdkType:"appkit",sdkVersion:"html-wagmi-undefined",defaultAccountTypes:n.oU.DEFAULT_ACCOUNT_TYPES,enableNetworkSwitch:!0}),c={state:a,subscribeKey:(e,t)=>(0,r.u$)(a,e,t),setOptions(e){Object.assign(a,e)},setFeatures(e){if(!e)return;a.features||(a.features=n.oU.DEFAULT_FEATURES);const t={...a.features,...e};a.features=t,a.features.socials&&(a.features.socials=o.D.filterSocialsByPlatform(a.features.socials))},setProjectId(e){a.projectId=e},setCustomRpcUrls(e){a.customRpcUrls=e},setAllWallets(e){a.allWallets=e},setIncludeWalletIds(e){a.includeWalletIds=e},setExcludeWalletIds(e){a.excludeWalletIds=e},setFeaturedWalletIds(e){a.featuredWalletIds=e},setTokens(e){a.tokens=e},setTermsConditionsUrl(e){a.termsConditionsUrl=e},setPrivacyPolicyUrl(e){a.privacyPolicyUrl=e},setCustomWallets(e){a.customWallets=e},setIsSiweEnabled(e){a.isSiweEnabled=e},setIsUniversalProvider(e){a.isUniversalProvider=e},setSdkVersion(e){a.sdkVersion=e},setMetadata(e){a.metadata=e},setDisableAppend(e){a.disableAppend=e},setEIP6963Enabled(e){a.enableEIP6963=e},setDebug(e){a.debug=e},setEnableWalletConnect(e){a.enableWalletConnect=e},setEnableWalletGuide(e){a.enableWalletGuide=e},setEnableAuthLogger(e){a.enableAuthLogger=e},setEnableWallets(e){a.enableWallets=e},setHasMultipleAddresses(e){a.hasMultipleAddresses=e},setSIWX(e){a.siwx=e},setConnectMethodsOrder(e){a.features={...a.features,connectMethodsOrder:e}},setWalletFeaturesOrder(e){a.features={...a.features,walletFeaturesOrder:e}},setSocialsOrder(e){a.features={...a.features,socials:e}},setCollapseWallets(e){a.features={...a.features,collapseWallets:e}},setEnableEmbedded(e){a.enableEmbedded=e},setAllowUnsupportedChain(e){a.allowUnsupportedChain=e},setManualWCControl(e){a.manualWCControl=e},setEnableNetworkSwitch(e){a.enableNetworkSwitch=e},setDefaultAccountTypes(e={}){Object.entries(e).forEach(([e,t])=>{t&&(a.defaultAccountTypes[e]=t)})},setUniversalProviderConfigOverride(e){a.universalProviderConfigOverride=e},getUniversalProviderConfigOverride:()=>a.universalProviderConfigOverride,getSnapshot:()=>(0,i.P9)(a)}},16279:(e,t,s)=>{s.d(t,{U:()=>l});var i=s(89168),r=s(84253),n=s(5813),o=s(27006),a=s(99013),c=s(41430);const h=(0,i.BX)({currentTab:0,tokenBalance:[],smartAccountDeployed:!1,addressLabels:new Map,allAccounts:[]}),l={state:h,replaceState(e){e&&Object.assign(h,(0,i.KR)(e))},subscribe:e=>a.W.subscribeChainProp("accountState",t=>{if(t)return e(t)}),subscribeKey(e,t,s){let i;return a.W.subscribeChainProp("accountState",s=>{if(s){const r=s[e];i!==r&&(i=r,t(r))}},s)},setStatus(e,t){a.W.setAccountProp("status",e,t)},getCaipAddress:e=>a.W.getAccountProp("caipAddress",e),setCaipAddress(e,t){const s=e?n.w.getPlainAddress(e):void 0;t===a.W.state.activeChain&&(a.W.state.activeCaipAddress=e),a.W.setAccountProp("caipAddress",e,t),a.W.setAccountProp("address",s,t)},setBalance(e,t,s){a.W.setAccountProp("balance",e,s),a.W.setAccountProp("balanceSymbol",t,s)},setProfileName(e,t){a.W.setAccountProp("profileName",e,t)},setProfileImage(e,t){a.W.setAccountProp("profileImage",e,t)},setUser(e,t){a.W.setAccountProp("user",e,t)},setAddressExplorerUrl(e,t){a.W.setAccountProp("addressExplorerUrl",e,t)},setSmartAccountDeployed(e,t){a.W.setAccountProp("smartAccountDeployed",e,t)},setCurrentTab(e){a.W.setAccountProp("currentTab",e,a.W.state.activeChain)},setTokenBalance(e,t){e&&a.W.setAccountProp("tokenBalance",e,t)},setShouldUpdateToAddress(e,t){a.W.setAccountProp("shouldUpdateToAddress",e,t)},setAllAccounts(e,t){a.W.setAccountProp("allAccounts",e,t)},addAddressLabel(e,t,s){const i=a.W.getAccountProp("addressLabels",s)||new Map;i.set(e,t),a.W.setAccountProp("addressLabels",i,s)},removeAddressLabel(e,t){const s=a.W.getAccountProp("addressLabels",t)||new Map;s.delete(e),a.W.setAccountProp("addressLabels",s,t)},setConnectedWalletInfo(e,t){a.W.setAccountProp("connectedWalletInfo",e,t,!1)},setPreferredAccountType(e,t){a.W.setAccountProp("preferredAccountType",e,t)},setSocialProvider(e,t){e&&a.W.setAccountProp("socialProvider",e,t)},setSocialWindow(e,t){a.W.setAccountProp("socialWindow",e?(0,i.KR)(e):void 0,t)},setFarcasterUrl(e,t){a.W.setAccountProp("farcasterUrl",e,t)},async fetchTokenBalance(e){h.balanceLoading=!0;const t=a.W.state.activeCaipNetwork?.caipNetworkId,s=a.W.state.activeCaipNetwork?.chainNamespace,i=a.W.state.activeCaipAddress,l=i?n.w.getPlainAddress(i):void 0;if(h.lastRetry&&!n.w.isAllowedRetry(h.lastRetry,30*r.oU.ONE_SEC_MS))return h.balanceLoading=!1,[];try{if(l&&t&&s){const e=(await o.T.getBalance(l,t)).balances.filter(e=>"0"!==e.quantity.decimals);return this.setTokenBalance(e,s),h.lastRetry=void 0,h.balanceLoading=!1,e}}catch(t){h.lastRetry=Date.now(),e?.(t),c.P.showError("Token Balance Unavailable")}finally{h.balanceLoading=!1}return[]},resetAccount(e){a.W.resetAccount(e)}}},16652:(e,t,s)=>{s.d(t,{R:()=>y});var i=s(89168),r=s(39150),n=s(22233),o=s(8834),a=s(9663),c=s(84253),h=s(5813),l=s(15406),p=s(16279),d=s(99013),u=s(89058),g=s(14479),f=s(42831),m=s(41430);const w=(0,i.BX)({tokenBalances:[],loading:!1}),y={state:w,subscribe:e=>(0,i.B1)(w,()=>e(w)),subscribeKey:(e,t)=>(0,r.u$)(w,e,t),setToken(e){e&&(w.token=(0,i.KR)(e))},setTokenAmount(e){w.sendTokenAmount=e},setReceiverAddress(e){w.receiverAddress=e},setReceiverProfileImageUrl(e){w.receiverProfileImageUrl=e},setReceiverProfileName(e){w.receiverProfileName=e},setGasPrice(e){w.gasPrice=e},setGasPriceInUsd(e){w.gasPriceInUSD=e},setNetworkBalanceInUsd(e){w.networkBalanceInUSD=e},setLoading(e){w.loading=e},sendToken(){switch(d.W.state.activeCaipNetwork?.chainNamespace){case"eip155":return void this.sendEvmToken();case"solana":return void this.sendSolanaToken();default:throw new Error("Unsupported chain")}},sendEvmToken(){this.state.token?.address&&this.state.sendTokenAmount&&this.state.receiverAddress?(g.E.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:p.U.state.preferredAccountType===a.Vl.ACCOUNT_TYPES.SMART_ACCOUNT,token:this.state.token.address,amount:this.state.sendTokenAmount,network:d.W.state.activeCaipNetwork?.caipNetworkId||""}}),this.sendERC20Token({receiverAddress:this.state.receiverAddress,tokenAddress:this.state.token.address,sendTokenAmount:this.state.sendTokenAmount,decimals:this.state.token.quantity.decimals})):this.state.receiverAddress&&this.state.sendTokenAmount&&this.state.gasPrice&&this.state.token?.quantity.decimals&&(g.E.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:p.U.state.preferredAccountType===a.Vl.ACCOUNT_TYPES.SMART_ACCOUNT,token:this.state.token?.symbol,amount:this.state.sendTokenAmount,network:d.W.state.activeCaipNetwork?.caipNetworkId||""}}),this.sendNativeToken({receiverAddress:this.state.receiverAddress,sendTokenAmount:this.state.sendTokenAmount,gasPrice:this.state.gasPrice,decimals:this.state.token.quantity.decimals}))},async fetchTokenBalance(e){w.loading=!0;const t=d.W.state.activeCaipNetwork?.caipNetworkId,s=d.W.state.activeCaipNetwork?.chainNamespace,i=d.W.state.activeCaipAddress,r=i?h.w.getPlainAddress(i):void 0;if(w.lastRetry&&!h.w.isAllowedRetry(w.lastRetry,30*c.oU.ONE_SEC_MS))return w.loading=!1,[];try{if(r&&t&&s){const e=await l.t.getMyTokensWithBalance();return w.tokenBalances=e,w.lastRetry=void 0,e}}catch(t){w.lastRetry=Date.now(),e?.(t),m.P.showError("Token Balance Unavailable")}finally{w.loading=!1}return[]},fetchNetworkBalance(){if(0===w.tokenBalances.length)return;const e=l.t.mapBalancesToSwapTokens(w.tokenBalances);if(!e)return;const t=e.find(e=>e.address===d.W.getActiveNetworkTokenAddress());t&&(w.networkBalanceInUSD=t?n.S.multiply(t.quantity.numeric,t.price).toString():"0")},isInsufficientNetworkTokenForGas(e,t){const s=t||"0";return!!n.S.bigNumber(e).eq(0)||n.S.bigNumber(n.S.bigNumber(s)).gt(e)},hasInsufficientGasFunds(){let e=!0;return p.U.state.preferredAccountType===a.Vl.ACCOUNT_TYPES.SMART_ACCOUNT?e=!1:w.networkBalanceInUSD&&(e=this.isInsufficientNetworkTokenForGas(w.networkBalanceInUSD,w.gasPriceInUSD)),e},async sendNativeToken(e){f.I.pushTransactionStack({view:"Account",goBack:!1});const t=e.receiverAddress,s=p.U.state.address,i=u.x.parseUnits(e.sendTokenAmount.toString(),Number(e.decimals));try{await u.x.sendTransaction({chainNamespace:"eip155",to:t,address:s,data:"0x",value:i??BigInt(0),gasPrice:e.gasPrice}),m.P.showSuccess("Transaction started"),g.E.sendEvent({type:"track",event:"SEND_SUCCESS",properties:{isSmartAccount:p.U.state.preferredAccountType===a.Vl.ACCOUNT_TYPES.SMART_ACCOUNT,token:this.state.token?.symbol||"",amount:e.sendTokenAmount,network:d.W.state.activeCaipNetwork?.caipNetworkId||""}}),this.resetSend()}catch(t){console.error("SendController:sendERC20Token - failed to send native token",t);const s=t instanceof Error?t.message:"Unknown error";g.E.sendEvent({type:"track",event:"SEND_ERROR",properties:{message:s,isSmartAccount:p.U.state.preferredAccountType===a.Vl.ACCOUNT_TYPES.SMART_ACCOUNT,token:this.state.token?.symbol||"",amount:e.sendTokenAmount,network:d.W.state.activeCaipNetwork?.caipNetworkId||""}}),m.P.showError("Something went wrong")}},async sendERC20Token(e){f.I.pushTransactionStack({view:"Account",goBack:!1});const t=u.x.parseUnits(e.sendTokenAmount.toString(),Number(e.decimals));try{if(p.U.state.address&&e.sendTokenAmount&&e.receiverAddress&&e.tokenAddress){const s=h.w.getPlainAddress(e.tokenAddress);await u.x.writeContract({fromAddress:p.U.state.address,tokenAddress:s,args:[e.receiverAddress,t??BigInt(0)],method:"transfer",abi:o.v.getERC20Abi(s),chainNamespace:"eip155"}),m.P.showSuccess("Transaction started"),this.resetSend()}}catch(t){console.error("SendController:sendERC20Token - failed to send erc20 token",t);const s=t instanceof Error?t.message:"Unknown error";g.E.sendEvent({type:"track",event:"SEND_ERROR",properties:{message:s,isSmartAccount:p.U.state.preferredAccountType===a.Vl.ACCOUNT_TYPES.SMART_ACCOUNT,token:this.state.token?.symbol||"",amount:e.sendTokenAmount,network:d.W.state.activeCaipNetwork?.caipNetworkId||""}}),m.P.showError("Something went wrong")}},sendSolanaToken(){this.state.sendTokenAmount&&this.state.receiverAddress?(f.I.pushTransactionStack({view:"Account",goBack:!1}),u.x.sendTransaction({chainNamespace:"solana",to:this.state.receiverAddress,value:this.state.sendTokenAmount}).then(()=>{this.resetSend(),p.U.fetchTokenBalance()}).catch(e=>{m.P.showError("Failed to send transaction. Please try again."),console.error("SendController:sendToken - failed to send solana transaction",e)})):m.P.showError("Please enter a valid amount and receiver address")},resetSend(){w.token=void 0,w.sendTokenAmount=void 0,w.receiverAddress=void 0,w.receiverProfileImageUrl=void 0,w.receiverProfileName=void 0,w.loading=!1,w.tokenBalances=[]}}},18354:(e,t,s)=>{s.d(t,{g:()=>i});const i=(0,s(40149).x)({id:"4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z",name:"Solana Testnet",network:"solana-testnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!0,chainNamespace:"solana",caipNetworkId:"solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z"})},18677:(e,t,s)=>{e=s.nmd(e);var i="__lodash_hash_undefined__",r=9007199254740991,n="[object Arguments]",o="[object Array]",a="[object Boolean]",c="[object Date]",h="[object Error]",l="[object Function]",p="[object Map]",d="[object Number]",u="[object Object]",g="[object Promise]",f="[object RegExp]",m="[object Set]",w="[object String]",y="[object WeakMap]",b="[object ArrayBuffer]",v="[object DataView]",E=/^\[object .+?Constructor\]$/,I=/^(?:0|[1-9]\d*)$/,_={};_["[object Float32Array]"]=_["[object Float64Array]"]=_["[object Int8Array]"]=_["[object Int16Array]"]=_["[object Int32Array]"]=_["[object Uint8Array]"]=_["[object Uint8ClampedArray]"]=_["[object Uint16Array]"]=_["[object Uint32Array]"]=!0,_[n]=_[o]=_[b]=_[a]=_[v]=_[c]=_[h]=_[l]=_[p]=_[d]=_[u]=_[f]=_[m]=_[w]=_[y]=!1;var N="object"==typeof s.g&&s.g&&s.g.Object===Object&&s.g,A="object"==typeof self&&self&&self.Object===Object&&self,C=N||A||Function("return this")(),P=t&&!t.nodeType&&t,S=P&&e&&!e.nodeType&&e,O=S&&S.exports===P,T=O&&N.process,k=function(){try{return T&&T.binding&&T.binding("util")}catch(e){}}(),x=k&&k.isTypedArray;function R(e,t){for(var s=-1,i=null==e?0:e.length;++s<i;)if(t(e[s],s,e))return!0;return!1}function U(e){var t=-1,s=Array(e.size);return e.forEach(function(e,i){s[++t]=[i,e]}),s}function D(e){var t=-1,s=Array(e.size);return e.forEach(function(e){s[++t]=e}),s}var j,M,L,q=Array.prototype,$=Function.prototype,B=Object.prototype,H=C["__core-js_shared__"],W=$.toString,z=B.hasOwnProperty,V=(j=/[^.]+$/.exec(H&&H.keys&&H.keys.IE_PROTO||""))?"Symbol(src)_1."+j:"",F=B.toString,K=RegExp("^"+W.call(z).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),G=O?C.Buffer:void 0,J=C.Symbol,Y=C.Uint8Array,Q=B.propertyIsEnumerable,X=q.splice,Z=J?J.toStringTag:void 0,ee=Object.getOwnPropertySymbols,te=G?G.isBuffer:void 0,se=(M=Object.keys,L=Object,function(e){return M(L(e))}),ie=Se(C,"DataView"),re=Se(C,"Map"),ne=Se(C,"Promise"),oe=Se(C,"Set"),ae=Se(C,"WeakMap"),ce=Se(Object,"create"),he=xe(ie),le=xe(re),pe=xe(ne),de=xe(oe),ue=xe(ae),ge=J?J.prototype:void 0,fe=ge?ge.valueOf:void 0;function me(e){var t=-1,s=null==e?0:e.length;for(this.clear();++t<s;){var i=e[t];this.set(i[0],i[1])}}function we(e){var t=-1,s=null==e?0:e.length;for(this.clear();++t<s;){var i=e[t];this.set(i[0],i[1])}}function ye(e){var t=-1,s=null==e?0:e.length;for(this.clear();++t<s;){var i=e[t];this.set(i[0],i[1])}}function be(e){var t=-1,s=null==e?0:e.length;for(this.__data__=new ye;++t<s;)this.add(e[t])}function ve(e){var t=this.__data__=new we(e);this.size=t.size}function Ee(e,t){for(var s=e.length;s--;)if(Re(e[s][0],t))return s;return-1}function Ie(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Z&&Z in Object(e)?function(e){var t=z.call(e,Z),s=e[Z];try{e[Z]=void 0;var i=!0}catch(e){}var r=F.call(e);return i&&(t?e[Z]=s:delete e[Z]),r}(e):function(e){return F.call(e)}(e)}function _e(e){return $e(e)&&Ie(e)==n}function Ne(e,t,s,i,r){return e===t||(null==e||null==t||!$e(e)&&!$e(t)?e!=e&&t!=t:function(e,t,s,i,r,l){var g=De(e),y=De(t),E=g?o:Te(e),I=y?o:Te(t),_=(E=E==n?u:E)==u,N=(I=I==n?u:I)==u,A=E==I;if(A&&je(e)){if(!je(t))return!1;g=!0,_=!1}if(A&&!_)return l||(l=new ve),g||Be(e)?Ae(e,t,s,i,r,l):function(e,t,s,i,r,n,o){switch(s){case v:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case b:return!(e.byteLength!=t.byteLength||!n(new Y(e),new Y(t)));case a:case c:case d:return Re(+e,+t);case h:return e.name==t.name&&e.message==t.message;case f:case w:return e==t+"";case p:var l=U;case m:var u=1&i;if(l||(l=D),e.size!=t.size&&!u)return!1;var g=o.get(e);if(g)return g==t;i|=2,o.set(e,t);var y=Ae(l(e),l(t),i,r,n,o);return o.delete(e),y;case"[object Symbol]":if(fe)return fe.call(e)==fe.call(t)}return!1}(e,t,E,s,i,r,l);if(!(1&s)){var C=_&&z.call(e,"__wrapped__"),P=N&&z.call(t,"__wrapped__");if(C||P){var S=C?e.value():e,O=P?t.value():t;return l||(l=new ve),r(S,O,s,i,l)}}return!!A&&(l||(l=new ve),function(e,t,s,i,r,n){var o=1&s,a=Ce(e),c=a.length;if(c!=Ce(t).length&&!o)return!1;for(var h=c;h--;){var l=a[h];if(!(o?l in t:z.call(t,l)))return!1}var p=n.get(e);if(p&&n.get(t))return p==t;var d=!0;n.set(e,t),n.set(t,e);for(var u=o;++h<c;){var g=e[l=a[h]],f=t[l];if(i)var m=o?i(f,g,l,t,e,n):i(g,f,l,e,t,n);if(!(void 0===m?g===f||r(g,f,s,i,n):m)){d=!1;break}u||(u="constructor"==l)}if(d&&!u){var w=e.constructor,y=t.constructor;w==y||!("constructor"in e)||!("constructor"in t)||"function"==typeof w&&w instanceof w&&"function"==typeof y&&y instanceof y||(d=!1)}return n.delete(e),n.delete(t),d}(e,t,s,i,r,l))}(e,t,s,i,Ne,r))}function Ae(e,t,s,i,r,n){var o=1&s,a=e.length,c=t.length;if(a!=c&&!(o&&c>a))return!1;var h=n.get(e);if(h&&n.get(t))return h==t;var l=-1,p=!0,d=2&s?new be:void 0;for(n.set(e,t),n.set(t,e);++l<a;){var u=e[l],g=t[l];if(i)var f=o?i(g,u,l,t,e,n):i(u,g,l,e,t,n);if(void 0!==f){if(f)continue;p=!1;break}if(d){if(!R(t,function(e,t){if(o=t,!d.has(o)&&(u===e||r(u,e,s,i,n)))return d.push(t);var o})){p=!1;break}}else if(u!==g&&!r(u,g,s,i,n)){p=!1;break}}return n.delete(e),n.delete(t),p}function Ce(e){return function(e,t,s){var i=t(e);return De(e)?i:function(e,t){for(var s=-1,i=t.length,r=e.length;++s<i;)e[r+s]=t[s];return e}(i,s(e))}(e,He,Oe)}function Pe(e,t){var s,i,r=e.__data__;return("string"==(i=typeof(s=t))||"number"==i||"symbol"==i||"boolean"==i?"__proto__"!==s:null===s)?r["string"==typeof t?"string":"hash"]:r.map}function Se(e,t){var s=function(e,t){return null==e?void 0:e[t]}(e,t);return function(e){return!(!qe(e)||function(e){return!!V&&V in e}(e))&&(Me(e)?K:E).test(xe(e))}(s)?s:void 0}me.prototype.clear=function(){this.__data__=ce?ce(null):{},this.size=0},me.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},me.prototype.get=function(e){var t=this.__data__;if(ce){var s=t[e];return s===i?void 0:s}return z.call(t,e)?t[e]:void 0},me.prototype.has=function(e){var t=this.__data__;return ce?void 0!==t[e]:z.call(t,e)},me.prototype.set=function(e,t){var s=this.__data__;return this.size+=this.has(e)?0:1,s[e]=ce&&void 0===t?i:t,this},we.prototype.clear=function(){this.__data__=[],this.size=0},we.prototype.delete=function(e){var t=this.__data__,s=Ee(t,e);return!(s<0||(s==t.length-1?t.pop():X.call(t,s,1),--this.size,0))},we.prototype.get=function(e){var t=this.__data__,s=Ee(t,e);return s<0?void 0:t[s][1]},we.prototype.has=function(e){return Ee(this.__data__,e)>-1},we.prototype.set=function(e,t){var s=this.__data__,i=Ee(s,e);return i<0?(++this.size,s.push([e,t])):s[i][1]=t,this},ye.prototype.clear=function(){this.size=0,this.__data__={hash:new me,map:new(re||we),string:new me}},ye.prototype.delete=function(e){var t=Pe(this,e).delete(e);return this.size-=t?1:0,t},ye.prototype.get=function(e){return Pe(this,e).get(e)},ye.prototype.has=function(e){return Pe(this,e).has(e)},ye.prototype.set=function(e,t){var s=Pe(this,e),i=s.size;return s.set(e,t),this.size+=s.size==i?0:1,this},be.prototype.add=be.prototype.push=function(e){return this.__data__.set(e,i),this},be.prototype.has=function(e){return this.__data__.has(e)},ve.prototype.clear=function(){this.__data__=new we,this.size=0},ve.prototype.delete=function(e){var t=this.__data__,s=t.delete(e);return this.size=t.size,s},ve.prototype.get=function(e){return this.__data__.get(e)},ve.prototype.has=function(e){return this.__data__.has(e)},ve.prototype.set=function(e,t){var s=this.__data__;if(s instanceof we){var i=s.__data__;if(!re||i.length<199)return i.push([e,t]),this.size=++s.size,this;s=this.__data__=new ye(i)}return s.set(e,t),this.size=s.size,this};var Oe=ee?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var s=-1,i=null==e?0:e.length,r=0,n=[];++s<i;){var o=e[s];t(o)&&(n[r++]=o)}return n}(ee(e),function(t){return Q.call(e,t)}))}:function(){return[]},Te=Ie;function ke(e,t){return!!(t=null==t?r:t)&&("number"==typeof e||I.test(e))&&e>-1&&e%1==0&&e<t}function xe(e){if(null!=e){try{return W.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Re(e,t){return e===t||e!=e&&t!=t}(ie&&Te(new ie(new ArrayBuffer(1)))!=v||re&&Te(new re)!=p||ne&&Te(ne.resolve())!=g||oe&&Te(new oe)!=m||ae&&Te(new ae)!=y)&&(Te=function(e){var t=Ie(e),s=t==u?e.constructor:void 0,i=s?xe(s):"";if(i)switch(i){case he:return v;case le:return p;case pe:return g;case de:return m;case ue:return y}return t});var Ue=_e(function(){return arguments}())?_e:function(e){return $e(e)&&z.call(e,"callee")&&!Q.call(e,"callee")},De=Array.isArray,je=te||function(){return!1};function Me(e){if(!qe(e))return!1;var t=Ie(e);return t==l||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}function Le(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=r}function qe(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function $e(e){return null!=e&&"object"==typeof e}var Be=x?function(e){return function(t){return e(t)}}(x):function(e){return $e(e)&&Le(e.length)&&!!_[Ie(e)]};function He(e){return null!=(t=e)&&Le(t.length)&&!Me(t)?function(e,t){var s=De(e),i=!s&&Ue(e),r=!s&&!i&&je(e),n=!s&&!i&&!r&&Be(e),o=s||i||r||n,a=o?function(e,t){for(var s=-1,i=Array(e);++s<e;)i[s]=t(s);return i}(e.length,String):[],c=a.length;for(var h in e)!t&&!z.call(e,h)||o&&("length"==h||r&&("offset"==h||"parent"==h)||n&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||ke(h,c))||a.push(h);return a}(e):function(e){if(s=(t=e)&&t.constructor,t!==("function"==typeof s&&s.prototype||B))return se(e);var t,s,i=[];for(var r in Object(e))z.call(e,r)&&"constructor"!=r&&i.push(r);return i}(e);var t}e.exports=function(e,t){return Ne(e,t)}},19760:(e,t,s)=>{async function i(...e){const t=await fetch(...e);if(!t.ok)throw new Error(`HTTP status code: ${t.status}`,{cause:t});return t}s.d(t,{Z:()=>r});class r{constructor({baseUrl:e,clientId:t}){this.baseUrl=e,this.clientId=t}async get({headers:e,signal:t,cache:s,...r}){const n=this.createUrl(r);return(await i(n,{method:"GET",headers:e,signal:t,cache:s})).json()}async getBlob({headers:e,signal:t,...s}){const r=this.createUrl(s);return(await i(r,{method:"GET",headers:e,signal:t})).blob()}async post({body:e,headers:t,signal:s,...r}){const n=this.createUrl(r);return(await i(n,{method:"POST",headers:t,body:e?JSON.stringify(e):void 0,signal:s})).json()}async put({body:e,headers:t,signal:s,...r}){const n=this.createUrl(r);return(await i(n,{method:"PUT",headers:t,body:e?JSON.stringify(e):void 0,signal:s})).json()}async delete({body:e,headers:t,signal:s,...r}){const n=this.createUrl(r);return(await i(n,{method:"DELETE",headers:t,body:e?JSON.stringify(e):void 0,signal:s})).json()}createUrl({path:e,params:t}){const s=new URL(e,this.baseUrl);return t&&Object.entries(t).forEach(([e,t])=>{t&&s.searchParams.append(e,t)}),this.clientId&&s.searchParams.append("clientId",this.clientId),s}}},21910:(e,t,s)=>{s.d(t,{$Q:()=>b,GF:()=>y,S9:()=>I,Vx:()=>m,ZP:()=>c,dQ:()=>p,lZ:()=>l,m5:()=>u,mF:()=>f,pi:()=>g,qE:()=>d,yJ:()=>_,zl:()=>w});var i=s(94549),r=s(50046),n=s.n(r),o=Object.defineProperty,a=(e,t,s)=>((e,t,s)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class c extends i.H{constructor(e){super(),this.opts=e,a(this,"protocol","wc"),a(this,"version",2)}}var h=Object.defineProperty;class l extends i.H{constructor(e,t){super(),this.core=e,this.logger=t,((e,t,s)=>{((e,t,s)=>{t in e?h(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s})(e,"symbol"!=typeof t?t+"":t,s)})(this,"records",new Map)}}class p{constructor(e,t){this.logger=e,this.core=t}}class d extends i.H{constructor(e,t){super(),this.relayer=e,this.logger=t}}class u extends i.H{constructor(e){super()}}class g{constructor(e,t,s,i){this.core=e,this.logger=t,this.name=s}}Object.defineProperty;class f extends i.H{constructor(e,t){super(),this.relayer=e,this.logger=t}}class m extends i.H{constructor(e,t){super(),this.core=e,this.logger=t}}class w{constructor(e,t,s){this.core=e,this.logger=t,this.store=s}}class y{constructor(e,t){this.projectId=e,this.logger=t}}class b{constructor(e,t,s){this.core=e,this.logger=t,this.telemetryEnabled=s}}var v=Object.defineProperty,E=(e,t,s)=>((e,t,s)=>t in e?v(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);n();class I{constructor(e){this.opts=e,E(this,"protocol","wc"),E(this,"version",2)}}r.EventEmitter;class _{constructor(e){this.client=e}}},22233:(e,t,s)=>{s.d(t,{S:()=>r});var i=s(66857);const r={bigNumber:e=>e?new i.A(e):new i.A(0),multiply(e,t){if(void 0===e||void 0===t)return new i.A(0);const s=new i.A(e),r=new i.A(t);return s.times(r)},formatNumberToLocalString:(e,t=2)=>void 0===e?"0.00":"number"==typeof e?e.toLocaleString("en-US",{maximumFractionDigits:t,minimumFractionDigits:t}):parseFloat(e).toLocaleString("en-US",{maximumFractionDigits:t,minimumFractionDigits:t}),parseLocalStringToNumber:e=>void 0===e?0:parseFloat(e.replace(/,/gu,""))}},24096:(e,t,s)=>{s.d(t,{Aj:()=>i.A}),s(24313),s(74091);var i=s(38753)},24210:(e,t,s)=>{s.d(t,{JX:()=>h,RF:()=>c,W5:()=>d,ck:()=>g,ds:()=>l,fD:()=>u});var i=s(35842),r=s(11807);let n,o,a;function c(e,t){n=document.createElement("style"),o=document.createElement("style"),a=document.createElement("style"),n.textContent=p(e).core.cssText,o.textContent=p(e).dark.cssText,a.textContent=p(e).light.cssText,document.head.appendChild(n),document.head.appendChild(o),document.head.appendChild(a),h(t)}function h(e){o&&a&&("light"===e?(o.removeAttribute("media"),a.media="enabled"):(a.removeAttribute("media"),o.media="enabled"))}function l(e){n&&o&&a&&(n.textContent=p(e).core.cssText,o.textContent=p(e).dark.cssText,a.textContent=p(e).light.cssText)}function p(e){return{core:i.AH`
|
|
3
|
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
|
|
4
|
+
@keyframes w3m-shake {
|
|
5
|
+
0% {
|
|
6
|
+
transform: scale(1) rotate(0deg);
|
|
7
|
+
}
|
|
8
|
+
20% {
|
|
9
|
+
transform: scale(1) rotate(-1deg);
|
|
10
|
+
}
|
|
11
|
+
40% {
|
|
12
|
+
transform: scale(1) rotate(1.5deg);
|
|
13
|
+
}
|
|
14
|
+
60% {
|
|
15
|
+
transform: scale(1) rotate(-1.5deg);
|
|
16
|
+
}
|
|
17
|
+
80% {
|
|
18
|
+
transform: scale(1) rotate(1deg);
|
|
19
|
+
}
|
|
20
|
+
100% {
|
|
21
|
+
transform: scale(1) rotate(0deg);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
@keyframes w3m-iframe-fade-out {
|
|
25
|
+
0% {
|
|
26
|
+
opacity: 1;
|
|
27
|
+
}
|
|
28
|
+
100% {
|
|
29
|
+
opacity: 0;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
@keyframes w3m-iframe-zoom-in {
|
|
33
|
+
0% {
|
|
34
|
+
transform: translateY(50px);
|
|
35
|
+
opacity: 0;
|
|
36
|
+
}
|
|
37
|
+
100% {
|
|
38
|
+
transform: translateY(0px);
|
|
39
|
+
opacity: 1;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
@keyframes w3m-iframe-zoom-in-mobile {
|
|
43
|
+
0% {
|
|
44
|
+
transform: scale(0.95);
|
|
45
|
+
opacity: 0;
|
|
46
|
+
}
|
|
47
|
+
100% {
|
|
48
|
+
transform: scale(1);
|
|
49
|
+
opacity: 1;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
:root {
|
|
53
|
+
--w3m-modal-width: 360px;
|
|
54
|
+
--w3m-color-mix-strength: ${(0,i.iz)(e?.["--w3m-color-mix-strength"]?`${e["--w3m-color-mix-strength"]}%`:"0%")};
|
|
55
|
+
--w3m-font-family: ${(0,i.iz)(e?.["--w3m-font-family"]||"Inter, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;")};
|
|
56
|
+
--w3m-font-size-master: ${(0,i.iz)(e?.["--w3m-font-size-master"]||"10px")};
|
|
57
|
+
--w3m-border-radius-master: ${(0,i.iz)(e?.["--w3m-border-radius-master"]||"4px")};
|
|
58
|
+
--w3m-z-index: ${(0,i.iz)(e?.["--w3m-z-index"]||999)};
|
|
59
|
+
|
|
60
|
+
--wui-font-family: var(--w3m-font-family);
|
|
61
|
+
|
|
62
|
+
--wui-font-size-mini: calc(var(--w3m-font-size-master) * 0.8);
|
|
63
|
+
--wui-font-size-micro: var(--w3m-font-size-master);
|
|
64
|
+
--wui-font-size-tiny: calc(var(--w3m-font-size-master) * 1.2);
|
|
65
|
+
--wui-font-size-small: calc(var(--w3m-font-size-master) * 1.4);
|
|
66
|
+
--wui-font-size-paragraph: calc(var(--w3m-font-size-master) * 1.6);
|
|
67
|
+
--wui-font-size-medium: calc(var(--w3m-font-size-master) * 1.8);
|
|
68
|
+
--wui-font-size-large: calc(var(--w3m-font-size-master) * 2);
|
|
69
|
+
--wui-font-size-title-6: calc(var(--w3m-font-size-master) * 2.2);
|
|
70
|
+
--wui-font-size-medium-title: calc(var(--w3m-font-size-master) * 2.4);
|
|
71
|
+
--wui-font-size-2xl: calc(var(--w3m-font-size-master) * 4);
|
|
72
|
+
|
|
73
|
+
--wui-border-radius-5xs: var(--w3m-border-radius-master);
|
|
74
|
+
--wui-border-radius-4xs: calc(var(--w3m-border-radius-master) * 1.5);
|
|
75
|
+
--wui-border-radius-3xs: calc(var(--w3m-border-radius-master) * 2);
|
|
76
|
+
--wui-border-radius-xxs: calc(var(--w3m-border-radius-master) * 3);
|
|
77
|
+
--wui-border-radius-xs: calc(var(--w3m-border-radius-master) * 4);
|
|
78
|
+
--wui-border-radius-s: calc(var(--w3m-border-radius-master) * 5);
|
|
79
|
+
--wui-border-radius-m: calc(var(--w3m-border-radius-master) * 7);
|
|
80
|
+
--wui-border-radius-l: calc(var(--w3m-border-radius-master) * 9);
|
|
81
|
+
--wui-border-radius-3xl: calc(var(--w3m-border-radius-master) * 20);
|
|
82
|
+
|
|
83
|
+
--wui-font-weight-light: 400;
|
|
84
|
+
--wui-font-weight-regular: 500;
|
|
85
|
+
--wui-font-weight-medium: 600;
|
|
86
|
+
--wui-font-weight-bold: 700;
|
|
87
|
+
|
|
88
|
+
--wui-letter-spacing-2xl: -1.6px;
|
|
89
|
+
--wui-letter-spacing-medium-title: -0.96px;
|
|
90
|
+
--wui-letter-spacing-title-6: -0.88px;
|
|
91
|
+
--wui-letter-spacing-large: -0.8px;
|
|
92
|
+
--wui-letter-spacing-medium: -0.72px;
|
|
93
|
+
--wui-letter-spacing-paragraph: -0.64px;
|
|
94
|
+
--wui-letter-spacing-small: -0.56px;
|
|
95
|
+
--wui-letter-spacing-tiny: -0.48px;
|
|
96
|
+
--wui-letter-spacing-micro: -0.2px;
|
|
97
|
+
--wui-letter-spacing-mini: -0.16px;
|
|
98
|
+
|
|
99
|
+
--wui-spacing-0: 0px;
|
|
100
|
+
--wui-spacing-4xs: 2px;
|
|
101
|
+
--wui-spacing-3xs: 4px;
|
|
102
|
+
--wui-spacing-xxs: 6px;
|
|
103
|
+
--wui-spacing-2xs: 7px;
|
|
104
|
+
--wui-spacing-xs: 8px;
|
|
105
|
+
--wui-spacing-1xs: 10px;
|
|
106
|
+
--wui-spacing-s: 12px;
|
|
107
|
+
--wui-spacing-m: 14px;
|
|
108
|
+
--wui-spacing-l: 16px;
|
|
109
|
+
--wui-spacing-2l: 18px;
|
|
110
|
+
--wui-spacing-xl: 20px;
|
|
111
|
+
--wui-spacing-xxl: 24px;
|
|
112
|
+
--wui-spacing-2xl: 32px;
|
|
113
|
+
--wui-spacing-3xl: 40px;
|
|
114
|
+
--wui-spacing-4xl: 90px;
|
|
115
|
+
--wui-spacing-5xl: 95px;
|
|
116
|
+
|
|
117
|
+
--wui-icon-box-size-xxs: 14px;
|
|
118
|
+
--wui-icon-box-size-xs: 20px;
|
|
119
|
+
--wui-icon-box-size-sm: 24px;
|
|
120
|
+
--wui-icon-box-size-md: 32px;
|
|
121
|
+
--wui-icon-box-size-mdl: 36px;
|
|
122
|
+
--wui-icon-box-size-lg: 40px;
|
|
123
|
+
--wui-icon-box-size-2lg: 48px;
|
|
124
|
+
--wui-icon-box-size-xl: 64px;
|
|
125
|
+
|
|
126
|
+
--wui-icon-size-inherit: inherit;
|
|
127
|
+
--wui-icon-size-xxs: 10px;
|
|
128
|
+
--wui-icon-size-xs: 12px;
|
|
129
|
+
--wui-icon-size-sm: 14px;
|
|
130
|
+
--wui-icon-size-md: 16px;
|
|
131
|
+
--wui-icon-size-mdl: 18px;
|
|
132
|
+
--wui-icon-size-lg: 20px;
|
|
133
|
+
--wui-icon-size-xl: 24px;
|
|
134
|
+
--wui-icon-size-xxl: 28px;
|
|
135
|
+
|
|
136
|
+
--wui-wallet-image-size-inherit: inherit;
|
|
137
|
+
--wui-wallet-image-size-sm: 40px;
|
|
138
|
+
--wui-wallet-image-size-md: 56px;
|
|
139
|
+
--wui-wallet-image-size-lg: 80px;
|
|
140
|
+
|
|
141
|
+
--wui-visual-size-size-inherit: inherit;
|
|
142
|
+
--wui-visual-size-sm: 40px;
|
|
143
|
+
--wui-visual-size-md: 55px;
|
|
144
|
+
--wui-visual-size-lg: 80px;
|
|
145
|
+
|
|
146
|
+
--wui-box-size-md: 100px;
|
|
147
|
+
--wui-box-size-lg: 120px;
|
|
148
|
+
|
|
149
|
+
--wui-ease-out-power-2: cubic-bezier(0, 0, 0.22, 1);
|
|
150
|
+
--wui-ease-out-power-1: cubic-bezier(0, 0, 0.55, 1);
|
|
151
|
+
|
|
152
|
+
--wui-ease-in-power-3: cubic-bezier(0.66, 0, 1, 1);
|
|
153
|
+
--wui-ease-in-power-2: cubic-bezier(0.45, 0, 1, 1);
|
|
154
|
+
--wui-ease-in-power-1: cubic-bezier(0.3, 0, 1, 1);
|
|
155
|
+
|
|
156
|
+
--wui-ease-inout-power-1: cubic-bezier(0.45, 0, 0.55, 1);
|
|
157
|
+
|
|
158
|
+
--wui-duration-lg: 200ms;
|
|
159
|
+
--wui-duration-md: 125ms;
|
|
160
|
+
--wui-duration-sm: 75ms;
|
|
161
|
+
|
|
162
|
+
--wui-path-network-sm: path(
|
|
163
|
+
'M15.4 2.1a5.21 5.21 0 0 1 5.2 0l11.61 6.7a5.21 5.21 0 0 1 2.61 4.52v13.4c0 1.87-1 3.59-2.6 4.52l-11.61 6.7c-1.62.93-3.6.93-5.22 0l-11.6-6.7a5.21 5.21 0 0 1-2.61-4.51v-13.4c0-1.87 1-3.6 2.6-4.52L15.4 2.1Z'
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
--wui-path-network-md: path(
|
|
167
|
+
'M43.4605 10.7248L28.0485 1.61089C25.5438 0.129705 22.4562 0.129705 19.9515 1.61088L4.53951 10.7248C2.03626 12.2051 0.5 14.9365 0.5 17.886V36.1139C0.5 39.0635 2.03626 41.7949 4.53951 43.2752L19.9515 52.3891C22.4562 53.8703 25.5438 53.8703 28.0485 52.3891L43.4605 43.2752C45.9637 41.7949 47.5 39.0635 47.5 36.114V17.8861C47.5 14.9365 45.9637 12.2051 43.4605 10.7248Z'
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
--wui-path-network-lg: path(
|
|
171
|
+
'M78.3244 18.926L50.1808 2.45078C45.7376 -0.150261 40.2624 -0.150262 35.8192 2.45078L7.6756 18.926C3.23322 21.5266 0.5 26.3301 0.5 31.5248V64.4752C0.5 69.6699 3.23322 74.4734 7.6756 77.074L35.8192 93.5492C40.2624 96.1503 45.7376 96.1503 50.1808 93.5492L78.3244 77.074C82.7668 74.4734 85.5 69.6699 85.5 64.4752V31.5248C85.5 26.3301 82.7668 21.5266 78.3244 18.926Z'
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
--wui-width-network-sm: 36px;
|
|
175
|
+
--wui-width-network-md: 48px;
|
|
176
|
+
--wui-width-network-lg: 86px;
|
|
177
|
+
|
|
178
|
+
--wui-height-network-sm: 40px;
|
|
179
|
+
--wui-height-network-md: 54px;
|
|
180
|
+
--wui-height-network-lg: 96px;
|
|
181
|
+
|
|
182
|
+
--wui-icon-size-network-xs: 12px;
|
|
183
|
+
--wui-icon-size-network-sm: 16px;
|
|
184
|
+
--wui-icon-size-network-md: 24px;
|
|
185
|
+
--wui-icon-size-network-lg: 42px;
|
|
186
|
+
|
|
187
|
+
--wui-color-inherit: inherit;
|
|
188
|
+
|
|
189
|
+
--wui-color-inverse-100: #fff;
|
|
190
|
+
--wui-color-inverse-000: #000;
|
|
191
|
+
|
|
192
|
+
--wui-cover: rgba(20, 20, 20, 0.8);
|
|
193
|
+
|
|
194
|
+
--wui-color-modal-bg: var(--wui-color-modal-bg-base);
|
|
195
|
+
|
|
196
|
+
--wui-color-accent-100: var(--wui-color-accent-base-100);
|
|
197
|
+
--wui-color-accent-090: var(--wui-color-accent-base-090);
|
|
198
|
+
--wui-color-accent-080: var(--wui-color-accent-base-080);
|
|
199
|
+
|
|
200
|
+
--wui-color-success-100: var(--wui-color-success-base-100);
|
|
201
|
+
--wui-color-success-125: var(--wui-color-success-base-125);
|
|
202
|
+
|
|
203
|
+
--wui-color-warning-100: var(--wui-color-warning-base-100);
|
|
204
|
+
|
|
205
|
+
--wui-color-error-100: var(--wui-color-error-base-100);
|
|
206
|
+
--wui-color-error-125: var(--wui-color-error-base-125);
|
|
207
|
+
|
|
208
|
+
--wui-color-blue-100: var(--wui-color-blue-base-100);
|
|
209
|
+
--wui-color-blue-90: var(--wui-color-blue-base-90);
|
|
210
|
+
|
|
211
|
+
--wui-icon-box-bg-error-100: var(--wui-icon-box-bg-error-base-100);
|
|
212
|
+
--wui-icon-box-bg-blue-100: var(--wui-icon-box-bg-blue-base-100);
|
|
213
|
+
--wui-icon-box-bg-success-100: var(--wui-icon-box-bg-success-base-100);
|
|
214
|
+
--wui-icon-box-bg-inverse-100: var(--wui-icon-box-bg-inverse-base-100);
|
|
215
|
+
|
|
216
|
+
--wui-all-wallets-bg-100: var(--wui-all-wallets-bg-100);
|
|
217
|
+
|
|
218
|
+
--wui-avatar-border: var(--wui-avatar-border-base);
|
|
219
|
+
|
|
220
|
+
--wui-thumbnail-border: var(--wui-thumbnail-border-base);
|
|
221
|
+
|
|
222
|
+
--wui-wallet-button-bg: var(--wui-wallet-button-bg-base);
|
|
223
|
+
|
|
224
|
+
--wui-box-shadow-blue: var(--wui-color-accent-glass-020);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
@supports (background: color-mix(in srgb, white 50%, black)) {
|
|
228
|
+
:root {
|
|
229
|
+
--wui-color-modal-bg: color-mix(
|
|
230
|
+
in srgb,
|
|
231
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
232
|
+
var(--wui-color-modal-bg-base)
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
--wui-box-shadow-blue: color-mix(in srgb, var(--wui-color-accent-100) 20%, transparent);
|
|
236
|
+
|
|
237
|
+
--wui-color-accent-100: color-mix(
|
|
238
|
+
in srgb,
|
|
239
|
+
var(--wui-color-accent-base-100) 100%,
|
|
240
|
+
transparent
|
|
241
|
+
);
|
|
242
|
+
--wui-color-accent-090: color-mix(
|
|
243
|
+
in srgb,
|
|
244
|
+
var(--wui-color-accent-base-100) 90%,
|
|
245
|
+
transparent
|
|
246
|
+
);
|
|
247
|
+
--wui-color-accent-080: color-mix(
|
|
248
|
+
in srgb,
|
|
249
|
+
var(--wui-color-accent-base-100) 80%,
|
|
250
|
+
transparent
|
|
251
|
+
);
|
|
252
|
+
--wui-color-accent-glass-090: color-mix(
|
|
253
|
+
in srgb,
|
|
254
|
+
var(--wui-color-accent-base-100) 90%,
|
|
255
|
+
transparent
|
|
256
|
+
);
|
|
257
|
+
--wui-color-accent-glass-080: color-mix(
|
|
258
|
+
in srgb,
|
|
259
|
+
var(--wui-color-accent-base-100) 80%,
|
|
260
|
+
transparent
|
|
261
|
+
);
|
|
262
|
+
--wui-color-accent-glass-020: color-mix(
|
|
263
|
+
in srgb,
|
|
264
|
+
var(--wui-color-accent-base-100) 20%,
|
|
265
|
+
transparent
|
|
266
|
+
);
|
|
267
|
+
--wui-color-accent-glass-015: color-mix(
|
|
268
|
+
in srgb,
|
|
269
|
+
var(--wui-color-accent-base-100) 15%,
|
|
270
|
+
transparent
|
|
271
|
+
);
|
|
272
|
+
--wui-color-accent-glass-010: color-mix(
|
|
273
|
+
in srgb,
|
|
274
|
+
var(--wui-color-accent-base-100) 10%,
|
|
275
|
+
transparent
|
|
276
|
+
);
|
|
277
|
+
--wui-color-accent-glass-005: color-mix(
|
|
278
|
+
in srgb,
|
|
279
|
+
var(--wui-color-accent-base-100) 5%,
|
|
280
|
+
transparent
|
|
281
|
+
);
|
|
282
|
+
--wui-color-accent-002: color-mix(
|
|
283
|
+
in srgb,
|
|
284
|
+
var(--wui-color-accent-base-100) 2%,
|
|
285
|
+
transparent
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
--wui-color-fg-100: color-mix(
|
|
289
|
+
in srgb,
|
|
290
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
291
|
+
var(--wui-color-fg-100)
|
|
292
|
+
);
|
|
293
|
+
--wui-color-fg-125: color-mix(
|
|
294
|
+
in srgb,
|
|
295
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
296
|
+
var(--wui-color-fg-125)
|
|
297
|
+
);
|
|
298
|
+
--wui-color-fg-150: color-mix(
|
|
299
|
+
in srgb,
|
|
300
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
301
|
+
var(--wui-color-fg-150)
|
|
302
|
+
);
|
|
303
|
+
--wui-color-fg-175: color-mix(
|
|
304
|
+
in srgb,
|
|
305
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
306
|
+
var(--wui-color-fg-175)
|
|
307
|
+
);
|
|
308
|
+
--wui-color-fg-200: color-mix(
|
|
309
|
+
in srgb,
|
|
310
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
311
|
+
var(--wui-color-fg-200)
|
|
312
|
+
);
|
|
313
|
+
--wui-color-fg-225: color-mix(
|
|
314
|
+
in srgb,
|
|
315
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
316
|
+
var(--wui-color-fg-225)
|
|
317
|
+
);
|
|
318
|
+
--wui-color-fg-250: color-mix(
|
|
319
|
+
in srgb,
|
|
320
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
321
|
+
var(--wui-color-fg-250)
|
|
322
|
+
);
|
|
323
|
+
--wui-color-fg-275: color-mix(
|
|
324
|
+
in srgb,
|
|
325
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
326
|
+
var(--wui-color-fg-275)
|
|
327
|
+
);
|
|
328
|
+
--wui-color-fg-300: color-mix(
|
|
329
|
+
in srgb,
|
|
330
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
331
|
+
var(--wui-color-fg-300)
|
|
332
|
+
);
|
|
333
|
+
--wui-color-fg-325: color-mix(
|
|
334
|
+
in srgb,
|
|
335
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
336
|
+
var(--wui-color-fg-325)
|
|
337
|
+
);
|
|
338
|
+
--wui-color-fg-350: color-mix(
|
|
339
|
+
in srgb,
|
|
340
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
341
|
+
var(--wui-color-fg-350)
|
|
342
|
+
);
|
|
343
|
+
|
|
344
|
+
--wui-color-bg-100: color-mix(
|
|
345
|
+
in srgb,
|
|
346
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
347
|
+
var(--wui-color-bg-100)
|
|
348
|
+
);
|
|
349
|
+
--wui-color-bg-125: color-mix(
|
|
350
|
+
in srgb,
|
|
351
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
352
|
+
var(--wui-color-bg-125)
|
|
353
|
+
);
|
|
354
|
+
--wui-color-bg-150: color-mix(
|
|
355
|
+
in srgb,
|
|
356
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
357
|
+
var(--wui-color-bg-150)
|
|
358
|
+
);
|
|
359
|
+
--wui-color-bg-175: color-mix(
|
|
360
|
+
in srgb,
|
|
361
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
362
|
+
var(--wui-color-bg-175)
|
|
363
|
+
);
|
|
364
|
+
--wui-color-bg-200: color-mix(
|
|
365
|
+
in srgb,
|
|
366
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
367
|
+
var(--wui-color-bg-200)
|
|
368
|
+
);
|
|
369
|
+
--wui-color-bg-225: color-mix(
|
|
370
|
+
in srgb,
|
|
371
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
372
|
+
var(--wui-color-bg-225)
|
|
373
|
+
);
|
|
374
|
+
--wui-color-bg-250: color-mix(
|
|
375
|
+
in srgb,
|
|
376
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
377
|
+
var(--wui-color-bg-250)
|
|
378
|
+
);
|
|
379
|
+
--wui-color-bg-275: color-mix(
|
|
380
|
+
in srgb,
|
|
381
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
382
|
+
var(--wui-color-bg-275)
|
|
383
|
+
);
|
|
384
|
+
--wui-color-bg-300: color-mix(
|
|
385
|
+
in srgb,
|
|
386
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
387
|
+
var(--wui-color-bg-300)
|
|
388
|
+
);
|
|
389
|
+
--wui-color-bg-325: color-mix(
|
|
390
|
+
in srgb,
|
|
391
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
392
|
+
var(--wui-color-bg-325)
|
|
393
|
+
);
|
|
394
|
+
--wui-color-bg-350: color-mix(
|
|
395
|
+
in srgb,
|
|
396
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
397
|
+
var(--wui-color-bg-350)
|
|
398
|
+
);
|
|
399
|
+
|
|
400
|
+
--wui-color-success-100: color-mix(
|
|
401
|
+
in srgb,
|
|
402
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
403
|
+
var(--wui-color-success-base-100)
|
|
404
|
+
);
|
|
405
|
+
--wui-color-success-125: color-mix(
|
|
406
|
+
in srgb,
|
|
407
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
408
|
+
var(--wui-color-success-base-125)
|
|
409
|
+
);
|
|
410
|
+
|
|
411
|
+
--wui-color-warning-100: color-mix(
|
|
412
|
+
in srgb,
|
|
413
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
414
|
+
var(--wui-color-warning-base-100)
|
|
415
|
+
);
|
|
416
|
+
|
|
417
|
+
--wui-color-error-100: color-mix(
|
|
418
|
+
in srgb,
|
|
419
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
420
|
+
var(--wui-color-error-base-100)
|
|
421
|
+
);
|
|
422
|
+
--wui-color-blue-100: color-mix(
|
|
423
|
+
in srgb,
|
|
424
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
425
|
+
var(--wui-color-blue-base-100)
|
|
426
|
+
);
|
|
427
|
+
--wui-color-blue-90: color-mix(
|
|
428
|
+
in srgb,
|
|
429
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
430
|
+
var(--wui-color-blue-base-90)
|
|
431
|
+
);
|
|
432
|
+
--wui-color-error-125: color-mix(
|
|
433
|
+
in srgb,
|
|
434
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
435
|
+
var(--wui-color-error-base-125)
|
|
436
|
+
);
|
|
437
|
+
|
|
438
|
+
--wui-icon-box-bg-error-100: color-mix(
|
|
439
|
+
in srgb,
|
|
440
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
441
|
+
var(--wui-icon-box-bg-error-base-100)
|
|
442
|
+
);
|
|
443
|
+
--wui-icon-box-bg-accent-100: color-mix(
|
|
444
|
+
in srgb,
|
|
445
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
446
|
+
var(--wui-icon-box-bg-blue-base-100)
|
|
447
|
+
);
|
|
448
|
+
--wui-icon-box-bg-success-100: color-mix(
|
|
449
|
+
in srgb,
|
|
450
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
451
|
+
var(--wui-icon-box-bg-success-base-100)
|
|
452
|
+
);
|
|
453
|
+
--wui-icon-box-bg-inverse-100: color-mix(
|
|
454
|
+
in srgb,
|
|
455
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
456
|
+
var(--wui-icon-box-bg-inverse-base-100)
|
|
457
|
+
);
|
|
458
|
+
|
|
459
|
+
--wui-all-wallets-bg-100: color-mix(
|
|
460
|
+
in srgb,
|
|
461
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
462
|
+
var(--wui-all-wallets-bg-100)
|
|
463
|
+
);
|
|
464
|
+
|
|
465
|
+
--wui-avatar-border: color-mix(
|
|
466
|
+
in srgb,
|
|
467
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
468
|
+
var(--wui-avatar-border-base)
|
|
469
|
+
);
|
|
470
|
+
|
|
471
|
+
--wui-thumbnail-border: color-mix(
|
|
472
|
+
in srgb,
|
|
473
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
474
|
+
var(--wui-thumbnail-border-base)
|
|
475
|
+
);
|
|
476
|
+
|
|
477
|
+
--wui-wallet-button-bg: color-mix(
|
|
478
|
+
in srgb,
|
|
479
|
+
var(--w3m-color-mix) var(--w3m-color-mix-strength),
|
|
480
|
+
var(--wui-wallet-button-bg-base)
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
`,light:i.AH`
|
|
485
|
+
:root {
|
|
486
|
+
--w3m-color-mix: ${(0,i.iz)(e?.["--w3m-color-mix"]||"#fff")};
|
|
487
|
+
--w3m-accent: ${(0,i.iz)((0,r.o)(e,"dark")["--w3m-accent"])};
|
|
488
|
+
--w3m-default: #fff;
|
|
489
|
+
|
|
490
|
+
--wui-color-modal-bg-base: ${(0,i.iz)((0,r.o)(e,"dark")["--w3m-background"])};
|
|
491
|
+
--wui-color-accent-base-100: var(--w3m-accent);
|
|
492
|
+
|
|
493
|
+
--wui-color-blueberry-100: hsla(230, 100%, 67%, 1);
|
|
494
|
+
--wui-color-blueberry-090: hsla(231, 76%, 61%, 1);
|
|
495
|
+
--wui-color-blueberry-080: hsla(230, 59%, 55%, 1);
|
|
496
|
+
--wui-color-blueberry-050: hsla(231, 100%, 70%, 0.1);
|
|
497
|
+
|
|
498
|
+
--wui-color-fg-100: #e4e7e7;
|
|
499
|
+
--wui-color-fg-125: #d0d5d5;
|
|
500
|
+
--wui-color-fg-150: #a8b1b1;
|
|
501
|
+
--wui-color-fg-175: #a8b0b0;
|
|
502
|
+
--wui-color-fg-200: #949e9e;
|
|
503
|
+
--wui-color-fg-225: #868f8f;
|
|
504
|
+
--wui-color-fg-250: #788080;
|
|
505
|
+
--wui-color-fg-275: #788181;
|
|
506
|
+
--wui-color-fg-300: #6e7777;
|
|
507
|
+
--wui-color-fg-325: #9a9a9a;
|
|
508
|
+
--wui-color-fg-350: #363636;
|
|
509
|
+
|
|
510
|
+
--wui-color-bg-100: #141414;
|
|
511
|
+
--wui-color-bg-125: #191a1a;
|
|
512
|
+
--wui-color-bg-150: #1e1f1f;
|
|
513
|
+
--wui-color-bg-175: #222525;
|
|
514
|
+
--wui-color-bg-200: #272a2a;
|
|
515
|
+
--wui-color-bg-225: #2c3030;
|
|
516
|
+
--wui-color-bg-250: #313535;
|
|
517
|
+
--wui-color-bg-275: #363b3b;
|
|
518
|
+
--wui-color-bg-300: #3b4040;
|
|
519
|
+
--wui-color-bg-325: #252525;
|
|
520
|
+
--wui-color-bg-350: #ffffff;
|
|
521
|
+
|
|
522
|
+
--wui-color-success-base-100: #26d962;
|
|
523
|
+
--wui-color-success-base-125: #30a46b;
|
|
524
|
+
|
|
525
|
+
--wui-color-warning-base-100: #f3a13f;
|
|
526
|
+
|
|
527
|
+
--wui-color-error-base-100: #f25a67;
|
|
528
|
+
--wui-color-error-base-125: #df4a34;
|
|
529
|
+
|
|
530
|
+
--wui-color-blue-base-100: rgba(102, 125, 255, 1);
|
|
531
|
+
--wui-color-blue-base-90: rgba(102, 125, 255, 0.9);
|
|
532
|
+
|
|
533
|
+
--wui-color-success-glass-001: rgba(38, 217, 98, 0.01);
|
|
534
|
+
--wui-color-success-glass-002: rgba(38, 217, 98, 0.02);
|
|
535
|
+
--wui-color-success-glass-005: rgba(38, 217, 98, 0.05);
|
|
536
|
+
--wui-color-success-glass-010: rgba(38, 217, 98, 0.1);
|
|
537
|
+
--wui-color-success-glass-015: rgba(38, 217, 98, 0.15);
|
|
538
|
+
--wui-color-success-glass-020: rgba(38, 217, 98, 0.2);
|
|
539
|
+
--wui-color-success-glass-025: rgba(38, 217, 98, 0.25);
|
|
540
|
+
--wui-color-success-glass-030: rgba(38, 217, 98, 0.3);
|
|
541
|
+
--wui-color-success-glass-060: rgba(38, 217, 98, 0.6);
|
|
542
|
+
--wui-color-success-glass-080: rgba(38, 217, 98, 0.8);
|
|
543
|
+
|
|
544
|
+
--wui-color-success-glass-reown-020: rgba(48, 164, 107, 0.2);
|
|
545
|
+
|
|
546
|
+
--wui-color-warning-glass-reown-020: rgba(243, 161, 63, 0.2);
|
|
547
|
+
|
|
548
|
+
--wui-color-error-glass-001: rgba(242, 90, 103, 0.01);
|
|
549
|
+
--wui-color-error-glass-002: rgba(242, 90, 103, 0.02);
|
|
550
|
+
--wui-color-error-glass-005: rgba(242, 90, 103, 0.05);
|
|
551
|
+
--wui-color-error-glass-010: rgba(242, 90, 103, 0.1);
|
|
552
|
+
--wui-color-error-glass-015: rgba(242, 90, 103, 0.15);
|
|
553
|
+
--wui-color-error-glass-020: rgba(242, 90, 103, 0.2);
|
|
554
|
+
--wui-color-error-glass-025: rgba(242, 90, 103, 0.25);
|
|
555
|
+
--wui-color-error-glass-030: rgba(242, 90, 103, 0.3);
|
|
556
|
+
--wui-color-error-glass-060: rgba(242, 90, 103, 0.6);
|
|
557
|
+
--wui-color-error-glass-080: rgba(242, 90, 103, 0.8);
|
|
558
|
+
|
|
559
|
+
--wui-color-error-glass-reown-020: rgba(223, 74, 52, 0.2);
|
|
560
|
+
|
|
561
|
+
--wui-color-gray-glass-001: rgba(255, 255, 255, 0.01);
|
|
562
|
+
--wui-color-gray-glass-002: rgba(255, 255, 255, 0.02);
|
|
563
|
+
--wui-color-gray-glass-005: rgba(255, 255, 255, 0.05);
|
|
564
|
+
--wui-color-gray-glass-010: rgba(255, 255, 255, 0.1);
|
|
565
|
+
--wui-color-gray-glass-015: rgba(255, 255, 255, 0.15);
|
|
566
|
+
--wui-color-gray-glass-020: rgba(255, 255, 255, 0.2);
|
|
567
|
+
--wui-color-gray-glass-025: rgba(255, 255, 255, 0.25);
|
|
568
|
+
--wui-color-gray-glass-030: rgba(255, 255, 255, 0.3);
|
|
569
|
+
--wui-color-gray-glass-060: rgba(255, 255, 255, 0.6);
|
|
570
|
+
--wui-color-gray-glass-080: rgba(255, 255, 255, 0.8);
|
|
571
|
+
--wui-color-gray-glass-090: rgba(255, 255, 255, 0.9);
|
|
572
|
+
|
|
573
|
+
--wui-color-dark-glass-100: rgba(42, 42, 42, 1);
|
|
574
|
+
|
|
575
|
+
--wui-icon-box-bg-error-base-100: #3c2426;
|
|
576
|
+
--wui-icon-box-bg-blue-base-100: #20303f;
|
|
577
|
+
--wui-icon-box-bg-success-base-100: #1f3a28;
|
|
578
|
+
--wui-icon-box-bg-inverse-base-100: #243240;
|
|
579
|
+
|
|
580
|
+
--wui-all-wallets-bg-100: #222b35;
|
|
581
|
+
|
|
582
|
+
--wui-avatar-border-base: #252525;
|
|
583
|
+
|
|
584
|
+
--wui-thumbnail-border-base: #252525;
|
|
585
|
+
|
|
586
|
+
--wui-wallet-button-bg-base: var(--wui-color-bg-125);
|
|
587
|
+
|
|
588
|
+
--w3m-card-embedded-shadow-color: rgb(17 17 18 / 25%);
|
|
589
|
+
}
|
|
590
|
+
`,dark:i.AH`
|
|
591
|
+
:root {
|
|
592
|
+
--w3m-color-mix: ${(0,i.iz)(e?.["--w3m-color-mix"]||"#000")};
|
|
593
|
+
--w3m-accent: ${(0,i.iz)((0,r.o)(e,"light")["--w3m-accent"])};
|
|
594
|
+
--w3m-default: #000;
|
|
595
|
+
|
|
596
|
+
--wui-color-modal-bg-base: ${(0,i.iz)((0,r.o)(e,"light")["--w3m-background"])};
|
|
597
|
+
--wui-color-accent-base-100: var(--w3m-accent);
|
|
598
|
+
|
|
599
|
+
--wui-color-blueberry-100: hsla(231, 100%, 70%, 1);
|
|
600
|
+
--wui-color-blueberry-090: hsla(231, 97%, 72%, 1);
|
|
601
|
+
--wui-color-blueberry-080: hsla(231, 92%, 74%, 1);
|
|
602
|
+
|
|
603
|
+
--wui-color-fg-100: #141414;
|
|
604
|
+
--wui-color-fg-125: #2d3131;
|
|
605
|
+
--wui-color-fg-150: #474d4d;
|
|
606
|
+
--wui-color-fg-175: #636d6d;
|
|
607
|
+
--wui-color-fg-200: #798686;
|
|
608
|
+
--wui-color-fg-225: #828f8f;
|
|
609
|
+
--wui-color-fg-250: #8b9797;
|
|
610
|
+
--wui-color-fg-275: #95a0a0;
|
|
611
|
+
--wui-color-fg-300: #9ea9a9;
|
|
612
|
+
--wui-color-fg-325: #9a9a9a;
|
|
613
|
+
--wui-color-fg-350: #d0d0d0;
|
|
614
|
+
|
|
615
|
+
--wui-color-bg-100: #ffffff;
|
|
616
|
+
--wui-color-bg-125: #f5fafa;
|
|
617
|
+
--wui-color-bg-150: #f3f8f8;
|
|
618
|
+
--wui-color-bg-175: #eef4f4;
|
|
619
|
+
--wui-color-bg-200: #eaf1f1;
|
|
620
|
+
--wui-color-bg-225: #e5eded;
|
|
621
|
+
--wui-color-bg-250: #e1e9e9;
|
|
622
|
+
--wui-color-bg-275: #dce7e7;
|
|
623
|
+
--wui-color-bg-300: #d8e3e3;
|
|
624
|
+
--wui-color-bg-325: #f3f3f3;
|
|
625
|
+
--wui-color-bg-350: #202020;
|
|
626
|
+
|
|
627
|
+
--wui-color-success-base-100: #26b562;
|
|
628
|
+
--wui-color-success-base-125: #30a46b;
|
|
629
|
+
|
|
630
|
+
--wui-color-warning-base-100: #f3a13f;
|
|
631
|
+
|
|
632
|
+
--wui-color-error-base-100: #f05142;
|
|
633
|
+
--wui-color-error-base-125: #df4a34;
|
|
634
|
+
|
|
635
|
+
--wui-color-blue-base-100: rgba(102, 125, 255, 1);
|
|
636
|
+
--wui-color-blue-base-90: rgba(102, 125, 255, 0.9);
|
|
637
|
+
|
|
638
|
+
--wui-color-success-glass-001: rgba(38, 181, 98, 0.01);
|
|
639
|
+
--wui-color-success-glass-002: rgba(38, 181, 98, 0.02);
|
|
640
|
+
--wui-color-success-glass-005: rgba(38, 181, 98, 0.05);
|
|
641
|
+
--wui-color-success-glass-010: rgba(38, 181, 98, 0.1);
|
|
642
|
+
--wui-color-success-glass-015: rgba(38, 181, 98, 0.15);
|
|
643
|
+
--wui-color-success-glass-020: rgba(38, 181, 98, 0.2);
|
|
644
|
+
--wui-color-success-glass-025: rgba(38, 181, 98, 0.25);
|
|
645
|
+
--wui-color-success-glass-030: rgba(38, 181, 98, 0.3);
|
|
646
|
+
--wui-color-success-glass-060: rgba(38, 181, 98, 0.6);
|
|
647
|
+
--wui-color-success-glass-080: rgba(38, 181, 98, 0.8);
|
|
648
|
+
|
|
649
|
+
--wui-color-success-glass-reown-020: rgba(48, 164, 107, 0.2);
|
|
650
|
+
|
|
651
|
+
--wui-color-warning-glass-reown-020: rgba(243, 161, 63, 0.2);
|
|
652
|
+
|
|
653
|
+
--wui-color-error-glass-001: rgba(240, 81, 66, 0.01);
|
|
654
|
+
--wui-color-error-glass-002: rgba(240, 81, 66, 0.02);
|
|
655
|
+
--wui-color-error-glass-005: rgba(240, 81, 66, 0.05);
|
|
656
|
+
--wui-color-error-glass-010: rgba(240, 81, 66, 0.1);
|
|
657
|
+
--wui-color-error-glass-015: rgba(240, 81, 66, 0.15);
|
|
658
|
+
--wui-color-error-glass-020: rgba(240, 81, 66, 0.2);
|
|
659
|
+
--wui-color-error-glass-025: rgba(240, 81, 66, 0.25);
|
|
660
|
+
--wui-color-error-glass-030: rgba(240, 81, 66, 0.3);
|
|
661
|
+
--wui-color-error-glass-060: rgba(240, 81, 66, 0.6);
|
|
662
|
+
--wui-color-error-glass-080: rgba(240, 81, 66, 0.8);
|
|
663
|
+
|
|
664
|
+
--wui-color-error-glass-reown-020: rgba(223, 74, 52, 0.2);
|
|
665
|
+
|
|
666
|
+
--wui-icon-box-bg-error-base-100: #f4dfdd;
|
|
667
|
+
--wui-icon-box-bg-blue-base-100: #d9ecfb;
|
|
668
|
+
--wui-icon-box-bg-success-base-100: #daf0e4;
|
|
669
|
+
--wui-icon-box-bg-inverse-base-100: #dcecfc;
|
|
670
|
+
|
|
671
|
+
--wui-all-wallets-bg-100: #e8f1fa;
|
|
672
|
+
|
|
673
|
+
--wui-avatar-border-base: #f3f4f4;
|
|
674
|
+
|
|
675
|
+
--wui-thumbnail-border-base: #eaefef;
|
|
676
|
+
|
|
677
|
+
--wui-wallet-button-bg-base: var(--wui-color-bg-125);
|
|
678
|
+
|
|
679
|
+
--wui-color-gray-glass-001: rgba(0, 0, 0, 0.01);
|
|
680
|
+
--wui-color-gray-glass-002: rgba(0, 0, 0, 0.02);
|
|
681
|
+
--wui-color-gray-glass-005: rgba(0, 0, 0, 0.05);
|
|
682
|
+
--wui-color-gray-glass-010: rgba(0, 0, 0, 0.1);
|
|
683
|
+
--wui-color-gray-glass-015: rgba(0, 0, 0, 0.15);
|
|
684
|
+
--wui-color-gray-glass-020: rgba(0, 0, 0, 0.2);
|
|
685
|
+
--wui-color-gray-glass-025: rgba(0, 0, 0, 0.25);
|
|
686
|
+
--wui-color-gray-glass-030: rgba(0, 0, 0, 0.3);
|
|
687
|
+
--wui-color-gray-glass-060: rgba(0, 0, 0, 0.6);
|
|
688
|
+
--wui-color-gray-glass-080: rgba(0, 0, 0, 0.8);
|
|
689
|
+
--wui-color-gray-glass-090: rgba(0, 0, 0, 0.9);
|
|
690
|
+
|
|
691
|
+
--wui-color-dark-glass-100: rgba(233, 233, 233, 1);
|
|
692
|
+
|
|
693
|
+
--w3m-card-embedded-shadow-color: rgb(224 225 233 / 25%);
|
|
694
|
+
}
|
|
695
|
+
`}}const d=i.AH`
|
|
696
|
+
*,
|
|
697
|
+
*::after,
|
|
698
|
+
*::before,
|
|
699
|
+
:host {
|
|
700
|
+
margin: 0;
|
|
701
|
+
padding: 0;
|
|
702
|
+
box-sizing: border-box;
|
|
703
|
+
font-style: normal;
|
|
704
|
+
text-rendering: optimizeSpeed;
|
|
705
|
+
-webkit-font-smoothing: antialiased;
|
|
706
|
+
-moz-osx-font-smoothing: grayscale;
|
|
707
|
+
-webkit-tap-highlight-color: transparent;
|
|
708
|
+
font-family: var(--wui-font-family);
|
|
709
|
+
backface-visibility: hidden;
|
|
710
|
+
}
|
|
711
|
+
`,u=i.AH`
|
|
712
|
+
button,
|
|
713
|
+
a {
|
|
714
|
+
cursor: pointer;
|
|
715
|
+
display: flex;
|
|
716
|
+
justify-content: center;
|
|
717
|
+
align-items: center;
|
|
718
|
+
position: relative;
|
|
719
|
+
transition:
|
|
720
|
+
color var(--wui-duration-lg) var(--wui-ease-out-power-1),
|
|
721
|
+
background-color var(--wui-duration-lg) var(--wui-ease-out-power-1),
|
|
722
|
+
border var(--wui-duration-lg) var(--wui-ease-out-power-1),
|
|
723
|
+
border-radius var(--wui-duration-lg) var(--wui-ease-out-power-1),
|
|
724
|
+
box-shadow var(--wui-duration-lg) var(--wui-ease-out-power-1);
|
|
725
|
+
will-change: background-color, color, border, box-shadow, border-radius;
|
|
726
|
+
outline: none;
|
|
727
|
+
border: none;
|
|
728
|
+
column-gap: var(--wui-spacing-3xs);
|
|
729
|
+
background-color: transparent;
|
|
730
|
+
text-decoration: none;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
wui-flex {
|
|
734
|
+
transition: border-radius var(--wui-duration-lg) var(--wui-ease-out-power-1);
|
|
735
|
+
will-change: border-radius;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
button:disabled > wui-wallet-image,
|
|
739
|
+
button:disabled > wui-all-wallets-image,
|
|
740
|
+
button:disabled > wui-network-image,
|
|
741
|
+
button:disabled > wui-image,
|
|
742
|
+
button:disabled > wui-transaction-visual,
|
|
743
|
+
button:disabled > wui-logo {
|
|
744
|
+
filter: grayscale(1);
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
@media (hover: hover) and (pointer: fine) {
|
|
748
|
+
button:hover:enabled {
|
|
749
|
+
background-color: var(--wui-color-gray-glass-005);
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
button:active:enabled {
|
|
753
|
+
background-color: var(--wui-color-gray-glass-010);
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
button:disabled > wui-icon-box {
|
|
758
|
+
opacity: 0.5;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
input {
|
|
762
|
+
border: none;
|
|
763
|
+
outline: none;
|
|
764
|
+
appearance: none;
|
|
765
|
+
}
|
|
766
|
+
`,g=i.AH`
|
|
767
|
+
.wui-color-inherit {
|
|
768
|
+
color: var(--wui-color-inherit);
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
.wui-color-accent-100 {
|
|
772
|
+
color: var(--wui-color-accent-100);
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
.wui-color-error-100 {
|
|
776
|
+
color: var(--wui-color-error-100);
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
.wui-color-blue-100 {
|
|
780
|
+
color: var(--wui-color-blue-100);
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
.wui-color-blue-90 {
|
|
784
|
+
color: var(--wui-color-blue-90);
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
.wui-color-error-125 {
|
|
788
|
+
color: var(--wui-color-error-125);
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
.wui-color-success-100 {
|
|
792
|
+
color: var(--wui-color-success-100);
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
.wui-color-success-125 {
|
|
796
|
+
color: var(--wui-color-success-125);
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
.wui-color-inverse-100 {
|
|
800
|
+
color: var(--wui-color-inverse-100);
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
.wui-color-inverse-000 {
|
|
804
|
+
color: var(--wui-color-inverse-000);
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
.wui-color-fg-100 {
|
|
808
|
+
color: var(--wui-color-fg-100);
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
.wui-color-fg-200 {
|
|
812
|
+
color: var(--wui-color-fg-200);
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
.wui-color-fg-300 {
|
|
816
|
+
color: var(--wui-color-fg-300);
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
.wui-color-fg-325 {
|
|
820
|
+
color: var(--wui-color-fg-325);
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
.wui-color-fg-350 {
|
|
824
|
+
color: var(--wui-color-fg-350);
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
.wui-bg-color-inherit {
|
|
828
|
+
background-color: var(--wui-color-inherit);
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
.wui-bg-color-blue-100 {
|
|
832
|
+
background-color: var(--wui-color-accent-100);
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
.wui-bg-color-error-100 {
|
|
836
|
+
background-color: var(--wui-color-error-100);
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
.wui-bg-color-error-125 {
|
|
840
|
+
background-color: var(--wui-color-error-125);
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
.wui-bg-color-success-100 {
|
|
844
|
+
background-color: var(--wui-color-success-100);
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
.wui-bg-color-success-125 {
|
|
848
|
+
background-color: var(--wui-color-success-100);
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
.wui-bg-color-inverse-100 {
|
|
852
|
+
background-color: var(--wui-color-inverse-100);
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
.wui-bg-color-inverse-000 {
|
|
856
|
+
background-color: var(--wui-color-inverse-000);
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
.wui-bg-color-fg-100 {
|
|
860
|
+
background-color: var(--wui-color-fg-100);
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
.wui-bg-color-fg-200 {
|
|
864
|
+
background-color: var(--wui-color-fg-200);
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
.wui-bg-color-fg-300 {
|
|
868
|
+
background-color: var(--wui-color-fg-300);
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
.wui-color-fg-325 {
|
|
872
|
+
background-color: var(--wui-color-fg-325);
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
.wui-color-fg-350 {
|
|
876
|
+
background-color: var(--wui-color-fg-350);
|
|
877
|
+
}
|
|
878
|
+
`},24313:(e,t,s)=>{s.d(t,{g:()=>u});var i=s(95191),r=s(99013),n=s(89058),o=s(50731),a=s(40868),c=s(16158),h=s(5813),l=s(11553),p=s(28127),d=s(38753);const u={getConnectorsByType(e,t,s){const{customWallets:i}=c.H.state,r=l.i.getRecentWallets(),n=d.A.filterOutDuplicateWallets(t),o=d.A.filterOutDuplicateWallets(s),a=e.filter(e=>"MULTI_CHAIN"===e.type),h=e.filter(e=>"ANNOUNCED"===e.type),p=e.filter(e=>"INJECTED"===e.type);return{custom:i,recent:r,external:e.filter(e=>"EXTERNAL"===e.type),multiChain:a,announced:h,injected:p,recommended:n,featured:o}},showConnector(e){const t=e.info?.rdns,s=Boolean(t)&&a.N.state.excludedWallets.some(e=>e.rdns===t),i=Boolean(e.name)&&a.N.state.excludedWallets.some(t=>p.y.isLowerCaseMatch(t.name,e.name));if("INJECTED"===e.type){if(!h.w.isMobile()&&"Browser Wallet"===e.name)return!1;if(!t&&!n.x.checkInstalled())return!1;if(s||i)return!1}return"ANNOUNCED"!==e.type||!s&&!i},getIsConnectedWithWC:()=>Array.from(r.W.state.chains.values()).some(e=>o.a.getConnectorId(e.namespace)===i.o.CONNECTOR_ID.WALLET_CONNECT),getConnectorTypeOrder({recommended:e,featured:t,custom:s,recent:i,announced:r,injected:n,multiChain:o,external:a,overriddenConnectors:h=c.H.state.features?.connectorTypeOrder??[]}){const l=u.getIsConnectedWithWC(),p=[{type:"walletConnect",isEnabled:c.H.state.enableWalletConnect&&!l},{type:"recent",isEnabled:i.length>0},{type:"injected",isEnabled:[...n,...r,...o].length>0},{type:"featured",isEnabled:t.length>0},{type:"custom",isEnabled:s&&s.length>0},{type:"external",isEnabled:a.length>0},{type:"recommended",isEnabled:e.length>0}].filter(e=>e.isEnabled),d=new Set(p.map(e=>e.type)),g=h.filter(e=>d.has(e)).map(e=>({type:e,isEnabled:!0})),f=p.filter(({type:e})=>!g.some(({type:t})=>t===e));return Array.from(new Set([...g,...f].map(({type:e})=>e)))}}},24529:(e,t,s)=>{s.d(t,{E:()=>i});const i={ERROR_CODE_UNRECOGNIZED_CHAIN_ID:4902,ERROR_CODE_DEFAULT:5e3,ERROR_INVALID_CHAIN_ID:32603}},24537:(e,t,s)=>{s.d(t,{U:()=>f}),s(99057);var i=s(95191),r=s(9663),n=s(16279),o=s(99013),a=s(89058),c=s(50731),h=s(14479),l=s(67018),p=s(16158),d=s(42831),u=s(41430),g=s(5813);const f={getSIWX:()=>p.H.state.siwx,async initializeIfEnabled(){const e=p.H.state.siwx,t=o.W.getActiveCaipAddress();if(!e||!t)return;const[s,i,r]=t.split(":");if(o.W.checkIfSupportedNetwork(s))try{if((await e.getSessions(`${s}:${i}`,r)).length)return;await l.W.open({view:"SIWXSignMessage"})}catch(e){console.error("SIWXUtil:initializeIfEnabled",e),h.E.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:this.getSIWXEventProperties()}),await(a.x._getClient()?.disconnect().catch(console.error)),d.I.reset("Connect"),u.P.showError("A problem occurred while trying initialize authentication")}},async requestSignMessage(){const e=p.H.state.siwx,t=g.w.getPlainAddress(o.W.getActiveCaipAddress()),s=o.W.getActiveCaipNetwork(),r=a.x._getClient();if(!e)throw new Error("SIWX is not enabled");if(!t)throw new Error("No ActiveCaipAddress found");if(!s)throw new Error("No ActiveCaipNetwork or client found");if(!r)throw new Error("No ConnectionController client found");try{const n=await e.createMessage({chainId:s.caipNetworkId,accountAddress:t}),o=n.toString();c.a.getConnectorId(s.chainNamespace)===i.o.CONNECTOR_ID.AUTH&&d.I.pushTransactionStack({view:null,goBack:!1,replace:!0});const a=await r.signMessage(o);await e.addSession({data:n,message:o,signature:a}),l.W.close(),h.E.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:this.getSIWXEventProperties()})}catch(e){const t=this.getSIWXEventProperties();l.W.state.open&&"ApproveTransaction"!==d.I.state.view||await l.W.open({view:"SIWXSignMessage"}),t.isSmartAccount?u.P.showError("This application might not support Smart Accounts"):u.P.showError("Signature declined"),h.E.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:t}),console.error("SWIXUtil:requestSignMessage",e)}},async cancelSignMessage(){try{const e=this.getSIWX(),t=e?.getRequired?.();t?await a.x.disconnect():l.W.close(),d.I.reset("Connect"),h.E.sendEvent({event:"CLICK_CANCEL_SIWX",type:"track",properties:this.getSIWXEventProperties()})}catch(e){console.error("SIWXUtil:cancelSignMessage",e)}},async getSessions(){const e=p.H.state.siwx,t=g.w.getPlainAddress(o.W.getActiveCaipAddress()),s=o.W.getActiveCaipNetwork();return e&&t&&s?e.getSessions(s.caipNetworkId,t):[]},async isSIWXCloseDisabled(){const e=this.getSIWX();if(e){const t="ApproveTransaction"===d.I.state.view,s="SIWXSignMessage"===d.I.state.view;if(t||s)return e.getRequired?.()&&0===(await this.getSessions()).length}return!1},async universalProviderAuthenticate({universalProvider:e,chains:t,methods:s}){const i=f.getSIWX(),r=new Set(t.map(e=>e.split(":")[0]));if(!i||1!==r.size||!r.has("eip155"))return!1;const a=await i.createMessage({chainId:o.W.getActiveCaipNetwork()?.caipNetworkId||"",accountAddress:""}),c=await e.authenticate({nonce:a.nonce,domain:a.domain,uri:a.uri,exp:a.expirationTime,iat:a.issuedAt,nbf:a.notBefore,requestId:a.requestId,version:a.version,resources:a.resources,statement:a.statement,chainId:a.chainId,methods:s,chains:[a.chainId,...t.filter(e=>e!==a.chainId)]});if(u.P.showLoading("Authenticating...",{autoClose:!1}),n.U.setConnectedWalletInfo({...c.session.peer.metadata,name:c.session.peer.metadata.name,icon:c.session.peer.metadata.icons?.[0],type:"WALLET_CONNECT"},Array.from(r)[0]),c?.auths?.length){const t=c.auths.map(t=>{const s=e.client.formatAuthMessage({request:t.p,iss:t.p.iss});return{data:{...t.p,accountAddress:t.p.iss.split(":").slice(-1).join(""),chainId:t.p.iss.split(":").slice(2,4).join(":"),uri:t.p.aud,version:t.p.version||a.version,expirationTime:t.p.exp,issuedAt:t.p.iat,notBefore:t.p.nbf},message:s,signature:t.s.s,cacao:t}});try{await i.setSessions(t),h.E.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:f.getSIWXEventProperties()})}catch(t){throw console.error("SIWX:universalProviderAuth - failed to set sessions",t),h.E.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:f.getSIWXEventProperties()}),await e.disconnect().catch(console.error),t}finally{u.P.hide()}}return!0},getSIWXEventProperties:()=>({network:o.W.state.activeCaipNetwork?.caipNetworkId||"",isSmartAccount:n.U.state.preferredAccountType===r.Vl.ACCOUNT_TYPES.SMART_ACCOUNT}),async clearSessions(){const e=this.getSIWX();e&&await e.setSessions([])}}},25422:(e,t,s)=>{s.d(t,{z:()=>n});var i=s(89168);const r=(0,i.BX)({loading:!1,open:!1,selectedNetworkId:void 0,activeChain:void 0,initialized:!1}),n={state:r,subscribe:e=>(0,i.B1)(r,()=>e(r)),set(e){Object.assign(r,{...r,...e})}}},26097:(e,t,s)=>{s.d(t,{W:()=>n});var i=s(95191),r=s(99013);const n={handleSolanaDeeplinkRedirect(e){if(r.W.state.activeChain===i.o.CHAIN.SOLANA){const t=window.location.href,s=encodeURIComponent(t);if("Phantom"===e&&!("phantom"in window)){const e=t.startsWith("https")?"https":"http",i=t.split("/")[2],r=encodeURIComponent(`${e}://${i}`);window.location.href=`https://phantom.app/ul/browse/${s}?ref=${r}`}"Coinbase Wallet"!==e||"coinbaseSolana"in window||(window.location.href=`https://go.cb-w.com/dapp?cb_url=${s}`)}}}},26545:(e,t,s)=>{s.d(t,{W:()=>a});var i=s(89168),r=s(11807),n=s(50731);const o=(0,i.BX)({themeMode:"dark",themeVariables:{},w3mThemeVariables:void 0}),a={state:o,subscribe:e=>(0,i.B1)(o,()=>e(o)),setThemeMode(e){o.themeMode=e;try{const t=n.a.getAuthConnector();if(t){const s=a.getSnapshot().themeVariables;t.provider.syncTheme({themeMode:e,themeVariables:s,w3mThemeVariables:(0,r.o)(s,e)})}}catch{console.info("Unable to sync theme to auth connector")}},setThemeVariables(e){o.themeVariables={...o.themeVariables,...e};try{const e=n.a.getAuthConnector();if(e){const t=a.getSnapshot().themeVariables;e.provider.syncTheme({themeVariables:t,w3mThemeVariables:(0,r.o)(o.themeVariables,o.themeMode)})}}catch{console.info("Unable to sync theme to auth connector")}},getSnapshot:()=>(0,i.P9)(o)}},27006:(e,t,s)=>{s.d(t,{T:()=>f});var i=s(89168),r=s(84253),n=s(5813),o=s(19760),a=s(11553),c=s(16279),h=s(99013),l=s(16158),p=s(41430);const d={purchaseCurrencies:[{id:"2b92315d-eab7-5bef-84fa-089a131333f5",name:"USD Coin",symbol:"USDC",networks:[{name:"ethereum-mainnet",display_name:"Ethereum",chain_id:"1",contract_address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{name:"polygon-mainnet",display_name:"Polygon",chain_id:"137",contract_address:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"}]},{id:"2b92315d-eab7-5bef-84fa-089a131333f5",name:"Ether",symbol:"ETH",networks:[{name:"ethereum-mainnet",display_name:"Ethereum",chain_id:"1",contract_address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{name:"polygon-mainnet",display_name:"Polygon",chain_id:"137",contract_address:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"}]}],paymentCurrencies:[{id:"USD",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]},{id:"EUR",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]}]},u=n.w.getBlockchainApiUrl(),g=(0,i.BX)({clientId:null,api:new o.Z({baseUrl:u,clientId:null}),supportedChains:{http:[],ws:[]}}),f={state:g,async get(e){const{st:t,sv:s}=f.getSdkProperties(),i=l.H.state.projectId,r={...e.params||{},st:t,sv:s,projectId:i};return g.api.get({...e,params:r})},getSdkProperties(){const{sdkType:e,sdkVersion:t}=l.H.state;return{st:e||"unknown",sv:t||"unknown"}},async isNetworkSupported(e){if(!e)return!1;try{g.supportedChains.http.length||await f.getSupportedNetworks()}catch(e){return!1}return g.supportedChains.http.includes(e)},async getSupportedNetworks(){const e=await f.get({path:"v1/supported-chains"});return g.supportedChains=e,e},async fetchIdentity({address:e,caipNetworkId:t}){if(!await f.isNetworkSupported(t))return{avatar:"",name:""};const s=a.i.getIdentityFromCacheForAddress(e);if(s)return s;const i=await f.get({path:`/v1/identity/${e}`,params:{sender:h.W.state.activeCaipAddress?n.w.getPlainAddress(h.W.state.activeCaipAddress):void 0}});return a.i.updateIdentityCache({address:e,identity:i,timestamp:Date.now()}),i},fetchTransactions:async({account:e,cursor:t,onramp:s,signal:i,cache:r,chainId:n})=>await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?f.get({path:`/v1/account/${e}/history`,params:{cursor:t,onramp:s,chainId:n},signal:i,cache:r}):{data:[],next:void 0},fetchSwapQuote:async({amount:e,userAddress:t,from:s,to:i,gasPrice:r})=>await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?f.get({path:"/v1/convert/quotes",headers:{"Content-Type":"application/json"},params:{amount:e,userAddress:t,from:s,to:i,gasPrice:r}}):{quotes:[]},fetchSwapTokens:async({chainId:e})=>await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?f.get({path:"/v1/convert/tokens",params:{chainId:e}}):{tokens:[]},fetchTokenPrice:async({addresses:e})=>await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?g.api.post({path:"/v1/fungible/price",body:{currency:"usd",addresses:e,projectId:l.H.state.projectId},headers:{"Content-Type":"application/json"}}):{fungibles:[]},fetchSwapAllowance:async({tokenAddress:e,userAddress:t})=>await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?f.get({path:"/v1/convert/allowance",params:{tokenAddress:e,userAddress:t},headers:{"Content-Type":"application/json"}}):{allowance:"0"},async fetchGasPrice({chainId:e}){const{st:t,sv:s}=f.getSdkProperties();if(!await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId))throw new Error("Network not supported for Gas Price");return f.get({path:"/v1/convert/gas-price",headers:{"Content-Type":"application/json"},params:{chainId:e,st:t,sv:s}})},async generateSwapCalldata({amount:e,from:t,to:s,userAddress:i,disableEstimate:n}){if(!await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId))throw new Error("Network not supported for Swaps");return g.api.post({path:"/v1/convert/build-transaction",headers:{"Content-Type":"application/json"},body:{amount:e,eip155:{slippage:r.oU.CONVERT_SLIPPAGE_TOLERANCE},projectId:l.H.state.projectId,from:t,to:s,userAddress:i,disableEstimate:n}})},async generateApproveCalldata({from:e,to:t,userAddress:s}){const{st:i,sv:r}=f.getSdkProperties();if(!await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId))throw new Error("Network not supported for Swaps");return f.get({path:"/v1/convert/build-approve",headers:{"Content-Type":"application/json"},params:{userAddress:s,from:e,to:t,st:i,sv:r}})},async getBalance(e,t,s){const{st:i,sv:r}=f.getSdkProperties();if(!await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId))return p.P.showError("Token Balance Unavailable"),{balances:[]};const n=`${t}:${e}`,o=a.i.getBalanceCacheForCaipAddress(n);if(o)return o;const c=await f.get({path:`/v1/account/${e}/balance`,params:{currency:"usd",chainId:t,forceUpdate:s,st:i,sv:r}});return a.i.updateBalanceCache({caipAddress:n,balance:c,timestamp:Date.now()}),c},lookupEnsName:async e=>await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?f.get({path:`/v1/profile/account/${e}`,params:{apiVersion:"2"}}):{addresses:{},attributes:[]},reverseLookupEnsName:async({address:e})=>await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?f.get({path:`/v1/profile/reverse/${e}`,params:{sender:c.U.state.address,apiVersion:"2"}}):[],getEnsNameSuggestions:async e=>await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?f.get({path:`/v1/profile/suggestions/${e}`,params:{zone:"reown.id"}}):{suggestions:[]},registerEnsName:async({coinType:e,address:t,message:s,signature:i})=>await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?g.api.post({path:"/v1/profile/account",body:{coin_type:e,address:t,message:s,signature:i},headers:{"Content-Type":"application/json"}}):{success:!1},generateOnRampURL:async({destinationWallets:e,partnerUserId:t,defaultNetwork:s,purchaseAmount:i,paymentAmount:r})=>await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?(await g.api.post({path:"/v1/generators/onrampurl",params:{projectId:l.H.state.projectId},body:{destinationWallets:e,defaultNetwork:s,partnerUserId:t,defaultExperience:"buy",presetCryptoAmount:i,presetFiatAmount:r}})).url:"",async getOnrampOptions(){if(!await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId))return{paymentCurrencies:[],purchaseCurrencies:[]};try{return await f.get({path:"/v1/onramp/options"})}catch(e){return d}},async getOnrampQuote({purchaseCurrency:e,paymentCurrency:t,amount:s,network:i}){try{return await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?await g.api.post({path:"/v1/onramp/quote",params:{projectId:l.H.state.projectId},body:{purchaseCurrency:e,paymentCurrency:t,amount:s,network:i}}):null}catch(e){return{coinbaseFee:{amount:s,currency:t.id},networkFee:{amount:s,currency:t.id},paymentSubtotal:{amount:s,currency:t.id},paymentTotal:{amount:s,currency:t.id},purchaseAmount:{amount:s,currency:t.id},quoteId:"mocked-quote-id"}}},getSmartSessions:async e=>await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?f.get({path:`/v1/sessions/${e}`}):[],revokeSmartSession:async(e,t,s)=>await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?g.api.post({path:`/v1/sessions/${e}/revoke`,params:{projectId:l.H.state.projectId},body:{pci:t,signature:s}}):{success:!1},setClientId(e){g.clientId=e,g.api=new o.Z({baseUrl:u,clientId:e})}}},27305:(e,t,s)=>{function i(e){return function(t){return"function"==typeof t?function(e,t){return customElements.get(e)||customElements.define(e,t),t}(e,t):function(e,t){const{kind:s,elements:i}=t;return{kind:s,elements:i,finisher(t){customElements.get(e)||customElements.define(e,t)}}}(e,t)}}s.d(t,{E:()=>i})},27938:(e,t,s)=>{s.d(t,{h:()=>a});var i=s(89168),r=s(39150),n=s(16158);const o=(0,i.BX)({message:"",variant:"info",open:!1}),a={state:o,subscribeKey:(e,t)=>(0,r.u$)(o,e,t),open(e,t){const{debug:s}=n.H.state,{shortMessage:i,longMessage:r}=e;s&&(o.message=i,o.variant=t,o.open=!0),r&&console.error("function"==typeof r?r():r)},close(){o.open=!1,o.message="",o.variant="info"}}},28127:(e,t,s)=>{s.d(t,{y:()=>r});var i=s(98207);const r={getCaipTokens(e){if(!e)return;const t={};return Object.entries(e).forEach(([e,s])=>{t[`${i.o.EIP155}:${e}`]=s}),t},isLowerCaseMatch:(e,t)=>e?.toLowerCase()===t?.toLowerCase()}},29864:(e,t,s)=>{s.d(t,{f:()=>g});var i=s(89168),r=s(39150),n=s(78760),o=s(11553),a=s(16279),c=s(27006),h=s(99013),l=s(89058),p=s(50731),d=s(42831);const u=(0,i.BX)({suggestions:[],loading:!1}),g={state:u,subscribe:e=>(0,i.B1)(u,()=>e(u)),subscribeKey:(e,t)=>(0,r.u$)(u,e,t),async resolveName(e){try{return await c.T.lookupEnsName(e)}catch(e){const t=e;throw new Error(t?.reasons?.[0]?.description||"Error resolving name")}},async isNameRegistered(e){try{return await c.T.lookupEnsName(e),!0}catch{return!1}},async getSuggestions(e){try{u.loading=!0,u.suggestions=[];const t=await c.T.getEnsNameSuggestions(e);return u.suggestions=t.suggestions.map(e=>({...e,name:e.name}))||[],u.suggestions}catch(e){const t=this.parseEnsApiError(e,"Error fetching name suggestions");throw new Error(t)}finally{u.loading=!1}},async getNamesForAddress(e){try{if(!h.W.state.activeCaipNetwork)return[];const t=o.i.getEnsFromCacheForAddress(e);if(t)return t;const s=await c.T.reverseLookupEnsName({address:e});return o.i.updateEnsCache({address:e,ens:s,timestamp:Date.now()}),s}catch(e){const t=this.parseEnsApiError(e,"Error fetching names for address");throw new Error(t)}},async registerName(e){const t=h.W.state.activeCaipNetwork;if(!t)throw new Error("Network not found");const s=a.U.state.address,i=p.a.getAuthConnector();if(!s||!i)throw new Error("Address or auth connector not found");u.loading=!0;try{const i=JSON.stringify({name:e,attributes:{},timestamp:Math.floor(Date.now()/1e3)});d.I.pushTransactionStack({view:"RegisterAccountNameSuccess",goBack:!1,replace:!0,onCancel(){u.loading=!1}});const r=await l.x.signMessage(i),o=t.id;if(!o)throw new Error("Network not found");const h=n.p.convertEVMChainIdToCoinType(Number(o));await c.T.registerEnsName({coinType:h,address:s,signature:r,message:i}),a.U.setProfileName(e,t.chainNamespace),d.I.replace("RegisterAccountNameSuccess")}catch(t){const s=this.parseEnsApiError(t,`Error registering name ${e}`);throw d.I.replace("RegisterAccountName"),new Error(s)}finally{u.loading=!1}},validateName:e=>/^[a-zA-Z0-9-]{4,}$/u.test(e),parseEnsApiError(e,t){const s=e;return s?.reasons?.[0]?.description||t}}},30544:(e,t,s)=>{s.d(t,{Rn0:()=>i.Rn0,gTy:()=>i.gTy,tWt:()=>i.tWt});var i=s(55164)},31575:(e,t,s)=>{s.d(t,{Ay:()=>K});var i=s(11629),r=s(70255),n=s(3665),o=s(91315),a=s(76754),c=s(50046),h=s.n(c),l=s(14350);const p="client",d=`wc@2:${p}:`,u=p,g="WALLETCONNECT_DEEPLINK_CHOICE",f="Proposal expired",m=o.SEVEN_DAYS,w={wc_sessionPropose:{req:{ttl:o.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1104},res:{ttl:o.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1106},res:{ttl:o.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:o.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:o.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1112},res:{ttl:o.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1114},res:{ttl:o.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:o.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:o.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1119}}},y={min:o.FIVE_MINUTES,max:o.SEVEN_DAYS},b="IDLE",v="ACTIVE",E={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"}},I=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],_="wc@1.5:auth:",N=`${_}:PUB_KEY`;var A=Object.defineProperty,C=Object.defineProperties,P=Object.getOwnPropertyDescriptors,S=Object.getOwnPropertySymbols,O=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable,k=(e,t,s)=>t in e?A(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,x=(e,t)=>{for(var s in t||(t={}))O.call(t,s)&&k(e,s,t[s]);if(S)for(var s of S(t))T.call(t,s)&&k(e,s,t[s]);return e},R=(e,t)=>C(e,P(t)),U=(e,t,s)=>k(e,"symbol"!=typeof t?t+"":t,s);class D extends n.yJ{constructor(e){super(e),U(this,"name","engine"),U(this,"events",new(h())),U(this,"initialized",!1),U(this,"requestQueue",{state:b,queue:[]}),U(this,"sessionRequestQueue",{state:b,queue:[]}),U(this,"requestQueueDelay",o.ONE_SECOND),U(this,"expectedPairingMethodMap",new Map),U(this,"recentlyDeletedMap",new Map),U(this,"recentlyDeletedLimit",200),U(this,"relayMessageCache",[]),U(this,"pendingSessions",new Map),U(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(w)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},(0,o.toMiliseconds)(this.requestQueueDelay)))}),U(this,"connect",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const t=R(x({},e),{requiredNamespaces:e.requiredNamespaces||{},optionalNamespaces:e.optionalNamespaces||{}});await this.isValidConnect(t);const{pairingTopic:s,requiredNamespaces:r,optionalNamespaces:n,sessionProperties:c,relays:h}=t;let p,d=s,u=!1;try{if(d){const e=this.client.core.pairing.pairings.get(d);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),u=e.active}}catch(e){throw this.client.logger.error(`connect() -> pairing.get(${d}) failed`),e}if(!d||!u){const{topic:e,uri:t}=await this.client.core.pairing.create();d=e,p=t}if(!d){const{message:e}=(0,a.GuA)("NO_MATCHING_KEY",`connect() pairing topic: ${d}`);throw new Error(e)}const g=await this.client.core.crypto.generateKeyPair(),m=w.wc_sessionPropose.req.ttl||o.FIVE_MINUTES,y=(0,a.Xw0)(m),b=R(x({requiredNamespaces:r,optionalNamespaces:n,relays:h??[{protocol:i.sD}],proposer:{publicKey:g,metadata:this.client.metadata},expiryTimestamp:y,pairingTopic:d},c&&{sessionProperties:c}),{id:(0,l.payloadId)()}),v=(0,a.hEn)("session_connect",b.id),{reject:E,resolve:I,done:_}=(0,a.Wx8)(m,f),N=({id:e})=>{e===b.id&&(this.client.events.off("proposal_expire",N),this.pendingSessions.delete(b.id),this.events.emit(v,{error:{message:f,code:0}}))};return this.client.events.on("proposal_expire",N),this.events.once(v,({error:e,session:t})=>{this.client.events.off("proposal_expire",N),e?E(e):t&&I(t)}),await this.sendRequest({topic:d,method:"wc_sessionPropose",params:b,throwOnFailedPublish:!0,clientRpcId:b.id}),await this.setProposal(b.id,b),{uri:p,approval:_}}),U(this,"pair",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(e)}catch(e){throw this.client.logger.error("pair() failed"),e}}),U(this,"approve",async e=>{var t,s,r;const n=this.client.core.eventClient.createEvent({properties:{topic:null==(t=e?.id)?void 0:t.toString(),trace:[i.$I.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(e){throw n.setError(i.U.no_internet_connection),e}try{await this.isValidProposalId(e?.id)}catch(t){throw this.client.logger.error(`approve() -> proposal.get(${e?.id}) failed`),n.setError(i.U.proposal_not_found),t}try{await this.isValidApprove(e)}catch(e){throw this.client.logger.error("approve() -> isValidApprove() failed"),n.setError(i.U.session_approve_namespace_validation_failure),e}const{id:o,relayProtocol:c,namespaces:h,sessionProperties:l,sessionConfig:p}=e,d=this.client.proposal.get(o);this.client.core.eventClient.deleteEvent({eventId:n.eventId});const{pairingTopic:u,proposer:g,requiredNamespaces:f,optionalNamespaces:w}=d;let y=null==(s=this.client.core.eventClient)?void 0:s.getEvent({topic:u});y||(y=null==(r=this.client.core.eventClient)?void 0:r.createEvent({type:i.$I.session_approve_started,properties:{topic:u,trace:[i.$I.session_approve_started,i.$I.session_namespaces_validation_success]}}));const b=await this.client.core.crypto.generateKeyPair(),v=g.publicKey,E=await this.client.core.crypto.generateSharedKey(b,v),I=x(x({relay:{protocol:c??"irn"},namespaces:h,controller:{publicKey:b,metadata:this.client.metadata},expiry:(0,a.Xw0)(m)},l&&{sessionProperties:l}),p&&{sessionConfig:p}),_=i.cV.relay;y.addTrace(i.$I.subscribing_session_topic);try{await this.client.core.relayer.subscribe(E,{transportType:_})}catch(e){throw y.setError(i.U.subscribe_session_topic_failure),e}y.addTrace(i.$I.subscribe_session_topic_success);const N=R(x({},I),{topic:E,requiredNamespaces:f,optionalNamespaces:w,pairingTopic:u,acknowledged:!1,self:I.controller,peer:{publicKey:g.publicKey,metadata:g.metadata},controller:b,transportType:i.cV.relay});await this.client.session.set(E,N),y.addTrace(i.$I.store_session);try{y.addTrace(i.$I.publishing_session_settle),await this.sendRequest({topic:E,method:"wc_sessionSettle",params:I,throwOnFailedPublish:!0}).catch(e=>{throw y?.setError(i.U.session_settle_publish_failure),e}),y.addTrace(i.$I.session_settle_publish_success),y.addTrace(i.$I.publishing_session_approve),await this.sendResult({id:o,topic:u,result:{relay:{protocol:c??"irn"},responderPublicKey:b},throwOnFailedPublish:!0}).catch(e=>{throw y?.setError(i.U.session_approve_publish_failure),e}),y.addTrace(i.$I.session_approve_publish_success)}catch(e){throw this.client.logger.error(e),this.client.session.delete(E,(0,a.Hjj)("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(E),e}return this.client.core.eventClient.deleteEvent({eventId:y.eventId}),await this.client.core.pairing.updateMetadata({topic:u,metadata:g.metadata}),await this.client.proposal.delete(o,(0,a.Hjj)("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:u}),await this.setExpiry(E,(0,a.Xw0)(m)),{topic:E,acknowledged:()=>Promise.resolve(this.client.session.get(E))}}),U(this,"reject",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(e)}catch(e){throw this.client.logger.error("reject() -> isValidReject() failed"),e}const{id:t,reason:s}=e;let i;try{i=this.client.proposal.get(t).pairingTopic}catch(e){throw this.client.logger.error(`reject() -> proposal.get(${t}) failed`),e}i&&(await this.sendError({id:t,topic:i,error:s,rpcOpts:w.wc_sessionPropose.reject}),await this.client.proposal.delete(t,(0,a.Hjj)("USER_DISCONNECTED")))}),U(this,"update",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(e)}catch(e){throw this.client.logger.error("update() -> isValidUpdate() failed"),e}const{topic:t,namespaces:s}=e,{done:i,resolve:r,reject:n}=(0,a.Wx8)(),o=(0,l.payloadId)(),c=(0,l.getBigIntRpcId)().toString(),h=this.client.session.get(t).namespaces;return this.events.once((0,a.hEn)("session_update",o),({error:e})=>{e?n(e):r()}),await this.client.session.update(t,{namespaces:s}),await this.sendRequest({topic:t,method:"wc_sessionUpdate",params:{namespaces:s},throwOnFailedPublish:!0,clientRpcId:o,relayRpcId:c}).catch(e=>{this.client.logger.error(e),this.client.session.update(t,{namespaces:h}),n(e)}),{acknowledged:i}}),U(this,"extend",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(e)}catch(e){throw this.client.logger.error("extend() -> isValidExtend() failed"),e}const{topic:t}=e,s=(0,l.payloadId)(),{done:i,resolve:r,reject:n}=(0,a.Wx8)();return this.events.once((0,a.hEn)("session_extend",s),({error:e})=>{e?n(e):r()}),await this.setExpiry(t,(0,a.Xw0)(m)),this.sendRequest({topic:t,method:"wc_sessionExtend",params:{},clientRpcId:s,throwOnFailedPublish:!0}).catch(e=>{n(e)}),{acknowledged:i}}),U(this,"request",async e=>{this.isInitialized();try{await this.isValidRequest(e)}catch(e){throw this.client.logger.error("request() -> isValidRequest() failed"),e}const{chainId:t,request:s,topic:r,expiry:n=w.wc_sessionRequest.req.ttl}=e,o=this.client.session.get(r);o?.transportType===i.cV.relay&&await this.confirmOnlineStateOrThrow();const c=(0,l.payloadId)(),h=(0,l.getBigIntRpcId)().toString(),{done:p,resolve:d,reject:u}=(0,a.Wx8)(n,"Request expired. Please try again.");this.events.once((0,a.hEn)("session_request",c),({error:e,result:t})=>{e?u(e):d(t)});const f="wc_sessionRequest",m=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);if(m)return await this.sendRequest({clientRpcId:c,relayRpcId:h,topic:r,method:f,params:{request:R(x({},s),{expiryTimestamp:(0,a.Xw0)(n)}),chainId:t},expiry:n,throwOnFailedPublish:!0,appLink:m}).catch(e=>u(e)),this.client.events.emit("session_request_sent",{topic:r,request:s,chainId:t,id:c}),await p();const y={request:R(x({},s),{expiryTimestamp:(0,a.Xw0)(n)}),chainId:t},b=this.shouldSetTVF(f,y);return await Promise.all([new Promise(async e=>{await this.sendRequest(x({clientRpcId:c,relayRpcId:h,topic:r,method:f,params:y,expiry:n,throwOnFailedPublish:!0},b&&{tvf:this.getTVFParams(c,y)})).catch(e=>u(e)),this.client.events.emit("session_request_sent",{topic:r,request:s,chainId:t,id:c}),e()}),new Promise(async e=>{var t;if(null==(t=o.sessionConfig)||!t.disableDeepLink){const e=await(0,a.jTh)(this.client.core.storage,g);await(0,a.n3s)({id:c,topic:r,wcDeepLink:e})}e()}),p()]).then(e=>e[2])}),U(this,"respond",async e=>{this.isInitialized(),await this.isValidRespond(e);const{topic:t,response:s}=e,{id:r}=s,n=this.client.session.get(t);n.transportType===i.cV.relay&&await this.confirmOnlineStateOrThrow();const o=this.getAppLinkIfEnabled(n.peer.metadata,n.transportType);(0,l.isJsonRpcResult)(s)?await this.sendResult({id:r,topic:t,result:s.result,throwOnFailedPublish:!0,appLink:o}):(0,l.isJsonRpcError)(s)&&await this.sendError({id:r,topic:t,error:s.error,appLink:o}),this.cleanupAfterResponse(e)}),U(this,"ping",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(e)}catch(e){throw this.client.logger.error("ping() -> isValidPing() failed"),e}const{topic:t}=e;if(this.client.session.keys.includes(t)){const e=(0,l.payloadId)(),s=(0,l.getBigIntRpcId)().toString(),{done:i,resolve:r,reject:n}=(0,a.Wx8)();this.events.once((0,a.hEn)("session_ping",e),({error:e})=>{e?n(e):r()}),await Promise.all([this.sendRequest({topic:t,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:e,relayRpcId:s}),i()])}else this.client.core.pairing.pairings.keys.includes(t)&&(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:t}))}),U(this,"emit",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(e);const{topic:t,event:s,chainId:i}=e,r=(0,l.getBigIntRpcId)().toString(),n=(0,l.payloadId)();await this.sendRequest({topic:t,method:"wc_sessionEvent",params:{event:s,chainId:i},throwOnFailedPublish:!0,relayRpcId:r,clientRpcId:n})}),U(this,"disconnect",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(e);const{topic:t}=e;if(this.client.session.keys.includes(t))await this.sendRequest({topic:t,method:"wc_sessionDelete",params:(0,a.Hjj)("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:t,emitEvent:!1});else{if(!this.client.core.pairing.pairings.keys.includes(t)){const{message:e}=(0,a.GuA)("MISMATCHED_TOPIC",`Session or pairing topic not found: ${t}`);throw new Error(e)}await this.client.core.pairing.disconnect({topic:t})}}),U(this,"find",e=>(this.isInitialized(),this.client.session.getAll().filter(t=>(0,a.HNf)(t,e)))),U(this,"getPendingSessionRequests",()=>this.client.pendingRequest.getAll()),U(this,"authenticate",async(e,t)=>{var s;this.isInitialized(),this.isValidAuthenticate(e);const r=t&&this.client.core.linkModeSupportedApps.includes(t)&&(null==(s=this.client.metadata.redirect)?void 0:s.linkMode),n=r?i.cV.link_mode:i.cV.relay;n===i.cV.relay&&await this.confirmOnlineStateOrThrow();const{chains:o,statement:c="",uri:h,domain:p,nonce:d,type:u,exp:g,nbf:f,methods:y=[],expiry:b}=e,v=[...e.resources||[]],{topic:E,uri:I}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:n});this.client.logger.info({message:"Generated new pairing",pairing:{topic:E,uri:I}});const _=await this.client.core.crypto.generateKeyPair(),A=(0,a.EN$)(_);if(await Promise.all([this.client.auth.authKeys.set(N,{responseTopic:A,publicKey:_}),this.client.auth.pairingTopics.set(A,{topic:A,pairingTopic:E})]),await this.client.core.relayer.subscribe(A,{transportType:n}),this.client.logger.info(`sending request to new pairing topic: ${E}`),y.length>0){const{namespace:e}=(0,a._Yb)(o[0]);let t=(0,a.e8_)(e,"request",y);(0,a.VBM)(v)&&(t=(0,a.hVC)(t,v.pop())),v.push(t)}const C=b&&b>w.wc_sessionAuthenticate.req.ttl?b:w.wc_sessionAuthenticate.req.ttl,P={authPayload:{type:u??"caip122",chains:o,statement:c,aud:h,domain:p,version:"1",nonce:d,iat:(new Date).toISOString(),exp:g,nbf:f,resources:v},requester:{publicKey:_,metadata:this.client.metadata},expiryTimestamp:(0,a.Xw0)(C)},S={requiredNamespaces:{},optionalNamespaces:{eip155:{chains:o,methods:[...new Set(["personal_sign",...y])],events:["chainChanged","accountsChanged"]}},relays:[{protocol:"irn"}],pairingTopic:E,proposer:{publicKey:_,metadata:this.client.metadata},expiryTimestamp:(0,a.Xw0)(w.wc_sessionPropose.req.ttl),id:(0,l.payloadId)()},{done:O,resolve:T,reject:k}=(0,a.Wx8)(C,"Request expired"),U=(0,l.payloadId)(),D=(0,a.hEn)("session_connect",S.id),j=(0,a.hEn)("session_request",U),M=async({error:e,session:t})=>{this.events.off(j,L),e?k(e):t&&T({session:t})},L=async e=>{var s,r,o;if(await this.deletePendingAuthRequest(U,{message:"fulfilled",code:0}),e.error){const t=(0,a.Hjj)("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return e.error.code===t.code?void 0:(this.events.off(D,M),k(e.error.message))}await this.deleteProposal(S.id),this.events.off(D,M);const{cacaos:c,responder:h}=e.result,l=[],p=[];for(const e of c){await(0,a.IjX)({cacao:e,projectId:this.client.core.projectId})||(this.client.logger.error(e,"Signature verification failed"),k((0,a.Hjj)("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:t}=e,s=(0,a.VBM)(t.resources),i=[(0,a.xkc)(t.iss)],r=(0,a.q_h)(t.iss);if(s){const e=(0,a.sc_)(s),t=(0,a.WWN)(s);l.push(...e),i.push(...t)}for(const e of i)p.push(`${e}:${r}`)}const d=await this.client.core.crypto.generateSharedKey(_,h.publicKey);let u;l.length>0&&(u={topic:d,acknowledged:!0,self:{publicKey:_,metadata:this.client.metadata},peer:h,controller:h.publicKey,expiry:(0,a.Xw0)(m),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:E,namespaces:(0,a.Van)([...new Set(l)],[...new Set(p)]),transportType:n},await this.client.core.relayer.subscribe(d,{transportType:n}),await this.client.session.set(d,u),E&&await this.client.core.pairing.updateMetadata({topic:E,metadata:h.metadata}),u=this.client.session.get(d)),null!=(s=this.client.metadata.redirect)&&s.linkMode&&null!=(r=h.metadata.redirect)&&r.linkMode&&null!=(o=h.metadata.redirect)&&o.universal&&t&&(this.client.core.addLinkModeSupportedApp(h.metadata.redirect.universal),this.client.session.update(d,{transportType:i.cV.link_mode})),T({auths:c,session:u})};let q;this.events.once(D,M),this.events.once(j,L);try{if(r){const e=(0,l.formatJsonRpcRequest)("wc_sessionAuthenticate",P,U);this.client.core.history.set(E,e);const s=await this.client.core.crypto.encode("",e,{type:a.EHS,encoding:a.Pa8});q=(0,a.$Bq)(t,E,s)}else await Promise.all([this.sendRequest({topic:E,method:"wc_sessionAuthenticate",params:P,expiry:e.expiry,throwOnFailedPublish:!0,clientRpcId:U}),this.sendRequest({topic:E,method:"wc_sessionPropose",params:S,expiry:w.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:S.id})])}catch(e){throw this.events.off(D,M),this.events.off(j,L),e}return await this.setProposal(S.id,S),await this.setAuthRequest(U,{request:R(x({},P),{verifyContext:{}}),pairingTopic:E,transportType:n}),{uri:q??I,response:O}}),U(this,"approveSessionAuthenticate",async e=>{const{id:t,auths:s}=e,r=this.client.core.eventClient.createEvent({properties:{topic:t.toString(),trace:[i.U$.authenticated_session_approve_started]}});try{this.isInitialized()}catch(e){throw r.setError(i.Tn.no_internet_connection),e}const n=this.getPendingAuthRequest(t);if(!n)throw r.setError(i.Tn.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${t}`);const o=n.transportType||i.cV.relay;o===i.cV.relay&&await this.confirmOnlineStateOrThrow();const c=n.requester.publicKey,h=await this.client.core.crypto.generateKeyPair(),l=(0,a.EN$)(c),p={type:a.Lp_,receiverPublicKey:c,senderPublicKey:h},d=[],u=[];for(const e of s){if(!await(0,a.IjX)({cacao:e,projectId:this.client.core.projectId})){r.setError(i.Tn.invalid_cacao);const e=(0,a.Hjj)("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:t,topic:l,error:e,encodeOpts:p}),new Error(e.message)}r.addTrace(i.U$.cacaos_verified);const{p:s}=e,n=(0,a.VBM)(s.resources),o=[(0,a.xkc)(s.iss)],c=(0,a.q_h)(s.iss);if(n){const e=(0,a.sc_)(n),t=(0,a.WWN)(n);d.push(...e),o.push(...t)}for(const e of o)u.push(`${e}:${c}`)}const g=await this.client.core.crypto.generateSharedKey(h,c);let f;if(r.addTrace(i.U$.create_authenticated_session_topic),d?.length>0){f={topic:g,acknowledged:!0,self:{publicKey:h,metadata:this.client.metadata},peer:{publicKey:c,metadata:n.requester.metadata},controller:c,expiry:(0,a.Xw0)(m),authentication:s,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:n.pairingTopic,namespaces:(0,a.Van)([...new Set(d)],[...new Set(u)]),transportType:o},r.addTrace(i.U$.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(g,{transportType:o})}catch(e){throw r.setError(i.Tn.subscribe_authenticated_session_topic_failure),e}r.addTrace(i.U$.subscribe_authenticated_session_topic_success),await this.client.session.set(g,f),r.addTrace(i.U$.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:n.pairingTopic,metadata:n.requester.metadata})}r.addTrace(i.U$.publishing_authenticated_session_approve);try{await this.sendResult({topic:l,id:t,result:{cacaos:s,responder:{publicKey:h,metadata:this.client.metadata}},encodeOpts:p,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(n.requester.metadata,o)})}catch(e){throw r.setError(i.Tn.authenticated_session_approve_publish_failure),e}return await this.client.auth.requests.delete(t,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:n.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:r.eventId}),{session:f}}),U(this,"rejectSessionAuthenticate",async e=>{this.isInitialized();const{id:t,reason:s}=e,r=this.getPendingAuthRequest(t);if(!r)throw new Error(`Could not find pending auth request with id ${t}`);r.transportType===i.cV.relay&&await this.confirmOnlineStateOrThrow();const n=r.requester.publicKey,o=await this.client.core.crypto.generateKeyPair(),c=(0,a.EN$)(n),h={type:a.Lp_,receiverPublicKey:n,senderPublicKey:o};await this.sendError({id:t,topic:c,error:s,encodeOpts:h,rpcOpts:w.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(r.requester.metadata,r.transportType)}),await this.client.auth.requests.delete(t,{message:"rejected",code:0}),await this.client.proposal.delete(t,(0,a.Hjj)("USER_DISCONNECTED"))}),U(this,"formatAuthMessage",e=>{this.isInitialized();const{request:t,iss:s}=e;return(0,a.hwK)(t,s)}),U(this,"processRelayMessageCache",()=>{setTimeout(async()=>{if(0!==this.relayMessageCache.length)for(;this.relayMessageCache.length>0;)try{const e=this.relayMessageCache.shift();e&&await this.onRelayMessage(e)}catch(e){this.client.logger.error(e)}},50)}),U(this,"cleanupDuplicatePairings",async e=>{if(e.pairingTopic)try{const t=this.client.core.pairing.pairings.get(e.pairingTopic),s=this.client.core.pairing.pairings.getAll().filter(s=>{var i,r;return(null==(i=s.peerMetadata)?void 0:i.url)&&(null==(r=s.peerMetadata)?void 0:r.url)===e.peer.metadata.url&&s.topic&&s.topic!==t.topic});if(0===s.length)return;this.client.logger.info(`Cleaning up ${s.length} duplicate pairing(s)`),await Promise.all(s.map(e=>this.client.core.pairing.disconnect({topic:e.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(e){this.client.logger.error(e)}}),U(this,"deleteSession",async e=>{var t;const{topic:s,expirerHasDeleted:i=!1,emitEvent:r=!0,id:n=0}=e,{self:o}=this.client.session.get(s);await this.client.core.relayer.unsubscribe(s),await this.client.session.delete(s,(0,a.Hjj)("USER_DISCONNECTED")),this.addToRecentlyDeleted(s,"session"),this.client.core.crypto.keychain.has(o.publicKey)&&await this.client.core.crypto.deleteKeyPair(o.publicKey),this.client.core.crypto.keychain.has(s)&&await this.client.core.crypto.deleteSymKey(s),i||this.client.core.expirer.del(s),this.client.core.storage.removeItem(g).catch(e=>this.client.logger.warn(e)),this.getPendingSessionRequests().forEach(e=>{e.topic===s&&this.deletePendingSessionRequest(e.id,(0,a.Hjj)("USER_DISCONNECTED"))}),s===(null==(t=this.sessionRequestQueue.queue[0])?void 0:t.topic)&&(this.sessionRequestQueue.state=b),r&&this.client.events.emit("session_delete",{id:n,topic:s})}),U(this,"deleteProposal",async(e,t)=>{if(t)try{const t=this.client.proposal.get(e),s=this.client.core.eventClient.getEvent({topic:t.pairingTopic});s?.setError(i.U.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(e,(0,a.Hjj)("USER_DISCONNECTED")),t?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"proposal")}),U(this,"deletePendingSessionRequest",async(e,t,s=!1)=>{await Promise.all([this.client.pendingRequest.delete(e,t),s?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(t=>t.id!==e),s&&(this.sessionRequestQueue.state=b,this.client.events.emit("session_request_expire",{id:e}))}),U(this,"deletePendingAuthRequest",async(e,t,s=!1)=>{await Promise.all([this.client.auth.requests.delete(e,t),s?Promise.resolve():this.client.core.expirer.del(e)])}),U(this,"setExpiry",async(e,t)=>{this.client.session.keys.includes(e)&&(this.client.core.expirer.set(e,t),await this.client.session.update(e,{expiry:t}))}),U(this,"setProposal",async(e,t)=>{this.client.core.expirer.set(e,(0,a.Xw0)(w.wc_sessionPropose.req.ttl)),await this.client.proposal.set(e,t)}),U(this,"setAuthRequest",async(e,t)=>{const{request:s,pairingTopic:r,transportType:n=i.cV.relay}=t;this.client.core.expirer.set(e,s.expiryTimestamp),await this.client.auth.requests.set(e,{authPayload:s.authPayload,requester:s.requester,expiryTimestamp:s.expiryTimestamp,id:e,pairingTopic:r,verifyContext:s.verifyContext,transportType:n})}),U(this,"setPendingSessionRequest",async e=>{const{id:t,topic:s,params:i,verifyContext:r}=e,n=i.request.expiryTimestamp||(0,a.Xw0)(w.wc_sessionRequest.req.ttl);this.client.core.expirer.set(t,n),await this.client.pendingRequest.set(t,{id:t,topic:s,params:i,verifyContext:r})}),U(this,"sendRequest",async e=>{const{topic:t,method:i,params:r,expiry:n,relayRpcId:o,clientRpcId:c,throwOnFailedPublish:h,appLink:p,tvf:d}=e,u=(0,l.formatJsonRpcRequest)(i,r,c);let g;const f=!!p;try{const e=f?a.Pa8:a.EWt;g=await this.client.core.crypto.encode(t,u,{encoding:e})}catch(e){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${t} failed`),e}let m;if(I.includes(i)){const e=(0,a.ALl)(JSON.stringify(u)),t=(0,a.ALl)(g);m=await this.client.core.verify.register({id:t,decryptedId:e})}const y=w[i].req;if(y.attestation=m,n&&(y.ttl=n),o&&(y.id=o),this.client.core.history.set(t,u),f){const e=(0,a.$Bq)(p,t,g);await s.g.Linking.openURL(e,this.client.name)}else{const e=w[i].req;n&&(e.ttl=n),o&&(e.id=o),e.tvf=R(x({},d),{correlationId:u.id}),h?(e.internal=R(x({},e.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(t,g,e)):this.client.core.relayer.publish(t,g,e).catch(e=>this.client.logger.error(e))}return u.id}),U(this,"sendResult",async e=>{const{id:t,topic:i,result:r,throwOnFailedPublish:n,encodeOpts:o,appLink:c}=e,h=(0,l.formatJsonRpcResult)(t,r);let p;const d=c&&typeof(null==s.g?void 0:s.g.Linking)<"u";try{const e=d?a.Pa8:a.EWt;p=await this.client.core.crypto.encode(i,h,R(x({},o||{}),{encoding:e}))}catch(e){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${i} failed`),e}let u,g;try{u=await this.client.core.history.get(i,t);const e=u.request;try{this.shouldSetTVF(e.method,e.params)&&(g=this.getTVFParams(t,e.params,r))}catch(e){this.client.logger.warn("sendResult() -> getTVFParams() failed",e)}}catch(e){throw this.client.logger.error(`sendResult() -> history.get(${i}, ${t}) failed`),e}if(d){const e=(0,a.$Bq)(c,i,p);await s.g.Linking.openURL(e,this.client.name)}else{const e=u.request.method,s=w[e].res;s.tvf=R(x({},g),{correlationId:t}),n?(s.internal=R(x({},s.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,p,s)):this.client.core.relayer.publish(i,p,s).catch(e=>this.client.logger.error(e))}await this.client.core.history.resolve(h)}),U(this,"sendError",async e=>{const{id:t,topic:i,error:r,encodeOpts:n,rpcOpts:o,appLink:c}=e,h=(0,l.formatJsonRpcError)(t,r);let p;const d=c&&typeof(null==s.g?void 0:s.g.Linking)<"u";try{const e=d?a.Pa8:a.EWt;p=await this.client.core.crypto.encode(i,h,R(x({},n||{}),{encoding:e}))}catch(e){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${i} failed`),e}let u;try{u=await this.client.core.history.get(i,t)}catch(e){throw this.client.logger.error(`sendError() -> history.get(${i}, ${t}) failed`),e}if(d){const e=(0,a.$Bq)(c,i,p);await s.g.Linking.openURL(e,this.client.name)}else{const e=u.request.method,t=o||w[e].res;this.client.core.relayer.publish(i,p,t)}await this.client.core.history.resolve(h)}),U(this,"cleanup",async()=>{const e=[],t=[];this.client.session.getAll().forEach(t=>{let s=!1;(0,a._dF)(t.expiry)&&(s=!0),this.client.core.crypto.keychain.has(t.topic)||(s=!0),s&&e.push(t.topic)}),this.client.proposal.getAll().forEach(e=>{(0,a._dF)(e.expiryTimestamp)&&t.push(e.id)}),await Promise.all([...e.map(e=>this.deleteSession({topic:e})),...t.map(e=>this.deleteProposal(e))])}),U(this,"onRelayEventRequest",async e=>{this.requestQueue.queue.push(e),await this.processRequestsQueue()}),U(this,"processRequestsQueue",async()=>{if(this.requestQueue.state!==v){for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=v;const e=this.requestQueue.queue.shift();if(e)try{await this.processRequest(e)}catch(e){this.client.logger.warn(e)}}this.requestQueue.state=b}else this.client.logger.info("Request queue already active, skipping...")}),U(this,"processRequest",async e=>{const{topic:t,payload:s,attestation:i,transportType:r,encryptedId:n}=e,o=s.method;if(!this.shouldIgnorePairingRequest({topic:t,requestMethod:o}))switch(o){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:t,payload:s,attestation:i,encryptedId:n});case"wc_sessionSettle":return await this.onSessionSettleRequest(t,s);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(t,s);case"wc_sessionExtend":return await this.onSessionExtendRequest(t,s);case"wc_sessionPing":return await this.onSessionPingRequest(t,s);case"wc_sessionDelete":return await this.onSessionDeleteRequest(t,s);case"wc_sessionRequest":return await this.onSessionRequest({topic:t,payload:s,attestation:i,encryptedId:n,transportType:r});case"wc_sessionEvent":return await this.onSessionEventRequest(t,s);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:t,payload:s,attestation:i,encryptedId:n,transportType:r});default:return this.client.logger.info(`Unsupported request method ${o}`)}}),U(this,"onRelayEventResponse",async e=>{const{topic:t,payload:s,transportType:i}=e,r=(await this.client.core.history.get(t,s.id)).request.method;switch(r){case"wc_sessionPropose":return this.onSessionProposeResponse(t,s,i);case"wc_sessionSettle":return this.onSessionSettleResponse(t,s);case"wc_sessionUpdate":return this.onSessionUpdateResponse(t,s);case"wc_sessionExtend":return this.onSessionExtendResponse(t,s);case"wc_sessionPing":return this.onSessionPingResponse(t,s);case"wc_sessionRequest":return this.onSessionRequestResponse(t,s);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(t,s);default:return this.client.logger.info(`Unsupported response method ${r}`)}}),U(this,"onRelayEventUnknownPayload",e=>{const{topic:t}=e,{message:s}=(0,a.GuA)("MISSING_OR_INVALID",`Decoded payload on topic ${t} is not identifiable as a JSON-RPC request or a response.`);throw new Error(s)}),U(this,"shouldIgnorePairingRequest",e=>{const{topic:t,requestMethod:s}=e,i=this.expectedPairingMethodMap.get(t);return!(!i||i.includes(s)||!(i.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0))}),U(this,"onSessionProposeRequest",async e=>{const{topic:t,payload:s,attestation:r,encryptedId:n}=e,{params:o,id:c}=s;try{const e=this.client.core.eventClient.getEvent({topic:t});0===this.client.events.listenerCount("session_proposal")&&(console.warn("No listener for session_proposal event"),e?.setError(i.S$.proposal_listener_not_found)),this.isValidConnect(x({},s.params));const h=o.expiryTimestamp||(0,a.Xw0)(w.wc_sessionPropose.req.ttl),l=x({id:c,pairingTopic:t,expiryTimestamp:h},o);await this.setProposal(c,l);const p=await this.getVerifyContext({attestationId:r,hash:(0,a.ALl)(JSON.stringify(s)),encryptedId:n,metadata:l.proposer.metadata});e?.addTrace(i.$w.emit_session_proposal),this.client.events.emit("session_proposal",{id:c,params:l,verifyContext:p})}catch(e){await this.sendError({id:c,topic:t,error:e,rpcOpts:w.wc_sessionPropose.autoReject}),this.client.logger.error(e)}}),U(this,"onSessionProposeResponse",async(e,t,s)=>{const{id:i}=t;if((0,l.isJsonRpcResult)(t)){const{result:r}=t;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:r});const n=this.client.proposal.get(i);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:n});const o=n.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:o});const a=r.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:a});const c=await this.client.core.crypto.generateSharedKey(o,a);this.pendingSessions.set(i,{sessionTopic:c,pairingTopic:e,proposalId:i,publicKey:o});const h=await this.client.core.relayer.subscribe(c,{transportType:s});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:h}),await this.client.core.pairing.activate({topic:e})}else if((0,l.isJsonRpcError)(t)){await this.client.proposal.delete(i,(0,a.Hjj)("USER_DISCONNECTED"));const e=(0,a.hEn)("session_connect",i);if(0===this.events.listenerCount(e))throw new Error(`emitting ${e} without any listeners, 954`);this.events.emit(e,{error:t.error})}}),U(this,"onSessionSettleRequest",async(e,t)=>{const{id:s,params:r}=t;try{this.isValidSessionSettleRequest(r);const{relay:s,controller:n,expiry:o,namespaces:c,sessionProperties:h,sessionConfig:l}=t.params,p=[...this.pendingSessions.values()].find(t=>t.sessionTopic===e);if(!p)return this.client.logger.error(`Pending session not found for topic ${e}`);const d=this.client.proposal.get(p.proposalId),u=R(x(x({topic:e,relay:s,expiry:o,namespaces:c,acknowledged:!0,pairingTopic:p.pairingTopic,requiredNamespaces:d.requiredNamespaces,optionalNamespaces:d.optionalNamespaces,controller:n.publicKey,self:{publicKey:p.publicKey,metadata:this.client.metadata},peer:{publicKey:n.publicKey,metadata:n.metadata}},h&&{sessionProperties:h}),l&&{sessionConfig:l}),{transportType:i.cV.relay});await this.client.session.set(u.topic,u),await this.setExpiry(u.topic,u.expiry),await this.client.core.pairing.updateMetadata({topic:p.pairingTopic,metadata:u.peer.metadata}),this.client.events.emit("session_connect",{session:u}),this.events.emit((0,a.hEn)("session_connect",p.proposalId),{session:u}),this.pendingSessions.delete(p.proposalId),this.deleteProposal(p.proposalId,!1),this.cleanupDuplicatePairings(u),await this.sendResult({id:t.id,topic:e,result:!0,throwOnFailedPublish:!0})}catch(t){await this.sendError({id:s,topic:e,error:t}),this.client.logger.error(t)}}),U(this,"onSessionSettleResponse",async(e,t)=>{const{id:s}=t;(0,l.isJsonRpcResult)(t)?(await this.client.session.update(e,{acknowledged:!0}),this.events.emit((0,a.hEn)("session_approve",s),{})):(0,l.isJsonRpcError)(t)&&(await this.client.session.delete(e,(0,a.Hjj)("USER_DISCONNECTED")),this.events.emit((0,a.hEn)("session_approve",s),{error:t.error}))}),U(this,"onSessionUpdateRequest",async(e,t)=>{const{params:s,id:i}=t;try{const t=`${e}_session_update`,r=a.nyL.get(t);if(r&&this.isRequestOutOfSync(r,i))return this.client.logger.warn(`Discarding out of sync request - ${i}`),void this.sendError({id:i,topic:e,error:(0,a.Hjj)("INVALID_UPDATE_REQUEST")});this.isValidUpdate(x({topic:e},s));try{a.nyL.set(t,i),await this.client.session.update(e,{namespaces:s.namespaces}),await this.sendResult({id:i,topic:e,result:!0,throwOnFailedPublish:!0})}catch(e){throw a.nyL.delete(t),e}this.client.events.emit("session_update",{id:i,topic:e,params:s})}catch(t){await this.sendError({id:i,topic:e,error:t}),this.client.logger.error(t)}}),U(this,"isRequestOutOfSync",(e,t)=>t.toString().slice(0,-3)<e.toString().slice(0,-3)),U(this,"onSessionUpdateResponse",(e,t)=>{const{id:s}=t,i=(0,a.hEn)("session_update",s);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);(0,l.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_update",s),{}):(0,l.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_update",s),{error:t.error})}),U(this,"onSessionExtendRequest",async(e,t)=>{const{id:s}=t;try{this.isValidExtend({topic:e}),await this.setExpiry(e,(0,a.Xw0)(m)),await this.sendResult({id:s,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:s,topic:e})}catch(t){await this.sendError({id:s,topic:e,error:t}),this.client.logger.error(t)}}),U(this,"onSessionExtendResponse",(e,t)=>{const{id:s}=t,i=(0,a.hEn)("session_extend",s);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);(0,l.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_extend",s),{}):(0,l.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_extend",s),{error:t.error})}),U(this,"onSessionPingRequest",async(e,t)=>{const{id:s}=t;try{this.isValidPing({topic:e}),await this.sendResult({id:s,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:s,topic:e})}catch(t){await this.sendError({id:s,topic:e,error:t}),this.client.logger.error(t)}}),U(this,"onSessionPingResponse",(e,t)=>{const{id:s}=t,i=(0,a.hEn)("session_ping",s);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);setTimeout(()=>{(0,l.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_ping",s),{}):(0,l.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_ping",s),{error:t.error})},500)}),U(this,"onSessionDeleteRequest",async(e,t)=>{const{id:s}=t;try{this.isValidDisconnect({topic:e,reason:t.params}),Promise.all([new Promise(t=>{this.client.core.relayer.once(i.Jf.publish,async()=>{t(await this.deleteSession({topic:e,id:s}))})}),this.sendResult({id:s,topic:e,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:e,error:(0,a.Hjj)("USER_DISCONNECTED")})]).catch(e=>this.client.logger.error(e))}catch(e){this.client.logger.error(e)}}),U(this,"onSessionRequest",async e=>{var t,s,r;const{topic:n,payload:o,attestation:c,encryptedId:h,transportType:p}=e,{id:d,params:u}=o;try{await this.isValidRequest(x({topic:n},u));const e=this.client.session.get(n),o={id:d,topic:n,params:u,verifyContext:await this.getVerifyContext({attestationId:c,hash:(0,a.ALl)(JSON.stringify((0,l.formatJsonRpcRequest)("wc_sessionRequest",u,d))),encryptedId:h,metadata:e.peer.metadata,transportType:p})};await this.setPendingSessionRequest(o),p===i.cV.link_mode&&null!=(t=e.peer.metadata.redirect)&&t.universal&&this.client.core.addLinkModeSupportedApp(null==(s=e.peer.metadata.redirect)?void 0:s.universal),null!=(r=this.client.signConfig)&&r.disableRequestQueue?this.emitSessionRequest(o):(this.addSessionRequestToSessionRequestQueue(o),this.processSessionRequestQueue())}catch(e){await this.sendError({id:d,topic:n,error:e}),this.client.logger.error(e)}}),U(this,"onSessionRequestResponse",(e,t)=>{const{id:s}=t,i=(0,a.hEn)("session_request",s);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);(0,l.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_request",s),{result:t.result}):(0,l.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_request",s),{error:t.error})}),U(this,"onSessionEventRequest",async(e,t)=>{const{id:s,params:i}=t;try{const t=`${e}_session_event_${i.event.name}`,r=a.nyL.get(t);if(r&&this.isRequestOutOfSync(r,s))return void this.client.logger.info(`Discarding out of sync request - ${s}`);this.isValidEmit(x({topic:e},i)),this.client.events.emit("session_event",{id:s,topic:e,params:i}),a.nyL.set(t,s)}catch(t){await this.sendError({id:s,topic:e,error:t}),this.client.logger.error(t)}}),U(this,"onSessionAuthenticateResponse",(e,t)=>{const{id:s}=t;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:e,payload:t}),(0,l.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_request",s),{result:t.result}):(0,l.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_request",s),{error:t.error})}),U(this,"onSessionAuthenticateRequest",async e=>{var t;const{topic:s,payload:r,attestation:n,encryptedId:o,transportType:c}=e;try{const{requester:e,authPayload:h,expiryTimestamp:l}=r.params,p=await this.getVerifyContext({attestationId:n,hash:(0,a.ALl)(JSON.stringify(r)),encryptedId:o,metadata:e.metadata,transportType:c}),d={requester:e,pairingTopic:s,id:r.id,authPayload:h,verifyContext:p,expiryTimestamp:l};await this.setAuthRequest(r.id,{request:d,pairingTopic:s,transportType:c}),c===i.cV.link_mode&&null!=(t=e.metadata.redirect)&&t.universal&&this.client.core.addLinkModeSupportedApp(e.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:s,params:r.params,id:r.id,verifyContext:p})}catch(e){this.client.logger.error(e);const t=r.params.requester.publicKey,i=await this.client.core.crypto.generateKeyPair(),n=this.getAppLinkIfEnabled(r.params.requester.metadata,c),o={type:a.Lp_,receiverPublicKey:t,senderPublicKey:i};await this.sendError({id:r.id,topic:s,error:e,encodeOpts:o,rpcOpts:w.wc_sessionAuthenticate.autoReject,appLink:n})}}),U(this,"addSessionRequestToSessionRequestQueue",e=>{this.sessionRequestQueue.queue.push(e)}),U(this,"cleanupAfterResponse",e=>{this.deletePendingSessionRequest(e.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=b,this.processSessionRequestQueue()},(0,o.toMiliseconds)(this.requestQueueDelay))}),U(this,"cleanupPendingSentRequestsForTopic",({topic:e,error:t})=>{const s=this.client.core.history.pending;s.length>0&&s.filter(t=>t.topic===e&&"wc_sessionRequest"===t.request.method).forEach(e=>{const s=e.request.id,i=(0,a.hEn)("session_request",s);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);this.events.emit((0,a.hEn)("session_request",e.request.id),{error:t})})}),U(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===v)return void this.client.logger.info("session request queue is already active.");const e=this.sessionRequestQueue.queue[0];if(e)try{this.sessionRequestQueue.state=v,this.emitSessionRequest(e)}catch(e){this.client.logger.error(e)}else this.client.logger.info("session request queue is empty.")}),U(this,"emitSessionRequest",e=>{this.client.events.emit("session_request",e)}),U(this,"onPairingCreated",e=>{if(e.methods&&this.expectedPairingMethodMap.set(e.topic,e.methods),e.active)return;const t=this.client.proposal.getAll().find(t=>t.pairingTopic===e.topic);t&&this.onSessionProposeRequest({topic:e.topic,payload:(0,l.formatJsonRpcRequest)("wc_sessionPropose",{requiredNamespaces:t.requiredNamespaces,optionalNamespaces:t.optionalNamespaces,relays:t.relays,proposer:t.proposer,sessionProperties:t.sessionProperties},t.id)})}),U(this,"isValidConnect",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(e)}`);throw new Error(t)}const{pairingTopic:t,requiredNamespaces:s,optionalNamespaces:i,sessionProperties:r,relays:n}=e;if((0,a.b07)(t)||await this.isValidPairingTopic(t),!(0,a.V9G)(n,!0)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`connect() relays: ${n}`);throw new Error(e)}!(0,a.b07)(s)&&0!==(0,a.aF0)(s)&&this.validateNamespaces(s,"requiredNamespaces"),!(0,a.b07)(i)&&0!==(0,a.aF0)(i)&&this.validateNamespaces(i,"optionalNamespaces"),(0,a.b07)(r)||this.validateSessionProps(r,"sessionProperties")}),U(this,"validateNamespaces",(e,t)=>{const s=(0,a.esh)(e,"connect()",t);if(s)throw new Error(s.message)}),U(this,"isValidApprove",async e=>{if(!(0,a.TeY)(e))throw new Error((0,a.GuA)("MISSING_OR_INVALID",`approve() params: ${e}`).message);const{id:t,namespaces:s,relayProtocol:i,sessionProperties:r}=e;this.checkRecentlyDeleted(t),await this.isValidProposalId(t);const n=this.client.proposal.get(t),o=(0,a.FiO)(s,"approve()");if(o)throw new Error(o.message);const c=(0,a.XqR)(n.requiredNamespaces,s,"approve()");if(c)throw new Error(c.message);if(!(0,a.Qhg)(i,!0)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`approve() relayProtocol: ${i}`);throw new Error(e)}(0,a.b07)(r)||this.validateSessionProps(r,"sessionProperties")}),U(this,"isValidReject",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`reject() params: ${e}`);throw new Error(t)}const{id:t,reason:s}=e;if(this.checkRecentlyDeleted(t),await this.isValidProposalId(t),!(0,a.X3c)(s)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(s)}`);throw new Error(e)}}),U(this,"isValidSessionSettleRequest",e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${e}`);throw new Error(t)}const{relay:t,controller:s,namespaces:i,expiry:r}=e;if(!(0,a.kuU)(t)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(e)}const n=(0,a.tk0)(s,"onSessionSettleRequest()");if(n)throw new Error(n.message);const o=(0,a.FiO)(i,"onSessionSettleRequest()");if(o)throw new Error(o.message);if((0,a._dF)(r)){const{message:e}=(0,a.GuA)("EXPIRED","onSessionSettleRequest()");throw new Error(e)}}),U(this,"isValidUpdate",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`update() params: ${e}`);throw new Error(t)}const{topic:t,namespaces:s}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t);const i=this.client.session.get(t),r=(0,a.FiO)(s,"update()");if(r)throw new Error(r.message);const n=(0,a.XqR)(i.requiredNamespaces,s,"update()");if(n)throw new Error(n.message)}),U(this,"isValidExtend",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`extend() params: ${e}`);throw new Error(t)}const{topic:t}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t)}),U(this,"isValidRequest",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`request() params: ${e}`);throw new Error(t)}const{topic:t,request:s,chainId:i,expiry:r}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t);const{namespaces:n}=this.client.session.get(t);if(!(0,a.tLy)(n,i)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() chainId: ${i}`);throw new Error(e)}if(!(0,a.iV1)(s)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() ${JSON.stringify(s)}`);throw new Error(e)}if(!(0,a.oKp)(n,i,s.method)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() method: ${s.method}`);throw new Error(e)}if(r&&!(0,a.Hbs)(r,y)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() expiry: ${r}. Expiry must be a number (in seconds) between ${y.min} and ${y.max}`);throw new Error(e)}}),U(this,"isValidRespond",async e=>{var t;if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`respond() params: ${e}`);throw new Error(t)}const{topic:s,response:i}=e;try{await this.isValidSessionTopic(s)}catch(s){throw null!=(t=e?.response)&&t.id&&this.cleanupAfterResponse(e),s}if(!(0,a.M8n)(i)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(i)}`);throw new Error(e)}}),U(this,"isValidPing",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)}),U(this,"isValidEmit",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`emit() params: ${e}`);throw new Error(t)}const{topic:t,event:s,chainId:i}=e;await this.isValidSessionTopic(t);const{namespaces:r}=this.client.session.get(t);if(!(0,a.tLy)(r,i)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`emit() chainId: ${i}`);throw new Error(e)}if(!(0,a.FR8)(s)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(e)}if(!(0,a.z2N)(r,i,s.name)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(e)}}),U(this,"isValidDisconnect",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)}),U(this,"isValidAuthenticate",e=>{const{chains:t,uri:s,domain:i,nonce:r}=e;if(!Array.isArray(t)||0===t.length)throw new Error("chains is required and must be a non-empty array");if(!(0,a.Qhg)(s,!1))throw new Error("uri is required parameter");if(!(0,a.Qhg)(i,!1))throw new Error("domain is required parameter");if(!(0,a.Qhg)(r,!1))throw new Error("nonce is required parameter");if([...new Set(t.map(e=>(0,a._Yb)(e).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:n}=(0,a._Yb)(t[0]);if("eip155"!==n)throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),U(this,"getVerifyContext",async e=>{const{attestationId:t,hash:s,encryptedId:r,metadata:n,transportType:o}=e,a={verified:{verifyUrl:n.verifyUrl||i.WB,validation:"UNKNOWN",origin:n.url||""}};try{if(o===i.cV.link_mode){const e=this.getAppLinkIfEnabled(n,o);return a.verified.validation=e&&new URL(e).origin===new URL(n.url).origin?"VALID":"INVALID",a}const e=await this.client.core.verify.resolve({attestationId:t,hash:s,encryptedId:r,verifyUrl:n.verifyUrl});e&&(a.verified.origin=e.origin,a.verified.isScam=e.isScam,a.verified.validation=e.origin===new URL(n.url).origin?"VALID":"INVALID")}catch(e){this.client.logger.warn(e)}return this.client.logger.debug(`Verify context: ${JSON.stringify(a)}`),a}),U(this,"validateSessionProps",(e,t)=>{Object.values(e).forEach(e=>{if(!(0,a.Qhg)(e,!1)){const{message:s}=(0,a.GuA)("MISSING_OR_INVALID",`${t} must be in Record<string, string> format. Received: ${JSON.stringify(e)}`);throw new Error(s)}})}),U(this,"getPendingAuthRequest",e=>{const t=this.client.auth.requests.get(e);return"object"==typeof t?t:void 0}),U(this,"addToRecentlyDeleted",(e,t)=>{if(this.recentlyDeletedMap.set(e,t),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let e=0;const t=this.recentlyDeletedLimit/2;for(const s of this.recentlyDeletedMap.keys()){if(e++>=t)break;this.recentlyDeletedMap.delete(s)}}}),U(this,"checkRecentlyDeleted",e=>{const t=this.recentlyDeletedMap.get(e);if(t){const{message:s}=(0,a.GuA)("MISSING_OR_INVALID",`Record was recently deleted - ${t}: ${e}`);throw new Error(s)}}),U(this,"isLinkModeEnabled",(e,t)=>{var r,n,o,a,c,h,l,p,d;return!(!e||t!==i.cV.link_mode)&&!0===(null==(n=null==(r=this.client.metadata)?void 0:r.redirect)?void 0:n.linkMode)&&void 0!==(null==(a=null==(o=this.client.metadata)?void 0:o.redirect)?void 0:a.universal)&&""!==(null==(h=null==(c=this.client.metadata)?void 0:c.redirect)?void 0:h.universal)&&void 0!==(null==(l=e?.redirect)?void 0:l.universal)&&""!==(null==(p=e?.redirect)?void 0:p.universal)&&!0===(null==(d=e?.redirect)?void 0:d.linkMode)&&this.client.core.linkModeSupportedApps.includes(e.redirect.universal)&&typeof(null==s.g?void 0:s.g.Linking)<"u"}),U(this,"getAppLinkIfEnabled",(e,t)=>{var s;return this.isLinkModeEnabled(e,t)?null==(s=e?.redirect)?void 0:s.universal:void 0}),U(this,"handleLinkModeMessage",({url:e})=>{if(!e||!e.includes("wc_ev")||!e.includes("topic"))return;const t=(0,a.$hI)(e,"topic")||"",s=decodeURIComponent((0,a.$hI)(e,"wc_ev")||""),r=this.client.session.keys.includes(t);r&&this.client.session.update(t,{transportType:i.cV.link_mode}),this.client.core.dispatchEnvelope({topic:t,message:s,sessionExists:r})}),U(this,"registerLinkModeListeners",async()=>{var e;if((0,a.w8K)()||(0,a.lVv)()&&null!=(e=this.client.metadata.redirect)&&e.linkMode){const e=null==s.g?void 0:s.g.Linking;if(typeof e<"u"){e.addEventListener("url",this.handleLinkModeMessage,this.client.name);const t=await e.getInitialURL();t&&setTimeout(()=>{this.handleLinkModeMessage({url:t})},50)}}}),U(this,"shouldSetTVF",(e,t)=>{if(!t||"wc_sessionRequest"!==e)return!1;const{request:s}=t;return Object.keys(E).includes(s.method)}),U(this,"getTVFParams",(e,t,s)=>{var i,r;try{const n=t.request.method,o=this.extractTxHashesFromResult(n,s);return R(x({correlationId:e,rpcMethods:[n],chainId:t.chainId},this.isValidContractData(t.request.params)&&{contractAddresses:[null==(r=null==(i=t.request.params)?void 0:i[0])?void 0:r.to]}),{txHashes:o})}catch(e){this.client.logger.warn("Error getting TVF params",e)}return{}}),U(this,"isValidContractData",e=>{var t;if(!e)return!1;try{const s=e?.data||(null==(t=e?.[0])?void 0:t.data);if(!s.startsWith("0x"))return!1;const i=s.slice(2);return!!/^[0-9a-fA-F]*$/.test(i)&&i.length%2==0}catch{}return!1}),U(this,"extractTxHashesFromResult",(e,t)=>{try{if("string"==typeof t)return[t];const s=t[E[e].key];if((0,a.OP1)(s))return s;if("string"==typeof s)return[s]}catch(e){this.client.logger.warn("Error extracting tx hashes from result",e)}return[]})}isInitialized(){if(!this.initialized){const{message:e}=(0,a.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(i.Jf.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){const{topic:t,message:s,attestation:r,transportType:n}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(N)?this.client.auth.authKeys.get(N):{responseTopic:void 0,publicKey:void 0},c=await this.client.core.crypto.decode(t,s,{receiverPublicKey:o,encoding:n===i.cV.link_mode?a.Pa8:a.EWt});try{(0,l.isJsonRpcRequest)(c)?(this.client.core.history.set(t,c),this.onRelayEventRequest({topic:t,payload:c,attestation:r,transportType:n,encryptedId:(0,a.ALl)(s)})):(0,l.isJsonRpcResponse)(c)?(await this.client.core.history.resolve(c),await this.onRelayEventResponse({topic:t,payload:c,transportType:n}),this.client.core.history.delete(t,c.id)):this.onRelayEventUnknownPayload({topic:t,payload:c,transportType:n})}catch(e){this.client.logger.error(e)}}registerExpirerEvents(){this.client.core.expirer.on(i.wn.expired,async e=>{const{topic:t,id:s}=(0,a.c82)(e.target);return s&&this.client.pendingRequest.keys.includes(s)?await this.deletePendingSessionRequest(s,(0,a.GuA)("EXPIRED"),!0):s&&this.client.auth.requests.keys.includes(s)?await this.deletePendingAuthRequest(s,(0,a.GuA)("EXPIRED"),!0):void(t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):s&&(await this.deleteProposal(s,!0),this.client.events.emit("proposal_expire",{id:s})))})}registerPairingEvents(){this.client.core.pairing.events.on(i.zN.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(i.zN.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!(0,a.Qhg)(e,!1)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if((0,a._dF)(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=(0,a.GuA)("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!(0,a.Qhg)(e,!1)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if((0,a._dF)(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:t}=(0,a.GuA)("EXPIRED",`session topic: ${e}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else{if(!this.client.core.pairing.pairings.keys.includes(e)){if((0,a.Qhg)(e,!1)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}{const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}this.isValidPairingTopic(e)}}async isValidProposalId(e){if(!(0,a.Alu)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if((0,a._dF)(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:t}=(0,a.GuA)("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}}class j extends i.il{constructor(e,t){super(e,t,"proposal",d),this.core=e,this.logger=t}}class M extends i.il{constructor(e,t){super(e,t,"session",d),this.core=e,this.logger=t}}class L extends i.il{constructor(e,t){super(e,t,"request",d,e=>e.id),this.core=e,this.logger=t}}class q extends i.il{constructor(e,t){super(e,t,"authKeys",_,()=>N),this.core=e,this.logger=t}}class $ extends i.il{constructor(e,t){super(e,t,"pairingTopics",_),this.core=e,this.logger=t}}class B extends i.il{constructor(e,t){super(e,t,"requests",_,e=>e.id),this.core=e,this.logger=t}}var H=Object.defineProperty,W=(e,t,s)=>((e,t,s)=>t in e?H(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class z{constructor(e,t){this.core=e,this.logger=t,W(this,"authKeys"),W(this,"pairingTopics"),W(this,"requests"),this.authKeys=new q(this.core,this.logger),this.pairingTopics=new $(this.core,this.logger),this.requests=new B(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}var V=Object.defineProperty,F=(e,t,s)=>((e,t,s)=>t in e?V(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class K extends n.S9{constructor(e){super(e),F(this,"protocol","wc"),F(this,"version",2),F(this,"name",u),F(this,"metadata"),F(this,"core"),F(this,"logger"),F(this,"events",new c.EventEmitter),F(this,"engine"),F(this,"session"),F(this,"proposal"),F(this,"pendingRequest"),F(this,"auth"),F(this,"signConfig"),F(this,"on",(e,t)=>this.events.on(e,t)),F(this,"once",(e,t)=>this.events.once(e,t)),F(this,"off",(e,t)=>this.events.off(e,t)),F(this,"removeListener",(e,t)=>this.events.removeListener(e,t)),F(this,"removeAllListeners",e=>this.events.removeAllListeners(e)),F(this,"connect",async e=>{try{return await this.engine.connect(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"pair",async e=>{try{return await this.engine.pair(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"approve",async e=>{try{return await this.engine.approve(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"reject",async e=>{try{return await this.engine.reject(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"update",async e=>{try{return await this.engine.update(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"extend",async e=>{try{return await this.engine.extend(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"request",async e=>{try{return await this.engine.request(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"respond",async e=>{try{return await this.engine.respond(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"ping",async e=>{try{return await this.engine.ping(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"emit",async e=>{try{return await this.engine.emit(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"disconnect",async e=>{try{return await this.engine.disconnect(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"find",e=>{try{return this.engine.find(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(e){throw this.logger.error(e.message),e}}),F(this,"authenticate",async(e,t)=>{try{return await this.engine.authenticate(e,t)}catch(e){throw this.logger.error(e.message),e}}),F(this,"formatAuthMessage",e=>{try{return this.engine.formatAuthMessage(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"approveSessionAuthenticate",async e=>{try{return await this.engine.approveSessionAuthenticate(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"rejectSessionAuthenticate",async e=>{try{return await this.engine.rejectSessionAuthenticate(e)}catch(e){throw this.logger.error(e.message),e}}),this.name=e?.name||u,this.metadata=e?.metadata||(0,a.lFF)(),this.signConfig=e?.signConfig;const t=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:(0,r.h6)((0,r.iP)({level:e?.logger||"error"}));this.core=e?.core||new i.iJ(e),this.logger=(0,r.U5)(t,this.name),this.session=new M(this.core,this.logger),this.proposal=new j(this.core,this.logger),this.pendingRequest=new L(this.core,this.logger),this.engine=new D(this),this.auth=new z(this.core,this.logger)}static async init(e){const t=new K(e);return await t.initialize(),t}get context(){return(0,r.oI)(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()},(0,o.toMiliseconds)(o.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}},32681:(e,t,s)=>{s.d(t,{IP:()=>o,T8:()=>r,Ud:()=>n,Ws:()=>i});const i={WALLET_ID:"@appkit/wallet_id",WALLET_NAME:"@appkit/wallet_name",SOLANA_WALLET:"@appkit/solana_wallet",SOLANA_CAIP_CHAIN:"@appkit/solana_caip_chain",ACTIVE_CAIP_NETWORK_ID:"@appkit/active_caip_network_id",CONNECTED_SOCIAL:"@appkit/connected_social",CONNECTED_SOCIAL_USERNAME:"@appkit-wallet/SOCIAL_USERNAME",RECENT_WALLETS:"@appkit/recent_wallets",DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",ACTIVE_NAMESPACE:"@appkit/active_namespace",CONNECTED_NAMESPACES:"@appkit/connected_namespaces",CONNECTION_STATUS:"@appkit/connection_status",SIWX_AUTH_TOKEN:"@appkit/siwx-auth-token",SIWX_NONCE_TOKEN:"@appkit/siwx-nonce-token",TELEGRAM_SOCIAL_PROVIDER:"@appkit/social_provider",NATIVE_BALANCE_CACHE:"@appkit/native_balance_cache",PORTFOLIO_CACHE:"@appkit/portfolio_cache",ENS_CACHE:"@appkit/ens_cache",IDENTITY_CACHE:"@appkit/identity_cache"};function r(e){if(!e)throw new Error("Namespace is required for CONNECTED_CONNECTOR_ID");return`@appkit/${e}:connected_connector_id`}const n={setItem(e,t){o()&&void 0!==t&&localStorage.setItem(e,t)},getItem(e){if(o())return localStorage.getItem(e)||void 0},removeItem(e){o()&&localStorage.removeItem(e)},clear(){o()&&localStorage.clear()}};function o(){return"undefined"!=typeof window&&"undefined"!=typeof localStorage}},33816:(e,t,s)=>{s.d(t,{X:()=>c}),s(1057);var i=s(95191),r=s(16279),n=s(16158),o=s(40770),a=s(76663);class c{constructor(e){this.availableConnectors=[],this.eventListeners=new Map,e&&this.construct(e)}construct(e){this.caipNetworks=e.networks,this.projectId=e.projectId,this.namespace=e.namespace,this.adapterType=e.adapterType}get connectors(){return this.availableConnectors}get networks(){return this.caipNetworks||[]}setAuthProvider(e){this.addConnector({id:i.o.CONNECTOR_ID.AUTH,type:"AUTH",name:i.o.CONNECTOR_NAMES.AUTH,provider:e,imageId:o.L.ConnectorImageIds[i.o.CONNECTOR_ID.AUTH],chain:this.namespace,chains:[]})}addConnector(...e){const t=new Set;this.availableConnectors=[...e,...this.availableConnectors].filter(e=>!t.has(e.id)&&(t.add(e.id),!0)),this.emit("connectors",this.availableConnectors)}setStatus(e,t){r.U.setStatus(e,t)}on(e,t){this.eventListeners.has(e)||this.eventListeners.set(e,new Set),this.eventListeners.get(e)?.add(t)}off(e,t){const s=this.eventListeners.get(e);s&&s.delete(t)}removeAllEventListeners(){this.eventListeners.forEach(e=>{e.clear()})}emit(e,t){const s=this.eventListeners.get(e);s&&s.forEach(e=>e(t))}async connectWalletConnect(e){const t=this.getWalletConnectConnector();return{clientId:(await t.connectWalletConnect()).clientId}}async switchNetwork(e){const{caipNetwork:t,providerType:s}=e;if(!e.provider)return;const i="provider"in e.provider?e.provider.provider:e.provider;if("WALLET_CONNECT"!==s){if(i&&"AUTH"===s){const e=i;await e.switchNetwork(t.caipNetworkId);const s=await e.getUser({chainId:t.caipNetworkId,preferredAccountType:n.H.state.defaultAccountTypes[t.chainNamespace]});this.emit("switchNetwork",s)}}else i.setDefaultChain(t.caipNetworkId)}getWalletConnectConnector(){const e=this.connectors.find(e=>e instanceof a.F);if(!e)throw new Error("WalletConnectConnector not found");return e}}},33937:(e,t,s)=>{s.d(t,{t:()=>i});const i=(0,s(40149).x)({id:"5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",name:"Solana",network:"solana-mainnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!1,chainNamespace:"solana",caipNetworkId:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",deprecatedCaipNetworkId:"solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ"})},35842:(e,t,s)=>{s.d(t,{AH:()=>i.AH,JW:()=>i.JW,WF:()=>i.WF,iz:()=>i.iz,qy:()=>i.qy}),s(58207),s(80181);var i=s(46477)},36641:(e,t,s)=>{s.d(t,{T:()=>r});var i=s(88612);const r={createBalance(e,t){const s={name:e.metadata.name||"",symbol:e.metadata.symbol||"",decimals:e.metadata.decimals||0,value:e.metadata.value||0,price:e.metadata.price||0,iconUrl:e.metadata.iconUrl||""};return{name:s.name,symbol:s.symbol,chainId:t,address:"native"===e.address?void 0:this.convertAddressToCAIP10Address(e.address,t),value:s.value,price:s.price,quantity:{decimals:s.decimals.toString(),numeric:this.convertHexToBalance({hex:e.balance,decimals:s.decimals})},iconUrl:s.iconUrl}},convertHexToBalance:({hex:e,decimals:t})=>(0,i.J)(BigInt(e),t),convertAddressToCAIP10Address:(e,t)=>`${t}:${e}`,createCAIP2ChainId:(e,t)=>`${t}:${parseInt(e,16)}`,getChainIdHexFromCAIP2ChainId(e){const t=e.split(":");if(t.length<2||!t[1])return"0x0";const s=t[1],i=parseInt(s,10);return isNaN(i)?"0x0":`0x${i.toString(16)}`},isWalletGetAssetsResponse(e){return"object"==typeof e&&null!==e&&Object.values(e).every(e=>Array.isArray(e)&&e.every(e=>this.isValidAsset(e)))},isValidAsset:e=>"object"==typeof e&&null!==e&&"string"==typeof e.address&&"string"==typeof e.balance&&("ERC20"===e.type||"NATIVE"===e.type)&&"object"==typeof e.metadata&&null!==e.metadata&&"string"==typeof e.metadata.name&&"string"==typeof e.metadata.symbol&&"number"==typeof e.metadata.decimals&&"number"==typeof e.metadata.price&&"string"==typeof e.metadata.iconUrl}},37876:(e,t,s)=>{s.d(t,{Ay:()=>K});var i=s(98752),r=s(70255),n=s(21910),o=s(91315),a=s(43039),c=s(50046),h=s.n(c),l=s(14350);const p="client",d=`wc@2:${p}:`,u=p,g="WALLETCONNECT_DEEPLINK_CHOICE",f="Proposal expired",m=o.SEVEN_DAYS,w={wc_sessionPropose:{req:{ttl:o.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1104},res:{ttl:o.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1106},res:{ttl:o.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:o.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:o.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1112},res:{ttl:o.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1114},res:{ttl:o.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:o.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:o.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1119}}},y={min:o.FIVE_MINUTES,max:o.SEVEN_DAYS},b="IDLE",v="ACTIVE",E={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"}},I=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],_="wc@1.5:auth:",N=`${_}:PUB_KEY`;var A=Object.defineProperty,C=Object.defineProperties,P=Object.getOwnPropertyDescriptors,S=Object.getOwnPropertySymbols,O=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable,k=(e,t,s)=>t in e?A(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,x=(e,t)=>{for(var s in t||(t={}))O.call(t,s)&&k(e,s,t[s]);if(S)for(var s of S(t))T.call(t,s)&&k(e,s,t[s]);return e},R=(e,t)=>C(e,P(t)),U=(e,t,s)=>k(e,"symbol"!=typeof t?t+"":t,s);class D extends n.yJ{constructor(e){super(e),U(this,"name","engine"),U(this,"events",new(h())),U(this,"initialized",!1),U(this,"requestQueue",{state:b,queue:[]}),U(this,"sessionRequestQueue",{state:b,queue:[]}),U(this,"requestQueueDelay",o.ONE_SECOND),U(this,"expectedPairingMethodMap",new Map),U(this,"recentlyDeletedMap",new Map),U(this,"recentlyDeletedLimit",200),U(this,"relayMessageCache",[]),U(this,"pendingSessions",new Map),U(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(w)}),this.initialized=!0,setTimeout(async()=>{await this.processPendingMessageEvents(),this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},(0,o.toMiliseconds)(this.requestQueueDelay)))}),U(this,"connect",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const t=R(x({},e),{requiredNamespaces:e.requiredNamespaces||{},optionalNamespaces:e.optionalNamespaces||{}});await this.isValidConnect(t);const{pairingTopic:s,requiredNamespaces:r,optionalNamespaces:n,sessionProperties:c,scopedProperties:h,relays:p}=t;let d,u=s,g=!1;try{if(u){const e=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."),g=e.active}}catch(e){throw this.client.logger.error(`connect() -> pairing.get(${u}) failed`),e}if(!u||!g){const{topic:e,uri:t}=await this.client.core.pairing.create();u=e,d=t}if(!u){const{message:e}=(0,a.GuA)("NO_MATCHING_KEY",`connect() pairing topic: ${u}`);throw new Error(e)}const m=await this.client.core.crypto.generateKeyPair(),y=w.wc_sessionPropose.req.ttl||o.FIVE_MINUTES,b=(0,a.Xw0)(y),v=R(x(x({requiredNamespaces:r,optionalNamespaces:n,relays:p??[{protocol:i.sD}],proposer:{publicKey:m,metadata:this.client.metadata},expiryTimestamp:b,pairingTopic:u},c&&{sessionProperties:c}),h&&{scopedProperties:h}),{id:(0,l.payloadId)()}),E=(0,a.hEn)("session_connect",v.id),{reject:I,resolve:_,done:N}=(0,a.Wx8)(y,f),A=({id:e})=>{e===v.id&&(this.client.events.off("proposal_expire",A),this.pendingSessions.delete(v.id),this.events.emit(E,{error:{message:f,code:0}}))};return this.client.events.on("proposal_expire",A),this.events.once(E,({error:e,session:t})=>{this.client.events.off("proposal_expire",A),e?I(e):t&&_(t)}),await this.sendRequest({topic:u,method:"wc_sessionPropose",params:v,throwOnFailedPublish:!0,clientRpcId:v.id}),await this.setProposal(v.id,v),{uri:d,approval:N}}),U(this,"pair",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(e)}catch(e){throw this.client.logger.error("pair() failed"),e}}),U(this,"approve",async e=>{var t,s,r;const n=this.client.core.eventClient.createEvent({properties:{topic:null==(t=e?.id)?void 0:t.toString(),trace:[i.$I.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(e){throw n.setError(i.U.no_internet_connection),e}try{await this.isValidProposalId(e?.id)}catch(t){throw this.client.logger.error(`approve() -> proposal.get(${e?.id}) failed`),n.setError(i.U.proposal_not_found),t}try{await this.isValidApprove(e)}catch(e){throw this.client.logger.error("approve() -> isValidApprove() failed"),n.setError(i.U.session_approve_namespace_validation_failure),e}const{id:o,relayProtocol:c,namespaces:h,sessionProperties:l,scopedProperties:p,sessionConfig:d}=e,u=this.client.proposal.get(o);this.client.core.eventClient.deleteEvent({eventId:n.eventId});const{pairingTopic:g,proposer:f,requiredNamespaces:w,optionalNamespaces:y}=u;let b=null==(s=this.client.core.eventClient)?void 0:s.getEvent({topic:g});b||(b=null==(r=this.client.core.eventClient)?void 0:r.createEvent({type:i.$I.session_approve_started,properties:{topic:g,trace:[i.$I.session_approve_started,i.$I.session_namespaces_validation_success]}}));const v=await this.client.core.crypto.generateKeyPair(),E=f.publicKey,I=await this.client.core.crypto.generateSharedKey(v,E),_=x(x(x({relay:{protocol:c??"irn"},namespaces:h,controller:{publicKey:v,metadata:this.client.metadata},expiry:(0,a.Xw0)(m)},l&&{sessionProperties:l}),p&&{scopedProperties:p}),d&&{sessionConfig:d}),N=i.cV.relay;b.addTrace(i.$I.subscribing_session_topic);try{await this.client.core.relayer.subscribe(I,{transportType:N})}catch(e){throw b.setError(i.U.subscribe_session_topic_failure),e}b.addTrace(i.$I.subscribe_session_topic_success);const A=R(x({},_),{topic:I,requiredNamespaces:w,optionalNamespaces:y,pairingTopic:g,acknowledged:!1,self:_.controller,peer:{publicKey:f.publicKey,metadata:f.metadata},controller:v,transportType:i.cV.relay});await this.client.session.set(I,A),b.addTrace(i.$I.store_session);try{b.addTrace(i.$I.publishing_session_settle),await this.sendRequest({topic:I,method:"wc_sessionSettle",params:_,throwOnFailedPublish:!0}).catch(e=>{throw b?.setError(i.U.session_settle_publish_failure),e}),b.addTrace(i.$I.session_settle_publish_success),b.addTrace(i.$I.publishing_session_approve),await this.sendResult({id:o,topic:g,result:{relay:{protocol:c??"irn"},responderPublicKey:v},throwOnFailedPublish:!0}).catch(e=>{throw b?.setError(i.U.session_approve_publish_failure),e}),b.addTrace(i.$I.session_approve_publish_success)}catch(e){throw this.client.logger.error(e),this.client.session.delete(I,(0,a.Hjj)("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(I),e}return this.client.core.eventClient.deleteEvent({eventId:b.eventId}),await this.client.core.pairing.updateMetadata({topic:g,metadata:f.metadata}),await this.client.proposal.delete(o,(0,a.Hjj)("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:g}),await this.setExpiry(I,(0,a.Xw0)(m)),{topic:I,acknowledged:()=>Promise.resolve(this.client.session.get(I))}}),U(this,"reject",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(e)}catch(e){throw this.client.logger.error("reject() -> isValidReject() failed"),e}const{id:t,reason:s}=e;let i;try{i=this.client.proposal.get(t).pairingTopic}catch(e){throw this.client.logger.error(`reject() -> proposal.get(${t}) failed`),e}i&&(await this.sendError({id:t,topic:i,error:s,rpcOpts:w.wc_sessionPropose.reject}),await this.client.proposal.delete(t,(0,a.Hjj)("USER_DISCONNECTED")))}),U(this,"update",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(e)}catch(e){throw this.client.logger.error("update() -> isValidUpdate() failed"),e}const{topic:t,namespaces:s}=e,{done:i,resolve:r,reject:n}=(0,a.Wx8)(),o=(0,l.payloadId)(),c=(0,l.getBigIntRpcId)().toString(),h=this.client.session.get(t).namespaces;return this.events.once((0,a.hEn)("session_update",o),({error:e})=>{e?n(e):r()}),await this.client.session.update(t,{namespaces:s}),await this.sendRequest({topic:t,method:"wc_sessionUpdate",params:{namespaces:s},throwOnFailedPublish:!0,clientRpcId:o,relayRpcId:c}).catch(e=>{this.client.logger.error(e),this.client.session.update(t,{namespaces:h}),n(e)}),{acknowledged:i}}),U(this,"extend",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(e)}catch(e){throw this.client.logger.error("extend() -> isValidExtend() failed"),e}const{topic:t}=e,s=(0,l.payloadId)(),{done:i,resolve:r,reject:n}=(0,a.Wx8)();return this.events.once((0,a.hEn)("session_extend",s),({error:e})=>{e?n(e):r()}),await this.setExpiry(t,(0,a.Xw0)(m)),this.sendRequest({topic:t,method:"wc_sessionExtend",params:{},clientRpcId:s,throwOnFailedPublish:!0}).catch(e=>{n(e)}),{acknowledged:i}}),U(this,"request",async e=>{this.isInitialized();try{await this.isValidRequest(e)}catch(e){throw this.client.logger.error("request() -> isValidRequest() failed"),e}const{chainId:t,request:s,topic:r,expiry:n=w.wc_sessionRequest.req.ttl}=e,o=this.client.session.get(r);o?.transportType===i.cV.relay&&await this.confirmOnlineStateOrThrow();const c=(0,l.payloadId)(),h=(0,l.getBigIntRpcId)().toString(),{done:p,resolve:d,reject:u}=(0,a.Wx8)(n,"Request expired. Please try again.");this.events.once((0,a.hEn)("session_request",c),({error:e,result:t})=>{e?u(e):d(t)});const f="wc_sessionRequest",m=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);if(m)return await this.sendRequest({clientRpcId:c,relayRpcId:h,topic:r,method:f,params:{request:R(x({},s),{expiryTimestamp:(0,a.Xw0)(n)}),chainId:t},expiry:n,throwOnFailedPublish:!0,appLink:m}).catch(e=>u(e)),this.client.events.emit("session_request_sent",{topic:r,request:s,chainId:t,id:c}),await p();const y={request:R(x({},s),{expiryTimestamp:(0,a.Xw0)(n)}),chainId:t},b=this.shouldSetTVF(f,y);return await Promise.all([new Promise(async e=>{await this.sendRequest(x({clientRpcId:c,relayRpcId:h,topic:r,method:f,params:y,expiry:n,throwOnFailedPublish:!0},b&&{tvf:this.getTVFParams(c,y)})).catch(e=>u(e)),this.client.events.emit("session_request_sent",{topic:r,request:s,chainId:t,id:c}),e()}),new Promise(async e=>{var t;if(null==(t=o.sessionConfig)||!t.disableDeepLink){const e=await(0,a.jTh)(this.client.core.storage,g);await(0,a.n3s)({id:c,topic:r,wcDeepLink:e})}e()}),p()]).then(e=>e[2])}),U(this,"respond",async e=>{this.isInitialized(),await this.isValidRespond(e);const{topic:t,response:s}=e,{id:r}=s,n=this.client.session.get(t);n.transportType===i.cV.relay&&await this.confirmOnlineStateOrThrow();const o=this.getAppLinkIfEnabled(n.peer.metadata,n.transportType);(0,l.isJsonRpcResult)(s)?await this.sendResult({id:r,topic:t,result:s.result,throwOnFailedPublish:!0,appLink:o}):(0,l.isJsonRpcError)(s)&&await this.sendError({id:r,topic:t,error:s.error,appLink:o}),this.cleanupAfterResponse(e)}),U(this,"ping",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(e)}catch(e){throw this.client.logger.error("ping() -> isValidPing() failed"),e}const{topic:t}=e;if(this.client.session.keys.includes(t)){const e=(0,l.payloadId)(),s=(0,l.getBigIntRpcId)().toString(),{done:i,resolve:r,reject:n}=(0,a.Wx8)();this.events.once((0,a.hEn)("session_ping",e),({error:e})=>{e?n(e):r()}),await Promise.all([this.sendRequest({topic:t,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:e,relayRpcId:s}),i()])}else this.client.core.pairing.pairings.keys.includes(t)&&(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:t}))}),U(this,"emit",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(e);const{topic:t,event:s,chainId:i}=e,r=(0,l.getBigIntRpcId)().toString(),n=(0,l.payloadId)();await this.sendRequest({topic:t,method:"wc_sessionEvent",params:{event:s,chainId:i},throwOnFailedPublish:!0,relayRpcId:r,clientRpcId:n})}),U(this,"disconnect",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(e);const{topic:t}=e;if(this.client.session.keys.includes(t))await this.sendRequest({topic:t,method:"wc_sessionDelete",params:(0,a.Hjj)("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:t,emitEvent:!1});else{if(!this.client.core.pairing.pairings.keys.includes(t)){const{message:e}=(0,a.GuA)("MISMATCHED_TOPIC",`Session or pairing topic not found: ${t}`);throw new Error(e)}await this.client.core.pairing.disconnect({topic:t})}}),U(this,"find",e=>(this.isInitialized(),this.client.session.getAll().filter(t=>(0,a.HNf)(t,e)))),U(this,"getPendingSessionRequests",()=>this.client.pendingRequest.getAll()),U(this,"authenticate",async(e,t)=>{var s;this.isInitialized(),this.isValidAuthenticate(e);const r=t&&this.client.core.linkModeSupportedApps.includes(t)&&(null==(s=this.client.metadata.redirect)?void 0:s.linkMode),n=r?i.cV.link_mode:i.cV.relay;n===i.cV.relay&&await this.confirmOnlineStateOrThrow();const{chains:o,statement:c="",uri:h,domain:p,nonce:d,type:u,exp:g,nbf:f,methods:y=[],expiry:b}=e,v=[...e.resources||[]],{topic:E,uri:I}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:n});this.client.logger.info({message:"Generated new pairing",pairing:{topic:E,uri:I}});const _=await this.client.core.crypto.generateKeyPair(),A=(0,a.EN$)(_);if(await Promise.all([this.client.auth.authKeys.set(N,{responseTopic:A,publicKey:_}),this.client.auth.pairingTopics.set(A,{topic:A,pairingTopic:E})]),await this.client.core.relayer.subscribe(A,{transportType:n}),this.client.logger.info(`sending request to new pairing topic: ${E}`),y.length>0){const{namespace:e}=(0,a._Yb)(o[0]);let t=(0,a.e8_)(e,"request",y);(0,a.VBM)(v)&&(t=(0,a.hVC)(t,v.pop())),v.push(t)}const C=b&&b>w.wc_sessionAuthenticate.req.ttl?b:w.wc_sessionAuthenticate.req.ttl,P={authPayload:{type:u??"caip122",chains:o,statement:c,aud:h,domain:p,version:"1",nonce:d,iat:(new Date).toISOString(),exp:g,nbf:f,resources:v},requester:{publicKey:_,metadata:this.client.metadata},expiryTimestamp:(0,a.Xw0)(C)},S={requiredNamespaces:{},optionalNamespaces:{eip155:{chains:o,methods:[...new Set(["personal_sign",...y])],events:["chainChanged","accountsChanged"]}},relays:[{protocol:"irn"}],pairingTopic:E,proposer:{publicKey:_,metadata:this.client.metadata},expiryTimestamp:(0,a.Xw0)(w.wc_sessionPropose.req.ttl),id:(0,l.payloadId)()},{done:O,resolve:T,reject:k}=(0,a.Wx8)(C,"Request expired"),U=(0,l.payloadId)(),D=(0,a.hEn)("session_connect",S.id),j=(0,a.hEn)("session_request",U),M=async({error:e,session:t})=>{this.events.off(j,L),e?k(e):t&&T({session:t})},L=async e=>{var s,r,o;if(await this.deletePendingAuthRequest(U,{message:"fulfilled",code:0}),e.error){const t=(0,a.Hjj)("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return e.error.code===t.code?void 0:(this.events.off(D,M),k(e.error.message))}await this.deleteProposal(S.id),this.events.off(D,M);const{cacaos:c,responder:h}=e.result,l=[],p=[];for(const e of c){await(0,a.IjX)({cacao:e,projectId:this.client.core.projectId})||(this.client.logger.error(e,"Signature verification failed"),k((0,a.Hjj)("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:t}=e,s=(0,a.VBM)(t.resources),i=[(0,a.xkc)(t.iss)],r=(0,a.q_h)(t.iss);if(s){const e=(0,a.sc_)(s),t=(0,a.WWN)(s);l.push(...e),i.push(...t)}for(const e of i)p.push(`${e}:${r}`)}const d=await this.client.core.crypto.generateSharedKey(_,h.publicKey);let u;l.length>0&&(u={topic:d,acknowledged:!0,self:{publicKey:_,metadata:this.client.metadata},peer:h,controller:h.publicKey,expiry:(0,a.Xw0)(m),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:E,namespaces:(0,a.Van)([...new Set(l)],[...new Set(p)]),transportType:n},await this.client.core.relayer.subscribe(d,{transportType:n}),await this.client.session.set(d,u),E&&await this.client.core.pairing.updateMetadata({topic:E,metadata:h.metadata}),u=this.client.session.get(d)),null!=(s=this.client.metadata.redirect)&&s.linkMode&&null!=(r=h.metadata.redirect)&&r.linkMode&&null!=(o=h.metadata.redirect)&&o.universal&&t&&(this.client.core.addLinkModeSupportedApp(h.metadata.redirect.universal),this.client.session.update(d,{transportType:i.cV.link_mode})),T({auths:c,session:u})};let q;this.events.once(D,M),this.events.once(j,L);try{if(r){const e=(0,l.formatJsonRpcRequest)("wc_sessionAuthenticate",P,U);this.client.core.history.set(E,e);const s=await this.client.core.crypto.encode("",e,{type:a.EHS,encoding:a.Pa8});q=(0,a.$Bq)(t,E,s)}else await Promise.all([this.sendRequest({topic:E,method:"wc_sessionAuthenticate",params:P,expiry:e.expiry,throwOnFailedPublish:!0,clientRpcId:U}),this.sendRequest({topic:E,method:"wc_sessionPropose",params:S,expiry:w.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:S.id})])}catch(e){throw this.events.off(D,M),this.events.off(j,L),e}return await this.setProposal(S.id,S),await this.setAuthRequest(U,{request:R(x({},P),{verifyContext:{}}),pairingTopic:E,transportType:n}),{uri:q??I,response:O}}),U(this,"approveSessionAuthenticate",async e=>{const{id:t,auths:s}=e,r=this.client.core.eventClient.createEvent({properties:{topic:t.toString(),trace:[i.U$.authenticated_session_approve_started]}});try{this.isInitialized()}catch(e){throw r.setError(i.Tn.no_internet_connection),e}const n=this.getPendingAuthRequest(t);if(!n)throw r.setError(i.Tn.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${t}`);const o=n.transportType||i.cV.relay;o===i.cV.relay&&await this.confirmOnlineStateOrThrow();const c=n.requester.publicKey,h=await this.client.core.crypto.generateKeyPair(),l=(0,a.EN$)(c),p={type:a.Lp_,receiverPublicKey:c,senderPublicKey:h},d=[],u=[];for(const e of s){if(!await(0,a.IjX)({cacao:e,projectId:this.client.core.projectId})){r.setError(i.Tn.invalid_cacao);const e=(0,a.Hjj)("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:t,topic:l,error:e,encodeOpts:p}),new Error(e.message)}r.addTrace(i.U$.cacaos_verified);const{p:s}=e,n=(0,a.VBM)(s.resources),o=[(0,a.xkc)(s.iss)],c=(0,a.q_h)(s.iss);if(n){const e=(0,a.sc_)(n),t=(0,a.WWN)(n);d.push(...e),o.push(...t)}for(const e of o)u.push(`${e}:${c}`)}const g=await this.client.core.crypto.generateSharedKey(h,c);let f;if(r.addTrace(i.U$.create_authenticated_session_topic),d?.length>0){f={topic:g,acknowledged:!0,self:{publicKey:h,metadata:this.client.metadata},peer:{publicKey:c,metadata:n.requester.metadata},controller:c,expiry:(0,a.Xw0)(m),authentication:s,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:n.pairingTopic,namespaces:(0,a.Van)([...new Set(d)],[...new Set(u)]),transportType:o},r.addTrace(i.U$.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(g,{transportType:o})}catch(e){throw r.setError(i.Tn.subscribe_authenticated_session_topic_failure),e}r.addTrace(i.U$.subscribe_authenticated_session_topic_success),await this.client.session.set(g,f),r.addTrace(i.U$.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:n.pairingTopic,metadata:n.requester.metadata})}r.addTrace(i.U$.publishing_authenticated_session_approve);try{await this.sendResult({topic:l,id:t,result:{cacaos:s,responder:{publicKey:h,metadata:this.client.metadata}},encodeOpts:p,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(n.requester.metadata,o)})}catch(e){throw r.setError(i.Tn.authenticated_session_approve_publish_failure),e}return await this.client.auth.requests.delete(t,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:n.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:r.eventId}),{session:f}}),U(this,"rejectSessionAuthenticate",async e=>{this.isInitialized();const{id:t,reason:s}=e,r=this.getPendingAuthRequest(t);if(!r)throw new Error(`Could not find pending auth request with id ${t}`);r.transportType===i.cV.relay&&await this.confirmOnlineStateOrThrow();const n=r.requester.publicKey,o=await this.client.core.crypto.generateKeyPair(),c=(0,a.EN$)(n),h={type:a.Lp_,receiverPublicKey:n,senderPublicKey:o};await this.sendError({id:t,topic:c,error:s,encodeOpts:h,rpcOpts:w.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(r.requester.metadata,r.transportType)}),await this.client.auth.requests.delete(t,{message:"rejected",code:0}),await this.client.proposal.delete(t,(0,a.Hjj)("USER_DISCONNECTED"))}),U(this,"formatAuthMessage",e=>{this.isInitialized();const{request:t,iss:s}=e;return(0,a.hwK)(t,s)}),U(this,"processRelayMessageCache",()=>{setTimeout(async()=>{if(0!==this.relayMessageCache.length)for(;this.relayMessageCache.length>0;)try{const e=this.relayMessageCache.shift();e&&await this.onRelayMessage(e)}catch(e){this.client.logger.error(e)}},50)}),U(this,"cleanupDuplicatePairings",async e=>{if(e.pairingTopic)try{const t=this.client.core.pairing.pairings.get(e.pairingTopic),s=this.client.core.pairing.pairings.getAll().filter(s=>{var i,r;return(null==(i=s.peerMetadata)?void 0:i.url)&&(null==(r=s.peerMetadata)?void 0:r.url)===e.peer.metadata.url&&s.topic&&s.topic!==t.topic});if(0===s.length)return;this.client.logger.info(`Cleaning up ${s.length} duplicate pairing(s)`),await Promise.all(s.map(e=>this.client.core.pairing.disconnect({topic:e.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(e){this.client.logger.error(e)}}),U(this,"deleteSession",async e=>{var t;const{topic:s,expirerHasDeleted:i=!1,emitEvent:r=!0,id:n=0}=e,{self:o}=this.client.session.get(s);await this.client.core.relayer.unsubscribe(s),await this.client.session.delete(s,(0,a.Hjj)("USER_DISCONNECTED")),this.addToRecentlyDeleted(s,"session"),this.client.core.crypto.keychain.has(o.publicKey)&&await this.client.core.crypto.deleteKeyPair(o.publicKey),this.client.core.crypto.keychain.has(s)&&await this.client.core.crypto.deleteSymKey(s),i||this.client.core.expirer.del(s),this.client.core.storage.removeItem(g).catch(e=>this.client.logger.warn(e)),this.getPendingSessionRequests().forEach(e=>{e.topic===s&&this.deletePendingSessionRequest(e.id,(0,a.Hjj)("USER_DISCONNECTED"))}),s===(null==(t=this.sessionRequestQueue.queue[0])?void 0:t.topic)&&(this.sessionRequestQueue.state=b),r&&this.client.events.emit("session_delete",{id:n,topic:s})}),U(this,"deleteProposal",async(e,t)=>{if(t)try{const t=this.client.proposal.get(e),s=this.client.core.eventClient.getEvent({topic:t.pairingTopic});s?.setError(i.U.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(e,(0,a.Hjj)("USER_DISCONNECTED")),t?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"proposal")}),U(this,"deletePendingSessionRequest",async(e,t,s=!1)=>{await Promise.all([this.client.pendingRequest.delete(e,t),s?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(t=>t.id!==e),s&&(this.sessionRequestQueue.state=b,this.client.events.emit("session_request_expire",{id:e}))}),U(this,"deletePendingAuthRequest",async(e,t,s=!1)=>{await Promise.all([this.client.auth.requests.delete(e,t),s?Promise.resolve():this.client.core.expirer.del(e)])}),U(this,"setExpiry",async(e,t)=>{this.client.session.keys.includes(e)&&(this.client.core.expirer.set(e,t),await this.client.session.update(e,{expiry:t}))}),U(this,"setProposal",async(e,t)=>{this.client.core.expirer.set(e,(0,a.Xw0)(w.wc_sessionPropose.req.ttl)),await this.client.proposal.set(e,t)}),U(this,"setAuthRequest",async(e,t)=>{const{request:s,pairingTopic:r,transportType:n=i.cV.relay}=t;this.client.core.expirer.set(e,s.expiryTimestamp),await this.client.auth.requests.set(e,{authPayload:s.authPayload,requester:s.requester,expiryTimestamp:s.expiryTimestamp,id:e,pairingTopic:r,verifyContext:s.verifyContext,transportType:n})}),U(this,"setPendingSessionRequest",async e=>{const{id:t,topic:s,params:i,verifyContext:r}=e,n=i.request.expiryTimestamp||(0,a.Xw0)(w.wc_sessionRequest.req.ttl);this.client.core.expirer.set(t,n),await this.client.pendingRequest.set(t,{id:t,topic:s,params:i,verifyContext:r})}),U(this,"sendRequest",async e=>{const{topic:t,method:i,params:r,expiry:n,relayRpcId:o,clientRpcId:c,throwOnFailedPublish:h,appLink:p,tvf:d}=e,u=(0,l.formatJsonRpcRequest)(i,r,c);let g;const f=!!p;try{const e=f?a.Pa8:a.EWt;g=await this.client.core.crypto.encode(t,u,{encoding:e})}catch(e){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${t} failed`),e}let m;if(I.includes(i)){const e=(0,a.ALl)(JSON.stringify(u)),t=(0,a.ALl)(g);m=await this.client.core.verify.register({id:t,decryptedId:e})}const y=w[i].req;if(y.attestation=m,n&&(y.ttl=n),o&&(y.id=o),this.client.core.history.set(t,u),f){const e=(0,a.$Bq)(p,t,g);await s.g.Linking.openURL(e,this.client.name)}else{const e=w[i].req;n&&(e.ttl=n),o&&(e.id=o),e.tvf=R(x({},d),{correlationId:u.id}),h?(e.internal=R(x({},e.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(t,g,e)):this.client.core.relayer.publish(t,g,e).catch(e=>this.client.logger.error(e))}return u.id}),U(this,"sendResult",async e=>{const{id:t,topic:i,result:r,throwOnFailedPublish:n,encodeOpts:o,appLink:c}=e,h=(0,l.formatJsonRpcResult)(t,r);let p;const d=c&&typeof(null==s.g?void 0:s.g.Linking)<"u";try{const e=d?a.Pa8:a.EWt;p=await this.client.core.crypto.encode(i,h,R(x({},o||{}),{encoding:e}))}catch(e){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${i} failed`),e}let u,g;try{u=await this.client.core.history.get(i,t);const e=u.request;try{this.shouldSetTVF(e.method,e.params)&&(g=this.getTVFParams(t,e.params,r))}catch(e){this.client.logger.warn("sendResult() -> getTVFParams() failed",e)}}catch(e){throw this.client.logger.error(`sendResult() -> history.get(${i}, ${t}) failed`),e}if(d){const e=(0,a.$Bq)(c,i,p);await s.g.Linking.openURL(e,this.client.name)}else{const e=u.request.method,s=w[e].res;s.tvf=R(x({},g),{correlationId:t}),n?(s.internal=R(x({},s.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,p,s)):this.client.core.relayer.publish(i,p,s).catch(e=>this.client.logger.error(e))}await this.client.core.history.resolve(h)}),U(this,"sendError",async e=>{const{id:t,topic:i,error:r,encodeOpts:n,rpcOpts:o,appLink:c}=e,h=(0,l.formatJsonRpcError)(t,r);let p;const d=c&&typeof(null==s.g?void 0:s.g.Linking)<"u";try{const e=d?a.Pa8:a.EWt;p=await this.client.core.crypto.encode(i,h,R(x({},n||{}),{encoding:e}))}catch(e){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${i} failed`),e}let u;try{u=await this.client.core.history.get(i,t)}catch(e){throw this.client.logger.error(`sendError() -> history.get(${i}, ${t}) failed`),e}if(d){const e=(0,a.$Bq)(c,i,p);await s.g.Linking.openURL(e,this.client.name)}else{const e=u.request.method,t=o||w[e].res;this.client.core.relayer.publish(i,p,t)}await this.client.core.history.resolve(h)}),U(this,"cleanup",async()=>{const e=[],t=[];this.client.session.getAll().forEach(t=>{let s=!1;(0,a._dF)(t.expiry)&&(s=!0),this.client.core.crypto.keychain.has(t.topic)||(s=!0),s&&e.push(t.topic)}),this.client.proposal.getAll().forEach(e=>{(0,a._dF)(e.expiryTimestamp)&&t.push(e.id)}),await Promise.all([...e.map(e=>this.deleteSession({topic:e})),...t.map(e=>this.deleteProposal(e))])}),U(this,"onProviderMessageEvent",async e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):await this.onRelayMessage(e)}),U(this,"onRelayEventRequest",async e=>{this.requestQueue.queue.push(e),await this.processRequestsQueue()}),U(this,"processRequestsQueue",async()=>{if(this.requestQueue.state!==v){for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=v;const e=this.requestQueue.queue.shift();if(e)try{await this.processRequest(e)}catch(e){this.client.logger.warn(e)}}this.requestQueue.state=b}else this.client.logger.info("Request queue already active, skipping...")}),U(this,"processRequest",async e=>{const{topic:t,payload:s,attestation:i,transportType:r,encryptedId:n}=e,o=s.method;if(!this.shouldIgnorePairingRequest({topic:t,requestMethod:o}))switch(o){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:t,payload:s,attestation:i,encryptedId:n});case"wc_sessionSettle":return await this.onSessionSettleRequest(t,s);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(t,s);case"wc_sessionExtend":return await this.onSessionExtendRequest(t,s);case"wc_sessionPing":return await this.onSessionPingRequest(t,s);case"wc_sessionDelete":return await this.onSessionDeleteRequest(t,s);case"wc_sessionRequest":return await this.onSessionRequest({topic:t,payload:s,attestation:i,encryptedId:n,transportType:r});case"wc_sessionEvent":return await this.onSessionEventRequest(t,s);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:t,payload:s,attestation:i,encryptedId:n,transportType:r});default:return this.client.logger.info(`Unsupported request method ${o}`)}}),U(this,"onRelayEventResponse",async e=>{const{topic:t,payload:s,transportType:i}=e,r=(await this.client.core.history.get(t,s.id)).request.method;switch(r){case"wc_sessionPropose":return this.onSessionProposeResponse(t,s,i);case"wc_sessionSettle":return this.onSessionSettleResponse(t,s);case"wc_sessionUpdate":return this.onSessionUpdateResponse(t,s);case"wc_sessionExtend":return this.onSessionExtendResponse(t,s);case"wc_sessionPing":return this.onSessionPingResponse(t,s);case"wc_sessionRequest":return this.onSessionRequestResponse(t,s);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(t,s);default:return this.client.logger.info(`Unsupported response method ${r}`)}}),U(this,"onRelayEventUnknownPayload",e=>{const{topic:t}=e,{message:s}=(0,a.GuA)("MISSING_OR_INVALID",`Decoded payload on topic ${t} is not identifiable as a JSON-RPC request or a response.`);throw new Error(s)}),U(this,"shouldIgnorePairingRequest",e=>{const{topic:t,requestMethod:s}=e,i=this.expectedPairingMethodMap.get(t);return!(!i||i.includes(s)||!(i.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0))}),U(this,"onSessionProposeRequest",async e=>{const{topic:t,payload:s,attestation:r,encryptedId:n}=e,{params:o,id:c}=s;try{const e=this.client.core.eventClient.getEvent({topic:t});0===this.client.events.listenerCount("session_proposal")&&(console.warn("No listener for session_proposal event"),e?.setError(i.S$.proposal_listener_not_found)),this.isValidConnect(x({},s.params));const h=o.expiryTimestamp||(0,a.Xw0)(w.wc_sessionPropose.req.ttl),l=x({id:c,pairingTopic:t,expiryTimestamp:h},o);await this.setProposal(c,l);const p=await this.getVerifyContext({attestationId:r,hash:(0,a.ALl)(JSON.stringify(s)),encryptedId:n,metadata:l.proposer.metadata});e?.addTrace(i.$w.emit_session_proposal),this.client.events.emit("session_proposal",{id:c,params:l,verifyContext:p})}catch(e){await this.sendError({id:c,topic:t,error:e,rpcOpts:w.wc_sessionPropose.autoReject}),this.client.logger.error(e)}}),U(this,"onSessionProposeResponse",async(e,t,s)=>{const{id:i}=t;if((0,l.isJsonRpcResult)(t)){const{result:r}=t;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:r});const n=this.client.proposal.get(i);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:n});const o=n.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:o});const a=r.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:a});const c=await this.client.core.crypto.generateSharedKey(o,a);this.pendingSessions.set(i,{sessionTopic:c,pairingTopic:e,proposalId:i,publicKey:o});const h=await this.client.core.relayer.subscribe(c,{transportType:s});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:h}),await this.client.core.pairing.activate({topic:e})}else if((0,l.isJsonRpcError)(t)){await this.client.proposal.delete(i,(0,a.Hjj)("USER_DISCONNECTED"));const e=(0,a.hEn)("session_connect",i);if(0===this.events.listenerCount(e))throw new Error(`emitting ${e} without any listeners, 954`);this.events.emit(e,{error:t.error})}}),U(this,"onSessionSettleRequest",async(e,t)=>{const{id:s,params:r}=t;try{this.isValidSessionSettleRequest(r);const{relay:s,controller:n,expiry:o,namespaces:c,sessionProperties:h,scopedProperties:l,sessionConfig:p}=t.params,d=[...this.pendingSessions.values()].find(t=>t.sessionTopic===e);if(!d)return this.client.logger.error(`Pending session not found for topic ${e}`);const u=this.client.proposal.get(d.proposalId),g=R(x(x(x({topic:e,relay:s,expiry:o,namespaces:c,acknowledged:!0,pairingTopic:d.pairingTopic,requiredNamespaces:u.requiredNamespaces,optionalNamespaces:u.optionalNamespaces,controller:n.publicKey,self:{publicKey:d.publicKey,metadata:this.client.metadata},peer:{publicKey:n.publicKey,metadata:n.metadata}},h&&{sessionProperties:h}),l&&{scopedProperties:l}),p&&{sessionConfig:p}),{transportType:i.cV.relay});await this.client.session.set(g.topic,g),await this.setExpiry(g.topic,g.expiry),await this.client.core.pairing.updateMetadata({topic:d.pairingTopic,metadata:g.peer.metadata}),this.client.events.emit("session_connect",{session:g}),this.events.emit((0,a.hEn)("session_connect",d.proposalId),{session:g}),this.pendingSessions.delete(d.proposalId),this.deleteProposal(d.proposalId,!1),this.cleanupDuplicatePairings(g),await this.sendResult({id:t.id,topic:e,result:!0,throwOnFailedPublish:!0})}catch(t){await this.sendError({id:s,topic:e,error:t}),this.client.logger.error(t)}}),U(this,"onSessionSettleResponse",async(e,t)=>{const{id:s}=t;(0,l.isJsonRpcResult)(t)?(await this.client.session.update(e,{acknowledged:!0}),this.events.emit((0,a.hEn)("session_approve",s),{})):(0,l.isJsonRpcError)(t)&&(await this.client.session.delete(e,(0,a.Hjj)("USER_DISCONNECTED")),this.events.emit((0,a.hEn)("session_approve",s),{error:t.error}))}),U(this,"onSessionUpdateRequest",async(e,t)=>{const{params:s,id:i}=t;try{const t=`${e}_session_update`,r=a.nyL.get(t);if(r&&this.isRequestOutOfSync(r,i))return this.client.logger.warn(`Discarding out of sync request - ${i}`),void this.sendError({id:i,topic:e,error:(0,a.Hjj)("INVALID_UPDATE_REQUEST")});this.isValidUpdate(x({topic:e},s));try{a.nyL.set(t,i),await this.client.session.update(e,{namespaces:s.namespaces}),await this.sendResult({id:i,topic:e,result:!0,throwOnFailedPublish:!0})}catch(e){throw a.nyL.delete(t),e}this.client.events.emit("session_update",{id:i,topic:e,params:s})}catch(t){await this.sendError({id:i,topic:e,error:t}),this.client.logger.error(t)}}),U(this,"isRequestOutOfSync",(e,t)=>t.toString().slice(0,-3)<e.toString().slice(0,-3)),U(this,"onSessionUpdateResponse",(e,t)=>{const{id:s}=t,i=(0,a.hEn)("session_update",s);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);(0,l.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_update",s),{}):(0,l.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_update",s),{error:t.error})}),U(this,"onSessionExtendRequest",async(e,t)=>{const{id:s}=t;try{this.isValidExtend({topic:e}),await this.setExpiry(e,(0,a.Xw0)(m)),await this.sendResult({id:s,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:s,topic:e})}catch(t){await this.sendError({id:s,topic:e,error:t}),this.client.logger.error(t)}}),U(this,"onSessionExtendResponse",(e,t)=>{const{id:s}=t,i=(0,a.hEn)("session_extend",s);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);(0,l.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_extend",s),{}):(0,l.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_extend",s),{error:t.error})}),U(this,"onSessionPingRequest",async(e,t)=>{const{id:s}=t;try{this.isValidPing({topic:e}),await this.sendResult({id:s,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:s,topic:e})}catch(t){await this.sendError({id:s,topic:e,error:t}),this.client.logger.error(t)}}),U(this,"onSessionPingResponse",(e,t)=>{const{id:s}=t,i=(0,a.hEn)("session_ping",s);setTimeout(()=>{if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners 2176`);(0,l.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_ping",s),{}):(0,l.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_ping",s),{error:t.error})},500)}),U(this,"onSessionDeleteRequest",async(e,t)=>{const{id:s}=t;try{this.isValidDisconnect({topic:e,reason:t.params}),Promise.all([new Promise(t=>{this.client.core.relayer.once(i.Jf.publish,async()=>{t(await this.deleteSession({topic:e,id:s}))})}),this.sendResult({id:s,topic:e,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:e,error:(0,a.Hjj)("USER_DISCONNECTED")})]).catch(e=>this.client.logger.error(e))}catch(e){this.client.logger.error(e)}}),U(this,"onSessionRequest",async e=>{var t,s,r;const{topic:n,payload:o,attestation:c,encryptedId:h,transportType:p}=e,{id:d,params:u}=o;try{await this.isValidRequest(x({topic:n},u));const e=this.client.session.get(n),o={id:d,topic:n,params:u,verifyContext:await this.getVerifyContext({attestationId:c,hash:(0,a.ALl)(JSON.stringify((0,l.formatJsonRpcRequest)("wc_sessionRequest",u,d))),encryptedId:h,metadata:e.peer.metadata,transportType:p})};await this.setPendingSessionRequest(o),p===i.cV.link_mode&&null!=(t=e.peer.metadata.redirect)&&t.universal&&this.client.core.addLinkModeSupportedApp(null==(s=e.peer.metadata.redirect)?void 0:s.universal),null!=(r=this.client.signConfig)&&r.disableRequestQueue?this.emitSessionRequest(o):(this.addSessionRequestToSessionRequestQueue(o),this.processSessionRequestQueue())}catch(e){await this.sendError({id:d,topic:n,error:e}),this.client.logger.error(e)}}),U(this,"onSessionRequestResponse",(e,t)=>{const{id:s}=t,i=(0,a.hEn)("session_request",s);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);(0,l.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_request",s),{result:t.result}):(0,l.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_request",s),{error:t.error})}),U(this,"onSessionEventRequest",async(e,t)=>{const{id:s,params:i}=t;try{const t=`${e}_session_event_${i.event.name}`,r=a.nyL.get(t);if(r&&this.isRequestOutOfSync(r,s))return void this.client.logger.info(`Discarding out of sync request - ${s}`);this.isValidEmit(x({topic:e},i)),this.client.events.emit("session_event",{id:s,topic:e,params:i}),a.nyL.set(t,s)}catch(t){await this.sendError({id:s,topic:e,error:t}),this.client.logger.error(t)}}),U(this,"onSessionAuthenticateResponse",(e,t)=>{const{id:s}=t;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:e,payload:t}),(0,l.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_request",s),{result:t.result}):(0,l.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_request",s),{error:t.error})}),U(this,"onSessionAuthenticateRequest",async e=>{var t;const{topic:s,payload:r,attestation:n,encryptedId:o,transportType:c}=e;try{const{requester:e,authPayload:h,expiryTimestamp:l}=r.params,p=await this.getVerifyContext({attestationId:n,hash:(0,a.ALl)(JSON.stringify(r)),encryptedId:o,metadata:e.metadata,transportType:c}),d={requester:e,pairingTopic:s,id:r.id,authPayload:h,verifyContext:p,expiryTimestamp:l};await this.setAuthRequest(r.id,{request:d,pairingTopic:s,transportType:c}),c===i.cV.link_mode&&null!=(t=e.metadata.redirect)&&t.universal&&this.client.core.addLinkModeSupportedApp(e.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:s,params:r.params,id:r.id,verifyContext:p})}catch(e){this.client.logger.error(e);const t=r.params.requester.publicKey,i=await this.client.core.crypto.generateKeyPair(),n=this.getAppLinkIfEnabled(r.params.requester.metadata,c),o={type:a.Lp_,receiverPublicKey:t,senderPublicKey:i};await this.sendError({id:r.id,topic:s,error:e,encodeOpts:o,rpcOpts:w.wc_sessionAuthenticate.autoReject,appLink:n})}}),U(this,"addSessionRequestToSessionRequestQueue",e=>{this.sessionRequestQueue.queue.push(e)}),U(this,"cleanupAfterResponse",e=>{this.deletePendingSessionRequest(e.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=b,this.processSessionRequestQueue()},(0,o.toMiliseconds)(this.requestQueueDelay))}),U(this,"cleanupPendingSentRequestsForTopic",({topic:e,error:t})=>{const s=this.client.core.history.pending;s.length>0&&s.filter(t=>t.topic===e&&"wc_sessionRequest"===t.request.method).forEach(e=>{const s=e.request.id,i=(0,a.hEn)("session_request",s);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);this.events.emit((0,a.hEn)("session_request",e.request.id),{error:t})})}),U(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===v)return void this.client.logger.info("session request queue is already active.");const e=this.sessionRequestQueue.queue[0];if(e)try{this.sessionRequestQueue.state=v,this.emitSessionRequest(e)}catch(e){this.client.logger.error(e)}else this.client.logger.info("session request queue is empty.")}),U(this,"emitSessionRequest",e=>{this.client.events.emit("session_request",e)}),U(this,"onPairingCreated",e=>{if(e.methods&&this.expectedPairingMethodMap.set(e.topic,e.methods),e.active)return;const t=this.client.proposal.getAll().find(t=>t.pairingTopic===e.topic);t&&this.onSessionProposeRequest({topic:e.topic,payload:(0,l.formatJsonRpcRequest)("wc_sessionPropose",R(x({},t),{requiredNamespaces:t.requiredNamespaces,optionalNamespaces:t.optionalNamespaces,relays:t.relays,proposer:t.proposer,sessionProperties:t.sessionProperties,scopedProperties:t.scopedProperties}),t.id)})}),U(this,"isValidConnect",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(e)}`);throw new Error(t)}const{pairingTopic:t,requiredNamespaces:s,optionalNamespaces:i,sessionProperties:r,scopedProperties:n,relays:o}=e;if((0,a.b07)(t)||await this.isValidPairingTopic(t),!(0,a.V9G)(o,!0)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`connect() relays: ${o}`);throw new Error(e)}if(!(0,a.b07)(s)&&0!==(0,a.aF0)(s)&&this.validateNamespaces(s,"requiredNamespaces"),!(0,a.b07)(i)&&0!==(0,a.aF0)(i)&&this.validateNamespaces(i,"optionalNamespaces"),(0,a.b07)(r)||this.validateSessionProps(r,"sessionProperties"),!(0,a.b07)(n)){this.validateSessionProps(n,"scopedProperties");const e=Object.keys(s||{}).concat(Object.keys(i||{}));if(!Object.keys(n).every(t=>e.includes(t)))throw new Error(`Scoped properties must be a subset of required/optional namespaces, received: ${JSON.stringify(n)}, required/optional namespaces: ${JSON.stringify(e)}`)}}),U(this,"validateNamespaces",(e,t)=>{const s=(0,a.esh)(e,"connect()",t);if(s)throw new Error(s.message)}),U(this,"isValidApprove",async e=>{if(!(0,a.TeY)(e))throw new Error((0,a.GuA)("MISSING_OR_INVALID",`approve() params: ${e}`).message);const{id:t,namespaces:s,relayProtocol:i,sessionProperties:r,scopedProperties:n}=e;this.checkRecentlyDeleted(t),await this.isValidProposalId(t);const o=this.client.proposal.get(t),c=(0,a.FiO)(s,"approve()");if(c)throw new Error(c.message);const h=(0,a.XqR)(o.requiredNamespaces,s,"approve()");if(h)throw new Error(h.message);if(!(0,a.Qhg)(i,!0)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`approve() relayProtocol: ${i}`);throw new Error(e)}if((0,a.b07)(r)||this.validateSessionProps(r,"sessionProperties"),!(0,a.b07)(n)){this.validateSessionProps(n,"scopedProperties");const e=new Set(Object.keys(s));if(!Object.keys(n).every(t=>e.has(t)))throw new Error(`Scoped properties must be a subset of approved namespaces, received: ${JSON.stringify(n)}, approved namespaces: ${Array.from(e).join(", ")}`)}}),U(this,"isValidReject",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`reject() params: ${e}`);throw new Error(t)}const{id:t,reason:s}=e;if(this.checkRecentlyDeleted(t),await this.isValidProposalId(t),!(0,a.X3c)(s)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(s)}`);throw new Error(e)}}),U(this,"isValidSessionSettleRequest",e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${e}`);throw new Error(t)}const{relay:t,controller:s,namespaces:i,expiry:r}=e;if(!(0,a.kuU)(t)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(e)}const n=(0,a.tk0)(s,"onSessionSettleRequest()");if(n)throw new Error(n.message);const o=(0,a.FiO)(i,"onSessionSettleRequest()");if(o)throw new Error(o.message);if((0,a._dF)(r)){const{message:e}=(0,a.GuA)("EXPIRED","onSessionSettleRequest()");throw new Error(e)}}),U(this,"isValidUpdate",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`update() params: ${e}`);throw new Error(t)}const{topic:t,namespaces:s}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t);const i=this.client.session.get(t),r=(0,a.FiO)(s,"update()");if(r)throw new Error(r.message);const n=(0,a.XqR)(i.requiredNamespaces,s,"update()");if(n)throw new Error(n.message)}),U(this,"isValidExtend",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`extend() params: ${e}`);throw new Error(t)}const{topic:t}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t)}),U(this,"isValidRequest",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`request() params: ${e}`);throw new Error(t)}const{topic:t,request:s,chainId:i,expiry:r}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t);const{namespaces:n}=this.client.session.get(t);if(!(0,a.tLy)(n,i)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() chainId: ${i}`);throw new Error(e)}if(!(0,a.iV1)(s)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() ${JSON.stringify(s)}`);throw new Error(e)}if(!(0,a.oKp)(n,i,s.method)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() method: ${s.method}`);throw new Error(e)}if(r&&!(0,a.Hbs)(r,y)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() expiry: ${r}. Expiry must be a number (in seconds) between ${y.min} and ${y.max}`);throw new Error(e)}}),U(this,"isValidRespond",async e=>{var t;if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`respond() params: ${e}`);throw new Error(t)}const{topic:s,response:i}=e;try{await this.isValidSessionTopic(s)}catch(s){throw null!=(t=e?.response)&&t.id&&this.cleanupAfterResponse(e),s}if(!(0,a.M8n)(i)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(i)}`);throw new Error(e)}}),U(this,"isValidPing",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)}),U(this,"isValidEmit",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`emit() params: ${e}`);throw new Error(t)}const{topic:t,event:s,chainId:i}=e;await this.isValidSessionTopic(t);const{namespaces:r}=this.client.session.get(t);if(!(0,a.tLy)(r,i)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`emit() chainId: ${i}`);throw new Error(e)}if(!(0,a.FR8)(s)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(e)}if(!(0,a.z2N)(r,i,s.name)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(e)}}),U(this,"isValidDisconnect",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)}),U(this,"isValidAuthenticate",e=>{const{chains:t,uri:s,domain:i,nonce:r}=e;if(!Array.isArray(t)||0===t.length)throw new Error("chains is required and must be a non-empty array");if(!(0,a.Qhg)(s,!1))throw new Error("uri is required parameter");if(!(0,a.Qhg)(i,!1))throw new Error("domain is required parameter");if(!(0,a.Qhg)(r,!1))throw new Error("nonce is required parameter");if([...new Set(t.map(e=>(0,a._Yb)(e).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:n}=(0,a._Yb)(t[0]);if("eip155"!==n)throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),U(this,"getVerifyContext",async e=>{const{attestationId:t,hash:s,encryptedId:r,metadata:n,transportType:o}=e,a={verified:{verifyUrl:n.verifyUrl||i.WB,validation:"UNKNOWN",origin:n.url||""}};try{if(o===i.cV.link_mode){const e=this.getAppLinkIfEnabled(n,o);return a.verified.validation=e&&new URL(e).origin===new URL(n.url).origin?"VALID":"INVALID",a}const e=await this.client.core.verify.resolve({attestationId:t,hash:s,encryptedId:r,verifyUrl:n.verifyUrl});e&&(a.verified.origin=e.origin,a.verified.isScam=e.isScam,a.verified.validation=e.origin===new URL(n.url).origin?"VALID":"INVALID")}catch(e){this.client.logger.warn(e)}return this.client.logger.debug(`Verify context: ${JSON.stringify(a)}`),a}),U(this,"validateSessionProps",(e,t)=>{Object.values(e).forEach((s,i)=>{if(null==s){const{message:r}=(0,a.GuA)("MISSING_OR_INVALID",`${t} must contain an existing value for each key. Received: ${s} for key ${Object.keys(e)[i]}`);throw new Error(r)}})}),U(this,"getPendingAuthRequest",e=>{const t=this.client.auth.requests.get(e);return"object"==typeof t?t:void 0}),U(this,"addToRecentlyDeleted",(e,t)=>{if(this.recentlyDeletedMap.set(e,t),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let e=0;const t=this.recentlyDeletedLimit/2;for(const s of this.recentlyDeletedMap.keys()){if(e++>=t)break;this.recentlyDeletedMap.delete(s)}}}),U(this,"checkRecentlyDeleted",e=>{const t=this.recentlyDeletedMap.get(e);if(t){const{message:s}=(0,a.GuA)("MISSING_OR_INVALID",`Record was recently deleted - ${t}: ${e}`);throw new Error(s)}}),U(this,"isLinkModeEnabled",(e,t)=>{var r,n,o,a,c,h,l,p,d;return!(!e||t!==i.cV.link_mode)&&!0===(null==(n=null==(r=this.client.metadata)?void 0:r.redirect)?void 0:n.linkMode)&&void 0!==(null==(a=null==(o=this.client.metadata)?void 0:o.redirect)?void 0:a.universal)&&""!==(null==(h=null==(c=this.client.metadata)?void 0:c.redirect)?void 0:h.universal)&&void 0!==(null==(l=e?.redirect)?void 0:l.universal)&&""!==(null==(p=e?.redirect)?void 0:p.universal)&&!0===(null==(d=e?.redirect)?void 0:d.linkMode)&&this.client.core.linkModeSupportedApps.includes(e.redirect.universal)&&typeof(null==s.g?void 0:s.g.Linking)<"u"}),U(this,"getAppLinkIfEnabled",(e,t)=>{var s;return this.isLinkModeEnabled(e,t)?null==(s=e?.redirect)?void 0:s.universal:void 0}),U(this,"handleLinkModeMessage",({url:e})=>{if(!e||!e.includes("wc_ev")||!e.includes("topic"))return;const t=(0,a.$hI)(e,"topic")||"",s=decodeURIComponent((0,a.$hI)(e,"wc_ev")||""),r=this.client.session.keys.includes(t);r&&this.client.session.update(t,{transportType:i.cV.link_mode}),this.client.core.dispatchEnvelope({topic:t,message:s,sessionExists:r})}),U(this,"registerLinkModeListeners",async()=>{var e;if((0,a.w8K)()||(0,a.lVv)()&&null!=(e=this.client.metadata.redirect)&&e.linkMode){const e=null==s.g?void 0:s.g.Linking;if(typeof e<"u"){e.addEventListener("url",this.handleLinkModeMessage,this.client.name);const t=await e.getInitialURL();t&&setTimeout(()=>{this.handleLinkModeMessage({url:t})},50)}}}),U(this,"shouldSetTVF",(e,t)=>{if(!t||"wc_sessionRequest"!==e)return!1;const{request:s}=t;return Object.keys(E).includes(s.method)}),U(this,"getTVFParams",(e,t,s)=>{var i,r;try{const n=t.request.method,o=this.extractTxHashesFromResult(n,s);return R(x({correlationId:e,rpcMethods:[n],chainId:t.chainId},this.isValidContractData(t.request.params)&&{contractAddresses:[null==(r=null==(i=t.request.params)?void 0:i[0])?void 0:r.to]}),{txHashes:o})}catch(e){this.client.logger.warn("Error getting TVF params",e)}return{}}),U(this,"isValidContractData",e=>{var t;if(!e)return!1;try{const s=e?.data||(null==(t=e?.[0])?void 0:t.data);if(!s.startsWith("0x"))return!1;const i=s.slice(2);return!!/^[0-9a-fA-F]*$/.test(i)&&i.length%2==0}catch{}return!1}),U(this,"extractTxHashesFromResult",(e,t)=>{try{if("string"==typeof t)return[t];const s=t[E[e].key];if((0,a.OP1)(s))return"solana_signAllTransactions"===e?s.map(e=>(0,a.PAk)(e)):s;if("string"==typeof s)return[s]}catch(e){this.client.logger.warn("Error extracting tx hashes from result",e)}return[]})}async processPendingMessageEvents(){try{const e=this.client.session.keys,t=this.client.core.relayer.messages.getWithoutAck(e);for(const[e,s]of Object.entries(t))for(const t of s)try{await this.onProviderMessageEvent({topic:e,message:t,publishedAt:Date.now()})}catch{this.client.logger.warn(`Error processing pending message event for topic: ${e}, message: ${t}`)}}catch(e){this.client.logger.warn("processPendingMessageEvents failed",e)}}isInitialized(){if(!this.initialized){const{message:e}=(0,a.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(i.Jf.message,e=>{this.onProviderMessageEvent(e)})}async onRelayMessage(e){const{topic:t,message:s,attestation:r,transportType:n}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(N)?this.client.auth.authKeys.get(N):{responseTopic:void 0,publicKey:void 0};try{const e=await this.client.core.crypto.decode(t,s,{receiverPublicKey:o,encoding:n===i.cV.link_mode?a.Pa8:a.EWt});(0,l.isJsonRpcRequest)(e)?(this.client.core.history.set(t,e),await this.onRelayEventRequest({topic:t,payload:e,attestation:r,transportType:n,encryptedId:(0,a.ALl)(s)})):(0,l.isJsonRpcResponse)(e)?(await this.client.core.history.resolve(e),await this.onRelayEventResponse({topic:t,payload:e,transportType:n}),this.client.core.history.delete(t,e.id)):await this.onRelayEventUnknownPayload({topic:t,payload:e,transportType:n}),await this.client.core.relayer.messages.ack(t,s)}catch(e){this.client.logger.error(e)}}registerExpirerEvents(){this.client.core.expirer.on(i.wn.expired,async e=>{const{topic:t,id:s}=(0,a.c82)(e.target);return s&&this.client.pendingRequest.keys.includes(s)?await this.deletePendingSessionRequest(s,(0,a.GuA)("EXPIRED"),!0):s&&this.client.auth.requests.keys.includes(s)?await this.deletePendingAuthRequest(s,(0,a.GuA)("EXPIRED"),!0):void(t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):s&&(await this.deleteProposal(s,!0),this.client.events.emit("proposal_expire",{id:s})))})}registerPairingEvents(){this.client.core.pairing.events.on(i.zN.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(i.zN.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!(0,a.Qhg)(e,!1)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if((0,a._dF)(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=(0,a.GuA)("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!(0,a.Qhg)(e,!1)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if((0,a._dF)(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:t}=(0,a.GuA)("EXPIRED",`session topic: ${e}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else{if(!this.client.core.pairing.pairings.keys.includes(e)){if((0,a.Qhg)(e,!1)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}{const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}this.isValidPairingTopic(e)}}async isValidProposalId(e){if(!(0,a.Alu)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if((0,a._dF)(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:t}=(0,a.GuA)("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}}class j extends i.il{constructor(e,t){super(e,t,"proposal",d),this.core=e,this.logger=t}}class M extends i.il{constructor(e,t){super(e,t,"session",d),this.core=e,this.logger=t}}class L extends i.il{constructor(e,t){super(e,t,"request",d,e=>e.id),this.core=e,this.logger=t}}class q extends i.il{constructor(e,t){super(e,t,"authKeys",_,()=>N),this.core=e,this.logger=t}}class $ extends i.il{constructor(e,t){super(e,t,"pairingTopics",_),this.core=e,this.logger=t}}class B extends i.il{constructor(e,t){super(e,t,"requests",_,e=>e.id),this.core=e,this.logger=t}}var H=Object.defineProperty,W=(e,t,s)=>((e,t,s)=>t in e?H(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class z{constructor(e,t){this.core=e,this.logger=t,W(this,"authKeys"),W(this,"pairingTopics"),W(this,"requests"),this.authKeys=new q(this.core,this.logger),this.pairingTopics=new $(this.core,this.logger),this.requests=new B(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}var V=Object.defineProperty,F=(e,t,s)=>((e,t,s)=>t in e?V(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class K extends n.S9{constructor(e){super(e),F(this,"protocol","wc"),F(this,"version",2),F(this,"name",u),F(this,"metadata"),F(this,"core"),F(this,"logger"),F(this,"events",new c.EventEmitter),F(this,"engine"),F(this,"session"),F(this,"proposal"),F(this,"pendingRequest"),F(this,"auth"),F(this,"signConfig"),F(this,"on",(e,t)=>this.events.on(e,t)),F(this,"once",(e,t)=>this.events.once(e,t)),F(this,"off",(e,t)=>this.events.off(e,t)),F(this,"removeListener",(e,t)=>this.events.removeListener(e,t)),F(this,"removeAllListeners",e=>this.events.removeAllListeners(e)),F(this,"connect",async e=>{try{return await this.engine.connect(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"pair",async e=>{try{return await this.engine.pair(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"approve",async e=>{try{return await this.engine.approve(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"reject",async e=>{try{return await this.engine.reject(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"update",async e=>{try{return await this.engine.update(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"extend",async e=>{try{return await this.engine.extend(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"request",async e=>{try{return await this.engine.request(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"respond",async e=>{try{return await this.engine.respond(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"ping",async e=>{try{return await this.engine.ping(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"emit",async e=>{try{return await this.engine.emit(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"disconnect",async e=>{try{return await this.engine.disconnect(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"find",e=>{try{return this.engine.find(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(e){throw this.logger.error(e.message),e}}),F(this,"authenticate",async(e,t)=>{try{return await this.engine.authenticate(e,t)}catch(e){throw this.logger.error(e.message),e}}),F(this,"formatAuthMessage",e=>{try{return this.engine.formatAuthMessage(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"approveSessionAuthenticate",async e=>{try{return await this.engine.approveSessionAuthenticate(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"rejectSessionAuthenticate",async e=>{try{return await this.engine.rejectSessionAuthenticate(e)}catch(e){throw this.logger.error(e.message),e}}),this.name=e?.name||u,this.metadata=e?.metadata||(0,a.lFF)(),this.signConfig=e?.signConfig;const t=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:(0,r.h6)((0,r.iP)({level:e?.logger||"error"}));this.core=e?.core||new i.iJ(e),this.logger=(0,r.U5)(t,this.name),this.session=new M(this.core,this.logger),this.proposal=new j(this.core,this.logger),this.pendingRequest=new L(this.core,this.logger),this.engine=new D(this),this.auth=new z(this.core,this.logger)}static async init(e){const t=new K(e);return await t.initialize(),t}get context(){return(0,r.oI)(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()},(0,o.toMiliseconds)(o.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}},38132:(e,t,s)=>{s.d(t,{r:()=>r});var i=s(70255);const r={createLogger(e,t="error"){const s=(0,i.iP)({level:t}),{logger:r}=(0,i.D5)({opts:s});return r.error=(...t)=>{for(const s of t)if(s instanceof Error)return void e(s,...t);e(void 0,...t)},r}}},38753:(e,t,s)=>{s.d(t,{A:()=>l});var i=s(50731),r=s(40868),n=s(16158),o=s(5813),a=s(11553),c=s(24313),h=s(74091);const l={filterOutDuplicatesByRDNS(e){const t=n.H.state.enableEIP6963?i.a.state.connectors:[],s=a.i.getRecentWallets(),r=t.map(e=>e.info?.rdns).filter(Boolean),c=s.map(e=>e.rdns).filter(Boolean),h=r.concat(c);if(h.includes("io.metamask.mobile")&&o.w.isMobile()){const e=h.indexOf("io.metamask.mobile");h[e]="io.metamask"}return e.filter(e=>!h.includes(String(e?.rdns)))},filterOutDuplicatesByIds(e){const t=i.a.state.connectors.filter(e=>"ANNOUNCED"===e.type||"INJECTED"===e.type),s=a.i.getRecentWallets(),r=t.map(e=>e.explorerId),n=s.map(e=>e.id),o=r.concat(n);return e.filter(e=>!o.includes(e?.id))},filterOutDuplicateWallets(e){const t=this.filterOutDuplicatesByRDNS(e);return this.filterOutDuplicatesByIds(t)},markWalletsAsInstalled(e){const{connectors:t}=i.a.state,s=t.filter(e=>"ANNOUNCED"===e.type).reduce((e,t)=>t.info?.rdns?(e[t.info.rdns]=!0,e):e,{});return e.map(e=>({...e,installed:Boolean(e.rdns)&&Boolean(s[e.rdns??""])})).sort((e,t)=>Number(t.installed)-Number(e.installed))},getConnectOrderMethod(e,t){const s=e?.connectMethodsOrder||n.H.state.features?.connectMethodsOrder,o=t||i.a.state.connectors;if(s)return s;const{injected:a,announced:l}=c.g.getConnectorsByType(o,r.N.state.recommended,r.N.state.featured),p=a.filter(c.g.showConnector),d=l.filter(c.g.showConnector);return p.length||d.length?["wallet","email","social"]:h.o.DEFAULT_CONNECT_METHOD_ORDER}}},40149:(e,t,s)=>{function i(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}s.d(t,{x:()=>i})},40446:(e,t,s)=>{s.d(t,{l:()=>Lr});var i=s(31575),r=s(76754),n=s(70255),o=s(64264),a=s(93786),c=s(14350),h=s(50046),l=s.n(h);const p="error",d="wc@2:universal_provider:",u="https://rpc.walletconnect.org/v1/",g="generic",f=`${u}bundler`,m="default_chain_changed";var w=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof s.g<"u"?s.g:typeof self<"u"?self:{},y=function(e,t){return e===t||e!=e&&t!=t},b=y,v=function(e,t){for(var s=e.length;s--;)if(b(e[s][0],t))return s;return-1},E=v,I=Array.prototype.splice,_=v,N=v,A=v,C=function(){this.__data__=[],this.size=0},P=function(e){var t=this.__data__,s=E(t,e);return!(s<0||(s==t.length-1?t.pop():I.call(t,s,1),--this.size,0))},S=function(e){var t=this.__data__,s=_(t,e);return s<0?void 0:t[s][1]},O=function(e){return N(this.__data__,e)>-1},T=function(e,t){var s=this.__data__,i=A(s,e);return i<0?(++this.size,s.push([e,t])):s[i][1]=t,this};function k(e){var t=-1,s=null==e?0:e.length;for(this.clear();++t<s;){var i=e[t];this.set(i[0],i[1])}}k.prototype.clear=C,k.prototype.delete=P,k.prototype.get=S,k.prototype.has=O,k.prototype.set=T;var x,R=k,U=R,D="object"==typeof w&&w&&w.Object===Object&&w,j=D,M="object"==typeof self&&self&&self.Object===Object&&self,L=j||M||Function("return this")(),q=L.Symbol,$=q,B=Object.prototype,H=B.hasOwnProperty,W=B.toString,z=$?$.toStringTag:void 0,V=Object.prototype.toString,F=function(e){var t=H.call(e,z),s=e[z];try{e[z]=void 0;var i=!0}catch{}var r=W.call(e);return i&&(t?e[z]=s:delete e[z]),r},K=function(e){return V.call(e)},G=q?q.toStringTag:void 0,J=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":G&&G in Object(e)?F(e):K(e)},Y=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},Q=J,X=Y,Z=function(e){if(!X(e))return!1;var t=Q(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},ee=L["__core-js_shared__"],te=(x=/[^.]+$/.exec(ee&&ee.keys&&ee.keys.IE_PROTO||""))?"Symbol(src)_1."+x:"",se=Function.prototype.toString,ie=Z,re=function(e){return!!te&&te in e},ne=Y,oe=function(e){if(null!=e){try{return se.call(e)}catch{}try{return e+""}catch{}}return""},ae=/^\[object .+?Constructor\]$/,ce=Function.prototype,he=Object.prototype,le=ce.toString,pe=he.hasOwnProperty,de=RegExp("^"+le.call(pe).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ue=function(e){return!(!ne(e)||re(e))&&(ie(e)?de:ae).test(oe(e))},ge=function(e,t){return e?.[t]},fe=function(e,t){var s=ge(e,t);return ue(s)?s:void 0},me=fe(L,"Map"),we=fe(Object,"create"),ye=we,be=we,ve=Object.prototype.hasOwnProperty,Ee=we,Ie=Object.prototype.hasOwnProperty,_e=we,Ne=function(){this.__data__=ye?ye(null):{},this.size=0},Ae=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Ce=function(e){var t=this.__data__;if(be){var s=t[e];return"__lodash_hash_undefined__"===s?void 0:s}return ve.call(t,e)?t[e]:void 0},Pe=function(e){var t=this.__data__;return Ee?void 0!==t[e]:Ie.call(t,e)},Se=function(e,t){var s=this.__data__;return this.size+=this.has(e)?0:1,s[e]=_e&&void 0===t?"__lodash_hash_undefined__":t,this};function Oe(e){var t=-1,s=null==e?0:e.length;for(this.clear();++t<s;){var i=e[t];this.set(i[0],i[1])}}Oe.prototype.clear=Ne,Oe.prototype.delete=Ae,Oe.prototype.get=Ce,Oe.prototype.has=Pe,Oe.prototype.set=Se;var Te=Oe,ke=R,xe=me,Re=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e},Ue=function(e,t){var s=e.__data__;return Re(t)?s["string"==typeof t?"string":"hash"]:s.map},De=Ue,je=Ue,Me=Ue,Le=Ue,qe=function(e){var t=De(this,e).delete(e);return this.size-=t?1:0,t},$e=function(e){return je(this,e).get(e)},Be=function(e){return Me(this,e).has(e)},He=function(e,t){var s=Le(this,e),i=s.size;return s.set(e,t),this.size+=s.size==i?0:1,this};function We(e){var t=-1,s=null==e?0:e.length;for(this.clear();++t<s;){var i=e[t];this.set(i[0],i[1])}}We.prototype.clear=function(){this.size=0,this.__data__={hash:new Te,map:new(xe||ke),string:new Te}},We.prototype.delete=qe,We.prototype.get=$e,We.prototype.has=Be,We.prototype.set=He;var ze=R,Ve=me,Fe=We,Ke=R,Ge=function(){this.__data__=new U,this.size=0},Je=function(e){var t=this.__data__,s=t.delete(e);return this.size=t.size,s},Ye=function(e){return this.__data__.get(e)},Qe=function(e){return this.__data__.has(e)},Xe=function(e,t){var s=this.__data__;if(s instanceof ze){var i=s.__data__;if(!Ve||i.length<199)return i.push([e,t]),this.size=++s.size,this;s=this.__data__=new Fe(i)}return s.set(e,t),this.size=s.size,this};function Ze(e){var t=this.__data__=new Ke(e);this.size=t.size}Ze.prototype.clear=Ge,Ze.prototype.delete=Je,Ze.prototype.get=Ye,Ze.prototype.has=Qe,Ze.prototype.set=Xe;var et=Ze,tt=fe,st=function(){try{var e=tt(Object,"defineProperty");return e({},"",{}),e}catch{}}(),it=st,rt=it,nt=function(e,t,s){"__proto__"==t&&rt?rt(e,t,{configurable:!0,enumerable:!0,value:s,writable:!0}):e[t]=s},ot=nt,at=y,ct=function(e,t,s){(void 0!==s&&!at(e[t],s)||void 0===s&&!(t in e))&&ot(e,t,s)},ht=function(e){return function(t,s,i){for(var r=-1,n=Object(t),o=i(t),a=o.length;a--;){var c=o[e?a:++r];if(!1===s(n[c],c,n))break}return t}}(),lt={exports:{}};!function(e,t){var s=L,i=t&&!t.nodeType&&t,r=i&&e&&!e.nodeType&&e,n=r&&r.exports===i?s.Buffer:void 0,o=n?n.allocUnsafe:void 0;e.exports=function(e,t){if(t)return e.slice();var s=e.length,i=o?o(s):new e.constructor(s);return e.copy(i),i}}(lt,lt.exports);var pt=L.Uint8Array,dt=function(e){var t=new e.constructor(e.byteLength);return new pt(t).set(new pt(e)),t},ut=Y,gt=Object.create,ft=function(){function e(){}return function(t){if(!ut(t))return{};if(gt)return gt(t);e.prototype=t;var s=new e;return e.prototype=void 0,s}}(),mt=ft,wt=function(e,t){return function(s){return e(t(s))}}(Object.getPrototypeOf,Object),yt=Object.prototype,bt=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||yt)},vt=mt,Et=wt,It=bt,_t=function(e){return null!=e&&"object"==typeof e},Nt=J,At=_t,Ct=function(e){return At(e)&&"[object Arguments]"==Nt(e)},Pt=_t,St=Object.prototype,Ot=St.hasOwnProperty,Tt=St.propertyIsEnumerable,kt=Ct(function(){return arguments}())?Ct:function(e){return Pt(e)&&Ot.call(e,"callee")&&!Tt.call(e,"callee")},xt=kt,Rt=Array.isArray,Ut=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991},Dt=Z,jt=Ut,Mt=function(e){return null!=e&&jt(e.length)&&!Dt(e)},Lt=Mt,qt=_t,$t={exports:{}},Bt=function(){return!1};!function(e,t){var s=L,i=Bt,r=t&&!t.nodeType&&t,n=r&&e&&!e.nodeType&&e,o=n&&n.exports===r?s.Buffer:void 0,a=(o?o.isBuffer:void 0)||i;e.exports=a}($t,$t.exports);var Ht=J,Wt=wt,zt=_t,Vt=Function.prototype,Ft=Object.prototype,Kt=Vt.toString,Gt=Ft.hasOwnProperty,Jt=Kt.call(Object),Yt=J,Qt=Ut,Xt=_t,Zt={};Zt["[object Float32Array]"]=Zt["[object Float64Array]"]=Zt["[object Int8Array]"]=Zt["[object Int16Array]"]=Zt["[object Int32Array]"]=Zt["[object Uint8Array]"]=Zt["[object Uint8ClampedArray]"]=Zt["[object Uint16Array]"]=Zt["[object Uint32Array]"]=!0,Zt["[object Arguments]"]=Zt["[object Array]"]=Zt["[object ArrayBuffer]"]=Zt["[object Boolean]"]=Zt["[object DataView]"]=Zt["[object Date]"]=Zt["[object Error]"]=Zt["[object Function]"]=Zt["[object Map]"]=Zt["[object Number]"]=Zt["[object Object]"]=Zt["[object RegExp]"]=Zt["[object Set]"]=Zt["[object String]"]=Zt["[object WeakMap]"]=!1;var es={exports:{}};!function(e,t){var s=D,i=t&&!t.nodeType&&t,r=i&&e&&!e.nodeType&&e,n=r&&r.exports===i&&s.process,o=function(){try{return r&&r.require&&r.require("util").types||n&&n.binding&&n.binding("util")}catch{}}();e.exports=o}(es,es.exports);var ts=function(e){return Xt(e)&&Qt(e.length)&&!!Zt[Yt(e)]},ss=function(e){return function(t){return e(t)}},is=es.exports,rs=is&&is.isTypedArray,ns=rs?ss(rs):ts,os=function(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]},as=nt,cs=y,hs=Object.prototype.hasOwnProperty,ls=function(e,t,s){var i=e[t];(!hs.call(e,t)||!cs(i,s)||void 0===s&&!(t in e))&&as(e,t,s)},ps=nt,ds=/^(?:0|[1-9]\d*)$/,us=function(e,t){var s=typeof e;return!!(t=t??9007199254740991)&&("number"==s||"symbol"!=s&&ds.test(e))&&e>-1&&e%1==0&&e<t},gs=function(e,t){for(var s=-1,i=Array(e);++s<e;)i[s]=t(s);return i},fs=xt,ms=Rt,ws=$t.exports,ys=us,bs=ns,vs=Object.prototype.hasOwnProperty,Es=Y,Is=bt,_s=function(e){var t=[];if(null!=e)for(var s in Object(e))t.push(s);return t},Ns=Object.prototype.hasOwnProperty,As=function(e,t){var s=ms(e),i=!s&&fs(e),r=!s&&!i&&ws(e),n=!s&&!i&&!r&&bs(e),o=s||i||r||n,a=o?gs(e.length,String):[],c=a.length;for(var h in e)(t||vs.call(e,h))&&(!o||!("length"==h||r&&("offset"==h||"parent"==h)||n&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||ys(h,c)))&&a.push(h);return a},Cs=function(e){if(!Es(e))return _s(e);var t=Is(e),s=[];for(var i in e)"constructor"==i&&(t||!Ns.call(e,i))||s.push(i);return s},Ps=Mt,Ss=function(e){return Ps(e)?As(e,!0):Cs(e)},Os=function(e,t,s,i){var r=!s;s||(s={});for(var n=-1,o=t.length;++n<o;){var a=t[n],c=i?i(s[a],e[a],a,s,e):void 0;void 0===c&&(c=e[a]),r?ps(s,a,c):ls(s,a,c)}return s},Ts=Ss,ks=ct,xs=lt.exports,Rs=function(e,t){var s=t?dt(e.buffer):e.buffer;return new e.constructor(s,e.byteOffset,e.length)},Us=function(e,t){var s=-1,i=e.length;for(t||(t=Array(i));++s<i;)t[s]=e[s];return t},Ds=function(e){return"function"!=typeof e.constructor||It(e)?{}:vt(Et(e))},js=xt,Ms=Rt,Ls=function(e){return qt(e)&&Lt(e)},qs=$t.exports,$s=Z,Bs=Y,Hs=function(e){if(!zt(e)||"[object Object]"!=Ht(e))return!1;var t=Wt(e);if(null===t)return!0;var s=Gt.call(t,"constructor")&&t.constructor;return"function"==typeof s&&s instanceof s&&Kt.call(s)==Jt},Ws=ns,zs=os,Vs=function(e){return Os(e,Ts(e))},Fs=et,Ks=ct,Gs=ht,Js=function(e,t,s,i,r,n,o){var a=zs(e,s),c=zs(t,s),h=o.get(c);if(h)ks(e,s,h);else{var l=n?n(a,c,s+"",e,t,o):void 0,p=void 0===l;if(p){var d=Ms(c),u=!d&&qs(c),g=!d&&!u&&Ws(c);l=c,d||u||g?Ms(a)?l=a:Ls(a)?l=Us(a):u?(p=!1,l=xs(c,!0)):g?(p=!1,l=Rs(c,!0)):l=[]:Hs(c)||js(c)?(l=a,js(a)?l=Vs(a):(!Bs(a)||$s(a))&&(l=Ds(c))):p=!1}p&&(o.set(c,l),r(l,c,i,n,o),o.delete(c)),ks(e,s,l)}},Ys=Y,Qs=Ss,Xs=os,Zs=function(e){return e},ei=function(e,t,s){switch(s.length){case 0:return e.call(t);case 1:return e.call(t,s[0]);case 2:return e.call(t,s[0],s[1]);case 3:return e.call(t,s[0],s[1],s[2])}return e.apply(t,s)},ti=Math.max,si=function(e){return function(){return e}},ii=it,ri=ii?function(e,t){return ii(e,"toString",{configurable:!0,enumerable:!1,value:si(t),writable:!0})}:Zs,ni=ri,oi=Date.now,ai=function(e){var t=0,s=0;return function(){var i=oi(),r=16-(i-s);if(s=i,r>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(ni),ci=Zs,hi=function(e,t,s){return t=ti(void 0===t?e.length-1:t,0),function(){for(var i=arguments,r=-1,n=ti(i.length-t,0),o=Array(n);++r<n;)o[r]=i[t+r];r=-1;for(var a=Array(t+1);++r<t;)a[r]=i[r];return a[t]=s(o),ei(e,this,a)}},li=ai,pi=y,di=Mt,ui=us,gi=Y,fi=function(e,t){return li(hi(e,t,ci),e+"")},mi=function(e,t,s){if(!gi(s))return!1;var i=typeof t;return!!("number"==i?di(s)&&ui(t,s.length):"string"==i&&t in s)&&pi(s[t],e)},wi=function e(t,s,i,r,n){t!==s&&Gs(s,function(o,a){if(n||(n=new Fs),Ys(o))Js(t,s,a,i,e,r,n);else{var c=r?r(Xs(t,a),o,a+"",t,s,n):void 0;void 0===c&&(c=o),Ks(t,a,c)}},Qs)},yi=function(e){return fi(function(t,s){var i=-1,r=s.length,n=r>1?s[r-1]:void 0,o=r>2?s[2]:void 0;for(n=e.length>3&&"function"==typeof n?(r--,n):void 0,o&&mi(s[0],s[1],o)&&(n=r<3?void 0:n,r=1),t=Object(t);++i<r;){var a=s[i];a&&e(t,a,i,n)}return t})}(function(e,t,s){wi(e,t,s)}),bi=yi,vi=Object.defineProperty,Ei=Object.defineProperties,Ii=Object.getOwnPropertyDescriptors,_i=Object.getOwnPropertySymbols,Ni=Object.prototype.hasOwnProperty,Ai=Object.prototype.propertyIsEnumerable,Ci=(e,t,s)=>t in e?vi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Pi=(e,t)=>{for(var s in t||(t={}))Ni.call(t,s)&&Ci(e,s,t[s]);if(_i)for(var s of _i(t))Ai.call(t,s)&&Ci(e,s,t[s]);return e},Si=(e,t)=>Ei(e,Ii(t));function Oi(e,t,s){var i;const n=(0,r._Yb)(e);return(null==(i=t.rpcMap)?void 0:i[n.reference])||`${u}?chainId=${n.namespace}:${n.reference}&projectId=${s}`}function Ti(e){return e.includes(":")?e.split(":")[1]:e}function ki(e){return e.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function xi(e={},t={}){const s=Ri(e),i=Ri(t);return bi(s,i)}function Ri(e){var t,s,i,n;const o={};if(!(0,r.aF0)(e))return o;for(const[a,c]of Object.entries(e)){const e=(0,r.nWe)(a)?[a]:c.chains,h=c.methods||[],l=c.events||[],p=c.rpcMap||{},d=(0,r.kob)(a);o[d]=Si(Pi(Pi({},o[d]),c),{chains:(0,r.TRk)(e,null==(t=o[d])?void 0:t.chains),methods:(0,r.TRk)(h,null==(s=o[d])?void 0:s.methods),events:(0,r.TRk)(l,null==(i=o[d])?void 0:i.events),rpcMap:Pi(Pi({},p),null==(n=o[d])?void 0:n.rpcMap)})}return o}function Ui(e){return e.includes(":")?e.split(":")[2]:e}function Di(e){const t={};for(const[s,i]of Object.entries(e)){const e=i.methods||[],n=i.events||[],o=i.accounts||[],a=(0,r.nWe)(s)?[s]:i.chains?i.chains:ki(i.accounts);t[s]={chains:a,methods:e,events:n,accounts:o}}return t}function ji(e){return"number"==typeof e?e:e.includes("0x")?parseInt(e,16):(e=e.includes(":")?e.split(":")[1]:e,isNaN(Number(e))?e:Number(e))}const Mi={},Li=e=>Mi[e],qi=(e,t)=>{Mi[e]=t};var $i=Object.defineProperty,Bi=(e,t,s)=>((e,t,s)=>t in e?$i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Hi{constructor(e){Bi(this,"name","polkadot"),Bi(this,"client"),Bi(this,"httpProviders"),Bi(this,"events"),Bi(this,"namespace"),Bi(this,"chainId"),this.namespace=e.namespace,this.events=Li("events"),this.client=Li("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(m,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e&&e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;const i=Ti(t);e[i]=this.createHttpProvider(i,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||Oi(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(s,Li("disableProviderPing")))}}var Wi=Object.defineProperty,zi=Object.defineProperties,Vi=Object.getOwnPropertyDescriptors,Fi=Object.getOwnPropertySymbols,Ki=Object.prototype.hasOwnProperty,Gi=Object.prototype.propertyIsEnumerable,Ji=(e,t,s)=>t in e?Wi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Yi=(e,t)=>{for(var s in t||(t={}))Ki.call(t,s)&&Ji(e,s,t[s]);if(Fi)for(var s of Fi(t))Gi.call(t,s)&&Ji(e,s,t[s]);return e},Qi=(e,t)=>zi(e,Vi(t)),Xi=(e,t,s)=>Ji(e,"symbol"!=typeof t?t+"":t,s);class Zi{constructor(e){Xi(this,"name","eip155"),Xi(this,"client"),Xi(this,"chainId"),Xi(this,"namespace"),Xi(this,"httpProviders"),Xi(this,"events"),this.namespace=e.namespace,this.events=Li("events"),this.client=Li("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(e);case"wallet_getCallsStatus":return await this.getCallStatus(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(parseInt(e),t),this.chainId=parseInt(e),this.events.emit(m,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,t){const s=t||Oi(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.V(s,Li("disableProviderPing")))}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;const i=parseInt(Ti(t));e[i]=this.createHttpProvider(i,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}async handleSwitchChain(e){var t,s;let i=e.request.params?null==(t=e.request.params[0])?void 0:t.chainId:"0x0";i=i.startsWith("0x")?i:`0x${i}`;const r=parseInt(i,16);if(this.isChainApproved(r))this.setDefaultChain(`${r}`);else{if(!this.namespace.methods.includes("wallet_switchEthereumChain"))throw new Error(`Failed to switch to chain 'eip155:${r}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:i}]},chainId:null==(s=this.namespace.chains)?void 0:s[0]}),this.setDefaultChain(`${r}`)}return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var t,s,i;const r=null==(s=null==(t=e.request)?void 0:t.params)?void 0:s[0];if(!r)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const n=this.client.session.get(e.topic),o=(null==(i=n?.sessionProperties)?void 0:i.capabilities)||{};if(null!=o&&o[r])return o?.[r];const a=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:Qi(Yi({},n.sessionProperties||{}),{capabilities:Qi(Yi({},o||{}),{[r]:a})})})}catch(e){console.warn("Failed to update session with capabilities",e)}return a}async getCallStatus(e){var t,s;const i=this.client.session.get(e.topic),r=null==(t=i.sessionProperties)?void 0:t.bundler_name;if(r){const t=this.getBundlerUrl(e.chainId,r);try{return await this.getUserOperationReceipt(t,e)}catch(e){console.warn("Failed to fetch call status from bundler",e,t)}}const n=null==(s=i.sessionProperties)?void 0:s.bundler_url;if(n)try{return await this.getUserOperationReceipt(n,e)}catch(e){console.warn("Failed to fetch call status from custom bundler",e,n)}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,t){var s;const i=new URL(e),r=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify((0,c.formatJsonRpcRequest)("eth_getUserOperationReceipt",[null==(s=t.request.params)?void 0:s[0]]))});if(!r.ok)throw new Error(`Failed to fetch user operation receipt - ${r.status}`);return await r.json()}getBundlerUrl(e,t){return`${f}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${t}`}}var er=Object.defineProperty,tr=(e,t,s)=>((e,t,s)=>t in e?er(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class sr{constructor(e){tr(this,"name","solana"),tr(this,"client"),tr(this,"httpProviders"),tr(this,"events"),tr(this,"namespace"),tr(this,"chainId"),this.namespace=e.namespace,this.events=Li("events"),this.client=Li("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(m,`${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(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;const i=Ti(t);e[i]=this.createHttpProvider(i,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||Oi(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(s,Li("disableProviderPing")))}}var ir=Object.defineProperty,rr=(e,t,s)=>((e,t,s)=>t in e?ir(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class nr{constructor(e){rr(this,"name","cosmos"),rr(this,"client"),rr(this,"httpProviders"),rr(this,"events"),rr(this,"namespace"),rr(this,"chainId"),this.namespace=e.namespace,this.events=Li("events"),this.client=Li("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(m,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;const i=Ti(t);e[i]=this.createHttpProvider(i,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||Oi(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(s,Li("disableProviderPing")))}}var or=Object.defineProperty,ar=(e,t,s)=>((e,t,s)=>t in e?or(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class cr{constructor(e){ar(this,"name","algorand"),ar(this,"client"),ar(this,"httpProviders"),ar(this,"events"),ar(this,"namespace"),ar(this,"chainId"),this.namespace=e.namespace,this.events=Li("events"),this.client=Li("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(!this.httpProviders[e]){const s=t||Oi(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,s)}this.chainId=e,this.events.emit(m,`${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(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;e[t]=this.createHttpProvider(t,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||Oi(e,this.namespace,this.client.core.projectId);return typeof s>"u"?void 0:new a.F(new o.A(s,Li("disableProviderPing")))}}var hr=Object.defineProperty,lr=(e,t,s)=>((e,t,s)=>t in e?hr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class pr{constructor(e){lr(this,"name","cip34"),lr(this,"client"),lr(this,"httpProviders"),lr(this,"events"),lr(this,"namespace"),lr(this,"chainId"),this.namespace=e.namespace,this.events=Li("events"),this.client=Li("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(m,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{const s=this.getCardanoRPCUrl(t),i=Ti(t);e[i]=this.createHttpProvider(i,s)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}getCardanoRPCUrl(e){const t=this.namespace.rpcMap;if(t)return t[e]}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||this.getCardanoRPCUrl(e);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(s,Li("disableProviderPing")))}}var dr=Object.defineProperty,ur=(e,t,s)=>((e,t,s)=>t in e?dr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class gr{constructor(e){ur(this,"name","elrond"),ur(this,"client"),ur(this,"httpProviders"),ur(this,"events"),ur(this,"namespace"),ur(this,"chainId"),this.namespace=e.namespace,this.events=Li("events"),this.client=Li("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(m,`${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(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;const i=Ti(t);e[i]=this.createHttpProvider(i,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||Oi(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(s,Li("disableProviderPing")))}}var fr=Object.defineProperty,mr=(e,t,s)=>((e,t,s)=>t in e?fr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class wr{constructor(e){mr(this,"name","multiversx"),mr(this,"client"),mr(this,"httpProviders"),mr(this,"events"),mr(this,"namespace"),mr(this,"chainId"),this.namespace=e.namespace,this.events=Li("events"),this.client=Li("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(m,`${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(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;const i=Ti(t);e[i]=this.createHttpProvider(i,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||Oi(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(s,Li("disableProviderPing")))}}var yr=Object.defineProperty,br=(e,t,s)=>((e,t,s)=>t in e?yr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class vr{constructor(e){br(this,"name","near"),br(this,"client"),br(this,"httpProviders"),br(this,"events"),br(this,"namespace"),br(this,"chainId"),this.namespace=e.namespace,this.events=Li("events"),this.client=Li("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const s=t||Oi(`${this.name}:${e}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,s)}this.events.emit(m,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e&&e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;e[t]=this.createHttpProvider(t,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||Oi(e,this.namespace);return typeof s>"u"?void 0:new a.F(new o.A(s,Li("disableProviderPing")))}}var Er=Object.defineProperty,Ir=(e,t,s)=>((e,t,s)=>t in e?Er(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class _r{constructor(e){Ir(this,"name","tezos"),Ir(this,"client"),Ir(this,"httpProviders"),Ir(this,"events"),Ir(this,"namespace"),Ir(this,"chainId"),this.namespace=e.namespace,this.events=Li("events"),this.client=Li("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const s=t||Oi(`${this.name}:${e}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,s)}this.events.emit(m,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e&&e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{e[t]=this.createHttpProvider(t)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||Oi(e,this.namespace);return typeof s>"u"?void 0:new a.F(new o.A(s))}}var Nr=Object.defineProperty,Ar=(e,t,s)=>((e,t,s)=>t in e?Nr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Cr{constructor(e){Ar(this,"name",g),Ar(this,"client"),Ar(this,"httpProviders"),Ar(this,"events"),Ar(this,"namespace"),Ar(this,"chainId"),this.namespace=e.namespace,this.events=Li("events"),this.client=Li("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(m,`${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(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){var e,t;const s={};return null==(t=null==(e=this.namespace)?void 0:e.accounts)||t.forEach(e=>{const t=(0,r._Yb)(e);s[`${t.namespace}:${t.reference}`]=this.createHttpProvider(e)}),s}getHttpProvider(e){const t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||Oi(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(s,Li("disableProviderPing")))}}var Pr=Object.defineProperty,Sr=Object.defineProperties,Or=Object.getOwnPropertyDescriptors,Tr=Object.getOwnPropertySymbols,kr=Object.prototype.hasOwnProperty,xr=Object.prototype.propertyIsEnumerable,Rr=(e,t,s)=>t in e?Pr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Ur=(e,t)=>{for(var s in t||(t={}))kr.call(t,s)&&Rr(e,s,t[s]);if(Tr)for(var s of Tr(t))xr.call(t,s)&&Rr(e,s,t[s]);return e},Dr=(e,t)=>Sr(e,Or(t)),jr=(e,t,s)=>Rr(e,"symbol"!=typeof t?t+"":t,s);class Mr{constructor(e){jr(this,"client"),jr(this,"namespaces"),jr(this,"optionalNamespaces"),jr(this,"sessionProperties"),jr(this,"events",new(l())),jr(this,"rpcProviders",{}),jr(this,"session"),jr(this,"providerOpts"),jr(this,"logger"),jr(this,"uri"),jr(this,"disableProviderPing",!1),this.providerOpts=e,this.logger=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:(0,n.h6)((0,n.iP)({level:e?.logger||p})),this.disableProviderPing=e?.disableProviderPing||!1}static async init(e){const t=new Mr(e);return await t.initialize(),t}async request(e,t,s){const[i,r]=this.validateChain(t);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(i).request({request:Ur({},e),chainId:`${i}:${r}`,topic:this.session.topic,expiry:s})}sendAsync(e,t,s,i){const r=(new Date).getTime();this.request(e,s,i).then(e=>t(null,(0,c.formatJsonRpcResult)(r,e))).catch(e=>t(e,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:null==(e=this.session)?void 0:e.topic,reason:(0,r.Hjj)("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,t){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:s,response:i}=await this.client.authenticate(e,t);s&&(this.uri=s,this.events.emit("display_uri",s));const r=await i();if(this.session=r.session,this.session){const e=Di(this.session.namespaces);this.namespaces=xi(this.namespaces,e),this.persist("namespaces",this.namespaces),this.onConnect()}return r}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}removeListener(e,t){this.events.removeListener(e,t)}off(e,t){this.events.off(e,t)}get isWalletConnect(){return!0}async pair(e){const{uri:t,approval:s}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});t&&(this.uri=t,this.events.emit("display_uri",t));const i=await s();this.session=i;const r=Di(i.namespaces);return this.namespaces=xi(this.namespaces,r),this.persist("namespaces",this.namespaces),this.onConnect(),this.session}setDefaultChain(e,t){try{if(!this.session)return;const[s,i]=this.validateChain(e),r=this.getProvider(s);r.name===g?r.setDefaultChain(`${s}:${i}`,t):r.setDefaultChain(i,t)}catch(e){if(!/Please call connect/.test(e.message))throw e}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const t=this.client.pairing.getAll();if((0,r.OP1)(t)){for(const s of t)e.deletePairings?this.client.core.expirer.set(s.topic,0):await this.client.core.relayer.subscriber.unsubscribe(s.topic);this.logger.info(`Inactive pairings cleared: ${t.length}`)}}abortPairingAttempt(){this.logger.warn("abortPairingAttempt is deprecated. This is now a no-op.")}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const e=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[e]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await i.Ay.init({core:this.providerOpts.core,logger:this.providerOpts.logger||p,relayUrl:this.providerOpts.relayUrl||"wss://relay.walletconnect.org",projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map(e=>(0,r.kob)(e)))];qi("client",this.client),qi("events",this.events),qi("disableProviderPing",this.disableProviderPing),e.forEach(e=>{if(!this.session)return;const t=function(e,t){const s=Object.keys(t.namespaces).filter(t=>t.includes(e));if(!s.length)return[];const i=[];return s.forEach(e=>{const s=t.namespaces[e].accounts;i.push(...s)}),i}(e,this.session),s=ki(t),i=xi(this.namespaces,this.optionalNamespaces),r=Dr(Ur({},i[e]),{accounts:t,chains:s});switch(e){case"eip155":this.rpcProviders[e]=new Zi({namespace:r});break;case"algorand":this.rpcProviders[e]=new cr({namespace:r});break;case"solana":this.rpcProviders[e]=new sr({namespace:r});break;case"cosmos":this.rpcProviders[e]=new nr({namespace:r});break;case"polkadot":this.rpcProviders[e]=new Hi({namespace:r});break;case"cip34":this.rpcProviders[e]=new pr({namespace:r});break;case"elrond":this.rpcProviders[e]=new gr({namespace:r});break;case"multiversx":this.rpcProviders[e]=new wr({namespace:r});break;case"near":this.rpcProviders[e]=new vr({namespace:r});break;case"tezos":this.rpcProviders[e]=new _r({namespace:r});break;default:this.rpcProviders[g]?this.rpcProviders[g].updateNamespace(r):this.rpcProviders[g]=new Cr({namespace:r})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{const{params:t}=e,{event:s}=t;if("accountsChanged"===s.name){const e=s.data;e&&(0,r.OP1)(e)&&this.events.emit("accountsChanged",e.map(Ui))}else if("chainChanged"===s.name){const e=t.chainId,s=t.event.data,i=(0,r.kob)(e),n=ji(e)!==ji(s)?`${i}:${ji(s)}`:e;this.onChainChanged(n)}else this.events.emit(s.name,s.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:t})=>{var s;const{namespaces:i}=t,r=null==(s=this.client)?void 0:s.session.get(e);this.session=Dr(Ur({},r),{namespaces:i}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:t})}),this.client.on("session_delete",async e=>{await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",Dr(Ur({},(0,r.Hjj)("USER_DISCONNECTED")),{data:e.topic}))}),this.on(m,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[g]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var t;this.getProvider(e).updateNamespace(null==(t=this.session)?void 0:t.namespaces[e])})}setNamespaces(e){const{namespaces:t,optionalNamespaces:s,sessionProperties:i}=e;t&&Object.keys(t).length&&(this.namespaces=t),s&&Object.keys(s).length&&(this.optionalNamespaces=s),this.sessionProperties=i,this.persist("namespaces",t),this.persist("optionalNamespaces",s)}validateChain(e){const[t,s]=e?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[t,s];if(t&&!Object.keys(this.namespaces||{}).map(e=>(0,r.kob)(e)).includes(t))throw new Error(`Namespace '${t}' is not configured. Please call connect() first with namespace config.`);if(t&&s)return[t,s];const i=(0,r.kob)(Object.keys(this.namespaces)[0]);return[i,this.rpcProviders[i].getDefaultChain()]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}onChainChanged(e,t=!1){if(!this.namespaces)return;const[s,i]=this.validateChain(e);i&&(t||this.getProvider(s).setDefaultChain(i),this.namespaces[s]?this.namespaces[s].defaultChain=i:this.namespaces[`${s}:${i}`]?this.namespaces[`${s}:${i}`].defaultChain=i:this.namespaces[`${s}:${i}`]={defaultChain:i},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",i))}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(e,t){this.client.core.storage.setItem(`${d}/${e}`,t)}async getFromStore(e){return await this.client.core.storage.getItem(`${d}/${e}`)}}const Lr=Mr},40770:(e,t,s)=>{s.d(t,{L:()=>n});var i=s(95191),r=s(98207);const n={ConnectorExplorerIds:{[i.o.CONNECTOR_ID.COINBASE]:"fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa",[i.o.CONNECTOR_ID.COINBASE_SDK]:"fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa",[i.o.CONNECTOR_ID.SAFE]:"225affb176778569276e484e1b92637ad061b01e13a048b35a9d280c3b58970f",[i.o.CONNECTOR_ID.LEDGER]:"19177a98252e07ddfc9af2083ba8e07ef627cb6103467ffebb3f8f4205fd7927",[i.o.CONNECTOR_ID.OKX]:"971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709",[r.o.METMASK_CONNECTOR_NAME]:"c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96",[r.o.TRUST_CONNECTOR_NAME]:"4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0",[r.o.SOLFLARE_CONNECTOR_NAME]:"1ca0bdd4747578705b1939af023d120677c64fe6ca76add81fda36e350605e79",[r.o.PHANTOM_CONNECTOR_NAME]:"a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393",[r.o.COIN98_CONNECTOR_NAME]:"2a3c89040ac3b723a1972a33a125b1db11e258a6975d3a61252cd64e6ea5ea01",[r.o.MAGIC_EDEN_CONNECTOR_NAME]:"8b830a2b724a9c3fbab63af6f55ed29c9dfa8a55e732dc88c80a196a2ba136c6",[r.o.BACKPACK_CONNECTOR_NAME]:"2bd8c14e035c2d48f184aaa168559e86b0e3433228d3c4075900a221785019b0",[r.o.BITGET_CONNECTOR_NAME]:"38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662",[r.o.FRONTIER_CONNECTOR_NAME]:"85db431492aa2e8672e93f4ea7acf10c88b97b867b0d373107af63dc4880f041",[r.o.XVERSE_CONNECTOR_NAME]:"2a87d74ae02e10bdd1f51f7ce6c4e1cc53cd5f2c0b6b5ad0d7b3007d2b13de7b",[r.o.LEATHER_CONNECTOR_NAME]:"483afe1df1df63daf313109971ff3ef8356ddf1cc4e45877d205eee0b7893a13"},NetworkImageIds:{1:"ba0ba0cd-17c6-4806-ad93-f9d174f17900",42161:"3bff954d-5cb0-47a0-9a23-d20192e74600",43114:"30c46e53-e989-45fb-4549-be3bd4eb3b00",56:"93564157-2e8e-4ce7-81df-b264dbee9b00",250:"06b26297-fe0c-4733-5d6b-ffa5498aac00",10:"ab9c186a-c52f-464b-2906-ca59d760a400",137:"41d04d42-da3b-4453-8506-668cc0727900",5e3:"e86fae9b-b770-4eea-e520-150e12c81100",295:"6a97d510-cac8-4e58-c7ce-e8681b044c00",11155111:"e909ea0a-f92a-4512-c8fc-748044ea6800",84532:"a18a7ecd-e307-4360-4746-283182228e00",1301:"4eeea7ef-0014-4649-5d1d-07271a80f600",130:"2257980a-3463-48c6-cbac-a42d2a956e00",10143:"0a728e83-bacb-46db-7844-948f05434900",100:"02b53f6a-e3d4-479e-1cb4-21178987d100",9001:"f926ff41-260d-4028-635e-91913fc28e00",324:"b310f07f-4ef7-49f3-7073-2a0a39685800",314:"5a73b3dd-af74-424e-cae0-0de859ee9400",4689:"34e68754-e536-40da-c153-6ef2e7188a00",1088:"3897a66d-40b9-4833-162f-a2c90531c900",1284:"161038da-44ae-4ec7-1208-0ea569454b00",1285:"f1d73bb6-5450-4e18-38f7-fb6484264a00",7777777:"845c60df-d429-4991-e687-91ae45791600",42220:"ab781bbc-ccc6-418d-d32d-789b15da1f00",8453:"7289c336-3981-4081-c5f4-efc26ac64a00",1313161554:"3ff73439-a619-4894-9262-4470c773a100",2020:"b8101fc0-9c19-4b6f-ec65-f6dfff106e00",2021:"b8101fc0-9c19-4b6f-ec65-f6dfff106e00",80094:"e329c2c9-59b0-4a02-83e4-212ff3779900","5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp":"a1b58899-f671-4276-6a5e-56ca5bd59700","4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z":"a1b58899-f671-4276-6a5e-56ca5bd59700",EtWTRABZaYq6iMfeYKouRu166VU2xqa1:"a1b58899-f671-4276-6a5e-56ca5bd59700","000000000019d6689c085ae165831e93":"0b4838db-0161-4ffe-022d-532bf03dba00","000000000933ea01ad0ee984209779ba":"39354064-d79b-420b-065d-f980c4b78200"},ConnectorImageIds:{[i.o.CONNECTOR_ID.COINBASE]:"0c2840c3-5b04-4c44-9661-fbd4b49e1800",[i.o.CONNECTOR_ID.COINBASE_SDK]:"0c2840c3-5b04-4c44-9661-fbd4b49e1800",[i.o.CONNECTOR_ID.SAFE]:"461db637-8616-43ce-035a-d89b8a1d5800",[i.o.CONNECTOR_ID.LEDGER]:"54a1aa77-d202-4f8d-0fb2-5d2bb6db0300",[i.o.CONNECTOR_ID.WALLET_CONNECT]:"ef1a1fcf-7fe8-4d69-bd6d-fda1345b4400",[i.o.CONNECTOR_ID.INJECTED]:"07ba87ed-43aa-4adf-4540-9e6a2b9cae00"},ConnectorNamesMap:{[i.o.CONNECTOR_ID.INJECTED]:"Browser Wallet",[i.o.CONNECTOR_ID.WALLET_CONNECT]:"WalletConnect",[i.o.CONNECTOR_ID.COINBASE]:"Coinbase",[i.o.CONNECTOR_ID.COINBASE_SDK]:"Coinbase",[i.o.CONNECTOR_ID.LEDGER]:"Ledger",[i.o.CONNECTOR_ID.SAFE]:"Safe"},ConnectorTypesMap:{[i.o.CONNECTOR_ID.INJECTED]:"INJECTED",[i.o.CONNECTOR_ID.WALLET_CONNECT]:"WALLET_CONNECT",[i.o.CONNECTOR_ID.EIP6963]:"ANNOUNCED",[i.o.CONNECTOR_ID.AUTH]:"AUTH"},WalletConnectRpcChainIds:[1,5,11155111,10,420,42161,421613,137,80001,42220,1313161554,1313161555,56,97,43114,43113,100,8453,84531,7777777,999,324,280]}},40868:(e,t,s)=>{s.d(t,{N:()=>w});var i=s(89168),r=s(39150),n=s(93224),o=s(5813),a=s(19760),c=s(11553),h=s(12472),l=s(99013),p=s(50731),d=s(14479),u=s(16158);const g=o.w.getApiUrl(),f=new a.Z({baseUrl:g,clientId:null}),m=(0,i.BX)({promises:{},page:1,count:0,featured:[],allFeatured:[],recommended:[],allRecommended:[],wallets:[],search:[],isAnalyticsEnabled:!1,excludedWallets:[],isFetchingRecommendedWallets:!1}),w={state:m,subscribeKey:(e,t)=>(0,r.u$)(m,e,t),_getSdkProperties(){const{projectId:e,sdkType:t,sdkVersion:s}=u.H.state;return{projectId:e,st:t||"appkit",sv:s||"html-wagmi-4.2.2"}},_filterOutExtensions:e=>u.H.state.isUniversalProvider?e.filter(e=>Boolean(e.mobile_link||e.desktop_link||e.webapp_link)):e,async _fetchWalletImage(e){const t=`${f.baseUrl}/getWalletImage/${e}`,s=await f.getBlob({path:t,params:w._getSdkProperties()});h.j.setWalletImage(e,URL.createObjectURL(s))},async _fetchNetworkImage(e){const t=`${f.baseUrl}/public/getAssetImage/${e}`,s=await f.getBlob({path:t,params:w._getSdkProperties()});h.j.setNetworkImage(e,URL.createObjectURL(s))},async _fetchConnectorImage(e){const t=`${f.baseUrl}/public/getAssetImage/${e}`,s=await f.getBlob({path:t,params:w._getSdkProperties()});h.j.setConnectorImage(e,URL.createObjectURL(s))},async _fetchCurrencyImage(e){const t=`${f.baseUrl}/public/getCurrencyImage/${e}`,s=await f.getBlob({path:t,params:w._getSdkProperties()});h.j.setCurrencyImage(e,URL.createObjectURL(s))},async _fetchTokenImage(e){const t=`${f.baseUrl}/public/getTokenImage/${e}`,s=await f.getBlob({path:t,params:w._getSdkProperties()});h.j.setTokenImage(e,URL.createObjectURL(s))},async fetchNetworkImages(){const e=l.W.getAllRequestedCaipNetworks(),t=e?.map(({assets:e})=>e?.imageId).filter(Boolean).filter(e=>!n.$.getNetworkImageById(e));t&&await Promise.allSettled(t.map(e=>w._fetchNetworkImage(e)))},async fetchConnectorImages(){const{connectors:e}=p.a.state,t=e.map(({imageId:e})=>e).filter(Boolean);await Promise.allSettled(t.map(e=>w._fetchConnectorImage(e)))},async fetchCurrencyImages(e=[]){await Promise.allSettled(e.map(e=>w._fetchCurrencyImage(e)))},async fetchTokenImages(e=[]){await Promise.allSettled(e.map(e=>w._fetchTokenImage(e)))},async fetchFeaturedWallets(){const{featuredWalletIds:e}=u.H.state;if(e?.length){const{data:t}=await f.get({path:"/getWallets",params:{...w._getSdkProperties(),page:"1",entries:e?.length?String(e.length):"4",include:e?.join(",")}});t.sort((t,s)=>e.indexOf(t.id)-e.indexOf(s.id));const s=t.map(e=>e.image_id).filter(Boolean);await Promise.allSettled(s.map(e=>w._fetchWalletImage(e))),m.featured=t,m.allFeatured=t}},async fetchRecommendedWallets(){try{m.isFetchingRecommendedWallets=!0;const{includeWalletIds:e,excludeWalletIds:t,featuredWalletIds:s}=u.H.state,i=[...t??[],...s??[]].filter(Boolean),r=l.W.getRequestedCaipNetworkIds().join(","),{data:n,count:o}=await f.get({path:"/getWallets",params:{...w._getSdkProperties(),page:"1",chains:r,entries:"4",include:e?.join(","),exclude:i?.join(",")}}),a=c.i.getRecentWallets(),h=n.map(e=>e.image_id).filter(Boolean),p=a.map(e=>e.image_id).filter(Boolean);await Promise.allSettled([...h,...p].map(e=>w._fetchWalletImage(e))),m.recommended=n,m.allRecommended=n,m.count=o??0}catch{}finally{m.isFetchingRecommendedWallets=!1}},async fetchWallets({page:e}){const{includeWalletIds:t,excludeWalletIds:s,featuredWalletIds:i}=u.H.state,r=l.W.getRequestedCaipNetworkIds().join(","),n=[...m.recommended.map(({id:e})=>e),...s??[],...i??[]].filter(Boolean),{data:a,count:c}=await f.get({path:"/getWallets",params:{...w._getSdkProperties(),page:String(e),entries:"40",chains:r,include:t?.join(","),exclude:n.join(",")}}),h=a.slice(0,20).map(e=>e.image_id).filter(Boolean);await Promise.allSettled(h.map(e=>w._fetchWalletImage(e))),m.wallets=o.w.uniqueBy([...m.wallets,...w._filterOutExtensions(a)],"id"),m.count=c>m.count?c:m.count,m.page=e},async initializeExcludedWallets({ids:e}){const t=l.W.getRequestedCaipNetworkIds().join(","),{data:s}=await f.get({path:"/getWallets",params:{...w._getSdkProperties(),page:"1",entries:String(e.length),chains:t,include:e?.join(",")}});s&&s.forEach(e=>{e?.rdns&&m.excludedWallets.push({rdns:e.rdns,name:e.name})})},async searchWallet({search:e,badge:t}){const{includeWalletIds:s,excludeWalletIds:i}=u.H.state;m.search=[];const r=l.W.getRequestedCaipNetworkIds().join(","),{data:n}=await f.get({path:"/getWallets",params:{...w._getSdkProperties(),page:"1",entries:"100",search:e?.trim(),badge_type:t,chains:r,include:s?.join(","),exclude:i?.join(",")}});d.E.sendEvent({type:"track",event:"SEARCH_WALLET",properties:{badge:t??"",search:e??""}});const a=n.map(e=>e.image_id).filter(Boolean);await Promise.allSettled([...a.map(e=>w._fetchWalletImage(e)),o.w.wait(300)]),m.search=w._filterOutExtensions(n)},initPromise:(e,t)=>m.promises[e]||(m.promises[e]=t()),prefetch({fetchConnectorImages:e=!0,fetchFeaturedWallets:t=!0,fetchRecommendedWallets:s=!0,fetchNetworkImages:i=!0}={}){const r=[e&&w.initPromise("connectorImages",w.fetchConnectorImages),t&&w.initPromise("featuredWallets",w.fetchFeaturedWallets),s&&w.initPromise("recommendedWallets",w.fetchRecommendedWallets),i&&w.initPromise("networkImages",w.fetchNetworkImages)].filter(Boolean);return Promise.allSettled(r)},prefetchAnalyticsConfig(){u.H.state.features?.analytics&&w.fetchAnalyticsConfig()},async fetchAnalyticsConfig(){try{const{isAnalyticsEnabled:e}=await f.get({path:"/getAnalyticsConfig",params:w._getSdkProperties()});u.H.setFeatures({analytics:e})}catch(e){u.H.setFeatures({analytics:!1})}},setFilterByNamespace(e){if(!e)return m.featured=m.allFeatured,void(m.recommended=m.allRecommended);const t=l.W.getRequestedCaipNetworkIds().join(",");m.featured=m.allFeatured.filter(e=>e.chains?.some(e=>t.includes(e))),m.recommended=m.allRecommended.filter(e=>e.chains?.some(e=>t.includes(e)))}}},41276:(e,t,s)=>{s.d(t,{f:()=>i});class i extends Error{constructor(e){super(`WalletConnect Adapter - Method ${e} is not supported by the wallet`),this.name="WalletConnectFeatureNotSupportedError"}}},41430:(e,t,s)=>{s.d(t,{P:()=>c});var i=s(89168),r=s(39150),n=s(5813);const o=Object.freeze({message:"",variant:"success",svg:void 0,open:!1,autoClose:!0}),a=(0,i.BX)({...o}),c={state:a,subscribeKey:(e,t)=>(0,r.u$)(a,e,t),showLoading(e,t={}){this._showMessage({message:e,variant:"loading",...t})},showSuccess(e){this._showMessage({message:e,variant:"success"})},showSvg(e,t){this._showMessage({message:e,svg:t})},showError(e){const t=n.w.parseError(e);this._showMessage({message:t,variant:"error"})},hide(){a.message=o.message,a.variant=o.variant,a.svg=o.svg,a.open=o.open,a.autoClose=o.autoClose},_showMessage({message:e,svg:t,variant:s="success",autoClose:i=o.autoClose}){a.open?(a.open=!1,setTimeout(()=>{a.message=e,a.variant=s,a.svg=t,a.open=!0,a.autoClose=i},150)):(a.message=e,a.variant=s,a.svg=t,a.open=!0,a.autoClose=i)}}},41977:(e,t,s)=>{s.d(t,{_:()=>U});var i=s(1057),r=s(76020),n=s(95191),o=s(59677),a=s(67018),c=s(42831),h=s(16279),l=s(99013),p=s(89058),d=s(50731),u=s(41430),g=s(26545),f=s(16158),m=s(27006),w=s(25422),y=s(14479),b=s(29864),v=s(27938),E=s(93224),I=s(5813),_=s(11553),N=s(24096),A=s(94768),C=s(98207),P=s(28127),S=s(60039),O=s(38132),T=s(15579),k=s(79473),x=s(46779),R=s(86808);class U{constructor(e){this.hasSwitchedToPreferredAccountTypeOnConnect=!1,this.chainNamespaces=[],this.reportedAlertErrors={},this.getCaipNetwork=e=>{if(e){const t=l.W.getNetworkData(e)?.caipNetwork;return t||l.W.getRequestedCaipNetworks(e).filter(t=>t.chainNamespace===e)?.[0]}return l.W.state.activeCaipNetwork||this.defaultCaipNetwork},this.getCaipNetworkId=()=>{const e=this.getCaipNetwork();if(e)return e.id},this.getCaipNetworks=e=>l.W.getRequestedCaipNetworks(e),this.getActiveChainNamespace=()=>l.W.state.activeChain,this.setRequestedCaipNetworks=(e,t)=>{l.W.setRequestedCaipNetworks(e,t)},this.getApprovedCaipNetworkIds=()=>l.W.getAllApprovedCaipNetworkIds(),this.getCaipAddress=e=>l.W.state.activeChain!==e&&e?l.W.getAccountProp("caipAddress",e):l.W.state.activeCaipAddress,this.setClientId=e=>{m.T.setClientId(e)},this.getProvider=e=>k.A.getProvider(e),this.getProviderType=e=>k.A.getProviderId(e),this.getPreferredAccountType=()=>h.U.state.preferredAccountType,this.setCaipAddress=(e,t)=>{h.U.setCaipAddress(e,t)},this.setBalance=(e,t,s)=>{h.U.setBalance(e,t,s)},this.setProfileName=(e,t)=>{h.U.setProfileName(e,t)},this.setProfileImage=(e,t)=>{h.U.setProfileImage(e,t)},this.setUser=(e,t)=>{h.U.setUser(e,t),f.H.state.enableEmbedded&&a.W.close()},this.resetAccount=e=>{h.U.resetAccount(e)},this.setCaipNetwork=e=>{l.W.setActiveCaipNetwork(e)},this.setCaipNetworkOfNamespace=(e,t)=>{l.W.setChainNetworkData(t,{caipNetwork:e})},this.setAllAccounts=(e,t)=>{h.U.setAllAccounts(e,t),f.H.setHasMultipleAddresses(e?.length>1)},this.setStatus=(e,t)=>{h.U.setStatus(e,t),d.a.isConnected()?_.i.setConnectionStatus("connected"):_.i.setConnectionStatus("disconnected")},this.getAddressByChainNamespace=e=>l.W.getAccountProp("address",e),this.setConnectors=e=>{const t=[...d.a.getConnectors(),...e];d.a.setConnectors(t)},this.fetchIdentity=e=>m.T.fetchIdentity(e),this.getReownName=e=>b.f.getNamesForAddress(e),this.getConnectors=()=>d.a.getConnectors(),this.getConnectorImage=e=>E.$.getConnectorImage(e),this.setConnectedWalletInfo=(e,t)=>{const s=k.A.getProviderId(t),i=e?{...e,type:s}:void 0;h.U.setConnectedWalletInfo(i,t)},this.getIsConnectedState=()=>Boolean(l.W.state.activeCaipAddress),this.addAddressLabel=(e,t,s)=>{h.U.addAddressLabel(e,t,s)},this.removeAddressLabel=(e,t)=>{h.U.removeAddressLabel(e,t)},this.getAddress=e=>l.W.state.activeChain!==e&&e?l.W.getAccountProp("address",e):h.U.state.address,this.setApprovedCaipNetworksData=e=>l.W.setApprovedCaipNetworksData(e),this.resetNetwork=e=>{l.W.resetNetwork(e)},this.addConnector=e=>{d.a.addConnector(e)},this.resetWcConnection=()=>{p.x.resetWcConnection()},this.setAddressExplorerUrl=(e,t)=>{h.U.setAddressExplorerUrl(e,t)},this.setSmartAccountDeployed=(e,t)=>{h.U.setSmartAccountDeployed(e,t)},this.setSmartAccountEnabledNetworks=(e,t)=>{l.W.setSmartAccountEnabledNetworks(e,t)},this.setPreferredAccountType=(e,t)=>{h.U.setPreferredAccountType(e,t)},this.setEIP6963Enabled=e=>{f.H.setEIP6963Enabled(e)},this.handleUnsafeRPCRequest=()=>{if(this.isOpen()){if(this.isTransactionStackEmpty())return;this.redirect("ApproveTransaction")}else this.open({view:"ApproveTransaction"})},this.options=e,this.version=e.sdkVersion,this.caipNetworks=this.extendCaipNetworks(e),this.chainNamespaces=[...new Set(this.caipNetworks?.map(e=>e.chainNamespace))],this.defaultCaipNetwork=this.extendDefaultCaipNetwork(e),this.chainAdapters=this.createAdapters(e.adapters),this.initialize(e),this.sendInitializeEvent(e)}async initialize(e){this.initControllers(e),await this.initChainAdapters(),await this.injectModalUi(),await this.syncExistingConnection(),w.z.set({initialized:!0})}sendInitializeEvent(e){const{...t}=e;delete t.adapters,y.E.sendEvent({type:"track",event:"INITIALIZE",properties:{...t,networks:e.networks.map(e=>e.id),siweConfig:{options:e.siweConfig?.options||{}}}})}initControllers(e){this.initializeOptionsController(e),this.initializeChainController(e),this.initializeThemeController(e),this.initializeConnectionController(e),this.initializeConnectorController()}initializeThemeController(e){e.themeMode&&g.W.setThemeMode(e.themeMode),e.themeVariables&&g.W.setThemeVariables(e.themeVariables)}initializeChainController(e){if(!this.connectionControllerClient||!this.networkControllerClient)throw new Error("ConnectionControllerClient and NetworkControllerClient must be set");l.W.initialize(e.adapters??[],this.caipNetworks,{connectionControllerClient:this.connectionControllerClient,networkControllerClient:this.networkControllerClient});const t=this.getDefaultNetwork();t&&l.W.setActiveCaipNetwork(t)}initializeConnectionController(e){p.x.setWcBasic(e.basic??!1)}initializeConnectorController(){d.a.initialize(this.chainNamespaces)}initializeOptionsController(e){f.H.setDebug(!1!==e.debug),f.H.setEnableWalletConnect(!1!==e.enableWalletConnect),f.H.setEnableWalletGuide(!1!==e.enableWalletGuide),f.H.setEnableWallets(!1!==e.enableWallets),f.H.setEIP6963Enabled(!1!==e.enableEIP6963),f.H.setEnableNetworkSwitch(!1!==e.enableNetworkSwitch),f.H.setEnableAuthLogger(!1!==e.enableAuthLogger),f.H.setCustomRpcUrls(e.customRpcUrls),f.H.setSdkVersion(e.sdkVersion),f.H.setProjectId(e.projectId),f.H.setEnableEmbedded(e.enableEmbedded),f.H.setAllWallets(e.allWallets),f.H.setIncludeWalletIds(e.includeWalletIds),f.H.setExcludeWalletIds(e.excludeWalletIds),f.H.setFeaturedWalletIds(e.featuredWalletIds),f.H.setTokens(e.tokens),f.H.setTermsConditionsUrl(e.termsConditionsUrl),f.H.setPrivacyPolicyUrl(e.privacyPolicyUrl),f.H.setCustomWallets(e.customWallets),f.H.setFeatures(e.features),f.H.setAllowUnsupportedChain(e.allowUnsupportedChain),f.H.setDefaultAccountTypes(e.defaultAccountTypes),f.H.setUniversalProviderConfigOverride(e.universalProviderConfigOverride);const t=this.getDefaultMetaData();if(!e.metadata&&t&&(e.metadata=t),f.H.setMetadata(e.metadata),f.H.setDisableAppend(e.disableAppend),f.H.setEnableEmbedded(e.enableEmbedded),f.H.setSIWX(e.siwx),!e.projectId)return void v.h.open(S.R.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error");const s=e.adapters?.find(e=>e.namespace===n.o.CHAIN.EVM);if(s&&e.siweConfig){if(e.siwx)throw new Error("Cannot set both `siweConfig` and `siwx` options");f.H.setSIWX(e.siweConfig.mapToSIWX())}}getDefaultMetaData(){return"undefined"!=typeof window&&"undefined"!=typeof document?{name:document.getElementsByTagName("title")?.[0]?.textContent||"",description:document.querySelector('meta[property="og:description"]')?.content||"",url:window.location.origin,icons:[document.querySelector('link[rel~="icon"]')?.href||""]}:null}setUnsupportedNetwork(e){const t=this.getActiveChainNamespace();if(t){const s=T.R.getUnsupportedNetwork(`${t}:${e}`);l.W.setActiveCaipNetwork(s)}}getDefaultNetwork(){return T.R.getCaipNetworkFromStorage(this.defaultCaipNetwork)}extendCaipNetwork(e,t){return T.R.extendCaipNetwork(e,{customNetworkImageUrls:t.chainImages,projectId:t.projectId})}extendCaipNetworks(e){return T.R.extendCaipNetworks(e.networks,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId})}extendDefaultCaipNetwork(e){const t=e.networks.find(t=>t.id===e.defaultNetwork?.id);return t?T.R.extendCaipNetwork(t,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId}):void 0}createClients(){this.connectionControllerClient={connectWalletConnect:async()=>{const e=l.W.state.activeChain,t=this.getAdapter(e),s=this.getCaipNetwork(e)?.id;if(!t)throw new Error("Adapter not found");const i=await t.connectWalletConnect(s);this.close(),this.setClientId(i?.clientId||null),_.i.setConnectedNamespaces([...l.W.state.chains.keys()]),this.chainNamespaces.forEach(e=>{d.a.setConnectorId(C.o.CONNECTOR_TYPE_WALLET_CONNECT,e)}),await this.syncWalletConnectAccount()},connectExternal:async({id:e,info:t,type:s,provider:i,chain:r,caipNetwork:n})=>{const o=l.W.state.activeChain,a=r||o,c=this.getAdapter(a);if(r&&r!==o&&!n){const e=this.caipNetworks?.find(e=>e.chainNamespace===r);e&&this.setCaipNetwork(e)}if(!c)throw new Error("Adapter not found");const h=this.getCaipNetwork(a),p=await c.connect({id:e,info:t,type:s,provider:i,chainId:n?.id||h?.id,rpcUrl:n?.rpcUrls?.default?.http?.[0]||h?.rpcUrls?.default?.http?.[0]});if(!p)return;_.i.addConnectedNamespace(a),this.syncProvider({...p,chainNamespace:a}),await this.syncAccount({...p,chainNamespace:a});const{accounts:d}=await c.getAccounts({namespace:a,id:e});this.setAllAccounts(d,a)},reconnectExternal:async({id:e,info:t,type:s,provider:i})=>{const r=l.W.state.activeChain,n=this.getAdapter(r);n?.reconnect&&(await(n?.reconnect({id:e,info:t,type:s,provider:i,chainId:this.getCaipNetwork()?.id})),_.i.addConnectedNamespace(r))},disconnect:async e=>{const t=e||l.W.state.activeChain,s=this.getAdapter(t),i=k.A.getProvider(t),r=k.A.getProviderId(t);await(s?.disconnect({provider:i,providerType:r})),_.i.removeConnectedNamespace(t),k.A.resetChain(t),this.setUser(void 0,t),this.setStatus("disconnected",t),this.hasSwitchedToPreferredAccountTypeOnConnect=!1},checkInstalled:e=>e?e.some(e=>Boolean(window.ethereum?.[String(e)])):Boolean(window.ethereum),signMessage:async e=>{const t=this.getAdapter(l.W.state.activeChain),s=await(t?.signMessage({message:e,address:h.U.state.address,provider:k.A.getProvider(l.W.state.activeChain)}));return s?.signature||""},sendTransaction:async e=>{if(e.chainNamespace===n.o.CHAIN.EVM){const t=this.getAdapter(l.W.state.activeChain),s=k.A.getProvider(l.W.state.activeChain),i=await(t?.sendTransaction({...e,caipNetwork:this.getCaipNetwork(),provider:s}));return i?.hash||""}return""},estimateGas:async e=>{if(e.chainNamespace===n.o.CHAIN.EVM){const t=this.getAdapter(l.W.state.activeChain),s=k.A.getProvider(l.W.state.activeChain),i=this.getCaipNetwork();if(!i)throw new Error("CaipNetwork is undefined");const r=await(t?.estimateGas({...e,provider:s,caipNetwork:i}));return r?.gas||0n}return 0n},getEnsAvatar:async()=>{const e=this.getAdapter(l.W.state.activeChain),t=await(e?.getProfile({address:h.U.state.address,chainId:Number(this.getCaipNetwork()?.id)}));return t?.profileImage||!1},getEnsAddress:async e=>{const t=this.getAdapter(l.W.state.activeChain),s=this.getCaipNetwork();if(!s)return!1;const i=await(t?.getEnsAddress({name:e,caipNetwork:s}));return i?.address||!1},writeContract:async e=>{const t=this.getAdapter(l.W.state.activeChain),s=this.getCaipNetwork(),i=this.getCaipAddress(),r=k.A.getProvider(l.W.state.activeChain);if(!s||!i)throw new Error("CaipNetwork or CaipAddress is undefined");const n=await(t?.writeContract({...e,caipNetwork:s,provider:r,caipAddress:i}));return n?.hash},parseUnits:(e,t)=>{const s=this.getAdapter(l.W.state.activeChain);return s?.parseUnits({value:e,decimals:t})??0n},formatUnits:(e,t)=>{const s=this.getAdapter(l.W.state.activeChain);return s?.formatUnits({value:e,decimals:t})??"0"},getCapabilities:async e=>{const t=this.getAdapter(l.W.state.activeChain);return await(t?.getCapabilities(e))},grantPermissions:async e=>{const t=this.getAdapter(l.W.state.activeChain);return await(t?.grantPermissions(e))},revokePermissions:async e=>{const t=this.getAdapter(l.W.state.activeChain);return t?.revokePermissions?await t.revokePermissions(e):"0x"},walletGetAssets:async e=>{const t=this.getAdapter(l.W.state.activeChain);return await(t?.walletGetAssets(e))??{}}},this.networkControllerClient={switchCaipNetwork:async e=>await this.switchCaipNetwork(e),getApprovedCaipNetworksData:async()=>this.getApprovedCaipNetworksData()},p.x.setClient(this.connectionControllerClient)}getApprovedCaipNetworksData(){if(k.A.getProviderId(l.W.state.activeChain)===C.o.CONNECTOR_TYPE_WALLET_CONNECT){const e=this.universalProvider?.session?.namespaces;return{supportsAllNetworks:"MetaMask Wallet"===this.universalProvider?.session?.peer?.metadata.name,approvedCaipNetworkIds:this.getChainsFromNamespaces(e)}}return{supportsAllNetworks:!0,approvedCaipNetworkIds:[]}}async switchCaipNetwork(e){if(!e)return;const t=e.chainNamespace;if(this.getAddressByChainNamespace(e.chainNamespace)){const s=k.A.getProvider(t),i=k.A.getProviderId(t);if(e.chainNamespace===l.W.state.activeChain){const r=this.getAdapter(t);await(r?.switchNetwork({caipNetwork:e,provider:s,providerType:i}))}else if(this.setCaipNetwork(e),i===C.o.CONNECTOR_TYPE_WALLET_CONNECT)this.syncWalletConnectAccount();else{const s=this.getAddressByChainNamespace(t);s&&this.syncAccount({address:s,chainId:e.id,chainNamespace:t})}}else this.setCaipNetwork(e)}getChainsFromNamespaces(e={}){return Object.values(e).flatMap(e=>{const t=e.chains||[],s=e.accounts.map(e=>{const{chainId:t,chainNamespace:s}=o.C.parseCaipAddress(e);return`${s}:${t}`});return Array.from(new Set([...t,...s]))})}createAdapters(e){return this.createClients(),this.chainNamespaces.reduce((t,s)=>{const i=e?.find(e=>e.namespace===s);return i?(t[s]=i,t[s].namespace=s,t[s].construct({namespace:s,projectId:this.options?.projectId,networks:this.caipNetworks})):t[s]=new x.n({namespace:s,networks:this.caipNetworks}),t},{})}async initChainAdapter(e){this.onConnectors(e),this.listenAdapter(e),this.chainAdapters?.[e].syncConnectors(this.options,this),await this.createUniversalProviderForAdapter(e)}async initChainAdapters(){await Promise.all(this.chainNamespaces.map(async e=>{await this.initChainAdapter(e)}))}onConnectors(e){const t=this.getAdapter(e);t?.on("connectors",this.setConnectors.bind(this))}listenAdapter(e){const t=this.getAdapter(e);if(!t)return;const s=_.i.getConnectionStatus();"connected"===s?this.setStatus("connecting",e):"disconnected"===s?(_.i.clearAddressCache(),this.setStatus(s,e)):this.setStatus(s,e),t.on("switchNetwork",({address:t,chainId:s})=>{const i=this.caipNetworks?.find(e=>e.id===s||e.caipNetworkId===s),r=l.W.state.activeChain===e,n=l.W.getAccountProp("address",e);if(i){const i=r&&t?t:n;i&&this.syncAccount({address:i,chainId:s,chainNamespace:e})}else this.setUnsupportedNetwork(s)}),t.on("disconnect",this.disconnect.bind(this,e)),t.on("pendingTransactions",()=>{const e=h.U.state.address,t=l.W.state.activeCaipNetwork;e&&t?.id&&this.updateNativeBalance(e,t.id,t.chainNamespace)}),t.on("accountChanged",({address:t,chainId:s})=>{const i=l.W.state.activeChain===e;i&&s?this.syncAccount({address:t,chainId:s,chainNamespace:e}):i&&l.W.state.activeCaipNetwork?.id?this.syncAccount({address:t,chainId:l.W.state.activeCaipNetwork?.id,chainNamespace:e}):this.syncAccountInfo(t,s,e)})}async createUniversalProviderForAdapter(e){await this.getUniversalProvider(),this.universalProvider&&this.chainAdapters?.[e]?.setUniversalProvider?.(this.universalProvider)}async syncExistingConnection(){await Promise.allSettled(this.chainNamespaces.map(e=>this.syncNamespaceConnection(e)))}async syncNamespaceConnection(e){try{const t=d.a.getConnectorId(e);switch(this.setStatus("connecting",e),t){case n.o.CONNECTOR_ID.WALLET_CONNECT:await this.syncWalletConnectAccount();break;case n.o.CONNECTOR_ID.AUTH:break;default:await this.syncAdapterConnection(e)}}catch(t){console.warn("AppKit couldn't sync existing connection",t),this.setStatus("disconnected",e)}}async syncAdapterConnection(e){const t=this.getAdapter(e),s=d.a.getConnectorId(e),i=this.getCaipNetwork(e),r=d.a.getConnectors(e).find(e=>e.id===s);try{if(!t||!r)throw new Error(`Adapter or connector not found for namespace ${e}`);if(!i?.id)throw new Error("CaipNetwork not found");const s=await(t?.syncConnection({namespace:e,id:r.id,chainId:i.id,rpcUrl:i?.rpcUrls?.default?.http?.[0]}));if(s){const i=await(t?.getAccounts({namespace:e,id:r.id}));i&&i.accounts.length>0?this.setAllAccounts(i.accounts,e):this.setAllAccounts([I.w.createAccount(e,s.address,"eoa")],e),this.syncProvider({...s,chainNamespace:e}),await this.syncAccount({...s,chainNamespace:e}),this.setStatus("connected",e)}else this.setStatus("disconnected",e)}catch(t){this.setStatus("disconnected",e)}}async syncWalletConnectAccount(){const e=this.chainNamespaces.map(async e=>{const t=this.getAdapter(e),s=this.universalProvider?.session?.namespaces?.[e]?.accounts||[],i=l.W.state.activeCaipNetwork?.id,r=s.find(e=>{const{chainId:t}=o.C.parseCaipAddress(e);return t===i?.toString()})||s[0];if(r){const s=o.C.validateCaipAddress(r),{chainId:i,address:a}=o.C.parseCaipAddress(s);if(k.A.setProviderId(e,C.o.CONNECTOR_TYPE_WALLET_CONNECT),this.caipNetworks&&l.W.state.activeCaipNetwork&&t?.namespace!==n.o.CHAIN.EVM){const s=t?.getWalletConnectProvider({caipNetworks:this.caipNetworks,provider:this.universalProvider,activeCaipNetwork:l.W.state.activeCaipNetwork});k.A.setProvider(e,s)}else k.A.setProvider(e,this.universalProvider);d.a.setConnectorId(n.o.CONNECTOR_ID.WALLET_CONNECT,e),_.i.addConnectedNamespace(e),this.syncWalletConnectAccounts(e),await this.syncAccount({address:a,chainId:i,chainNamespace:e})}else this.setStatus("disconnected",e);await l.W.setApprovedCaipNetworksData(e)});await Promise.all(e)}syncWalletConnectAccounts(e){const t=this.universalProvider?.session?.namespaces?.[e]?.accounts?.map(e=>{const{address:t}=o.C.parseCaipAddress(e);return t}).filter((e,t,s)=>s.indexOf(e)===t);t&&this.setAllAccounts(t.map(t=>I.w.createAccount(e,t,"bip122"===e?"payment":"eoa")),e)}syncProvider({type:e,provider:t,id:s,chainNamespace:i}){k.A.setProviderId(i,e),k.A.setProvider(i,t),d.a.setConnectorId(s,i)}async syncAccount(e){const t=e.chainNamespace===l.W.state.activeChain,s=l.W.getCaipNetworkByNamespace(e.chainNamespace,e.chainId),{address:i,chainId:r,chainNamespace:a}=e,{chainId:c}=_.i.getActiveNetworkProps(),p=r||c,d=l.W.state.activeCaipNetwork?.name===n.o.UNSUPPORTED_NETWORK_NAME,u=l.W.getNetworkProp("supportsAllNetworks",a);if(this.setStatus("connected",a),(!d||u)&&p){let e=this.caipNetworks?.find(e=>e.id.toString()===p.toString()),r=this.caipNetworks?.find(e=>e.chainNamespace===a);if(!u&&!e&&!r){const t=this.getApprovedCaipNetworkIds()||[],s=t.find(e=>o.C.parseCaipNetworkId(e)?.chainId===p.toString()),i=t.find(e=>o.C.parseCaipNetworkId(e)?.chainNamespace===a);e=this.caipNetworks?.find(e=>e.caipNetworkId===s),r=this.caipNetworks?.find(e=>e.caipNetworkId===i||"deprecatedCaipNetworkId"in e&&e.deprecatedCaipNetworkId===i)}const c=e||r;c?.chainNamespace===l.W.state.activeChain?f.H.state.enableNetworkSwitch&&!f.H.state.allowUnsupportedChain&&l.W.state.activeCaipNetwork?.name===n.o.UNSUPPORTED_NETWORK_NAME?l.W.showUnsupportedChainUI():this.setCaipNetwork(c):t||s&&this.setCaipNetworkOfNamespace(s,a),this.syncConnectedWalletInfo(a),P.y.isLowerCaseMatch(i,h.U.state.address)||this.syncAccountInfo(i,c?.id,a),t?await this.syncBalance({address:i,chainId:c?.id,chainNamespace:a}):await this.syncBalance({address:i,chainId:s?.id,chainNamespace:a})}}async syncAccountInfo(e,t,s){const i=this.getCaipAddress(s),r=t||i?.split(":")[1];if(!r)return;const n=`${s}:${r}:${e}`;this.setCaipAddress(n,s),await this.syncIdentity({address:e,chainId:r,chainNamespace:s})}async syncReownName(e,t){try{const s=await this.getReownName(e);if(s[0]){const e=s[0];this.setProfileName(e.name,t)}else this.setProfileName(null,t)}catch{this.setProfileName(null,t)}}syncConnectedWalletInfo(e){const t=d.a.getConnectorId(e),s=k.A.getProviderId(e);if(s===C.o.CONNECTOR_TYPE_ANNOUNCED||s===C.o.CONNECTOR_TYPE_INJECTED){if(t){const s=this.getConnectors().find(e=>e.id===t);if(s){const{info:t,name:i,imageUrl:r}=s,n=r||this.getConnectorImage(s);this.setConnectedWalletInfo({name:i,icon:n,...t},e)}}}else if(s===C.o.CONNECTOR_TYPE_WALLET_CONNECT){const t=k.A.getProvider(e);t?.session&&this.setConnectedWalletInfo({...t.session.peer.metadata,name:t.session.peer.metadata.name,icon:t.session.peer.metadata.icons?.[0]},e)}else if(t)if(t===n.o.CONNECTOR_ID.COINBASE){const t=this.getConnectors().find(e=>e.id===n.o.CONNECTOR_ID.COINBASE);this.setConnectedWalletInfo({name:"Coinbase Wallet",icon:this.getConnectorImage(t)},e)}else this.setConnectedWalletInfo({name:t},e)}async syncBalance(e){r.L.getNetworksByNamespace(this.caipNetworks,e.chainNamespace).find(t=>t.id.toString()===e.chainId?.toString())&&e.chainId&&await this.updateNativeBalance(e.address,e.chainId,e.chainNamespace)}async updateNativeBalance(e,t,s){const i=this.getAdapter(s);if(i){const r=await i.getBalance({address:e,chainId:t,caipNetwork:this.getCaipNetwork(s),tokens:this.options.tokens});this.setBalance(r.balance,r.symbol,s)}}async initializeUniversalAdapter(){const e=O.r.createLogger((e,...t)=>{e&&this.handleAlertError(e),console.error(...t)}),t={projectId:this.options?.projectId,metadata:{name:this.options?.metadata?this.options?.metadata.name:"",description:this.options?.metadata?this.options?.metadata.description:"",url:this.options?.metadata?this.options?.metadata.url:"",icons:this.options?.metadata?this.options?.metadata.icons:[""]},logger:e};f.H.setManualWCControl(Boolean(this.options?.manualWCControl)),this.universalProvider=this.options.universalProvider??await i.A.init(t),this.listenWalletConnect()}listenWalletConnect(){this.universalProvider&&(this.universalProvider.on("display_uri",e=>{p.x.setUri(e)}),this.universalProvider.on("connect",p.x.finalizeWcConnection),this.universalProvider.on("disconnect",()=>{this.chainNamespaces.forEach(e=>{this.resetAccount(e)}),p.x.resetWcConnection()}),this.universalProvider.on("chainChanged",e=>{const t=this.caipNetworks?.find(t=>t.id==e),s=this.getCaipNetwork();t?s?.id!==t?.id&&this.setCaipNetwork(t):this.setUnsupportedNetwork(e)}),this.universalProvider.on("session_event",e=>{if(R.kl.isSessionEventData(e)){const{name:t,data:s}=e.params.event;"accountsChanged"===t&&Array.isArray(s)&&I.w.isCaipAddress(s[0])&&this.syncAccount(o.C.parseCaipAddress(s[0]))}}))}createUniversalProvider(){return!this.universalProviderInitPromise&&I.w.isClient()&&this.options?.projectId&&(this.universalProviderInitPromise=this.initializeUniversalAdapter()),this.universalProviderInitPromise}async getUniversalProvider(){if(!this.universalProvider)try{await this.createUniversalProvider()}catch(e){y.E.sendEvent({type:"error",event:"INTERNAL_SDK_ERROR",properties:{errorType:"UniversalProviderInitError",errorMessage:e instanceof Error?e.message:"Unknown",uncaught:!1}}),console.error("AppKit:getUniversalProvider - Cannot create provider",e)}return this.universalProvider}handleAlertError(e){const t=Object.entries(S.R.UniversalProviderErrors).find(([,{message:t}])=>e.message.includes(t)),[s,i]=t??[],{message:r,alertErrorKey:n}=i??{};if(s&&r&&!this.reportedAlertErrors[s]){const e=S.R.ALERT_ERRORS[n];e&&(v.h.open(e,"error"),this.reportedAlertErrors[s]=!0)}}getAdapter(e){if(e)return this.chainAdapters?.[e]}createAdapter(e){if(!e)return;const t=e.namespace;if(!t)return;this.createClients();const s=e;s.namespace=t,s.construct({namespace:t,projectId:this.options?.projectId,networks:this.caipNetworks}),this.chainNamespaces.includes(t)||this.chainNamespaces.push(t),this.chainAdapters&&(this.chainAdapters[t]=s)}async open(e){await this.injectModalUi(),e?.uri&&p.x.setUri(e.uri),await a.W.open(e)}async close(){await this.injectModalUi(),a.W.close()}setLoading(e,t){a.W.setLoading(e,t)}async disconnect(e){await p.x.disconnect(e)}getError(){return""}getChainId(){return l.W.state.activeCaipNetwork?.id}async switchNetwork(e){const t=this.caipNetworks?.find(t=>t.id===e.id);t?await l.W.switchActiveNetwork(t):v.h.open(S.R.ALERT_ERRORS.SWITCH_NETWORK_NOT_FOUND,"error")}getWalletProvider(){return l.W.state.activeChain?k.A.state.providers[l.W.state.activeChain]:null}getWalletProviderType(){return k.A.getProviderId(l.W.state.activeChain)}subscribeProviders(e){return k.A.subscribeProviders(e)}getThemeMode(){return g.W.state.themeMode}getThemeVariables(){return g.W.state.themeVariables}setThemeMode(e){g.W.setThemeMode(e),(0,A.JX)(g.W.state.themeMode)}setTermsConditionsUrl(e){f.H.setTermsConditionsUrl(e)}setPrivacyPolicyUrl(e){f.H.setPrivacyPolicyUrl(e)}setThemeVariables(e){g.W.setThemeVariables(e),(0,A.ds)(g.W.state.themeVariables)}subscribeTheme(e){return g.W.subscribe(e)}getWalletInfo(){return h.U.state.connectedWalletInfo}getAccount(e){const t=d.a.getAuthConnector(e),s=l.W.getAccountData(e);if(s)return{allAccounts:s.allAccounts,caipAddress:s.caipAddress,address:I.w.getPlainAddress(s.caipAddress),isConnected:Boolean(s.caipAddress),status:s.status,embeddedWalletInfo:t?{user:s.user,authProvider:s.socialProvider||"email",accountType:s.preferredAccountType,isSmartAccountDeployed:Boolean(s.smartAccountDeployed)}:void 0}}subscribeAccount(e,t){const s=()=>{const s=this.getAccount(t);s&&e(s)};t?l.W.subscribeChainProp("accountState",s,t):l.W.subscribe(s),d.a.subscribe(s)}subscribeNetwork(e){return l.W.subscribe(({activeCaipNetwork:t})=>{e({caipNetwork:t,chainId:t?.id,caipNetworkId:t?.caipNetworkId})})}subscribeWalletInfo(e){return h.U.subscribeKey("connectedWalletInfo",e)}subscribeShouldUpdateToAddress(e){h.U.subscribeKey("shouldUpdateToAddress",e)}subscribeCaipNetworkChange(e){l.W.subscribeKey("activeCaipNetwork",e)}getState(){return w.z.state}subscribeState(e){return w.z.subscribe(e)}showErrorMessage(e){u.P.showError(e)}showSuccessMessage(e){u.P.showSuccess(e)}getEvent(){return{...y.E.state}}subscribeEvents(e){return y.E.subscribe(e)}replace(e){c.I.replace(e)}redirect(e){c.I.push(e)}popTransactionStack(e){c.I.popTransactionStack(e)}isOpen(){return a.W.state.open}isTransactionStackEmpty(){return 0===c.I.state.transactionStack.length}isTransactionShouldReplaceView(){return c.I.state.transactionStack[c.I.state.transactionStack.length-1]?.replace}static getInstance(){return this.instance}updateFeatures(e){f.H.setFeatures(e)}updateOptions(e){const t={...f.H.state||{},...e};f.H.setOptions(t)}setConnectMethodsOrder(e){f.H.setConnectMethodsOrder(e)}setWalletFeaturesOrder(e){f.H.setWalletFeaturesOrder(e)}setCollapseWallets(e){f.H.setCollapseWallets(e)}setSocialsOrder(e){f.H.setSocialsOrder(e)}getConnectMethodsOrder(){return N.Aj.getConnectOrderMethod(f.H.state.features,d.a.getConnectors())}removeAdapter(e){const t=this.getIsConnectedState(),s=this.getAdapter(e);if(!s||!this.chainAdapters||t)return;const i=this.caipNetworks?.filter(t=>t.chainNamespace!==e);l.W.removeAdapter(e),d.a.removeAdapter(e),this.chainNamespaces=this.chainNamespaces.filter(t=>t!==e),this.caipNetworks=i,s.removeAllEventListeners(),Reflect.deleteProperty(this.chainAdapters,e)}addAdapter(e,t){const s=e.namespace;if(!this.connectionControllerClient||!this.networkControllerClient)return;if(!this.chainAdapters||!s)return;const i=this.extendCaipNetworks({...this.options,networks:t});this.caipNetworks=[...this.caipNetworks||[],...i],this.createAdapter(e),this.initChainAdapter(s),l.W.addAdapter(e,{connectionControllerClient:this.connectionControllerClient,networkControllerClient:this.networkControllerClient},i)}addNetwork(e,t){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);const s=this.extendCaipNetwork(t,this.options);l.W.addNetwork(s),this.caipNetworks&&!this.caipNetworks?.find(e=>e.id===s.id)&&this.caipNetworks.push(s)}removeNetwork(e,t){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);const s=this.caipNetworks?.find(e=>e.id===t);if(!s)throw new Error(`Network with ID ${t} not found`);if(!this.caipNetworks)return;const i=this.caipNetworks.filter(s=>s.chainNamespace===e&&s.id!==t);if(!i?.length)throw new Error("Cannot remove last network for a namespace");l.W.removeNetwork(e,t),this.caipNetworks=[...i]}}},42831:(e,t,s)=>{s.d(t,{I:()=>p});var i=s(89168),r=s(39150),n=s(16279),o=s(99013),a=s(50731),c=s(67018),h=s(16158);const l=(0,i.BX)({view:"Connect",history:["Connect"],transactionStack:[]}),p={state:l,subscribeKey:(e,t)=>(0,r.u$)(l,e,t),pushTransactionStack(e){l.transactionStack.push(e)},popTransactionStack(e){const t=l.transactionStack.pop();if(t)if(e)this.goBack(),t?.onCancel?.();else{if(t.goBack)this.goBack();else if(t.replace){const e=l.history.indexOf("ConnectingSiwe");e>0?this.goBackToIndex(e-1):(c.W.close(),l.history=[])}else t.view&&this.reset(t.view);t?.onSuccess?.()}},push(e,t){e!==l.view&&(l.view=e,l.history.push(e),l.data=t)},reset(e,t){l.view=e,l.history=[e],l.data=t},replace(e,t){l.history.at(-1)===e||(l.view=e,l.history[l.history.length-1]=e,l.data=t)},goBack(){const e=!o.W.state.activeCaipAddress&&"ConnectingFarcaster"===this.state.view;if(l.history.length>1&&!l.history.includes("UnsupportedChain")){l.history.pop();const[e]=l.history.slice(-1);e&&(l.view=e)}else c.W.close();l.data?.wallet&&(l.data.wallet=void 0),setTimeout(()=>{if(e){n.U.setFarcasterUrl(void 0,o.W.state.activeChain);const e=a.a.getAuthConnector();e?.provider?.reload();const t=(0,i.P9)(h.H.state);e?.provider?.syncDappData?.({metadata:t.metadata,sdkVersion:t.sdkVersion,projectId:t.projectId,sdkType:t.sdkType})}},100)},goBackToIndex(e){if(l.history.length>1){l.history=l.history.slice(0,e+1);const[t]=l.history.slice(-1);t&&(l.view=t)}}}},43039:(e,t,s)=>{s.d(t,{$Bq:()=>jt,$hI:()=>O,ALl:()=>Dt,Alu:()=>is,EHS:()=>Rt,EN$:()=>Ut,EWt:()=>Ot,FR8:()=>cs,FiO:()=>es,GuA:()=>Bt,HNf:()=>Gt,Hbs:()=>gs,Hjj:()=>Ht,IjX:()=>_e,Lp_:()=>xt,M8n:()=>as,OP1:()=>Wt,PAk:()=>le,Pa8:()=>Tt,Qhg:()=>Ft,TeY:()=>rs,V9G:()=>ss,VBM:()=>Re,Van:()=>Lt,WWN:()=>xe,Wx8:()=>E,X3c:()=>ns,XqR:()=>ds,Xw0:()=>_,_Yb:()=>d,_dF:()=>N,aF0:()=>zt,b07:()=>Vt,c82:()=>I,e8_:()=>Oe,esh:()=>Zt,hEn:()=>A,hVC:()=>Te,hwK:()=>Ne,iV1:()=>os,jTh:()=>S,kuU:()=>ts,lFF:()=>b,lVv:()=>w,n3s:()=>P,nyL:()=>ms,oKp:()=>ls,q_h:()=>Ie,sc_:()=>ke,tLy:()=>hs,tk0:()=>Yt,w8K:()=>T,xkc:()=>Ee,z2N:()=>ps});var i=s(91315),r=s(20635),n=s(67822),o=s(71268),a=s(33244),c=(s(97353),s(1030)),h=(s(13360),s(17367),s(39907)),l=s(48526).hp;const p=":";function d(e){const[t,s]=e.split(p);return{namespace:t,reference:s}}function u(e,t){return e.includes(":")?[e]:t.chains||[]}const g="ReactNative",f={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"};function m(){return typeof h<"u"&&typeof h.versions<"u"&&typeof h.versions.node<"u"}function w(){return!(0,r.getDocument)()&&!!(0,r.getNavigator)()&&navigator.product===g}function y(){return!m()&&!!(0,r.getNavigator)()&&!!(0,r.getDocument)()}function b(){return(0,n.g)()||{name:"",description:"",url:"",icons:[""]}}function v(e,t){return e.filter(e=>t.includes(e)).length===e.length}function E(e=i.FIVE_MINUTES,t){const s=(0,i.toMiliseconds)(e||i.FIVE_MINUTES);let r,n,o,a;return{resolve:e=>{o&&r&&(clearTimeout(o),r(e),a=Promise.resolve(e))},reject:e=>{o&&n&&(clearTimeout(o),n(e))},done:()=>new Promise((e,i)=>{if(a)return e(a);o=setTimeout(()=>{const e=new Error(t);a=Promise.reject(e),i(e)},s),r=e,n=i})}}function I(e){const[t,s]=e.split(":"),i={id:void 0,topic:void 0};if("topic"===t&&"string"==typeof s)i.topic=s;else{if("id"!==t||!Number.isInteger(Number(s)))throw new Error(`Invalid target, expected id:number or topic:string, got ${t}:${s}`);i.id=Number(s)}return i}function _(e,t){return(0,i.fromMiliseconds)((t||Date.now())+(0,i.toMiliseconds)(e))}function N(e){return Date.now()>=(0,i.toMiliseconds)(e)}function A(e,t){return`${e}${t?`:${t}`:""}`}function C(e=[],t=[]){return[...new Set([...e,...t])]}async function P({id:e,topic:t,wcDeepLink:i}){var n;try{if(!i)return;const o="string"==typeof i?JSON.parse(i):i,a=o?.href;if("string"!=typeof a)return;const c=function(e,t,s){const i=`requestId=${t}&sessionTopic=${s}`;e.endsWith("/")&&(e=e.slice(0,-1));let r=`${e}`;return r=e.startsWith("https://t.me")?`${r}${e.includes("?")?"&startapp=":"?startapp="}${function(e,t=!1){const s=l.from(e).toString("base64");return t?s.replace(/[=]/g,""):s}(i,!0)}`:`${r}/wc?${i}`,r}(a,e,t),h=w()?f.reactNative:m()?f.node:y()?f.browser:f.unknown;if(h===f.browser){if(null==(n=(0,r.getDocument)())||!n.hasFocus())return void console.warn("Document does not have focus, skipping deeplink.");!function(e){let t="_self";!function(){try{return window.self!==window.top}catch{return!1}}()?(typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)||e.startsWith("https://")||e.startsWith("http://"))&&(t="_blank"):t="_top",window.open(e,t,"noreferrer noopener")}(c)}else h===f.reactNative&&typeof(null==s.g?void 0:s.g.Linking)<"u"&&await s.g.Linking.openURL(c)}catch(e){console.error(e)}}async function S(e,t){let s="";try{if(y()&&(s=localStorage.getItem(t),s))return s;s=await e.getItem(t)}catch(e){console.error(e)}return s}function O(e,t){if(!e.includes(t))return null;const s=e.split(/([&,?,=])/),i=s.indexOf(t);return s[i+2]}function T(){return typeof h<"u"&&"true"===h.env.IS_VITEST}function k(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function x(e,...t){if(!function(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function R(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function U(e,t){x(e);const s=t.outputLen;if(e.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}const D=BigInt(2**32-1),j=BigInt(32);function M(e,t=!1){return t?{h:Number(e&D),l:Number(e>>j&D)}:{h:0|Number(e>>j&D),l:0|Number(e&D)}}const L="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function q(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function $(e,t){return e<<32-t|e>>>t}const B=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];function H(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function W(e){for(let t=0;t<e.length;t++)e[t]=H(e[t])}function z(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),x(e),e}class V{clone(){return this._cloneInto()}}function F(e){const t=t=>e().update(z(t)).digest(),s=e();return t.outputLen=s.outputLen,t.blockLen=s.blockLen,t.create=()=>e(),t}const K=[],G=[],J=[],Y=BigInt(0),Q=BigInt(1),X=BigInt(2),Z=BigInt(7),ee=BigInt(256),te=BigInt(113);for(let e=0,t=Q,s=1,i=0;e<24;e++){[s,i]=[i,(2*s+3*i)%5],K.push(2*(5*i+s)),G.push((e+1)*(e+2)/2%64);let r=Y;for(let e=0;e<7;e++)t=(t<<Q^(t>>Z)*te)%ee,t&X&&(r^=Q<<(Q<<BigInt(e))-Q);J.push(r)}const[se,ie]=function(e,t=!1){let s=new Uint32Array(e.length),i=new Uint32Array(e.length);for(let r=0;r<e.length;r++){const{h:n,l:o}=M(e[r],t);[s[r],i[r]]=[n,o]}return[s,i]}(J,!0),re=(e,t,s)=>s>32?((e,t,s)=>t<<s-32|e>>>64-s)(e,t,s):((e,t,s)=>e<<s|t>>>32-s)(e,t,s),ne=(e,t,s)=>s>32?((e,t,s)=>e<<s-32|t>>>64-s)(e,t,s):((e,t,s)=>t<<s|e>>>32-s)(e,t,s);class oe extends V{constructor(e,t,s,i=!1,r=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=s,this.enableXOF=i,this.rounds=r,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,k(s),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var n;this.state=new Uint8Array(200),this.state32=(n=this.state,new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)))}keccak(){B||W(this.state32),function(e,t=24){const s=new Uint32Array(10);for(let i=24-t;i<24;i++){for(let t=0;t<10;t++)s[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const i=(t+8)%10,r=(t+2)%10,n=s[r],o=s[r+1],a=re(n,o,1)^s[i],c=ne(n,o,1)^s[i+1];for(let s=0;s<50;s+=10)e[t+s]^=a,e[t+s+1]^=c}let t=e[2],r=e[3];for(let s=0;s<24;s++){const i=G[s],n=re(t,r,i),o=ne(t,r,i),a=K[s];t=e[a],r=e[a+1],e[a]=n,e[a+1]=o}for(let t=0;t<50;t+=10){for(let i=0;i<10;i++)s[i]=e[t+i];for(let i=0;i<10;i++)e[t+i]^=~s[(i+2)%10]&s[(i+4)%10]}e[0]^=se[i],e[1]^=ie[i]}s.fill(0)}(this.state32,this.rounds),B||W(this.state32),this.posOut=0,this.pos=0}update(e){R(this);const{blockLen:t,state:s}=this,i=(e=z(e)).length;for(let r=0;r<i;){const n=Math.min(t-this.pos,i-r);for(let t=0;t<n;t++)s[this.pos++]^=e[r++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:s,blockLen:i}=this;e[s]^=t,!!(128&t)&&s===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){R(this,!1),x(e),this.finish();const t=this.state,{blockLen:s}=this;for(let i=0,r=e.length;i<r;){this.posOut>=s&&this.keccak();const n=Math.min(s-this.posOut,r-i);e.set(t.subarray(this.posOut,this.posOut+n),i),this.posOut+=n,i+=n}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return k(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(U(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:t,suffix:s,outputLen:i,rounds:r,enableXOF:n}=this;return e||(e=new oe(t,s,i,n,r)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=r,e.suffix=s,e.outputLen=i,e.enableXOF=n,e.destroyed=this.destroyed,e}}const ae=F(()=>new oe(136,1,32)),ce="https://rpc.walletconnect.org/v1";function he(e){const t=`Ethereum Signed Message:\n${e.length}`,s=(new TextEncoder).encode(t+e);return"0x"+l.from(ae(s)).toString("hex")}function le(e){const t=atob(e),s=new Uint8Array(t.length);for(let e=0;e<t.length;e++)s[e]=t.charCodeAt(e);const i=s[0];if(0===i)throw new Error("No signatures found");const r=1+64*i;if(s.length<r)throw new Error("Transaction data too short for claimed signature count");if(s.length<100)throw new Error("Transaction too short");const n=l.from(e,"base64").slice(1,65);return a.A.encode(n)}var pe=Object.defineProperty,de=Object.defineProperties,ue=Object.getOwnPropertyDescriptors,ge=Object.getOwnPropertySymbols,fe=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable,we=(e,t,s)=>t in e?pe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,ye=(e,t)=>{for(var s in t||(t={}))fe.call(t,s)&&we(e,s,t[s]);if(ge)for(var s of ge(t))me.call(t,s)&&we(e,s,t[s]);return e},be=(e,t)=>de(e,ue(t));const ve=e=>e?.split(":"),Ee=e=>{const t=e&&ve(e);if(t)return t[2]+":"+t[3]},Ie=e=>{const t=e&&ve(e);if(t)return t.pop()};async function _e(e){const{cacao:t,projectId:s}=e,{s:i,p:r}=t,n=Ne(r,r.iss),a=Ie(r.iss);return await async function(e,t,s,i,r,n){switch(s.t){case"eip191":return await async function(e,t,s){return(await(0,o.x)({hash:he(t),signature:s})).toLowerCase()===e.toLowerCase()}(e,t,s.s);case"eip1271":return await async function(e,t,s,i,r,n){const o=d(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{const o="0x1626ba7e",a="0000000000000000000000000000000000000000000000000000000000000040",c="0000000000000000000000000000000000000000000000000000000000000041",h=s.substring(2),l=o+he(t).substring(2)+a+c+h,p=await fetch(`${n||ce}/?chainId=${i}&projectId=${r}`,{method:"POST",body:JSON.stringify({id:Date.now()+Math.floor(1e3*Math.random()),jsonrpc:"2.0",method:"eth_call",params:[{to:e,data:l},"latest"]})}),{result:d}=await p.json();return!!d&&d.slice(0,o.length).toLowerCase()===o.toLowerCase()}catch(e){return console.error("isValidEip1271Signature: ",e),!1}}(e,t,s.s,i,r,n);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${s.t}`)}}(a,n,i,Ee(r.iss),s)}const Ne=(e,t)=>{const s=`${e.domain} wants you to sign in with your Ethereum account:`,i=Ie(t);if(!e.aud&&!e.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let r=e.statement||void 0;const n=`URI: ${e.aud||e.uri}`,o=`Version: ${e.version}`,a=`Chain ID: ${(e=>{const t=e&&ve(e);if(t)return e.includes("did:pkh:")?t[3]:t[1]})(t)}`,c=`Nonce: ${e.nonce}`,h=`Issued At: ${e.iat}`,l=e.exp?`Expiration Time: ${e.exp}`:void 0,p=e.nbf?`Not Before: ${e.nbf}`:void 0,d=e.requestId?`Request ID: ${e.requestId}`:void 0,u=e.resources?`Resources:${e.resources.map(e=>`\n- ${e}`).join("")}`:void 0,g=Re(e.resources);return g&&(r=function(e="",t){Ae(t);const s="I further authorize the stated URI to perform the following actions on my behalf: ";if(e.includes(s))return e;const i=[];let r=0;return Object.keys(t.att).forEach(e=>{const s=Object.keys(t.att[e]).map(e=>({ability:e.split("/")[0],action:e.split("/")[1]}));s.sort((e,t)=>e.action.localeCompare(t.action));const n={};s.forEach(e=>{n[e.ability]||(n[e.ability]=[]),n[e.ability].push(e.action)});const o=Object.keys(n).map(t=>(r++,`(${r}) '${t}': '${n[t].join("', '")}' for '${e}'.`));i.push(o.join(", ").replace(".,","."))}),`${e?e+" ":""}${s}${i.join(" ")}`}(r,Se(g))),[s,i,"",r,"",n,o,a,c,h,l,p,d,u].filter(e=>null!=e).join("\n")};function Ae(e){if(!e)throw new Error("No recap provided, value is undefined");if(!e.att)throw new Error("No `att` property found");const t=Object.keys(e.att);if(null==t||!t.length)throw new Error("No resources found in `att` property");t.forEach(t=>{const s=e.att[t];if(Array.isArray(s))throw new Error(`Resource must be an object: ${t}`);if("object"!=typeof s)throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(s).length)throw new Error(`Resource object is empty: ${t}`);Object.keys(s).forEach(e=>{const t=s[e];if(!Array.isArray(t))throw new Error(`Ability limits ${e} must be an array of objects, found: ${t}`);if(!t.length)throw new Error(`Value of ${e} is empty array, must be an array with objects`);t.forEach(t=>{if("object"!=typeof t)throw new Error(`Ability limits (${e}) must be an array of objects, found: ${t}`)})})})}function Ce(e,t,s={}){t=t?.sort((e,t)=>e.localeCompare(t));const i=t.map(t=>({[`${e}/${t}`]:[s]}));return Object.assign({},...i)}function Pe(e){return Ae(e),`urn:recap:${function(e){return l.from(JSON.stringify(e)).toString("base64")}(e).replace(/=/g,"")}`}function Se(e){const t=function(e){return JSON.parse(l.from(e,"base64").toString("utf-8"))}(e.replace("urn:recap:",""));return Ae(t),t}function Oe(e,t,s){const i=function(e,t,s,i={}){return s?.sort((e,t)=>e.localeCompare(t)),{att:{[e]:Ce(t,s,i)}}}(e,t,s);return Pe(i)}function Te(e,t){const s=function(e,t){Ae(e),Ae(t);const s=Object.keys(e.att).concat(Object.keys(t.att)).sort((e,t)=>e.localeCompare(t)),i={att:{}};return s.forEach(s=>{var r,n;Object.keys((null==(r=e.att)?void 0:r[s])||{}).concat(Object.keys((null==(n=t.att)?void 0:n[s])||{})).sort((e,t)=>e.localeCompare(t)).forEach(r=>{var n,o;i.att[s]=be(ye({},i.att[s]),{[r]:(null==(n=e.att[s])?void 0:n[r])||(null==(o=t.att[s])?void 0:o[r])})})}),i}(Se(e),Se(t));return Pe(s)}function ke(e){var t;const s=Se(e);Ae(s);const i=null==(t=s.att)?void 0:t.eip155;return i?Object.keys(i).map(e=>e.split("/")[1]):[]}function xe(e){const t=Se(e);Ae(t);const s=[];return Object.values(t.att).forEach(e=>{Object.values(e).forEach(e=>{var t;null!=(t=e?.[0])&&t.chains&&s.push(e[0].chains)})}),[...new Set(s.flat())]}function Re(e){if(!e)return;const t=e?.[e.length-1];return function(e){return e&&e.includes("urn:recap:")}(t)?t:void 0}function Ue(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function De(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function je(e,...t){if(!De(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Me(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Le(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}const qe=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");function $e(e){if("string"==typeof e)e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e);else{if(!De(e))throw new Error("Uint8Array expected, got "+typeof e);e=We(e)}return e}function Be(e,t,s=!0){if(void 0===t)return new Uint8Array(e);if(t.length!==e)throw new Error("invalid output length, expected "+e+", got: "+t.length);if(s&&!function(e){return e.byteOffset%4==0}(t))throw new Error("invalid output, must be aligned");return t}function He(e,t,s,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,s,i);const r=BigInt(32),n=BigInt(4294967295),o=Number(s>>r&n),a=Number(s&n),c=i?4:0,h=i?0:4;e.setUint32(t+c,o,i),e.setUint32(t+h,a,i)}function We(e){return Uint8Array.from(e)}function ze(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const Ve=e=>Uint8Array.from(e.split("").map(e=>e.charCodeAt(0))),Fe=Ve("expand 16-byte k"),Ke=Ve("expand 32-byte k"),Ge=qe(Fe),Je=qe(Ke);function Ye(e,t){return e<<t|e>>>32-t}function Qe(e){return e.byteOffset%4==0}const Xe=2**32-1,Ze=new Uint32Array,et=(e,t)=>255&e[t++]|(255&e[t++])<<8;class tt{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,je(e=$e(e),32);const t=et(e,0),s=et(e,2),i=et(e,4),r=et(e,6),n=et(e,8),o=et(e,10),a=et(e,12),c=et(e,14);this.r[0]=8191&t,this.r[1]=8191&(t>>>13|s<<3),this.r[2]=7939&(s>>>10|i<<6),this.r[3]=8191&(i>>>7|r<<9),this.r[4]=255&(r>>>4|n<<12),this.r[5]=n>>>1&8190,this.r[6]=8191&(n>>>14|o<<2),this.r[7]=8065&(o>>>11|a<<5),this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127;for(let t=0;t<8;t++)this.pad[t]=et(e,16+2*t)}process(e,t,s=!1){const i=s?0:2048,{h:r,r:n}=this,o=n[0],a=n[1],c=n[2],h=n[3],l=n[4],p=n[5],d=n[6],u=n[7],g=n[8],f=n[9],m=et(e,t+0),w=et(e,t+2),y=et(e,t+4),b=et(e,t+6),v=et(e,t+8),E=et(e,t+10),I=et(e,t+12),_=et(e,t+14);let N=r[0]+(8191&m),A=r[1]+(8191&(m>>>13|w<<3)),C=r[2]+(8191&(w>>>10|y<<6)),P=r[3]+(8191&(y>>>7|b<<9)),S=r[4]+(8191&(b>>>4|v<<12)),O=r[5]+(v>>>1&8191),T=r[6]+(8191&(v>>>14|E<<2)),k=r[7]+(8191&(E>>>11|I<<5)),x=r[8]+(8191&(I>>>8|_<<8)),R=r[9]+(_>>>5|i),U=0,D=U+N*o+A*(5*f)+C*(5*g)+P*(5*u)+S*(5*d);U=D>>>13,D&=8191,D+=O*(5*p)+T*(5*l)+k*(5*h)+x*(5*c)+R*(5*a),U+=D>>>13,D&=8191;let j=U+N*a+A*o+C*(5*f)+P*(5*g)+S*(5*u);U=j>>>13,j&=8191,j+=O*(5*d)+T*(5*p)+k*(5*l)+x*(5*h)+R*(5*c),U+=j>>>13,j&=8191;let M=U+N*c+A*a+C*o+P*(5*f)+S*(5*g);U=M>>>13,M&=8191,M+=O*(5*u)+T*(5*d)+k*(5*p)+x*(5*l)+R*(5*h),U+=M>>>13,M&=8191;let L=U+N*h+A*c+C*a+P*o+S*(5*f);U=L>>>13,L&=8191,L+=O*(5*g)+T*(5*u)+k*(5*d)+x*(5*p)+R*(5*l),U+=L>>>13,L&=8191;let q=U+N*l+A*h+C*c+P*a+S*o;U=q>>>13,q&=8191,q+=O*(5*f)+T*(5*g)+k*(5*u)+x*(5*d)+R*(5*p),U+=q>>>13,q&=8191;let $=U+N*p+A*l+C*h+P*c+S*a;U=$>>>13,$&=8191,$+=O*o+T*(5*f)+k*(5*g)+x*(5*u)+R*(5*d),U+=$>>>13,$&=8191;let B=U+N*d+A*p+C*l+P*h+S*c;U=B>>>13,B&=8191,B+=O*a+T*o+k*(5*f)+x*(5*g)+R*(5*u),U+=B>>>13,B&=8191;let H=U+N*u+A*d+C*p+P*l+S*h;U=H>>>13,H&=8191,H+=O*c+T*a+k*o+x*(5*f)+R*(5*g),U+=H>>>13,H&=8191;let W=U+N*g+A*u+C*d+P*p+S*l;U=W>>>13,W&=8191,W+=O*h+T*c+k*a+x*o+R*(5*f),U+=W>>>13,W&=8191;let z=U+N*f+A*g+C*u+P*d+S*p;U=z>>>13,z&=8191,z+=O*l+T*h+k*c+x*a+R*o,U+=z>>>13,z&=8191,U=(U<<2)+U|0,U=U+D|0,D=8191&U,U>>>=13,j+=U,r[0]=D,r[1]=j,r[2]=M,r[3]=L,r[4]=q,r[5]=$,r[6]=B,r[7]=H,r[8]=W,r[9]=z}finalize(){const{h:e,pad:t}=this,s=new Uint16Array(10);let i=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=i,i=e[t]>>>13,e[t]&=8191;e[0]+=5*i,i=e[0]>>>13,e[0]&=8191,e[1]+=i,i=e[1]>>>13,e[1]&=8191,e[2]+=i,s[0]=e[0]+5,i=s[0]>>>13,s[0]&=8191;for(let t=1;t<10;t++)s[t]=e[t]+i,i=s[t]>>>13,s[t]&=8191;s[9]-=8192;let r=(1^i)-1;for(let e=0;e<10;e++)s[e]&=r;r=~r;for(let t=0;t<10;t++)e[t]=e[t]&r|s[t];e[0]=65535&(e[0]|e[1]<<13),e[1]=65535&(e[1]>>>3|e[2]<<10),e[2]=65535&(e[2]>>>6|e[3]<<7),e[3]=65535&(e[3]>>>9|e[4]<<4),e[4]=65535&(e[4]>>>12|e[5]<<1|e[6]<<14),e[5]=65535&(e[6]>>>2|e[7]<<11),e[6]=65535&(e[7]>>>5|e[8]<<8),e[7]=65535&(e[8]>>>8|e[9]<<5);let n=e[0]+t[0];e[0]=65535&n;for(let s=1;s<8;s++)n=(e[s]+t[s]|0)+(n>>>16)|0,e[s]=65535&n;ze(s)}update(e){Me(this);const{buffer:t,blockLen:s}=this,i=(e=$e(e)).length;for(let r=0;r<i;){const n=Math.min(s-this.pos,i-r);if(n!==s)t.set(e.subarray(r,r+n),this.pos),this.pos+=n,r+=n,this.pos===s&&(this.process(t,0,!1),this.pos=0);else for(;s<=i-r;r+=s)this.process(e,r)}return this}destroy(){ze(this.h,this.r,this.buffer,this.pad)}digestInto(e){Me(this),function(e,t){je(e);const s=t.outputLen;if(e.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}(e,this),this.finished=!0;const{buffer:t,h:s}=this;let{pos:i}=this;if(i){for(t[i++]=1;i<16;i++)t[i]=0;this.process(t,0,!0)}this.finalize();let r=0;for(let t=0;t<8;t++)e[r++]=s[t]>>>0,e[r++]=s[t]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const s=e.slice(0,t);return this.destroy(),s}}const st=function(e){const t=(t,s)=>e(s).update($e(t)).digest(),s=e(new Uint8Array(32));return t.outputLen=s.outputLen,t.blockLen=s.blockLen,t.create=t=>e(t),t}(e=>new tt(e)),it=function(e){const{allowShortKeys:t,extendNonceFn:s,counterLength:i,counterRight:r,rounds:n}=function(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t)}(0,{counterRight:!1,counterLength:4,allowShortKeys:!1});return Ue(i),Ue(n),Le(r),Le(t),(o,a,c,h,l=0)=>{je(o),je(a),je(c);const p=c.length;if(void 0===h&&(h=new Uint8Array(p)),je(h),Ue(l),l<0||l>=Xe)throw new Error("arx: counter overflow");if(h.length<p)throw new Error(`arx: output (${h.length}) is shorter than data (${p})`);const d=[];let u,g,f=o.length;if(32===f)d.push(u=We(o)),g=Je;else{if(16!==f||!t)throw new Error(`arx: invalid 32-byte key, got length=${f}`);u=new Uint8Array(32),u.set(o),u.set(o,16),g=Ge,d.push(u)}Qe(a)||d.push(a=We(a));const m=qe(u);if(s){if(24!==a.length)throw new Error("arx: extended nonce must be 24 bytes");s(g,m,qe(a.subarray(0,16)),m),a=a.subarray(16)}const w=16-i;if(w!==a.length)throw new Error(`arx: nonce must be ${w} or 16 bytes`);if(12!==w){const e=new Uint8Array(12);e.set(a,r?0:12-a.length),a=e,d.push(a)}const y=qe(a);return function(e,t,s,i,r,n,o,a){const c=r.length,h=new Uint8Array(64),l=qe(h),p=Qe(r)&&Qe(n),d=p?qe(r):Ze,u=p?qe(n):Ze;for(let g=0;g<c;o++){if(e(t,s,i,l,o,a),o>=Xe)throw new Error("arx: counter overflow");const f=Math.min(64,c-g);if(p&&64===f){const e=g/4;if(g%4!=0)throw new Error("arx: invalid block position");for(let t,s=0;s<16;s++)t=e+s,u[t]=d[t]^l[s];g+=64;continue}for(let e,t=0;t<f;t++)e=g+t,n[e]=r[e]^h[t];g+=f}}(e,g,m,y,c,h,l,n),ze(...d),h}}(function(e,t,s,i,r,n=20){let o=e[0],a=e[1],c=e[2],h=e[3],l=t[0],p=t[1],d=t[2],u=t[3],g=t[4],f=t[5],m=t[6],w=t[7],y=r,b=s[0],v=s[1],E=s[2],I=o,_=a,N=c,A=h,C=l,P=p,S=d,O=u,T=g,k=f,x=m,R=w,U=y,D=b,j=v,M=E;for(let e=0;e<n;e+=2)I=I+C|0,U=Ye(U^I,16),T=T+U|0,C=Ye(C^T,12),I=I+C|0,U=Ye(U^I,8),T=T+U|0,C=Ye(C^T,7),_=_+P|0,D=Ye(D^_,16),k=k+D|0,P=Ye(P^k,12),_=_+P|0,D=Ye(D^_,8),k=k+D|0,P=Ye(P^k,7),N=N+S|0,j=Ye(j^N,16),x=x+j|0,S=Ye(S^x,12),N=N+S|0,j=Ye(j^N,8),x=x+j|0,S=Ye(S^x,7),A=A+O|0,M=Ye(M^A,16),R=R+M|0,O=Ye(O^R,12),A=A+O|0,M=Ye(M^A,8),R=R+M|0,O=Ye(O^R,7),I=I+P|0,M=Ye(M^I,16),x=x+M|0,P=Ye(P^x,12),I=I+P|0,M=Ye(M^I,8),x=x+M|0,P=Ye(P^x,7),_=_+S|0,U=Ye(U^_,16),R=R+U|0,S=Ye(S^R,12),_=_+S|0,U=Ye(U^_,8),R=R+U|0,S=Ye(S^R,7),N=N+O|0,D=Ye(D^N,16),T=T+D|0,O=Ye(O^T,12),N=N+O|0,D=Ye(D^N,8),T=T+D|0,O=Ye(O^T,7),A=A+C|0,j=Ye(j^A,16),k=k+j|0,C=Ye(C^k,12),A=A+C|0,j=Ye(j^A,8),k=k+j|0,C=Ye(C^k,7);let L=0;i[L++]=o+I|0,i[L++]=a+_|0,i[L++]=c+N|0,i[L++]=h+A|0,i[L++]=l+C|0,i[L++]=p+P|0,i[L++]=d+S|0,i[L++]=u+O|0,i[L++]=g+T|0,i[L++]=f+k|0,i[L++]=m+x|0,i[L++]=w+R|0,i[L++]=y+U|0,i[L++]=b+D|0,i[L++]=v+j|0,i[L++]=E+M|0}),rt=new Uint8Array(16),nt=(e,t)=>{e.update(t);const s=t.length%16;s&&e.update(rt.subarray(s))},ot=new Uint8Array(32);function at(e,t,s,i,r){const n=e(t,s,ot),o=st.create(n);r&&nt(o,r),nt(o,i);const a=new Uint8Array(16),c=(e=>new DataView(e.buffer,e.byteOffset,e.byteLength))(a);He(c,0,BigInt(r?r.length:0),!0),He(c,8,BigInt(i.length),!0),o.update(a);const h=o.digest();return ze(n,a),h}((e,t)=>{Object.assign(function(s,...i){if(je(s),void 0!==e.nonceLength){const t=i[0];if(!t)throw new Error("nonce / iv required");e.varSizeNonce?je(t):je(t,e.nonceLength)}const r=e.tagLength;r&&void 0!==i[1]&&je(i[1]);const n=t(s,...i),o=(e,t)=>{if(void 0!==t){if(2!==e)throw new Error("cipher output not supported");je(t)}};let a=!1;return{encrypt(e,t){if(a)throw new Error("cannot encrypt() twice with same key + nonce");return a=!0,je(e),o(n.encrypt.length,t),n.encrypt(e,t)},decrypt(e,t){if(je(e),r&&e.length<r)throw new Error("invalid ciphertext length: smaller than tagLength="+r);return o(n.decrypt.length,t),n.decrypt(e,t)}}},e)})({blockSize:64,nonceLength:12,tagLength:16},(e=>(t,s,i)=>({encrypt(r,n){const o=r.length;(n=Be(o+16,n,!1)).set(r);const a=n.subarray(0,-16);e(t,s,a,a,1);const c=at(e,t,s,a,i);return n.set(c,o),ze(c),n},decrypt(r,n){n=Be(r.length-16,n,!1);const o=r.subarray(0,-16),a=r.subarray(-16),c=at(e,t,s,o,i);if(!function(e,t){if(e.length!==t.length)return!1;let s=0;for(let i=0;i<e.length;i++)s|=e[i]^t[i];return 0===s}(a,c))throw new Error("invalid tag");return n.set(r.subarray(0,-16)),e(t,s,n,n,1),ze(c),n}}))(it));function ct(e,t,s){return e&t^~e&s}function ht(e,t,s){return e&t^e&s^t&s}new Uint8Array([0]),new Uint8Array;class lt extends V{constructor(e,t,s,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=s,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=q(this.buffer)}update(e){R(this);const{view:t,buffer:s,blockLen:i}=this,r=(e=z(e)).length;for(let n=0;n<r;){const o=Math.min(i-this.pos,r-n);if(o===i){const t=q(e);for(;i<=r-n;n+=i)this.process(t,n);continue}s.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){R(this),U(e,this),this.finished=!0;const{buffer:t,view:s,blockLen:i,isLE:r}=this;let{pos:n}=this;t[n++]=128,this.buffer.subarray(n).fill(0),this.padOffset>i-n&&(this.process(s,0),n=0);for(let e=n;e<i;e++)t[e]=0;(function(e,t,s,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,s,i);const r=BigInt(32),n=BigInt(4294967295),o=Number(s>>r&n),a=Number(s&n),c=i?4:0,h=i?0:4;e.setUint32(t+c,o,i),e.setUint32(t+h,a,i)})(s,i-8,BigInt(8*this.length),r),this.process(s,0);const o=q(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,h=this.get();if(c>h.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)o.setUint32(4*e,h[e],r)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const s=e.slice(0,t);return this.destroy(),s}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:s,length:i,finished:r,destroyed:n,pos:o}=this;return e.length=i,e.pos=o,e.finished=r,e.destroyed=n,i%t&&e.buffer.set(s),e}}const pt=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]),dt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ut=new Uint32Array(64);class gt extends lt{constructor(){super(64,32,8,!1),this.A=0|dt[0],this.B=0|dt[1],this.C=0|dt[2],this.D=0|dt[3],this.E=0|dt[4],this.F=0|dt[5],this.G=0|dt[6],this.H=0|dt[7]}get(){const{A:e,B:t,C:s,D:i,E:r,F:n,G:o,H:a}=this;return[e,t,s,i,r,n,o,a]}set(e,t,s,i,r,n,o,a){this.A=0|e,this.B=0|t,this.C=0|s,this.D=0|i,this.E=0|r,this.F=0|n,this.G=0|o,this.H=0|a}process(e,t){for(let s=0;s<16;s++,t+=4)ut[s]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=ut[e-15],s=ut[e-2],i=$(t,7)^$(t,18)^t>>>3,r=$(s,17)^$(s,19)^s>>>10;ut[e]=r+ut[e-7]+i+ut[e-16]|0}let{A:s,B:i,C:r,D:n,E:o,F:a,G:c,H:h}=this;for(let e=0;e<64;e++){const t=h+($(o,6)^$(o,11)^$(o,25))+ct(o,a,c)+pt[e]+ut[e]|0,l=($(s,2)^$(s,13)^$(s,22))+ht(s,i,r)|0;h=c,c=a,a=o,o=n+t|0,n=r,r=i,i=s,s=t+l|0}s=s+this.A|0,i=i+this.B|0,r=r+this.C|0,n=n+this.D|0,o=o+this.E|0,a=a+this.F|0,c=c+this.G|0,h=h+this.H|0,this.set(s,i,r,n,o,a,c,h)}roundClean(){ut.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const ft=F(()=>new gt);BigInt(0);function mt(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function wt(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function yt(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,s=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const i=new Uint8Array(s);for(let t=0,r=0;t<s;t++,r+=2){const s=wt(e.charCodeAt(r)),n=wt(e.charCodeAt(r+1));if(void 0===s||void 0===n){const t=e[r]+e[r+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+r)}i[t]=16*s+n}return i}const bt={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||mt(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)},vt=BigInt(0);BigInt(1);function Et(e,t){const s=e%t;return s>=vt?s:t+s}function It(e,t,s){let i=e;for(;t-- >vt;)i*=i,i%=s;return i}BigInt(0),BigInt(1),BigInt(0),BigInt(1),BigInt(2),BigInt(8);BigInt(0),BigInt(1);const _t=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const Nt=BigInt(1),At=BigInt(2),Ct=BigInt(3),Pt=BigInt(5);BigInt(8),function(e){const t=function(e){return function(e,t,s={}){const i=(t,s,i)=>{const r=bt[s];if("function"!=typeof r)throw new Error("invalid validator function");const n=e[t];if(!(i&&void 0===n||r(n,e)))throw new Error("param "+String(t)+" is invalid. Expected "+s+", got "+n)};for(const[e,s]of Object.entries(t))i(e,s,!1);for(const[e,t]of Object.entries(s))i(e,t,!0)}(e,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...e})}(e),{P:s}=t,i=e=>Et(e,s),r=t.montgomeryBits,n=Math.ceil(r/8);t.nByteLength,t.adjustScalarBytes,t.powPminus2;t.a,BigInt(2),BigInt(4);function o(e){return function(e,t){return function(e,t){return yt(e.toString(16).padStart(2*t,"0"))}(e,t).reverse()}(i(e),n)}o(t.Gu)}({P:_t,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{const t=_t,{pow_p_5_8:s,b2:i}=function(e){const t=BigInt(10),s=BigInt(20),i=BigInt(40),r=BigInt(80),n=_t,o=e*e%n*e%n,a=It(o,At,n)*o%n,c=It(a,Nt,n)*e%n,h=It(c,Pt,n)*c%n,l=It(h,t,n)*h%n,p=It(l,s,n)*l%n,d=It(p,i,n)*p%n,u=It(d,r,n)*d%n,g=It(u,r,n)*d%n,f=It(g,t,n)*h%n;return{pow_p_5_8:It(f,At,n)*e%n,b2:o}}(e);return Et(It(s,Ct,t)*i,t)},adjustScalarBytes:function(e){return e[0]&=248,e[31]&=127,e[31]|=64,e},randomBytes:function(e=32){if(L&&"function"==typeof L.getRandomValues)return L.getRandomValues(new Uint8Array(e));if(L&&"function"==typeof L.randomBytes)return L.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}});const St="base16",Ot="base64pad",Tt="base64url",kt="utf8",xt=1,Rt=2;function Ut(e){const t=ft((0,c.sH)(e,St));return(0,c.dI)(t,St)}function Dt(e){const t=ft((0,c.sH)(e,kt));return(0,c.dI)(t,St)}function jt(e,t,s){return`${e}?wc_ev=${s}&topic=${t}`}function Mt(e){const t=[];return e.forEach(e=>{const[s,i]=e.split(":");t.push(`${s}:${i}`)}),t}function Lt(e,t){const s=function(e){const t={};return e?.forEach(e=>{var s;const[i,r]=e.split(":");t[i]||(t[i]={accounts:[],chains:[],events:[],methods:[]}),t[i].accounts.push(e),null==(s=t[i].chains)||s.push(`${i}:${r}`)}),t}(t=t.map(e=>e.replace("did:pkh:","")));for(const[t,i]of Object.entries(s))i.methods?i.methods=C(i.methods,e):i.methods=e,i.events=["chainChanged","accountsChanged"];return s}Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;const qt={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}},$t={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 Bt(e,t){const{message:s,code:i}=$t[e];return{message:t?`${s} ${t}`:s,code:i}}function Ht(e,t){const{message:s,code:i}=qt[e];return{message:t?`${s} ${t}`:s,code:i}}function Wt(e,t){return!!Array.isArray(e)&&(!(typeof t<"u"&&e.length)||e.every(t))}function zt(e){return Object.getPrototypeOf(e)===Object.prototype&&Object.keys(e).length}function Vt(e){return typeof e>"u"}function Ft(e,t){return!(!t||!Vt(e))||"string"==typeof e&&!!e.trim().length}function Kt(e,t){return!(!t||!Vt(e))||"number"==typeof e&&!isNaN(e)}function Gt(e,t){const{requiredNamespaces:s}=t,i=Object.keys(e.namespaces),r=Object.keys(s);let n=!0;return!!v(r,i)&&(i.forEach(t=>{const{accounts:i,methods:r,events:o}=e.namespaces[t],a=Mt(i),c=s[t];v(u(t,c),a)&&v(c.methods,r)&&v(c.events,o)||(n=!1)}),n)}function Jt(e){return!(!Ft(e,!1)||!e.includes(":"))&&2===e.split(":").length}function Yt(e,t){let s=null;return Ft(e?.publicKey,!1)||(s=Bt("MISSING_OR_INVALID",`${t} controller public key should be a string`)),s}function Qt(e){let t=!0;return Wt(e)?e.length&&(t=e.every(e=>Ft(e,!1))):t=!1,t}function Xt(e,t){let s=null;return Object.values(e).forEach(e=>{if(s)return;const i=function(e,t){let s=null;return Qt(e?.methods)?Qt(e?.events)||(s=Ht("UNSUPPORTED_EVENTS",`${t}, events should be an array of strings or empty array for no events`)):s=Ht("UNSUPPORTED_METHODS",`${t}, methods should be an array of strings or empty array for no methods`),s}(e,`${t}, namespace`);i&&(s=i)}),s}function Zt(e,t,s){let i=null;if(e&&zt(e)){const r=Xt(e,t);r&&(i=r);const n=function(e,t,s){let i=null;return Object.entries(e).forEach(([e,r])=>{if(i)return;const n=function(e,t,s){let i=null;return Wt(t)&&t.length?t.forEach(e=>{i||Jt(e)||(i=Ht("UNSUPPORTED_CHAINS",`${s}, chain ${e} should be a string and conform to "namespace:chainId" format`))}):Jt(e)||(i=Ht("UNSUPPORTED_CHAINS",`${s}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}(e,u(e,r),`${t} ${s}`);n&&(i=n)}),i}(e,t,s);n&&(i=n)}else i=Bt("MISSING_OR_INVALID",`${t}, ${s} should be an object with data`);return i}function es(e,t){let s=null;if(e&&zt(e)){const i=Xt(e,t);i&&(s=i);const r=function(e,t){let s=null;return Object.values(e).forEach(e=>{if(s)return;const i=function(e,t){let s=null;return Wt(e)?e.forEach(e=>{s||function(e){if(Ft(e,!1)&&e.includes(":")){const t=e.split(":");if(3===t.length){const e=t[0]+":"+t[1];return!!t[2]&&Jt(e)}}return!1}(e)||(s=Ht("UNSUPPORTED_ACCOUNTS",`${t}, account ${e} should be a string and conform to "namespace:chainId:address" format`))}):s=Ht("UNSUPPORTED_ACCOUNTS",`${t}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),s}(e?.accounts,`${t} namespace`);i&&(s=i)}),s}(e,t);r&&(s=r)}else s=Bt("MISSING_OR_INVALID",`${t}, namespaces should be an object with data`);return s}function ts(e){return Ft(e.protocol,!0)}function ss(e,t){let s=!1;return t&&!e?s=!0:e&&Wt(e)&&e.length&&e.forEach(e=>{s=ts(e)}),s}function is(e){return"number"==typeof e}function rs(e){return typeof e<"u"&&null!==typeof e}function ns(e){return!!(e&&"object"==typeof e&&e.code&&Kt(e.code,!1)&&e.message&&Ft(e.message,!1))}function os(e){return!(Vt(e)||!Ft(e.method,!1))}function as(e){return!(Vt(e)||Vt(e.result)&&Vt(e.error)||!Kt(e.id,!1)||!Ft(e.jsonrpc,!1))}function cs(e){return!(Vt(e)||!Ft(e.name,!1))}function hs(e,t){return!(!Jt(t)||!function(e){const t=[];return Object.values(e).forEach(e=>{t.push(...Mt(e.accounts))}),t}(e).includes(t))}function ls(e,t,s){return!!Ft(s,!1)&&function(e,t){const s=[];return Object.values(e).forEach(e=>{Mt(e.accounts).includes(t)&&s.push(...e.methods)}),s}(e,t).includes(s)}function ps(e,t,s){return!!Ft(s,!1)&&function(e,t){const s=[];return Object.values(e).forEach(e=>{Mt(e.accounts).includes(t)&&s.push(...e.events)}),s}(e,t).includes(s)}function ds(e,t,s){let i=null;const r=function(e){const t={};return Object.keys(e).forEach(s=>{var i;s.includes(":")?t[s]=e[s]:null==(i=e[s].chains)||i.forEach(i=>{t[i]={methods:e[s].methods,events:e[s].events}})}),t}(e),n=function(e){const t={};return Object.keys(e).forEach(s=>{if(s.includes(":"))t[s]=e[s];else{const i=Mt(e[s].accounts);i?.forEach(i=>{t[i]={accounts:e[s].accounts.filter(e=>e.includes(`${i}:`)),methods:e[s].methods,events:e[s].events}})}}),t}(t),o=Object.keys(r),a=Object.keys(n),c=us(Object.keys(e)),h=us(Object.keys(t)),l=c.filter(e=>!h.includes(e));return l.length&&(i=Bt("NON_CONFORMING_NAMESPACES",`${s} namespaces keys don't satisfy requiredNamespaces.\n Required: ${l.toString()}\n Received: ${Object.keys(t).toString()}`)),v(o,a)||(i=Bt("NON_CONFORMING_NAMESPACES",`${s} namespaces chains don't satisfy required namespaces.\n Required: ${o.toString()}\n Approved: ${a.toString()}`)),Object.keys(t).forEach(e=>{if(!e.includes(":")||i)return;const r=Mt(t[e].accounts);r.includes(e)||(i=Bt("NON_CONFORMING_NAMESPACES",`${s} namespaces accounts don't satisfy namespace accounts for ${e}\n Required: ${e}\n Approved: ${r.toString()}`))}),o.forEach(e=>{i||(v(r[e].methods,n[e].methods)?v(r[e].events,n[e].events)||(i=Bt("NON_CONFORMING_NAMESPACES",`${s} namespaces events don't satisfy namespace events for ${e}`)):i=Bt("NON_CONFORMING_NAMESPACES",`${s} namespaces methods don't satisfy namespace methods for ${e}`))}),i}function us(e){return[...new Set(e.map(e=>e.includes(":")?e.split(":")[0]:e))]}function gs(e,t){return Kt(e,!1)&&e<=t.max&&e>=t.min}const fs={};class ms{static get(e){return fs[e]}static set(e,t){fs[e]=t}static delete(e){delete fs[e]}}},46779:(e,t,s)=>{s.d(t,{n:()=>u});var i=s(33244),r=s(38903),n=s(95191),o=s(16279),a=s(99013),c=s(84253),h=s(5813),l=s(33816),p=s(76663),d=s(24529);class u extends l.X{setUniversalProvider(e){this.addConnector(new p.F({provider:e,caipNetworks:this.caipNetworks||[],namespace:this.namespace}))}async connect(e){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:Number(e.chainId),provider:this.provider,address:""})}async disconnect(){try{const e=this.getWalletConnectConnector();await e.disconnect()}catch(e){console.warn("UniversalAdapter:disconnect - error",e)}}async getAccounts({namespace:e}){const t=this.provider,s=t?.session?.namespaces?.[e]?.accounts?.map(e=>{const[,,t]=e.split(":");return t}).filter((e,t,s)=>s.indexOf(e)===t)||[];return Promise.resolve({accounts:s.map(t=>h.w.createAccount(e,t,"bip122"===e?"payment":"eoa"))})}async syncConnectors(){return Promise.resolve()}async getBalance(e){if(!e.caipNetwork||!c.oU.BALANCE_SUPPORTED_CHAINS.includes(e.caipNetwork?.chainNamespace)||e.caipNetwork?.testnet)return{balance:"0.00",symbol:e.caipNetwork?.nativeCurrency.symbol||""};if(o.U.state.balanceLoading&&e.chainId===a.W.state.activeCaipNetwork?.id)return{balance:o.U.state.balance||"0.00",symbol:o.U.state.balanceSymbol||""};const t=(await o.U.fetchTokenBalance()).find(t=>t.chainId===`${e.caipNetwork?.chainNamespace}:${e.chainId}`&&t.symbol===e.caipNetwork?.nativeCurrency.symbol);return{balance:t?.quantity.numeric||"0.00",symbol:t?.symbol||e.caipNetwork?.nativeCurrency.symbol||""}}async signMessage(e){const{provider:t,message:s,address:r}=e;if(!t)throw new Error("UniversalAdapter:signMessage - provider is undefined");let o="";return o=a.W.state.activeCaipNetwork?.chainNamespace===n.o.CHAIN.SOLANA?(await t.request({method:"solana_signMessage",params:{message:i.A.encode((new TextEncoder).encode(s)),pubkey:r}},a.W.state.activeCaipNetwork?.caipNetworkId)).signature:await t.request({method:"personal_sign",params:[s,r]},a.W.state.activeCaipNetwork?.caipNetworkId),{signature:o}}async estimateGas(){return Promise.resolve({gas:BigInt(0)})}async getProfile(){return Promise.resolve({profileImage:"",profileName:""})}async sendTransaction(){return Promise.resolve({hash:""})}walletGetAssets(e){return Promise.resolve({})}async writeContract(){return Promise.resolve({hash:""})}async getEnsAddress(){return Promise.resolve({address:!1})}parseUnits(){return 0n}formatUnits(){return"0"}async getCapabilities(){return Promise.resolve({})}async grantPermissions(){return Promise.resolve({})}async revokePermissions(){return Promise.resolve("0x")}async syncConnection(){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:1,provider:this.provider,address:""})}async switchNetwork(e){const{caipNetwork:t}=e,s=this.getWalletConnectConnector();if(t.chainNamespace===n.o.CHAIN.EVM)try{await(s.provider?.request({method:"wallet_switchEthereumChain",params:[{chainId:(0,r.nj)(t.id)}]}))}catch(e){if(e.code===d.E.ERROR_CODE_UNRECOGNIZED_CHAIN_ID||e.code===d.E.ERROR_INVALID_CHAIN_ID||e.code===d.E.ERROR_CODE_DEFAULT||e?.data?.originalError?.code===d.E.ERROR_CODE_UNRECOGNIZED_CHAIN_ID)try{await(s.provider?.request({method:"wallet_addEthereumChain",params:[{chainId:(0,r.nj)(t.id),rpcUrls:[t?.rpcUrls.chainDefault?.http],chainName:t.name,nativeCurrency:t.nativeCurrency,blockExplorerUrls:[t.blockExplorers?.default.url]}]}))}catch(e){throw new Error("Chain is not supported")}}s.provider.setDefaultChain(t.caipNetworkId)}getWalletConnectProvider(){const e=this.connectors.find(e=>"WALLET_CONNECT"===e.type),t=e?.provider;return t}}},47431:(e,t,s)=>{s.d(t,{Hjj:()=>xe,OP1:()=>Re,TRk:()=>n,_Yb:()=>r,aF0:()=>Ue,kob:()=>Te,nWe:()=>Oe}),s(91315),s(20635),s(67822),s(33244),s(97353),s(1030),s(13360),s(17367),s(39907),s(48526).hp;const i=":";function r(e){const[t,s]=e.split(i);return{namespace:t,reference:s}}function n(e=[],t=[]){return[...new Set([...e,...t])]}function o(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function a(e,...t){if(!function(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function c(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function h(e,t){a(e);const s=t.outputLen;if(e.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}const l=BigInt(2**32-1),p=BigInt(32);function d(e,t=!1){return t?{h:Number(e&l),l:Number(e>>p&l)}:{h:0|Number(e>>p&l),l:0|Number(e&l)}}const u="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function g(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function f(e,t){return e<<32-t|e>>>t}const m=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];function w(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function y(e){for(let t=0;t<e.length;t++)e[t]=w(e[t])}function b(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),a(e),e}class v{clone(){return this._cloneInto()}}function E(e){const t=t=>e().update(b(t)).digest(),s=e();return t.outputLen=s.outputLen,t.blockLen=s.blockLen,t.create=()=>e(),t}const I=[],_=[],N=[],A=BigInt(0),C=BigInt(1),P=BigInt(2),S=BigInt(7),O=BigInt(256),T=BigInt(113);for(let e=0,t=C,s=1,i=0;e<24;e++){[s,i]=[i,(2*s+3*i)%5],I.push(2*(5*i+s)),_.push((e+1)*(e+2)/2%64);let r=A;for(let e=0;e<7;e++)t=(t<<C^(t>>S)*T)%O,t&P&&(r^=C<<(C<<BigInt(e))-C);N.push(r)}const[k,x]=function(e,t=!1){let s=new Uint32Array(e.length),i=new Uint32Array(e.length);for(let r=0;r<e.length;r++){const{h:n,l:o}=d(e[r],t);[s[r],i[r]]=[n,o]}return[s,i]}(N,!0),R=(e,t,s)=>s>32?((e,t,s)=>t<<s-32|e>>>64-s)(e,t,s):((e,t,s)=>e<<s|t>>>32-s)(e,t,s),U=(e,t,s)=>s>32?((e,t,s)=>e<<s-32|t>>>64-s)(e,t,s):((e,t,s)=>t<<s|e>>>32-s)(e,t,s);class D extends v{constructor(e,t,s,i=!1,r=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=s,this.enableXOF=i,this.rounds=r,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,o(s),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var n;this.state=new Uint8Array(200),this.state32=(n=this.state,new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)))}keccak(){m||y(this.state32),function(e,t=24){const s=new Uint32Array(10);for(let i=24-t;i<24;i++){for(let t=0;t<10;t++)s[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const i=(t+8)%10,r=(t+2)%10,n=s[r],o=s[r+1],a=R(n,o,1)^s[i],c=U(n,o,1)^s[i+1];for(let s=0;s<50;s+=10)e[t+s]^=a,e[t+s+1]^=c}let t=e[2],r=e[3];for(let s=0;s<24;s++){const i=_[s],n=R(t,r,i),o=U(t,r,i),a=I[s];t=e[a],r=e[a+1],e[a]=n,e[a+1]=o}for(let t=0;t<50;t+=10){for(let i=0;i<10;i++)s[i]=e[t+i];for(let i=0;i<10;i++)e[t+i]^=~s[(i+2)%10]&s[(i+4)%10]}e[0]^=k[i],e[1]^=x[i]}s.fill(0)}(this.state32,this.rounds),m||y(this.state32),this.posOut=0,this.pos=0}update(e){c(this);const{blockLen:t,state:s}=this,i=(e=b(e)).length;for(let r=0;r<i;){const n=Math.min(t-this.pos,i-r);for(let t=0;t<n;t++)s[this.pos++]^=e[r++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:s,blockLen:i}=this;e[s]^=t,!!(128&t)&&s===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){c(this,!1),a(e),this.finish();const t=this.state,{blockLen:s}=this;for(let i=0,r=e.length;i<r;){this.posOut>=s&&this.keccak();const n=Math.min(s-this.posOut,r-i);e.set(t.subarray(this.posOut,this.posOut+n),i),this.posOut+=n,i+=n}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return o(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(h(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:t,suffix:s,outputLen:i,rounds:r,enableXOF:n}=this;return e||(e=new D(t,s,i,n,r)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=r,e.suffix=s,e.outputLen=i,e.enableXOF=n,e.destroyed=this.destroyed,e}}function j(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function M(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function L(e,...t){if(!M(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function q(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function $(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}E(()=>new D(136,1,32)),Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;const B=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");function H(e){if("string"==typeof e)e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e);else{if(!M(e))throw new Error("Uint8Array expected, got "+typeof e);e=V(e)}return e}function W(e,t,s=!0){if(void 0===t)return new Uint8Array(e);if(t.length!==e)throw new Error("invalid output length, expected "+e+", got: "+t.length);if(s&&!function(e){return e.byteOffset%4==0}(t))throw new Error("invalid output, must be aligned");return t}function z(e,t,s,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,s,i);const r=BigInt(32),n=BigInt(4294967295),o=Number(s>>r&n),a=Number(s&n),c=i?4:0,h=i?0:4;e.setUint32(t+c,o,i),e.setUint32(t+h,a,i)}function V(e){return Uint8Array.from(e)}function F(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const K=e=>Uint8Array.from(e.split("").map(e=>e.charCodeAt(0))),G=K("expand 16-byte k"),J=K("expand 32-byte k"),Y=B(G),Q=B(J);function X(e,t){return e<<t|e>>>32-t}function Z(e){return e.byteOffset%4==0}const ee=2**32-1,te=new Uint32Array,se=(e,t)=>255&e[t++]|(255&e[t++])<<8;class ie{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,L(e=H(e),32);const t=se(e,0),s=se(e,2),i=se(e,4),r=se(e,6),n=se(e,8),o=se(e,10),a=se(e,12),c=se(e,14);this.r[0]=8191&t,this.r[1]=8191&(t>>>13|s<<3),this.r[2]=7939&(s>>>10|i<<6),this.r[3]=8191&(i>>>7|r<<9),this.r[4]=255&(r>>>4|n<<12),this.r[5]=n>>>1&8190,this.r[6]=8191&(n>>>14|o<<2),this.r[7]=8065&(o>>>11|a<<5),this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127;for(let t=0;t<8;t++)this.pad[t]=se(e,16+2*t)}process(e,t,s=!1){const i=s?0:2048,{h:r,r:n}=this,o=n[0],a=n[1],c=n[2],h=n[3],l=n[4],p=n[5],d=n[6],u=n[7],g=n[8],f=n[9],m=se(e,t+0),w=se(e,t+2),y=se(e,t+4),b=se(e,t+6),v=se(e,t+8),E=se(e,t+10),I=se(e,t+12),_=se(e,t+14);let N=r[0]+(8191&m),A=r[1]+(8191&(m>>>13|w<<3)),C=r[2]+(8191&(w>>>10|y<<6)),P=r[3]+(8191&(y>>>7|b<<9)),S=r[4]+(8191&(b>>>4|v<<12)),O=r[5]+(v>>>1&8191),T=r[6]+(8191&(v>>>14|E<<2)),k=r[7]+(8191&(E>>>11|I<<5)),x=r[8]+(8191&(I>>>8|_<<8)),R=r[9]+(_>>>5|i),U=0,D=U+N*o+A*(5*f)+C*(5*g)+P*(5*u)+S*(5*d);U=D>>>13,D&=8191,D+=O*(5*p)+T*(5*l)+k*(5*h)+x*(5*c)+R*(5*a),U+=D>>>13,D&=8191;let j=U+N*a+A*o+C*(5*f)+P*(5*g)+S*(5*u);U=j>>>13,j&=8191,j+=O*(5*d)+T*(5*p)+k*(5*l)+x*(5*h)+R*(5*c),U+=j>>>13,j&=8191;let M=U+N*c+A*a+C*o+P*(5*f)+S*(5*g);U=M>>>13,M&=8191,M+=O*(5*u)+T*(5*d)+k*(5*p)+x*(5*l)+R*(5*h),U+=M>>>13,M&=8191;let L=U+N*h+A*c+C*a+P*o+S*(5*f);U=L>>>13,L&=8191,L+=O*(5*g)+T*(5*u)+k*(5*d)+x*(5*p)+R*(5*l),U+=L>>>13,L&=8191;let q=U+N*l+A*h+C*c+P*a+S*o;U=q>>>13,q&=8191,q+=O*(5*f)+T*(5*g)+k*(5*u)+x*(5*d)+R*(5*p),U+=q>>>13,q&=8191;let $=U+N*p+A*l+C*h+P*c+S*a;U=$>>>13,$&=8191,$+=O*o+T*(5*f)+k*(5*g)+x*(5*u)+R*(5*d),U+=$>>>13,$&=8191;let B=U+N*d+A*p+C*l+P*h+S*c;U=B>>>13,B&=8191,B+=O*a+T*o+k*(5*f)+x*(5*g)+R*(5*u),U+=B>>>13,B&=8191;let H=U+N*u+A*d+C*p+P*l+S*h;U=H>>>13,H&=8191,H+=O*c+T*a+k*o+x*(5*f)+R*(5*g),U+=H>>>13,H&=8191;let W=U+N*g+A*u+C*d+P*p+S*l;U=W>>>13,W&=8191,W+=O*h+T*c+k*a+x*o+R*(5*f),U+=W>>>13,W&=8191;let z=U+N*f+A*g+C*u+P*d+S*p;U=z>>>13,z&=8191,z+=O*l+T*h+k*c+x*a+R*o,U+=z>>>13,z&=8191,U=(U<<2)+U|0,U=U+D|0,D=8191&U,U>>>=13,j+=U,r[0]=D,r[1]=j,r[2]=M,r[3]=L,r[4]=q,r[5]=$,r[6]=B,r[7]=H,r[8]=W,r[9]=z}finalize(){const{h:e,pad:t}=this,s=new Uint16Array(10);let i=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=i,i=e[t]>>>13,e[t]&=8191;e[0]+=5*i,i=e[0]>>>13,e[0]&=8191,e[1]+=i,i=e[1]>>>13,e[1]&=8191,e[2]+=i,s[0]=e[0]+5,i=s[0]>>>13,s[0]&=8191;for(let t=1;t<10;t++)s[t]=e[t]+i,i=s[t]>>>13,s[t]&=8191;s[9]-=8192;let r=(1^i)-1;for(let e=0;e<10;e++)s[e]&=r;r=~r;for(let t=0;t<10;t++)e[t]=e[t]&r|s[t];e[0]=65535&(e[0]|e[1]<<13),e[1]=65535&(e[1]>>>3|e[2]<<10),e[2]=65535&(e[2]>>>6|e[3]<<7),e[3]=65535&(e[3]>>>9|e[4]<<4),e[4]=65535&(e[4]>>>12|e[5]<<1|e[6]<<14),e[5]=65535&(e[6]>>>2|e[7]<<11),e[6]=65535&(e[7]>>>5|e[8]<<8),e[7]=65535&(e[8]>>>8|e[9]<<5);let n=e[0]+t[0];e[0]=65535&n;for(let s=1;s<8;s++)n=(e[s]+t[s]|0)+(n>>>16)|0,e[s]=65535&n;F(s)}update(e){q(this);const{buffer:t,blockLen:s}=this,i=(e=H(e)).length;for(let r=0;r<i;){const n=Math.min(s-this.pos,i-r);if(n!==s)t.set(e.subarray(r,r+n),this.pos),this.pos+=n,r+=n,this.pos===s&&(this.process(t,0,!1),this.pos=0);else for(;s<=i-r;r+=s)this.process(e,r)}return this}destroy(){F(this.h,this.r,this.buffer,this.pad)}digestInto(e){q(this),function(e,t){L(e);const s=t.outputLen;if(e.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}(e,this),this.finished=!0;const{buffer:t,h:s}=this;let{pos:i}=this;if(i){for(t[i++]=1;i<16;i++)t[i]=0;this.process(t,0,!0)}this.finalize();let r=0;for(let t=0;t<8;t++)e[r++]=s[t]>>>0,e[r++]=s[t]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const s=e.slice(0,t);return this.destroy(),s}}const re=function(e){const t=(t,s)=>e(s).update(H(t)).digest(),s=e(new Uint8Array(32));return t.outputLen=s.outputLen,t.blockLen=s.blockLen,t.create=t=>e(t),t}(e=>new ie(e)),ne=function(e){const{allowShortKeys:t,extendNonceFn:s,counterLength:i,counterRight:r,rounds:n}=function(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t)}(0,{counterRight:!1,counterLength:4,allowShortKeys:!1});return j(i),j(n),$(r),$(t),(o,a,c,h,l=0)=>{L(o),L(a),L(c);const p=c.length;if(void 0===h&&(h=new Uint8Array(p)),L(h),j(l),l<0||l>=ee)throw new Error("arx: counter overflow");if(h.length<p)throw new Error(`arx: output (${h.length}) is shorter than data (${p})`);const d=[];let u,g,f=o.length;if(32===f)d.push(u=V(o)),g=Q;else{if(16!==f||!t)throw new Error(`arx: invalid 32-byte key, got length=${f}`);u=new Uint8Array(32),u.set(o),u.set(o,16),g=Y,d.push(u)}Z(a)||d.push(a=V(a));const m=B(u);if(s){if(24!==a.length)throw new Error("arx: extended nonce must be 24 bytes");s(g,m,B(a.subarray(0,16)),m),a=a.subarray(16)}const w=16-i;if(w!==a.length)throw new Error(`arx: nonce must be ${w} or 16 bytes`);if(12!==w){const e=new Uint8Array(12);e.set(a,r?0:12-a.length),a=e,d.push(a)}const y=B(a);return function(e,t,s,i,r,n,o,a){const c=r.length,h=new Uint8Array(64),l=B(h),p=Z(r)&&Z(n),d=p?B(r):te,u=p?B(n):te;for(let g=0;g<c;o++){if(e(t,s,i,l,o,a),o>=ee)throw new Error("arx: counter overflow");const f=Math.min(64,c-g);if(p&&64===f){const e=g/4;if(g%4!=0)throw new Error("arx: invalid block position");for(let t,s=0;s<16;s++)t=e+s,u[t]=d[t]^l[s];g+=64;continue}for(let e,t=0;t<f;t++)e=g+t,n[e]=r[e]^h[t];g+=f}}(e,g,m,y,c,h,l,n),F(...d),h}}(function(e,t,s,i,r,n=20){let o=e[0],a=e[1],c=e[2],h=e[3],l=t[0],p=t[1],d=t[2],u=t[3],g=t[4],f=t[5],m=t[6],w=t[7],y=r,b=s[0],v=s[1],E=s[2],I=o,_=a,N=c,A=h,C=l,P=p,S=d,O=u,T=g,k=f,x=m,R=w,U=y,D=b,j=v,M=E;for(let e=0;e<n;e+=2)I=I+C|0,U=X(U^I,16),T=T+U|0,C=X(C^T,12),I=I+C|0,U=X(U^I,8),T=T+U|0,C=X(C^T,7),_=_+P|0,D=X(D^_,16),k=k+D|0,P=X(P^k,12),_=_+P|0,D=X(D^_,8),k=k+D|0,P=X(P^k,7),N=N+S|0,j=X(j^N,16),x=x+j|0,S=X(S^x,12),N=N+S|0,j=X(j^N,8),x=x+j|0,S=X(S^x,7),A=A+O|0,M=X(M^A,16),R=R+M|0,O=X(O^R,12),A=A+O|0,M=X(M^A,8),R=R+M|0,O=X(O^R,7),I=I+P|0,M=X(M^I,16),x=x+M|0,P=X(P^x,12),I=I+P|0,M=X(M^I,8),x=x+M|0,P=X(P^x,7),_=_+S|0,U=X(U^_,16),R=R+U|0,S=X(S^R,12),_=_+S|0,U=X(U^_,8),R=R+U|0,S=X(S^R,7),N=N+O|0,D=X(D^N,16),T=T+D|0,O=X(O^T,12),N=N+O|0,D=X(D^N,8),T=T+D|0,O=X(O^T,7),A=A+C|0,j=X(j^A,16),k=k+j|0,C=X(C^k,12),A=A+C|0,j=X(j^A,8),k=k+j|0,C=X(C^k,7);let L=0;i[L++]=o+I|0,i[L++]=a+_|0,i[L++]=c+N|0,i[L++]=h+A|0,i[L++]=l+C|0,i[L++]=p+P|0,i[L++]=d+S|0,i[L++]=u+O|0,i[L++]=g+T|0,i[L++]=f+k|0,i[L++]=m+x|0,i[L++]=w+R|0,i[L++]=y+U|0,i[L++]=b+D|0,i[L++]=v+j|0,i[L++]=E+M|0}),oe=new Uint8Array(16),ae=(e,t)=>{e.update(t);const s=t.length%16;s&&e.update(oe.subarray(s))},ce=new Uint8Array(32);function he(e,t,s,i,r){const n=e(t,s,ce),o=re.create(n);r&&ae(o,r),ae(o,i);const a=new Uint8Array(16),c=(e=>new DataView(e.buffer,e.byteOffset,e.byteLength))(a);z(c,0,BigInt(r?r.length:0),!0),z(c,8,BigInt(i.length),!0),o.update(a);const h=o.digest();return F(n,a),h}((e,t)=>{Object.assign(function(s,...i){if(L(s),void 0!==e.nonceLength){const t=i[0];if(!t)throw new Error("nonce / iv required");e.varSizeNonce?L(t):L(t,e.nonceLength)}const r=e.tagLength;r&&void 0!==i[1]&&L(i[1]);const n=t(s,...i),o=(e,t)=>{if(void 0!==t){if(2!==e)throw new Error("cipher output not supported");L(t)}};let a=!1;return{encrypt(e,t){if(a)throw new Error("cannot encrypt() twice with same key + nonce");return a=!0,L(e),o(n.encrypt.length,t),n.encrypt(e,t)},decrypt(e,t){if(L(e),r&&e.length<r)throw new Error("invalid ciphertext length: smaller than tagLength="+r);return o(n.decrypt.length,t),n.decrypt(e,t)}}},e)})({blockSize:64,nonceLength:12,tagLength:16},(e=>(t,s,i)=>({encrypt(r,n){const o=r.length;(n=W(o+16,n,!1)).set(r);const a=n.subarray(0,-16);e(t,s,a,a,1);const c=he(e,t,s,a,i);return n.set(c,o),F(c),n},decrypt(r,n){n=W(r.length-16,n,!1);const o=r.subarray(0,-16),a=r.subarray(-16),c=he(e,t,s,o,i);if(!function(e,t){if(e.length!==t.length)return!1;let s=0;for(let i=0;i<e.length;i++)s|=e[i]^t[i];return 0===s}(a,c))throw new Error("invalid tag");return n.set(r.subarray(0,-16)),e(t,s,n,n,1),F(c),n}}))(ne));function le(e,t,s){return e&t^~e&s}function pe(e,t,s){return e&t^e&s^t&s}new Uint8Array([0]),new Uint8Array;class de extends v{constructor(e,t,s,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=s,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=g(this.buffer)}update(e){c(this);const{view:t,buffer:s,blockLen:i}=this,r=(e=b(e)).length;for(let n=0;n<r;){const o=Math.min(i-this.pos,r-n);if(o===i){const t=g(e);for(;i<=r-n;n+=i)this.process(t,n);continue}s.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){c(this),h(e,this),this.finished=!0;const{buffer:t,view:s,blockLen:i,isLE:r}=this;let{pos:n}=this;t[n++]=128,this.buffer.subarray(n).fill(0),this.padOffset>i-n&&(this.process(s,0),n=0);for(let e=n;e<i;e++)t[e]=0;(function(e,t,s,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,s,i);const r=BigInt(32),n=BigInt(4294967295),o=Number(s>>r&n),a=Number(s&n),c=i?4:0,h=i?0:4;e.setUint32(t+c,o,i),e.setUint32(t+h,a,i)})(s,i-8,BigInt(8*this.length),r),this.process(s,0);const o=g(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=a/4,p=this.get();if(l>p.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<l;e++)o.setUint32(4*e,p[e],r)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const s=e.slice(0,t);return this.destroy(),s}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:s,length:i,finished:r,destroyed:n,pos:o}=this;return e.length=i,e.pos=o,e.finished=r,e.destroyed=n,i%t&&e.buffer.set(s),e}}const ue=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]),ge=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),fe=new Uint32Array(64);class me extends de{constructor(){super(64,32,8,!1),this.A=0|ge[0],this.B=0|ge[1],this.C=0|ge[2],this.D=0|ge[3],this.E=0|ge[4],this.F=0|ge[5],this.G=0|ge[6],this.H=0|ge[7]}get(){const{A:e,B:t,C:s,D:i,E:r,F:n,G:o,H:a}=this;return[e,t,s,i,r,n,o,a]}set(e,t,s,i,r,n,o,a){this.A=0|e,this.B=0|t,this.C=0|s,this.D=0|i,this.E=0|r,this.F=0|n,this.G=0|o,this.H=0|a}process(e,t){for(let s=0;s<16;s++,t+=4)fe[s]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=fe[e-15],s=fe[e-2],i=f(t,7)^f(t,18)^t>>>3,r=f(s,17)^f(s,19)^s>>>10;fe[e]=r+fe[e-7]+i+fe[e-16]|0}let{A:s,B:i,C:r,D:n,E:o,F:a,G:c,H:h}=this;for(let e=0;e<64;e++){const t=h+(f(o,6)^f(o,11)^f(o,25))+le(o,a,c)+ue[e]+fe[e]|0,l=(f(s,2)^f(s,13)^f(s,22))+pe(s,i,r)|0;h=c,c=a,a=o,o=n+t|0,n=r,r=i,i=s,s=t+l|0}s=s+this.A|0,i=i+this.B|0,r=r+this.C|0,n=n+this.D|0,o=o+this.E|0,a=a+this.F|0,c=c+this.G|0,h=h+this.H|0,this.set(s,i,r,n,o,a,c,h)}roundClean(){fe.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}E(()=>new me);BigInt(0);function we(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function ye(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function be(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,s=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const i=new Uint8Array(s);for(let t=0,r=0;t<s;t++,r+=2){const s=ye(e.charCodeAt(r)),n=ye(e.charCodeAt(r+1));if(void 0===s||void 0===n){const t=e[r]+e[r+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+r)}i[t]=16*s+n}return i}const ve={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||we(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)},Ee=BigInt(0);BigInt(1);function Ie(e,t){const s=e%t;return s>=Ee?s:t+s}function _e(e,t,s){let i=e;for(;t-- >Ee;)i*=i,i%=s;return i}BigInt(0),BigInt(1),BigInt(0),BigInt(1),BigInt(2),BigInt(8);BigInt(0),BigInt(1);const Ne=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const Ae=BigInt(1),Ce=BigInt(2),Pe=BigInt(3),Se=BigInt(5);function Oe(e){return e.includes(":")}function Te(e){return Oe(e)?e.split(":")[0]:e}BigInt(8),function(e){const t=function(e){return function(e,t,s={}){const i=(t,s,i)=>{const r=ve[s];if("function"!=typeof r)throw new Error("invalid validator function");const n=e[t];if(!(i&&void 0===n||r(n,e)))throw new Error("param "+String(t)+" is invalid. Expected "+s+", got "+n)};for(const[e,s]of Object.entries(t))i(e,s,!1);for(const[e,t]of Object.entries(s))i(e,t,!0)}(e,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...e})}(e),{P:s}=t,i=e=>Ie(e,s),r=t.montgomeryBits,n=Math.ceil(r/8);t.nByteLength,t.adjustScalarBytes,t.powPminus2;t.a,BigInt(2),BigInt(4);function o(e){return function(e,t){return function(e,t){return be(e.toString(16).padStart(2*t,"0"))}(e,t).reverse()}(i(e),n)}o(t.Gu)}({P:Ne,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{const t=Ne,{pow_p_5_8:s,b2:i}=function(e){const t=BigInt(10),s=BigInt(20),i=BigInt(40),r=BigInt(80),n=Ne,o=e*e%n*e%n,a=_e(o,Ce,n)*o%n,c=_e(a,Ae,n)*e%n,h=_e(c,Se,n)*c%n,l=_e(h,t,n)*h%n,p=_e(l,s,n)*l%n,d=_e(p,i,n)*p%n,u=_e(d,r,n)*d%n,g=_e(u,r,n)*d%n,f=_e(g,t,n)*h%n;return{pow_p_5_8:_e(f,Ce,n)*e%n,b2:o}}(e);return Ie(_e(s,Pe,t)*i,t)},adjustScalarBytes:function(e){return e[0]&=248,e[31]&=127,e[31]|=64,e},randomBytes:function(e=32){if(u&&"function"==typeof u.getRandomValues)return u.getRandomValues(new Uint8Array(e));if(u&&"function"==typeof u.randomBytes)return u.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}}),Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;const ke={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}};function xe(e,t){const{message:s,code:i}=ke[e];return{message:t?`${s} ${t}`:s,code:i}}function Re(e,t){return!!Array.isArray(e)&&(!(typeof t<"u"&&e.length)||e.every(t))}function Ue(e){return Object.getPrototypeOf(e)===Object.prototype&&Object.keys(e).length}},48336:(e,t,s)=>{s.d(t,{s:()=>n});var i=s(88315),r=s(58906);function n(e){return new i._({...e,basic:!0,sdkVersion:`html-core-${r.i}`})}},48851:(e,t,s)=>{s.d(t,{ADD:()=>k,ALl:()=>Vt,AYU:()=>ys,AwN:()=>ts,BdH:()=>v,C5G:()=>es,CTo:()=>bs,EN$:()=>zt,EWt:()=>xt,F$L:()=>Qt,GuA:()=>gs,Hjj:()=>fs,K3g:()=>O,Lln:()=>m,Lp_:()=>Dt,PUk:()=>P,QJh:()=>ps,Qhg:()=>ws,R7U:()=>I,TZl:()=>Bt,TeY:()=>Es,Tw2:()=>Yt,U0i:()=>rs,V7m:()=>ss,Wx8:()=>S,Xw0:()=>U,YcA:()=>Jt,_dF:()=>D,aRZ:()=>b,aa1:()=>as,b07:()=>ms,bEt:()=>kt,c82:()=>R,gOF:()=>x,gZm:()=>M,h0Y:()=>C,hEn:()=>j,iui:()=>Zt,jUZ:()=>A,lFF:()=>_,m01:()=>y,mr0:()=>vs,n6V:()=>os,ojD:()=>N,ovp:()=>Wt,ps1:()=>is,sc7:()=>Is,two:()=>Ht,uym:()=>_s,w8K:()=>L,wYp:()=>hs,wa2:()=>Gt,x0t:()=>Kt,yy4:()=>$});var i=s(24661),r=s(91315),n=s(20635),o=s(67822),a=(s(33244),s(97353)),c=s(1030),h=s(13360),l=s(17367),p=s(39907),d=s(48526).hp;const u="ReactNative",g={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},f="js";function m(){return typeof p<"u"&&typeof p.versions<"u"&&typeof p.versions.node<"u"}function w(){return!(0,n.getDocument)()&&!!(0,n.getNavigator)()&&navigator.product===u}function y(){return w()&&typeof s.g<"u"&&typeof(null==s.g?void 0:s.g.Platform)<"u"&&"android"===(null==s.g?void 0:s.g.Platform.OS)}function b(){return w()&&typeof s.g<"u"&&typeof(null==s.g?void 0:s.g.Platform)<"u"&&"ios"===(null==s.g?void 0:s.g.Platform.OS)}function v(){return!m()&&!!(0,n.getNavigator)()&&!!(0,n.getDocument)()}function E(){return w()?g.reactNative:m()?g.node:v()?g.browser:g.unknown}function I(){var e;try{return w()&&typeof s.g<"u"&&typeof(null==s.g?void 0:s.g.Application)<"u"?null==(e=s.g.Application)?void 0:e.applicationId:void 0}catch{return}}function _(){return(0,o.g)()||{name:"",description:"",url:"",icons:[""]}}function N(e,t,r){const o=function(){if(E()===g.reactNative&&typeof s.g<"u"&&typeof(null==s.g?void 0:s.g.Platform)<"u"){const{OS:e,Version:t}=s.g.Platform;return[e,t].join("-")}const e=(0,i.o0)();if(null===e)return"unknown";const t=e.os?e.os.replace(" ","").toLowerCase():"unknown";return"browser"===e.type?[t,e.name,e.version].join("-"):[t,e.version].join("-")}(),a=function(){var e;const t=E();return t===g.browser?[t,(null==(e=(0,n.getLocation)())?void 0:e.host)||"unknown"].join(":"):t}();return[[e,t].join("-"),[f,r].join("-"),o,a].join("/")}function A({protocol:e,version:t,relayUrl:s,sdkVersion:i,auth:r,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:c}){const h=s.split("?"),l={auth:r,ua:N(e,t,i),projectId:n,useOnCloseEvent:o||void 0,packageName:c||void 0,bundleId:a||void 0},p=function(e,t){const s=new URLSearchParams(e);for(const e of Object.keys(t).sort())if(t.hasOwnProperty(e)){const i=t[e];void 0!==i&&s.set(e,i)}return s.toString()}(h[1]||"",l);return h[0]+"?"+p}function C(e){return Object.fromEntries(e.entries())}function P(e){return new Map(Object.entries(e))}function S(e=r.FIVE_MINUTES,t){const s=(0,r.toMiliseconds)(e||r.FIVE_MINUTES);let i,n,o,a;return{resolve:e=>{o&&i&&(clearTimeout(o),i(e),a=Promise.resolve(e))},reject:e=>{o&&n&&(clearTimeout(o),n(e))},done:()=>new Promise((e,r)=>{if(a)return e(a);o=setTimeout(()=>{const e=new Error(t);a=Promise.reject(e),r(e)},s),i=e,n=r})}}function O(e,t,s){return new Promise(async(i,r)=>{const n=setTimeout(()=>r(new Error(s)),t);try{i(await e)}catch(e){r(e)}clearTimeout(n)})}function T(e,t){if("string"==typeof t&&t.startsWith(`${e}:`))return t;if("topic"===e.toLowerCase()){if("string"!=typeof t)throw new Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}if("id"===e.toLowerCase()){if("number"!=typeof t)throw new Error('Value must be "number" for expirer target type: id');return`id:${t}`}throw new Error(`Unknown expirer target type: ${e}`)}function k(e){return T("topic",e)}function x(e){return T("id",e)}function R(e){const[t,s]=e.split(":"),i={id:void 0,topic:void 0};if("topic"===t&&"string"==typeof s)i.topic=s;else{if("id"!==t||!Number.isInteger(Number(s)))throw new Error(`Invalid target, expected id:number or topic:string, got ${t}:${s}`);i.id=Number(s)}return i}function U(e,t){return(0,r.fromMiliseconds)((t||Date.now())+(0,r.toMiliseconds)(e))}function D(e){return Date.now()>=(0,r.toMiliseconds)(e)}function j(e,t){return`${e}${t?`:${t}`:""}`}function M(){return typeof crypto<"u"&&null!=crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function L(){return typeof p<"u"&&"true"===p.env.IS_VITEST}function q(e){return d.from(e,"base64").toString("utf-8")}function $(e){return new Promise(t=>setTimeout(t,e))}function B(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function H(e,...t){if(!function(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function W(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");B(e.outputLen),B(e.blockLen)}function z(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function V(e,t){H(e);const s=t.outputLen;if(e.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}const F=BigInt(2**32-1),K=BigInt(32);function G(e,t=!1){return t?{h:Number(e&F),l:Number(e>>K&F)}:{h:0|Number(e>>K&F),l:0|Number(e&F)}}const J="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function Y(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Q(e,t){return e<<32-t|e>>>t}const X=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];function Z(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function ee(e){for(let t=0;t<e.length;t++)e[t]=Z(e[t])}function te(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),H(e),e}class se{clone(){return this._cloneInto()}}function ie(e){const t=t=>e().update(te(t)).digest(),s=e();return t.outputLen=s.outputLen,t.blockLen=s.blockLen,t.create=()=>e(),t}function re(e=32){if(J&&"function"==typeof J.getRandomValues)return J.getRandomValues(new Uint8Array(e));if(J&&"function"==typeof J.randomBytes)return J.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}const ne=[],oe=[],ae=[],ce=BigInt(0),he=BigInt(1),le=BigInt(2),pe=BigInt(7),de=BigInt(256),ue=BigInt(113);for(let e=0,t=he,s=1,i=0;e<24;e++){[s,i]=[i,(2*s+3*i)%5],ne.push(2*(5*i+s)),oe.push((e+1)*(e+2)/2%64);let r=ce;for(let e=0;e<7;e++)t=(t<<he^(t>>pe)*ue)%de,t&le&&(r^=he<<(he<<BigInt(e))-he);ae.push(r)}const[ge,fe]=function(e,t=!1){let s=new Uint32Array(e.length),i=new Uint32Array(e.length);for(let r=0;r<e.length;r++){const{h:n,l:o}=G(e[r],t);[s[r],i[r]]=[n,o]}return[s,i]}(ae,!0),me=(e,t,s)=>s>32?((e,t,s)=>t<<s-32|e>>>64-s)(e,t,s):((e,t,s)=>e<<s|t>>>32-s)(e,t,s),we=(e,t,s)=>s>32?((e,t,s)=>e<<s-32|t>>>64-s)(e,t,s):((e,t,s)=>t<<s|e>>>32-s)(e,t,s);class ye extends se{constructor(e,t,s,i=!1,r=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=s,this.enableXOF=i,this.rounds=r,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,B(s),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var n;this.state=new Uint8Array(200),this.state32=(n=this.state,new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)))}keccak(){X||ee(this.state32),function(e,t=24){const s=new Uint32Array(10);for(let i=24-t;i<24;i++){for(let t=0;t<10;t++)s[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const i=(t+8)%10,r=(t+2)%10,n=s[r],o=s[r+1],a=me(n,o,1)^s[i],c=we(n,o,1)^s[i+1];for(let s=0;s<50;s+=10)e[t+s]^=a,e[t+s+1]^=c}let t=e[2],r=e[3];for(let s=0;s<24;s++){const i=oe[s],n=me(t,r,i),o=we(t,r,i),a=ne[s];t=e[a],r=e[a+1],e[a]=n,e[a+1]=o}for(let t=0;t<50;t+=10){for(let i=0;i<10;i++)s[i]=e[t+i];for(let i=0;i<10;i++)e[t+i]^=~s[(i+2)%10]&s[(i+4)%10]}e[0]^=ge[i],e[1]^=fe[i]}s.fill(0)}(this.state32,this.rounds),X||ee(this.state32),this.posOut=0,this.pos=0}update(e){z(this);const{blockLen:t,state:s}=this,i=(e=te(e)).length;for(let r=0;r<i;){const n=Math.min(t-this.pos,i-r);for(let t=0;t<n;t++)s[this.pos++]^=e[r++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:s,blockLen:i}=this;e[s]^=t,!!(128&t)&&s===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){z(this,!1),H(e),this.finish();const t=this.state,{blockLen:s}=this;for(let i=0,r=e.length;i<r;){this.posOut>=s&&this.keccak();const n=Math.min(s-this.posOut,r-i);e.set(t.subarray(this.posOut,this.posOut+n),i),this.posOut+=n,i+=n}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return B(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(V(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:t,suffix:s,outputLen:i,rounds:r,enableXOF:n}=this;return e||(e=new ye(t,s,i,n,r)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=r,e.suffix=s,e.outputLen=i,e.enableXOF=n,e.destroyed=this.destroyed,e}}function be(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function ve(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function Ee(e,...t){if(!ve(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Ie(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function _e(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}ie(()=>new ye(136,1,32)),Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;const Ne=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");function Ae(e){if("string"==typeof e)e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e);else{if(!ve(e))throw new Error("Uint8Array expected, got "+typeof e);e=Se(e)}return e}function Ce(e,t,s=!0){if(void 0===t)return new Uint8Array(e);if(t.length!==e)throw new Error("invalid output length, expected "+e+", got: "+t.length);if(s&&!function(e){return e.byteOffset%4==0}(t))throw new Error("invalid output, must be aligned");return t}function Pe(e,t,s,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,s,i);const r=BigInt(32),n=BigInt(4294967295),o=Number(s>>r&n),a=Number(s&n),c=i?4:0,h=i?0:4;e.setUint32(t+c,o,i),e.setUint32(t+h,a,i)}function Se(e){return Uint8Array.from(e)}function Oe(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const Te=e=>Uint8Array.from(e.split("").map(e=>e.charCodeAt(0))),ke=Te("expand 16-byte k"),xe=Te("expand 32-byte k"),Re=Ne(ke),Ue=Ne(xe);function De(e,t){return e<<t|e>>>32-t}function je(e){return e.byteOffset%4==0}const Me=2**32-1,Le=new Uint32Array,qe=(e,t)=>255&e[t++]|(255&e[t++])<<8;class $e{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,Ee(e=Ae(e),32);const t=qe(e,0),s=qe(e,2),i=qe(e,4),r=qe(e,6),n=qe(e,8),o=qe(e,10),a=qe(e,12),c=qe(e,14);this.r[0]=8191&t,this.r[1]=8191&(t>>>13|s<<3),this.r[2]=7939&(s>>>10|i<<6),this.r[3]=8191&(i>>>7|r<<9),this.r[4]=255&(r>>>4|n<<12),this.r[5]=n>>>1&8190,this.r[6]=8191&(n>>>14|o<<2),this.r[7]=8065&(o>>>11|a<<5),this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127;for(let t=0;t<8;t++)this.pad[t]=qe(e,16+2*t)}process(e,t,s=!1){const i=s?0:2048,{h:r,r:n}=this,o=n[0],a=n[1],c=n[2],h=n[3],l=n[4],p=n[5],d=n[6],u=n[7],g=n[8],f=n[9],m=qe(e,t+0),w=qe(e,t+2),y=qe(e,t+4),b=qe(e,t+6),v=qe(e,t+8),E=qe(e,t+10),I=qe(e,t+12),_=qe(e,t+14);let N=r[0]+(8191&m),A=r[1]+(8191&(m>>>13|w<<3)),C=r[2]+(8191&(w>>>10|y<<6)),P=r[3]+(8191&(y>>>7|b<<9)),S=r[4]+(8191&(b>>>4|v<<12)),O=r[5]+(v>>>1&8191),T=r[6]+(8191&(v>>>14|E<<2)),k=r[7]+(8191&(E>>>11|I<<5)),x=r[8]+(8191&(I>>>8|_<<8)),R=r[9]+(_>>>5|i),U=0,D=U+N*o+A*(5*f)+C*(5*g)+P*(5*u)+S*(5*d);U=D>>>13,D&=8191,D+=O*(5*p)+T*(5*l)+k*(5*h)+x*(5*c)+R*(5*a),U+=D>>>13,D&=8191;let j=U+N*a+A*o+C*(5*f)+P*(5*g)+S*(5*u);U=j>>>13,j&=8191,j+=O*(5*d)+T*(5*p)+k*(5*l)+x*(5*h)+R*(5*c),U+=j>>>13,j&=8191;let M=U+N*c+A*a+C*o+P*(5*f)+S*(5*g);U=M>>>13,M&=8191,M+=O*(5*u)+T*(5*d)+k*(5*p)+x*(5*l)+R*(5*h),U+=M>>>13,M&=8191;let L=U+N*h+A*c+C*a+P*o+S*(5*f);U=L>>>13,L&=8191,L+=O*(5*g)+T*(5*u)+k*(5*d)+x*(5*p)+R*(5*l),U+=L>>>13,L&=8191;let q=U+N*l+A*h+C*c+P*a+S*o;U=q>>>13,q&=8191,q+=O*(5*f)+T*(5*g)+k*(5*u)+x*(5*d)+R*(5*p),U+=q>>>13,q&=8191;let $=U+N*p+A*l+C*h+P*c+S*a;U=$>>>13,$&=8191,$+=O*o+T*(5*f)+k*(5*g)+x*(5*u)+R*(5*d),U+=$>>>13,$&=8191;let B=U+N*d+A*p+C*l+P*h+S*c;U=B>>>13,B&=8191,B+=O*a+T*o+k*(5*f)+x*(5*g)+R*(5*u),U+=B>>>13,B&=8191;let H=U+N*u+A*d+C*p+P*l+S*h;U=H>>>13,H&=8191,H+=O*c+T*a+k*o+x*(5*f)+R*(5*g),U+=H>>>13,H&=8191;let W=U+N*g+A*u+C*d+P*p+S*l;U=W>>>13,W&=8191,W+=O*h+T*c+k*a+x*o+R*(5*f),U+=W>>>13,W&=8191;let z=U+N*f+A*g+C*u+P*d+S*p;U=z>>>13,z&=8191,z+=O*l+T*h+k*c+x*a+R*o,U+=z>>>13,z&=8191,U=(U<<2)+U|0,U=U+D|0,D=8191&U,U>>>=13,j+=U,r[0]=D,r[1]=j,r[2]=M,r[3]=L,r[4]=q,r[5]=$,r[6]=B,r[7]=H,r[8]=W,r[9]=z}finalize(){const{h:e,pad:t}=this,s=new Uint16Array(10);let i=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=i,i=e[t]>>>13,e[t]&=8191;e[0]+=5*i,i=e[0]>>>13,e[0]&=8191,e[1]+=i,i=e[1]>>>13,e[1]&=8191,e[2]+=i,s[0]=e[0]+5,i=s[0]>>>13,s[0]&=8191;for(let t=1;t<10;t++)s[t]=e[t]+i,i=s[t]>>>13,s[t]&=8191;s[9]-=8192;let r=(1^i)-1;for(let e=0;e<10;e++)s[e]&=r;r=~r;for(let t=0;t<10;t++)e[t]=e[t]&r|s[t];e[0]=65535&(e[0]|e[1]<<13),e[1]=65535&(e[1]>>>3|e[2]<<10),e[2]=65535&(e[2]>>>6|e[3]<<7),e[3]=65535&(e[3]>>>9|e[4]<<4),e[4]=65535&(e[4]>>>12|e[5]<<1|e[6]<<14),e[5]=65535&(e[6]>>>2|e[7]<<11),e[6]=65535&(e[7]>>>5|e[8]<<8),e[7]=65535&(e[8]>>>8|e[9]<<5);let n=e[0]+t[0];e[0]=65535&n;for(let s=1;s<8;s++)n=(e[s]+t[s]|0)+(n>>>16)|0,e[s]=65535&n;Oe(s)}update(e){Ie(this);const{buffer:t,blockLen:s}=this,i=(e=Ae(e)).length;for(let r=0;r<i;){const n=Math.min(s-this.pos,i-r);if(n!==s)t.set(e.subarray(r,r+n),this.pos),this.pos+=n,r+=n,this.pos===s&&(this.process(t,0,!1),this.pos=0);else for(;s<=i-r;r+=s)this.process(e,r)}return this}destroy(){Oe(this.h,this.r,this.buffer,this.pad)}digestInto(e){Ie(this),function(e,t){Ee(e);const s=t.outputLen;if(e.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}(e,this),this.finished=!0;const{buffer:t,h:s}=this;let{pos:i}=this;if(i){for(t[i++]=1;i<16;i++)t[i]=0;this.process(t,0,!0)}this.finalize();let r=0;for(let t=0;t<8;t++)e[r++]=s[t]>>>0,e[r++]=s[t]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const s=e.slice(0,t);return this.destroy(),s}}const Be=function(e){const t=(t,s)=>e(s).update(Ae(t)).digest(),s=e(new Uint8Array(32));return t.outputLen=s.outputLen,t.blockLen=s.blockLen,t.create=t=>e(t),t}(e=>new $e(e)),He=function(e){const{allowShortKeys:t,extendNonceFn:s,counterLength:i,counterRight:r,rounds:n}=function(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t)}(0,{counterRight:!1,counterLength:4,allowShortKeys:!1});return be(i),be(n),_e(r),_e(t),(o,a,c,h,l=0)=>{Ee(o),Ee(a),Ee(c);const p=c.length;if(void 0===h&&(h=new Uint8Array(p)),Ee(h),be(l),l<0||l>=Me)throw new Error("arx: counter overflow");if(h.length<p)throw new Error(`arx: output (${h.length}) is shorter than data (${p})`);const d=[];let u,g,f=o.length;if(32===f)d.push(u=Se(o)),g=Ue;else{if(16!==f||!t)throw new Error(`arx: invalid 32-byte key, got length=${f}`);u=new Uint8Array(32),u.set(o),u.set(o,16),g=Re,d.push(u)}je(a)||d.push(a=Se(a));const m=Ne(u);if(s){if(24!==a.length)throw new Error("arx: extended nonce must be 24 bytes");s(g,m,Ne(a.subarray(0,16)),m),a=a.subarray(16)}const w=16-i;if(w!==a.length)throw new Error(`arx: nonce must be ${w} or 16 bytes`);if(12!==w){const e=new Uint8Array(12);e.set(a,r?0:12-a.length),a=e,d.push(a)}const y=Ne(a);return function(e,t,s,i,r,n,o,a){const c=r.length,h=new Uint8Array(64),l=Ne(h),p=je(r)&&je(n),d=p?Ne(r):Le,u=p?Ne(n):Le;for(let g=0;g<c;o++){if(e(t,s,i,l,o,a),o>=Me)throw new Error("arx: counter overflow");const f=Math.min(64,c-g);if(p&&64===f){const e=g/4;if(g%4!=0)throw new Error("arx: invalid block position");for(let t,s=0;s<16;s++)t=e+s,u[t]=d[t]^l[s];g+=64;continue}for(let e,t=0;t<f;t++)e=g+t,n[e]=r[e]^h[t];g+=f}}(e,g,m,y,c,h,l,n),Oe(...d),h}}(function(e,t,s,i,r,n=20){let o=e[0],a=e[1],c=e[2],h=e[3],l=t[0],p=t[1],d=t[2],u=t[3],g=t[4],f=t[5],m=t[6],w=t[7],y=r,b=s[0],v=s[1],E=s[2],I=o,_=a,N=c,A=h,C=l,P=p,S=d,O=u,T=g,k=f,x=m,R=w,U=y,D=b,j=v,M=E;for(let e=0;e<n;e+=2)I=I+C|0,U=De(U^I,16),T=T+U|0,C=De(C^T,12),I=I+C|0,U=De(U^I,8),T=T+U|0,C=De(C^T,7),_=_+P|0,D=De(D^_,16),k=k+D|0,P=De(P^k,12),_=_+P|0,D=De(D^_,8),k=k+D|0,P=De(P^k,7),N=N+S|0,j=De(j^N,16),x=x+j|0,S=De(S^x,12),N=N+S|0,j=De(j^N,8),x=x+j|0,S=De(S^x,7),A=A+O|0,M=De(M^A,16),R=R+M|0,O=De(O^R,12),A=A+O|0,M=De(M^A,8),R=R+M|0,O=De(O^R,7),I=I+P|0,M=De(M^I,16),x=x+M|0,P=De(P^x,12),I=I+P|0,M=De(M^I,8),x=x+M|0,P=De(P^x,7),_=_+S|0,U=De(U^_,16),R=R+U|0,S=De(S^R,12),_=_+S|0,U=De(U^_,8),R=R+U|0,S=De(S^R,7),N=N+O|0,D=De(D^N,16),T=T+D|0,O=De(O^T,12),N=N+O|0,D=De(D^N,8),T=T+D|0,O=De(O^T,7),A=A+C|0,j=De(j^A,16),k=k+j|0,C=De(C^k,12),A=A+C|0,j=De(j^A,8),k=k+j|0,C=De(C^k,7);let L=0;i[L++]=o+I|0,i[L++]=a+_|0,i[L++]=c+N|0,i[L++]=h+A|0,i[L++]=l+C|0,i[L++]=p+P|0,i[L++]=d+S|0,i[L++]=u+O|0,i[L++]=g+T|0,i[L++]=f+k|0,i[L++]=m+x|0,i[L++]=w+R|0,i[L++]=y+U|0,i[L++]=b+D|0,i[L++]=v+j|0,i[L++]=E+M|0}),We=new Uint8Array(16),ze=(e,t)=>{e.update(t);const s=t.length%16;s&&e.update(We.subarray(s))},Ve=new Uint8Array(32);function Fe(e,t,s,i,r){const n=e(t,s,Ve),o=Be.create(n);r&&ze(o,r),ze(o,i);const a=new Uint8Array(16),c=(e=>new DataView(e.buffer,e.byteOffset,e.byteLength))(a);Pe(c,0,BigInt(r?r.length:0),!0),Pe(c,8,BigInt(i.length),!0),o.update(a);const h=o.digest();return Oe(n,a),h}const Ke=((e,t)=>{function s(s,...i){if(Ee(s),void 0!==e.nonceLength){const t=i[0];if(!t)throw new Error("nonce / iv required");e.varSizeNonce?Ee(t):Ee(t,e.nonceLength)}const r=e.tagLength;r&&void 0!==i[1]&&Ee(i[1]);const n=t(s,...i),o=(e,t)=>{if(void 0!==t){if(2!==e)throw new Error("cipher output not supported");Ee(t)}};let a=!1;return{encrypt(e,t){if(a)throw new Error("cannot encrypt() twice with same key + nonce");return a=!0,Ee(e),o(n.encrypt.length,t),n.encrypt(e,t)},decrypt(e,t){if(Ee(e),r&&e.length<r)throw new Error("invalid ciphertext length: smaller than tagLength="+r);return o(n.decrypt.length,t),n.decrypt(e,t)}}}return Object.assign(s,e),s})({blockSize:64,nonceLength:12,tagLength:16},(e=>(t,s,i)=>({encrypt(r,n){const o=r.length;(n=Ce(o+16,n,!1)).set(r);const a=n.subarray(0,-16);e(t,s,a,a,1);const c=Fe(e,t,s,a,i);return n.set(c,o),Oe(c),n},decrypt(r,n){n=Ce(r.length-16,n,!1);const o=r.subarray(0,-16),a=r.subarray(-16),c=Fe(e,t,s,o,i);if(!function(e,t){if(e.length!==t.length)return!1;let s=0;for(let i=0;i<e.length;i++)s|=e[i]^t[i];return 0===s}(a,c))throw new Error("invalid tag");return n.set(r.subarray(0,-16)),e(t,s,n,n,1),Oe(c),n}}))(He));class Ge extends se{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,W(e);const s=te(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,r=new Uint8Array(i);r.set(s.length>i?e.create().update(s).digest():s);for(let e=0;e<r.length;e++)r[e]^=54;this.iHash.update(r),this.oHash=e.create();for(let e=0;e<r.length;e++)r[e]^=106;this.oHash.update(r),r.fill(0)}update(e){return z(this),this.iHash.update(e),this}digestInto(e){z(this),H(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:t,iHash:s,finished:i,destroyed:r,blockLen:n,outputLen:o}=this;return e.finished=i,e.destroyed=r,e.blockLen=n,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=s._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Je=(e,t,s)=>new Ge(e,t).update(s).digest();Je.create=(e,t)=>new Ge(e,t);const Ye=new Uint8Array([0]),Qe=new Uint8Array,Xe=(e,t,s,i,r)=>function(e,t,s,i=32){if(W(e),B(i),i>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const r=Math.ceil(i/e.outputLen);void 0===s&&(s=Qe);const n=new Uint8Array(r*e.outputLen),o=Je.create(e,t),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let t=0;t<r;t++)Ye[0]=t+1,a.update(0===t?Qe:c).update(s).update(Ye).digestInto(c),n.set(c,e.outputLen*t),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),Ye.fill(0),n.slice(0,i)}(e,function(e,t,s){return W(e),void 0===s&&(s=new Uint8Array(e.outputLen)),Je(e,te(s),te(t))}(e,t,s),i,r);function Ze(e,t,s){return e&t^~e&s}function et(e,t,s){return e&t^e&s^t&s}class tt extends se{constructor(e,t,s,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=s,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Y(this.buffer)}update(e){z(this);const{view:t,buffer:s,blockLen:i}=this,r=(e=te(e)).length;for(let n=0;n<r;){const o=Math.min(i-this.pos,r-n);if(o===i){const t=Y(e);for(;i<=r-n;n+=i)this.process(t,n);continue}s.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){z(this),V(e,this),this.finished=!0;const{buffer:t,view:s,blockLen:i,isLE:r}=this;let{pos:n}=this;t[n++]=128,this.buffer.subarray(n).fill(0),this.padOffset>i-n&&(this.process(s,0),n=0);for(let e=n;e<i;e++)t[e]=0;(function(e,t,s,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,s,i);const r=BigInt(32),n=BigInt(4294967295),o=Number(s>>r&n),a=Number(s&n),c=i?4:0,h=i?0:4;e.setUint32(t+c,o,i),e.setUint32(t+h,a,i)})(s,i-8,BigInt(8*this.length),r),this.process(s,0);const o=Y(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,h=this.get();if(c>h.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)o.setUint32(4*e,h[e],r)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const s=e.slice(0,t);return this.destroy(),s}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:s,length:i,finished:r,destroyed:n,pos:o}=this;return e.length=i,e.pos=o,e.finished=r,e.destroyed=n,i%t&&e.buffer.set(s),e}}const st=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]),it=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),rt=new Uint32Array(64);class nt extends tt{constructor(){super(64,32,8,!1),this.A=0|it[0],this.B=0|it[1],this.C=0|it[2],this.D=0|it[3],this.E=0|it[4],this.F=0|it[5],this.G=0|it[6],this.H=0|it[7]}get(){const{A:e,B:t,C:s,D:i,E:r,F:n,G:o,H:a}=this;return[e,t,s,i,r,n,o,a]}set(e,t,s,i,r,n,o,a){this.A=0|e,this.B=0|t,this.C=0|s,this.D=0|i,this.E=0|r,this.F=0|n,this.G=0|o,this.H=0|a}process(e,t){for(let s=0;s<16;s++,t+=4)rt[s]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=rt[e-15],s=rt[e-2],i=Q(t,7)^Q(t,18)^t>>>3,r=Q(s,17)^Q(s,19)^s>>>10;rt[e]=r+rt[e-7]+i+rt[e-16]|0}let{A:s,B:i,C:r,D:n,E:o,F:a,G:c,H:h}=this;for(let e=0;e<64;e++){const t=h+(Q(o,6)^Q(o,11)^Q(o,25))+Ze(o,a,c)+st[e]+rt[e]|0,l=(Q(s,2)^Q(s,13)^Q(s,22))+et(s,i,r)|0;h=c,c=a,a=o,o=n+t|0,n=r,r=i,i=s,s=t+l|0}s=s+this.A|0,i=i+this.B|0,r=r+this.C|0,n=n+this.D|0,o=o+this.E|0,a=a+this.F|0,c=c+this.G|0,h=h+this.H|0,this.set(s,i,r,n,o,a,c,h)}roundClean(){rt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const ot=ie(()=>new nt),at=BigInt(0);function ct(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function ht(e){if(!ct(e))throw new Error("Uint8Array expected")}const lt=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function pt(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function dt(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,s=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const i=new Uint8Array(s);for(let t=0,r=0;t<s;t++,r+=2){const s=pt(e.charCodeAt(r)),n=pt(e.charCodeAt(r+1));if(void 0===s||void 0===n){const t=e[r]+e[r+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+r)}i[t]=16*s+n}return i}function ut(e){return ht(e),function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?at:BigInt("0x"+e)}(function(e){ht(e);let t="";for(let s=0;s<e.length;s++)t+=lt[e[s]];return t}(Uint8Array.from(e).reverse()))}function gt(e,t,s){let i;if("string"==typeof t)try{i=dt(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!ct(t))throw new Error(e+" must be hex string or Uint8Array");i=Uint8Array.from(t)}const r=i.length;if("number"==typeof s&&r!==s)throw new Error(e+" of length "+s+" expected, got "+r);return i}const ft=e=>"bigint"==typeof e&&at<=e;function mt(e,t,s,i){if(!function(e,t,s){return ft(e)&&ft(t)&&ft(s)&&t<=e&&e<s}(t,s,i))throw new Error("expected valid "+e+": "+s+" <= n < "+i+", got "+t)}const wt={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||ct(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)},yt=BigInt(0),bt=BigInt(1);function vt(e,t){const s=e%t;return s>=yt?s:t+s}function Et(e,t,s){let i=e;for(;t-- >yt;)i*=i,i%=s;return i}BigInt(0),BigInt(1),BigInt(0),BigInt(1),BigInt(2),BigInt(8);const It=BigInt(0),_t=BigInt(1);const Nt=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const At=BigInt(1),Ct=BigInt(2),Pt=BigInt(3),St=BigInt(5);BigInt(8);const Ot=function(e){const t=function(e){return function(e,t,s={}){const i=(t,s,i)=>{const r=wt[s];if("function"!=typeof r)throw new Error("invalid validator function");const n=e[t];if(!(i&&void 0===n||r(n,e)))throw new Error("param "+String(t)+" is invalid. Expected "+s+", got "+n)};for(const[e,s]of Object.entries(t))i(e,s,!1);for(const[e,t]of Object.entries(s))i(e,t,!0)}(e,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...e})}(e),{P:s}=t,i=e=>vt(e,s),r=t.montgomeryBits,n=Math.ceil(r/8),o=t.nByteLength,a=t.adjustScalarBytes||(e=>e),c=t.powPminus2||(e=>function(e,t,s){if(t<yt)throw new Error("invalid exponent, negatives unsupported");if(s<=yt)throw new Error("invalid modulus");if(s===bt)return yt;let i=bt;for(;t>yt;)t&bt&&(i=i*e%s),e=e*e%s,t>>=bt;return i}(e,s-BigInt(2),s));function h(e,t,s){const r=i(e*(t-s));return[t=i(t-r),s=i(s+r)]}const l=(t.a-BigInt(2))/BigInt(4);function p(e){return function(e,t){return function(e,t){return dt(e.toString(16).padStart(2*t,"0"))}(e,t).reverse()}(i(e),n)}function d(e,t){const d=function(e){const t=gt("u coordinate",e,n);return 32===o&&(t[31]&=127),ut(t)}(t),u=function(e){const t=gt("scalar",e),s=t.length;if(s!==n&&s!==o)throw new Error("invalid scalar, expected "+n+" or "+o+" bytes, got "+s);return ut(a(t))}(e),g=function(e,t){mt("u",e,It,s),mt("scalar",t,It,s);const n=t,o=e;let a,p=_t,d=It,u=e,g=_t,f=It;for(let e=BigInt(r-1);e>=It;e--){const t=n>>e&_t;f^=t,a=h(f,p,u),p=a[0],u=a[1],a=h(f,d,g),d=a[0],g=a[1],f=t;const s=p+d,r=i(s*s),c=p-d,m=i(c*c),w=r-m,y=u+g,b=i((u-g)*s),v=i(y*c),E=b+v,I=b-v;u=i(E*E),g=i(o*i(I*I)),p=i(r*m),d=i(w*(r+i(l*w)))}a=h(f,p,u),p=a[0],u=a[1],a=h(f,d,g),d=a[0],g=a[1];const m=c(d);return i(p*m)}(d,u);if(g===It)throw new Error("invalid private or public key received");return p(g)}const u=p(t.Gu);function g(e){return d(e,u)}return{scalarMult:d,scalarMultBase:g,getSharedSecret:(e,t)=>d(e,t),getPublicKey:e=>g(e),utils:{randomPrivateKey:()=>t.randomBytes(t.nByteLength)},GuBytes:u}}({P:Nt,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{const t=Nt,{pow_p_5_8:s,b2:i}=function(e){const t=BigInt(10),s=BigInt(20),i=BigInt(40),r=BigInt(80),n=Nt,o=e*e%n*e%n,a=Et(o,Ct,n)*o%n,c=Et(a,At,n)*e%n,h=Et(c,St,n)*c%n,l=Et(h,t,n)*h%n,p=Et(l,s,n)*l%n,d=Et(p,i,n)*p%n,u=Et(d,r,n)*d%n,g=Et(u,r,n)*d%n,f=Et(g,t,n)*h%n;return{pow_p_5_8:Et(f,Ct,n)*e%n,b2:o}}(e);return vt(Et(s,Pt,t)*i,t)},adjustScalarBytes:function(e){return e[0]&=248,e[31]&=127,e[31]|=64,e},randomBytes:re}),Tt="base10",kt="base16",xt="base64pad",Rt="utf8",Ut=0,Dt=1,jt=2,Mt=0,Lt=1,qt=12,$t=32;function Bt(){const e=Ot.utils.randomPrivateKey(),t=Ot.getPublicKey(e);return{privateKey:(0,c.dI)(e,kt),publicKey:(0,c.dI)(t,kt)}}function Ht(){const e=re($t);return(0,c.dI)(e,kt)}function Wt(e,t){const s=Ot.getSharedSecret((0,c.sH)(e,kt),(0,c.sH)(t,kt)),i=Xe(ot,s,void 0,void 0,$t);return(0,c.dI)(i,kt)}function zt(e){const t=ot((0,c.sH)(e,kt));return(0,c.dI)(t,kt)}function Vt(e){const t=ot((0,c.sH)(e,Rt));return(0,c.dI)(t,kt)}function Ft(e){return(0,c.sH)(`${e}`,Tt)}function Kt(e){return Number((0,c.dI)(e,Tt))}function Gt(e){const t=Ft(typeof e.type<"u"?e.type:Ut);if(Kt(t)===Dt&&typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const s=typeof e.senderPublicKey<"u"?(0,c.sH)(e.senderPublicKey,kt):void 0,i=typeof e.iv<"u"?(0,c.sH)(e.iv,kt):re(qt),r=(0,c.sH)(e.symKey,kt);return Xt({type:t,sealed:Ke(r,i).encrypt((0,c.sH)(e.message,Rt)),iv:i,senderPublicKey:s,encoding:e.encoding})}function Jt(e){const t=(0,c.sH)(e.symKey,kt),{sealed:s,iv:i}=Zt(e),r=Ke(t,i).decrypt(s);if(null===r)throw new Error("Failed to decrypt");return(0,c.dI)(r,Rt)}function Yt(e,t){const s=Ft(jt),i=re(qt);return Xt({type:s,sealed:(0,c.sH)(e,Rt),iv:i,encoding:t})}function Qt(e,t){const{sealed:s}=Zt({encoded:e,encoding:t});return(0,c.dI)(s,Rt)}function Xt(e){const{encoding:t=xt}=e;if(Kt(e.type)===jt)return(0,c.dI)((0,c.xW)([e.type,e.sealed]),t);if(Kt(e.type)===Dt){if(typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return(0,c.dI)((0,c.xW)([e.type,e.senderPublicKey,e.iv,e.sealed]),t)}return(0,c.dI)((0,c.xW)([e.type,e.iv,e.sealed]),t)}function Zt(e){const{encoded:t,encoding:s=xt}=e,i=(0,c.sH)(t,s),r=i.slice(Mt,Lt),n=Lt;if(Kt(r)===Dt){const e=n+$t,t=e+qt,s=i.slice(n,e),o=i.slice(e,t);return{type:r,sealed:i.slice(t),iv:o,senderPublicKey:s}}if(Kt(r)===jt)return{type:r,sealed:i.slice(n),iv:re(qt)};const o=n+qt,a=i.slice(n,o);return{type:r,sealed:i.slice(o),iv:a}}function es(e,t){const s=Zt({encoded:e,encoding:t?.encoding});return ts({type:Kt(s.type),senderPublicKey:typeof s.senderPublicKey<"u"?(0,c.dI)(s.senderPublicKey,kt):void 0,receiverPublicKey:t?.receiverPublicKey})}function ts(e){const t=e?.type||Ut;if(t===Dt){if(typeof e?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof e?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:t,senderPublicKey:e?.senderPublicKey,receiverPublicKey:e?.receiverPublicKey}}function ss(e){return e.type===Dt&&"string"==typeof e.senderPublicKey&&"string"==typeof e.receiverPublicKey}function is(e){return e.type===jt}function rs(e,t){const[s,i,r]=e.split("."),n=function(e){return d.from(function(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");const s=t.length%4;return s>0&&(t+="=".repeat(4-s)),t}(e),"base64")}(r);if(64!==n.length)throw new Error("Invalid signature length");const o=n.slice(0,32).toString("hex"),l=n.slice(32,64).toString("hex"),p=ot(`${s}.${i}`),u=function(e){return new h.ec("p256").keyFromPublic({x:d.from(e.x,"base64").toString("hex"),y:d.from(e.y,"base64").toString("hex")},"hex")}(t),g=(0,c.dI)(p,kt);if(!u.verify(g,{r:o,s:l}))throw new Error("Invalid signature");return(0,a.Cq)(e).payload}const ns="irn";function os(e){return e?.relay||{protocol:ns}}function as(e){const t=l.CG[e];if(typeof t>"u")throw new Error(`Relay Protocol not supported: ${e}`);return t}function cs(e,t="-"){const s={},i="relay"+t;return Object.keys(e).forEach(t=>{if(t.startsWith(i)){const r=t.replace(i,""),n=e[t];s[r]=n}}),s}function hs(e){if(!e.includes("wc:")){const t=q(e);null!=t&&t.includes("wc:")&&(e=t)}const t=(e=(e=e.includes("wc://")?e.replace("wc://",""):e).includes("wc:")?e.replace("wc:",""):e).indexOf(":"),s=-1!==e.indexOf("?")?e.indexOf("?"):void 0,i=e.substring(0,t),r=e.substring(t+1,s).split("@"),n=typeof s<"u"?e.substring(s):"",o=new URLSearchParams(n),a={};o.forEach((e,t)=>{a[t]=e});const c="string"==typeof a.methods?a.methods.split(","):void 0;return{protocol:i,topic:ls(r[0]),version:parseInt(r[1],10),symKey:a.symKey,relay:cs(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function ls(e){return e.startsWith("//")?e.substring(2):e}function ps(e){const t=new URLSearchParams,s=function(e,t="-"){const s={};return Object.keys(e).forEach(i=>{const r=i,n="relay"+t+r;e[r]&&(s[n]=e[r])}),s}(e.relay);Object.keys(s).sort().forEach(e=>{t.set(e,s[e])}),t.set("symKey",e.symKey),e.expiryTimestamp&&t.set("expiryTimestamp",e.expiryTimestamp.toString()),e.methods&&t.set("methods",e.methods.join(","));const i=t.toString();return`${e.protocol}:${e.topic}@${e.version}?${i}`}Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;const ds={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}},us={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 gs(e,t){const{message:s,code:i}=us[e];return{message:t?`${s} ${t}`:s,code:i}}function fs(e,t){const{message:s,code:i}=ds[e];return{message:t?`${s} ${t}`:s,code:i}}function ms(e){return typeof e>"u"}function ws(e,t){return!(!t||!ms(e))||"string"==typeof e&&!!e.trim().length}function ys(e){function t(e){try{return typeof new URL(e)<"u"}catch{return!1}}try{if(ws(e,!1))return!!t(e)||t(q(e))}catch{}return!1}function bs(e){var t;return null==(t=e?.proposer)?void 0:t.publicKey}function vs(e){return e?.topic}function Es(e){return typeof e<"u"&&null!==typeof e}function Is(){const e=E();return new Promise(t=>{switch(e){case g.browser:t(v()&&navigator?.onLine);break;case g.reactNative:t(async function(){if(w()&&typeof s.g<"u"&&null!=s.g&&s.g.NetInfo){const e=await(null==s.g?void 0:s.g.NetInfo.fetch());return e?.isConnected}return!0}());break;case g.node:default:t(!0)}})}function _s(e){switch(E()){case g.browser:!function(e){!w()&&v()&&(window.addEventListener("online",()=>e(!0)),window.addEventListener("offline",()=>e(!1)))}(e);break;case g.reactNative:!function(e){w()&&typeof s.g<"u"&&null!=s.g&&s.g.NetInfo&&s.g?.NetInfo.addEventListener(t=>e(t?.isConnected))}(e);case g.node:}}},49009:(e,t,s)=>{s.d(t,{Q:()=>i});const i=[{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}]},50047:(e,t,s)=>{s.d(t,{R:()=>i});const i=(0,s(40149).x)({id:"EtWTRABZaYq6iMfeYKouRu166VU2xqa1",name:"Solana Devnet",network:"solana-devnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!0,chainNamespace:"solana",caipNetworkId:"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",deprecatedCaipNetworkId:"solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"})},50731:(e,t,s)=>{s.d(t,{a:()=>m});var i=s(89168),r=s(39150),n=s(95191),o=s(11807),a=s(26097),c=s(11553),h=s(40868),l=s(99013),p=s(16158),d=s(42831),u=s(26545);const g={eip155:void 0,solana:void 0,polkadot:void 0,bip122:void 0},f=(0,i.BX)({allConnectors:[],connectors:[],activeConnector:void 0,filterByNamespace:void 0,activeConnectorIds:{...g}}),m={state:f,subscribe:e=>(0,i.B1)(f,()=>{e(f)}),subscribeKey:(e,t)=>(0,r.u$)(f,e,t),initialize(e){e.forEach(e=>{const t=c.i.getConnectedConnectorId(e);t&&this.setConnectorId(t,e)})},setActiveConnector(e){e&&(f.activeConnector=(0,i.KR)(e))},setConnectors(e){e.filter(e=>!f.allConnectors.some(t=>t.id===e.id&&this.getConnectorName(t.name)===this.getConnectorName(e.name)&&t.chain===e.chain)).forEach(e=>{"MULTI_CHAIN"!==e.type&&f.allConnectors.push((0,i.KR)(e))}),f.connectors=this.mergeMultiChainConnectors(f.allConnectors)},removeAdapter(e){f.allConnectors=f.allConnectors.filter(t=>t.chain!==e),f.connectors=this.mergeMultiChainConnectors(f.allConnectors)},mergeMultiChainConnectors(e){const t=this.generateConnectorMapByName(e),s=[];return t.forEach(e=>{const t=e[0],i=t?.id===n.o.CONNECTOR_ID.AUTH;e.length>1&&t?s.push({name:t.name,imageUrl:t.imageUrl,imageId:t.imageId,connectors:[...e],type:i?"AUTH":"MULTI_CHAIN",chain:"eip155",id:t?.id||""}):t&&s.push(t)}),s},generateConnectorMapByName(e){const t=new Map;return e.forEach(e=>{const{name:s}=e,i=this.getConnectorName(s);if(!i)return;const r=t.get(i)||[];r.find(t=>t.chain===e.chain)||r.push(e),t.set(i,r)}),t},getConnectorName:e=>e&&{"Trust Wallet":"Trust"}[e]||e,getUniqueConnectorsByName(e){const t=[];return e.forEach(e=>{t.find(t=>t.chain===e.chain)||t.push(e)}),t},addConnector(e){if(e.id===n.o.CONNECTOR_ID.AUTH){const t=e,s=(0,i.P9)(p.H.state),r=u.W.getSnapshot().themeMode,n=u.W.getSnapshot().themeVariables;t?.provider?.syncDappData?.({metadata:s.metadata,sdkVersion:s.sdkVersion,projectId:s.projectId,sdkType:s.sdkType}),t?.provider?.syncTheme({themeMode:r,themeVariables:n,w3mThemeVariables:(0,o.o)(n,r)}),this.setConnectors([e])}else this.setConnectors([e])},getAuthConnector(e){const t=e||l.W.state.activeChain,s=f.connectors.find(e=>e.id===n.o.CONNECTOR_ID.AUTH);if(s)return s?.connectors?.length?s.connectors.find(e=>e.chain===t):s},getAnnouncedConnectorRdns:()=>f.connectors.filter(e=>"ANNOUNCED"===e.type).map(e=>e.info?.rdns),getConnectorById:e=>f.allConnectors.find(t=>t.id===e),getConnector:(e,t)=>f.allConnectors.filter(e=>e.chain===l.W.state.activeChain).find(s=>s.explorerId===e||s.info?.rdns===t),syncIfAuthConnector(e){if("ID_AUTH"!==e.id)return;const t=e,s=(0,i.P9)(p.H.state),r=u.W.getSnapshot().themeMode,n=u.W.getSnapshot().themeVariables;t?.provider?.syncDappData?.({metadata:s.metadata,sdkVersion:s.sdkVersion,sdkType:s.sdkType,projectId:s.projectId}),t.provider.syncTheme({themeMode:r,themeVariables:n,w3mThemeVariables:(0,o.o)(n,r)})},getConnectorsByNamespace(e){const t=f.allConnectors.filter(t=>t.chain===e);return this.mergeMultiChainConnectors(t)},selectWalletConnector(e){const t=m.getConnector(e.id,e.rdns);l.W.state.activeChain===n.o.CHAIN.SOLANA&&a.W.handleSolanaDeeplinkRedirect(t?.name||e.name||""),t?d.I.push("ConnectingExternal",{connector:t}):d.I.push("ConnectingWalletConnect",{wallet:e})},getConnectors(e){return e?this.getConnectorsByNamespace(e):this.mergeMultiChainConnectors(f.allConnectors)},setFilterByNamespace(e){f.filterByNamespace=e,f.connectors=this.getConnectors(e),h.N.setFilterByNamespace(e)},setConnectorId(e,t){e&&(f.activeConnectorIds={...f.activeConnectorIds,[t]:e},c.i.setConnectedConnectorId(t,e))},removeConnectorId(e){f.activeConnectorIds={...f.activeConnectorIds,[e]:void 0},c.i.deleteConnectedConnectorId(e)},getConnectorId(e){if(e)return f.activeConnectorIds[e]},isConnected:e=>e?Boolean(f.activeConnectorIds[e]):Object.values(f.activeConnectorIds).some(e=>Boolean(e)),resetConnectorIds(){f.activeConnectorIds={...g}}}},51493:(e,t,s)=>{},52059:(e,t,s)=>{s.d(t,{W:()=>d});var i=s(89168),r=s(9663),n=s(16279),o=s(27006),a=s(99013),c=s(14479),h=s(16158),l=s(41430);const p=(0,i.BX)({transactions:[],coinbaseTransactions:{},transactionsByYear:{},lastNetworkInView:void 0,loading:!1,empty:!1,next:void 0}),d={state:p,subscribe:e=>(0,i.B1)(p,()=>e(p)),setLastNetworkInView(e){p.lastNetworkInView=e},async fetchTransactions(e,t){if(!e)throw new Error("Transactions can't be fetched without an accountAddress");p.loading=!0;try{const s=await o.T.fetchTransactions({account:e,cursor:p.next,onramp:t,cache:"coinbase"===t?"no-cache":void 0,chainId:a.W.state.activeCaipNetwork?.caipNetworkId}),i=this.filterSpamTransactions(s.data),r=this.filterByConnectedChain(i),n=[...p.transactions,...r];p.loading=!1,"coinbase"===t?p.coinbaseTransactions=this.groupTransactionsByYearAndMonth(p.coinbaseTransactions,s.data):(p.transactions=n,p.transactionsByYear=this.groupTransactionsByYearAndMonth(p.transactionsByYear,r)),p.empty=0===n.length,p.next=s.next?s.next:void 0}catch(t){c.E.sendEvent({type:"track",event:"ERROR_FETCH_TRANSACTIONS",properties:{address:e,projectId:h.H.state.projectId,cursor:p.next,isSmartAccount:n.U.state.preferredAccountType===r.Vl.ACCOUNT_TYPES.SMART_ACCOUNT}}),l.P.showError("Failed to fetch transactions"),p.loading=!1,p.empty=!0,p.next=void 0}},groupTransactionsByYearAndMonth(e={},t=[]){const s=e;return t.forEach(e=>{const t=new Date(e.metadata.minedAt).getFullYear(),i=new Date(e.metadata.minedAt).getMonth(),r=s[t]??{},n=(r[i]??[]).filter(t=>t.id!==e.id);s[t]={...r,[i]:[...n,e].sort((e,t)=>new Date(t.metadata.minedAt).getTime()-new Date(e.metadata.minedAt).getTime())}}),s},filterSpamTransactions:e=>e.filter(e=>!e.transfers.every(e=>!0===e.nft_info?.flags.is_spam)),filterByConnectedChain(e){const t=a.W.state.activeCaipNetwork?.caipNetworkId;return e.filter(e=>e.metadata.chain===t)},clearCursor(){p.next=void 0},resetTransactions(){p.transactions=[],p.transactionsByYear={},p.lastNetworkInView=void 0,p.loading=!1,p.empty=!1,p.next=void 0}}},55164:(e,t,s)=>{s.d(t,{Rn0:()=>i.Rn,gTy:()=>i.gT,tWt:()=>i.tW});var i=s(14133);s(95642)},55770:(e,t,s)=>{s.d(t,{r:()=>i});const i=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"sender",type:"address"},{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{name:"",type:"bool"}]}]},58906:(e,t,s)=>{s.d(t,{i:()=>i});const i="1.7.2"},59677:(e,t,s)=>{s.d(t,{C:()=>i});const i={validateCaipAddress(e){if(3!==e.split(":")?.length)throw new Error("Invalid CAIP Address");return e},parseCaipAddress(e){const t=e.split(":");if(3!==t.length)throw new Error(`Invalid CAIP-10 address: ${e}`);const[s,i,r]=t;if(!s||!i||!r)throw new Error(`Invalid CAIP-10 address: ${e}`);return{chainNamespace:s,chainId:i,address:r}},parseCaipNetworkId(e){const t=e.split(":");if(2!==t.length)throw new Error(`Invalid CAIP-2 network id: ${e}`);const[s,i]=t;if(!s||!i)throw new Error(`Invalid CAIP-2 network id: ${e}`);return{chainNamespace:s,chainId:i}}}},60039:(e,t,s)=>{s.d(t,{R:()=>i});const i={UniversalProviderErrors:{UNAUTHORIZED_DOMAIN_NOT_ALLOWED:{message:"Unauthorized: origin not allowed",alertErrorKey:"INVALID_APP_CONFIGURATION"},JWT_VALIDATION_ERROR:{message:"JWT validation error: JWT Token is not yet valid",alertErrorKey:"JWT_TOKEN_NOT_VALID"},INVALID_KEY:{message:"Unauthorized: invalid key",alertErrorKey:"INVALID_PROJECT_ID"}},ALERT_ERRORS:{SWITCH_NETWORK_NOT_FOUND:{shortMessage:"Network Not Found",longMessage:"Network not found - please make sure it is included in 'networks' array in createAppKit function"},INVALID_APP_CONFIGURATION:{shortMessage:"Invalid App Configuration",longMessage:()=>`Origin ${"undefined"!=typeof window?window.origin:"unknown"} not found on Allowlist - update configuration on cloud.reown.com`},SOCIALS_TIMEOUT:{shortMessage:"Invalid App Configuration",longMessage:()=>"There was an issue loading the embedded wallet. Please verify that your domain is allowed at cloud.reown.com"},JWT_TOKEN_NOT_VALID:{shortMessage:"Session Expired",longMessage:"Invalid session found on UniversalProvider - please check your time settings and connect again"},INVALID_PROJECT_ID:{shortMessage:"Invalid App Configuration",longMessage:"Invalid Project ID - update configuration"},PROJECT_ID_NOT_CONFIGURED:{shortMessage:"Project ID Not Configured",longMessage:"Project ID Not Configured - update configuration on cloud.reown.com"}}}},63789:(e,t,s)=>{s.d(t,{Z:()=>i});const i={getSpacingStyles:(e,t)=>Array.isArray(e)?e[t]?`var(--wui-spacing-${e[t]})`:void 0:"string"==typeof e?`var(--wui-spacing-${e})`:void 0,getFormattedDate:e=>new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric"}).format(e),getHostName(e){try{return new URL(e).hostname}catch(e){return""}},getTruncateString:({string:e,charsStart:t,charsEnd:s,truncate:i})=>e.length<=t+s?e:"end"===i?`${e.substring(0,t)}...`:"start"===i?`...${e.substring(e.length-s)}`:`${e.substring(0,Math.floor(t))}...${e.substring(e.length-Math.floor(s))}`,generateAvatarColors(e){const t=e.toLowerCase().replace(/^0x/iu,"").replace(/[^a-f0-9]/gu,"").substring(0,6).padEnd(6,"0"),s=this.hexToRgb(t),i=getComputedStyle(document.documentElement).getPropertyValue("--w3m-border-radius-master"),r=100-3*Number(i?.replace("px","")),n=`${r}% ${r}% at 65% 40%`,o=[];for(let e=0;e<5;e+=1){const t=this.tintColor(s,.15*e);o.push(`rgb(${t[0]}, ${t[1]}, ${t[2]})`)}return`\n --local-color-1: ${o[0]};\n --local-color-2: ${o[1]};\n --local-color-3: ${o[2]};\n --local-color-4: ${o[3]};\n --local-color-5: ${o[4]};\n --local-radial-circle: ${n}\n `},hexToRgb(e){const t=parseInt(e,16);return[t>>16&255,t>>8&255,255&t]},tintColor(e,t){const[s,i,r]=e;return[Math.round(s+(255-s)*t),Math.round(i+(255-i)*t),Math.round(r+(255-r)*t)]},isNumber:e=>/^[0-9]+$/u.test(e),getColorTheme:e=>e||("undefined"!=typeof window&&window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)")?.matches?"dark":"light":"dark"),splitBalance(e){const t=e.split(".");return 2===t.length?[t[0],t[1]]:["0","00"]},roundNumber:(e,t,s)=>e.toString().length>=t?Number(e).toFixed(s):e,formatNumberToLocalString:(e,t=2)=>void 0===e?"0.00":"number"==typeof e?e.toLocaleString("en-US",{maximumFractionDigits:t,minimumFractionDigits:t}):parseFloat(e).toLocaleString("en-US",{maximumFractionDigits:t,minimumFractionDigits:t})}},66715:(e,t,s)=>{s.d(t,{f:()=>w});var i=s(53834),r=s(73821),n=s(3834),o=s(40446),a=s(76754),c=s(48336),h=s(30544),l=s(33244),p=s(96759),d=s(84320),u=s(41276),g=s(89351),f=s(85445),m=s(48526).hp;class w{_UniversalProvider;_session;_modal;_projectId;_network;_ConnectQueueResolver;constructor(e){if(this.initClient(e.options),this._network=e.network,!e.options.projectId)throw Error("WalletConnect Adapter: Project ID is undefined");this._projectId=e.options.projectId}async connect(){if(this._UniversalProvider||await new Promise(e=>{this._ConnectQueueResolver=e}),!this._UniversalProvider)throw new Error("WalletConnect Adapter - Universal Provider was undefined while calling 'connect()'");if(this._UniversalProvider.session){this._session=this._UniversalProvider.session;const e=(0,g.hJ)(this._session,this._network);return this._network=e,this._UniversalProvider.setDefaultChain(e),{publicKey:this.publicKey}}await this.initModal();const e=(0,g.lC)(this._network);this._modal?.open();const t=new AbortController,s=t.signal;this._modal?.subscribeState(e=>{e.open||t.abort(new f.K)});try{const t=await Promise.race([this._UniversalProvider?.connect(e),new Promise((e,t)=>{s.addEventListener("abort",()=>{t(s.reason)})})]);if(this._modal?.close(),this._session=t,!t)throw new i.Y6;const r=(0,g.hJ)(t,this._network);return this._network=r,this._UniversalProvider?.setDefaultChain(r),{publicKey:this.publicKey}}catch(e){throw this._modal?.close(),e}}async disconnect(){if(!this._UniversalProvider?.session)throw new d.r;if(await this.initModal(),!this._modal)throw Error("WalletConnect Adapter -Modal is undefined: unable to disconnect");await this.client.disconnect(),this._session=void 0}get client(){if(this._UniversalProvider)return this._UniversalProvider;throw new d.r}get session(){if(!this._session)throw new d.r;return this._session}get publicKey(){if(this._UniversalProvider?.session&&this._session){const{address:e}=(0,a.cK)(this._session?.namespaces.solana?.accounts[0]??"");return new n.PublicKey(e)}throw new d.r}async signTransaction(e){this.checkIfWalletSupportsMethod(p.jD.signTransaction);const t=(0,r.Y)(e),s=t?{}:e,{signature:i,transaction:n}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:p.jD.signTransaction,params:{...s,transaction:this.serialize(e)}}});return n?this.deserialize(n,t):(e.addSignature(this.publicKey,m.from(l.A.decode(i))),e)}async signMessage(e){this.checkIfWalletSupportsMethod(p.jD.signMessage);const{signature:t}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:p.jD.signMessage,params:{pubkey:this.publicKey.toString(),message:l.A.encode(e)}}});return l.A.decode(t)}async signAndSendTransaction(e){this.checkIfWalletSupportsMethod(p.jD.signAndSendTransaction);const{signature:t}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:p.jD.signAndSendTransaction,params:{transaction:this.serialize(e)}}});return t}async signAllTransactions(e){try{this.checkIfWalletSupportsMethod(p.jD.signAllTransactions);const t=e.map(e=>this.serialize(e)),{transactions:s}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:p.jD.signAllTransactions,params:{transactions:t}}});return e.map((e,t)=>(0,r.Y)(e)?this.deserialize(s[t]??"",!0):this.deserialize(s[t]??""))}catch(t){if(t instanceof u.f){const t=e.map(e=>this.signTransaction(e));return await Promise.all(t)}throw t}}async initClient(e){const t=await o.l.init(e);this._UniversalProvider=t,this._ConnectQueueResolver&&this._ConnectQueueResolver(!0)}async initModal(){if(!this._modal){if(!this._UniversalProvider)throw new Error("WalletConnect Adapter - cannot init modal when Universal Provider is undefined");this._modal=(0,c.s)({projectId:this._projectId,universalProvider:this._UniversalProvider,networks:[h.tWt,h.Rn0,h.gTy],manualWCControl:!0})}}serialize(e){return m.from(e.serialize({verifySignatures:!1})).toString("base64")}deserialize(e,t=!1){return t?n.VersionedTransaction.deserialize(m.from(e,"base64")):n.Transaction.from(m.from(e,"base64"))}checkIfWalletSupportsMethod(e){if(!this.session.namespaces.solana?.methods.includes(e))throw new u.f(e)}}},67018:(e,t,s)=>{s.d(t,{W:()=>m});var i=s(89168),r=s(39150),n=s(5813),o=s(16279),a=s(40868),c=s(99013),h=s(89058),l=s(50731),p=s(14479),d=s(16158),u=s(25422),g=s(42831);const f=(0,i.BX)({loading:!1,loadingNamespaceMap:new Map,open:!1,shake:!1,namespace:void 0}),m={state:f,subscribe:e=>(0,i.B1)(f,()=>e(f)),subscribeKey:(e,t)=>(0,r.u$)(f,e,t),async open(e){const t="connected"===o.U.state.status;h.x.state.wcBasic?a.N.prefetch({fetchNetworkImages:!1,fetchConnectorImages:!1}):await a.N.prefetch({fetchConnectorImages:!t,fetchFeaturedWallets:!t,fetchRecommendedWallets:!t}),e?.namespace?(await c.W.switchActiveNamespace(e.namespace),m.setLoading(!0,e.namespace)):m.setLoading(!0),l.a.setFilterByNamespace(e?.namespace);const s=c.W.getAccountData(e?.namespace)?.caipAddress;c.W.state.noAdapters&&!s?n.w.isMobile()?g.I.reset("AllWallets"):g.I.reset("ConnectingWalletConnectBasic"):e?.view?g.I.reset(e.view):s?g.I.reset("Account"):g.I.reset("Connect"),f.open=!0,u.z.set({open:!0}),p.E.sendEvent({type:"track",event:"MODAL_OPEN",properties:{connected:Boolean(s)}})},close(){const e=d.H.state.enableEmbedded,t=Boolean(c.W.state.activeCaipAddress);f.open&&p.E.sendEvent({type:"track",event:"MODAL_CLOSE",properties:{connected:t}}),f.open=!1,m.clearLoading(),e?t?g.I.replace("Account"):g.I.push("Connect"):u.z.set({open:!1}),h.x.resetUri()},setLoading(e,t){t&&f.loadingNamespaceMap.set(t,e),f.loading=e,u.z.set({loading:e})},clearLoading(){f.loadingNamespaceMap.clear(),f.loading=!1},shake(){f.shake||(f.shake=!0,setTimeout(()=>{f.shake=!1},500))}}},69033:(e,t,s)=>{s.d(t,{k:()=>o});var i=s(29864),r=s(55164);const n={solana:["solana_signMessage","solana_signTransaction","solana_requestAccounts","solana_getAccounts","solana_signAllTransactions","solana_signAndSendTransaction"],eip155:["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_getCallsStatus","wallet_showCallsStatus","wallet_sendCalls","wallet_getCapabilities","wallet_grantPermissions","wallet_revokePermissions","wallet_getAssets"],bip122:["sendTransfer","signMessage","signPsbt","getAccountAddresses"]},o={getMethodsByChainNamespace:e=>n[e]||[],createDefaultNamespace(e){return{methods:this.getMethodsByChainNamespace(e),events:["accountsChanged","chainChanged"],chains:[],rpcMap:{}}},applyNamespaceOverrides(e,t){if(!t)return{...e};const s={...e},i=new Set;if(t.methods&&Object.keys(t.methods).forEach(e=>i.add(e)),t.chains&&Object.keys(t.chains).forEach(e=>i.add(e)),t.events&&Object.keys(t.events).forEach(e=>i.add(e)),t.rpcMap&&Object.keys(t.rpcMap).forEach(e=>{const[t]=e.split(":");t&&i.add(t)}),i.forEach(e=>{s[e]||(s[e]=this.createDefaultNamespace(e))}),t.methods&&Object.entries(t.methods).forEach(([e,t])=>{s[e]&&(s[e].methods=t)}),t.chains&&Object.entries(t.chains).forEach(([e,t])=>{s[e]&&(s[e].chains=t)}),t.events&&Object.entries(t.events).forEach(([e,t])=>{s[e]&&(s[e].events=t)}),t.rpcMap){const e=new Set;Object.entries(t.rpcMap).forEach(([t,i])=>{const[r,n]=t.split(":");r&&n&&s[r]&&(s[r].rpcMap||(s[r].rpcMap={}),e.has(r)||(s[r].rpcMap={},e.add(r)),s[r].rpcMap[n]=i)})}return s},createNamespaces(e,t){const s=e.reduce((e,t)=>{const{id:s,chainNamespace:i,rpcUrls:n}=t,o=n.default.http[0];e[i]||(e[i]=this.createDefaultNamespace(i));const a=`${i}:${s}`,c=e[i];switch(c.chains.push(a),a){case r.tWt.caipNetworkId:c.chains.push(r.tWt.deprecatedCaipNetworkId);break;case r.Rn0.caipNetworkId:c.chains.push(r.Rn0.deprecatedCaipNetworkId)}return c?.rpcMap&&o&&(c.rpcMap[s]=o),e},{});return this.applyNamespaceOverrides(s,t)},resolveReownName:async e=>{const t=await i.f.resolveName(e),s=Object.values(t?.addresses)||[];return s[0]?.address||!1},getChainsFromNamespaces:(e={})=>Object.values(e).flatMap(e=>{const t=e.chains||[],s=e.accounts.map(e=>{const[t,s]=e.split(":");return`${t}:${s}`});return Array.from(new Set([...t,...s]))}),isSessionEventData:e=>"object"==typeof e&&null!==e&&"id"in e&&"topic"in e&&"params"in e&&"object"==typeof e.params&&null!==e.params&&"chainId"in e.params&&"event"in e.params&&"object"==typeof e.params.event&&null!==e.params.event}},72931:(e,t,s)=>{s(3496),s(63789)},74091:(e,t,s)=>{s.d(t,{o:()=>r});var i=s(39907);const r={ACCOUNT_TABS:[{label:"Tokens"},{label:"NFTs"},{label:"Activity"}],SECURE_SITE_ORIGIN:(void 0!==i&&void 0!==i.env?i.env.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",VIEW_DIRECTION:{Next:"next",Prev:"prev"},DEFAULT_CONNECT_METHOD_ORDER:["email","social","wallet"],ANIMATION_DURATIONS:{HeaderText:120,ModalHeight:150,ViewTransition:150}}},76020:(e,t,s)=>{s.d(t,{L:()=>i});const i={caipNetworkIdToNumber:e=>e?Number(e.split(":")[1]):void 0,parseEvmChainId(e){return"string"==typeof e?this.caipNetworkIdToNumber(e):e},getNetworksByNamespace:(e,t)=>e?.filter(e=>e.chainNamespace===t)||[],getFirstNetworkByNamespace(e,t){return this.getNetworksByNamespace(e,t)[0]}}},76663:(e,t,s)=>{s.d(t,{F:()=>c}),s(1057);var i=s(95191),r=s(16158),n=s(24537),o=s(40770),a=s(86808);class c{constructor({provider:e,caipNetworks:t,namespace:s}){this.id=i.o.CONNECTOR_ID.WALLET_CONNECT,this.name=o.L.ConnectorNamesMap[i.o.CONNECTOR_ID.WALLET_CONNECT],this.type="WALLET_CONNECT",this.imageId=o.L.ConnectorImageIds[i.o.CONNECTOR_ID.WALLET_CONNECT],this.caipNetworks=t,this.provider=e,this.chain=s}get chains(){return this.caipNetworks}async connectWalletConnect(){if(!await this.authenticate()){const e=r.H.state.universalProviderConfigOverride,t=a.kl.createNamespaces(this.caipNetworks,e);await this.provider.connect({optionalNamespaces:t})}return{clientId:await this.provider.client.core.crypto.getClientId(),session:this.provider.session}}async disconnect(){await this.provider.disconnect()}async authenticate(){const e=this.chains.map(e=>e.caipNetworkId);return n.U.universalProviderAuthenticate({universalProvider:this.provider,chains:e,methods:h})}}const h=["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_getCallsStatus","wallet_sendCalls","wallet_getCapabilities","wallet_grantPermissions","wallet_revokePermissions","wallet_getAssets"]},76754:(e,t,s)=>{s.d(t,{$Bq:()=>Js,$hI:()=>F,ADD:()=>M,ALl:()=>Ss,AYU:()=>pi,Alu:()=>Ei,AwN:()=>Ls,BdH:()=>A,C5G:()=>Ms,CTo:()=>di,EHS:()=>bs,EN$:()=>Ps,EWt:()=>gs,F$L:()=>Us,FR8:()=>Ci,FiO:()=>yi,GuA:()=>si,HNf:()=>hi,Hbs:()=>xi,Hjj:()=>ii,IjX:()=>ze,K3g:()=>D,Lln:()=>E,Lp_:()=>ys,M8n:()=>Ai,OP1:()=>ri,PUk:()=>R,Pa8:()=>fs,QJh:()=>Gs,Qhg:()=>ai,R7U:()=>P,TRk:()=>W,TZl:()=>Ns,TeY:()=>Ii,Tw2:()=>Rs,U0i:()=>Bs,V7m:()=>qs,V9G:()=>vi,VBM:()=>et,Van:()=>Zs,WWN:()=>Ze,Wx8:()=>U,X3c:()=>_i,XqR:()=>Ti,Xw0:()=>$,YcA:()=>xs,_Yb:()=>f,_dF:()=>B,aF0:()=>ni,aRZ:()=>N,aa1:()=>zs,b07:()=>oi,bEt:()=>us,c82:()=>q,cK:()=>m,e8_:()=>Ye,esh:()=>wi,gOF:()=>L,gZm:()=>K,h0Y:()=>x,hEn:()=>H,hVC:()=>Qe,hwK:()=>Ve,iV1:()=>Ni,iui:()=>js,jTh:()=>V,jUZ:()=>T,kob:()=>Xs,kuU:()=>bi,lFF:()=>S,lVv:()=>I,m01:()=>_,mr0:()=>ui,n3s:()=>z,n6V:()=>Ws,nWe:()=>Qs,nyL:()=>ji,oKp:()=>Si,ojD:()=>O,ovp:()=>Cs,ps1:()=>$s,q_h:()=>We,sc7:()=>Ri,sc_:()=>Xe,tLy:()=>Pi,tk0:()=>gi,two:()=>As,uym:()=>Ui,w8K:()=>G,wYp:()=>Fs,wa2:()=>ks,x0t:()=>Ts,xkc:()=>He,yy4:()=>Y,z2N:()=>Oi});var i=s(24661),r=s(91315),n=s(20635),o=s(67822),a=s(71268),c=s(97353),h=s(1030),l=s(13360),p=s(17367),d=s(39907),u=s(48526).hp;const g=":";function f(e){const[t,s]=e.split(g);return{namespace:t,reference:s}}function m(e){const[t,s,i]=e.split(g);return{namespace:t,reference:s,address:i}}function w(e,t){return e.includes(":")?[e]:t.chains||[]}const y="ReactNative",b={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},v="js";function E(){return typeof d<"u"&&typeof d.versions<"u"&&typeof d.versions.node<"u"}function I(){return!(0,n.getDocument)()&&!!(0,n.getNavigator)()&&navigator.product===y}function _(){return I()&&typeof s.g<"u"&&typeof(null==s.g?void 0:s.g.Platform)<"u"&&"android"===(null==s.g?void 0:s.g.Platform.OS)}function N(){return I()&&typeof s.g<"u"&&typeof(null==s.g?void 0:s.g.Platform)<"u"&&"ios"===(null==s.g?void 0:s.g.Platform.OS)}function A(){return!E()&&!!(0,n.getNavigator)()&&!!(0,n.getDocument)()}function C(){return I()?b.reactNative:E()?b.node:A()?b.browser:b.unknown}function P(){var e;try{return I()&&typeof s.g<"u"&&typeof(null==s.g?void 0:s.g.Application)<"u"?null==(e=s.g.Application)?void 0:e.applicationId:void 0}catch{return}}function S(){return(0,o.g)()||{name:"",description:"",url:"",icons:[""]}}function O(e,t,r){const o=function(){if(C()===b.reactNative&&typeof s.g<"u"&&typeof(null==s.g?void 0:s.g.Platform)<"u"){const{OS:e,Version:t}=s.g.Platform;return[e,t].join("-")}const e=(0,i.o0)();if(null===e)return"unknown";const t=e.os?e.os.replace(" ","").toLowerCase():"unknown";return"browser"===e.type?[t,e.name,e.version].join("-"):[t,e.version].join("-")}(),a=function(){var e;const t=C();return t===b.browser?[t,(null==(e=(0,n.getLocation)())?void 0:e.host)||"unknown"].join(":"):t}();return[[e,t].join("-"),[v,r].join("-"),o,a].join("/")}function T({protocol:e,version:t,relayUrl:s,sdkVersion:i,auth:r,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:c}){const h=s.split("?"),l={auth:r,ua:O(e,t,i),projectId:n,useOnCloseEvent:o||void 0,packageName:c||void 0,bundleId:a||void 0},p=function(e,t){const s=new URLSearchParams(e);for(const e of Object.keys(t).sort())if(t.hasOwnProperty(e)){const i=t[e];void 0!==i&&s.set(e,i)}return s.toString()}(h[1]||"",l);return h[0]+"?"+p}function k(e,t){return e.filter(e=>t.includes(e)).length===e.length}function x(e){return Object.fromEntries(e.entries())}function R(e){return new Map(Object.entries(e))}function U(e=r.FIVE_MINUTES,t){const s=(0,r.toMiliseconds)(e||r.FIVE_MINUTES);let i,n,o,a;return{resolve:e=>{o&&i&&(clearTimeout(o),i(e),a=Promise.resolve(e))},reject:e=>{o&&n&&(clearTimeout(o),n(e))},done:()=>new Promise((e,r)=>{if(a)return e(a);o=setTimeout(()=>{const e=new Error(t);a=Promise.reject(e),r(e)},s),i=e,n=r})}}function D(e,t,s){return new Promise(async(i,r)=>{const n=setTimeout(()=>r(new Error(s)),t);try{i(await e)}catch(e){r(e)}clearTimeout(n)})}function j(e,t){if("string"==typeof t&&t.startsWith(`${e}:`))return t;if("topic"===e.toLowerCase()){if("string"!=typeof t)throw new Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}if("id"===e.toLowerCase()){if("number"!=typeof t)throw new Error('Value must be "number" for expirer target type: id');return`id:${t}`}throw new Error(`Unknown expirer target type: ${e}`)}function M(e){return j("topic",e)}function L(e){return j("id",e)}function q(e){const[t,s]=e.split(":"),i={id:void 0,topic:void 0};if("topic"===t&&"string"==typeof s)i.topic=s;else{if("id"!==t||!Number.isInteger(Number(s)))throw new Error(`Invalid target, expected id:number or topic:string, got ${t}:${s}`);i.id=Number(s)}return i}function $(e,t){return(0,r.fromMiliseconds)((t||Date.now())+(0,r.toMiliseconds)(e))}function B(e){return Date.now()>=(0,r.toMiliseconds)(e)}function H(e,t){return`${e}${t?`:${t}`:""}`}function W(e=[],t=[]){return[...new Set([...e,...t])]}async function z({id:e,topic:t,wcDeepLink:i}){var r;try{if(!i)return;const o="string"==typeof i?JSON.parse(i):i,a=o?.href;if("string"!=typeof a)return;const c=function(e,t,s){const i=`requestId=${t}&sessionTopic=${s}`;e.endsWith("/")&&(e=e.slice(0,-1));let r=`${e}`;return r=e.startsWith("https://t.me")?`${r}${e.includes("?")?"&startapp=":"?startapp="}${function(e,t=!1){const s=u.from(e).toString("base64");return t?s.replace(/[=]/g,""):s}(i,!0)}`:`${r}/wc?${i}`,r}(a,e,t),h=C();if(h===b.browser){if(null==(r=(0,n.getDocument)())||!r.hasFocus())return void console.warn("Document does not have focus, skipping deeplink.");!function(e){let t="_self";!function(){try{return window.self!==window.top}catch{return!1}}()?(typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)||e.startsWith("https://")||e.startsWith("http://"))&&(t="_blank"):t="_top",window.open(e,t,"noreferrer noopener")}(c)}else h===b.reactNative&&typeof(null==s.g?void 0:s.g.Linking)<"u"&&await s.g.Linking.openURL(c)}catch(e){console.error(e)}}async function V(e,t){let s="";try{if(A()&&(s=localStorage.getItem(t),s))return s;s=await e.getItem(t)}catch(e){console.error(e)}return s}function F(e,t){if(!e.includes(t))return null;const s=e.split(/([&,?,=])/),i=s.indexOf(t);return s[i+2]}function K(){return typeof crypto<"u"&&null!=crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function G(){return typeof d<"u"&&"true"===d.env.IS_VITEST}function J(e){return u.from(e,"base64").toString("utf-8")}function Y(e){return new Promise(t=>setTimeout(t,e))}function Q(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function X(e,...t){if(!function(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Z(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");Q(e.outputLen),Q(e.blockLen)}function ee(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function te(e,t){X(e);const s=t.outputLen;if(e.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}const se=BigInt(2**32-1),ie=BigInt(32);function re(e,t=!1){return t?{h:Number(e&se),l:Number(e>>ie&se)}:{h:0|Number(e>>ie&se),l:0|Number(e&se)}}const ne="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function oe(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ae(e,t){return e<<32-t|e>>>t}const ce=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];function he(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function le(e){for(let t=0;t<e.length;t++)e[t]=he(e[t])}function pe(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),X(e),e}class de{clone(){return this._cloneInto()}}function ue(e){const t=t=>e().update(pe(t)).digest(),s=e();return t.outputLen=s.outputLen,t.blockLen=s.blockLen,t.create=()=>e(),t}function ge(e=32){if(ne&&"function"==typeof ne.getRandomValues)return ne.getRandomValues(new Uint8Array(e));if(ne&&"function"==typeof ne.randomBytes)return ne.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}const fe=[],me=[],we=[],ye=BigInt(0),be=BigInt(1),ve=BigInt(2),Ee=BigInt(7),Ie=BigInt(256),_e=BigInt(113);for(let e=0,t=be,s=1,i=0;e<24;e++){[s,i]=[i,(2*s+3*i)%5],fe.push(2*(5*i+s)),me.push((e+1)*(e+2)/2%64);let r=ye;for(let e=0;e<7;e++)t=(t<<be^(t>>Ee)*_e)%Ie,t&ve&&(r^=be<<(be<<BigInt(e))-be);we.push(r)}const[Ne,Ae]=function(e,t=!1){let s=new Uint32Array(e.length),i=new Uint32Array(e.length);for(let r=0;r<e.length;r++){const{h:n,l:o}=re(e[r],t);[s[r],i[r]]=[n,o]}return[s,i]}(we,!0),Ce=(e,t,s)=>s>32?((e,t,s)=>t<<s-32|e>>>64-s)(e,t,s):((e,t,s)=>e<<s|t>>>32-s)(e,t,s),Pe=(e,t,s)=>s>32?((e,t,s)=>e<<s-32|t>>>64-s)(e,t,s):((e,t,s)=>t<<s|e>>>32-s)(e,t,s);class Se extends de{constructor(e,t,s,i=!1,r=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=s,this.enableXOF=i,this.rounds=r,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Q(s),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var n;this.state=new Uint8Array(200),this.state32=(n=this.state,new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)))}keccak(){ce||le(this.state32),function(e,t=24){const s=new Uint32Array(10);for(let i=24-t;i<24;i++){for(let t=0;t<10;t++)s[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const i=(t+8)%10,r=(t+2)%10,n=s[r],o=s[r+1],a=Ce(n,o,1)^s[i],c=Pe(n,o,1)^s[i+1];for(let s=0;s<50;s+=10)e[t+s]^=a,e[t+s+1]^=c}let t=e[2],r=e[3];for(let s=0;s<24;s++){const i=me[s],n=Ce(t,r,i),o=Pe(t,r,i),a=fe[s];t=e[a],r=e[a+1],e[a]=n,e[a+1]=o}for(let t=0;t<50;t+=10){for(let i=0;i<10;i++)s[i]=e[t+i];for(let i=0;i<10;i++)e[t+i]^=~s[(i+2)%10]&s[(i+4)%10]}e[0]^=Ne[i],e[1]^=Ae[i]}s.fill(0)}(this.state32,this.rounds),ce||le(this.state32),this.posOut=0,this.pos=0}update(e){ee(this);const{blockLen:t,state:s}=this,i=(e=pe(e)).length;for(let r=0;r<i;){const n=Math.min(t-this.pos,i-r);for(let t=0;t<n;t++)s[this.pos++]^=e[r++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:s,blockLen:i}=this;e[s]^=t,!!(128&t)&&s===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){ee(this,!1),X(e),this.finish();const t=this.state,{blockLen:s}=this;for(let i=0,r=e.length;i<r;){this.posOut>=s&&this.keccak();const n=Math.min(s-this.posOut,r-i);e.set(t.subarray(this.posOut,this.posOut+n),i),this.posOut+=n,i+=n}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Q(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(te(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:t,suffix:s,outputLen:i,rounds:r,enableXOF:n}=this;return e||(e=new Se(t,s,i,n,r)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=r,e.suffix=s,e.outputLen=i,e.enableXOF=n,e.destroyed=this.destroyed,e}}const Oe=ue(()=>new Se(136,1,32)),Te="https://rpc.walletconnect.org/v1";function ke(e){const t=`Ethereum Signed Message:\n${e.length}`,s=(new TextEncoder).encode(t+e);return"0x"+u.from(Oe(s)).toString("hex")}var xe=Object.defineProperty,Re=Object.defineProperties,Ue=Object.getOwnPropertyDescriptors,De=Object.getOwnPropertySymbols,je=Object.prototype.hasOwnProperty,Me=Object.prototype.propertyIsEnumerable,Le=(e,t,s)=>t in e?xe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,qe=(e,t)=>{for(var s in t||(t={}))je.call(t,s)&&Le(e,s,t[s]);if(De)for(var s of De(t))Me.call(t,s)&&Le(e,s,t[s]);return e},$e=(e,t)=>Re(e,Ue(t));const Be=e=>e?.split(":"),He=e=>{const t=e&&Be(e);if(t)return t[2]+":"+t[3]},We=e=>{const t=e&&Be(e);if(t)return t.pop()};async function ze(e){const{cacao:t,projectId:s}=e,{s:i,p:r}=t,n=Ve(r,r.iss),o=We(r.iss);return await async function(e,t,s,i,r,n){switch(s.t){case"eip191":return await async function(e,t,s){return(await(0,a.x)({hash:ke(t),signature:s})).toLowerCase()===e.toLowerCase()}(e,t,s.s);case"eip1271":return await async function(e,t,s,i,r,n){const o=f(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{const o="0x1626ba7e",a="0000000000000000000000000000000000000000000000000000000000000040",c="0000000000000000000000000000000000000000000000000000000000000041",h=s.substring(2),l=o+ke(t).substring(2)+a+c+h,p=await fetch(`${n||Te}/?chainId=${i}&projectId=${r}`,{method:"POST",body:JSON.stringify({id:Date.now()+Math.floor(1e3*Math.random()),jsonrpc:"2.0",method:"eth_call",params:[{to:e,data:l},"latest"]})}),{result:d}=await p.json();return!!d&&d.slice(0,o.length).toLowerCase()===o.toLowerCase()}catch(e){return console.error("isValidEip1271Signature: ",e),!1}}(e,t,s.s,i,r,n);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${s.t}`)}}(o,n,i,He(r.iss),s)}const Ve=(e,t)=>{const s=`${e.domain} wants you to sign in with your Ethereum account:`,i=We(t);if(!e.aud&&!e.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let r=e.statement||void 0;const n=`URI: ${e.aud||e.uri}`,o=`Version: ${e.version}`,a=`Chain ID: ${(e=>{const t=e&&Be(e);if(t)return e.includes("did:pkh:")?t[3]:t[1]})(t)}`,c=`Nonce: ${e.nonce}`,h=`Issued At: ${e.iat}`,l=e.exp?`Expiration Time: ${e.exp}`:void 0,p=e.nbf?`Not Before: ${e.nbf}`:void 0,d=e.requestId?`Request ID: ${e.requestId}`:void 0,u=e.resources?`Resources:${e.resources.map(e=>`\n- ${e}`).join("")}`:void 0,g=et(e.resources);return g&&(r=function(e="",t){Fe(t);const s="I further authorize the stated URI to perform the following actions on my behalf: ";if(e.includes(s))return e;const i=[];let r=0;return Object.keys(t.att).forEach(e=>{const s=Object.keys(t.att[e]).map(e=>({ability:e.split("/")[0],action:e.split("/")[1]}));s.sort((e,t)=>e.action.localeCompare(t.action));const n={};s.forEach(e=>{n[e.ability]||(n[e.ability]=[]),n[e.ability].push(e.action)});const o=Object.keys(n).map(t=>(r++,`(${r}) '${t}': '${n[t].join("', '")}' for '${e}'.`));i.push(o.join(", ").replace(".,","."))}),`${e?e+" ":""}${s}${i.join(" ")}`}(r,Je(g))),[s,i,"",r,"",n,o,a,c,h,l,p,d,u].filter(e=>null!=e).join("\n")};function Fe(e){if(!e)throw new Error("No recap provided, value is undefined");if(!e.att)throw new Error("No `att` property found");const t=Object.keys(e.att);if(null==t||!t.length)throw new Error("No resources found in `att` property");t.forEach(t=>{const s=e.att[t];if(Array.isArray(s))throw new Error(`Resource must be an object: ${t}`);if("object"!=typeof s)throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(s).length)throw new Error(`Resource object is empty: ${t}`);Object.keys(s).forEach(e=>{const t=s[e];if(!Array.isArray(t))throw new Error(`Ability limits ${e} must be an array of objects, found: ${t}`);if(!t.length)throw new Error(`Value of ${e} is empty array, must be an array with objects`);t.forEach(t=>{if("object"!=typeof t)throw new Error(`Ability limits (${e}) must be an array of objects, found: ${t}`)})})})}function Ke(e,t,s={}){t=t?.sort((e,t)=>e.localeCompare(t));const i=t.map(t=>({[`${e}/${t}`]:[s]}));return Object.assign({},...i)}function Ge(e){return Fe(e),`urn:recap:${function(e){return u.from(JSON.stringify(e)).toString("base64")}(e).replace(/=/g,"")}`}function Je(e){const t=function(e){return JSON.parse(u.from(e,"base64").toString("utf-8"))}(e.replace("urn:recap:",""));return Fe(t),t}function Ye(e,t,s){const i=function(e,t,s,i={}){return s?.sort((e,t)=>e.localeCompare(t)),{att:{[e]:Ke(t,s,i)}}}(e,t,s);return Ge(i)}function Qe(e,t){const s=function(e,t){Fe(e),Fe(t);const s=Object.keys(e.att).concat(Object.keys(t.att)).sort((e,t)=>e.localeCompare(t)),i={att:{}};return s.forEach(s=>{var r,n;Object.keys((null==(r=e.att)?void 0:r[s])||{}).concat(Object.keys((null==(n=t.att)?void 0:n[s])||{})).sort((e,t)=>e.localeCompare(t)).forEach(r=>{var n,o;i.att[s]=$e(qe({},i.att[s]),{[r]:(null==(n=e.att[s])?void 0:n[r])||(null==(o=t.att[s])?void 0:o[r])})})}),i}(Je(e),Je(t));return Ge(s)}function Xe(e){var t;const s=Je(e);Fe(s);const i=null==(t=s.att)?void 0:t.eip155;return i?Object.keys(i).map(e=>e.split("/")[1]):[]}function Ze(e){const t=Je(e);Fe(t);const s=[];return Object.values(t.att).forEach(e=>{Object.values(e).forEach(e=>{var t;null!=(t=e?.[0])&&t.chains&&s.push(e[0].chains)})}),[...new Set(s.flat())]}function et(e){if(!e)return;const t=e?.[e.length-1];return function(e){return e&&e.includes("urn:recap:")}(t)?t:void 0}function tt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function st(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function it(e,...t){if(!st(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function rt(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function nt(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}const ot=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");function at(e){if("string"==typeof e)e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e);else{if(!st(e))throw new Error("Uint8Array expected, got "+typeof e);e=lt(e)}return e}function ct(e,t,s=!0){if(void 0===t)return new Uint8Array(e);if(t.length!==e)throw new Error("invalid output length, expected "+e+", got: "+t.length);if(s&&!function(e){return e.byteOffset%4==0}(t))throw new Error("invalid output, must be aligned");return t}function ht(e,t,s,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,s,i);const r=BigInt(32),n=BigInt(4294967295),o=Number(s>>r&n),a=Number(s&n),c=i?4:0,h=i?0:4;e.setUint32(t+c,o,i),e.setUint32(t+h,a,i)}function lt(e){return Uint8Array.from(e)}function pt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const dt=e=>Uint8Array.from(e.split("").map(e=>e.charCodeAt(0))),ut=dt("expand 16-byte k"),gt=dt("expand 32-byte k"),ft=ot(ut),mt=ot(gt);function wt(e,t){return e<<t|e>>>32-t}function yt(e){return e.byteOffset%4==0}const bt=2**32-1,vt=new Uint32Array,Et=(e,t)=>255&e[t++]|(255&e[t++])<<8;class It{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,it(e=at(e),32);const t=Et(e,0),s=Et(e,2),i=Et(e,4),r=Et(e,6),n=Et(e,8),o=Et(e,10),a=Et(e,12),c=Et(e,14);this.r[0]=8191&t,this.r[1]=8191&(t>>>13|s<<3),this.r[2]=7939&(s>>>10|i<<6),this.r[3]=8191&(i>>>7|r<<9),this.r[4]=255&(r>>>4|n<<12),this.r[5]=n>>>1&8190,this.r[6]=8191&(n>>>14|o<<2),this.r[7]=8065&(o>>>11|a<<5),this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127;for(let t=0;t<8;t++)this.pad[t]=Et(e,16+2*t)}process(e,t,s=!1){const i=s?0:2048,{h:r,r:n}=this,o=n[0],a=n[1],c=n[2],h=n[3],l=n[4],p=n[5],d=n[6],u=n[7],g=n[8],f=n[9],m=Et(e,t+0),w=Et(e,t+2),y=Et(e,t+4),b=Et(e,t+6),v=Et(e,t+8),E=Et(e,t+10),I=Et(e,t+12),_=Et(e,t+14);let N=r[0]+(8191&m),A=r[1]+(8191&(m>>>13|w<<3)),C=r[2]+(8191&(w>>>10|y<<6)),P=r[3]+(8191&(y>>>7|b<<9)),S=r[4]+(8191&(b>>>4|v<<12)),O=r[5]+(v>>>1&8191),T=r[6]+(8191&(v>>>14|E<<2)),k=r[7]+(8191&(E>>>11|I<<5)),x=r[8]+(8191&(I>>>8|_<<8)),R=r[9]+(_>>>5|i),U=0,D=U+N*o+A*(5*f)+C*(5*g)+P*(5*u)+S*(5*d);U=D>>>13,D&=8191,D+=O*(5*p)+T*(5*l)+k*(5*h)+x*(5*c)+R*(5*a),U+=D>>>13,D&=8191;let j=U+N*a+A*o+C*(5*f)+P*(5*g)+S*(5*u);U=j>>>13,j&=8191,j+=O*(5*d)+T*(5*p)+k*(5*l)+x*(5*h)+R*(5*c),U+=j>>>13,j&=8191;let M=U+N*c+A*a+C*o+P*(5*f)+S*(5*g);U=M>>>13,M&=8191,M+=O*(5*u)+T*(5*d)+k*(5*p)+x*(5*l)+R*(5*h),U+=M>>>13,M&=8191;let L=U+N*h+A*c+C*a+P*o+S*(5*f);U=L>>>13,L&=8191,L+=O*(5*g)+T*(5*u)+k*(5*d)+x*(5*p)+R*(5*l),U+=L>>>13,L&=8191;let q=U+N*l+A*h+C*c+P*a+S*o;U=q>>>13,q&=8191,q+=O*(5*f)+T*(5*g)+k*(5*u)+x*(5*d)+R*(5*p),U+=q>>>13,q&=8191;let $=U+N*p+A*l+C*h+P*c+S*a;U=$>>>13,$&=8191,$+=O*o+T*(5*f)+k*(5*g)+x*(5*u)+R*(5*d),U+=$>>>13,$&=8191;let B=U+N*d+A*p+C*l+P*h+S*c;U=B>>>13,B&=8191,B+=O*a+T*o+k*(5*f)+x*(5*g)+R*(5*u),U+=B>>>13,B&=8191;let H=U+N*u+A*d+C*p+P*l+S*h;U=H>>>13,H&=8191,H+=O*c+T*a+k*o+x*(5*f)+R*(5*g),U+=H>>>13,H&=8191;let W=U+N*g+A*u+C*d+P*p+S*l;U=W>>>13,W&=8191,W+=O*h+T*c+k*a+x*o+R*(5*f),U+=W>>>13,W&=8191;let z=U+N*f+A*g+C*u+P*d+S*p;U=z>>>13,z&=8191,z+=O*l+T*h+k*c+x*a+R*o,U+=z>>>13,z&=8191,U=(U<<2)+U|0,U=U+D|0,D=8191&U,U>>>=13,j+=U,r[0]=D,r[1]=j,r[2]=M,r[3]=L,r[4]=q,r[5]=$,r[6]=B,r[7]=H,r[8]=W,r[9]=z}finalize(){const{h:e,pad:t}=this,s=new Uint16Array(10);let i=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=i,i=e[t]>>>13,e[t]&=8191;e[0]+=5*i,i=e[0]>>>13,e[0]&=8191,e[1]+=i,i=e[1]>>>13,e[1]&=8191,e[2]+=i,s[0]=e[0]+5,i=s[0]>>>13,s[0]&=8191;for(let t=1;t<10;t++)s[t]=e[t]+i,i=s[t]>>>13,s[t]&=8191;s[9]-=8192;let r=(1^i)-1;for(let e=0;e<10;e++)s[e]&=r;r=~r;for(let t=0;t<10;t++)e[t]=e[t]&r|s[t];e[0]=65535&(e[0]|e[1]<<13),e[1]=65535&(e[1]>>>3|e[2]<<10),e[2]=65535&(e[2]>>>6|e[3]<<7),e[3]=65535&(e[3]>>>9|e[4]<<4),e[4]=65535&(e[4]>>>12|e[5]<<1|e[6]<<14),e[5]=65535&(e[6]>>>2|e[7]<<11),e[6]=65535&(e[7]>>>5|e[8]<<8),e[7]=65535&(e[8]>>>8|e[9]<<5);let n=e[0]+t[0];e[0]=65535&n;for(let s=1;s<8;s++)n=(e[s]+t[s]|0)+(n>>>16)|0,e[s]=65535&n;pt(s)}update(e){rt(this);const{buffer:t,blockLen:s}=this,i=(e=at(e)).length;for(let r=0;r<i;){const n=Math.min(s-this.pos,i-r);if(n!==s)t.set(e.subarray(r,r+n),this.pos),this.pos+=n,r+=n,this.pos===s&&(this.process(t,0,!1),this.pos=0);else for(;s<=i-r;r+=s)this.process(e,r)}return this}destroy(){pt(this.h,this.r,this.buffer,this.pad)}digestInto(e){rt(this),function(e,t){it(e);const s=t.outputLen;if(e.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}(e,this),this.finished=!0;const{buffer:t,h:s}=this;let{pos:i}=this;if(i){for(t[i++]=1;i<16;i++)t[i]=0;this.process(t,0,!0)}this.finalize();let r=0;for(let t=0;t<8;t++)e[r++]=s[t]>>>0,e[r++]=s[t]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const s=e.slice(0,t);return this.destroy(),s}}const _t=function(e){const t=(t,s)=>e(s).update(at(t)).digest(),s=e(new Uint8Array(32));return t.outputLen=s.outputLen,t.blockLen=s.blockLen,t.create=t=>e(t),t}(e=>new It(e)),Nt=function(e){const{allowShortKeys:t,extendNonceFn:s,counterLength:i,counterRight:r,rounds:n}=function(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t)}(0,{counterRight:!1,counterLength:4,allowShortKeys:!1});return tt(i),tt(n),nt(r),nt(t),(o,a,c,h,l=0)=>{it(o),it(a),it(c);const p=c.length;if(void 0===h&&(h=new Uint8Array(p)),it(h),tt(l),l<0||l>=bt)throw new Error("arx: counter overflow");if(h.length<p)throw new Error(`arx: output (${h.length}) is shorter than data (${p})`);const d=[];let u,g,f=o.length;if(32===f)d.push(u=lt(o)),g=mt;else{if(16!==f||!t)throw new Error(`arx: invalid 32-byte key, got length=${f}`);u=new Uint8Array(32),u.set(o),u.set(o,16),g=ft,d.push(u)}yt(a)||d.push(a=lt(a));const m=ot(u);if(s){if(24!==a.length)throw new Error("arx: extended nonce must be 24 bytes");s(g,m,ot(a.subarray(0,16)),m),a=a.subarray(16)}const w=16-i;if(w!==a.length)throw new Error(`arx: nonce must be ${w} or 16 bytes`);if(12!==w){const e=new Uint8Array(12);e.set(a,r?0:12-a.length),a=e,d.push(a)}const y=ot(a);return function(e,t,s,i,r,n,o,a){const c=r.length,h=new Uint8Array(64),l=ot(h),p=yt(r)&&yt(n),d=p?ot(r):vt,u=p?ot(n):vt;for(let g=0;g<c;o++){if(e(t,s,i,l,o,a),o>=bt)throw new Error("arx: counter overflow");const f=Math.min(64,c-g);if(p&&64===f){const e=g/4;if(g%4!=0)throw new Error("arx: invalid block position");for(let t,s=0;s<16;s++)t=e+s,u[t]=d[t]^l[s];g+=64;continue}for(let e,t=0;t<f;t++)e=g+t,n[e]=r[e]^h[t];g+=f}}(e,g,m,y,c,h,l,n),pt(...d),h}}(function(e,t,s,i,r,n=20){let o=e[0],a=e[1],c=e[2],h=e[3],l=t[0],p=t[1],d=t[2],u=t[3],g=t[4],f=t[5],m=t[6],w=t[7],y=r,b=s[0],v=s[1],E=s[2],I=o,_=a,N=c,A=h,C=l,P=p,S=d,O=u,T=g,k=f,x=m,R=w,U=y,D=b,j=v,M=E;for(let e=0;e<n;e+=2)I=I+C|0,U=wt(U^I,16),T=T+U|0,C=wt(C^T,12),I=I+C|0,U=wt(U^I,8),T=T+U|0,C=wt(C^T,7),_=_+P|0,D=wt(D^_,16),k=k+D|0,P=wt(P^k,12),_=_+P|0,D=wt(D^_,8),k=k+D|0,P=wt(P^k,7),N=N+S|0,j=wt(j^N,16),x=x+j|0,S=wt(S^x,12),N=N+S|0,j=wt(j^N,8),x=x+j|0,S=wt(S^x,7),A=A+O|0,M=wt(M^A,16),R=R+M|0,O=wt(O^R,12),A=A+O|0,M=wt(M^A,8),R=R+M|0,O=wt(O^R,7),I=I+P|0,M=wt(M^I,16),x=x+M|0,P=wt(P^x,12),I=I+P|0,M=wt(M^I,8),x=x+M|0,P=wt(P^x,7),_=_+S|0,U=wt(U^_,16),R=R+U|0,S=wt(S^R,12),_=_+S|0,U=wt(U^_,8),R=R+U|0,S=wt(S^R,7),N=N+O|0,D=wt(D^N,16),T=T+D|0,O=wt(O^T,12),N=N+O|0,D=wt(D^N,8),T=T+D|0,O=wt(O^T,7),A=A+C|0,j=wt(j^A,16),k=k+j|0,C=wt(C^k,12),A=A+C|0,j=wt(j^A,8),k=k+j|0,C=wt(C^k,7);let L=0;i[L++]=o+I|0,i[L++]=a+_|0,i[L++]=c+N|0,i[L++]=h+A|0,i[L++]=l+C|0,i[L++]=p+P|0,i[L++]=d+S|0,i[L++]=u+O|0,i[L++]=g+T|0,i[L++]=f+k|0,i[L++]=m+x|0,i[L++]=w+R|0,i[L++]=y+U|0,i[L++]=b+D|0,i[L++]=v+j|0,i[L++]=E+M|0}),At=new Uint8Array(16),Ct=(e,t)=>{e.update(t);const s=t.length%16;s&&e.update(At.subarray(s))},Pt=new Uint8Array(32);function St(e,t,s,i,r){const n=e(t,s,Pt),o=_t.create(n);r&&Ct(o,r),Ct(o,i);const a=new Uint8Array(16),c=(e=>new DataView(e.buffer,e.byteOffset,e.byteLength))(a);ht(c,0,BigInt(r?r.length:0),!0),ht(c,8,BigInt(i.length),!0),o.update(a);const h=o.digest();return pt(n,a),h}const Ot=((e,t)=>{function s(s,...i){if(it(s),void 0!==e.nonceLength){const t=i[0];if(!t)throw new Error("nonce / iv required");e.varSizeNonce?it(t):it(t,e.nonceLength)}const r=e.tagLength;r&&void 0!==i[1]&&it(i[1]);const n=t(s,...i),o=(e,t)=>{if(void 0!==t){if(2!==e)throw new Error("cipher output not supported");it(t)}};let a=!1;return{encrypt(e,t){if(a)throw new Error("cannot encrypt() twice with same key + nonce");return a=!0,it(e),o(n.encrypt.length,t),n.encrypt(e,t)},decrypt(e,t){if(it(e),r&&e.length<r)throw new Error("invalid ciphertext length: smaller than tagLength="+r);return o(n.decrypt.length,t),n.decrypt(e,t)}}}return Object.assign(s,e),s})({blockSize:64,nonceLength:12,tagLength:16},(e=>(t,s,i)=>({encrypt(r,n){const o=r.length;(n=ct(o+16,n,!1)).set(r);const a=n.subarray(0,-16);e(t,s,a,a,1);const c=St(e,t,s,a,i);return n.set(c,o),pt(c),n},decrypt(r,n){n=ct(r.length-16,n,!1);const o=r.subarray(0,-16),a=r.subarray(-16),c=St(e,t,s,o,i);if(!function(e,t){if(e.length!==t.length)return!1;let s=0;for(let i=0;i<e.length;i++)s|=e[i]^t[i];return 0===s}(a,c))throw new Error("invalid tag");return n.set(r.subarray(0,-16)),e(t,s,n,n,1),pt(c),n}}))(Nt));class Tt extends de{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Z(e);const s=pe(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,r=new Uint8Array(i);r.set(s.length>i?e.create().update(s).digest():s);for(let e=0;e<r.length;e++)r[e]^=54;this.iHash.update(r),this.oHash=e.create();for(let e=0;e<r.length;e++)r[e]^=106;this.oHash.update(r),r.fill(0)}update(e){return ee(this),this.iHash.update(e),this}digestInto(e){ee(this),X(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:t,iHash:s,finished:i,destroyed:r,blockLen:n,outputLen:o}=this;return e.finished=i,e.destroyed=r,e.blockLen=n,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=s._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const kt=(e,t,s)=>new Tt(e,t).update(s).digest();kt.create=(e,t)=>new Tt(e,t);const xt=new Uint8Array([0]),Rt=new Uint8Array,Ut=(e,t,s,i,r)=>function(e,t,s,i=32){if(Z(e),Q(i),i>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const r=Math.ceil(i/e.outputLen);void 0===s&&(s=Rt);const n=new Uint8Array(r*e.outputLen),o=kt.create(e,t),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let t=0;t<r;t++)xt[0]=t+1,a.update(0===t?Rt:c).update(s).update(xt).digestInto(c),n.set(c,e.outputLen*t),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),xt.fill(0),n.slice(0,i)}(e,function(e,t,s){return Z(e),void 0===s&&(s=new Uint8Array(e.outputLen)),kt(e,pe(s),pe(t))}(e,t,s),i,r);function Dt(e,t,s){return e&t^~e&s}function jt(e,t,s){return e&t^e&s^t&s}class Mt extends de{constructor(e,t,s,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=s,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=oe(this.buffer)}update(e){ee(this);const{view:t,buffer:s,blockLen:i}=this,r=(e=pe(e)).length;for(let n=0;n<r;){const o=Math.min(i-this.pos,r-n);if(o===i){const t=oe(e);for(;i<=r-n;n+=i)this.process(t,n);continue}s.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){ee(this),te(e,this),this.finished=!0;const{buffer:t,view:s,blockLen:i,isLE:r}=this;let{pos:n}=this;t[n++]=128,this.buffer.subarray(n).fill(0),this.padOffset>i-n&&(this.process(s,0),n=0);for(let e=n;e<i;e++)t[e]=0;(function(e,t,s,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,s,i);const r=BigInt(32),n=BigInt(4294967295),o=Number(s>>r&n),a=Number(s&n),c=i?4:0,h=i?0:4;e.setUint32(t+c,o,i),e.setUint32(t+h,a,i)})(s,i-8,BigInt(8*this.length),r),this.process(s,0);const o=oe(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,h=this.get();if(c>h.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)o.setUint32(4*e,h[e],r)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const s=e.slice(0,t);return this.destroy(),s}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:s,length:i,finished:r,destroyed:n,pos:o}=this;return e.length=i,e.pos=o,e.finished=r,e.destroyed=n,i%t&&e.buffer.set(s),e}}const Lt=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]),qt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),$t=new Uint32Array(64);class Bt extends Mt{constructor(){super(64,32,8,!1),this.A=0|qt[0],this.B=0|qt[1],this.C=0|qt[2],this.D=0|qt[3],this.E=0|qt[4],this.F=0|qt[5],this.G=0|qt[6],this.H=0|qt[7]}get(){const{A:e,B:t,C:s,D:i,E:r,F:n,G:o,H:a}=this;return[e,t,s,i,r,n,o,a]}set(e,t,s,i,r,n,o,a){this.A=0|e,this.B=0|t,this.C=0|s,this.D=0|i,this.E=0|r,this.F=0|n,this.G=0|o,this.H=0|a}process(e,t){for(let s=0;s<16;s++,t+=4)$t[s]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=$t[e-15],s=$t[e-2],i=ae(t,7)^ae(t,18)^t>>>3,r=ae(s,17)^ae(s,19)^s>>>10;$t[e]=r+$t[e-7]+i+$t[e-16]|0}let{A:s,B:i,C:r,D:n,E:o,F:a,G:c,H:h}=this;for(let e=0;e<64;e++){const t=h+(ae(o,6)^ae(o,11)^ae(o,25))+Dt(o,a,c)+Lt[e]+$t[e]|0,l=(ae(s,2)^ae(s,13)^ae(s,22))+jt(s,i,r)|0;h=c,c=a,a=o,o=n+t|0,n=r,r=i,i=s,s=t+l|0}s=s+this.A|0,i=i+this.B|0,r=r+this.C|0,n=n+this.D|0,o=o+this.E|0,a=a+this.F|0,c=c+this.G|0,h=h+this.H|0,this.set(s,i,r,n,o,a,c,h)}roundClean(){$t.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Ht=ue(()=>new Bt),Wt=BigInt(0);function zt(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function Vt(e){if(!zt(e))throw new Error("Uint8Array expected")}const Ft=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Kt(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function Gt(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,s=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const i=new Uint8Array(s);for(let t=0,r=0;t<s;t++,r+=2){const s=Kt(e.charCodeAt(r)),n=Kt(e.charCodeAt(r+1));if(void 0===s||void 0===n){const t=e[r]+e[r+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+r)}i[t]=16*s+n}return i}function Jt(e){return Vt(e),function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?Wt:BigInt("0x"+e)}(function(e){Vt(e);let t="";for(let s=0;s<e.length;s++)t+=Ft[e[s]];return t}(Uint8Array.from(e).reverse()))}function Yt(e,t,s){let i;if("string"==typeof t)try{i=Gt(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!zt(t))throw new Error(e+" must be hex string or Uint8Array");i=Uint8Array.from(t)}const r=i.length;if("number"==typeof s&&r!==s)throw new Error(e+" of length "+s+" expected, got "+r);return i}const Qt=e=>"bigint"==typeof e&&Wt<=e;function Xt(e,t,s,i){if(!function(e,t,s){return Qt(e)&&Qt(t)&&Qt(s)&&t<=e&&e<s}(t,s,i))throw new Error("expected valid "+e+": "+s+" <= n < "+i+", got "+t)}const Zt={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||zt(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)},es=BigInt(0),ts=BigInt(1);function ss(e,t){const s=e%t;return s>=es?s:t+s}function is(e,t,s){let i=e;for(;t-- >es;)i*=i,i%=s;return i}BigInt(0),BigInt(1),BigInt(0),BigInt(1),BigInt(2),BigInt(8);const rs=BigInt(0),ns=BigInt(1);const os=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const as=BigInt(1),cs=BigInt(2),hs=BigInt(3),ls=BigInt(5);BigInt(8);const ps=function(e){const t=function(e){return function(e,t,s={}){const i=(t,s,i)=>{const r=Zt[s];if("function"!=typeof r)throw new Error("invalid validator function");const n=e[t];if(!(i&&void 0===n||r(n,e)))throw new Error("param "+String(t)+" is invalid. Expected "+s+", got "+n)};for(const[e,s]of Object.entries(t))i(e,s,!1);for(const[e,t]of Object.entries(s))i(e,t,!0)}(e,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...e})}(e),{P:s}=t,i=e=>ss(e,s),r=t.montgomeryBits,n=Math.ceil(r/8),o=t.nByteLength,a=t.adjustScalarBytes||(e=>e),c=t.powPminus2||(e=>function(e,t,s){if(t<es)throw new Error("invalid exponent, negatives unsupported");if(s<=es)throw new Error("invalid modulus");if(s===ts)return es;let i=ts;for(;t>es;)t&ts&&(i=i*e%s),e=e*e%s,t>>=ts;return i}(e,s-BigInt(2),s));function h(e,t,s){const r=i(e*(t-s));return[t=i(t-r),s=i(s+r)]}const l=(t.a-BigInt(2))/BigInt(4);function p(e){return function(e,t){return function(e,t){return Gt(e.toString(16).padStart(2*t,"0"))}(e,t).reverse()}(i(e),n)}function d(e,t){const d=function(e){const t=Yt("u coordinate",e,n);return 32===o&&(t[31]&=127),Jt(t)}(t),u=function(e){const t=Yt("scalar",e),s=t.length;if(s!==n&&s!==o)throw new Error("invalid scalar, expected "+n+" or "+o+" bytes, got "+s);return Jt(a(t))}(e),g=function(e,t){Xt("u",e,rs,s),Xt("scalar",t,rs,s);const n=t,o=e;let a,p=ns,d=rs,u=e,g=ns,f=rs;for(let e=BigInt(r-1);e>=rs;e--){const t=n>>e&ns;f^=t,a=h(f,p,u),p=a[0],u=a[1],a=h(f,d,g),d=a[0],g=a[1],f=t;const s=p+d,r=i(s*s),c=p-d,m=i(c*c),w=r-m,y=u+g,b=i((u-g)*s),v=i(y*c),E=b+v,I=b-v;u=i(E*E),g=i(o*i(I*I)),p=i(r*m),d=i(w*(r+i(l*w)))}a=h(f,p,u),p=a[0],u=a[1],a=h(f,d,g),d=a[0],g=a[1];const m=c(d);return i(p*m)}(d,u);if(g===rs)throw new Error("invalid private or public key received");return p(g)}const u=p(t.Gu);function g(e){return d(e,u)}return{scalarMult:d,scalarMultBase:g,getSharedSecret:(e,t)=>d(e,t),getPublicKey:e=>g(e),utils:{randomPrivateKey:()=>t.randomBytes(t.nByteLength)},GuBytes:u}}({P:os,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{const t=os,{pow_p_5_8:s,b2:i}=function(e){const t=BigInt(10),s=BigInt(20),i=BigInt(40),r=BigInt(80),n=os,o=e*e%n*e%n,a=is(o,cs,n)*o%n,c=is(a,as,n)*e%n,h=is(c,ls,n)*c%n,l=is(h,t,n)*h%n,p=is(l,s,n)*l%n,d=is(p,i,n)*p%n,u=is(d,r,n)*d%n,g=is(u,r,n)*d%n,f=is(g,t,n)*h%n;return{pow_p_5_8:is(f,cs,n)*e%n,b2:o}}(e);return ss(is(s,hs,t)*i,t)},adjustScalarBytes:function(e){return e[0]&=248,e[31]&=127,e[31]|=64,e},randomBytes:ge}),ds="base10",us="base16",gs="base64pad",fs="base64url",ms="utf8",ws=0,ys=1,bs=2,vs=0,Es=1,Is=12,_s=32;function Ns(){const e=ps.utils.randomPrivateKey(),t=ps.getPublicKey(e);return{privateKey:(0,h.dI)(e,us),publicKey:(0,h.dI)(t,us)}}function As(){const e=ge(_s);return(0,h.dI)(e,us)}function Cs(e,t){const s=ps.getSharedSecret((0,h.sH)(e,us),(0,h.sH)(t,us)),i=Ut(Ht,s,void 0,void 0,_s);return(0,h.dI)(i,us)}function Ps(e){const t=Ht((0,h.sH)(e,us));return(0,h.dI)(t,us)}function Ss(e){const t=Ht((0,h.sH)(e,ms));return(0,h.dI)(t,us)}function Os(e){return(0,h.sH)(`${e}`,ds)}function Ts(e){return Number((0,h.dI)(e,ds))}function ks(e){const t=Os(typeof e.type<"u"?e.type:ws);if(Ts(t)===ys&&typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const s=typeof e.senderPublicKey<"u"?(0,h.sH)(e.senderPublicKey,us):void 0,i=typeof e.iv<"u"?(0,h.sH)(e.iv,us):ge(Is),r=(0,h.sH)(e.symKey,us);return Ds({type:t,sealed:Ot(r,i).encrypt((0,h.sH)(e.message,ms)),iv:i,senderPublicKey:s,encoding:e.encoding})}function xs(e){const t=(0,h.sH)(e.symKey,us),{sealed:s,iv:i}=js(e),r=Ot(t,i).decrypt(s);if(null===r)throw new Error("Failed to decrypt");return(0,h.dI)(r,ms)}function Rs(e,t){const s=Os(bs),i=ge(Is);return Ds({type:s,sealed:(0,h.sH)(e,ms),iv:i,encoding:t})}function Us(e,t){const{sealed:s}=js({encoded:e,encoding:t});return(0,h.dI)(s,ms)}function Ds(e){const{encoding:t=gs}=e;if(Ts(e.type)===bs)return(0,h.dI)((0,h.xW)([e.type,e.sealed]),t);if(Ts(e.type)===ys){if(typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return(0,h.dI)((0,h.xW)([e.type,e.senderPublicKey,e.iv,e.sealed]),t)}return(0,h.dI)((0,h.xW)([e.type,e.iv,e.sealed]),t)}function js(e){const{encoded:t,encoding:s=gs}=e,i=(0,h.sH)(t,s),r=i.slice(vs,Es),n=Es;if(Ts(r)===ys){const e=n+_s,t=e+Is,s=i.slice(n,e),o=i.slice(e,t);return{type:r,sealed:i.slice(t),iv:o,senderPublicKey:s}}if(Ts(r)===bs)return{type:r,sealed:i.slice(n),iv:ge(Is)};const o=n+Is,a=i.slice(n,o);return{type:r,sealed:i.slice(o),iv:a}}function Ms(e,t){const s=js({encoded:e,encoding:t?.encoding});return Ls({type:Ts(s.type),senderPublicKey:typeof s.senderPublicKey<"u"?(0,h.dI)(s.senderPublicKey,us):void 0,receiverPublicKey:t?.receiverPublicKey})}function Ls(e){const t=e?.type||ws;if(t===ys){if(typeof e?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof e?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:t,senderPublicKey:e?.senderPublicKey,receiverPublicKey:e?.receiverPublicKey}}function qs(e){return e.type===ys&&"string"==typeof e.senderPublicKey&&"string"==typeof e.receiverPublicKey}function $s(e){return e.type===bs}function Bs(e,t){const[s,i,r]=e.split("."),n=function(e){return u.from(function(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");const s=t.length%4;return s>0&&(t+="=".repeat(4-s)),t}(e),"base64")}(r);if(64!==n.length)throw new Error("Invalid signature length");const o=n.slice(0,32).toString("hex"),a=n.slice(32,64).toString("hex"),p=Ht(`${s}.${i}`),d=function(e){return new l.ec("p256").keyFromPublic({x:u.from(e.x,"base64").toString("hex"),y:u.from(e.y,"base64").toString("hex")},"hex")}(t),g=(0,h.dI)(p,us);if(!d.verify(g,{r:o,s:a}))throw new Error("Invalid signature");return(0,c.Cq)(e).payload}const Hs="irn";function Ws(e){return e?.relay||{protocol:Hs}}function zs(e){const t=p.CG[e];if(typeof t>"u")throw new Error(`Relay Protocol not supported: ${e}`);return t}function Vs(e,t="-"){const s={},i="relay"+t;return Object.keys(e).forEach(t=>{if(t.startsWith(i)){const r=t.replace(i,""),n=e[t];s[r]=n}}),s}function Fs(e){if(!e.includes("wc:")){const t=J(e);null!=t&&t.includes("wc:")&&(e=t)}const t=(e=(e=e.includes("wc://")?e.replace("wc://",""):e).includes("wc:")?e.replace("wc:",""):e).indexOf(":"),s=-1!==e.indexOf("?")?e.indexOf("?"):void 0,i=e.substring(0,t),r=e.substring(t+1,s).split("@"),n=typeof s<"u"?e.substring(s):"",o=new URLSearchParams(n),a={};o.forEach((e,t)=>{a[t]=e});const c="string"==typeof a.methods?a.methods.split(","):void 0;return{protocol:i,topic:Ks(r[0]),version:parseInt(r[1],10),symKey:a.symKey,relay:Vs(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function Ks(e){return e.startsWith("//")?e.substring(2):e}function Gs(e){const t=new URLSearchParams,s=function(e,t="-"){const s={};return Object.keys(e).forEach(i=>{const r=i,n="relay"+t+r;e[r]&&(s[n]=e[r])}),s}(e.relay);Object.keys(s).sort().forEach(e=>{t.set(e,s[e])}),t.set("symKey",e.symKey),e.expiryTimestamp&&t.set("expiryTimestamp",e.expiryTimestamp.toString()),e.methods&&t.set("methods",e.methods.join(","));const i=t.toString();return`${e.protocol}:${e.topic}@${e.version}?${i}`}function Js(e,t,s){return`${e}?wc_ev=${s}&topic=${t}`}function Ys(e){const t=[];return e.forEach(e=>{const[s,i]=e.split(":");t.push(`${s}:${i}`)}),t}function Qs(e){return e.includes(":")}function Xs(e){return Qs(e)?e.split(":")[0]:e}function Zs(e,t){const s=function(e){const t={};return e?.forEach(e=>{var s;const[i,r]=e.split(":");t[i]||(t[i]={accounts:[],chains:[],events:[],methods:[]}),t[i].accounts.push(e),null==(s=t[i].chains)||s.push(`${i}:${r}`)}),t}(t=t.map(e=>e.replace("did:pkh:","")));for(const[t,i]of Object.entries(s))i.methods?i.methods=W(i.methods,e):i.methods=e,i.events=["chainChanged","accountsChanged"];return s}Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;const ei={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}},ti={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 si(e,t){const{message:s,code:i}=ti[e];return{message:t?`${s} ${t}`:s,code:i}}function ii(e,t){const{message:s,code:i}=ei[e];return{message:t?`${s} ${t}`:s,code:i}}function ri(e,t){return!!Array.isArray(e)&&(!(typeof t<"u"&&e.length)||e.every(t))}function ni(e){return Object.getPrototypeOf(e)===Object.prototype&&Object.keys(e).length}function oi(e){return typeof e>"u"}function ai(e,t){return!(!t||!oi(e))||"string"==typeof e&&!!e.trim().length}function ci(e,t){return!(!t||!oi(e))||"number"==typeof e&&!isNaN(e)}function hi(e,t){const{requiredNamespaces:s}=t,i=Object.keys(e.namespaces),r=Object.keys(s);let n=!0;return!!k(r,i)&&(i.forEach(t=>{const{accounts:i,methods:r,events:o}=e.namespaces[t],a=Ys(i),c=s[t];k(w(t,c),a)&&k(c.methods,r)&&k(c.events,o)||(n=!1)}),n)}function li(e){return!(!ai(e,!1)||!e.includes(":"))&&2===e.split(":").length}function pi(e){function t(e){try{return typeof new URL(e)<"u"}catch{return!1}}try{if(ai(e,!1))return!!t(e)||t(J(e))}catch{}return!1}function di(e){var t;return null==(t=e?.proposer)?void 0:t.publicKey}function ui(e){return e?.topic}function gi(e,t){let s=null;return ai(e?.publicKey,!1)||(s=si("MISSING_OR_INVALID",`${t} controller public key should be a string`)),s}function fi(e){let t=!0;return ri(e)?e.length&&(t=e.every(e=>ai(e,!1))):t=!1,t}function mi(e,t){let s=null;return Object.values(e).forEach(e=>{if(s)return;const i=function(e,t){let s=null;return fi(e?.methods)?fi(e?.events)||(s=ii("UNSUPPORTED_EVENTS",`${t}, events should be an array of strings or empty array for no events`)):s=ii("UNSUPPORTED_METHODS",`${t}, methods should be an array of strings or empty array for no methods`),s}(e,`${t}, namespace`);i&&(s=i)}),s}function wi(e,t,s){let i=null;if(e&&ni(e)){const r=mi(e,t);r&&(i=r);const n=function(e,t,s){let i=null;return Object.entries(e).forEach(([e,r])=>{if(i)return;const n=function(e,t,s){let i=null;return ri(t)&&t.length?t.forEach(e=>{i||li(e)||(i=ii("UNSUPPORTED_CHAINS",`${s}, chain ${e} should be a string and conform to "namespace:chainId" format`))}):li(e)||(i=ii("UNSUPPORTED_CHAINS",`${s}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}(e,w(e,r),`${t} ${s}`);n&&(i=n)}),i}(e,t,s);n&&(i=n)}else i=si("MISSING_OR_INVALID",`${t}, ${s} should be an object with data`);return i}function yi(e,t){let s=null;if(e&&ni(e)){const i=mi(e,t);i&&(s=i);const r=function(e,t){let s=null;return Object.values(e).forEach(e=>{if(s)return;const i=function(e,t){let s=null;return ri(e)?e.forEach(e=>{s||function(e){if(ai(e,!1)&&e.includes(":")){const t=e.split(":");if(3===t.length){const e=t[0]+":"+t[1];return!!t[2]&&li(e)}}return!1}(e)||(s=ii("UNSUPPORTED_ACCOUNTS",`${t}, account ${e} should be a string and conform to "namespace:chainId:address" format`))}):s=ii("UNSUPPORTED_ACCOUNTS",`${t}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),s}(e?.accounts,`${t} namespace`);i&&(s=i)}),s}(e,t);r&&(s=r)}else s=si("MISSING_OR_INVALID",`${t}, namespaces should be an object with data`);return s}function bi(e){return ai(e.protocol,!0)}function vi(e,t){let s=!1;return t&&!e?s=!0:e&&ri(e)&&e.length&&e.forEach(e=>{s=bi(e)}),s}function Ei(e){return"number"==typeof e}function Ii(e){return typeof e<"u"&&null!==typeof e}function _i(e){return!!(e&&"object"==typeof e&&e.code&&ci(e.code,!1)&&e.message&&ai(e.message,!1))}function Ni(e){return!(oi(e)||!ai(e.method,!1))}function Ai(e){return!(oi(e)||oi(e.result)&&oi(e.error)||!ci(e.id,!1)||!ai(e.jsonrpc,!1))}function Ci(e){return!(oi(e)||!ai(e.name,!1))}function Pi(e,t){return!(!li(t)||!function(e){const t=[];return Object.values(e).forEach(e=>{t.push(...Ys(e.accounts))}),t}(e).includes(t))}function Si(e,t,s){return!!ai(s,!1)&&function(e,t){const s=[];return Object.values(e).forEach(e=>{Ys(e.accounts).includes(t)&&s.push(...e.methods)}),s}(e,t).includes(s)}function Oi(e,t,s){return!!ai(s,!1)&&function(e,t){const s=[];return Object.values(e).forEach(e=>{Ys(e.accounts).includes(t)&&s.push(...e.events)}),s}(e,t).includes(s)}function Ti(e,t,s){let i=null;const r=function(e){const t={};return Object.keys(e).forEach(s=>{var i;s.includes(":")?t[s]=e[s]:null==(i=e[s].chains)||i.forEach(i=>{t[i]={methods:e[s].methods,events:e[s].events}})}),t}(e),n=function(e){const t={};return Object.keys(e).forEach(s=>{if(s.includes(":"))t[s]=e[s];else{const i=Ys(e[s].accounts);i?.forEach(i=>{t[i]={accounts:e[s].accounts.filter(e=>e.includes(`${i}:`)),methods:e[s].methods,events:e[s].events}})}}),t}(t),o=Object.keys(r),a=Object.keys(n),c=ki(Object.keys(e)),h=ki(Object.keys(t)),l=c.filter(e=>!h.includes(e));return l.length&&(i=si("NON_CONFORMING_NAMESPACES",`${s} namespaces keys don't satisfy requiredNamespaces.\n Required: ${l.toString()}\n Received: ${Object.keys(t).toString()}`)),k(o,a)||(i=si("NON_CONFORMING_NAMESPACES",`${s} namespaces chains don't satisfy required namespaces.\n Required: ${o.toString()}\n Approved: ${a.toString()}`)),Object.keys(t).forEach(e=>{if(!e.includes(":")||i)return;const r=Ys(t[e].accounts);r.includes(e)||(i=si("NON_CONFORMING_NAMESPACES",`${s} namespaces accounts don't satisfy namespace accounts for ${e}\n Required: ${e}\n Approved: ${r.toString()}`))}),o.forEach(e=>{i||(k(r[e].methods,n[e].methods)?k(r[e].events,n[e].events)||(i=si("NON_CONFORMING_NAMESPACES",`${s} namespaces events don't satisfy namespace events for ${e}`)):i=si("NON_CONFORMING_NAMESPACES",`${s} namespaces methods don't satisfy namespace methods for ${e}`))}),i}function ki(e){return[...new Set(e.map(e=>e.includes(":")?e.split(":")[0]:e))]}function xi(e,t){return ci(e,!1)&&e<=t.max&&e>=t.min}function Ri(){const e=C();return new Promise(t=>{switch(e){case b.browser:t(A()&&navigator?.onLine);break;case b.reactNative:t(async function(){if(I()&&typeof s.g<"u"&&null!=s.g&&s.g.NetInfo){const e=await(null==s.g?void 0:s.g.NetInfo.fetch());return e?.isConnected}return!0}());break;case b.node:default:t(!0)}})}function Ui(e){switch(C()){case b.browser:!function(e){!I()&&A()&&(window.addEventListener("online",()=>e(!0)),window.addEventListener("offline",()=>e(!1)))}(e);break;case b.reactNative:!function(e){I()&&typeof s.g<"u"&&null!=s.g&&s.g.NetInfo&&s.g?.NetInfo.addEventListener(t=>e(t?.isConnected))}(e);case b.node:}}const Di={};class ji{static get(e){return Di[e]}static set(e,t){Di[e]=t}static delete(e){delete Di[e]}}},78760:(e,t,s)=>{s.d(t,{p:()=>r});const i=2147483648,r={convertEVMChainIdToCoinType(e){if(e>=i)throw new Error("Invalid chainId");return(i|e)>>>0}}},79473:(e,t,s)=>{s.d(t,{A:()=>a});var i=s(89168),r=s(39150);const n={eip155:void 0,solana:void 0,polkadot:void 0,bip122:void 0},o=(0,i.BX)({providers:{...n},providerIds:{...n}}),a={state:o,subscribeKey:(e,t)=>(0,r.u$)(o,e,t),subscribe:e=>(0,i.B1)(o,()=>{e(o)}),subscribeProviders:e=>(0,i.B1)(o.providers,()=>e(o.providers)),setProvider(e,t){t&&(o.providers[e]=(0,i.KR)(t))},getProvider:e=>o.providers[e],setProviderId(e,t){t&&(o.providerIds[e]=t)},getProviderId(e){if(e)return o.providerIds[e]},reset(){o.providers={...n},o.providerIds={...n}},resetChain(e){o.providers[e]=void 0,o.providerIds[e]=void 0}}},84253:(e,t,s)=>{s.d(t,{oU:()=>n});var i=s(39907);const r=(void 0!==i&&void 0!==i.env?i.env.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",n={FOUR_MINUTES_MS:24e4,TEN_SEC_MS:1e4,FIVE_SEC_MS:5e3,THREE_SEC_MS:3e3,ONE_SEC_MS:1e3,SECURE_SITE:r,SECURE_SITE_DASHBOARD:`${r}/dashboard`,SECURE_SITE_FAVICON:`${r}/images/favicon.png`,RESTRICTED_TIMEZONES:["ASIA/SHANGHAI","ASIA/URUMQI","ASIA/CHONGQING","ASIA/HARBIN","ASIA/KASHGAR","ASIA/MACAU","ASIA/HONG_KONG","ASIA/MACAO","ASIA/BEIJING","ASIA/HARBIN"],WC_COINBASE_PAY_SDK_CHAINS:["ethereum","arbitrum","polygon","berachain","avalanche-c-chain","optimism","celo","base"],WC_COINBASE_PAY_SDK_FALLBACK_CHAIN:"ethereum",WC_COINBASE_PAY_SDK_CHAIN_NAME_MAP:{Ethereum:"ethereum","Arbitrum One":"arbitrum",Polygon:"polygon",Berachain:"berachain",Avalanche:"avalanche-c-chain","OP Mainnet":"optimism",Celo:"celo",Base:"base"},WC_COINBASE_ONRAMP_APP_ID:"bf18c88d-495a-463b-b249-0b9d3656cf5e",SWAP_SUGGESTED_TOKENS:["ETH","UNI","1INCH","AAVE","SOL","ADA","AVAX","DOT","LINK","NITRO","GAIA","MILK","TRX","NEAR","GNO","WBTC","DAI","WETH","USDC","USDT","ARB","BAL","BICO","CRV","ENS","MATIC","OP"],SWAP_POPULAR_TOKENS:["ETH","UNI","1INCH","AAVE","SOL","ADA","AVAX","DOT","LINK","NITRO","GAIA","MILK","TRX","NEAR","GNO","WBTC","DAI","WETH","USDC","USDT","ARB","BAL","BICO","CRV","ENS","MATIC","OP","METAL","DAI","CHAMP","WOLF","SALE","BAL","BUSD","MUST","BTCpx","ROUTE","HEX","WELT","amDAI","VSQ","VISION","AURUM","pSP","SNX","VC","LINK","CHP","amUSDT","SPHERE","FOX","GIDDY","GFC","OMEN","OX_OLD","DE","WNT"],BALANCE_SUPPORTED_CHAINS:["eip155","solana"],SWAP_SUPPORTED_NETWORKS:["eip155:1","eip155:42161","eip155:10","eip155:324","eip155:8453","eip155:56","eip155:137","eip155:100","eip155:43114","eip155:250","eip155:8217","eip155:1313161554"],NAMES_SUPPORTED_CHAIN_NAMESPACES:["eip155"],ONRAMP_SUPPORTED_CHAIN_NAMESPACES:["eip155","solana"],ACTIVITY_ENABLED_CHAIN_NAMESPACES:["eip155","solana"],NATIVE_TOKEN_ADDRESS:{eip155:"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",solana:"So11111111111111111111111111111111111111111",polkadot:"0x",bip122:"0x"},CONVERT_SLIPPAGE_TOLERANCE:1,CONNECT_LABELS:{MOBILE:"Open and continue in a new browser tab"},DEFAULT_FEATURES:{swaps:!0,onramp:!0,receive:!0,send:!0,email:!0,emailShowWallets:!0,socials:["google","x","discord","farcaster","github","apple","facebook"],connectorTypeOrder:["walletConnect","recent","injected","featured","custom","external","recommended"],history:!0,analytics:!0,allWallets:!0,legalCheckbox:!1,smartSessions:!1,collapseWallets:!1,walletFeaturesOrder:["onramp","swaps","receive","send"],connectMethodsOrder:void 0},DEFAULT_ACCOUNT_TYPES:{bip122:"payment",eip155:"smartAccount",polkadot:"eoa",solana:"eoa"},ADAPTER_TYPES:{UNIVERSAL:"universal",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5",BITCOIN:"bitcoin"}}},84320:(e,t,s)=>{s.d(t,{r:()=>i});class i extends Error{constructor(){super(),Object.setPrototypeOf(this,i.prototype)}}},85445:(e,t,s)=>{s.d(t,{K:()=>i});class i extends Error{constructor(){super("QR Code Modal was closed by user"),Object.setPrototypeOf(this,i.prototype),this.name="QRCodeModalError"}}},86808:(e,t,s)=>{s.d(t,{kl:()=>i.k}),s(24529);var i=s(69033)},87201:(e,t,s)=>{s.d(t,{WalletConnectWalletAdapter:()=>h});var i=s(80110),r=s(53834),n=s(68559),o=s(13324),a=s(96759),c=s(66715);class h extends n.Kl{name="WalletConnect";url="https://walletconnect.org";icon="data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjE4NSIgdmlld0JveD0iMCAwIDMwMCAxODUiIHdpZHRoPSIzMDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0ibTYxLjQzODU0MjkgMzYuMjU2MjYxMmM0OC45MTEyMjQxLTQ3Ljg4ODE2NjMgMTI4LjIxMTk4NzEtNDcuODg4MTY2MyAxNzcuMTIzMjA5MSAwbDUuODg2NTQ1IDUuNzYzNDE3NGMyLjQ0NTU2MSAyLjM5NDQwODEgMi40NDU1NjEgNi4yNzY1MTEyIDAgOC42NzA5MjA0bC0yMC4xMzY2OTUgMTkuNzE1NTAzYy0xLjIyMjc4MSAxLjE5NzIwNTEtMy4yMDUzIDEuMTk3MjA1MS00LjQyODA4MSAwbC04LjEwMDU4NC03LjkzMTE0NzljLTM0LjEyMTY5Mi0zMy40MDc5ODE3LTg5LjQ0Mzg4Ni0zMy40MDc5ODE3LTEyMy41NjU1Nzg4IDBsLTguNjc1MDU2MiA4LjQ5MzYwNTFjLTEuMjIyNzgxNiAxLjE5NzIwNDEtMy4yMDUzMDEgMS4xOTcyMDQxLTQuNDI4MDgwNiAwbC0yMC4xMzY2OTQ5LTE5LjcxNTUwMzFjLTIuNDQ1NTYxMi0yLjM5NDQwOTItMi40NDU1NjEyLTYuMjc2NTEyMiAwLTguNjcwOTIwNHptMjE4Ljc2Nzc5NjEgNDAuNzczNzQ0OSAxNy45MjE2OTcgMTcuNTQ2ODk3YzIuNDQ1NTQ5IDIuMzk0Mzk2OSAyLjQ0NTU2MyA2LjI3NjQ3NjkuMDAwMDMxIDguNjcwODg5OWwtODAuODEwMTcxIDc5LjEyMTEzNGMtMi40NDU1NDQgMi4zOTQ0MjYtNi40MTA1ODIgMi4zOTQ0NTMtOC44NTYxNi4wMDAwNjItLjAwMDAxLS4wMDAwMS0uMDAwMDIyLS4wMDAwMjItLjAwMDAzMi0uMDAwMDMybC01Ny4zNTQxNDMtNTYuMTU0NTcyYy0uNjExMzktLjU5ODYwMi0xLjYwMjY1LS41OTg2MDItMi4yMTQwNCAwLS4wMDAwMDQuMDAwMDA0LS4wMDAwMDcuMDAwMDA4LS4wMDAwMTEuMDAwMDExbC01Ny4zNTI5MjEyIDU2LjE1NDUzMWMtMi40NDU1MzY4IDIuMzk0NDMyLTYuNDEwNTc1NSAyLjM5NDQ3Mi04Ljg1NjE2MTIuMDAwMDg3LS4wMDAwMTQzLS4wMDAwMTQtLjAwMDAyOTYtLjAwMDAyOC0uMDAwMDQ0OS0uMDAwMDQ0bC04MC44MTI0MTk0My03OS4xMjIxODVjLTIuNDQ1NTYwMjEtMi4zOTQ0MDgtMi40NDU1NjAyMS02LjI3NjUxMTUgMC04LjY3MDkxOTdsMTcuOTIxNzI5NjMtMTcuNTQ2ODY3M2MyLjQ0NTU2MDItMi4zOTQ0MDgyIDYuNDEwNTk4OS0yLjM5NDQwODIgOC44NTYxNjAyIDBsNTcuMzU0OTc3NSA1Ni4xNTUzNTdjLjYxMTM5MDguNTk4NjAyIDEuNjAyNjQ5LjU5ODYwMiAyLjIxNDAzOTggMCAuMDAwMDA5Mi0uMDAwMDA5LjAwMDAxNzQtLjAwMDAxNy4wMDAwMjY1LS4wMDAwMjRsNTcuMzUyMTAzMS01Ni4xNTUzMzNjMi40NDU1MDUtMi4zOTQ0NjMzIDYuNDEwNTQ0LTIuMzk0NTUzMSA4Ljg1NjE2MS0uMDAwMi4wMDAwMzQuMDAwMDMzNi4wMDAwNjguMDAwMDY3My4wMDAxMDEuMDAwMTAxbDU3LjM1NDkwMiA1Ni4xNTU0MzJjLjYxMTM5LjU5ODYwMSAxLjYwMjY1LjU5ODYwMSAyLjIxNDA0IDBsNTcuMzUzOTc1LTU2LjE1NDMyNDljMi40NDU1NjEtMi4zOTQ0MDkyIDYuNDEwNTk5LTIuMzk0NDA5MiA4Ljg1NjE2IDB6IiBmaWxsPSIjM2I5OWZjIi8+PC9zdmc+";supportedTransactionVersions=new Set(["legacy",0]);_publicKey;_connecting;_wallet;_config;_readyState;_onDisconnect;constructor(e){super(),this._publicKey=null,this._connecting=!1,this._config=e,this._wallet=null,this._readyState="undefined"==typeof window?i.Ok.Unsupported:i.Ok.Loadable,this._onDisconnect=this.disconnect.bind(this)}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get readyState(){return this._readyState}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==i.Ok.Loadable)throw new r.AE;this._connecting=!0,this._wallet=new c.f({network:this._config.network===o.B.Mainnet?a.aj.Mainnet:a.aj.Devnet,options:this._config.options});const{publicKey:e}=await this._wallet.connect();this._publicKey=e,this.emit("connect",e),this._wallet.client.on("session_delete",this._onDisconnect)}catch(e){if("QRCodeModalError"===e.constructor.name||e instanceof Error&&"QRCodeModalError"===e.name)throw new r.KL;throw this._connecting=!1,e}finally{this._connecting=!1}}async disconnect(){const e=this._wallet;if(e){e.client.off("session_delete",this._onDisconnect),this._publicKey=null;try{e.client.session&&await e.disconnect()}catch(e){console.error("WalletConnectWalletAdapter: disconnect error",e),this.emit("error",new r.Y8(e?.message,e))}}this.emit("disconnect")}async signTransaction(e){try{const t=this._wallet;if(!t)throw new r.kW;try{return await t.signTransaction(e)}catch(e){throw new r.z4(e?.message,e)}}catch(e){throw this.emit("error",e),e}}async signMessage(e){try{const t=this._wallet;if(!t)throw new r.kW;try{return await t.signMessage(e)}catch(e){throw new r.K3(e?.message,e)}}catch(e){throw this.emit("error",e),e}}async signAndSendTransaction(e){try{const t=this._wallet;if(!t)throw new r.kW;try{return await t.signAndSendTransaction(e)}catch(e){throw new r.z4(e?.message,e)}}catch(e){throw this.emit("error",e),e}}async signAllTransactions(e){try{const t=this._wallet;if(!t)throw new r.kW;try{return await t.signAllTransactions(e)}catch(e){throw new r.z4(e?.message,e)}}catch(e){throw this.emit("error",e),e}}}},87841:(e,t,s)=>{s.d(t,{g:()=>o});var i=s(95191),r=s(99013),n=s(93927);function o(e){const t=Array.from(r.W.state.chains.keys());let s=[];return e?(s.push([e,r.W.state.chains.get(e)]),(0,n.Q)(e,i.o.CONNECTOR_ID.WALLET_CONNECT)?t.forEach(t=>{t!==e&&(0,n.Q)(t,i.o.CONNECTOR_ID.WALLET_CONNECT)&&s.push([t,r.W.state.chains.get(t)])}):(0,n.Q)(e,i.o.CONNECTOR_ID.AUTH)&&t.forEach(t=>{t!==e&&(0,n.Q)(t,i.o.CONNECTOR_ID.AUTH)&&s.push([t,r.W.state.chains.get(t)])})):s=Array.from(r.W.state.chains.entries()),s}},88315:(e,t,s)=>{s.d(t,{_:()=>h});var i=s(89058),r=s(50731),n=s(16158),o=s(5813),a=s(41977);let c=!1;class h extends a._{async open(e){r.a.isConnected()||await super.open(e)}async close(){await super.close(),this.options.manualWCControl&&i.x.finalizeWcConnection()}async syncIdentity(e){return Promise.resolve()}async syncBalance(e){return Promise.resolve()}async injectModalUi(){if(!c&&o.w.isClient()){if(await Promise.all([s.e(6484),s.e(4194),s.e(4379)]).then(s.bind(s,34379)),await Promise.all([s.e(4194),s.e(5972)]).then(s.bind(s,45972)),!document.querySelector("w3m-modal")){const e=document.createElement("w3m-modal");n.H.state.disableAppend||n.H.state.enableEmbedded||document.body.insertAdjacentElement("beforeend",e)}c=!0}}}},89058:(e,t,s)=>{s.d(t,{x:()=>m});var i=s(89168),r=s(39150),n=s(5813),o=s(24537),a=s(11553),c=s(99013),h=s(50731),l=s(14479),p=s(67018),d=s(42831),u=s(52059);const g=(0,i.BX)({wcError:!1,buffering:!1,status:"disconnected"});let f;const m={state:g,subscribeKey:(e,t)=>(0,r.u$)(g,e,t),_getClient:()=>g._client,setClient(e){g._client=(0,i.KR)(e)},async connectWalletConnect(){if(n.w.isTelegram()||n.w.isSafari()&&n.w.isIos()){if(f)return await f,void(f=void 0);if(!n.w.isPairingExpired(g?.wcPairingExpiry)){const e=g.wcUri;return void(g.wcUri=e)}f=this._getClient()?.connectWalletConnect?.().catch(()=>{}),this.state.status="connecting",await f,f=void 0,g.wcPairingExpiry=void 0,this.state.status="connected"}else await(this._getClient()?.connectWalletConnect?.())},async connectExternal(e,t,s=!0){await(this._getClient()?.connectExternal?.(e)),s&&c.W.setActiveNamespace(t)},async reconnectExternal(e){await(this._getClient()?.reconnectExternal?.(e));const t=e.chain||c.W.state.activeChain;t&&h.a.setConnectorId(e.id,t)},async setPreferredAccountType(e){p.W.setLoading(!0,c.W.state.activeChain);const t=h.a.getAuthConnector();t&&(await(t?.provider.setPreferredAccount(e)),await this.reconnectExternal(t),p.W.setLoading(!1,c.W.state.activeChain),l.E.sendEvent({type:"track",event:"SET_PREFERRED_ACCOUNT_TYPE",properties:{accountType:e,network:c.W.state.activeCaipNetwork?.caipNetworkId||""}}))},async signMessage(e){return this._getClient()?.signMessage(e)},parseUnits(e,t){return this._getClient()?.parseUnits(e,t)},formatUnits(e,t){return this._getClient()?.formatUnits(e,t)},async sendTransaction(e){return this._getClient()?.sendTransaction(e)},async getCapabilities(e){return this._getClient()?.getCapabilities(e)},async grantPermissions(e){return this._getClient()?.grantPermissions(e)},async walletGetAssets(e){return this._getClient()?.walletGetAssets(e)??{}},async estimateGas(e){return this._getClient()?.estimateGas(e)},async writeContract(e){return this._getClient()?.writeContract(e)},async getEnsAddress(e){return this._getClient()?.getEnsAddress(e)},async getEnsAvatar(e){return this._getClient()?.getEnsAvatar(e)},checkInstalled(e){return this._getClient()?.checkInstalled?.(e)||!1},resetWcConnection(){g.wcUri=void 0,g.wcPairingExpiry=void 0,g.wcLinking=void 0,g.recentWallet=void 0,g.status="disconnected",u.W.resetTransactions(),a.i.deleteWalletConnectDeepLink()},resetUri(){g.wcUri=void 0,g.wcPairingExpiry=void 0},finalizeWcConnection(){const{wcLinking:e,recentWallet:t}=m.state;e&&a.i.setWalletConnectDeepLink(e),t&&a.i.setAppKitRecent(t),l.E.sendEvent({type:"track",event:"CONNECT_SUCCESS",properties:{method:e?"mobile":"qrcode",name:d.I.state.data?.wallet?.name||"Unknown"}})},setWcBasic(e){g.wcBasic=e},setUri(e){g.wcUri=e,g.wcPairingExpiry=n.w.getPairingExpiry()},setWcLinking(e){g.wcLinking=e},setWcError(e){g.wcError=e,g.buffering=!1},setRecentWallet(e){g.recentWallet=e},setBuffering(e){g.buffering=e},setStatus(e){g.status=e},async disconnect(e){try{p.W.setLoading(!0,e),await o.U.clearSessions(),await c.W.disconnect(e),p.W.setLoading(!1,e),h.a.setFilterByNamespace(void 0)}catch(e){throw new Error("Failed to disconnect")}}}},89351:(e,t,s)=>{s.d(t,{hJ:()=>n,lC:()=>o});var i=s(96759);const r={mainnet:`You are using a deprecated chain ID for Solana Mainnet, please use ${i.ac.Mainnet} instead.`,devnet:`You are using a deprecated chain ID for Solana Devnet, please use ${i.ac.Devnet} instead.`,wallet:"The connected wallet is using a deprecated chain ID for Solana. Please, contact them to upgrade. You can learn more at https://github.com/ChainAgnostic/namespaces/blob/main/solana/caip10.md#chain-ids"};function n(e,t){const s=e.namespaces.solana?.accounts.map(e=>`solana:${e.split(":")[1]}`);if(t===i.ac.Mainnet)return s?.find(e=>e===i.ac.Mainnet)?i.ac.Mainnet:(console.warn(r.wallet),i.ac.Deprecated_Mainnet);if(t===i.ac.Devnet)return s?.find(e=>e===i.ac.Devnet)?i.ac.Devnet:(console.warn(r.wallet),i.ac.Deprecated_Devnet);throw Error("WalletConnect Solana Adapter: Unable to get a default chain from the session.")}function o(e){const t=function(e){let t=[e];return e===i.ac.Mainnet||e===i.ac.Deprecated_Mainnet?(t=[i.ac.Mainnet,i.ac.Deprecated_Mainnet],e===i.ac.Deprecated_Mainnet&&console.warn(r.mainnet)):e!==i.ac.Deprecated_Devnet&&e!==i.ac.Devnet||(t=[i.ac.Devnet,i.ac.Deprecated_Devnet],i.ac.Deprecated_Devnet&&console.warn(r.devnet)),t}(e);return{optionalNamespaces:{solana:{chains:t,methods:[i.jD.signTransaction,i.jD.signMessage],events:[]}}}}},91310:(e,t,s)=>{s.d(t,{D:()=>n});var i=s(84253),r=s(5813);const n={getFeatureValue(e,t){const s=t?.[e];return void 0===s?i.oU.DEFAULT_FEATURES[e]:s},filterSocialsByPlatform(e){if(!e||!e.length)return e;if(r.w.isTelegram()){if(r.w.isIos())return e.filter(e=>"google"!==e);if(r.w.isMac())return e.filter(e=>"x"!==e);if(r.w.isAndroid())return e.filter(e=>!["facebook","x"].includes(e))}return e}}},93224:(e,t,s)=>{s.d(t,{$:()=>c});var i=s(89168),r=s(40868),n=s(12472);const o={eip155:"ba0ba0cd-17c6-4806-ad93-f9d174f17900",solana:"a1b58899-f671-4276-6a5e-56ca5bd59700",polkadot:"",bip122:"0b4838db-0161-4ffe-022d-532bf03dba00"},a=(0,i.BX)({networkImagePromises:{}}),c={async fetchWalletImage(e){if(e)return await r.N._fetchWalletImage(e),this.getWalletImageById(e)},async fetchNetworkImage(e){if(!e)return;return this.getNetworkImageById(e)||(a.networkImagePromises[e]||(a.networkImagePromises[e]=r.N._fetchNetworkImage(e)),await a.networkImagePromises[e],this.getNetworkImageById(e))},getWalletImageById(e){if(e)return n.j.state.walletImages[e]},getWalletImage:e=>e?.image_url?e?.image_url:e?.image_id?n.j.state.walletImages[e.image_id]:void 0,getNetworkImage:e=>e?.assets?.imageUrl?e?.assets?.imageUrl:e?.assets?.imageId?n.j.state.networkImages[e.assets.imageId]:void 0,getNetworkImageById(e){if(e)return n.j.state.networkImages[e]},getConnectorImage:e=>e?.imageUrl?e.imageUrl:e?.imageId?n.j.state.connectorImages[e.imageId]:void 0,getChainImage:e=>n.j.state.networkImages[o[e]]}},93927:(e,t,s)=>{s.d(t,{Q:()=>r});var i=s(50731);function r(e,t){return i.a.getConnectorId(e)===t}},94768:(e,t,s)=>{s.d(t,{EM:()=>n.E,JX:()=>i.JX,RF:()=>i.RF,Zv:()=>r.Z,ds:()=>i.ds}),s(51493);var i=s(24210),r=s(63789),n=(s(72931),s(27305))},95191:(e,t,s)=>{s.d(t,{o:()=>i});const i={WC_NAME_SUFFIX:".reown.id",WC_NAME_SUFFIX_LEGACY:".wcn.id",BLOCKCHAIN_API_RPC_URL:"https://rpc.walletconnect.org",PULSE_API_URL:"https://pulse.walletconnect.org",W3M_API_URL:"https://api.web3modal.org",CONNECTOR_ID:{WALLET_CONNECT:"walletConnect",INJECTED:"injected",WALLET_STANDARD:"announced",COINBASE:"coinbaseWallet",COINBASE_SDK:"coinbaseWalletSDK",SAFE:"safe",LEDGER:"ledger",OKX:"okx",EIP6963:"eip6963",AUTH:"ID_AUTH"},CONNECTOR_NAMES:{AUTH:"Auth"},AUTH_CONNECTOR_SUPPORTED_CHAINS:["eip155","solana"],LIMITS:{PENDING_TRANSACTIONS:99},CHAIN:{EVM:"eip155",SOLANA:"solana",POLKADOT:"polkadot",BITCOIN:"bip122"},CHAIN_NAME_MAP:{eip155:"EVM Networks",solana:"Solana",polkadot:"Polkadot",bip122:"Bitcoin"},ADAPTER_TYPES:{BITCOIN:"bitcoin",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5"},USDT_CONTRACT_ADDRESSES:["0xdac17f958d2ee523a2206206994597c13d831ec7","0xc2132d05d31c914a87c6611c10748aeb04b58e8f","0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7","0x919C1c267BC06a7039e03fcc2eF738525769109c","0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e","0x55d398326f99059fF775485246999027B3197955","0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"],HTTP_STATUS_CODES:{SERVICE_UNAVAILABLE:503,FORBIDDEN:403},UNSUPPORTED_NETWORK_NAME:"Unknown Network"}},95642:(e,t,s)=>{var i=s(40149);(0,i.x)({id:"000000000019d6689c085ae165831e93",caipNetworkId:"bip122:000000000019d6689c085ae165831e93",chainNamespace:"bip122",name:"Bitcoin",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}}}),(0,i.x)({id:"000000000933ea01ad0ee984209779ba",caipNetworkId:"bip122:000000000933ea01ad0ee984209779ba",chainNamespace:"bip122",name:"Bitcoin Testnet",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},testnet:!0})},96759:(e,t,s)=>{var i,r;s.d(t,{ac:()=>n,aj:()=>i,jD:()=>r}),function(e){e.Mainnet="solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",e.Devnet="solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",e.Deprecated_Mainnet="solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ",e.Deprecated_Devnet="solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"}(i||(i={})),function(e){e.signTransaction="solana_signTransaction",e.signMessage="solana_signMessage",e.signAndSendTransaction="solana_signAndSendTransaction",e.signAndSendAllTransactions="solana_signAndSendAllTransactions",e.signAllTransactions="solana_signAllTransactions"}(r||(r={}));const n={Mainnet:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",Devnet:"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",Deprecated_Mainnet:"solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ",Deprecated_Devnet:"solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"}},98207:(e,t,s)=>{s.d(t,{o:()=>i});const i={METMASK_CONNECTOR_NAME:"MetaMask",TRUST_CONNECTOR_NAME:"Trust Wallet",SOLFLARE_CONNECTOR_NAME:"Solflare",PHANTOM_CONNECTOR_NAME:"Phantom",COIN98_CONNECTOR_NAME:"Coin98",MAGIC_EDEN_CONNECTOR_NAME:"Magic Eden",BACKPACK_CONNECTOR_NAME:"Backpack",BITGET_CONNECTOR_NAME:"Bitget Wallet",FRONTIER_CONNECTOR_NAME:"Frontier",XVERSE_CONNECTOR_NAME:"Xverse Wallet",LEATHER_CONNECTOR_NAME:"Leather",EIP155:"eip155",ADD_CHAIN_METHOD:"wallet_addEthereumChain",EIP6963_ANNOUNCE_EVENT:"eip6963:announceProvider",EIP6963_REQUEST_EVENT:"eip6963:requestProvider",CONNECTOR_RDNS_MAP:{coinbaseWallet:"com.coinbase.wallet",coinbaseWalletSDK:"com.coinbase.wallet"},CONNECTOR_TYPE_EXTERNAL:"EXTERNAL",CONNECTOR_TYPE_WALLET_CONNECT:"WALLET_CONNECT",CONNECTOR_TYPE_INJECTED:"INJECTED",CONNECTOR_TYPE_ANNOUNCED:"ANNOUNCED",CONNECTOR_TYPE_AUTH:"AUTH",CONNECTOR_TYPE_MULTI_CHAIN:"MULTI_CHAIN",CONNECTOR_TYPE_W3M_AUTH:"ID_AUTH"}},98752:(e,t,s)=>{s.d(t,{$I:()=>Y,$w:()=>G,Jf:()=>P,S$:()=>J,Tn:()=>Z,U:()=>Q,U$:()=>X,WB:()=>V,cV:()=>R,iJ:()=>hi,il:()=>ks,sD:()=>A,wn:()=>W,zN:()=>q});var i=s(50046),r=s.n(i),n=s(37147),o=s(81030),a=s(70255),c=s(21910),h=s(91315),l=s(25607),p=s(97353),d=s(48851),u=s(1030),g=s(93786),f=s(14350),m=s(63342),w=s(20635),y=s(48526).hp;const b="core",v=`wc@2:${b}:`,E={database:":memory:"},I="client_ed25519_seed",_=h.ONE_DAY,N=h.SIX_HOURS,A="irn",C="wss://relay.walletconnect.org",P={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"},S="payload",O="connect",T="disconnect",k="error",x="2.19.1",R={link_mode:"link_mode",relay:"relay"},U="inbound",D="WALLETCONNECT_LINK_MODE_APPS",j="subscription_created",M="subscription_deleted",L=(h.FIVE_SECONDS,{wc_pairingDelete:{req:{ttl:h.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:h.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:h.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:h.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:h.ONE_DAY,prompt:!1,tag:0},res:{ttl:h.ONE_DAY,prompt:!1,tag:0}}}),q={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},$="history_created",B="history_updated",H="history_deleted",W={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},z="https://verify.walletconnect.org",V=z,F=`${V}/v3`,K=["https://verify.walletconnect.com",z],G={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"},J={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"},Y={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"},Q={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"},X={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"},Z={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"};const ee=e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")};class te{constructor(e,t,s){this.name=e,this.prefix=t,this.baseEncode=s}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class se{constructor(e,t,s){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=s}decode(e){if("string"==typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return re(this,e)}}class ie{constructor(e){this.decoders=e}or(e){return re(this,e)}decode(e){const t=e[0],s=this.decoders[t];if(s)return s.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const re=(e,t)=>new ie({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class ne{constructor(e,t,s,i){this.name=e,this.prefix=t,this.baseEncode=s,this.baseDecode=i,this.encoder=new te(e,t,s),this.decoder=new se(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const oe=({name:e,prefix:t,encode:s,decode:i})=>new ne(e,t,s,i),ae=({prefix:e,name:t,alphabet:s})=>{const{encode:i,decode:r}=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var s=new Uint8Array(256),i=0;i<s.length;i++)s[i]=255;for(var r=0;r<e.length;r++){var n=e.charAt(r),o=n.charCodeAt(0);if(255!==s[o])throw new TypeError(n+" is ambiguous");s[o]=r}var a=e.length,c=e.charAt(0),h=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function p(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var i=0,r=0;e[t]===c;)i++,t++;for(var n=(e.length-t)*h+1>>>0,o=new Uint8Array(n);e[t];){var l=s[e.charCodeAt(t)];if(255===l)return;for(var p=0,d=n-1;(0!==l||p<r)&&-1!==d;d--,p++)l+=a*o[d]>>>0,o[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");r=p,t++}if(" "!==e[t]){for(var u=n-r;u!==n&&0===o[u];)u++;for(var g=new Uint8Array(i+(n-u)),f=i;u!==n;)g[f++]=o[u++];return g}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var s=0,i=0,r=0,n=t.length;r!==n&&0===t[r];)r++,s++;for(var o=(n-r)*l+1>>>0,h=new Uint8Array(o);r!==n;){for(var p=t[r],d=0,u=o-1;(0!==p||d<i)&&-1!==u;u--,d++)p+=256*h[u]>>>0,h[u]=p%a>>>0,p=p/a>>>0;if(0!==p)throw new Error("Non-zero carry");i=d,r++}for(var g=o-i;g!==o&&0===h[g];)g++;for(var f=c.repeat(s);g<o;++g)f+=e.charAt(h[g]);return f},decodeUnsafe:p,decode:function(e){var s=p(e);if(s)return s;throw new Error(`Non-${t} character`)}}}(s,t);return oe({prefix:e,name:t,encode:i,decode:e=>ee(r(e))})},ce=({name:e,prefix:t,bitsPerChar:s,alphabet:i})=>oe({prefix:t,name:e,encode:e=>((e,t,s)=>{const i="="===t[t.length-1],r=(1<<s)-1;let n="",o=0,a=0;for(let i=0;i<e.length;++i)for(a=a<<8|e[i],o+=8;o>s;)o-=s,n+=t[r&a>>o];if(o&&(n+=t[r&a<<s-o]),i)for(;n.length*s&7;)n+="=";return n})(e,i,s),decode:t=>((e,t,s,i)=>{const r={};for(let e=0;e<t.length;++e)r[t[e]]=e;let n=e.length;for(;"="===e[n-1];)--n;const o=new Uint8Array(n*s/8|0);let a=0,c=0,h=0;for(let t=0;t<n;++t){const n=r[e[t]];if(void 0===n)throw new SyntaxError(`Non-${i} character`);c=c<<s|n,a+=s,a>=8&&(a-=8,o[h++]=255&c>>a)}if(a>=s||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o})(t,i,s,e)}),he=oe({prefix:"\0",name:"identity",encode:e=>(e=>(new TextDecoder).decode(e))(e),decode:e=>(e=>(new TextEncoder).encode(e))(e)});var le=Object.freeze({__proto__:null,identity:he});const pe=ce({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var de=Object.freeze({__proto__:null,base2:pe});const ue=ce({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ge=Object.freeze({__proto__:null,base8:ue});const fe=ae({prefix:"9",name:"base10",alphabet:"0123456789"});var me=Object.freeze({__proto__:null,base10:fe});const we=ce({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ye=ce({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var be=Object.freeze({__proto__:null,base16:we,base16upper:ye});const ve=ce({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ee=ce({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ie=ce({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),_e=ce({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ne=ce({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ae=ce({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ce=ce({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Pe=ce({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Se=ce({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Oe=Object.freeze({__proto__:null,base32:ve,base32upper:Ee,base32pad:Ie,base32padupper:_e,base32hex:Ne,base32hexupper:Ae,base32hexpad:Ce,base32hexpadupper:Pe,base32z:Se});const Te=ae({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ke=ae({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var xe=Object.freeze({__proto__:null,base36:Te,base36upper:ke});const Re=ae({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ue=ae({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var De=Object.freeze({__proto__:null,base58btc:Re,base58flickr:Ue});const je=ce({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Me=ce({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Le=ce({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),qe=ce({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var $e=Object.freeze({__proto__:null,base64:je,base64pad:Me,base64url:Le,base64urlpad:qe});const Be=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),He=Be.reduce((e,t,s)=>(e[s]=t,e),[]),We=Be.reduce((e,t,s)=>(e[t.codePointAt(0)]=s,e),[]),ze=oe({prefix:"🚀",name:"base256emoji",encode:function(e){return e.reduce((e,t)=>e+He[t],"")},decode:function(e){const t=[];for(const s of e){const e=We[s.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${s}`);t.push(e)}return new Uint8Array(t)}});var Ve=Object.freeze({__proto__:null,base256emoji:ze}),Fe=128,Ke=-128,Ge=Math.pow(2,31),Je=Math.pow(2,7),Ye=Math.pow(2,14),Qe=Math.pow(2,21),Xe=Math.pow(2,28),Ze=Math.pow(2,35),et=Math.pow(2,42),tt=Math.pow(2,49),st=Math.pow(2,56),it=Math.pow(2,63),rt=function e(t,s,i){s=s||[];for(var r=i=i||0;t>=Ge;)s[i++]=255&t|Fe,t/=128;for(;t&Ke;)s[i++]=255&t|Fe,t>>>=7;return s[i]=0|t,e.bytes=i-r+1,s},nt=function(e){return e<Je?1:e<Ye?2:e<Qe?3:e<Xe?4:e<Ze?5:e<et?6:e<tt?7:e<st?8:e<it?9:10};const ot=(e,t,s=0)=>(rt(e,t,s),t),at=e=>nt(e),ct=(e,t)=>{const s=t.byteLength,i=at(e),r=i+at(s),n=new Uint8Array(r+s);return ot(e,n,0),ot(s,n,i),n.set(t,r),new ht(e,s,t,n)};class ht{constructor(e,t,s,i){this.code=e,this.size=t,this.digest=s,this.bytes=i}}const lt=({name:e,code:t,encode:s})=>new pt(e,t,s);class pt{constructor(e,t,s){this.name=e,this.code=t,this.encode=s}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?ct(this.code,t):t.then(e=>ct(this.code,e))}throw Error("Unknown type, must be binary type")}}const dt=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),ut=lt({name:"sha2-256",code:18,encode:dt("SHA-256")}),gt=lt({name:"sha2-512",code:19,encode:dt("SHA-512")});Object.freeze({__proto__:null,sha256:ut,sha512:gt});const ft=ee,mt={code:0,name:"identity",encode:ft,digest:e=>ct(0,ft(e))};Object.freeze({__proto__:null,identity:mt}),new TextEncoder,new TextDecoder;const wt={...le,...de,...ge,...me,...be,...Oe,...xe,...De,...$e,...Ve};function yt(e,t,s,i){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:s},decoder:{decode:i}}}const bt=yt("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>(new TextEncoder).encode(e.substring(1))),vt=yt("ascii","a",e=>{let t="a";for(let s=0;s<e.length;s++)t+=String.fromCharCode(e[s]);return t},e=>{const t=function(e=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?globalThis.Buffer.allocUnsafe(e):new Uint8Array(e)}((e=e.substring(1)).length);for(let s=0;s<e.length;s++)t[s]=e.charCodeAt(s);return t}),Et={utf8:bt,"utf-8":bt,hex:wt.base16,latin1:vt,ascii:vt,binary:vt,...wt};var It=Object.defineProperty,_t=(e,t,s)=>((e,t,s)=>t in e?It(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Nt{constructor(e,t){this.core=e,this.logger=t,_t(this,"keychain",new Map),_t(this,"name","keychain"),_t(this,"version","0.3"),_t(this,"initialized",!1),_t(this,"storagePrefix",v),_t(this,"init",async()=>{if(!this.initialized){const e=await this.getKeyChain();typeof e<"u"&&(this.keychain=e),this.initialized=!0}}),_t(this,"has",e=>(this.isInitialized(),this.keychain.has(e))),_t(this,"set",async(e,t)=>{this.isInitialized(),this.keychain.set(e,t),await this.persist()}),_t(this,"get",e=>{this.isInitialized();const t=this.keychain.get(e);if(typeof t>"u"){const{message:t}=(0,d.GuA)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}),_t(this,"del",async e=>{this.isInitialized(),this.keychain.delete(e),await this.persist()}),this.core=e,this.logger=(0,a.U5)(t,this.name)}get context(){return(0,a.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,(0,d.h0Y)(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?(0,d.PUk)(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var At=Object.defineProperty,Ct=(e,t,s)=>((e,t,s)=>t in e?At(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Pt{constructor(e,t,s){this.core=e,this.logger=t,Ct(this,"name","crypto"),Ct(this,"keychain"),Ct(this,"randomSessionIdentifier",(0,d.two)()),Ct(this,"initialized",!1),Ct(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)}),Ct(this,"hasKeys",e=>(this.isInitialized(),this.keychain.has(e))),Ct(this,"getClientId",async()=>{this.isInitialized();const e=await this.getClientSeed(),t=p.TZ(e);return p.UF(t.publicKey)}),Ct(this,"generateKeyPair",()=>{this.isInitialized();const e=(0,d.TZl)();return this.setPrivateKey(e.publicKey,e.privateKey)}),Ct(this,"signJWT",async e=>{this.isInitialized();const t=await this.getClientSeed(),s=p.TZ(t),i=this.randomSessionIdentifier,r=_;return await p.FA(i,e,r,s)}),Ct(this,"generateSharedKey",(e,t,s)=>{this.isInitialized();const i=this.getPrivateKey(e),r=(0,d.ovp)(i,t);return this.setSymKey(r,s)}),Ct(this,"setSymKey",async(e,t)=>{this.isInitialized();const s=t||(0,d.EN$)(e);return await this.keychain.set(s,e),s}),Ct(this,"deleteKeyPair",async e=>{this.isInitialized(),await this.keychain.del(e)}),Ct(this,"deleteSymKey",async e=>{this.isInitialized(),await this.keychain.del(e)}),Ct(this,"encode",async(e,t,s)=>{this.isInitialized();const i=(0,d.AwN)(s),r=(0,l.h)(t);if((0,d.ps1)(i))return(0,d.Tw2)(r,s?.encoding);if((0,d.V7m)(i)){const t=i.senderPublicKey,s=i.receiverPublicKey;e=await this.generateSharedKey(t,s)}const n=this.getSymKey(e),{type:o,senderPublicKey:a}=i;return(0,d.wa2)({type:o,symKey:n,message:r,senderPublicKey:a,encoding:s?.encoding})}),Ct(this,"decode",async(e,t,s)=>{this.isInitialized();const i=(0,d.C5G)(t,s);if((0,d.ps1)(i)){const e=(0,d.F$L)(t,s?.encoding);return(0,l.j)(e)}if((0,d.V7m)(i)){const t=i.receiverPublicKey,s=i.senderPublicKey;e=await this.generateSharedKey(t,s)}try{const i=this.getSymKey(e),r=(0,d.YcA)({symKey:i,encoded:t,encoding:s?.encoding});return(0,l.j)(r)}catch(t){this.logger.error(`Failed to decode message from topic: '${e}', clientId: '${await this.getClientId()}'`),this.logger.error(t)}}),Ct(this,"getPayloadType",(e,t=d.EWt)=>{const s=(0,d.iui)({encoded:e,encoding:t});return(0,d.x0t)(s.type)}),Ct(this,"getPayloadSenderPublicKey",(e,t=d.EWt)=>{const s=(0,d.iui)({encoded:e,encoding:t});return s.senderPublicKey?(0,u.dI)(s.senderPublicKey,d.bEt):void 0}),this.core=e,this.logger=(0,a.U5)(t,this.name),this.keychain=s||new Nt(this.core,this.logger)}get context(){return(0,a.oI)(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(I)}catch{e=(0,d.two)(),await this.keychain.set(I,e)}return function(e,t="utf8"){const s=Et[t];if(!s)throw new Error(`Unsupported encoding "${t}"`);return"utf8"!==t&&"utf-8"!==t||null==globalThis.Buffer||null==globalThis.Buffer.from?s.decoder.decode(`${s.prefix}${e}`):globalThis.Buffer.from(e,"utf8")}(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var St=Object.defineProperty,Ot=Object.defineProperties,Tt=Object.getOwnPropertyDescriptors,kt=Object.getOwnPropertySymbols,xt=Object.prototype.hasOwnProperty,Rt=Object.prototype.propertyIsEnumerable,Ut=(e,t,s)=>t in e?St(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Dt=(e,t,s)=>Ut(e,"symbol"!=typeof t?t+"":t,s);class jt extends c.dQ{constructor(e,t){super(e,t),this.logger=e,this.core=t,Dt(this,"messages",new Map),Dt(this,"messagesWithoutClientAck",new Map),Dt(this,"name","messages"),Dt(this,"version","0.3"),Dt(this,"initialized",!1),Dt(this,"storagePrefix",v),Dt(this,"init",async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const e=await this.getRelayerMessages();typeof e<"u"&&(this.messages=e);const t=await this.getRelayerMessagesWithoutClientAck();typeof t<"u"&&(this.messagesWithoutClientAck=t),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}finally{this.initialized=!0}}}),Dt(this,"set",async(e,t,s)=>{this.isInitialized();const i=(0,d.ALl)(t);let r=this.messages.get(e);if(typeof r>"u"&&(r={}),typeof r[i]<"u")return i;if(r[i]=t,this.messages.set(e,r),s===U){const s=this.messagesWithoutClientAck.get(e)||{};this.messagesWithoutClientAck.set(e,((e,t)=>Ot(e,Tt(t)))(((e,t)=>{for(var s in t||(t={}))xt.call(t,s)&&Ut(e,s,t[s]);if(kt)for(var s of kt(t))Rt.call(t,s)&&Ut(e,s,t[s]);return e})({},s),{[i]:t}))}return await this.persist(),i}),Dt(this,"get",e=>{this.isInitialized();let t=this.messages.get(e);return typeof t>"u"&&(t={}),t}),Dt(this,"getWithoutAck",e=>{this.isInitialized();const t={};for(const s of e){const e=this.messagesWithoutClientAck.get(s)||{};t[s]=Object.values(e)}return t}),Dt(this,"has",(e,t)=>(this.isInitialized(),typeof this.get(e)[(0,d.ALl)(t)]<"u")),Dt(this,"ack",async(e,t)=>{this.isInitialized();const s=this.messagesWithoutClientAck.get(e);typeof s>"u"||(delete s[(0,d.ALl)(t)],0===Object.keys(s).length?this.messagesWithoutClientAck.delete(e):this.messagesWithoutClientAck.set(e,s),await this.persist())}),Dt(this,"del",async e=>{this.isInitialized(),this.messages.delete(e),this.messagesWithoutClientAck.delete(e),await this.persist()}),this.logger=(0,a.U5)(e,this.name),this.core=t}get context(){return(0,a.oI)(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,(0,d.h0Y)(e))}async setRelayerMessagesWithoutClientAck(e){await this.core.storage.setItem(this.storageKeyWithoutClientAck,(0,d.h0Y)(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?(0,d.PUk)(e):void 0}async getRelayerMessagesWithoutClientAck(){const e=await this.core.storage.getItem(this.storageKeyWithoutClientAck);return typeof e<"u"?(0,d.PUk)(e):void 0}async persist(){await this.setRelayerMessages(this.messages),await this.setRelayerMessagesWithoutClientAck(this.messagesWithoutClientAck)}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Mt=Object.defineProperty,Lt=Object.defineProperties,qt=Object.getOwnPropertyDescriptors,$t=Object.getOwnPropertySymbols,Bt=Object.prototype.hasOwnProperty,Ht=Object.prototype.propertyIsEnumerable,Wt=(e,t,s)=>t in e?Mt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,zt=(e,t)=>{for(var s in t||(t={}))Bt.call(t,s)&&Wt(e,s,t[s]);if($t)for(var s of $t(t))Ht.call(t,s)&&Wt(e,s,t[s]);return e},Vt=(e,t)=>Lt(e,qt(t)),Ft=(e,t,s)=>Wt(e,"symbol"!=typeof t?t+"":t,s);class Kt extends c.qE{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,Ft(this,"events",new i.EventEmitter),Ft(this,"name","publisher"),Ft(this,"queue",new Map),Ft(this,"publishTimeout",(0,h.toMiliseconds)(h.ONE_MINUTE)),Ft(this,"initialPublishTimeout",(0,h.toMiliseconds)(15*h.ONE_SECOND)),Ft(this,"needsTransportRestart",!1),Ft(this,"publish",async(e,t,s)=>{var i;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:e,message:t,opts:s}});const r=s?.ttl||N,n=(0,d.n6V)(s),o=s?.prompt||!1,a=s?.tag||0,c=s?.id||(0,f.getBigIntRpcId)().toString(),h={topic:e,message:t,opts:{ttl:r,relay:n,prompt:o,tag:a,id:c,attestation:s?.attestation,tvf:s?.tvf}},l=`Failed to publish payload, please try again. id:${c} tag:${a}`;try{const i=new Promise(async i=>{const n=({id:e})=>{h.opts.id===e&&(this.removeRequestFromQueue(e),this.relayer.events.removeListener(P.publish,n),i(h))};this.relayer.events.on(P.publish,n);const l=(0,d.K3g)(new Promise((i,n)=>{this.rpcPublish({topic:e,message:t,ttl:r,prompt:o,tag:a,id:c,attestation:s?.attestation,tvf:s?.tvf}).then(i).catch(e=>{this.logger.warn(e,e?.message),n(e)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${c} tag:${a}`);try{await l,this.events.removeListener(P.publish,n)}catch(e){this.queue.set(c,Vt(zt({},h),{attempt:1})),this.logger.warn(e,e?.message)}});this.logger.trace({type:"method",method:"publish",params:{id:c,topic:e,message:t,opts:s}}),await(0,d.K3g)(i,this.publishTimeout,l)}catch(e){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(e),null!=(i=s?.internal)&&i.throwOnFailedPublish)throw e}finally{this.queue.delete(c)}}),Ft(this,"on",(e,t)=>{this.events.on(e,t)}),Ft(this,"once",(e,t)=>{this.events.once(e,t)}),Ft(this,"off",(e,t)=>{this.events.off(e,t)}),Ft(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.relayer=e,this.logger=(0,a.U5)(t,this.name),this.registerEventListeners()}get context(){return(0,a.oI)(this.logger)}async rpcPublish(e){var t,s,i,r;const{topic:n,message:o,ttl:a=N,prompt:c,tag:h,id:l,attestation:p,tvf:u}=e,g={method:(0,d.aa1)((0,d.n6V)().protocol).publish,params:zt({topic:n,message:o,ttl:a,prompt:c,tag:h,attestation:p},u),id:l};(0,d.b07)(null==(t=g.params)?void 0:t.prompt)&&(null==(s=g.params)||delete s.prompt),(0,d.b07)(null==(i=g.params)?void 0:i.tag)&&(null==(r=g.params)||delete r.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:g});const f=await this.relayer.request(g);return this.relayer.events.emit(P.publish,e),this.logger.debug("Successfully Published Payload"),f}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,t)=>{const s=e.attempt+1;this.queue.set(t,Vt(zt({},e),{attempt:s}));const{topic:i,message:r,opts:n,attestation:o}=e;this.logger.warn({},`Publisher: queue->publishing: ${e.opts.id}, tag: ${e.opts.tag}, attempt: ${s}`),await this.rpcPublish(Vt(zt({},e),{topic:i,message:r,ttl:n.ttl,prompt:n.prompt,tag:n.tag,id:n.id,attestation:o,tvf:n.tvf})),this.logger.warn({},`Publisher: queue->published: ${e.opts.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(n.li.pulse,()=>{if(this.needsTransportRestart)return this.needsTransportRestart=!1,void this.relayer.events.emit(P.connection_stalled);this.checkQueue()}),this.relayer.on(P.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}var Gt=Object.defineProperty,Jt=(e,t,s)=>((e,t,s)=>t in e?Gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Yt{constructor(){Jt(this,"map",new Map),Jt(this,"set",(e,t)=>{const s=this.get(e);this.exists(e,t)||this.map.set(e,[...s,t])}),Jt(this,"get",e=>this.map.get(e)||[]),Jt(this,"exists",(e,t)=>this.get(e).includes(t)),Jt(this,"delete",(e,t)=>{if(typeof t>"u")return void this.map.delete(e);if(!this.map.has(e))return;const s=this.get(e);if(!this.exists(e,t))return;const i=s.filter(e=>e!==t);i.length?this.map.set(e,i):this.map.delete(e)}),Jt(this,"clear",()=>{this.map.clear()})}get topics(){return Array.from(this.map.keys())}}var Qt=Object.defineProperty,Xt=Object.defineProperties,Zt=Object.getOwnPropertyDescriptors,es=Object.getOwnPropertySymbols,ts=Object.prototype.hasOwnProperty,ss=Object.prototype.propertyIsEnumerable,is=(e,t,s)=>t in e?Qt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,rs=(e,t)=>{for(var s in t||(t={}))ts.call(t,s)&&is(e,s,t[s]);if(es)for(var s of es(t))ss.call(t,s)&&is(e,s,t[s]);return e},ns=(e,t)=>Xt(e,Zt(t)),os=(e,t,s)=>is(e,"symbol"!=typeof t?t+"":t,s);class as extends c.mF{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,os(this,"subscriptions",new Map),os(this,"topicMap",new Yt),os(this,"events",new i.EventEmitter),os(this,"name","subscription"),os(this,"version","0.3"),os(this,"pending",new Map),os(this,"cached",[]),os(this,"initialized",!1),os(this,"storagePrefix",v),os(this,"subscribeTimeout",(0,h.toMiliseconds)(h.ONE_MINUTE)),os(this,"initialSubscribeTimeout",(0,h.toMiliseconds)(15*h.ONE_SECOND)),os(this,"clientId"),os(this,"batchSubscribeTopicsLimit",500),os(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0}),os(this,"subscribe",async(e,t)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}});try{const s=(0,d.n6V)(t),i={topic:e,relay:s,transportType:t?.transportType};this.pending.set(e,i);const r=await this.rpcSubscribe(e,s,t);return"string"==typeof r&&(this.onSubscribe(r,i),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}})),r}catch(e){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(e),e}}),os(this,"unsubscribe",async(e,t)=>{this.isInitialized(),typeof t?.id<"u"?await this.unsubscribeById(e,t.id,t):await this.unsubscribeByTopic(e,t)}),os(this,"isSubscribed",e=>new Promise(t=>{t(this.topicMap.topics.includes(e))})),os(this,"isKnownTopic",e=>new Promise(t=>{t(this.topicMap.topics.includes(e)||this.pending.has(e)||this.cached.some(t=>t.topic===e))})),os(this,"on",(e,t)=>{this.events.on(e,t)}),os(this,"once",(e,t)=>{this.events.once(e,t)}),os(this,"off",(e,t)=>{this.events.off(e,t)}),os(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),os(this,"start",async()=>{await this.onConnect()}),os(this,"stop",async()=>{await this.onDisconnect()}),os(this,"restart",async()=>{await this.restore(),await this.onRestart()}),os(this,"checkPending",async()=>{if(!(0!==this.pending.size||this.initialized&&this.relayer.connected))return;const e=[];this.pending.forEach(t=>{e.push(t)}),await this.batchSubscribe(e)}),os(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(n.li.pulse,async()=>{await this.checkPending()}),this.events.on(j,async e=>{const t=j;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}),this.events.on(M,async e=>{const t=M;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})}),this.relayer=e,this.logger=(0,a.U5)(t,this.name),this.clientId=""}get context(){return(0,a.oI)(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,t){let s=!1;try{s=this.getSubscription(e).topic===t}catch{}return s}reset(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){const s=this.topicMap.get(e);await Promise.all(s.map(async s=>await this.unsubscribeById(e,s,t)))}async unsubscribeById(e,t,s){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:s}});try{const i=(0,d.n6V)(s);await this.restartToComplete({topic:e,id:t,relay:i}),await this.rpcUnsubscribe(e,t,i);const r=(0,d.Hjj)("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,r),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:s}})}catch(e){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(e),e}}async rpcSubscribe(e,t,s){var i;(!s||s?.transportType===R.relay)&&await this.restartToComplete({topic:e,id:e,relay:t});const r={method:(0,d.aa1)(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r});const n=null==(i=s?.internal)?void 0:i.throwOnFailedPublish;try{const t=await this.getSubscriptionId(e);if(s?.transportType===R.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(r).catch(e=>this.logger.warn(e))},(0,h.toMiliseconds)(h.ONE_SECOND)),t;const i=new Promise(async t=>{const s=i=>{i.topic===e&&(this.events.removeListener(j,s),t(i.id))};this.events.on(j,s);try{const i=await(0,d.K3g)(new Promise((e,t)=>{this.relayer.request(r).catch(e=>{this.logger.warn(e,e?.message),t(e)}).then(e)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(j,s),t(i)}catch{}}),o=await(0,d.K3g)(i,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!o&&n)throw new Error(`Subscribing to ${e} failed, please try again`);return o?t:null}catch(e){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(P.connection_stalled),n)throw e}return null}async rpcBatchSubscribe(e){if(!e.length)return;const t=e[0].relay,s={method:(0,d.aa1)(t.protocol).batchSubscribe,params:{topics:e.map(e=>e.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});try{await await(0,d.K3g)(new Promise(e=>{this.relayer.request(s).catch(e=>this.logger.warn(e)).then(e)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(P.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const t=e[0].relay,s={method:(0,d.aa1)(t.protocol).batchFetchMessages,params:{topics:e.map(e=>e.topic)}};let i;this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});try{i=await await(0,d.K3g)(new Promise((e,t)=>{this.relayer.request(s).catch(e=>{this.logger.warn(e),t(e)}).then(e)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(P.connection_stalled)}return i}rpcUnsubscribe(e,t,s){const i={method:(0,d.aa1)(s.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i}),this.relayer.request(i)}onSubscribe(e,t){this.setSubscription(e,ns(rs({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(e=>{this.setSubscription(e.id,rs({},e)),this.pending.delete(e.topic)})}async onUnsubscribe(e,t,s){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,s),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t)}addSubscription(e,t){this.subscriptions.set(e,rs({},t)),this.topicMap.set(t.topic,e),this.events.emit(j,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const{message:t}=(0,d.GuA)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const s=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(s.topic,e),this.events.emit(M,ns(rs({},s),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit("subscription_sync")}async onRestart(){if(this.cached.length){const e=[...this.cached],t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let s=0;s<t;s++){const t=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(t)}}this.events.emit("subscription_resubscribed")}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:e}=(0,d.GuA)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(e)}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 e=>ns(rs({},e),{id:await this.getSubscriptionId(e.topic)})))))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(await(0,d.yy4)((0,h.toMiliseconds)(h.ONE_SECOND)),await this.relayer.handleBatchMessageEvents(t.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("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(0,d.ALl)(e+await this.getClientId())}}var cs=Object.defineProperty,hs=Object.getOwnPropertySymbols,ls=Object.prototype.hasOwnProperty,ps=Object.prototype.propertyIsEnumerable,ds=(e,t,s)=>t in e?cs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,us=(e,t)=>{for(var s in t||(t={}))ls.call(t,s)&&ds(e,s,t[s]);if(hs)for(var s of hs(t))ps.call(t,s)&&ds(e,s,t[s]);return e},gs=(e,t,s)=>ds(e,"symbol"!=typeof t?t+"":t,s);class fs extends c.m5{constructor(e){super(e),gs(this,"protocol","wc"),gs(this,"version",2),gs(this,"core"),gs(this,"logger"),gs(this,"events",new i.EventEmitter),gs(this,"provider"),gs(this,"messages"),gs(this,"subscriber"),gs(this,"publisher"),gs(this,"name","relayer"),gs(this,"transportExplicitlyClosed",!1),gs(this,"initialized",!1),gs(this,"connectionAttemptInProgress",!1),gs(this,"relayUrl"),gs(this,"projectId"),gs(this,"packageName"),gs(this,"bundleId"),gs(this,"hasExperiencedNetworkDisruption",!1),gs(this,"pingTimeout"),gs(this,"heartBeatTimeout",(0,h.toMiliseconds)(h.THIRTY_SECONDS+h.FIVE_SECONDS)),gs(this,"reconnectTimeout"),gs(this,"connectPromise"),gs(this,"reconnectInProgress",!1),gs(this,"requestsInFlight",[]),gs(this,"connectTimeout",(0,h.toMiliseconds)(15*h.ONE_SECOND)),gs(this,"request",async e=>{var t,s;this.logger.debug("Publishing Request Payload");const i=e.id||(0,f.getBigIntRpcId)().toString();await this.toEstablishConnection();try{this.logger.trace({id:i,method:e.method,topic:null==(t=e.params)?void 0:t.topic},"relayer.request - publishing...");const r=`${i}:${(null==(s=e.params)?void 0:s.tag)||""}`;this.requestsInFlight.push(r);const n=await this.provider.request(e);return this.requestsInFlight=this.requestsInFlight.filter(e=>e!==r),n}catch(e){throw this.logger.debug(`Failed to Publish Request: ${i}`),e}}),gs(this,"resetPingTimeout",()=>{(0,d.Lln)()&&(clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var e,t,s,i;try{this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),null==(i=null==(s=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:s.terminate)||i.call(s)}catch(e){this.logger.warn(e,e?.message)}},this.heartBeatTimeout))}),gs(this,"onPayloadHandler",e=>{this.onProviderPayload(e),this.resetPingTimeout()}),gs(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected 🛜"),this.startPingTimeout(),this.events.emit(P.connect)}),gs(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected 🛑"),this.requestsInFlight=[],this.onProviderDisconnect()}),gs(this,"onProviderErrorHandler",e=>{this.logger.fatal(`Fatal socket error: ${e.message}`),this.events.emit(P.error,e),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()}),gs(this,"registerProviderListeners",()=>{this.provider.on(S,this.onPayloadHandler),this.provider.on(O,this.onConnectHandler),this.provider.on(T,this.onDisconnectHandler),this.provider.on(k,this.onProviderErrorHandler)}),this.core=e.core,this.logger=typeof e.logger<"u"&&"string"!=typeof e.logger?(0,a.U5)(e.logger,this.name):(0,a.h6)((0,a.iP)({level:e.logger||"error"})),this.messages=new jt(this.logger,e.core),this.subscriber=new as(this,this.logger),this.publisher=new Kt(this,this.logger),this.relayUrl=e?.relayUrl||C,this.projectId=e.projectId,(0,d.m01)()?this.packageName=(0,d.R7U)():(0,d.aRZ)()&&(this.bundleId=(0,d.R7U)()),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.hasAnyTopics)try{await this.transportOpen()}catch(e){this.logger.warn(e,e?.message)}}get context(){return(0,a.oI)(this.logger)}get connected(){var e,t,s;return 1===(null==(s=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:s.readyState)||!1}get connecting(){var e,t,s;return 0===(null==(s=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:s.readyState)||void 0!==this.connectPromise||!1}async publish(e,t,s){this.isInitialized(),await this.publisher.publish(e,t,s),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:R.relay},"outbound")}async subscribe(e,t){var s,i,r;this.isInitialized(),(null==t||!t.transportType||"relay"===t?.transportType)&&await this.toEstablishConnection();const n=typeof(null==(s=t?.internal)?void 0:s.throwOnFailedPublish)>"u"||(null==(i=t?.internal)?void 0:i.throwOnFailedPublish);let o,a=(null==(r=this.subscriber.topicMap.get(e))?void 0:r[0])||"";const c=t=>{t.topic===e&&(this.subscriber.off(j,c),o())};return await Promise.all([new Promise(e=>{o=e,this.subscriber.on(j,c)}),new Promise(async(s,i)=>{a=await this.subscriber.subscribe(e,us({internal:{throwOnFailedPublish:n}},t)).catch(e=>{n&&i(e)})||a,s()})]),a}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await(0,d.K3g)(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){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(t,s)=>{await this.connect(e).then(t).catch(s).finally(()=>{this.connectPromise=void 0})}),await this.connectPromise),!this.connected)throw new Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}else this.logger.warn("Starting WS connection skipped because the client has no topics to work with.")}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(0,d.sc7)())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(0===e?.length)return void this.logger.trace("Batch message events is empty. Ignoring...");const t=e.sort((e,t)=>e.publishedAt-t.publishedAt);this.logger.debug(`Batch of ${t.length} message events sorted`);for(const e of t)try{await this.onMessageEvent(e)}catch(e){this.logger.warn(e,"Error while processing batch message event: "+e?.message)}this.logger.trace(`Batch of ${t.length} message events processed`)}async onLinkMessageEvent(e,t){const{topic:s}=e;if(!t.sessionExists){const e={topic:s,expiry:(0,d.Xw0)(h.FIVE_MINUTES),relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(s,e)}this.events.emit(P.message,e),await this.recordMessageEvent(e,U)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let t=1;for(;t<6;){try{if(this.transportExplicitlyClosed)break;this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${t}...`),await this.createProvider(),await new Promise(async(e,t)=>{const s=()=>{t(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(T,s),await(0,d.K3g)(new Promise((e,t)=>{this.provider.connect().then(e).catch(t)}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(e=>{t(e)}).finally(()=>{this.provider.off(T,s),clearTimeout(this.reconnectTimeout)}),await new Promise(async(e,t)=>{const s=()=>{t(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(T,s),await this.subscriber.start().then(e).catch(t).finally(()=>{this.provider.off(T,s)})}),this.hasExperiencedNetworkDisruption=!1,e()})}catch(e){await this.subscriber.stop();const t=e;this.logger.warn({},t.message),this.hasExperiencedNetworkDisruption=!0}finally{this.connectionAttemptInProgress=!1}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${t}`);break}await new Promise(e=>setTimeout(e,(0,h.toMiliseconds)(1*t))),t++}}startPingTimeout(){var e,t,s,i,r;if((0,d.Lln)())try{null!=(t=null==(e=this.provider)?void 0:e.connection)&&t.socket&&(null==(r=null==(i=null==(s=this.provider)?void 0:s.connection)?void 0:i.socket)||r.on("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(e){this.logger.warn(e,e?.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new g.F(new m.A((0,d.jUZ)({sdkVersion:x,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,t){const{topic:s,message:i}=e;await this.messages.set(s,i,t)}async shouldIgnoreMessageEvent(e){const{topic:t,message:s}=e;if(!s||0===s.length)return this.logger.warn(`Ignoring invalid/empty message: ${s}`),!0;if(!await this.subscriber.isKnownTopic(t))return this.logger.warn(`Ignoring message for unknown topic ${t}`),!0;const i=this.messages.has(t,s);return i&&this.logger.warn(`Ignoring duplicate message: ${s}`),i}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),(0,f.isJsonRpcRequest)(e)){if(!e.method.endsWith("_subscription"))return;const t=e.params,{topic:s,message:i,publishedAt:r,attestation:n}=t.data,o={topic:s,message:i,publishedAt:r,transportType:R.relay,attestation:n};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(us({type:"event",event:t.id},o)),this.events.emit(t.id,o),await this.acknowledgePayload(e),await this.onMessageEvent(o)}else(0,f.isJsonRpcResponse)(e)&&this.events.emit(P.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(await this.recordMessageEvent(e,U),this.events.emit(P.message,e))}async acknowledgePayload(e){const t=(0,f.formatJsonRpcResult)(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(S,this.onPayloadHandler),this.provider.off(O,this.onConnectHandler),this.provider.off(T,this.onDisconnectHandler),this.provider.off(k,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await(0,d.sc7)();(0,d.uym)(async t=>{e!==t&&(e=t,t?await this.transportOpen().catch(e=>this.logger.error(e,e?.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){clearTimeout(this.pingTimeout),this.events.emit(P.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?.message)),this.reconnectTimeout=void 0,this.reconnectInProgress=!1},(0,h.toMiliseconds)(.1)))))}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&await this.connect()}}function ms(){}function ws(e){if(!e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&"[object Object]"===Object.prototype.toString.call(e)}function ys(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}function bs(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const vs="[object Arguments]",Es="[object Object]";function Is(e,t,s,i,r,n,o){const a=o(e,t,s,i,r,n);if(void 0!==a)return a;if(typeof e==typeof t)switch(typeof e){case"bigint":case"string":case"boolean":case"symbol":case"undefined":case"function":return e===t;case"number":return e===t||Object.is(e,t);case"object":return _s(e,t,n,o)}return _s(e,t,n,o)}function _s(e,t,s,i){if(Object.is(e,t))return!0;let r=bs(e),n=bs(t);if(r===vs&&(r=Es),n===vs&&(n=Es),r!==n)return!1;switch(r){case"[object String]":return e.toString()===t.toString();case"[object Number]":return function(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}(e.valueOf(),t.valueOf());case"[object Boolean]":case"[object Date]":case"[object Symbol]":return Object.is(e.valueOf(),t.valueOf());case"[object RegExp]":return e.source===t.source&&e.flags===t.flags;case"[object Function]":return e===t}const o=(s=s??new Map).get(e),a=s.get(t);if(null!=o&&null!=a)return o===t;s.set(e,t),s.set(t,e);try{switch(r){case"[object Map]":if(e.size!==t.size)return!1;for(const[r,n]of e.entries())if(!t.has(r)||!Is(n,t.get(r),r,e,t,s,i))return!1;return!0;case"[object Set]":{if(e.size!==t.size)return!1;const r=Array.from(e.values()),n=Array.from(t.values());for(let o=0;o<r.length;o++){const a=r[o],c=n.findIndex(r=>Is(a,r,void 0,e,t,s,i));if(-1===c)return!1;n.splice(c,1)}return!0}case"[object Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":case"[object BigUint64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object BigInt64Array]":case"[object Float32Array]":case"[object Float64Array]":if(typeof y<"u"&&y.isBuffer(e)!==y.isBuffer(t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Is(e[r],t[r],r,e,t,s,i))return!1;return!0;case"[object ArrayBuffer]":return e.byteLength===t.byteLength&&_s(new Uint8Array(e),new Uint8Array(t),s,i);case"[object DataView]":return e.byteLength===t.byteLength&&e.byteOffset===t.byteOffset&&_s(new Uint8Array(e),new Uint8Array(t),s,i);case"[object Error]":return e.name===t.name&&e.message===t.message;case Es:{if(!(_s(e.constructor,t.constructor,s,i)||ws(e)&&ws(t)))return!1;const r=[...Object.keys(e),...ys(e)],n=[...Object.keys(t),...ys(t)];if(r.length!==n.length)return!1;for(let n=0;n<r.length;n++){const o=r[n],a=e[o];if(!Object.hasOwn(t,o))return!1;if(!Is(a,t[o],o,e,t,s,i))return!1}return!0}default:return!1}}finally{s.delete(e),s.delete(t)}}var Ns=Object.defineProperty,As=Object.getOwnPropertySymbols,Cs=Object.prototype.hasOwnProperty,Ps=Object.prototype.propertyIsEnumerable,Ss=(e,t,s)=>t in e?Ns(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Os=(e,t)=>{for(var s in t||(t={}))Cs.call(t,s)&&Ss(e,s,t[s]);if(As)for(var s of As(t))Ps.call(t,s)&&Ss(e,s,t[s]);return e},Ts=(e,t,s)=>Ss(e,"symbol"!=typeof t?t+"":t,s);class ks extends c.pi{constructor(e,t,s,i=v,r=void 0){super(e,t,s,i),this.core=e,this.logger=t,this.name=s,Ts(this,"map",new Map),Ts(this,"version","0.3"),Ts(this,"cached",[]),Ts(this,"initialized",!1),Ts(this,"getKey"),Ts(this,"storagePrefix",v),Ts(this,"recentlyDeleted",[]),Ts(this,"recentlyDeletedLimit",200),Ts(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(e=>{this.getKey&&null!==e&&!(0,d.b07)(e)?this.map.set(this.getKey(e),e):(0,d.CTo)(e)?this.map.set(e.id,e):(0,d.mr0)(e)&&this.map.set(e.topic,e)}),this.cached=[],this.initialized=!0)}),Ts(this,"set",async(e,t)=>{this.isInitialized(),this.map.has(e)?await this.update(e,t):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:e,value:t}),this.map.set(e,t),await this.persist())}),Ts(this,"get",e=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:e}),this.getData(e))),Ts(this,"getAll",e=>(this.isInitialized(),e?this.values.filter(t=>Object.keys(e).every(s=>function(e,t){return function(e,t,s){return Is(e,t,void 0,void 0,void 0,void 0,s)}(e,t,ms)}(t[s],e[s]))):this.values)),Ts(this,"update",async(e,t)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:e,update:t});const s=Os(Os({},this.getData(e)),t);this.map.set(e,s),await this.persist()}),Ts(this,"delete",async(e,t)=>{this.isInitialized(),this.map.has(e)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:e,reason:t}),this.map.delete(e),this.addToRecentlyDeleted(e),await this.persist())}),this.logger=(0,a.U5)(t,this.name),this.storagePrefix=i,this.getKey=r}get context(){return(0,a.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){const{message:t}=(0,d.GuA)("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(t),new Error(t)}const{message:t}=(0,d.GuA)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(t),new Error(t)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:e}=(0,d.GuA)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}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}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var xs=Object.defineProperty,Rs=(e,t,s)=>((e,t,s)=>t in e?xs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Us{constructor(e,t){this.core=e,this.logger=t,Rs(this,"name","pairing"),Rs(this,"version","0.3"),Rs(this,"events",new(r())),Rs(this,"pairings"),Rs(this,"initialized",!1),Rs(this,"storagePrefix",v),Rs(this,"ignoredPayloadTypes",[d.Lp_]),Rs(this,"registeredMethods",[]),Rs(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))}),Rs(this,"register",({methods:e})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...e])]}),Rs(this,"create",async e=>{this.isInitialized();const t=(0,d.two)(),s=await this.core.crypto.setSymKey(t),i=(0,d.Xw0)(h.FIVE_MINUTES),r={protocol:A},n={topic:s,expiry:i,relay:r,active:!1,methods:e?.methods},o=(0,d.QJh)({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:t,relay:r,expiryTimestamp:i,methods:e?.methods});return this.events.emit(q.create,n),this.core.expirer.set(s,i),await this.pairings.set(s,n),await this.core.relayer.subscribe(s,{transportType:e?.transportType}),{topic:s,uri:o}}),Rs(this,"pair",async e=>{this.isInitialized();const t=this.core.eventClient.createEvent({properties:{topic:e?.uri,trace:[G.pairing_started]}});this.isValidPair(e,t);const{topic:s,symKey:i,relay:r,expiryTimestamp:n,methods:o}=(0,d.wYp)(e.uri);let a;if(t.props.properties.topic=s,t.addTrace(G.pairing_uri_validation_success),t.addTrace(G.pairing_uri_not_expired),this.pairings.keys.includes(s)){if(a=this.pairings.get(s),t.addTrace(G.existing_pairing),a.active)throw t.setError(J.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);t.addTrace(G.pairing_not_expired)}const c=n||(0,d.Xw0)(h.FIVE_MINUTES),l={topic:s,relay:r,expiry:c,active:!1,methods:o};this.core.expirer.set(s,c),await this.pairings.set(s,l),t.addTrace(G.store_new_pairing),e.activatePairing&&await this.activate({topic:s}),this.events.emit(q.create,l),t.addTrace(G.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(i,s),t.addTrace(G.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{t.setError(J.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:r})}catch(e){throw t.setError(J.subscribe_pairing_topic_failure),e}return t.addTrace(G.subscribe_pairing_topic_success),l}),Rs(this,"activate",async({topic:e})=>{this.isInitialized();const t=(0,d.Xw0)(h.FIVE_MINUTES);this.core.expirer.set(e,t),await this.pairings.update(e,{active:!0,expiry:t})}),Rs(this,"ping",async e=>{this.isInitialized(),await this.isValidPing(e),this.logger.warn("ping() is deprecated and will be removed in the next major release.");const{topic:t}=e;if(this.pairings.keys.includes(t)){const e=await this.sendRequest(t,"wc_pairingPing",{}),{done:s,resolve:i,reject:r}=(0,d.Wx8)();this.events.once((0,d.hEn)("pairing_ping",e),({error:e})=>{e?r(e):i()}),await s()}}),Rs(this,"updateExpiry",async({topic:e,expiry:t})=>{this.isInitialized(),await this.pairings.update(e,{expiry:t})}),Rs(this,"updateMetadata",async({topic:e,metadata:t})=>{this.isInitialized(),await this.pairings.update(e,{peerMetadata:t})}),Rs(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),Rs(this,"disconnect",async e=>{this.isInitialized(),await this.isValidDisconnect(e);const{topic:t}=e;this.pairings.keys.includes(t)&&(await this.sendRequest(t,"wc_pairingDelete",(0,d.Hjj)("USER_DISCONNECTED")),await this.deletePairing(t))}),Rs(this,"formatUriFromPairing",e=>{this.isInitialized();const{topic:t,relay:s,expiry:i,methods:r}=e,n=this.core.crypto.keychain.get(t);return(0,d.QJh)({protocol:this.core.protocol,version:this.core.version,topic:t,symKey:n,relay:s,expiryTimestamp:i,methods:r})}),Rs(this,"sendRequest",async(e,t,s)=>{const i=(0,f.formatJsonRpcRequest)(t,s),r=await this.core.crypto.encode(e,i),n=L[t].req;return this.core.history.set(e,i),this.core.relayer.publish(e,r,n),i.id}),Rs(this,"sendResult",async(e,t,s)=>{const i=(0,f.formatJsonRpcResult)(e,s),r=await this.core.crypto.encode(t,i),n=(await this.core.history.get(t,e)).request.method,o=L[n].res;await this.core.relayer.publish(t,r,o),await this.core.history.resolve(i)}),Rs(this,"sendError",async(e,t,s)=>{const i=(0,f.formatJsonRpcError)(e,s),r=await this.core.crypto.encode(t,i),n=(await this.core.history.get(t,e)).request.method,o=L[n]?L[n].res:L.unregistered_method.res;await this.core.relayer.publish(t,r,o),await this.core.history.resolve(i)}),Rs(this,"deletePairing",async(e,t)=>{await this.core.relayer.unsubscribe(e),await Promise.all([this.pairings.delete(e,(0,d.Hjj)("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(e),t?Promise.resolve():this.core.expirer.del(e)])}),Rs(this,"cleanup",async()=>{const e=this.pairings.getAll().filter(e=>(0,d._dF)(e.expiry));await Promise.all(e.map(e=>this.deletePairing(e.topic)))}),Rs(this,"onRelayEventRequest",async e=>{const{topic:t,payload:s}=e;switch(s.method){case"wc_pairingPing":return await this.onPairingPingRequest(t,s);case"wc_pairingDelete":return await this.onPairingDeleteRequest(t,s);default:return await this.onUnknownRpcMethodRequest(t,s)}}),Rs(this,"onRelayEventResponse",async e=>{const{topic:t,payload:s}=e,i=(await this.core.history.get(t,s.id)).request.method;return"wc_pairingPing"===i?this.onPairingPingResponse(t,s):this.onUnknownRpcMethodResponse(i)}),Rs(this,"onPairingPingRequest",async(e,t)=>{const{id:s}=t;try{this.isValidPing({topic:e}),await this.sendResult(s,e,!0),this.events.emit(q.ping,{id:s,topic:e})}catch(t){await this.sendError(s,e,t),this.logger.error(t)}}),Rs(this,"onPairingPingResponse",(e,t)=>{const{id:s}=t;setTimeout(()=>{(0,f.isJsonRpcResult)(t)?this.events.emit((0,d.hEn)("pairing_ping",s),{}):(0,f.isJsonRpcError)(t)&&this.events.emit((0,d.hEn)("pairing_ping",s),{error:t.error})},500)}),Rs(this,"onPairingDeleteRequest",async(e,t)=>{const{id:s}=t;try{this.isValidDisconnect({topic:e}),await this.deletePairing(e),this.events.emit(q.delete,{id:s,topic:e})}catch(t){await this.sendError(s,e,t),this.logger.error(t)}}),Rs(this,"onUnknownRpcMethodRequest",async(e,t)=>{const{id:s,method:i}=t;try{if(this.registeredMethods.includes(i))return;const t=(0,d.Hjj)("WC_METHOD_UNSUPPORTED",i);await this.sendError(s,e,t),this.logger.error(t)}catch(t){await this.sendError(s,e,t),this.logger.error(t)}}),Rs(this,"onUnknownRpcMethodResponse",e=>{this.registeredMethods.includes(e)||this.logger.error((0,d.Hjj)("WC_METHOD_UNSUPPORTED",e))}),Rs(this,"isValidPair",(e,t)=>{var s;if(!(0,d.TeY)(e)){const{message:s}=(0,d.GuA)("MISSING_OR_INVALID",`pair() params: ${e}`);throw t.setError(J.malformed_pairing_uri),new Error(s)}if(!(0,d.AYU)(e.uri)){const{message:s}=(0,d.GuA)("MISSING_OR_INVALID",`pair() uri: ${e.uri}`);throw t.setError(J.malformed_pairing_uri),new Error(s)}const i=(0,d.wYp)(e?.uri);if(null==(s=i?.relay)||!s.protocol){const{message:e}=(0,d.GuA)("MISSING_OR_INVALID","pair() uri#relay-protocol");throw t.setError(J.malformed_pairing_uri),new Error(e)}if(null==i||!i.symKey){const{message:e}=(0,d.GuA)("MISSING_OR_INVALID","pair() uri#symKey");throw t.setError(J.malformed_pairing_uri),new Error(e)}if(null!=i&&i.expiryTimestamp&&(0,h.toMiliseconds)(i?.expiryTimestamp)<Date.now()){t.setError(J.pairing_expired);const{message:e}=(0,d.GuA)("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(e)}}),Rs(this,"isValidPing",async e=>{if(!(0,d.TeY)(e)){const{message:t}=(0,d.GuA)("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidPairingTopic(t)}),Rs(this,"isValidDisconnect",async e=>{if(!(0,d.TeY)(e)){const{message:t}=(0,d.GuA)("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidPairingTopic(t)}),Rs(this,"isValidPairingTopic",async e=>{if(!(0,d.Qhg)(e,!1)){const{message:t}=(0,d.GuA)("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.pairings.keys.includes(e)){const{message:t}=(0,d.GuA)("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if((0,d._dF)(this.pairings.get(e).expiry)){await this.deletePairing(e);const{message:t}=(0,d.GuA)("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}),this.core=e,this.logger=(0,a.U5)(t,this.name),this.pairings=new ks(this.core,this.logger,this.name,this.storagePrefix)}get context(){return(0,a.oI)(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(P.message,async e=>{const{topic:t,message:s,transportType:i}=e;if(this.pairings.keys.includes(t)&&i!==R.link_mode&&!this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(s)))try{const e=await this.core.crypto.decode(t,s);(0,f.isJsonRpcRequest)(e)?(this.core.history.set(t,e),await this.onRelayEventRequest({topic:t,payload:e})):(0,f.isJsonRpcResponse)(e)&&(await this.core.history.resolve(e),await this.onRelayEventResponse({topic:t,payload:e}),this.core.history.delete(t,e.id)),await this.core.relayer.messages.ack(t,s)}catch(e){this.logger.error(e)}})}registerExpirerEvents(){this.core.expirer.on(W.expired,async e=>{const{topic:t}=(0,d.c82)(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(q.expire,{topic:t}))})}}var Ds=Object.defineProperty,js=(e,t,s)=>((e,t,s)=>t in e?Ds(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Ms extends c.lZ{constructor(e,t){super(e,t),this.core=e,this.logger=t,js(this,"records",new Map),js(this,"events",new i.EventEmitter),js(this,"name","history"),js(this,"version","0.3"),js(this,"cached",[]),js(this,"initialized",!1),js(this,"storagePrefix",v),js(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(e=>this.records.set(e.id,e)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),js(this,"set",(e,t,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:e,request:t,chainId:s}),this.records.has(t.id))return;const i={id:t.id,topic:e,request:{method:t.method,params:t.params||null},chainId:s,expiry:(0,d.Xw0)(h.THIRTY_DAYS)};this.records.set(i.id,i),this.persist(),this.events.emit($,i)}),js(this,"resolve",async e=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:e}),!this.records.has(e.id))return;const t=await this.getRecord(e.id);typeof t.response>"u"&&(t.response=(0,f.isJsonRpcError)(e)?{error:e.error}:{result:e.result},this.records.set(t.id,t),this.persist(),this.events.emit(B,t))}),js(this,"get",async(e,t)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:e,id:t}),await this.getRecord(t))),js(this,"delete",(e,t)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:t}),this.values.forEach(s=>{if(s.topic===e){if(typeof t<"u"&&s.id!==t)return;this.records.delete(s.id),this.events.emit(H,s)}}),this.persist()}),js(this,"exists",async(e,t)=>(this.isInitialized(),!!this.records.has(t)&&(await this.getRecord(t)).topic===e)),js(this,"on",(e,t)=>{this.events.on(e,t)}),js(this,"once",(e,t)=>{this.events.once(e,t)}),js(this,"off",(e,t)=>{this.events.off(e,t)}),js(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.logger=(0,a.U5)(t,this.name)}get context(){return(0,a.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(t=>{if(typeof t.response<"u")return;const s={topic:t.topic,request:(0,f.formatJsonRpcRequest)(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(s)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const t=this.records.get(e);if(!t){const{message:t}=(0,d.GuA)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit("history_sync")}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:e}=(0,d.GuA)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}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($,e=>{const t=$;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(B,e=>{const t=B;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(H,e=>{const t=H;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.core.heartbeat.on(n.li.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{(0,h.toMiliseconds)(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(H,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Ls=Object.defineProperty,qs=(e,t,s)=>((e,t,s)=>t in e?Ls(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class $s extends c.Vx{constructor(e,t){super(e,t),this.core=e,this.logger=t,qs(this,"expirations",new Map),qs(this,"events",new i.EventEmitter),qs(this,"name","expirer"),qs(this,"version","0.3"),qs(this,"cached",[]),qs(this,"initialized",!1),qs(this,"storagePrefix",v),qs(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(e=>this.expirations.set(e.target,e)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),qs(this,"has",e=>{try{const t=this.formatTarget(e);return typeof this.getExpiration(t)<"u"}catch{return!1}}),qs(this,"set",(e,t)=>{this.isInitialized();const s=this.formatTarget(e),i={target:s,expiry:t};this.expirations.set(s,i),this.checkExpiry(s,i),this.events.emit(W.created,{target:s,expiration:i})}),qs(this,"get",e=>{this.isInitialized();const t=this.formatTarget(e);return this.getExpiration(t)}),qs(this,"del",e=>{if(this.isInitialized(),this.has(e)){const t=this.formatTarget(e),s=this.getExpiration(t);this.expirations.delete(t),this.events.emit(W.deleted,{target:t,expiration:s})}}),qs(this,"on",(e,t)=>{this.events.on(e,t)}),qs(this,"once",(e,t)=>{this.events.once(e,t)}),qs(this,"off",(e,t)=>{this.events.off(e,t)}),qs(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.logger=(0,a.U5)(t,this.name)}get context(){return(0,a.oI)(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("string"==typeof e)return(0,d.ADD)(e);if("number"==typeof e)return(0,d.gOF)(e);const{message:t}=(0,d.GuA)("UNKNOWN_TYPE","Target type: "+typeof e);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(W.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:e}=(0,d.GuA)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const t=this.expirations.get(e);if(!t){const{message:t}=(0,d.GuA)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(t),new Error(t)}return t}checkExpiry(e,t){const{expiry:s}=t;(0,h.toMiliseconds)(s)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(W.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(n.li.pulse,()=>this.checkExpirations()),this.events.on(W.created,e=>{const t=W.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(W.expired,e=>{const t=W.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(W.deleted,e=>{const t=W.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Bs=Object.defineProperty,Hs=(e,t,s)=>((e,t,s)=>t in e?Bs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Ws extends c.zl{constructor(e,t,s){super(e,t,s),this.core=e,this.logger=t,this.store=s,Hs(this,"name","verify-api"),Hs(this,"abortController"),Hs(this,"isDevEnv"),Hs(this,"verifyUrlV3",F),Hs(this,"storagePrefix",v),Hs(this,"version",2),Hs(this,"publicKey"),Hs(this,"fetchPromise"),Hs(this,"init",async()=>{var e;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&(0,h.toMiliseconds)(null==(e=this.publicKey)?void 0:e.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))}),Hs(this,"register",async e=>{if(!(0,d.BdH)()||this.isDevEnv)return;const t=window.location.origin,{id:s,decryptedId:i}=e,r=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${t}&id=${s}&decryptedId=${i}`;try{const e=(0,w.getDocument)(),t=this.startAbortTimer(5*h.ONE_SECOND),i=await new Promise((i,n)=>{const o=()=>{window.removeEventListener("message",c),e.body.removeChild(a),n("attestation aborted")};this.abortController.signal.addEventListener("abort",o);const a=e.createElement("iframe");a.src=r,a.style.display="none",a.addEventListener("error",o,{signal:this.abortController.signal});const c=r=>{if(r.data&&"string"==typeof r.data)try{const n=JSON.parse(r.data);if("verify_attestation"===n.type){if((0,p.Cq)(n.attestation).payload.id!==s)return;clearInterval(t),e.body.removeChild(a),this.abortController.signal.removeEventListener("abort",o),window.removeEventListener("message",c),i(null===n.attestation?"":n.attestation)}}catch(e){this.logger.warn(e)}};e.body.appendChild(a),window.addEventListener("message",c,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",i),i}catch(e){this.logger.warn(e)}return""}),Hs(this,"resolve",async e=>{if(this.isDevEnv)return"";const{attestationId:t,hash:s,encryptedId:i}=e;if(""===t)return void this.logger.debug("resolve: attestationId is empty, skipping");if(t){if((0,p.Cq)(t).payload.id!==i)return;const e=await this.isValidJwtAttestation(t);if(e)return e.isVerified?e:void this.logger.warn("resolve: jwt attestation: origin url not verified")}if(!s)return;const r=this.getVerifyUrl(e?.verifyUrl);return this.fetchAttestation(s,r)}),Hs(this,"fetchAttestation",async(e,t)=>{this.logger.debug(`resolving attestation: ${e} from url: ${t}`);const s=this.startAbortTimer(5*h.ONE_SECOND),i=await fetch(`${t}/attestation/${e}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(s),200===i.status?await i.json():void 0}),Hs(this,"getVerifyUrl",e=>{let t=e||V;return K.includes(t)||(this.logger.info(`verify url: ${t}, not included in trusted list, assigning default: ${V}`),t=V),t}),Hs(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const e=this.startAbortTimer(h.FIVE_SECONDS),t=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(e),await t.json()}catch(e){this.logger.warn(e)}}),Hs(this,"persistPublicKey",async e=>{this.logger.debug("persisting public key to local storage",e),await this.store.setItem(this.storeKey,e),this.publicKey=e}),Hs(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0}),Hs(this,"isValidJwtAttestation",async e=>{const t=await this.getPublicKey();try{if(t)return this.validateAttestation(e,t)}catch(e){this.logger.error(e),this.logger.warn("error validating attestation")}const s=await this.fetchAndPersistPublicKey();try{if(s)return this.validateAttestation(e,s)}catch(e){this.logger.error(e),this.logger.warn("error validating attestation")}}),Hs(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),Hs(this,"fetchAndPersistPublicKey",async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async e=>{const t=await this.fetchPublicKey();t&&(await this.persistPublicKey(t),e(t))});const e=await this.fetchPromise;return this.fetchPromise=void 0,e}),Hs(this,"validateAttestation",(e,t)=>{const s=(0,d.U0i)(e,t.publicKey),i={hasExpired:(0,h.toMiliseconds)(s.exp)<Date.now(),payload:s};if(i.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:i.payload.origin,isScam:i.payload.isScam,isVerified:i.payload.isVerified}}),this.logger=(0,a.U5)(t,this.name),this.abortController=new AbortController,this.isDevEnv=(0,d.w8K)(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return(0,a.oI)(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),(0,h.toMiliseconds)(e))}}var zs=Object.defineProperty,Vs=(e,t,s)=>((e,t,s)=>t in e?zs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Fs extends c.GF{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,Vs(this,"context","echo"),Vs(this,"registerDeviceToken",async e=>{const{clientId:t,token:s,notificationType:i,enableEncrypted:r=!1}=e,n=`https://echo.walletconnect.com/${this.projectId}/clients`;await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:t,type:i,token:s,always_raw:r})})}),this.logger=(0,a.U5)(t,this.context)}}var Ks=Object.defineProperty,Gs=Object.getOwnPropertySymbols,Js=Object.prototype.hasOwnProperty,Ys=Object.prototype.propertyIsEnumerable,Qs=(e,t,s)=>t in e?Ks(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Xs=(e,t)=>{for(var s in t||(t={}))Js.call(t,s)&&Qs(e,s,t[s]);if(Gs)for(var s of Gs(t))Ys.call(t,s)&&Qs(e,s,t[s]);return e},Zs=(e,t,s)=>Qs(e,"symbol"!=typeof t?t+"":t,s);class ei extends c.$Q{constructor(e,t,s=!0){super(e,t,s),this.core=e,this.logger=t,Zs(this,"context","event-client"),Zs(this,"storagePrefix",v),Zs(this,"storageVersion",.1),Zs(this,"events",new Map),Zs(this,"shouldPersist",!1),Zs(this,"init",async()=>{if(!(0,d.w8K)())try{const e={eventId:(0,d.gZm)(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:(0,d.ojD)(this.core.relayer.protocol,this.core.relayer.version,x)}}};await this.sendEvent([e])}catch(e){this.logger.warn(e)}}),Zs(this,"createEvent",e=>{const{event:t="ERROR",type:s="",properties:{topic:i,trace:r}}=e,n=(0,d.gZm)(),o=this.core.projectId||"",a=Date.now(),c=Xs({eventId:n,timestamp:a,props:{event:t,type:s,properties:{topic:i,trace:r}},bundleId:o,domain:this.getAppDomain()},this.setMethods(n));return this.telemetryEnabled&&(this.events.set(n,c),this.shouldPersist=!0),c}),Zs(this,"getEvent",e=>{const{eventId:t,topic:s}=e;if(t)return this.events.get(t);const i=Array.from(this.events.values()).find(e=>e.props.properties.topic===s);return i?Xs(Xs({},i),this.setMethods(i.eventId)):void 0}),Zs(this,"deleteEvent",e=>{const{eventId:t}=e;this.events.delete(t),this.shouldPersist=!0}),Zs(this,"setEventListeners",()=>{this.core.heartbeat.on(n.li.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(e=>{(0,h.fromMiliseconds)(Date.now())-(0,h.fromMiliseconds)(e.timestamp)>86400&&(this.events.delete(e.eventId),this.shouldPersist=!0)})})}),Zs(this,"setMethods",e=>({addTrace:t=>this.addTrace(e,t),setError:t=>this.setError(e,t)})),Zs(this,"addTrace",(e,t)=>{const s=this.events.get(e);s&&(s.props.properties.trace.push(t),this.events.set(e,s),this.shouldPersist=!0)}),Zs(this,"setError",(e,t)=>{const s=this.events.get(e);s&&(s.props.type=t,s.timestamp=Date.now(),this.events.set(e,s),this.shouldPersist=!0)}),Zs(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1}),Zs(this,"restore",async()=>{try{const e=await this.core.storage.getItem(this.storageKey)||[];if(!e.length)return;e.forEach(e=>{this.events.set(e.eventId,Xs(Xs({},e),this.setMethods(e.eventId)))})}catch(e){this.logger.warn(e)}}),Zs(this,"submit",async()=>{if(!this.telemetryEnabled||0===this.events.size)return;const e=[];for(const[t,s]of this.events)s.props.type&&e.push(s);if(0!==e.length)try{if((await this.sendEvent(e)).ok)for(const t of e)this.events.delete(t.eventId),this.shouldPersist=!0}catch(e){this.logger.warn(e)}}),Zs(this,"sendEvent",async e=>{const t=this.getAppDomain()?"":"&sp=desktop";return await fetch(`https://pulse.walletconnect.org/batch?projectId=${this.core.projectId}&st=events_sdk&sv=js-${x}${t}`,{method:"POST",body:JSON.stringify(e)})}),Zs(this,"getAppDomain",()=>(0,d.lFF)().url),this.logger=(0,a.U5)(t,this.context),this.telemetryEnabled=s,s?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var ti=Object.defineProperty,si=Object.getOwnPropertySymbols,ii=Object.prototype.hasOwnProperty,ri=Object.prototype.propertyIsEnumerable,ni=(e,t,s)=>t in e?ti(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,oi=(e,t)=>{for(var s in t||(t={}))ii.call(t,s)&&ni(e,s,t[s]);if(si)for(var s of si(t))ri.call(t,s)&&ni(e,s,t[s]);return e},ai=(e,t,s)=>ni(e,"symbol"!=typeof t?t+"":t,s);class ci extends c.ZP{constructor(e){var t;super(e),ai(this,"protocol","wc"),ai(this,"version",2),ai(this,"name",b),ai(this,"relayUrl"),ai(this,"projectId"),ai(this,"customStoragePrefix"),ai(this,"events",new i.EventEmitter),ai(this,"logger"),ai(this,"heartbeat"),ai(this,"relayer"),ai(this,"crypto"),ai(this,"storage"),ai(this,"history"),ai(this,"expirer"),ai(this,"pairing"),ai(this,"verify"),ai(this,"echoClient"),ai(this,"linkModeSupportedApps"),ai(this,"eventClient"),ai(this,"initialized",!1),ai(this,"logChunkController"),ai(this,"on",(e,t)=>this.events.on(e,t)),ai(this,"once",(e,t)=>this.events.once(e,t)),ai(this,"off",(e,t)=>this.events.off(e,t)),ai(this,"removeListener",(e,t)=>this.events.removeListener(e,t)),ai(this,"dispatchEnvelope",({topic:e,message:t,sessionExists:s})=>{if(!e||!t)return;const i={topic:e,message:t,publishedAt:Date.now(),transportType:R.link_mode};this.relayer.onLinkMessageEvent(i,{sessionExists:s})}),this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||C,this.customStoragePrefix=null!=e&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const s=(0,a.iP)({level:"string"==typeof e?.logger&&e.logger?e.logger:"error",name:b}),{logger:r,chunkLoggerController:c}=(0,a.D5)({opts:s,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=c,null!=(t=this.logChunkController)&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var e,t;null!=(e=this.logChunkController)&&e.downloadLogsBlobInBrowser&&(null==(t=this.logChunkController)||t.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=(0,a.U5)(r,this.name),this.heartbeat=new n.VH,this.crypto=new Pt(this,this.logger,e?.keychain),this.history=new Ms(this,this.logger),this.expirer=new $s(this,this.logger),this.storage=null!=e&&e.storage?e.storage:new o.A(oi(oi({},E),e?.storageOptions)),this.relayer=new fs({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new Us(this,this.logger),this.verify=new Ws(this,this.logger,this.storage),this.echoClient=new Fs(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new ei(this,this.logger,e?.telemetryEnabled)}static async init(e){const t=new ci(e);await t.initialize();const s=await t.crypto.getClientId();return await t.storage.setItem("WALLETCONNECT_CLIENT_ID",s),t}get context(){return(0,a.oI)(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return null==(e=this.logChunkController)?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(D,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.linkModeSupportedApps=await this.storage.getItem(D)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}}const hi=ci},99013:(e,t,s)=>{s.d(t,{W:()=>_});var i=s(89168),r=s(39150),n=s(76020),o=s(95191),a=s(87841),c=s(84253),h=s(5813),l=s(11553),p=s(16279),d=s(89058),u=s(50731),g=s(14479),f=s(67018),m=s(16158),w=s(25422),y=s(42831),b=s(16652);const v={currentTab:0,tokenBalance:[],smartAccountDeployed:!1,addressLabels:new Map,allAccounts:[],user:void 0},E={caipNetwork:void 0,supportsAllNetworks:!0,smartAccountEnabledNetworks:[]},I=(0,i.BX)({chains:(0,r.zC)(),activeCaipAddress:void 0,activeChain:void 0,activeCaipNetwork:void 0,noAdapters:!1,universalAdapter:{networkControllerClient:void 0,connectionControllerClient:void 0},isSwitchingNamespace:!1}),_={state:I,subscribe:e=>(0,i.B1)(I,()=>{e(I)}),subscribeKey:(e,t)=>(0,r.u$)(I,e,t),subscribeChainProp(e,t,s){let r;return(0,i.B1)(I.chains,()=>{const i=s||I.activeChain;if(i){const s=I.chains.get(i)?.[e];r!==s&&(r=s,t(s))}})},initialize(e,t,s){const{chainId:r,namespace:n}=l.i.getActiveNetworkProps(),o=t?.find(e=>e.id.toString()===r?.toString()),a=e.find(e=>e?.namespace===n)||e?.[0],c=new Set([...t?.map(e=>e.chainNamespace)??[]]);0!==e?.length&&a||(I.noAdapters=!0),I.noAdapters||(I.activeChain=a?.namespace,I.activeCaipNetwork=o,this.setChainNetworkData(a?.namespace,{caipNetwork:o}),I.activeChain&&w.z.set({activeChain:a?.namespace})),c.forEach(e=>{const r=t?.filter(t=>t.chainNamespace===e);_.state.chains.set(e,{namespace:e,networkState:(0,i.BX)({...E,caipNetwork:r?.[0]}),accountState:(0,i.BX)(v),caipNetworks:r??[],...s}),this.setRequestedCaipNetworks(r??[],e)})},removeAdapter(e){if(I.activeChain===e){const t=Array.from(I.chains.entries()).find(([t])=>t!==e);if(t){const e=t[1]?.caipNetworks?.[0];e&&this.setActiveCaipNetwork(e)}}I.chains.delete(e)},addAdapter(e,{networkControllerClient:t,connectionControllerClient:s},i){I.chains.set(e.namespace,{namespace:e.namespace,networkState:{...E,caipNetwork:i[0]},accountState:v,caipNetworks:i,connectionControllerClient:s,networkControllerClient:t}),this.setRequestedCaipNetworks(i?.filter(t=>t.chainNamespace===e.namespace)??[],e.namespace)},addNetwork(e){const t=I.chains.get(e.chainNamespace);if(t){const s=[...t.caipNetworks||[]];t.caipNetworks?.find(t=>t.id===e.id)||s.push(e),I.chains.set(e.chainNamespace,{...t,caipNetworks:s}),this.setRequestedCaipNetworks(s,e.chainNamespace)}},removeNetwork(e,t){const s=I.chains.get(e);if(s){const i=I.activeCaipNetwork?.id===t,r=[...s.caipNetworks?.filter(e=>e.id!==t)||[]];i&&s?.caipNetworks?.[0]&&this.setActiveCaipNetwork(s.caipNetworks[0]),I.chains.set(e,{...s,caipNetworks:r}),this.setRequestedCaipNetworks(r||[],e)}},setAdapterNetworkState(e,t){const s=I.chains.get(e);s&&(s.networkState={...s.networkState||E,...t},I.chains.set(e,s))},setChainAccountData(e,t,s=!0){if(!e)throw new Error("Chain is required to update chain account data");const i=I.chains.get(e);if(i){const s={...i.accountState||v,...t};I.chains.set(e,{...i,accountState:s}),1!==I.chains.size&&I.activeChain!==e||(t.caipAddress&&(I.activeCaipAddress=t.caipAddress),p.U.replaceState(s))}},setChainNetworkData(e,t){if(!e)return;const s=I.chains.get(e);if(s){const i={...s.networkState||E,...t};I.chains.set(e,{...s,networkState:i})}},setAccountProp(e,t,s,i=!0){this.setChainAccountData(s,{[e]:t},i),"status"===e&&"disconnected"===t&&s&&u.a.removeConnectorId(s)},setActiveNamespace(e){I.activeChain=e;const t=e?I.chains.get(e):void 0,s=t?.networkState?.caipNetwork;s?.id&&e&&(I.activeCaipAddress=t?.accountState?.caipAddress,I.activeCaipNetwork=s,this.setChainNetworkData(e,{caipNetwork:s}),l.i.setActiveCaipNetworkId(s?.caipNetworkId),w.z.set({activeChain:e,selectedNetworkId:s?.caipNetworkId}))},setActiveCaipNetwork(e){if(!e)return;I.activeChain!==e.chainNamespace&&this.setIsSwitchingNamespace(!0);const t=I.chains.get(e.chainNamespace);I.activeChain=e.chainNamespace,I.activeCaipNetwork=e,this.setChainNetworkData(e.chainNamespace,{caipNetwork:e}),I.activeCaipAddress=t?.accountState?.address?`${e.chainNamespace}:${e.id}:${t?.accountState?.address}`:void 0,this.setAccountProp("caipAddress",I.activeCaipAddress,e.chainNamespace),t&&p.U.replaceState(t.accountState),b.R.resetSend(),w.z.set({activeChain:I.activeChain,selectedNetworkId:I.activeCaipNetwork?.caipNetworkId}),l.i.setActiveCaipNetworkId(e.caipNetworkId),this.checkIfSupportedNetwork(e.chainNamespace)||!m.H.state.enableNetworkSwitch||m.H.state.allowUnsupportedChain||d.x.state.wcBasic||this.showUnsupportedChainUI()},addCaipNetwork(e){if(!e)return;const t=I.chains.get(e.chainNamespace);t&&t?.caipNetworks?.push(e)},async switchActiveNamespace(e){if(!e)return;const t=e!==_.state.activeChain,s=_.getNetworkData(e)?.caipNetwork,i=_.getCaipNetworkByNamespace(e,s?.id);t&&i&&await _.switchActiveNetwork(i)},async switchActiveNetwork(e){const t=_.state.chains.get(_.state.activeChain);!t?.caipNetworks?.some(e=>e.id===I.activeCaipNetwork?.id)&&y.I.goBack();const s=this.getNetworkControllerClient(e.chainNamespace);s&&(await s.switchCaipNetwork(e),g.E.sendEvent({type:"track",event:"SWITCH_NETWORK",properties:{network:e.caipNetworkId}}))},getNetworkControllerClient(e){const t=e||I.activeChain,s=I.chains.get(t);if(!s)throw new Error("Chain adapter not found");if(!s.networkControllerClient)throw new Error("NetworkController client not set");return s.networkControllerClient},getConnectionControllerClient(e){const t=e||I.activeChain;if(!t)throw new Error("Chain is required to get connection controller client");const s=I.chains.get(t);if(!s?.connectionControllerClient)throw new Error("ConnectionController client not set");return s.connectionControllerClient},getAccountProp(e,t){let s=I.activeChain;if(t&&(s=t),!s)return;const i=I.chains.get(s)?.accountState;return i?i[e]:void 0},getNetworkProp(e,t){const s=I.chains.get(t)?.networkState;if(s)return s[e]},getRequestedCaipNetworks(e){const t=I.chains.get(e),{approvedCaipNetworkIds:s=[],requestedCaipNetworks:i=[]}=t?.networkState||{};return h.w.sortRequestedNetworks(s,i)},getAllRequestedCaipNetworks(){const e=[];return I.chains.forEach(t=>{const s=this.getRequestedCaipNetworks(t.namespace);e.push(...s)}),e},setRequestedCaipNetworks(e,t){this.setAdapterNetworkState(t,{requestedCaipNetworks:e})},getAllApprovedCaipNetworkIds(){const e=[];return I.chains.forEach(t=>{const s=this.getApprovedCaipNetworkIds(t.namespace);e.push(...s)}),e},getActiveCaipNetwork:()=>I.activeCaipNetwork,getActiveCaipAddress:()=>I.activeCaipAddress,getApprovedCaipNetworkIds(e){const t=I.chains.get(e);return t?.networkState?.approvedCaipNetworkIds||[]},async setApprovedCaipNetworksData(e){const t=this.getNetworkControllerClient(),s=await(t?.getApprovedCaipNetworksData());this.setAdapterNetworkState(e,{approvedCaipNetworkIds:s?.approvedCaipNetworkIds,supportsAllNetworks:s?.supportsAllNetworks})},checkIfSupportedNetwork(e,t){const s=t||I.activeCaipNetwork,i=this.getRequestedCaipNetworks(e);return!i.length||i?.some(e=>e.id===s?.id)},checkIfSupportedChainId(e){if(!I.activeChain)return!0;const t=this.getRequestedCaipNetworks(I.activeChain);return t?.some(t=>t.id===e)},setSmartAccountEnabledNetworks(e,t){this.setAdapterNetworkState(t,{smartAccountEnabledNetworks:e})},checkIfSmartAccountEnabled(){const e=n.L.caipNetworkIdToNumber(I.activeCaipNetwork?.caipNetworkId),t=I.activeChain;if(!t||!e)return!1;const s=this.getNetworkProp("smartAccountEnabledNetworks",t);return Boolean(s?.includes(Number(e)))},getActiveNetworkTokenAddress(){const e=I.activeCaipNetwork?.chainNamespace||"eip155";return`${e}:${I.activeCaipNetwork?.id||1}:${c.oU.NATIVE_TOKEN_ADDRESS[e]}`},showUnsupportedChainUI(){f.W.open({view:"UnsupportedChain"})},checkIfNamesSupported(){const e=I.activeCaipNetwork;return Boolean(e?.chainNamespace&&c.oU.NAMES_SUPPORTED_CHAIN_NAMESPACES.includes(e.chainNamespace))},resetNetwork(e){this.setAdapterNetworkState(e,{approvedCaipNetworkIds:void 0,supportsAllNetworks:!0,smartAccountEnabledNetworks:[]})},resetAccount(e){const t=e;if(!t)throw new Error("Chain is required to set account prop");I.activeCaipAddress=void 0,this.setChainAccountData(t,{smartAccountDeployed:!1,currentTab:0,caipAddress:void 0,address:void 0,balance:void 0,balanceSymbol:void 0,profileName:void 0,profileImage:void 0,addressExplorerUrl:void 0,tokenBalance:[],connectedWalletInfo:void 0,preferredAccountType:void 0,socialProvider:void 0,socialWindow:void 0,farcasterUrl:void 0,allAccounts:[],user:void 0,status:"disconnected"}),u.a.removeConnectorId(t)},async disconnect(e){const t=(0,a.g)(e);try{b.R.resetSend();const s=await Promise.allSettled(t.map(async([e,t])=>{try{const{caipAddress:s}=this.getAccountData(e)||{};s&&t.connectionControllerClient?.disconnect&&await t.connectionControllerClient.disconnect(e),this.resetAccount(e),this.resetNetwork(e)}catch(t){throw new Error(`Failed to disconnect chain ${e}: ${t.message}`)}}));d.x.resetWcConnection();const i=s.filter(e=>"rejected"===e.status);if(i.length>0)throw new Error(i.map(e=>e.reason.message).join(", "));l.i.deleteConnectedSocialProvider(),e?u.a.removeConnectorId(e):u.a.resetConnectorIds(),g.E.sendEvent({type:"track",event:"DISCONNECT_SUCCESS",properties:{namespace:e||"all"}})}catch(e){console.error(e.message||"Failed to disconnect chains"),g.E.sendEvent({type:"track",event:"DISCONNECT_ERROR",properties:{message:e.message||"Failed to disconnect chains"}})}},setIsSwitchingNamespace(e){I.isSwitchingNamespace=e},getFirstCaipNetworkSupportsAuthConnector(){const e=[];let t;if(I.chains.forEach(t=>{o.o.AUTH_CONNECTOR_SUPPORTED_CHAINS.find(e=>e===t.namespace)&&t.namespace&&e.push(t.namespace)}),e.length>0){const s=e[0];return t=s?I.chains.get(s)?.caipNetworks?.[0]:void 0,t}},getAccountData:e=>e?_.state.chains.get(e)?.accountState:p.U.state,getNetworkData(e){const t=e||I.activeChain;if(t)return _.state.chains.get(t)?.networkState},getCaipNetworkByNamespace(e,t){if(!e)return;const s=_.state.chains.get(e),i=s?.caipNetworks?.find(e=>e.id===t);return i||s?.networkState?.caipNetwork||s?.caipNetworks?.[0]},getRequestedCaipNetworkIds(){const e=u.a.state.filterByNamespace;return(e?[I.chains.get(e)]:Array.from(I.chains.values())).flatMap(e=>e?.caipNetworks||[]).map(e=>e.caipNetworkId)}}},99057:(e,t,s)=>{s(70255),s(64264),s(93786),s(14350),s(50046),s(48526).hp,Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable,Object.defineProperty,Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable,Object.defineProperty,Object.defineProperty,Object.defineProperty,Object.defineProperty,Object.defineProperty,Object.defineProperty,Object.defineProperty,Object.defineProperty,Object.defineProperty,Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable}};
|