@dodoex/wallet-web3 0.3.5 → 0.4.1-rise

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.
Files changed (91) hide show
  1. package/dist/{alchemy-provider-5870b6fa-696b6cc4.js → alchemy-provider-5870b6fa-14ec4a67.js} +1 -1
  2. package/dist/{alchemy-websocket-provider-213da986-275b5c6a.js → alchemy-websocket-provider-213da986-248efea7.js} +1 -1
  3. package/dist/{blocto-e1aefb44.js → blocto-f754a82a.js} +1 -1
  4. package/dist/{ccip-0aa3a5f4.js → ccip-97718869.js} +1 -1
  5. package/dist/ccip-e1bced07.js +1 -0
  6. package/dist/cjs/{alchemy-provider-5870b6fa-4a0949d5.cjs → alchemy-provider-5870b6fa-116ab07a.cjs} +1 -1
  7. package/dist/cjs/{alchemy-websocket-provider-213da986-aac8edbc.cjs → alchemy-websocket-provider-213da986-87ccad9d.cjs} +1 -1
  8. package/dist/cjs/{blocto-f15f90ae.cjs → blocto-95507d3f.cjs} +1 -1
  9. package/dist/cjs/{ccip-bd97f70b.cjs → ccip-51bad854.cjs} +1 -1
  10. package/dist/cjs/ccip-b38d78bc.cjs +1 -0
  11. package/dist/cjs/{draggabilly-1d308289.cjs → draggabilly-e359aaca.cjs} +1 -1
  12. package/dist/cjs/id-2a5c5ef2.cjs +1 -0
  13. package/dist/cjs/{index-cfaff5d4.cjs → index-10a24541.cjs} +1 -1
  14. package/dist/cjs/{index-51063af3.cjs → index-39f61aea.cjs} +1 -1
  15. package/dist/cjs/index-5f0913a9.cjs +2 -0
  16. package/dist/cjs/{index-b988e64d.cjs → index-643e5119.cjs} +1 -1
  17. package/dist/cjs/{index-200ed5fd.cjs → index-69bd892e.cjs} +1 -1
  18. package/dist/cjs/{index-a38f4e67.cjs → index-7af70508.cjs} +3 -3
  19. package/dist/cjs/{index-f79473f2.cjs → index-96e65b8a.cjs} +1 -1
  20. package/dist/cjs/{index-0d49b891.cjs → index-9ccb1170.cjs} +1 -1
  21. package/dist/cjs/index-bb10a98a.cjs +6 -0
  22. package/dist/cjs/{index-11758bb0.cjs → index-f544eb4c.cjs} +1 -1
  23. package/dist/cjs/index-fadaf8b8.cjs +28 -0
  24. package/dist/cjs/index.cjs +1 -1
  25. package/dist/cjs/{index.es-2b50e672.cjs → index.es-f545ef05.cjs} +1 -1
  26. package/dist/cjs/{interface-2182d86c.cjs → interface-8a637174.cjs} +1 -1
  27. package/dist/cjs/lib-typedarrays-cad6d780.cjs +1 -0
  28. package/dist/cjs/{portis-ad141241.cjs → portis-6bb18e8c.cjs} +1 -1
  29. package/dist/cjs/{provider-c6d5b478.cjs → provider-ef4d48ff.cjs} +1 -1
  30. package/dist/cjs/providers/connector/alchemy/index.d.ts +12 -8
  31. package/dist/cjs/providers/connector/index.d.ts +3 -907
  32. package/dist/cjs/providers/connector/rise/index.d.ts +3 -0
  33. package/dist/cjs/providers/connector/rise/provider.d.ts +2 -0
  34. package/dist/cjs/providers/wallets/index.d.ts +4 -0
  35. package/dist/cjs/providers/wallets/standalone.d.ts +1 -0
  36. package/dist/cjs/providers/wallets/types.d.ts +1 -0
  37. package/dist/cjs/{rainbow-e5c6a47a.cjs → rainbow-23f226c3.cjs} +1 -1
  38. package/dist/cjs/secp256k1-12b6c26a.cjs +2 -0
  39. package/dist/cjs/sha224-80c902fd.cjs +1 -0
  40. package/dist/cjs/{sha256-5ac1c2d4.cjs → sha256-5fef9f66.cjs} +1 -1
  41. package/dist/cjs/{typed-data-03ab75bd.cjs → typed-data-6fcfdd47.cjs} +1 -1
  42. package/dist/cjs/uAuth-2e9ca189.cjs +1 -0
  43. package/dist/cjs/{walletConnect-1a7e2d7f.cjs → walletConnect-a924de37.cjs} +1 -1
  44. package/dist/cjs/{walletLink-c38483ce.cjs → walletLink-61f852a1.cjs} +1 -1
  45. package/dist/{draggabilly-e2a64f00.js → draggabilly-3125c6e9.js} +1 -1
  46. package/dist/id-cdf2dadd.js +1 -0
  47. package/dist/{index-80bc89d5.js → index-388a0406.js} +1 -1
  48. package/dist/{index-ec3b3731.js → index-3f3b3b93.js} +1 -1
  49. package/dist/index-435c5426.js +2 -0
  50. package/dist/index-4f2cd06b.js +6 -0
  51. package/dist/index-9534d8ad.js +28 -0
  52. package/dist/{index-e1d234ee.js → index-bbbb136d.js} +1 -1
  53. package/dist/{index-7cbd6234.js → index-be44c6cf.js} +1 -1
  54. package/dist/{index-0a579548.js → index-ce22e241.js} +3 -3
  55. package/dist/{index-137d769a.js → index-dca9f9d5.js} +1 -1
  56. package/dist/{index-882015e7.js → index-ecc4ef84.js} +1 -1
  57. package/dist/{index-cc475881.js → index-f9b4c373.js} +1 -1
  58. package/dist/{index.es-a4cf5453.js → index.es-54e0c8fc.js} +1 -1
  59. package/dist/index.js +1 -1
  60. package/dist/{interface-9e9accf0.js → interface-a828a662.js} +1 -1
  61. package/dist/lib-typedarrays-87be4777.js +1 -0
  62. package/dist/{portis-ba9783ab.js → portis-2c5bf8b6.js} +1 -1
  63. package/dist/{provider-97940efd.js → provider-68c12b1a.js} +1 -1
  64. package/dist/providers/connector/alchemy/index.d.ts +12 -8
  65. package/dist/providers/connector/index.d.ts +3 -907
  66. package/dist/providers/connector/rise/index.d.ts +3 -0
  67. package/dist/providers/connector/rise/provider.d.ts +2 -0
  68. package/dist/providers/wallets/index.d.ts +4 -0
  69. package/dist/providers/wallets/standalone.d.ts +1 -0
  70. package/dist/providers/wallets/types.d.ts +1 -0
  71. package/dist/{rainbow-3c78c1a5.js → rainbow-049a1739.js} +1 -1
  72. package/dist/secp256k1-981bc92b.js +2 -0
  73. package/dist/sha224-5fac1d2c.js +1 -0
  74. package/dist/{sha256-2c6fd6b4.js → sha256-5efde761.js} +1 -1
  75. package/dist/{typed-data-c08773d7.js → typed-data-fd8be8f8.js} +1 -1
  76. package/dist/uAuth-d6acd696.js +1 -0
  77. package/dist/{walletConnect-443f90da.js → walletConnect-bad92dcf.js} +1 -1
  78. package/dist/{walletLink-3cdaed45.js → walletLink-b85ce653.js} +1 -1
  79. package/package.json +5 -4
  80. package/dist/cjs/id-7b464a84.cjs +0 -1
  81. package/dist/cjs/index-0ab3d083.cjs +0 -6
  82. package/dist/cjs/index-6e40eb80.cjs +0 -28
  83. package/dist/cjs/lib-typedarrays-d5d3c2ad.cjs +0 -1
  84. package/dist/cjs/sha224-b1b1470c.cjs +0 -1
  85. package/dist/cjs/uAuth-31a4eb75.cjs +0 -1
  86. package/dist/id-47439a66.js +0 -1
  87. package/dist/index-6188dadc.js +0 -28
  88. package/dist/index-c438e955.js +0 -6
  89. package/dist/lib-typedarrays-61f78341.js +0 -1
  90. package/dist/sha224-6888f214.js +0 -1
  91. package/dist/uAuth-d1c3c763.js +0 -1
@@ -0,0 +1,2 @@
1
+ "use strict";var e=require("./index-fadaf8b8.cjs");require("@ethersproject/address");class t extends Error{constructor(e,n={}){const r=n.cause instanceof t?n.cause.details:n.cause?.message?n.cause.message:n.details,s=n.cause instanceof t&&n.cause.docsPath||n.docsPath;super([e||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...s?[`Docs: https://abitype.dev${s}`]:[],...r?[`Details: ${r}`]:[],"Version: abitype@1.0.8"].join("\n")),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiTypeError"}),n.cause&&(this.cause=n.cause),this.details=r,this.docsPath=s,this.metaMessages=n.metaMessages,this.shortMessage=e}}function n(e,t){const n=e.exec(t);return n?.groups}const r=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,s=/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/,i=/^\(.+?\).*?$/,a=/^tuple(?<array>(\[(\d*)\])*)$/;function o(e){let t=e.type;if(a.test(e.type)&&"components"in e){t="(";const r=e.components.length;for(let n=0;n<r;n++){t+=o(e.components[n]),n<r-1&&(t+=", ")}const s=n(a,e.type);return t+=`)${s?.array??""}`,o({...e,type:t})}return"indexed"in e&&e.indexed&&(t=`${t} indexed`),e.name?`${t} ${e.name}`:t}function c(e){let t="";const n=e.length;for(let r=0;r<n;r++){t+=o(e[r]),r!==n-1&&(t+=", ")}return t}const u=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const d=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const l=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;const f=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function p(e){return f.test(e)}function h(e){return n(f,e)}const m=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;const y=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;const b=/^receive\(\) external payable$/;const g=new Set(["indexed"]),w=new Set(["calldata","memory","storage"]);class v extends t{constructor({type:e}){super("Unknown type.",{metaMessages:[`Type "${e}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownTypeError"})}}class x extends t{constructor({type:e}){super("Unknown type.",{metaMessages:[`Type "${e}" is not a valid ABI type.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSolidityTypeError"})}}class I extends t{constructor({param:e}){super("Invalid ABI parameter.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class P extends t{constructor({param:e,name:t}){super("Invalid ABI parameter.",{details:e,metaMessages:[`"${t}" is a protected Solidity keyword. More info: https://docs.soliditylang.org/en/latest/cheatsheet.html`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SolidityProtectedKeywordError"})}}class z extends t{constructor({param:e,type:t,modifier:n}){super("Invalid ABI parameter.",{details:e,metaMessages:[`Modifier "${n}" not allowed${t?` in "${t}" type`:""}.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidModifierError"})}}class E extends t{constructor({param:e,type:t,modifier:n}){super("Invalid ABI parameter.",{details:e,metaMessages:[`Modifier "${n}" not allowed${t?` in "${t}" type`:""}.`,`Data location can only be specified for array, struct, or mapping types, but "${n}" was given.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidFunctionModifierError"})}}class A extends t{constructor({abiParameter:e}){super("Invalid ABI parameter.",{details:JSON.stringify(e,null,2),metaMessages:["ABI parameter type is invalid."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiTypeParameterError"})}}class k extends t{constructor({signature:e,type:t}){super(`Invalid ${t} signature.`,{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class M extends t{constructor({signature:e}){super("Unknown signature.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class $ extends t{constructor({signature:e}){super("Invalid struct signature.",{details:e,metaMessages:["No properties exist."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidStructSignatureError"})}}class O extends t{constructor({type:e}){super("Circular reference detected.",{metaMessages:[`Struct "${e}" is a circular reference.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"CircularReferenceError"})}}class j extends t{constructor({current:e,depth:t}){super("Unbalanced parentheses.",{metaMessages:[`"${e.trim()}" has too many ${t>0?"opening":"closing"} parentheses.`],details:`Depth "${t}"`}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParenthesisError"})}}const S=new Map([["address",{type:"address"}],["bool",{type:"bool"}],["bytes",{type:"bytes"}],["bytes32",{type:"bytes32"}],["int",{type:"int256"}],["int256",{type:"int256"}],["string",{type:"string"}],["uint",{type:"uint256"}],["uint8",{type:"uint8"}],["uint16",{type:"uint16"}],["uint24",{type:"uint24"}],["uint32",{type:"uint32"}],["uint64",{type:"uint64"}],["uint96",{type:"uint96"}],["uint112",{type:"uint112"}],["uint160",{type:"uint160"}],["uint192",{type:"uint192"}],["uint256",{type:"uint256"}],["address owner",{type:"address",name:"owner"}],["address to",{type:"address",name:"to"}],["bool approved",{type:"bool",name:"approved"}],["bytes _data",{type:"bytes",name:"_data"}],["bytes data",{type:"bytes",name:"data"}],["bytes signature",{type:"bytes",name:"signature"}],["bytes32 hash",{type:"bytes32",name:"hash"}],["bytes32 r",{type:"bytes32",name:"r"}],["bytes32 root",{type:"bytes32",name:"root"}],["bytes32 s",{type:"bytes32",name:"s"}],["string name",{type:"string",name:"name"}],["string symbol",{type:"string",name:"symbol"}],["string tokenURI",{type:"string",name:"tokenURI"}],["uint tokenId",{type:"uint256",name:"tokenId"}],["uint8 v",{type:"uint8",name:"v"}],["uint256 balance",{type:"uint256",name:"balance"}],["uint256 tokenId",{type:"uint256",name:"tokenId"}],["uint256 value",{type:"uint256",name:"value"}],["event:address indexed from",{type:"address",name:"from",indexed:!0}],["event:address indexed to",{type:"address",name:"to",indexed:!0}],["event:uint indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}],["event:uint256 indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}]]);function N(e,t={}){if(function(e){return l.test(e)}(e))return function(e,t={}){const r=function(e){return n(l,e)}(e);if(!r)throw new k({signature:e,type:"function"});const s=B(r.parameters),i=[],a=s.length;for(let e=0;e<a;e++)i.push(C(s[e],{modifiers:w,structs:t,type:"function"}));const o=[];if(r.returns){const e=B(r.returns),n=e.length;for(let r=0;r<n;r++)o.push(C(e[r],{modifiers:w,structs:t,type:"function"}))}return{name:r.name,type:"function",stateMutability:r.stateMutability??"nonpayable",inputs:i,outputs:o}}(e,t);if(function(e){return d.test(e)}(e))return function(e,t={}){const r=function(e){return n(d,e)}(e);if(!r)throw new k({signature:e,type:"event"});const s=B(r.parameters),i=[],a=s.length;for(let e=0;e<a;e++)i.push(C(s[e],{modifiers:g,structs:t,type:"event"}));return{name:r.name,type:"event",inputs:i}}(e,t);if(function(e){return u.test(e)}(e))return function(e,t={}){const r=function(e){return n(u,e)}(e);if(!r)throw new k({signature:e,type:"error"});const s=B(r.parameters),i=[],a=s.length;for(let e=0;e<a;e++)i.push(C(s[e],{structs:t,type:"error"}));return{name:r.name,type:"error",inputs:i}}(e,t);if(function(e){return m.test(e)}(e))return function(e,t={}){const r=function(e){return n(m,e)}(e);if(!r)throw new k({signature:e,type:"constructor"});const s=B(r.parameters),i=[],a=s.length;for(let e=0;e<a;e++)i.push(C(s[e],{structs:t,type:"constructor"}));return{type:"constructor",stateMutability:r.stateMutability??"nonpayable",inputs:i}}(e,t);if(function(e){return y.test(e)}(e))return function(e){const t=function(e){return n(y,e)}(e);if(!t)throw new k({signature:e,type:"fallback"});return{type:"fallback",stateMutability:t.stateMutability??"nonpayable"}}(e);if(function(e){return b.test(e)}(e))return{type:"receive",stateMutability:"payable"};throw new M({signature:e})}const T=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,_=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,R=/^u?int$/;function C(e,t){const a=function(e,t,n){let r="";if(n)for(const e of Object.entries(n)){if(!e)continue;let t="";for(const n of e[1])t+=`[${n.type}${n.name?`:${n.name}`:""}]`;r+=`(${e[0]}{${t}})`}return t?`${t}:${e}${r}`:e}(e,t?.type,t?.structs);if(S.has(a))return S.get(a);const o=i.test(e),c=n(o?_:T,e);if(!c)throw new I({param:e});if(c.name&&function(e){return"address"===e||"bool"===e||"function"===e||"string"===e||"tuple"===e||r.test(e)||s.test(e)||U.test(e)}(c.name))throw new P({param:e,name:c.name});const u=c.name?{name:c.name}:{},d="indexed"===c.modifier?{indexed:!0}:{},l=t?.structs??{};let f,p={};if(o){f="tuple";const e=B(c.type),t=[],n=e.length;for(let r=0;r<n;r++)t.push(C(e[r],{structs:l}));p={components:t}}else if(c.type in l)f="tuple",p={components:l[c.type]};else if(R.test(c.type))f=`${c.type}256`;else if(f=c.type,"struct"!==t?.type&&!D(f))throw new x({type:f});if(c.modifier){if(!t?.modifiers?.has?.(c.modifier))throw new z({param:e,type:t?.type,modifier:c.modifier});if(w.has(c.modifier)&&!function(e,t){return t||"bytes"===e||"string"===e||"tuple"===e}(f,!!c.array))throw new E({param:e,type:t?.type,modifier:c.modifier})}const h={type:`${f}${c.array??""}`,...u,...d,...p};return S.set(a,h),h}function B(e,t=[],n="",r=0){const s=e.trim().length;for(let i=0;i<s;i++){const s=e[i],a=e.slice(i+1);switch(s){case",":return 0===r?B(a,[...t,n.trim()]):B(a,t,`${n}${s}`,r);case"(":return B(a,t,`${n}${s}`,r+1);case")":return B(a,t,`${n}${s}`,r-1);default:return B(a,t,`${n}${s}`,r)}}if(""===n)return t;if(0!==r)throw new j({current:n,depth:r});return t.push(n.trim()),t}function D(e){return"address"===e||"bool"===e||"function"===e||"string"===e||r.test(e)||s.test(e)}const U=/^(?:after|alias|anonymous|apply|auto|byte|calldata|case|catch|constant|copyof|default|defined|error|event|external|false|final|function|immutable|implements|in|indexed|inline|internal|let|mapping|match|memory|mutable|null|of|override|partial|private|promise|public|pure|reference|relocatable|return|returns|sizeof|static|storage|struct|super|supports|switch|this|true|try|typedef|typeof|var|view|virtual)$/;const q=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;function L(e,t,r=new Set){const s=[],a=e.length;for(let o=0;o<a;o++){const a=e[o];if(i.test(a.type))s.push(a);else{const e=n(q,a.type);if(!e?.type)throw new A({abiParameter:a});const{array:i,type:o}=e;if(o in t){if(r.has(o))throw new O({type:o});s.push({...a,type:`tuple${i??""}`,components:L(t[o]??[],t,new Set([...r,o]))})}else{if(!D(o))throw new v({type:o});s.push(a)}}}return s}function F(e){const t=function(e){const t={},n=e.length;for(let r=0;r<n;r++){const n=e[r];if(!p(n))continue;const s=h(n);if(!s)throw new k({signature:n,type:"struct"});const i=s.properties.split(";"),a=[],o=i.length;for(let e=0;e<o;e++){const t=i[e].trim();if(!t)continue;const n=C(t,{type:"struct"});a.push(n)}if(!a.length)throw new $({signature:n});t[s.name]=a}const r={},s=Object.entries(t),i=s.length;for(let e=0;e<i;e++){const[n,i]=s[e];r[n]=L(i,t)}return r}(e),n=[],r=e.length;for(let s=0;s<r;s++){const r=e[s];p(r)||n.push(N(r,t))}return n}function K(e,t,n){const r=e[t.name];if("function"==typeof r)return r;const s=e[n];return"function"==typeof s?s:n=>t(e,n)}function G(e,{includeName:t=!1}={}){if("function"!==e.type&&"event"!==e.type&&"error"!==e.type)throw new me(e.type);return`${e.name}(${V(e.inputs,{includeName:t})})`}function V(e,{includeName:t=!1}={}){return e?e.map((e=>function(e,{includeName:t}){if(e.type.startsWith("tuple"))return`(${V(e.components,{includeName:t})})${e.type.slice(5)}`;return e.type+(t&&e.name?` ${e.name}`:"")}(e,{includeName:t}))).join(t?", ":","):""}function Z(e,{strict:t=!0}={}){return!!e&&("string"==typeof e&&(t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")))}function H(e){return Z(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const W="2.37.0";let Y=({docsBaseUrl:e,docsPath:t="",docsSlug:n})=>t?`${e??"https://viem.sh"}${t}${n?`#${n}`:""}`:void 0,Q=`viem@${W}`;class J extends Error{constructor(e,t={}){const n=t.cause instanceof J?t.cause.details:t.cause?.message?t.cause.message:t.details,r=t.cause instanceof J&&t.cause.docsPath||t.docsPath,s=Y?.({...t,docsPath:r});super([e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...n?[`Details: ${n}`]:[],...Q?[`Version: ${Q}`]:[]].join("\n"),t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=n,this.docsPath=r,this.metaMessages=t.metaMessages,this.name=t.name??this.name,this.shortMessage=e,this.version=W}walk(e){return X(this,e)}}function X(e,t){return t?.(e)?e:e&&"object"==typeof e&&"cause"in e&&void 0!==e.cause?X(e.cause,t):t?null:e}class ee extends J{constructor({docsPath:e}){super(["A constructor was not found on the ABI.","Make sure you are using the correct ABI and that the constructor exists on it."].join("\n"),{docsPath:e,name:"AbiConstructorNotFoundError"})}}class te extends J{constructor({docsPath:e}){super(["Constructor arguments were provided (`args`), but a constructor parameters (`inputs`) were not found on the ABI.","Make sure you are using the correct ABI, and that the `inputs` attribute on the constructor exists."].join("\n"),{docsPath:e,name:"AbiConstructorParamsNotFoundError"})}}class ne extends J{constructor({data:e,params:t,size:n}){super([`Data size of ${n} bytes is too small for given parameters.`].join("\n"),{metaMessages:[`Params: (${V(t,{includeName:!0})})`,`Data: ${e} (${n} bytes)`],name:"AbiDecodingDataSizeTooSmallError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"params",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"size",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=e,this.params=t,this.size=n}}class re extends J{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.',{name:"AbiDecodingZeroDataError"})}}class se extends J{constructor({expectedLength:e,givenLength:t,type:n}){super([`ABI encoding array length mismatch for type ${n}.`,`Expected length: ${e}`,`Given length: ${t}`].join("\n"),{name:"AbiEncodingArrayLengthMismatchError"})}}class ie extends J{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${H(t)}) does not match expected size (bytes${e}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class ae extends J{constructor({expectedLength:e,givenLength:t}){super(["ABI encoding params/values length mismatch.",`Expected length (params): ${e}`,`Given length (values): ${t}`].join("\n"),{name:"AbiEncodingLengthMismatchError"})}}class oe extends J{constructor(e,{docsPath:t}){super([`Encoded error signature "${e}" not found on ABI.`,"Make sure you are using the correct ABI and that the error exists on it.",`You can look up the decoded signature here: https://openchain.xyz/signatures?query=${e}.`].join("\n"),{docsPath:t,name:"AbiErrorSignatureNotFoundError"}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.signature=e}}class ce extends J{constructor(e,{docsPath:t}={}){super([`Function ${e?`"${e}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the function exists on it."].join("\n"),{docsPath:t,name:"AbiFunctionNotFoundError"})}}class ue extends J{constructor(e,{docsPath:t}){super([`Function "${e}" does not contain any \`outputs\` on ABI.`,"Cannot decode function result without knowing what the parameter types are.","Make sure you are using the correct ABI and that the function exists on it."].join("\n"),{docsPath:t,name:"AbiFunctionOutputsNotFoundError"})}}class de extends J{constructor(e,t){super("Found ambiguous types in overloaded ABI items.",{metaMessages:[`\`${e.type}\` in \`${G(e.abiItem)}\`, and`,`\`${t.type}\` in \`${G(t.abiItem)}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."],name:"AbiItemAmbiguityError"})}}class le extends J{constructor({expectedSize:e,givenSize:t}){super(`Expected bytes${e}, got bytes${t}.`,{name:"BytesSizeMismatchError"})}}class fe extends J{constructor(e,{docsPath:t}){super([`Type "${e}" is not a valid encoding type.`,"Please provide a valid ABI type."].join("\n"),{docsPath:t,name:"InvalidAbiEncodingType"})}}class pe extends J{constructor(e,{docsPath:t}){super([`Type "${e}" is not a valid decoding type.`,"Please provide a valid ABI type."].join("\n"),{docsPath:t,name:"InvalidAbiDecodingType"})}}class he extends J{constructor(e){super([`Value "${e}" is not a valid array.`].join("\n"),{name:"InvalidArrayError"})}}class me extends J{constructor(e){super([`"${e}" is not a valid definition type.`,'Valid types: "function", "event", "error"'].join("\n"),{name:"InvalidDefinitionTypeError"})}}class ye extends J{constructor({offset:e,position:t,size:n}){super(`Slice ${"start"===t?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}}class be extends J{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:"SizeExceedsPaddingSizeError"})}}class ge extends J{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} is expected to be ${t} ${n} long, but is ${e} ${n} long.`,{name:"InvalidBytesLengthError"})}}function we(e,{dir:t,size:n=32}={}){return"string"==typeof e?ve(e,{dir:t,size:n}):function(e,{dir:t,size:n=32}={}){if(null===n)return e;if(e.length>n)throw new be({size:e.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let s=0;s<n;s++){const i="right"===t;r[i?s:n-s-1]=e[i?s:e.length-s-1]}return r}(e,{dir:t,size:n})}function ve(e,{dir:t,size:n=32}={}){if(null===n)return e;const r=e.replace("0x","");if(r.length>2*n)throw new be({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r["right"===t?"padEnd":"padStart"](2*n,"0")}`}class xe extends J{constructor({max:e,min:t,signed:n,size:r,value:s}){super(`Number "${s}" is not in safe ${r?`${8*r}-bit ${n?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}}class Ie extends J{constructor(e){super(`Bytes value "${e}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`,{name:"InvalidBytesBooleanError"})}}class Pe extends J{constructor(e){super(`Hex value "${e}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`,{name:"InvalidHexBooleanError"})}}class ze extends J{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function Ee(e,{dir:t="left"}={}){let n="string"==typeof e?e.replace("0x",""):e,r=0;for(let e=0;e<n.length-1&&"0"===n["left"===t?e:n.length-e-1].toString();e++)r++;return n="left"===t?n.slice(r):n.slice(0,n.length-r),"string"==typeof e?(1===n.length&&"right"===t&&(n=`${n}0`),`0x${n.length%2==1?`0${n}`:n}`):n}function Ae(e,{size:t}){if(H(e)>t)throw new ze({givenSize:H(e),maxSize:t})}function ke(e,t={}){const{signed:n}=t;t.size&&Ae(e,{size:t.size});const r=BigInt(e);if(!n)return r;const s=(e.length-2)/2;return r<=(1n<<8n*BigInt(s)-1n)-1n?r:r-BigInt(`0x${"f".padStart(2*s,"f")}`)-1n}function Me(e,t={}){return Number(ke(e,t))}const $e=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function Oe(e,t={}){return"number"==typeof e||"bigint"==typeof e?Ne(e,t):"string"==typeof e?_e(e,t):"boolean"==typeof e?je(e,t):Se(e,t)}function je(e,t={}){const n=`0x${Number(e)}`;return"number"==typeof t.size?(Ae(n,{size:t.size}),we(n,{size:t.size})):n}function Se(e,t={}){let n="";for(let t=0;t<e.length;t++)n+=$e[e[t]];const r=`0x${n}`;return"number"==typeof t.size?(Ae(r,{size:t.size}),we(r,{dir:"right",size:t.size})):r}function Ne(e,t={}){const{signed:n,size:r}=t,s=BigInt(e);let i;r?i=n?(1n<<8n*BigInt(r)-1n)-1n:2n**(8n*BigInt(r))-1n:"number"==typeof e&&(i=BigInt(Number.MAX_SAFE_INTEGER));const a="bigint"==typeof i&&n?-i-1n:0;if(i&&s>i||s<a){const t="bigint"==typeof e?"n":"";throw new xe({max:i?`${i}${t}`:void 0,min:`${a}${t}`,signed:n,size:r,value:`${e}${t}`})}const o=`0x${(n&&s<0?(1n<<BigInt(8*r))+BigInt(s):s).toString(16)}`;return r?we(o,{size:r}):o}const Te=new TextEncoder;function _e(e,t={}){return Se(Te.encode(e),t)}const Re=new TextEncoder;function Ce(e,t={}){return"number"==typeof e||"bigint"==typeof e?function(e,t){const n=Ne(e,t);return Ue(n)}(e,t):"boolean"==typeof e?function(e,t={}){const n=new Uint8Array(1);if(n[0]=Number(e),"number"==typeof t.size)return Ae(n,{size:t.size}),we(n,{size:t.size});return n}(e,t):Z(e)?Ue(e,t):qe(e,t)}const Be={zero:48,nine:57,A:65,F:70,a:97,f:102};function De(e){return e>=Be.zero&&e<=Be.nine?e-Be.zero:e>=Be.A&&e<=Be.F?e-(Be.A-10):e>=Be.a&&e<=Be.f?e-(Be.a-10):void 0}function Ue(e,t={}){let n=e;t.size&&(Ae(n,{size:t.size}),n=we(n,{dir:"right",size:t.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const s=r.length/2,i=new Uint8Array(s);for(let e=0,t=0;e<s;e++){const n=De(r.charCodeAt(t++)),s=De(r.charCodeAt(t++));if(void 0===n||void 0===s)throw new J(`Invalid byte sequence ("${r[t-2]}${r[t-1]}" in "${r}").`);i[e]=16*n+s}return i}function qe(e,t={}){const n=Re.encode(e);return"number"==typeof t.size?(Ae(n,{size:t.size}),we(n,{dir:"right",size:t.size})):n}const Le=BigInt(2**32-1),Fe=BigInt(32);function Ke(e,t=!1){return t?{h:Number(e&Le),l:Number(e>>Fe&Le)}:{h:0|Number(e>>Fe&Le),l:0|Number(e&Le)}}function Ge(e,t=!1){const n=e.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let i=0;i<n;i++){const{h:n,l:a}=Ke(e[i],t);[r[i],s[i]]=[n,a]}return[r,s]}const Ve=(e,t,n)=>e>>>n,Ze=(e,t,n)=>e<<32-n|t>>>n,He=(e,t,n)=>e>>>n|t<<32-n,We=(e,t,n)=>e<<32-n|t>>>n,Ye=(e,t,n)=>e<<64-n|t>>>n-32,Qe=(e,t,n)=>e>>>n-32|t<<64-n;function Je(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:0|s}}const Xe=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),et=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,tt=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),nt=(e,t,n,r,s)=>t+n+r+s+(e/2**32|0)|0,rt=(e,t,n,r,s)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(s>>>0),st=(e,t,n,r,s,i)=>t+n+r+s+i+(e/2**32|0)|0,it="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function at(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function ot(e,...t){if(!((n=e)instanceof Uint8Array||ArrayBuffer.isView(n)&&"Uint8Array"===n.constructor.name))throw new Error("Uint8Array expected");var n;if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function ct(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 ut(e,t){ot(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function dt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function lt(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ft(e,t){return e<<32-t|e>>>t}const pt=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])()?e=>e:function(e){for(let n=0;n<e.length;n++)e[n]=(t=e[n])<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;var t;return e};function ht(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e)),ot(e),e}class mt{}function yt(e){const t=t=>e().update(ht(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function bt(e=32){if(it&&"function"==typeof it.getRandomValues)return it.getRandomValues(new Uint8Array(e));if(it&&"function"==typeof it.randomBytes)return Uint8Array.from(it.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}const gt=BigInt(0),wt=BigInt(1),vt=BigInt(2),xt=BigInt(7),It=BigInt(256),Pt=BigInt(113),zt=[],Et=[],At=[];for(let e=0,t=wt,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],zt.push(2*(5*r+n)),Et.push((e+1)*(e+2)/2%64);let s=gt;for(let e=0;e<7;e++)t=(t<<wt^(t>>xt)*Pt)%It,t&vt&&(s^=wt<<(wt<<BigInt(e))-wt);At.push(s)}const kt=Ge(At,!0),Mt=kt[0],$t=kt[1],Ot=(e,t,n)=>n>32?((e,t,n)=>t<<n-32|e>>>64-n)(e,t,n):((e,t,n)=>e<<n|t>>>32-n)(e,t,n),jt=(e,t,n)=>n>32?((e,t,n)=>e<<n-32|t>>>64-n)(e,t,n):((e,t,n)=>t<<n|e>>>32-n)(e,t,n);class St extends mt{constructor(e,t,n,r=!1,s=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=s,at(n),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");var i;this.state=new Uint8Array(200),this.state32=(i=this.state,new Uint32Array(i.buffer,i.byteOffset,Math.floor(i.byteLength/4)))}clone(){return this._cloneInto()}keccak(){pt(this.state32),function(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)n[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const r=(t+8)%10,s=(t+2)%10,i=n[s],a=n[s+1],o=Ot(i,a,1)^n[r],c=jt(i,a,1)^n[r+1];for(let n=0;n<50;n+=10)e[t+n]^=o,e[t+n+1]^=c}let t=e[2],s=e[3];for(let n=0;n<24;n++){const r=Et[n],i=Ot(t,s,r),a=jt(t,s,r),o=zt[n];t=e[o],s=e[o+1],e[o]=i,e[o+1]=a}for(let t=0;t<50;t+=10){for(let r=0;r<10;r++)n[r]=e[t+r];for(let r=0;r<10;r++)e[t+r]^=~n[(r+2)%10]&n[(r+4)%10]}e[0]^=Mt[r],e[1]^=$t[r]}dt(n)}(this.state32,this.rounds),pt(this.state32),this.posOut=0,this.pos=0}update(e){ct(this),ot(e=ht(e));const{blockLen:t,state:n}=this,r=e.length;for(let s=0;s<r;){const i=Math.min(t-this.pos,r-s);for(let t=0;t<i;t++)n[this.pos++]^=e[s++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,0!=(128&t)&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){ct(this,!1),ot(e),this.finish();const t=this.state,{blockLen:n}=this;for(let r=0,s=e.length;r<s;){this.posOut>=n&&this.keccak();const i=Math.min(n-this.posOut,s-r);e.set(t.subarray(this.posOut,this.posOut+i),r),this.posOut+=i,r+=i}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return at(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(ut(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,dt(this.state)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:r,rounds:s,enableXOF:i}=this;return e||(e=new St(t,n,r,i,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=n,e.outputLen=r,e.enableXOF=i,e.destroyed=this.destroyed,e}}const Nt=(()=>{return e=1,t=136,n=32,yt((()=>new St(t,e,n)));var e,t,n})();function Tt(e,t){const n=t||"hex",r=Nt(Z(e,{strict:!1})?Ce(e):e);return"bytes"===n?r:Oe(r)}const _t=e=>Tt(Ce(e));const Rt=e=>{var t;return function(e){let t=!0,n="",r=0,s="",i=!1;for(let a=0;a<e.length;a++){const o=e[a];if(["(",")",","].includes(o)&&(t=!0),"("===o&&r++,")"===o&&r--,t)if(0!==r)" "!==o?(s+=o,n+=o):","!==e[a-1]&&","!==n&&",("!==n&&(n="",t=!1);else if(" "===o&&["event","function",""].includes(s))s="";else if(s+=o,")"===o){i=!0;break}}if(!i)throw new J("Unable to normalize signature.");return s}("string"==typeof e?e:"function"===(t=e).type?`function ${t.name}(${c(t.inputs)})${t.stateMutability&&"nonpayable"!==t.stateMutability?` ${t.stateMutability}`:""}${t.outputs?.length?` returns (${c(t.outputs)})`:""}`:"event"===t.type?`event ${t.name}(${c(t.inputs)})`:"error"===t.type?`error ${t.name}(${c(t.inputs)})`:"constructor"===t.type?`constructor(${c(t.inputs)})${"payable"===t.stateMutability?" payable":""}`:"fallback"===t.type?"fallback() external"+("payable"===t.stateMutability?" payable":""):"receive() external payable")};function Ct(e){return t=Rt(e),_t(t);var t}const Bt=Ct;class Dt extends J{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class Ut extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&void 0!==t&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const e=this.keys().next().value;e&&this.delete(e)}return this}}const qt=new Ut(8192);function Lt(e,t){if(qt.has(`${e}.${t}`))return qt.get(`${e}.${t}`);const n=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),r=Tt(qe(n),"bytes"),s=(t?n.substring(`${t}0x`.length):n).split("");for(let e=0;e<40;e+=2)r[e>>1]>>4>=8&&s[e]&&(s[e]=s[e].toUpperCase()),(15&r[e>>1])>=8&&s[e+1]&&(s[e+1]=s[e+1].toUpperCase());const i=`0x${s.join("")}`;return qt.set(`${e}.${t}`,i),i}function Ft(e,t){if(!Vt(e,{strict:!1}))throw new Dt({address:e});return Lt(e,t)}const Kt=/^0x[a-fA-F0-9]{40}$/,Gt=new Ut(8192);function Vt(e,t){const{strict:n=!0}=t??{},r=`${e}.${n}`;if(Gt.has(r))return Gt.get(r);const s=!(!Kt.test(e)||e.toLowerCase()!==e&&n&&Lt(e)!==e);return Gt.set(r,s),s}function Zt(e){return"string"==typeof e[0]?Ht(e):function(e){let t=0;for(const n of e)t+=n.length;const n=new Uint8Array(t);let r=0;for(const t of e)n.set(t,r),r+=t.length;return n}(e)}function Ht(e){return`0x${e.reduce(((e,t)=>e+t.replace("0x","")),"")}`}function Wt(e,t,n,{strict:r}={}){return Z(e,{strict:!1})?Xt(e,t,n,{strict:r}):Jt(e,t,n,{strict:r})}function Yt(e,t){if("number"==typeof t&&t>0&&t>H(e)-1)throw new ye({offset:t,position:"start",size:H(e)})}function Qt(e,t,n){if("number"==typeof t&&"number"==typeof n&&H(e)!==n-t)throw new ye({offset:n,position:"end",size:H(e)})}function Jt(e,t,n,{strict:r}={}){Yt(e,t);const s=e.slice(t,n);return r&&Qt(s,t,n),s}function Xt(e,t,n,{strict:r}={}){Yt(e,t);const s=`0x${e.replace("0x","").slice(2*(t??0),2*(n??e.length))}`;return r&&Qt(s,t,n),s}const en=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,tn=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;function nn(e,t){if(e.length!==t.length)throw new ae({expectedLength:e.length,givenLength:t.length});const n=function({params:e,values:t}){const n=[];for(let r=0;r<e.length;r++)n.push(rn({param:e[r],value:t[r]}));return n}({params:e,values:t}),r=sn(n);return 0===r.length?"0x":r}function rn({param:e,value:t}){const n=an(e.type);if(n){const[r,s]=n;return function(e,{length:t,param:n}){const r=null===t;if(!Array.isArray(e))throw new he(e);if(!r&&e.length!==t)throw new se({expectedLength:t,givenLength:e.length,type:`${n.type}[${t}]`});let s=!1;const i=[];for(let t=0;t<e.length;t++){const r=rn({param:n,value:e[t]});r.dynamic&&(s=!0),i.push(r)}if(r||s){const e=sn(i);if(r){const t=Ne(i.length,{size:32});return{dynamic:!0,encoded:i.length>0?Zt([t,e]):t}}if(s)return{dynamic:!0,encoded:e}}return{dynamic:!1,encoded:Zt(i.map((({encoded:e})=>e)))}}(t,{length:r,param:{...e,type:s}})}if("tuple"===e.type)return function(e,{param:t}){let n=!1;const r=[];for(let s=0;s<t.components.length;s++){const i=t.components[s],a=rn({param:i,value:e[Array.isArray(e)?s:i.name]});r.push(a),a.dynamic&&(n=!0)}return{dynamic:n,encoded:n?sn(r):Zt(r.map((({encoded:e})=>e)))}}(t,{param:e});if("address"===e.type)return function(e){if(!Vt(e))throw new Dt({address:e});return{dynamic:!1,encoded:ve(e.toLowerCase())}}(t);if("bool"===e.type)return function(e){if("boolean"!=typeof e)throw new J(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:ve(je(e))}}(t);if(e.type.startsWith("uint")||e.type.startsWith("int")){const n=e.type.startsWith("int"),[,,r="256"]=tn.exec(e.type)??[];return function(e,{signed:t,size:n=256}){if("number"==typeof n){const r=2n**(BigInt(n)-(t?1n:0n))-1n,s=t?-r-1n:0n;if(e>r||e<s)throw new xe({max:r.toString(),min:s.toString(),signed:t,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:Ne(e,{size:32,signed:t})}}(t,{signed:n,size:Number(r)})}if(e.type.startsWith("bytes"))return function(e,{param:t}){const[,n]=t.type.split("bytes"),r=H(e);if(!n){let t=e;return r%32!=0&&(t=ve(t,{dir:"right",size:32*Math.ceil((e.length-2)/2/32)})),{dynamic:!0,encoded:Zt([ve(Ne(r,{size:32})),t])}}if(r!==Number.parseInt(n,10))throw new ie({expectedSize:Number.parseInt(n,10),value:e});return{dynamic:!1,encoded:ve(e,{dir:"right"})}}(t,{param:e});if("string"===e.type)return function(e){const t=_e(e),n=Math.ceil(H(t)/32),r=[];for(let e=0;e<n;e++)r.push(ve(Wt(t,32*e,32*(e+1)),{dir:"right"}));return{dynamic:!0,encoded:Zt([ve(Ne(H(t),{size:32})),...r])}}(t);throw new fe(e.type,{docsPath:"/docs/contract/encodeAbiParameters"})}function sn(e){let t=0;for(let n=0;n<e.length;n++){const{dynamic:r,encoded:s}=e[n];t+=r?32:H(s)}const n=[],r=[];let s=0;for(let i=0;i<e.length;i++){const{dynamic:a,encoded:o}=e[i];a?(n.push(Ne(t+s,{size:32})),r.push(o),s+=H(o)):n.push(o)}return Zt([...n,...r])}function an(e){const t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}const on=e=>Wt(Ct(e),0,4);function cn(e){const{abi:t,args:n=[],name:r}=e,s=Z(r,{strict:!1}),i=t.filter((e=>s?"function"===e.type?on(e)===r:"event"===e.type&&Bt(e)===r:"name"in e&&e.name===r));if(0===i.length)return;if(1===i.length)return i[0];let a;for(const e of i){if(!("inputs"in e))continue;if(!n||0===n.length){if(!e.inputs||0===e.inputs.length)return e;continue}if(!e.inputs)continue;if(0===e.inputs.length)continue;if(e.inputs.length!==n.length)continue;const t=n.every(((t,n)=>{const r="inputs"in e&&e.inputs[n];return!!r&&un(t,r)}));if(t){if(a&&"inputs"in a&&a.inputs){const t=dn(e.inputs,a.inputs,n);if(t)throw new de({abiItem:e,type:t[0]},{abiItem:a,type:t[1]})}a=e}}return a||i[0]}function un(e,t){const n=typeof e,r=t.type;switch(r){case"address":return Vt(e,{strict:!1});case"bool":return"boolean"===n;case"function":case"string":return"string"===n;default:return"tuple"===r&&"components"in t?Object.values(t.components).every(((t,n)=>un(Object.values(e)[n],t))):/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(r)?"number"===n||"bigint"===n:/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(r)?"string"===n||e instanceof Uint8Array:!!/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(r)&&(Array.isArray(e)&&e.every((e=>un(e,{...t,type:r.replace(/(\[[0-9]{0,}\])$/,"")}))))}}function dn(e,t,n){for(const r in e){const s=e[r],i=t[r];if("tuple"===s.type&&"tuple"===i.type&&"components"in s&&"components"in i)return dn(s.components,i.components,n[r]);const a=[s.type,i.type];if(!(!a.includes("address")||!a.includes("bytes20"))||(a.includes("address")&&a.includes("string")||!(!a.includes("address")||!a.includes("bytes")))&&Vt(n[r],{strict:!1}))return a}}function ln(e){return"string"==typeof e?{address:e,type:"json-rpc"}:e}const fn="/docs/contract/encodeFunctionData";function pn(e){const{args:t}=e,{abi:n,functionName:r}=1===e.abi.length&&e.functionName?.startsWith("0x")?e:function(e){const{abi:t,args:n,functionName:r}=e;let s=t[0];if(r){const e=cn({abi:t,args:n,name:r});if(!e)throw new ce(r,{docsPath:fn});s=e}if("function"!==s.type)throw new ce(void 0,{docsPath:fn});return{abi:[s],functionName:on(G(s))}}(e),s=n[0];return Ht([r,("inputs"in s&&s.inputs?nn(s.inputs,t??[]):void 0)??"0x"])}const hn={1:"An `assert` condition failed.",17:"Arithmetic operation resulted in underflow or overflow.",18:"Division or modulo by zero (e.g. `5 / 0` or `23 % 0`).",33:"Attempted to convert to an invalid type.",34:"Attempted to access a storage byte array that is incorrectly encoded.",49:"Performed `.pop()` on an empty array",50:"Array index is out of bounds.",65:"Allocated too much memory or created an array which is too large.",81:"Attempted to call a zero-initialized variable of internal function type."},mn={inputs:[{name:"message",type:"string"}],name:"Error",type:"error"},yn={inputs:[{name:"reason",type:"uint256"}],name:"Panic",type:"error"};class bn extends J{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`,{name:"NegativeOffsetError"})}}class gn extends J{constructor({length:e,position:t}){super(`Position \`${t}\` is out of bounds (\`0 < position < ${e}\`).`,{name:"PositionOutOfBoundsError"})}}class wn extends J{constructor({count:e,limit:t}){super(`Recursive read limit of \`${t}\` exceeded (recursive read count: \`${e}\`).`,{name:"RecursiveReadLimitExceededError"})}}const vn={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new wn({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new gn({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new bn({offset:e});const t=this.position-e;this.assertPosition(t),this.position=t},getReadCount(e){return this.positionReadCount.get(e||this.position)||0},incrementPosition(e){if(e<0)throw new bn({offset:e});const t=this.position+e;this.assertPosition(t),this.position=t},inspectByte(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectBytes(e,t){const n=t??this.position;return this.assertPosition(n+e-1),this.bytes.subarray(n,n+e)},inspectUint8(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectUint16(e){const t=e??this.position;return this.assertPosition(t+1),this.dataView.getUint16(t)},inspectUint24(e){const t=e??this.position;return this.assertPosition(t+2),(this.dataView.getUint16(t)<<8)+this.dataView.getUint8(t+2)},inspectUint32(e){const t=e??this.position;return this.assertPosition(t+3),this.dataView.getUint32(t)},pushByte(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushBytes(e){this.assertPosition(this.position+e.length-1),this.bytes.set(e,this.position),this.position+=e.length},pushUint8(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushUint16(e){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,e),this.position+=2},pushUint24(e){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,e>>8),this.dataView.setUint8(this.position+2,255&e),this.position+=3},pushUint32(e){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,e),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const e=this.inspectByte();return this.position++,e},readBytes(e,t){this.assertReadLimit(),this._touch();const n=this.inspectBytes(e);return this.position+=t??e,n},readUint8(){this.assertReadLimit(),this._touch();const e=this.inspectUint8();return this.position+=1,e},readUint16(){this.assertReadLimit(),this._touch();const e=this.inspectUint16();return this.position+=2,e},readUint24(){this.assertReadLimit(),this._touch();const e=this.inspectUint24();return this.position+=3,e},readUint32(){this.assertReadLimit(),this._touch();const e=this.inspectUint32();return this.position+=4,e},get remaining(){return this.bytes.length-this.position},setPosition(e){const t=this.position;return this.assertPosition(e),this.position=e,()=>this.position=t},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const e=this.getReadCount();this.positionReadCount.set(this.position,e+1),e>0&&this.recursiveReadCount++}};function xn(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(vn);return n.bytes=e,n.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=t,n}function In(e,t={}){void 0!==t.size&&Ae(e,{size:t.size});return ke(Se(e,t),t)}function Pn(e,t={}){let n=e;if(void 0!==t.size&&(Ae(n,{size:t.size}),n=Ee(n)),n.length>1||n[0]>1)throw new Ie(n);return Boolean(n[0])}function zn(e,t={}){void 0!==t.size&&Ae(e,{size:t.size});return Me(Se(e,t),t)}function En(e,t){const n="string"==typeof t?Ue(t):t,r=xn(n);if(0===H(n)&&e.length>0)throw new re;if(H(t)&&H(t)<32)throw new ne({data:"string"==typeof t?t:Se(t),params:e,size:H(t)});let s=0;const i=[];for(let t=0;t<e.length;++t){const n=e[t];r.setPosition(s);const[a,o]=An(r,n,{staticPosition:0});s+=o,i.push(a)}return i}function An(e,t,{staticPosition:n}){const r=an(t.type);if(r){const[s,i]=r;return function(e,t,{length:n,staticPosition:r}){if(!n){const n=r+zn(e.readBytes(Mn)),s=n+kn;e.setPosition(n);const i=zn(e.readBytes(kn)),a=$n(t);let o=0;const c=[];for(let n=0;n<i;++n){e.setPosition(s+(a?32*n:o));const[r,i]=An(e,t,{staticPosition:s});o+=i,c.push(r)}return e.setPosition(r+32),[c,32]}if($n(t)){const s=r+zn(e.readBytes(Mn)),i=[];for(let r=0;r<n;++r){e.setPosition(s+32*r);const[n]=An(e,t,{staticPosition:s});i.push(n)}return e.setPosition(r+32),[i,32]}let s=0;const i=[];for(let a=0;a<n;++a){const[n,a]=An(e,t,{staticPosition:r+s});s+=a,i.push(n)}return[i,s]}(e,{...t,type:i},{length:s,staticPosition:n})}if("tuple"===t.type)return function(e,t,{staticPosition:n}){const r=0===t.components.length||t.components.some((({name:e})=>!e)),s=r?[]:{};let i=0;if($n(t)){const a=n+zn(e.readBytes(Mn));for(let n=0;n<t.components.length;++n){const o=t.components[n];e.setPosition(a+i);const[c,u]=An(e,o,{staticPosition:a});i+=u,s[r?n:o?.name]=c}return e.setPosition(n+32),[s,32]}for(let a=0;a<t.components.length;++a){const o=t.components[a],[c,u]=An(e,o,{staticPosition:n});s[r?a:o?.name]=c,i+=u}return[s,i]}(e,t,{staticPosition:n});if("address"===t.type)return function(e){const t=e.readBytes(32);return[Lt(Se(Jt(t,-20))),32]}(e);if("bool"===t.type)return function(e){return[Pn(e.readBytes(32),{size:32}),32]}(e);if(t.type.startsWith("bytes"))return function(e,t,{staticPosition:n}){const[r,s]=t.type.split("bytes");if(!s){const t=zn(e.readBytes(32));e.setPosition(n+t);const r=zn(e.readBytes(32));if(0===r)return e.setPosition(n+32),["0x",32];const s=e.readBytes(r);return e.setPosition(n+32),[Se(s),32]}const i=Se(e.readBytes(Number.parseInt(s,10),32));return[i,32]}(e,t,{staticPosition:n});if(t.type.startsWith("uint")||t.type.startsWith("int"))return function(e,t){const n=t.type.startsWith("int"),r=Number.parseInt(t.type.split("int")[1]||"256",10),s=e.readBytes(32);return[r>48?In(s,{signed:n}):zn(s,{signed:n}),32]}(e,t);if("string"===t.type)return function(e,{staticPosition:t}){const n=zn(e.readBytes(32)),r=t+n;e.setPosition(r);const s=zn(e.readBytes(32));if(0===s)return e.setPosition(t+32),["",32];const i=e.readBytes(s,32),a=function(e,t={}){let n=e;return void 0!==t.size&&(Ae(n,{size:t.size}),n=Ee(n,{dir:"right"})),(new TextDecoder).decode(n)}(Ee(i));return e.setPosition(t+32),[a,32]}(e,{staticPosition:n});throw new pe(t.type,{docsPath:"/docs/contract/decodeAbiParameters"})}const kn=32,Mn=32;function $n(e){const{type:t}=e;if("string"===t)return!0;if("bytes"===t)return!0;if(t.endsWith("[]"))return!0;if("tuple"===t)return e.components?.some($n);const n=an(e.type);return!(!n||!$n({...e,type:n[1]}))}function On(e){const{abi:t,data:n}=e,r=Wt(n,0,4);if("0x"===r)throw new re;const s=[...t||[],mn,yn].find((e=>"error"===e.type&&r===on(G(e))));if(!s)throw new oe(r,{docsPath:"/docs/contract/decodeErrorResult"});return{abiItem:s,args:"inputs"in s&&s.inputs&&s.inputs.length>0?En(s.inputs,Wt(n,4)):void 0,errorName:s.name}}const jn=(e,t,n)=>JSON.stringify(e,((e,n)=>{const r="bigint"==typeof n?n.toString():n;return"function"==typeof t?t(e,r):r}),n);function Sn({abiItem:e,args:t,includeFunctionName:n=!0,includeName:r=!1}){if("name"in e&&"inputs"in e&&e.inputs)return`${n?e.name:""}(${e.inputs.map(((e,n)=>`${r&&e.name?`${e.name}: `:""}${"object"==typeof t[n]?jn(t[n]):t[n]}`)).join(", ")})`}const Nn={gwei:9,wei:18},Tn={ether:-9,wei:9};function _n(e,t){let n=e.toString();const r=n.startsWith("-");r&&(n=n.slice(1)),n=n.padStart(t,"0");let[s,i]=[n.slice(0,n.length-t),n.slice(n.length-t)];return i=i.replace(/(0+)$/,""),`${r?"-":""}${s||"0"}${i?`.${i}`:""}`}function Rn(e,t="wei"){return _n(e,Nn[t])}function Cn(e,t="wei"){return _n(e,Tn[t])}class Bn extends J{constructor({address:e}){super(`State for account "${e}" is set multiple times.`,{name:"AccountStateConflictError"})}}class Dn extends J{constructor(){super("state and stateDiff are set on the same account.",{name:"StateAssignmentConflictError"})}}function Un(e){return e.reduce(((e,{slot:t,value:n})=>`${e} ${t}: ${n}\n`),"")}function qn(e){const t=Object.entries(e).map((([e,t])=>void 0===t||!1===t?null:[e,t])).filter(Boolean),n=t.reduce(((e,[t])=>Math.max(e,t.length)),0);return t.map((([e,t])=>` ${`${e}:`.padEnd(n+1)} ${t}`)).join("\n")}class Ln extends J{constructor(){super(["Cannot specify both a `gasPrice` and a `maxFeePerGas`/`maxPriorityFeePerGas`.","Use `maxFeePerGas`/`maxPriorityFeePerGas` for EIP-1559 compatible networks, and `gasPrice` for others."].join("\n"),{name:"FeeConflictError"})}}class Fn extends J{constructor({v:e}){super(`Invalid \`v\` value "${e}". Expected 27 or 28.`,{name:"InvalidLegacyVError"})}}class Kn extends J{constructor({transaction:e}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",qn(e),"}","","To infer the type, either provide:","- a `type` to the Transaction, or","- an EIP-1559 Transaction with `maxFeePerGas`, or","- an EIP-2930 Transaction with `gasPrice` & `accessList`, or","- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or","- an EIP-7702 Transaction with `authorizationList`, or","- a Legacy Transaction with `gasPrice`"],name:"InvalidSerializableTransactionError"})}}class Gn extends J{constructor({storageKey:e}){super(`Size for storage key "${e}" is invalid. Expected 32 bytes. Got ${Math.floor((e.length-2)/2)} bytes.`,{name:"InvalidStorageKeySizeError"})}}const Vn=e=>e;class Zn extends J{constructor(e,{account:t,docsPath:n,chain:r,data:s,gas:i,gasPrice:a,maxFeePerGas:o,maxPriorityFeePerGas:c,nonce:u,to:d,value:l,stateOverride:f}){const p=t?ln(t):void 0;let h=qn({from:p?.address,to:d,value:void 0!==l&&`${Rn(l)} ${r?.nativeCurrency?.symbol||"ETH"}`,data:s,gas:i,gasPrice:void 0!==a&&`${Cn(a)} gwei`,maxFeePerGas:void 0!==o&&`${Cn(o)} gwei`,maxPriorityFeePerGas:void 0!==c&&`${Cn(c)} gwei`,nonce:u});f&&(h+=`\n${function(e){return e.reduce(((e,{address:t,...n})=>{let r=`${e} ${t}:\n`;return n.nonce&&(r+=` nonce: ${n.nonce}\n`),n.balance&&(r+=` balance: ${n.balance}\n`),n.code&&(r+=` code: ${n.code}\n`),n.state&&(r+=" state:\n",r+=Un(n.state)),n.stateDiff&&(r+=" stateDiff:\n",r+=Un(n.stateDiff)),r})," State Override:\n").slice(0,-1)}(f)}`),super(e.shortMessage,{cause:e,docsPath:n,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],"Raw Call Arguments:",h].filter(Boolean),name:"CallExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=e}}class Hn extends J{constructor(e,{abi:t,args:n,contractAddress:r,docsPath:s,functionName:i,sender:a}){const o=cn({abi:t,args:n,name:i}),c=o?Sn({abiItem:o,args:n,includeFunctionName:!1,includeName:!1}):void 0,u=qn({address:r&&r,function:o?G(o,{includeName:!0}):void 0,args:c&&"()"!==c&&`${[...Array(i?.length??0).keys()].map((()=>" ")).join("")}${c}`,sender:a});super(e.shortMessage||`An unknown error occurred while executing the contract function "${i}".`,{cause:e,docsPath:s,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],u&&"Contract Call:",u].filter(Boolean),name:"ContractFunctionExecutionError"}),Object.defineProperty(this,"abi",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"args",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"contractAddress",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"formattedArgs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"functionName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sender",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abi=t,this.args=n,this.cause=e,this.contractAddress=r,this.functionName=i,this.sender=a}}class Wn extends J{constructor({abi:e,data:t,functionName:n,message:r}){let s,i,a,o,c;if(t&&"0x"!==t)try{i=On({abi:e,data:t});const{abiItem:n,errorName:r,args:s}=i;if("Error"===r)o=s[0];else if("Panic"===r){const[e]=s;o=hn[e]}else{const e=n?G(n,{includeName:!0}):void 0,t=n&&s?Sn({abiItem:n,args:s,includeFunctionName:!1,includeName:!1}):void 0;a=[e?`Error: ${e}`:"",t&&"()"!==t?` ${[...Array(r?.length??0).keys()].map((()=>" ")).join("")}${t}`:""]}}catch(e){s=e}else r&&(o=r);s instanceof oe&&(c=s.signature,a=[`Unable to decode signature "${c}" as it was not found on the provided ABI.`,"Make sure you are using the correct ABI and that the error exists on it.",`You can look up the decoded signature here: https://openchain.xyz/signatures?query=${c}.`]),super(o&&"execution reverted"!==o||c?[`The contract function "${n}" reverted with the following ${c?"signature":"reason"}:`,o||c].join("\n"):`The contract function "${n}" reverted.`,{cause:s,metaMessages:a,name:"ContractFunctionRevertedError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"raw",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reason",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=i,this.raw=t,this.reason=o,this.signature=c}}class Yn extends J{constructor({functionName:e}){super(`The contract function "${e}" returned no data ("0x").`,{metaMessages:["This could be due to any of the following:",` - The contract does not have the function "${e}",`," - The parameters passed to the contract function may be invalid, or"," - The address is not a contract."],name:"ContractFunctionZeroDataError"})}}class Qn extends J{constructor({factory:e}){super("Deployment for counterfactual contract call failed"+(e?` for factory "${e}".`:""),{metaMessages:["Please ensure:","- The `factory` is a valid contract deployment factory (ie. Create2 Factory, ERC-4337 Factory, etc).","- The `factoryData` is a valid encoded function call for contract deployment function on the factory."],name:"CounterfactualDeploymentFailedError"})}}class Jn extends J{constructor({data:e,message:t}){super(t||"",{name:"RawContractError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=e}}class Xn extends J{constructor({body:e,cause:t,details:n,headers:r,status:s,url:i}){super("HTTP request failed.",{cause:t,details:n,metaMessages:[s&&`Status: ${s}`,`URL: ${i}`,e&&`Request body: ${jn(e)}`].filter(Boolean),name:"HttpRequestError"}),Object.defineProperty(this,"body",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"url",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.body=e,this.headers=r,this.status=s,this.url=i}}class er extends J{constructor({body:e,error:t,url:n}){super("RPC Request failed.",{cause:t,details:t.message,metaMessages:[`URL: ${n}`,`Request body: ${jn(e)}`],name:"RpcRequestError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=t.code,this.data=t.data}}class tr extends J{constructor({body:e,url:t}){super("The request took too long to respond.",{details:"The request timed out.",metaMessages:[`URL: ${t}`,`Request body: ${jn(e)}`],name:"TimeoutError"})}}class nr extends J{constructor(e,{code:t,docsPath:n,metaMessages:r,name:s,shortMessage:i}){super(i,{cause:e,docsPath:n,metaMessages:r||e?.metaMessages,name:s||"RpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=s||e.name,this.code=e instanceof er?e.code:t??-1}}class rr extends nr{constructor(e,t){super(e,t),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=t.data}}class sr extends nr{constructor(e){super(e,{code:sr.code,name:"ParseRpcError",shortMessage:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."})}}Object.defineProperty(sr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class ir extends nr{constructor(e){super(e,{code:ir.code,name:"InvalidRequestRpcError",shortMessage:"JSON is not a valid request object."})}}Object.defineProperty(ir,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class ar extends nr{constructor(e,{method:t}={}){super(e,{code:ar.code,name:"MethodNotFoundRpcError",shortMessage:`The method${t?` "${t}"`:""} does not exist / is not available.`})}}Object.defineProperty(ar,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class or extends nr{constructor(e){super(e,{code:or.code,name:"InvalidParamsRpcError",shortMessage:["Invalid parameters were provided to the RPC method.","Double check you have provided the correct parameters."].join("\n")})}}Object.defineProperty(or,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class cr extends nr{constructor(e){super(e,{code:cr.code,name:"InternalRpcError",shortMessage:"An internal error was received."})}}Object.defineProperty(cr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class ur extends nr{constructor(e){super(e,{code:ur.code,name:"InvalidInputRpcError",shortMessage:["Missing or invalid parameters.","Double check you have provided the correct parameters."].join("\n")})}}Object.defineProperty(ur,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class dr extends nr{constructor(e){super(e,{code:dr.code,name:"ResourceNotFoundRpcError",shortMessage:"Requested resource not found."}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ResourceNotFoundRpcError"})}}Object.defineProperty(dr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class lr extends nr{constructor(e){super(e,{code:lr.code,name:"ResourceUnavailableRpcError",shortMessage:"Requested resource not available."})}}Object.defineProperty(lr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class fr extends nr{constructor(e){super(e,{code:fr.code,name:"TransactionRejectedRpcError",shortMessage:"Transaction creation failed."})}}Object.defineProperty(fr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class pr extends nr{constructor(e,{method:t}={}){super(e,{code:pr.code,name:"MethodNotSupportedRpcError",shortMessage:`Method${t?` "${t}"`:""} is not supported.`})}}Object.defineProperty(pr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class hr extends nr{constructor(e){super(e,{code:hr.code,name:"LimitExceededRpcError",shortMessage:"Request exceeds defined limit."})}}Object.defineProperty(hr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class mr extends nr{constructor(e){super(e,{code:mr.code,name:"JsonRpcVersionUnsupportedError",shortMessage:"Version of JSON-RPC protocol is not supported."})}}Object.defineProperty(mr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});class yr extends rr{constructor(e){super(e,{code:yr.code,name:"UserRejectedRequestError",shortMessage:"User rejected the request."})}}Object.defineProperty(yr,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class br extends rr{constructor(e){super(e,{code:br.code,name:"UnauthorizedProviderError",shortMessage:"The requested method and/or account has not been authorized by the user."})}}Object.defineProperty(br,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class gr extends rr{constructor(e,{method:t}={}){super(e,{code:gr.code,name:"UnsupportedProviderMethodError",shortMessage:`The Provider does not support the requested method${t?` " ${t}"`:""}.`})}}Object.defineProperty(gr,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class wr extends rr{constructor(e){super(e,{code:wr.code,name:"ProviderDisconnectedError",shortMessage:"The Provider is disconnected from all chains."})}}Object.defineProperty(wr,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});class vr extends rr{constructor(e){super(e,{code:vr.code,name:"ChainDisconnectedError",shortMessage:"The Provider is not connected to the requested chain."})}}Object.defineProperty(vr,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});class xr extends rr{constructor(e){super(e,{code:xr.code,name:"SwitchChainError",shortMessage:"An error occurred when attempting to switch chain."})}}Object.defineProperty(xr,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902});class Ir extends rr{constructor(e){super(e,{code:Ir.code,name:"UnsupportedNonOptionalCapabilityError",shortMessage:"This Wallet does not support a capability that was not marked as optional."})}}Object.defineProperty(Ir,"code",{enumerable:!0,configurable:!0,writable:!0,value:5700});class Pr extends rr{constructor(e){super(e,{code:Pr.code,name:"UnsupportedChainIdError",shortMessage:"This Wallet does not support the requested chain ID."})}}Object.defineProperty(Pr,"code",{enumerable:!0,configurable:!0,writable:!0,value:5710});class zr extends rr{constructor(e){super(e,{code:zr.code,name:"DuplicateIdError",shortMessage:"There is already a bundle submitted with this ID."})}}Object.defineProperty(zr,"code",{enumerable:!0,configurable:!0,writable:!0,value:5720});class Er extends rr{constructor(e){super(e,{code:Er.code,name:"UnknownBundleIdError",shortMessage:"This bundle id is unknown / has not been submitted"})}}Object.defineProperty(Er,"code",{enumerable:!0,configurable:!0,writable:!0,value:5730});class Ar extends rr{constructor(e){super(e,{code:Ar.code,name:"BundleTooLargeError",shortMessage:"The call bundle is too large for the Wallet to process."})}}Object.defineProperty(Ar,"code",{enumerable:!0,configurable:!0,writable:!0,value:5740});class kr extends rr{constructor(e){super(e,{code:kr.code,name:"AtomicReadyWalletRejectedUpgradeError",shortMessage:"The Wallet can support atomicity after an upgrade, but the user rejected the upgrade."})}}Object.defineProperty(kr,"code",{enumerable:!0,configurable:!0,writable:!0,value:5750});class Mr extends rr{constructor(e){super(e,{code:Mr.code,name:"AtomicityNotSupportedError",shortMessage:"The wallet does not support atomic execution but the request requires it."})}}Object.defineProperty(Mr,"code",{enumerable:!0,configurable:!0,writable:!0,value:5760});class $r extends nr{constructor(e){super(e,{name:"UnknownRpcError",shortMessage:"An unknown RPC error occurred."})}}const Or=3;function jr(e,{abi:t,address:n,args:r,docsPath:s,functionName:i,sender:a}){const o=e instanceof Jn?e:e instanceof J?e.walk((e=>"data"in e))||e.walk():{},{code:c,data:u,details:d,message:l,shortMessage:f}=o,p=e instanceof re?new Yn({functionName:i}):[Or,cr.code].includes(c)&&(u||d||l||f)?new Wn({abi:t,data:"object"==typeof u?u.data:u,functionName:i,message:o instanceof er?d:f??l}):e;return new Hn(p,{abi:t,args:r,contractAddress:n,docsPath:s,functionName:i,sender:a})}function Sr(e){if(0===e||1===e)return e;if(27===e)return 0;if(28===e)return 1;throw new Error("Invalid yParityOrV value")}async function Nr({hash:e,signature:t}){return n=await async function({hash:e,signature:t}){const n=Z(e)?e:Oe(e),{secp256k1:r}=await Promise.resolve().then((function(){return Ed}));return`0x${(()=>{if("object"==typeof t&&"r"in t&&"s"in t){const{r:e,s:n,v:s,yParity:i}=t,a=Sr(Number(i??s));return new r.Signature(ke(e),ke(n)).addRecoveryBit(a)}const e=Z(t)?t:Oe(t);if(65!==H(e))throw new Error("invalid signature length");const n=Sr(Me(`0x${e.slice(130)}`));return r.Signature.fromCompact(e.substring(2,130)).addRecoveryBit(n)})().recoverPublicKey(n.substring(2)).toHex(!1)}`}({hash:e,signature:t}),Lt(`0x${Tt(`0x${n.substring(4)}`).substring(26)}`);var n}function Tr(e,t="hex"){const n=_r(e),r=xn(new Uint8Array(n.length));return n.encode(r),"hex"===t?Se(r.bytes):r.bytes}function _r(e){return Array.isArray(e)?function(e){const t=e.reduce(((e,t)=>e+t.length),0),n=Rr(t);return{length:t<=55?1+t:1+n+t,encode(r){t<=55?r.pushByte(192+t):(r.pushByte(247+n),1===n?r.pushUint8(t):2===n?r.pushUint16(t):3===n?r.pushUint24(t):r.pushUint32(t));for(const{encode:t}of e)t(r)}}}(e.map((e=>_r(e)))):function(e){const t="string"==typeof e?Ue(e):e,n=Rr(t.length),r=1===t.length&&t[0]<128?1:t.length<=55?1+t.length:1+n+t.length;return{length:r,encode(e){1===t.length&&t[0]<128?e.pushBytes(t):t.length<=55?(e.pushByte(128+t.length),e.pushBytes(t)):(e.pushByte(183+n),1===n?e.pushUint8(t.length):2===n?e.pushUint16(t.length):3===n?e.pushUint24(t.length):e.pushUint32(t.length),e.pushBytes(t))}}}(e)}function Rr(e){if(e<256)return 1;if(e<65536)return 2;if(e<2**24)return 3;if(e<2**32)return 4;throw new J("Length is too large.")}function Cr(e){const{chainId:t,nonce:n,to:r}=e,s=e.contractAddress??e.address,i=Tt(Ht(["0x05",Tr([t?Ne(t):"0x",s,n?Ne(n):"0x"])]));return"bytes"===r?Ue(i):i}class Br extends J{constructor({cause:e,message:t}={}){const n=t?.replace("execution reverted: ","")?.replace("execution reverted","");super(`Execution reverted ${n?`with reason: ${n}`:"for an unknown reason"}.`,{cause:e,name:"ExecutionRevertedError"})}}Object.defineProperty(Br,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(Br,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});class Dr extends J{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${Cn(t)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:e,name:"FeeCapTooHighError"})}}Object.defineProperty(Dr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});class Ur extends J{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${Cn(t)}`:""} gwei) cannot be lower than the block base fee.`,{cause:e,name:"FeeCapTooLowError"})}}Object.defineProperty(Ur,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/});class qr extends J{constructor({cause:e,nonce:t}={}){super(`Nonce provided for the transaction ${t?`(${t}) `:""}is higher than the next one expected.`,{cause:e,name:"NonceTooHighError"})}}Object.defineProperty(qr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class Lr extends J{constructor({cause:e,nonce:t}={}){super([`Nonce provided for the transaction ${t?`(${t}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join("\n"),{cause:e,name:"NonceTooLowError"})}}Object.defineProperty(Lr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});class Fr extends J{constructor({cause:e,nonce:t}={}){super(`Nonce provided for the transaction ${t?`(${t}) `:""}exceeds the maximum allowed nonce.`,{cause:e,name:"NonceMaxValueError"})}}Object.defineProperty(Fr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});class Kr extends J{constructor({cause:e}={}){super(["The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."].join("\n"),{cause:e,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}}Object.defineProperty(Kr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class Gr extends J{constructor({cause:e,gas:t}={}){super(`The amount of gas ${t?`(${t}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:e,name:"IntrinsicGasTooHighError"})}}Object.defineProperty(Gr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class Vr extends J{constructor({cause:e,gas:t}={}){super(`The amount of gas ${t?`(${t}) `:""}provided for the transaction is too low.`,{cause:e,name:"IntrinsicGasTooLowError"})}}Object.defineProperty(Vr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class Zr extends J{constructor({cause:e}){super("The transaction type is not supported for this chain.",{cause:e,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(Zr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class Hr extends J{constructor({cause:e,maxPriorityFeePerGas:t,maxFeePerGas:n}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${t?` = ${Cn(t)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n?` = ${Cn(n)} gwei`:""}).`].join("\n"),{cause:e,name:"TipAboveFeeCapError"})}}Object.defineProperty(Hr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max priority fee per gas higher than max fee per gas|tip higher than fee cap/});class Wr extends J{constructor({cause:e}){super(`An error occurred while executing: ${e?.shortMessage}`,{cause:e,name:"UnknownNodeError"})}}function Yr(e,{format:t}){if(!t)return{};const n={};return function t(r){const s=Object.keys(r);for(const i of s)i in e&&(n[i]=e[i]),r[i]&&"object"==typeof r[i]&&!Array.isArray(r[i])&&t(r[i])}(t(e||{})),n}function Qr(e,t){return({exclude:n,format:r})=>({exclude:n,format:e=>{const s=t(e);if(n)for(const e of n)delete s[e];return{...s,...r(e)}},type:e})}const Jr={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function Xr(e){const t={};return void 0!==e.authorizationList&&(t.authorizationList=e.authorizationList.map((e=>({address:e.address,r:e.r?Ne(BigInt(e.r)):e.r,s:e.s?Ne(BigInt(e.s)):e.s,chainId:Ne(e.chainId),nonce:Ne(e.nonce),...void 0!==e.yParity?{yParity:Ne(e.yParity)}:{},...void 0!==e.v&&void 0===e.yParity?{v:Ne(e.v)}:{}})))),void 0!==e.accessList&&(t.accessList=e.accessList),void 0!==e.blobVersionedHashes&&(t.blobVersionedHashes=e.blobVersionedHashes),void 0!==e.blobs&&("string"!=typeof e.blobs[0]?t.blobs=e.blobs.map((e=>Se(e))):t.blobs=e.blobs),void 0!==e.data&&(t.data=e.data),void 0!==e.from&&(t.from=e.from),void 0!==e.gas&&(t.gas=Ne(e.gas)),void 0!==e.gasPrice&&(t.gasPrice=Ne(e.gasPrice)),void 0!==e.maxFeePerBlobGas&&(t.maxFeePerBlobGas=Ne(e.maxFeePerBlobGas)),void 0!==e.maxFeePerGas&&(t.maxFeePerGas=Ne(e.maxFeePerGas)),void 0!==e.maxPriorityFeePerGas&&(t.maxPriorityFeePerGas=Ne(e.maxPriorityFeePerGas)),void 0!==e.nonce&&(t.nonce=Ne(e.nonce)),void 0!==e.to&&(t.to=e.to),void 0!==e.type&&(t.type=Jr[e.type]),void 0!==e.value&&(t.value=Ne(e.value)),t}function es(e){if(e&&0!==e.length)return e.reduce(((e,{slot:t,value:n})=>{if(66!==t.length)throw new ge({size:t.length,targetSize:66,type:"hex"});if(66!==n.length)throw new ge({size:n.length,targetSize:66,type:"hex"});return e[t]=n,e}),{})}function ts(e){const{balance:t,nonce:n,state:r,stateDiff:s,code:i}=e,a={};if(void 0!==i&&(a.code=i),void 0!==t&&(a.balance=Ne(t)),void 0!==n&&(a.nonce=Ne(n)),void 0!==r&&(a.state=es(r)),void 0!==s){if(a.state)throw new Dn;a.stateDiff=es(s)}return a}const ns=2n**256n-1n;const rs={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function ss(e){const t={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?Me(e.chainId):void 0,gas:e.gas?BigInt(e.gas):void 0,gasPrice:e.gasPrice?BigInt(e.gasPrice):void 0,maxFeePerBlobGas:e.maxFeePerBlobGas?BigInt(e.maxFeePerBlobGas):void 0,maxFeePerGas:e.maxFeePerGas?BigInt(e.maxFeePerGas):void 0,maxPriorityFeePerGas:e.maxPriorityFeePerGas?BigInt(e.maxPriorityFeePerGas):void 0,nonce:e.nonce?Me(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?rs[e.type]:void 0,typeHex:e.type?e.type:void 0,value:e.value?BigInt(e.value):void 0,v:e.v?BigInt(e.v):void 0};return e.authorizationList&&(t.authorizationList=e.authorizationList.map((e=>({address:e.address,chainId:Number(e.chainId),nonce:Number(e.nonce),r:e.r,s:e.s,yParity:Number(e.yParity)})))),t.yParity=(()=>{if(e.yParity)return Number(e.yParity);if("bigint"==typeof t.v){if(0n===t.v||27n===t.v)return 0;if(1n===t.v||28n===t.v)return 1;if(t.v>=35n)return t.v%2n===0n?1:0}})(),"legacy"===t.type&&(delete t.accessList,delete t.maxFeePerBlobGas,delete t.maxFeePerGas,delete t.maxPriorityFeePerGas,delete t.yParity),"eip2930"===t.type&&(delete t.maxFeePerBlobGas,delete t.maxFeePerGas,delete t.maxPriorityFeePerGas),"eip1559"===t.type&&delete t.maxFeePerBlobGas,t}const is=Qr("transaction",ss);function as(e){const t=(e.transactions??[]).map((e=>"string"==typeof e?e:ss(e)));return{...e,baseFeePerGas:e.baseFeePerGas?BigInt(e.baseFeePerGas):null,blobGasUsed:e.blobGasUsed?BigInt(e.blobGasUsed):void 0,difficulty:e.difficulty?BigInt(e.difficulty):void 0,excessBlobGas:e.excessBlobGas?BigInt(e.excessBlobGas):void 0,gasLimit:e.gasLimit?BigInt(e.gasLimit):void 0,gasUsed:e.gasUsed?BigInt(e.gasUsed):void 0,hash:e.hash?e.hash:null,logsBloom:e.logsBloom?e.logsBloom:null,nonce:e.nonce?e.nonce:null,number:e.number?BigInt(e.number):null,size:e.size?BigInt(e.size):void 0,timestamp:e.timestamp?BigInt(e.timestamp):void 0,transactions:t,totalDifficulty:e.totalDifficulty?BigInt(e.totalDifficulty):null}}const os=Qr("block",as);function cs(e){const{kzg:t}=e,n=e.to??("string"==typeof e.blobs[0]?"hex":"bytes"),r="string"==typeof e.blobs[0]?e.blobs.map((e=>Ue(e))):e.blobs,s=[];for(const e of r)s.push(Uint8Array.from(t.blobToKzgCommitment(e)));return"bytes"===n?s:s.map((e=>Se(e)))}function us(e){const{kzg:t}=e,n=e.to??("string"==typeof e.blobs[0]?"hex":"bytes"),r="string"==typeof e.blobs[0]?e.blobs.map((e=>Ue(e))):e.blobs,s="string"==typeof e.commitments[0]?e.commitments.map((e=>Ue(e))):e.commitments,i=[];for(let e=0;e<r.length;e++){const n=r[e],a=s[e];i.push(Uint8Array.from(t.computeBlobKzgProof(n,a)))}return"bytes"===n?i:i.map((e=>Se(e)))}function ds(e,t,n){return e&t^e&n^t&n}class ls extends mt{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=lt(this.buffer)}update(e){ct(this),ot(e=ht(e));const{view:t,buffer:n,blockLen:r}=this,s=e.length;for(let i=0;i<s;){const a=Math.min(r-this.pos,s-i);if(a!==r)n.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===r&&(this.process(t,0),this.pos=0);else{const t=lt(e);for(;r<=s-i;i+=r)this.process(t,i)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){ct(this),ut(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:s}=this;let{pos:i}=this;t[i++]=128,dt(this.buffer.subarray(i)),this.padOffset>r-i&&(this.process(n,0),i=0);for(let e=i;e<r;e++)t[e]=0;!function(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const s=BigInt(32),i=BigInt(4294967295),a=Number(n>>s&i),o=Number(n&i),c=r?4:0,u=r?0:4;e.setUint32(t+c,a,r),e.setUint32(t+u,o,r)}(n,r-8,BigInt(8*this.length),s),this.process(n,0);const a=lt(e),o=this.outputLen;if(o%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=o/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)a.setUint32(4*e,u[e],s)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:s,destroyed:i,pos:a}=this;return e.destroyed=i,e.finished=s,e.length=r,e.pos=a,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}}const fs=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ps=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),hs=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),ms=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ys=new Uint32Array(64);class bs extends ls{constructor(e=32){super(64,e,8,!1),this.A=0|fs[0],this.B=0|fs[1],this.C=0|fs[2],this.D=0|fs[3],this.E=0|fs[4],this.F=0|fs[5],this.G=0|fs[6],this.H=0|fs[7]}get(){const{A:e,B:t,C:n,D:r,E:s,F:i,G:a,H:o}=this;return[e,t,n,r,s,i,a,o]}set(e,t,n,r,s,i,a,o){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|s,this.F=0|i,this.G=0|a,this.H=0|o}process(e,t){for(let n=0;n<16;n++,t+=4)ys[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=ys[e-15],n=ys[e-2],r=ft(t,7)^ft(t,18)^t>>>3,s=ft(n,17)^ft(n,19)^n>>>10;ys[e]=s+ys[e-7]+r+ys[e-16]|0}let{A:n,B:r,C:s,D:i,E:a,F:o,G:c,H:u}=this;for(let e=0;e<64;e++){const t=u+(ft(a,6)^ft(a,11)^ft(a,25))+((d=a)&o^~d&c)+ms[e]+ys[e]|0,l=(ft(n,2)^ft(n,13)^ft(n,22))+ds(n,r,s)|0;u=c,c=o,o=a,a=i+t|0,i=s,s=r,r=n,n=t+l|0}var d;n=n+this.A|0,r=r+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,o=o+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(n,r,s,i,a,o,c,u)}roundClean(){dt(ys)}destroy(){this.set(0,0,0,0,0,0,0,0),dt(this.buffer)}}const gs=(()=>Ge(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((e=>BigInt(e)))))(),ws=(()=>gs[0])(),vs=(()=>gs[1])(),xs=new Uint32Array(80),Is=new Uint32Array(80);class Ps extends ls{constructor(e=64){super(128,e,16,!1),this.Ah=0|hs[0],this.Al=0|hs[1],this.Bh=0|hs[2],this.Bl=0|hs[3],this.Ch=0|hs[4],this.Cl=0|hs[5],this.Dh=0|hs[6],this.Dl=0|hs[7],this.Eh=0|hs[8],this.El=0|hs[9],this.Fh=0|hs[10],this.Fl=0|hs[11],this.Gh=0|hs[12],this.Gl=0|hs[13],this.Hh=0|hs[14],this.Hl=0|hs[15]}get(){const{Ah:e,Al:t,Bh:n,Bl:r,Ch:s,Cl:i,Dh:a,Dl:o,Eh:c,El:u,Fh:d,Fl:l,Gh:f,Gl:p,Hh:h,Hl:m}=this;return[e,t,n,r,s,i,a,o,c,u,d,l,f,p,h,m]}set(e,t,n,r,s,i,a,o,c,u,d,l,f,p,h,m){this.Ah=0|e,this.Al=0|t,this.Bh=0|n,this.Bl=0|r,this.Ch=0|s,this.Cl=0|i,this.Dh=0|a,this.Dl=0|o,this.Eh=0|c,this.El=0|u,this.Fh=0|d,this.Fl=0|l,this.Gh=0|f,this.Gl=0|p,this.Hh=0|h,this.Hl=0|m}process(e,t){for(let n=0;n<16;n++,t+=4)xs[n]=e.getUint32(t),Is[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|xs[e-15],n=0|Is[e-15],r=He(t,n,1)^He(t,n,8)^Ve(t,0,7),s=We(t,n,1)^We(t,n,8)^Ze(t,n,7),i=0|xs[e-2],a=0|Is[e-2],o=He(i,a,19)^Ye(i,a,61)^Ve(i,0,6),c=We(i,a,19)^Qe(i,a,61)^Ze(i,a,6),u=tt(s,c,Is[e-7],Is[e-16]),d=nt(u,r,o,xs[e-7],xs[e-16]);xs[e]=0|d,Is[e]=0|u}let{Ah:n,Al:r,Bh:s,Bl:i,Ch:a,Cl:o,Dh:c,Dl:u,Eh:d,El:l,Fh:f,Fl:p,Gh:h,Gl:m,Hh:y,Hl:b}=this;for(let e=0;e<80;e++){const t=He(d,l,14)^He(d,l,18)^Ye(d,l,41),g=We(d,l,14)^We(d,l,18)^Qe(d,l,41),w=d&f^~d&h,v=rt(b,g,l&p^~l&m,vs[e],Is[e]),x=st(v,y,t,w,ws[e],xs[e]),I=0|v,P=He(n,r,28)^Ye(n,r,34)^Ye(n,r,39),z=We(n,r,28)^Qe(n,r,34)^Qe(n,r,39),E=n&s^n&a^s&a,A=r&i^r&o^i&o;y=0|h,b=0|m,h=0|f,m=0|p,f=0|d,p=0|l,({h:d,l:l}=Je(0|c,0|u,0|x,0|I)),c=0|a,u=0|o,a=0|s,o=0|i,s=0|n,i=0|r;const k=Xe(I,z,A);n=et(k,x,P,E),r=0|k}({h:n,l:r}=Je(0|this.Ah,0|this.Al,0|n,0|r)),({h:s,l:i}=Je(0|this.Bh,0|this.Bl,0|s,0|i)),({h:a,l:o}=Je(0|this.Ch,0|this.Cl,0|a,0|o)),({h:c,l:u}=Je(0|this.Dh,0|this.Dl,0|c,0|u)),({h:d,l:l}=Je(0|this.Eh,0|this.El,0|d,0|l)),({h:f,l:p}=Je(0|this.Fh,0|this.Fl,0|f,0|p)),({h:h,l:m}=Je(0|this.Gh,0|this.Gl,0|h,0|m)),({h:y,l:b}=Je(0|this.Hh,0|this.Hl,0|y,0|b)),this.set(n,r,s,i,a,o,c,u,d,l,f,p,h,m,y,b)}roundClean(){dt(xs,Is)}destroy(){dt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class zs extends Ps{constructor(){super(48),this.Ah=0|ps[0],this.Al=0|ps[1],this.Bh=0|ps[2],this.Bl=0|ps[3],this.Ch=0|ps[4],this.Cl=0|ps[5],this.Dh=0|ps[6],this.Dl=0|ps[7],this.Eh=0|ps[8],this.El=0|ps[9],this.Fh=0|ps[10],this.Fl=0|ps[11],this.Gh=0|ps[12],this.Gl=0|ps[13],this.Hh=0|ps[14],this.Hl=0|ps[15]}}const Es=yt((()=>new bs)),As=yt((()=>new Ps)),ks=yt((()=>new zs)),Ms=Es;function $s(e){const{commitment:t,version:n=1}=e,r=e.to??("string"==typeof t?"hex":"bytes"),s=function(e,t){const n=t||"hex",r=Ms(Z(e,{strict:!1})?Ce(e):e);return"bytes"===n?r:Oe(r)}(t,"bytes");return s.set([n],0),"bytes"===r?s:Se(s)}const Os=32,js=4096,Ss=Os*js,Ns=6*Ss-1-1*js*6,Ts=1;class _s extends J{constructor({maxSize:e,size:t}){super("Blob size is too large.",{metaMessages:[`Max: ${e} bytes`,`Given: ${t} bytes`],name:"BlobSizeTooLargeError"})}}class Rs extends J{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}class Cs extends J{constructor({hash:e,size:t}){super(`Versioned hash "${e}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${t}`],name:"InvalidVersionedHashSizeError"})}}class Bs extends J{constructor({hash:e,version:t}){super(`Versioned hash "${e}" version is invalid.`,{metaMessages:[`Expected: ${Ts}`,`Received: ${t}`],name:"InvalidVersionedHashVersionError"})}}function Ds(e){const{data:t,kzg:n,to:r}=e,s=e.blobs??function(e){const t=e.to??("string"==typeof e.data?"hex":"bytes"),n="string"==typeof e.data?Ue(e.data):e.data,r=H(n);if(!r)throw new Rs;if(r>Ns)throw new _s({maxSize:Ns,size:r});const s=[];let i=!0,a=0;for(;i;){const e=xn(new Uint8Array(Ss));let t=0;for(;t<js;){const r=n.slice(a,a+(Os-1));if(e.pushByte(0),e.pushBytes(r),r.length<31){e.pushByte(128),i=!1;break}t++,a+=31}s.push(e)}return"bytes"===t?s.map((e=>e.bytes)):s.map((e=>Se(e.bytes)))}({data:t,to:r}),i=e.commitments??cs({blobs:s,kzg:n,to:r}),a=e.proofs??us({blobs:s,commitments:i,kzg:n,to:r}),o=[];for(let e=0;e<s.length;e++)o.push({blob:s[e],commitment:i[e],proof:a[e]});return o}function Us(e,t){if(!Vt(e,{strict:!1}))throw new Dt({address:e});if(!Vt(t,{strict:!1}))throw new Dt({address:t});return e.toLowerCase()===t.toLowerCase()}const qs="/docs/contract/decodeFunctionResult";function Ls(e){const{abi:t,args:n,functionName:r,data:s}=e;let i=t[0];if(r){const e=cn({abi:t,args:n,name:r});if(!e)throw new ce(r,{docsPath:qs});i=e}if("function"!==i.type)throw new ce(void 0,{docsPath:qs});if(!i.outputs)throw new ue(i.name,{docsPath:qs});const a=En(i.outputs,s);return a&&a.length>1?a:a&&1===a.length?a[0]:void 0}
2
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Fs=BigInt(0),Ks=BigInt(1);function Gs(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function Vs(e){if(!Gs(e))throw new Error("Uint8Array expected")}function Zs(e,t){if("boolean"!=typeof t)throw new Error(e+" boolean expected, got "+t)}function Hs(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function Ws(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?Fs:BigInt("0x"+e)}const Ys="function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex,Qs=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function Js(e){if(Vs(e),Ys)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=Qs[e[n]];return t}const Xs={_0:48,_9:57,A:65,F:70,a:97,f:102};function ei(e){return e>=Xs._0&&e<=Xs._9?e-Xs._0:e>=Xs.A&&e<=Xs.F?e-(Xs.A-10):e>=Xs.a&&e<=Xs.f?e-(Xs.a-10):void 0}function ti(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(Ys)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,s=0;t<n;t++,s+=2){const n=ei(e.charCodeAt(s)),i=ei(e.charCodeAt(s+1));if(void 0===n||void 0===i){const t=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+s)}r[t]=16*n+i}return r}function ni(e){return Ws(Js(e))}function ri(e){return Vs(e),Ws(Js(Uint8Array.from(e).reverse()))}function si(e,t){return ti(e.toString(16).padStart(2*t,"0"))}function ii(e,t){return si(e,t).reverse()}function ai(e,t,n){let r;if("string"==typeof t)try{r=ti(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!Gs(t))throw new Error(e+" must be hex string or Uint8Array");r=Uint8Array.from(t)}const s=r.length;if("number"==typeof n&&s!==n)throw new Error(e+" of length "+n+" expected, got "+s);return r}function oi(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];Vs(r),t+=r.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const s=e[t];n.set(s,r),r+=s.length}return n}function ci(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}const ui=e=>"bigint"==typeof e&&Fs<=e;function di(e,t,n){return ui(e)&&ui(t)&&ui(n)&&t<=e&&e<n}function li(e,t,n,r){if(!di(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}const fi=e=>(Ks<<BigInt(e))-Ks,pi=e=>new Uint8Array(e),hi=e=>Uint8Array.from(e);const mi={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||Gs(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)};function yi(e,t,n={}){const r=(t,n,r)=>{const s=mi[n];if("function"!=typeof s)throw new Error("invalid validator function");const i=e[t];if(!(r&&void 0===i||s(i,e)))throw new Error("param "+String(t)+" is invalid. Expected "+n+", got "+i)};for(const[e,n]of Object.entries(t))r(e,n,!1);for(const[e,t]of Object.entries(n))r(e,t,!0);return e}function bi(e){const t=new WeakMap;return(n,...r)=>{const s=t.get(n);if(void 0!==s)return s;const i=e(n,...r);return t.set(n,i),i}}class gi extends Error{constructor(e,t={}){const n=(()=>{if(t.cause instanceof gi){if(t.cause.details)return t.cause.details;if(t.cause.shortMessage)return t.cause.shortMessage}return t.cause&&"details"in t.cause&&"string"==typeof t.cause.details?t.cause.details:t.cause?.message?t.cause.message:t.details})(),r=t.cause instanceof gi&&t.cause.docsPath||t.docsPath,s=`https://oxlib.sh${r??""}`;super([e||"An error occurred.",...t.metaMessages?["",...t.metaMessages]:[],...n||r?["",n?`Details: ${n}`:void 0,r?`See: ${s}`:void 0]:[]].filter((e=>"string"==typeof e)).join("\n"),t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:"ox@0.1.1"}),this.cause=t.cause,this.details=n,this.docs=s,this.docsPath=r,this.shortMessage=e}walk(e){return wi(this,e)}}function wi(e,t){return t?.(e)?e:e&&"object"==typeof e&&"cause"in e&&e.cause?wi(e.cause,t):t?null:e}function vi(e,t){if(ji(e)>t)throw new Di({givenSize:ji(e),maxSize:t})}const xi={zero:48,nine:57,A:65,F:70,a:97,f:102};function Ii(e){return e>=xi.zero&&e<=xi.nine?e-xi.zero:e>=xi.A&&e<=xi.F?e-(xi.A-10):e>=xi.a&&e<=xi.f?e-(xi.a-10):void 0}function Pi(e,t={}){const{dir:n="left"}=t;let r=e,s=0;for(let e=0;e<r.length-1&&"0"===r["left"===n?e:r.length-e-1].toString();e++)s++;return r="left"===n?r.slice(s):r.slice(0,r.length-s),r}function zi(e,t){if(Ji(e)>t)throw new na({givenSize:Ji(e),maxSize:t})}function Ei(e,t={}){const{dir:n,size:r=32}=t;if(0===r)return e;const s=e.replace("0x","");if(s.length>2*r)throw new sa({size:Math.ceil(s.length/2),targetSize:r,type:"Hex"});return`0x${s["right"===n?"padEnd":"padStart"](2*r,"0")}`}const Ai=new TextDecoder,ki=new TextEncoder;function Mi(e){return e instanceof Uint8Array?e:"string"==typeof e?$i(e):function(e){return e instanceof Uint8Array?e:new Uint8Array(e)}(e)}function $i(e,t={}){const{size:n}=t;let r=e;n&&(zi(e,n),r=Yi(e,n));let s=r.slice(2);s.length%2&&(s=`0${s}`);const i=s.length/2,a=new Uint8Array(i);for(let e=0,t=0;e<i;e++){const n=Ii(s.charCodeAt(t++)),r=Ii(s.charCodeAt(t++));if(void 0===n||void 0===r)throw new gi(`Invalid byte sequence ("${s[t-2]}${s[t-1]}" in "${s}").`);a[e]=16*n+r}return a}function Oi(e,t={}){const{size:n}=t,r=ki.encode(e);return"number"==typeof n?(vi(r,n),function(e,t){return function(e,t={}){const{dir:n,size:r=32}=t;if(0===r)return e;if(e.length>r)throw new qi({size:e.length,targetSize:r,type:"Bytes"});const s=new Uint8Array(r);for(let t=0;t<r;t++){const i="right"===n;s[i?t:r-t-1]=e[i?t:e.length-t-1]}return s}(e,{dir:"right",size:t})}(r,n)):r}function ji(e){return e.length}function Si(e,t,n,r={}){const{strict:s}=r;!function(e,t){if("number"==typeof t&&t>0&&t>ji(e)-1)throw new Ui({offset:t,position:"start",size:ji(e)})}(e,t);const i=e.slice(t,n);return s&&function(e,t,n){if("number"==typeof t&&"number"==typeof n&&ji(e)!==n-t)throw new Ui({offset:n,position:"end",size:ji(e)})}(i,t,n),i}function Ni(e,t={}){const{size:n}=t;void 0!==n&&vi(e,n);return Xi(Vi(e,t),t)}function Ti(e,t={}){const{size:n}=t;let r=e;if(void 0!==n&&(vi(r,n),r=Ci(r)),r.length>1||r[0]>1)throw new Bi(r);return Boolean(r[0])}function _i(e,t={}){const{size:n}=t;void 0!==n&&vi(e,n);return ea(Vi(e,t),t)}function Ri(e,t={}){const{size:n}=t;let r=e;return void 0!==n&&(vi(r,n),r=Pi(r,{dir:"right"})),Ai.decode(r)}function Ci(e){return Pi(e,{dir:"left"})}class Bi extends gi{constructor(e){super(`Bytes value \`${e}\` is not a valid boolean.`,{metaMessages:["The bytes array must contain a single byte of either a `0` or `1` value."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.InvalidBytesBooleanError"})}}class Di extends gi{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed \`${t}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}}class Ui extends gi{constructor({offset:e,position:t,size:n}){super(`Slice ${"start"===t?"starting":"ending"} at offset \`${e}\` is out-of-bounds (size: \`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SliceOffsetOutOfBoundsError"})}}class qi extends gi{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeExceedsPaddingSizeError"})}}const Li=new TextEncoder,Fi=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function Ki(...e){return`0x${e.reduce(((e,t)=>e+t.replace("0x","")),"")}`}function Gi(e,t={}){const n=`0x${Number(e)}`;return"number"==typeof t.size?(zi(n,t.size),Wi(n,t.size)):n}function Vi(e,t={}){let n="";for(let t=0;t<e.length;t++)n+=Fi[e[t]];const r=`0x${n}`;return"number"==typeof t.size?(zi(r,t.size),Yi(r,t.size)):r}function Zi(e,t={}){const{signed:n,size:r}=t,s=BigInt(e);let i;r?i=n?(1n<<8n*BigInt(r)-1n)-1n:2n**(8n*BigInt(r))-1n:"number"==typeof e&&(i=BigInt(Number.MAX_SAFE_INTEGER));const a="bigint"==typeof i&&n?-i-1n:0;if(i&&s>i||s<a){const t="bigint"==typeof e?"n":"";throw new ta({max:i?`${i}${t}`:void 0,min:`${a}${t}`,signed:n,size:r,value:`${e}${t}`})}const o=`0x${(n&&s<0?(1n<<BigInt(8*r))+BigInt(s):s).toString(16)}`;return r?Wi(o,r):o}function Hi(e,t={}){return Vi(Li.encode(e),t)}function Wi(e,t){return Ei(e,{dir:"left",size:t})}function Yi(e,t){return Ei(e,{dir:"right",size:t})}function Qi(e,t,n,r={}){const{strict:s}=r;!function(e,t){if("number"==typeof t&&t>0&&t>Ji(e)-1)throw new ra({offset:t,position:"start",size:Ji(e)})}(e,t);const i=`0x${e.replace("0x","").slice(2*(t??0),2*(n??e.length))}`;return s&&function(e,t,n){if("number"==typeof t&&"number"==typeof n&&Ji(e)!==n-t)throw new ra({offset:n,position:"end",size:Ji(e)})}(i,t,n),i}function Ji(e){return Math.ceil((e.length-2)/2)}function Xi(e,t={}){const{signed:n}=t;t.size&&zi(e,t.size);const r=BigInt(e);if(!n)return r;const s=(e.length-2)/2,i=(1n<<8n*BigInt(s))-1n;return r<=i>>1n?r:r-i-1n}function ea(e,t={}){const{signed:n,size:r}=t;return Number(n||r?Xi(e,t):e)}class ta extends gi{constructor({max:e,min:t,signed:n,size:r,value:s}){super(`Number \`${s}\` is not in safe${r?` ${8*r}-bit`:""}${n?" signed":" unsigned"} integer range ${e?`(\`${t}\` to \`${e}\`)`:`(above \`${t}\`)`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.IntegerOutOfRangeError"})}}class na extends gi{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed \`${t}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeOverflowError"})}}class ra extends gi{constructor({offset:e,position:t,size:n}){super(`Slice ${"start"===t?"starting":"ending"} at offset \`${e}\` is out-of-bounds (size: \`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SliceOffsetOutOfBoundsError"})}}class sa extends gi{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}}function ia(e){return{address:e.address,amount:Zi(e.amount),index:Zi(e.index),validatorIndex:Zi(e.validatorIndex)}}const aa=[{inputs:[{components:[{name:"target",type:"address"},{name:"allowFailure",type:"bool"},{name:"callData",type:"bytes"}],name:"calls",type:"tuple[]"}],name:"aggregate3",outputs:[{components:[{name:"success",type:"bool"},{name:"returnData",type:"bytes"}],name:"returnData",type:"tuple[]"}],stateMutability:"view",type:"function"}],oa=[{name:"isValidSignature",type:"function",stateMutability:"view",inputs:[{name:"hash",type:"bytes32"},{name:"signature",type:"bytes"}],outputs:[{name:"",type:"bytes4"}]}],ca=[{inputs:[{name:"_signer",type:"address"},{name:"_hash",type:"bytes32"},{name:"_signature",type:"bytes"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[{name:"_signer",type:"address"},{name:"_hash",type:"bytes32"},{name:"_signature",type:"bytes"}],outputs:[{type:"bool"}],stateMutability:"nonpayable",type:"function",name:"isValidSig"}],ua="0x82ad56cb",da="0x608060405234801561001057600080fd5b5060405161018e38038061018e83398101604081905261002f91610124565b6000808351602085016000f59050803b61004857600080fd5b6000808351602085016000855af16040513d6000823e81610067573d81fd5b3d81f35b634e487b7160e01b600052604160045260246000fd5b600082601f83011261009257600080fd5b81516001600160401b038111156100ab576100ab61006b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156100d9576100d961006b565b6040528181528382016020018510156100f157600080fd5b60005b82811015610110576020818601810151838301820152016100f4565b506000918101602001919091529392505050565b6000806040838503121561013757600080fd5b82516001600160401b0381111561014d57600080fd5b61015985828601610081565b602085015190935090506001600160401b0381111561017757600080fd5b61018385828601610081565b915050925092905056fe",la="0x608060405234801561001057600080fd5b506040516102c03803806102c083398101604081905261002f916101e6565b836001600160a01b03163b6000036100e457600080836001600160a01b03168360405161005c9190610270565b6000604051808303816000865af19150503d8060008114610099576040519150601f19603f3d011682016040523d82523d6000602084013e61009e565b606091505b50915091508115806100b857506001600160a01b0386163b155b156100e1578060405163101bb98d60e01b81526004016100d8919061028c565b60405180910390fd5b50505b6000808451602086016000885af16040513d6000823e81610103573d81fd5b3d81f35b80516001600160a01b038116811461011e57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561015457818101518382015260200161013c565b50506000910152565b600082601f83011261016e57600080fd5b81516001600160401b0381111561018757610187610123565b604051601f8201601f19908116603f011681016001600160401b03811182821017156101b5576101b5610123565b6040528181528382016020018510156101cd57600080fd5b6101de826020830160208701610139565b949350505050565b600080600080608085870312156101fc57600080fd5b61020585610107565b60208601519094506001600160401b0381111561022157600080fd5b61022d8782880161015d565b93505061023c60408601610107565b60608601519092506001600160401b0381111561025857600080fd5b6102648782880161015d565b91505092959194509250565b60008251610282818460208701610139565b9190910192915050565b60208152600082518060208401526102ab816040850160208701610139565b601f01601f1916919091016040019291505056fe",fa="0x608060405234801561001057600080fd5b5060405161069438038061069483398101604081905261002f9161051e565b600061003c848484610048565b9050806000526001601ff35b60007f64926492649264926492649264926492649264926492649264926492649264926100748361040c565b036101e7576000606080848060200190518101906100929190610577565b60405192955090935091506000906001600160a01b038516906100b69085906105dd565b6000604051808303816000865af19150503d80600081146100f3576040519150601f19603f3d011682016040523d82523d6000602084013e6100f8565b606091505b50509050876001600160a01b03163b60000361016057806101605760405162461bcd60e51b815260206004820152601e60248201527f5369676e617475726556616c696461746f723a206465706c6f796d656e74000060448201526064015b60405180910390fd5b604051630b135d3f60e11b808252906001600160a01b038a1690631626ba7e90610190908b9087906004016105f9565b602060405180830381865afa1580156101ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d19190610633565b6001600160e01b03191614945050505050610405565b6001600160a01b0384163b1561027a57604051630b135d3f60e11b808252906001600160a01b03861690631626ba7e9061022790879087906004016105f9565b602060405180830381865afa158015610244573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102689190610633565b6001600160e01b031916149050610405565b81516041146102df5760405162461bcd60e51b815260206004820152603a602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e6174757265206c656e6774680000000000006064820152608401610157565b6102e7610425565b5060208201516040808401518451859392600091859190811061030c5761030c61065d565b016020015160f81c9050601b811480159061032b57508060ff16601c14155b1561038c5760405162461bcd60e51b815260206004820152603b602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e617475726520762076616c756500000000006064820152608401610157565b60408051600081526020810180835289905260ff83169181019190915260608101849052608081018390526001600160a01b0389169060019060a0016020604051602081039080840390855afa1580156103ea573d6000803e3d6000fd5b505050602060405103516001600160a01b0316149450505050505b9392505050565b600060208251101561041d57600080fd5b508051015190565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b038116811461045857600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561048c578181015183820152602001610474565b50506000910152565b600082601f8301126104a657600080fd5b81516001600160401b038111156104bf576104bf61045b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156104ed576104ed61045b565b60405281815283820160200185101561050557600080fd5b610516826020830160208701610471565b949350505050565b60008060006060848603121561053357600080fd5b835161053e81610443565b6020850151604086015191945092506001600160401b0381111561056157600080fd5b61056d86828701610495565b9150509250925092565b60008060006060848603121561058c57600080fd5b835161059781610443565b60208501519093506001600160401b038111156105b357600080fd5b6105bf86828701610495565b604086015190935090506001600160401b0381111561056157600080fd5b600082516105ef818460208701610471565b9190910192915050565b828152604060208201526000825180604084015261061e816060850160208701610471565b601f01601f1916919091016060019392505050565b60006020828403121561064557600080fd5b81516001600160e01b03198116811461040557600080fd5b634e487b7160e01b600052603260045260246000fdfe5369676e617475726556616c696461746f72237265636f7665725369676e6572",pa="0x608060405234801561001057600080fd5b506115b9806100206000396000f3fe6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e14610325578063bce38bd714610350578063c3077fa914610380578063ee82ac5e146103b2576100f3565b80634d2301cc1461026257806372425d9d1461029f57806382ad56cb146102ca57806386d516e8146102fa576100f3565b80633408e470116100c65780633408e470146101af578063399542e9146101da5780633e64a6961461020c57806342cbb15c14610237576100f3565b80630f28c97d146100f8578063174dea7114610123578063252dba421461015357806327e86d6e14610184575b600080fd5b34801561010457600080fd5b5061010d6103ef565b60405161011a9190610c0a565b60405180910390f35b61013d60048036038101906101389190610c94565b6103f7565b60405161014a9190610e94565b60405180910390f35b61016d60048036038101906101689190610f0c565b610615565b60405161017b92919061101b565b60405180910390f35b34801561019057600080fd5b506101996107ab565b6040516101a69190611064565b60405180910390f35b3480156101bb57600080fd5b506101c46107b7565b6040516101d19190610c0a565b60405180910390f35b6101f460048036038101906101ef91906110ab565b6107bf565b6040516102039392919061110b565b60405180910390f35b34801561021857600080fd5b506102216107e1565b60405161022e9190610c0a565b60405180910390f35b34801561024357600080fd5b5061024c6107e9565b6040516102599190610c0a565b60405180910390f35b34801561026e57600080fd5b50610289600480360381019061028491906111a7565b6107f1565b6040516102969190610c0a565b60405180910390f35b3480156102ab57600080fd5b506102b4610812565b6040516102c19190610c0a565b60405180910390f35b6102e460048036038101906102df919061122a565b61081a565b6040516102f19190610e94565b60405180910390f35b34801561030657600080fd5b5061030f6109e4565b60405161031c9190610c0a565b60405180910390f35b34801561033157600080fd5b5061033a6109ec565b6040516103479190611286565b60405180910390f35b61036a600480360381019061036591906110ab565b6109f4565b6040516103779190610e94565b60405180910390f35b61039a60048036038101906103959190610f0c565b610ba6565b6040516103a99392919061110b565b60405180910390f35b3480156103be57600080fd5b506103d960048036038101906103d491906112cd565b610bca565b6040516103e69190611064565b60405180910390f35b600042905090565b60606000808484905090508067ffffffffffffffff81111561041c5761041b6112fa565b5b60405190808252806020026020018201604052801561045557816020015b610442610bd5565b81526020019060019003908161043a5790505b5092503660005b828110156105c957600085828151811061047957610478611329565b5b6020026020010151905087878381811061049657610495611329565b5b90506020028101906104a89190611367565b925060008360400135905080860195508360000160208101906104cb91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16818580606001906104f2919061138f565b604051610500929190611431565b60006040518083038185875af1925050503d806000811461053d576040519150601f19603f3d011682016040523d82523d6000602084013e610542565b606091505b5083600001846020018290528215151515815250505081516020850135176105bc577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b826001019250505061045c565b5082341461060c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610603906114a7565b60405180910390fd5b50505092915050565b6000606043915060008484905090508067ffffffffffffffff81111561063e5761063d6112fa565b5b60405190808252806020026020018201604052801561067157816020015b606081526020019060019003908161065c5790505b5091503660005b828110156107a157600087878381811061069557610694611329565b5b90506020028101906106a791906114c7565b92508260000160208101906106bc91906111a7565b73ffffffffffffffffffffffffffffffffffffffff168380602001906106e2919061138f565b6040516106f0929190611431565b6000604051808303816000865af19150503d806000811461072d576040519150601f19603f3d011682016040523d82523d6000602084013e610732565b606091505b5086848151811061074657610745611329565b5b60200260200101819052819250505080610795576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161078c9061153b565b60405180910390fd5b81600101915050610678565b5050509250929050565b60006001430340905090565b600046905090565b6000806060439250434091506107d68686866109f4565b905093509350939050565b600048905090565b600043905090565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b600044905090565b606060008383905090508067ffffffffffffffff81111561083e5761083d6112fa565b5b60405190808252806020026020018201604052801561087757816020015b610864610bd5565b81526020019060019003908161085c5790505b5091503660005b828110156109db57600084828151811061089b5761089a611329565b5b602002602001015190508686838181106108b8576108b7611329565b5b90506020028101906108ca919061155b565b92508260000160208101906108df91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060400190610905919061138f565b604051610913929190611431565b6000604051808303816000865af19150503d8060008114610950576040519150601f19603f3d011682016040523d82523d6000602084013e610955565b606091505b5082600001836020018290528215151515815250505080516020840135176109cf577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b8160010191505061087e565b50505092915050565b600045905090565b600041905090565b606060008383905090508067ffffffffffffffff811115610a1857610a176112fa565b5b604051908082528060200260200182016040528015610a5157816020015b610a3e610bd5565b815260200190600190039081610a365790505b5091503660005b82811015610b9c576000848281518110610a7557610a74611329565b5b60200260200101519050868683818110610a9257610a91611329565b5b9050602002810190610aa491906114c7565b9250826000016020810190610ab991906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060200190610adf919061138f565b604051610aed929190611431565b6000604051808303816000865af19150503d8060008114610b2a576040519150601f19603f3d011682016040523d82523d6000602084013e610b2f565b606091505b508260000183602001829052821515151581525050508715610b90578060000151610b8f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b869061153b565b60405180910390fd5b5b81600101915050610a58565b5050509392505050565b6000806060610bb7600186866107bf565b8093508194508295505050509250925092565b600081409050919050565b6040518060400160405280600015158152602001606081525090565b6000819050919050565b610c0481610bf1565b82525050565b6000602082019050610c1f6000830184610bfb565b92915050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610c5457610c53610c2f565b5b8235905067ffffffffffffffff811115610c7157610c70610c34565b5b602083019150836020820283011115610c8d57610c8c610c39565b5b9250929050565b60008060208385031215610cab57610caa610c25565b5b600083013567ffffffffffffffff811115610cc957610cc8610c2a565b5b610cd585828601610c3e565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b60008115159050919050565b610d2281610d0d565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610d62578082015181840152602081019050610d47565b83811115610d71576000848401525b50505050565b6000601f19601f8301169050919050565b6000610d9382610d28565b610d9d8185610d33565b9350610dad818560208601610d44565b610db681610d77565b840191505092915050565b6000604083016000830151610dd96000860182610d19565b5060208301518482036020860152610df18282610d88565b9150508091505092915050565b6000610e0a8383610dc1565b905092915050565b6000602082019050919050565b6000610e2a82610ce1565b610e348185610cec565b935083602082028501610e4685610cfd565b8060005b85811015610e825784840389528151610e638582610dfe565b9450610e6e83610e12565b925060208a01995050600181019050610e4a565b50829750879550505050505092915050565b60006020820190508181036000830152610eae8184610e1f565b905092915050565b60008083601f840112610ecc57610ecb610c2f565b5b8235905067ffffffffffffffff811115610ee957610ee8610c34565b5b602083019150836020820283011115610f0557610f04610c39565b5b9250929050565b60008060208385031215610f2357610f22610c25565b5b600083013567ffffffffffffffff811115610f4157610f40610c2a565b5b610f4d85828601610eb6565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6000610f918383610d88565b905092915050565b6000602082019050919050565b6000610fb182610f59565b610fbb8185610f64565b935083602082028501610fcd85610f75565b8060005b858110156110095784840389528151610fea8582610f85565b9450610ff583610f99565b925060208a01995050600181019050610fd1565b50829750879550505050505092915050565b60006040820190506110306000830185610bfb565b81810360208301526110428184610fa6565b90509392505050565b6000819050919050565b61105e8161104b565b82525050565b60006020820190506110796000830184611055565b92915050565b61108881610d0d565b811461109357600080fd5b50565b6000813590506110a58161107f565b92915050565b6000806000604084860312156110c4576110c3610c25565b5b60006110d286828701611096565b935050602084013567ffffffffffffffff8111156110f3576110f2610c2a565b5b6110ff86828701610eb6565b92509250509250925092565b60006060820190506111206000830186610bfb565b61112d6020830185611055565b818103604083015261113f8184610e1f565b9050949350505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061117482611149565b9050919050565b61118481611169565b811461118f57600080fd5b50565b6000813590506111a18161117b565b92915050565b6000602082840312156111bd576111bc610c25565b5b60006111cb84828501611192565b91505092915050565b60008083601f8401126111ea576111e9610c2f565b5b8235905067ffffffffffffffff81111561120757611206610c34565b5b60208301915083602082028301111561122357611222610c39565b5b9250929050565b6000806020838503121561124157611240610c25565b5b600083013567ffffffffffffffff81111561125f5761125e610c2a565b5b61126b858286016111d4565b92509250509250929050565b61128081611169565b82525050565b600060208201905061129b6000830184611277565b92915050565b6112aa81610bf1565b81146112b557600080fd5b50565b6000813590506112c7816112a1565b92915050565b6000602082840312156112e3576112e2610c25565b5b60006112f1848285016112b8565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600080fd5b600080fd5b600080fd5b60008235600160800383360303811261138357611382611358565b5b80830191505092915050565b600080833560016020038436030381126113ac576113ab611358565b5b80840192508235915067ffffffffffffffff8211156113ce576113cd61135d565b5b6020830192506001820236038313156113ea576113e9611362565b5b509250929050565b600081905092915050565b82818337600083830152505050565b600061141883856113f2565b93506114258385846113fd565b82840190509392505050565b600061143e82848661140c565b91508190509392505050565b600082825260208201905092915050565b7f4d756c746963616c6c333a2076616c7565206d69736d61746368000000000000600082015250565b6000611491601a8361144a565b915061149c8261145b565b602082019050919050565b600060208201905081810360008301526114c081611484565b9050919050565b6000823560016040038336030381126114e3576114e2611358565b5b80830191505092915050565b7f4d756c746963616c6c333a2063616c6c206661696c6564000000000000000000600082015250565b600061152560178361144a565b9150611530826114ef565b602082019050919050565b6000602082019050818103600083015261155481611518565b9050919050565b60008235600160600383360303811261157757611576611358565b5b8083019150509291505056fea264697066735822122020c1bc9aacf8e4a6507193432a895a8e77094f45a1395583f07b24e860ef06cd64736f6c634300080c0033";class ha extends J{constructor({blockNumber:e,chain:t,contract:n}){super(`Chain "${t.name}" does not support contract "${n.name}".`,{metaMessages:["This could be due to any of the following:",...e&&n.blockCreated&&n.blockCreated>e?[`- The contract "${n.name}" was not deployed until block ${n.blockCreated} (current block ${e}).`]:[`- The chain does not have the contract "${n.name}" configured.`]],name:"ChainDoesNotSupportContract"})}}class ma extends J{constructor(){super("No chain was provided to the Client.",{name:"ClientChainNotConfiguredError"})}}class ya extends J{constructor({chainId:e}){super("number"==typeof e?`Chain ID "${e}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}const ba="/docs/contract/encodeDeployData";function ga(e){const{abi:t,args:n,bytecode:r}=e;if(!n||0===n.length)return r;const s=t.find((e=>"type"in e&&"constructor"===e.type));if(!s)throw new ee({docsPath:ba});if(!("inputs"in s))throw new te({docsPath:ba});if(!s.inputs||0===s.inputs.length)throw new te({docsPath:ba});return Ht([r,nn(s.inputs,n)])}function wa(e,{docsPath:t,...n}){const r=(()=>{const t=function(e,t){const n=(e.details||"").toLowerCase(),r=e instanceof J?e.walk((e=>e?.code===Br.code)):e;return r instanceof J?new Br({cause:e,message:r.details}):Br.nodeMessage.test(n)?new Br({cause:e,message:e.details}):Dr.nodeMessage.test(n)?new Dr({cause:e,maxFeePerGas:t?.maxFeePerGas}):Ur.nodeMessage.test(n)?new Ur({cause:e,maxFeePerGas:t?.maxFeePerGas}):qr.nodeMessage.test(n)?new qr({cause:e,nonce:t?.nonce}):Lr.nodeMessage.test(n)?new Lr({cause:e,nonce:t?.nonce}):Fr.nodeMessage.test(n)?new Fr({cause:e,nonce:t?.nonce}):Kr.nodeMessage.test(n)?new Kr({cause:e}):Gr.nodeMessage.test(n)?new Gr({cause:e,gas:t?.gas}):Vr.nodeMessage.test(n)?new Vr({cause:e,gas:t?.gas}):Zr.nodeMessage.test(n)?new Zr({cause:e}):Hr.nodeMessage.test(n)?new Hr({cause:e,maxFeePerGas:t?.maxFeePerGas,maxPriorityFeePerGas:t?.maxPriorityFeePerGas}):new Wr({cause:e})}(e,n);return t instanceof Wr?e:t})();return new Zn(r,{docsPath:t,...n})}function va(){let e=()=>{},t=()=>{};return{promise:new Promise(((n,r)=>{e=n,t=r})),resolve:e,reject:t}}const xa=new Map;function Ia({fn:e,id:t,shouldSplitBatch:n,wait:r=0,sort:s}){const i=async()=>{const t=o();a();const n=t.map((({args:e})=>e));0!==n.length&&e(n).then((e=>{s&&Array.isArray(e)&&e.sort(s);for(let n=0;n<t.length;n++){const{resolve:r}=t[n];r?.([e[n],e])}})).catch((e=>{for(let n=0;n<t.length;n++){const{reject:r}=t[n];r?.(e)}}))},a=()=>xa.delete(t),o=()=>xa.get(t)||[],c=e=>xa.set(t,[...o(),e]);return{flush:a,async schedule(e){const{promise:t,resolve:s,reject:a}=va(),u=n?.([...o().map((({args:e})=>e)),e]);u&&i();return o().length>0?(c({args:e,resolve:s,reject:a}),t):(c({args:e,resolve:s,reject:a}),setTimeout(i,r),t)}}}async function Pa(e,t){const{account:n=e.account,authorizationList:r,batch:s=Boolean(e.batch?.multicall),blockNumber:i,blockTag:a=e.experimental_blockTag??"latest",accessList:o,blobs:c,blockOverrides:u,code:d,data:l,factory:f,factoryData:p,gas:h,gasPrice:m,maxFeePerBlobGas:y,maxFeePerGas:b,maxPriorityFeePerGas:g,nonce:w,to:v,value:x,stateOverride:I,...P}=t,z=n?ln(n):void 0;if(d&&(f||p))throw new J("Cannot provide both `code` & `factory`/`factoryData` as parameters.");if(d&&v)throw new J("Cannot provide both `code` & `to` as parameters.");const E=d&&l,A=f&&p&&v&&l,k=E||A,M=E?za({code:d,data:l}):A?function(e){const{data:t,factory:n,factoryData:r,to:s}=e;return ga({abi:F(["constructor(address, bytes, address, bytes)"]),bytecode:la,args:[s,t,n,r]})}({data:l,factory:f,factoryData:p,to:v}):l;try{!function(e){const{account:t,gasPrice:n,maxFeePerGas:r,maxPriorityFeePerGas:s,to:i}=e,a=t?ln(t):void 0;if(a&&!Vt(a.address))throw new Dt({address:a.address});if(i&&!Vt(i))throw new Dt({address:i});if(void 0!==n&&(void 0!==r||void 0!==s))throw new Ln;if(r&&r>ns)throw new Dr({maxFeePerGas:r});if(s&&r&&s>r)throw new Hr({maxFeePerGas:r,maxPriorityFeePerGas:s})}(t);const n=("bigint"==typeof i?Ne(i):void 0)||a,d=u?function(e){return{..."bigint"==typeof e.baseFeePerGas&&{baseFeePerGas:Zi(e.baseFeePerGas)},..."bigint"==typeof e.blobBaseFee&&{blobBaseFee:Zi(e.blobBaseFee)},..."string"==typeof e.feeRecipient&&{feeRecipient:e.feeRecipient},..."bigint"==typeof e.gasLimit&&{gasLimit:Zi(e.gasLimit)},..."bigint"==typeof e.number&&{number:Zi(e.number)},..."bigint"==typeof e.prevRandao&&{prevRandao:Zi(e.prevRandao)},..."bigint"==typeof e.time&&{time:Zi(e.time)},...e.withdrawals&&{withdrawals:e.withdrawals.map(ia)}}}(u):void 0,l=function(e){if(!e)return;const t={};for(const{address:n,...r}of e){if(!Vt(n,{strict:!1}))throw new Dt({address:n});if(t[n])throw new Bn({address:n});t[n]=ts(r)}return t}(I),f=e.chain?.formatters?.transactionRequest?.format,p=(f||Xr)({...Yr(P,{format:f}),from:z?.address,accessList:o,authorizationList:r,blobs:c,data:M,gas:h,gasPrice:m,maxFeePerBlobGas:y,maxFeePerGas:b,maxPriorityFeePerGas:g,nonce:w,to:k?void 0:v,value:x});if(s&&function({request:e}){const{data:t,to:n,...r}=e;return!!t&&(!t.startsWith(ua)&&(!!n&&!(Object.values(r).filter((e=>void 0!==e)).length>0)))}({request:p})&&!l&&!d)try{return await async function(e,t){const{batchSize:n=1024,deployless:r=!1,wait:s=0}="object"==typeof e.batch?.multicall?e.batch.multicall:{},{blockNumber:i,blockTag:a=e.experimental_blockTag??"latest",data:o,to:c}=t,u=(()=>{if(r)return null;if(t.multicallAddress)return t.multicallAddress;if(e.chain)return function({blockNumber:e,chain:t,contract:n}){const r=t?.contracts?.[n];if(!r)throw new ha({chain:t,contract:{name:n}});if(e&&r.blockCreated&&r.blockCreated>e)throw new ha({blockNumber:e,chain:t,contract:{name:n,blockCreated:r.blockCreated}});return r.address}({blockNumber:i,chain:e.chain,contract:"multicall3"});throw new ma})(),d="bigint"==typeof i?Ne(i):void 0,l=d||a,{schedule:f}=Ia({id:`${e.uid}.${l}`,wait:s,shouldSplitBatch(e){const t=e.reduce(((e,{data:t})=>e+(t.length-2)),0);return t>2*n},fn:async t=>{const n=t.map((e=>({allowFailure:!0,callData:e.data,target:e.to}))),r=pn({abi:aa,args:[n],functionName:"aggregate3"}),s=await e.request({method:"eth_call",params:[{...null===u?{data:za({code:pa,data:r})}:{to:u,data:r}},l]});return Ls({abi:aa,args:[n],functionName:"aggregate3",data:s||"0x"})}}),[{returnData:p,success:h}]=await f({data:o,to:c});if(!h)throw new Jn({data:p});return"0x"===p?{data:void 0}:{data:p}}(e,{...p,blockNumber:i,blockTag:a})}catch(e){if(!(e instanceof ma||e instanceof ha))throw e}const E=(()=>{const e=[p,n];return l&&d?[...e,l,d]:l?[...e,l]:d?[...e,{},d]:e})(),A=await e.request({method:"eth_call",params:E});return"0x"===A?{data:void 0}:{data:A}}catch(n){const r=function(e){if(!(e instanceof J))return;const t=e.walk();return"object"==typeof t?.data?t.data?.data:t.data}(n),{offchainLookup:s,offchainLookupSignature:i}=await Promise.resolve().then((function(){return require("./ccip-b38d78bc.cjs")}));if(!1!==e.ccipRead&&r?.slice(0,10)===i&&v)return{data:await s(e,{data:r,to:v})};if(k&&"0x101bb98d"===r?.slice(0,10))throw new Qn({factory:f});throw wa(n,{...t,account:z,chain:e.chain})}}function za(e){const{code:t,data:n}=e;return ga({abi:F(["constructor(bytes, bytes)"]),bytecode:da,args:[t,n]})}async function Ea(e,t){const{abi:n,address:r,args:s,functionName:i,...a}=t,o=pn({abi:n,args:s,functionName:i});try{const{data:t}=await K(e,Pa,"call")({...a,data:o,to:r});return Ls({abi:n,args:s,functionName:i,data:t||"0x"})}catch(e){throw jr(e,{abi:n,address:r,args:s,docsPath:"/docs/contract/readContract",functionName:i})}}const Aa=new Map,ka=new Map;let Ma=0;function $a(e,t,n){const r=++Ma,s=()=>Aa.get(e)||[],i=()=>{const t=s();if(!t.some((e=>e.id===r)))return;const n=ka.get(e);if(1===t.length&&n){const e=n();e instanceof Promise&&e.catch((()=>{}))}(()=>{const t=s();Aa.set(e,t.filter((e=>e.id!==r)))})()},a=s();if(Aa.set(e,[...a,{id:r,fns:t}]),a&&a.length>0)return i;const o={};for(const e in t)o[e]=(...t)=>{const n=s();if(0!==n.length)for(const r of n)r.fns[e]?.(...t)};const c=n(o);return"function"==typeof c&&ka.set(e,c),i}async function Oa(e){return new Promise((t=>setTimeout(t,e)))}const ja=new Map,Sa=new Map;async function Na(e,{cacheKey:t,cacheTime:n=Number.POSITIVE_INFINITY}){const r=function(e){const t=(e,t)=>({clear:()=>t.delete(e),get:()=>t.get(e),set:n=>t.set(e,n)}),n=t(e,ja),r=t(e,Sa);return{clear:()=>{n.clear(),r.clear()},promise:n,response:r}}(t),s=r.response.get();if(s&&n>0){if(Date.now()-s.created.getTime()<n)return s.data}let i=r.promise.get();i||(i=e(),r.promise.set(i));try{const e=await i;return r.response.set({created:new Date,data:e}),e}finally{r.promise.clear()}}class Ta extends J{constructor(e){super(`Call bundle failed with status: ${e.statusCode}`,{name:"BundleFailedError"}),Object.defineProperty(this,"result",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.result=e}}function _a(e,{delay:t=100,retryCount:n=2,shouldRetry:r=(()=>!0)}={}){return new Promise(((s,i)=>{const a=async({count:o=0}={})=>{try{const t=await e();s(t)}catch(e){if(o<n&&await r({count:o,error:e}))return(async({error:e})=>{const n="function"==typeof t?t({count:o,error:e}):t;n&&await Oa(n),a({count:o+1})})({error:e});i(e)}};a()}))}const Ra={"0x0":"reverted","0x1":"success"};function Ca(e){const t={...e,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,contractAddress:e.contractAddress?e.contractAddress:null,cumulativeGasUsed:e.cumulativeGasUsed?BigInt(e.cumulativeGasUsed):null,effectiveGasPrice:e.effectiveGasPrice?BigInt(e.effectiveGasPrice):null,gasUsed:e.gasUsed?BigInt(e.gasUsed):null,logs:e.logs?e.logs.map((e=>function(e,{args:t,eventName:n}={}){return{...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,logIndex:e.logIndex?Number(e.logIndex):null,transactionHash:e.transactionHash?e.transactionHash:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,...n?{args:t,eventName:n}:{}}}(e))):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Me(e.transactionIndex):null,status:e.status?Ra[e.status]:null,type:e.type?rs[e.type]||e.type:null};return e.blobGasPrice&&(t.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(t.blobGasUsed=BigInt(e.blobGasUsed)),t}const Ba=Qr("transactionReceipt",Ca),Da="0x5792579257925792579257925792579257925792579257925792579257925792",Ua=Ne(0,{size:32});async function qa(e,t){const{id:n,pollingInterval:r=e.pollingInterval,status:s=(({statusCode:e})=>200===e||e>=300),retryCount:i=4,retryDelay:a=(({count:e})=>200*~~(1<<e)),timeout:o=6e4,throwOnFailure:c=!1}=t,u=jn(["waitForCallsStatus",e.uid,n]),{promise:d,resolve:l,reject:f}=va();let p;const h=$a(u,{resolve:l,reject:f},(t=>{const o=function(e,{emitOnBegin:t,initialWaitTime:n,interval:r}){let s=!0;const i=()=>s=!1;return(async()=>{let a;t&&(a=await e({unpoll:i}));const o=await(n?.(a))??r;await Oa(o);const c=async()=>{s&&(await e({unpoll:i}),await Oa(r),c())};c()})(),i}((async()=>{const r=e=>{clearTimeout(p),o(),e(),h()};try{const o=await _a((async()=>{const t=await async function(e,t){const{atomic:n=!1,chainId:r,receipts:s,version:i="2.0.0",...a}=await async function(t){if(t.endsWith(Da.slice(2))){const n=Ee(Xt(t,-64,-32)),r=Xt(t,0,-64).slice(2).match(/.{1,64}/g),s=await Promise.all(r.map((t=>Ua.slice(2)!==t?e.request({method:"eth_getTransactionReceipt",params:[`0x${t}`]},{dedupe:!0}):void 0))),i=s.some((e=>null===e))?100:s.every((e=>"0x1"===e?.status))?200:s.every((e=>"0x0"===e?.status))?500:600;return{atomic:!1,chainId:Me(n),receipts:s.filter(Boolean),status:i,version:"2.0.0"}}return e.request({method:"wallet_getCallsStatus",params:[t]})}(t.id),[o,c]=(()=>{const e=a.status;return e>=100&&e<200?["pending",e]:e>=200&&e<300?["success",e]:e>=300&&e<700?["failure",e]:"CONFIRMED"===e?["success",200]:"PENDING"===e?["pending",100]:[void 0,e]})();return{...a,atomic:n,chainId:r?Me(r):void 0,receipts:s?.map((e=>({...e,blockNumber:ke(e.blockNumber),gasUsed:ke(e.gasUsed),status:Ra[e.status]})))??[],statusCode:c,status:o,version:i}}(e,{id:n});if(c&&"failure"===t.status)throw new Ta(t);return t}),{retryCount:i,delay:a});if(!s(o))return;r((()=>t.resolve(o)))}catch(e){r((()=>t.reject(e)))}}),{interval:r,emitOnBegin:!0});return o}));return p=o?setTimeout((()=>{h(),clearTimeout(p),f(new La({id:n}))}),o):void 0,await d}class La extends J{constructor({id:e}){super(`Timed out while waiting for call bundle with id "${e}" to be confirmed.`,{name:"WaitForCallsStatusTimeoutError"})}}const Fa=256;let Ka,Ga=Fa;function Va(e=11){if(!Ka||Ga+e>2*Fa){Ka="",Ga=0;for(let e=0;e<Fa;e++)Ka+=(256+256*Math.random()|0).toString(16).substring(1)}return Ka.substring(Ga,Ga+++e)}function Za(e){const{batch:t,chain:n,ccipRead:r,key:s="base",name:i="Base Client",type:a="base"}=e,o=e.experimental_blockTag??("number"==typeof n?.experimental_preconfirmationTime?"pending":void 0),c=n?.blockTime??12e3,u=Math.min(Math.max(Math.floor(c/2),500),4e3),d=e.pollingInterval??u,l=e.cacheTime??d,f=e.account?ln(e.account):void 0,{config:p,request:h,value:m}=e.transport({chain:n,pollingInterval:d}),y={account:f,batch:t,cacheTime:l,ccipRead:r,chain:n,key:s,name:i,pollingInterval:d,request:h,transport:{...p,...m},type:a,uid:Va(),...o?{experimental_blockTag:o}:{}};return Object.assign(y,{extend:function e(t){return n=>{const r=n(t);for(const e in y)delete r[e];const s={...t,...r};return Object.assign(s,{extend:e(s)})}}(y)})}class Ha extends J{constructor({address:e}){super(`No EIP-712 domain found on contract "${e}".`,{metaMessages:["Ensure that:",`- The contract is deployed at the address "${e}".`,"- `eip712Domain()` function exists on the contract.","- `eip712Domain()` function matches signature to ERC-5267 specification."],name:"Eip712DomainNotFoundError"})}}const Wa=[{inputs:[],name:"eip712Domain",outputs:[{name:"fields",type:"bytes1"},{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"},{name:"salt",type:"bytes32"},{name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"}];function Ya(e){const{chainId:t,maxPriorityFeePerGas:n,maxFeePerGas:r,to:s}=e;if(t<=0)throw new ya({chainId:t});if(s&&!Vt(s))throw new Dt({address:s});if(r&&r>ns)throw new Dr({maxFeePerGas:r});if(n&&r&&n>r)throw new Hr({maxFeePerGas:r,maxPriorityFeePerGas:n})}function Qa(e){if(!e||0===e.length)return[];const t=[];for(let n=0;n<e.length;n++){const{address:r,storageKeys:s}=e[n];for(let e=0;e<s.length;e++)if(s[e].length-2!=64)throw new Gn({storageKey:s[e]});if(!Vt(r,{strict:!1}))throw new Dt({address:r});t.push([r,s])}return t}function Ja(e,t){const n=function(e){if(e.type)return e.type;if(void 0!==e.authorizationList)return"eip7702";if(void 0!==e.blobs||void 0!==e.blobVersionedHashes||void 0!==e.maxFeePerBlobGas||void 0!==e.sidecars)return"eip4844";if(void 0!==e.maxFeePerGas||void 0!==e.maxPriorityFeePerGas)return"eip1559";if(void 0!==e.gasPrice)return void 0!==e.accessList?"eip2930":"legacy";throw new Kn({transaction:e})}(e);return"eip1559"===n?function(e,t){const{chainId:n,gas:r,nonce:s,to:i,value:a,maxFeePerGas:o,maxPriorityFeePerGas:c,accessList:u,data:d}=e;Ya(e);const l=Qa(u),f=[Ne(n),s?Ne(s):"0x",c?Ne(c):"0x",o?Ne(o):"0x",r?Ne(r):"0x",i??"0x",a?Ne(a):"0x",d??"0x",l,...Xa(e,t)];return Ht(["0x02",Tr(f)])}(e,t):"eip2930"===n?function(e,t){const{chainId:n,gas:r,data:s,nonce:i,to:a,value:o,accessList:c,gasPrice:u}=e;!function(e){const{chainId:t,maxPriorityFeePerGas:n,gasPrice:r,maxFeePerGas:s,to:i}=e;if(t<=0)throw new ya({chainId:t});if(i&&!Vt(i))throw new Dt({address:i});if(n||s)throw new J("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(r&&r>ns)throw new Dr({maxFeePerGas:r})}(e);const d=Qa(c),l=[Ne(n),i?Ne(i):"0x",u?Ne(u):"0x",r?Ne(r):"0x",a??"0x",o?Ne(o):"0x",s??"0x",d,...Xa(e,t)];return Ht(["0x01",Tr(l)])}(e,t):"eip4844"===n?function(e,t){const{chainId:n,gas:r,nonce:s,to:i,value:a,maxFeePerBlobGas:o,maxFeePerGas:c,maxPriorityFeePerGas:u,accessList:d,data:l}=e;!function(e){const{blobVersionedHashes:t}=e;if(t){if(0===t.length)throw new Rs;for(const e of t){const t=H(e),n=Me(Wt(e,0,1));if(32!==t)throw new Cs({hash:e,size:t});if(n!==Ts)throw new Bs({hash:e,version:n})}}Ya(e)}(e);let f=e.blobVersionedHashes,p=e.sidecars;if(e.blobs&&(void 0===f||void 0===p)){const t="string"==typeof e.blobs[0]?e.blobs:e.blobs.map((e=>Se(e))),n=e.kzg,r=cs({blobs:t,kzg:n});if(void 0===f&&(f=function(e){const{commitments:t,version:n}=e,r=e.to??("string"==typeof t[0]?"hex":"bytes"),s=[];for(const e of t)s.push($s({commitment:e,to:r,version:n}));return s}({commitments:r})),void 0===p){p=Ds({blobs:t,commitments:r,proofs:us({blobs:t,commitments:r,kzg:n})})}}const h=Qa(d),m=[Ne(n),s?Ne(s):"0x",u?Ne(u):"0x",c?Ne(c):"0x",r?Ne(r):"0x",i??"0x",a?Ne(a):"0x",l??"0x",h,o?Ne(o):"0x",f??[],...Xa(e,t)],y=[],b=[],g=[];if(p)for(let e=0;e<p.length;e++){const{blob:t,commitment:n,proof:r}=p[e];y.push(t),b.push(n),g.push(r)}return Ht(["0x03",Tr(p?[m,y,b,g]:m)])}(e,t):"eip7702"===n?function(e,t){const{authorizationList:n,chainId:r,gas:s,nonce:i,to:a,value:o,maxFeePerGas:c,maxPriorityFeePerGas:u,accessList:d,data:l}=e;!function(e){const{authorizationList:t}=e;if(t)for(const e of t){const{chainId:t}=e,n=e.address;if(!Vt(n))throw new Dt({address:n});if(t<0)throw new ya({chainId:t})}Ya(e)}(e);const f=Qa(d),p=function(e){if(!e||0===e.length)return[];const t=[];for(const n of e){const{chainId:e,nonce:r,...s}=n,i=n.address;t.push([e?Oe(e):"0x",i,r?Oe(r):"0x",...Xa({},s)])}return t}(n);return Ht(["0x04",Tr([Ne(r),i?Ne(i):"0x",u?Ne(u):"0x",c?Ne(c):"0x",s?Ne(s):"0x",a??"0x",o?Ne(o):"0x",l??"0x",f,p,...Xa(e,t)])])}(e,t):function(e,t){const{chainId:n=0,gas:r,data:s,nonce:i,to:a,value:o,gasPrice:c}=e;!function(e){const{chainId:t,maxPriorityFeePerGas:n,gasPrice:r,maxFeePerGas:s,to:i}=e;if(i&&!Vt(i))throw new Dt({address:i});if(void 0!==t&&t<=0)throw new ya({chainId:t});if(n||s)throw new J("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(r&&r>ns)throw new Dr({maxFeePerGas:r})}(e);let u=[i?Ne(i):"0x",c?Ne(c):"0x",r?Ne(r):"0x",a??"0x",o?Ne(o):"0x",s??"0x"];if(t){const e=(()=>{if(t.v>=35n){return(t.v-35n)/2n>0?t.v:27n+(35n===t.v?0n:1n)}if(n>0)return BigInt(2*n)+BigInt(35n+t.v-27n);const e=27n+(27n===t.v?0n:1n);if(t.v!==e)throw new Fn({v:t.v});return e})(),r=Ee(t.r),s=Ee(t.s);u=[...u,Ne(e),"0x00"===r?"0x":r,"0x00"===s?"0x":s]}else n>0&&(u=[...u,Ne(n),"0x","0x"]);return Tr(u)}(e,t)}function Xa(e,t){const n=t??e,{v:r,yParity:s}=n;if(void 0===n.r)return[];if(void 0===n.s)return[];if(void 0===r&&void 0===s)return[];const i=Ee(n.r),a=Ee(n.s);return["number"==typeof s?s?Ne(1):"0x":0n===r?"0x":1n===r?Ne(1):27n===r?"0x":Ne(1),"0x00"===i?"0x":i,"0x00"===a?"0x":a]}async function eo({address:e,authorization:t,signature:n}){return Us(Ft(e),await async function(e){const{authorization:t,signature:n}=e;return Nr({hash:Cr(t),signature:n??t})}({authorization:t,signature:n}))}const to=new Ut(8192);function no(e,t={}){return async(n,r={})=>{const{dedupe:s=!1,methods:i,retryDelay:a=150,retryCount:o=3,uid:c}={...t,...r},{method:u}=n;if(i?.exclude?.includes(u))throw new pr(new Error("method not supported"),{method:u});if(i?.include&&!i.include.includes(u))throw new pr(new Error("method not supported"),{method:u});return function(e,{enabled:t=!0,id:n}){if(!t||!n)return e();if(to.get(n))return to.get(n);const r=e().finally((()=>to.delete(n)));return to.set(n,r),r}((()=>_a((async()=>{try{return await e(n)}catch(e){const t=e;switch(t.code){case sr.code:throw new sr(t);case ir.code:throw new ir(t);case ar.code:throw new ar(t,{method:n.method});case or.code:throw new or(t);case cr.code:throw new cr(t);case ur.code:throw new ur(t);case dr.code:throw new dr(t);case lr.code:throw new lr(t);case fr.code:throw new fr(t);case pr.code:throw new pr(t,{method:n.method});case hr.code:throw new hr(t);case mr.code:throw new mr(t);case yr.code:throw new yr(t);case br.code:throw new br(t);case gr.code:throw new gr(t);case wr.code:throw new wr(t);case vr.code:throw new vr(t);case xr.code:throw new xr(t);case Ir.code:throw new Ir(t);case Pr.code:throw new Pr(t);case zr.code:throw new zr(t);case Er.code:throw new Er(t);case Ar.code:throw new Ar(t);case kr.code:throw new kr(t);case Mr.code:throw new Mr(t);case 5e3:throw new yr(t);default:if(e instanceof J)throw e;throw new $r(t)}}}),{delay:({count:e,error:t})=>{if(t&&t instanceof Xn){const e=t?.headers?.get("Retry-After");if(e?.match(/\d/))return 1e3*Number.parseInt(e,10)}return~~(1<<e)*a},retryCount:o,shouldRetry:({error:e})=>function(e){if("code"in e&&"number"==typeof e.code)return-1===e.code||(e.code===hr.code||e.code===cr.code);if(e instanceof Xn&&e.status)return 403===e.status||(408===e.status||(413===e.status||(429===e.status||(500===e.status||(502===e.status||(503===e.status||504===e.status))))));return!0}(e)})),{enabled:s,id:s?_e(`${c}.${jn(n)}`):void 0})}}function ro(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}function so(){return{current:0,take(){return this.current++},reset(){this.current=0}}}const io=so();function ao(e,t={}){return{async request(n){const{body:r,fetchFn:s=t.fetchFn??fetch,onRequest:i=t.onRequest,onResponse:a=t.onResponse,timeout:o=t.timeout??1e4}=n,c={...t.fetchOptions??{},...n.fetchOptions??{}},{headers:u,method:d,signal:l}=c;try{const t=await function(e,{errorInstance:t=new Error("timed out"),timeout:n,signal:r}){return new Promise(((s,i)=>{(async()=>{let a;try{const o=new AbortController;n>0&&(a=setTimeout((()=>{r?o.abort():i(t)}),n)),s(await e({signal:o?.signal||null}))}catch(e){"AbortError"===e?.name&&i(t),i(e)}finally{clearTimeout(a)}})()}))}((async({signal:t})=>{const n={...c,body:Array.isArray(r)?jn(r.map((e=>({jsonrpc:"2.0",id:e.id??io.take(),...e})))):jn({jsonrpc:"2.0",id:r.id??io.take(),...r}),headers:{"Content-Type":"application/json",...u},method:d||"POST",signal:l||(o>0?t:null)},a=new Request(e,n),f=await(i?.(a,n))??{...n,url:e};return await s(f.url??e,f)}),{errorInstance:new tr({body:r,url:e}),timeout:o,signal:!0});let n;if(a&&await a(t),t.headers.get("Content-Type")?.startsWith("application/json"))n=await t.json();else{n=await t.text();try{n=JSON.parse(n||"{}")}catch(e){if(t.ok)throw e;n={error:n}}}if(!t.ok)throw new Xn({body:r,details:jn(n.error)||t.statusText,headers:t.headers,status:t.status,url:e});return n}catch(t){if(t instanceof Xn)throw t;if(t instanceof tr)throw t;throw new Xn({body:r,cause:t,url:e})}}}}const oo="Ethereum Signed Message:\n";function co(e,t){return Tt(function(e){const t="string"==typeof e?_e(e):"string"==typeof e.raw?e.raw:Se(e.raw);return Zt([_e(`${oo}${H(t)}`),t])}(e),t)}class uo extends J{constructor({domain:e}){super(`Invalid domain "${jn(e)}".`,{metaMessages:["Must be a valid EIP-712 domain."]})}}class lo extends J{constructor({primaryType:e,types:t}){super(`Invalid primary type \`${e}\` must be one of \`${JSON.stringify(Object.keys(t))}\`.`,{docsPath:"/api/glossary/Errors#typeddatainvalidprimarytypeerror",metaMessages:["Check that the primary type is a key in `types`."]})}}class fo extends J{constructor({type:e}){super(`Struct type "${e}" is invalid.`,{metaMessages:["Struct type must not be a Solidity type."],name:"InvalidStructTypeError"})}}function po({domain:e}){return["string"==typeof e?.name&&{name:"name",type:"string"},e?.version&&{name:"version",type:"string"},("number"==typeof e?.chainId||"bigint"==typeof e?.chainId)&&{name:"chainId",type:"uint256"},e?.verifyingContract&&{name:"verifyingContract",type:"address"},e?.salt&&{name:"salt",type:"bytes32"}].filter(Boolean)}function ho(e){if("address"===e||"bool"===e||"string"===e||e.startsWith("bytes")||e.startsWith("uint")||e.startsWith("int"))throw new fo({type:e})}function mo(e){const{domain:t={},message:n,primaryType:r}=e,s={EIP712Domain:po({domain:t}),...e.types};!function(e){const{domain:t,message:n,primaryType:r,types:s}=e,i=(e,t)=>{for(const n of e){const{name:e,type:r}=n,a=t[e],o=r.match(tn);if(o&&("number"==typeof a||"bigint"==typeof a)){const[e,t,n]=o;Ne(a,{signed:"int"===t,size:Number.parseInt(n,10)/8})}if("address"===r&&"string"==typeof a&&!Vt(a))throw new Dt({address:a});const c=r.match(en);if(c){const[e,t]=c;if(t&&H(a)!==Number.parseInt(t,10))throw new le({expectedSize:Number.parseInt(t,10),givenSize:H(a)})}const u=s[r];u&&(ho(r),i(u,a))}};if(s.EIP712Domain&&t){if("object"!=typeof t)throw new uo({domain:t});i(s.EIP712Domain,t)}if("EIP712Domain"!==r){if(!s[r])throw new lo({primaryType:r,types:s});i(s[r],n)}}({domain:t,message:n,primaryType:r,types:s});const i=["0x1901"];return t&&i.push(function({domain:e,types:t}){return yo({data:e,primaryType:"EIP712Domain",types:t})}({domain:t,types:s})),"EIP712Domain"!==r&&i.push(yo({data:n,primaryType:r,types:s})),Tt(Zt(i))}function yo({data:e,primaryType:t,types:n}){return Tt(bo({data:e,primaryType:t,types:n}))}function bo({data:e,primaryType:t,types:n}){const r=[{type:"bytes32"}],s=[go({primaryType:t,types:n})];for(const i of n[t]){const[t,a]=vo({types:n,name:i.name,type:i.type,value:e[i.name]});r.push(t),s.push(a)}return nn(r,s)}function go({primaryType:e,types:t}){const n=Oe(function({primaryType:e,types:t}){let n="";const r=wo({primaryType:e,types:t});r.delete(e);const s=[e,...Array.from(r).sort()];for(const e of s)n+=`${e}(${t[e].map((({name:e,type:t})=>`${t} ${e}`)).join(",")})`;return n}({primaryType:e,types:t}));return Tt(n)}function wo({primaryType:e,types:t},n=new Set){const r=e.match(/^\w*/u),s=r?.[0];if(n.has(s)||void 0===t[s])return n;n.add(s);for(const e of t[s])wo({primaryType:e.type,types:t},n);return n}function vo({types:e,name:t,type:n,value:r}){if(void 0!==e[n])return[{type:"bytes32"},Tt(bo({data:r,primaryType:n,types:e}))];if("bytes"===n){return[{type:"bytes32"},Tt(r=`0x${(r.length%2?"0":"")+r.slice(2)}`)]}if("string"===n)return[{type:"bytes32"},Tt(Oe(r))];if(n.lastIndexOf("]")===n.length-1){const s=n.slice(0,n.lastIndexOf("[")),i=r.map((n=>vo({name:t,type:s,types:e,value:n})));return[{type:"bytes32"},Tt(nn(i.map((([e])=>e)),i.map((([,e])=>e))))]}return[{type:n},r]}class xo extends Error{constructor(e,t={}){const n=t.cause instanceof xo?t.cause.details:t.cause?.message?t.cause.message:t.details,r=t.cause instanceof xo&&t.cause.docsPath||t.docsPath;super([e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...r?[`Docs: https://abitype.dev${r}`]:[],...n?[`Details: ${n}`]:[],"Version: abitype@1.2.3"].join("\n")),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiTypeError"}),t.cause&&(this.cause=t.cause),this.details=n,this.docsPath=r,this.metaMessages=t.metaMessages,this.shortMessage=e}}function Io(e,t){const n=e.exec(t);return n?.groups}const Po=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,zo=/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/,Eo=/^\(.+?\).*?$/,Ao=/^tuple(?<array>(\[(\d*)\])*)$/;function ko(e){let t=e.type;if(Ao.test(e.type)&&"components"in e){t="(";const n=e.components.length;for(let r=0;r<n;r++){t+=ko(e.components[r]),r<n-1&&(t+=", ")}const r=Io(Ao,e.type);return t+=`)${r?.array||""}`,ko({...e,type:t})}return"indexed"in e&&e.indexed&&(t=`${t} indexed`),e.name?`${t} ${e.name}`:t}function Mo(e){let t="";const n=e.length;for(let r=0;r<n;r++){t+=ko(e[r]),r!==n-1&&(t+=", ")}return t}const $o=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const Oo=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const jo=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;const So=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function No(e){return So.test(e)}function To(e){return Io(So,e)}const _o=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;const Ro=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;const Co=/^receive\(\) external payable$/;const Bo=new Set(["memory","indexed","storage","calldata"]),Do=new Set(["indexed"]),Uo=new Set(["calldata","memory","storage"]);class qo extends xo{constructor({signature:e}){super("Failed to parse ABI item.",{details:`parseAbiItem(${JSON.stringify(e,null,2)})`,docsPath:"/api/human#parseabiitem-1"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiItemError"})}}class Lo extends xo{constructor({type:e}){super("Unknown type.",{metaMessages:[`Type "${e}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownTypeError"})}}class Fo extends xo{constructor({type:e}){super("Unknown type.",{metaMessages:[`Type "${e}" is not a valid ABI type.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSolidityTypeError"})}}class Ko extends xo{constructor({params:e}){super("Failed to parse ABI parameters.",{details:`parseAbiParameters(${JSON.stringify(e,null,2)})`,docsPath:"/api/human#parseabiparameters-1"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiParametersError"})}}class Go extends xo{constructor({param:e}){super("Invalid ABI parameter.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class Vo extends xo{constructor({param:e,name:t}){super("Invalid ABI parameter.",{details:e,metaMessages:[`"${t}" is a protected Solidity keyword. More info: https://docs.soliditylang.org/en/latest/cheatsheet.html`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SolidityProtectedKeywordError"})}}class Zo extends xo{constructor({param:e,type:t,modifier:n}){super("Invalid ABI parameter.",{details:e,metaMessages:[`Modifier "${n}" not allowed${t?` in "${t}" type`:""}.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidModifierError"})}}class Ho extends xo{constructor({param:e,type:t,modifier:n}){super("Invalid ABI parameter.",{details:e,metaMessages:[`Modifier "${n}" not allowed${t?` in "${t}" type`:""}.`,`Data location can only be specified for array, struct, or mapping types, but "${n}" was given.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidFunctionModifierError"})}}class Wo extends xo{constructor({abiParameter:e}){super("Invalid ABI parameter.",{details:JSON.stringify(e,null,2),metaMessages:["ABI parameter type is invalid."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiTypeParameterError"})}}class Yo extends xo{constructor({signature:e,type:t}){super(`Invalid ${t} signature.`,{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class Qo extends xo{constructor({signature:e}){super("Unknown signature.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class Jo extends xo{constructor({signature:e}){super("Invalid struct signature.",{details:e,metaMessages:["No properties exist."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidStructSignatureError"})}}class Xo extends xo{constructor({type:e}){super("Circular reference detected.",{metaMessages:[`Struct "${e}" is a circular reference.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"CircularReferenceError"})}}class ec extends xo{constructor({current:e,depth:t}){super("Unbalanced parentheses.",{metaMessages:[`"${e.trim()}" has too many ${t>0?"opening":"closing"} parentheses.`],details:`Depth "${t}"`}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParenthesisError"})}}const tc=new Map([["address",{type:"address"}],["bool",{type:"bool"}],["bytes",{type:"bytes"}],["bytes32",{type:"bytes32"}],["int",{type:"int256"}],["int256",{type:"int256"}],["string",{type:"string"}],["uint",{type:"uint256"}],["uint8",{type:"uint8"}],["uint16",{type:"uint16"}],["uint24",{type:"uint24"}],["uint32",{type:"uint32"}],["uint64",{type:"uint64"}],["uint96",{type:"uint96"}],["uint112",{type:"uint112"}],["uint160",{type:"uint160"}],["uint192",{type:"uint192"}],["uint256",{type:"uint256"}],["address owner",{type:"address",name:"owner"}],["address to",{type:"address",name:"to"}],["bool approved",{type:"bool",name:"approved"}],["bytes _data",{type:"bytes",name:"_data"}],["bytes data",{type:"bytes",name:"data"}],["bytes signature",{type:"bytes",name:"signature"}],["bytes32 hash",{type:"bytes32",name:"hash"}],["bytes32 r",{type:"bytes32",name:"r"}],["bytes32 root",{type:"bytes32",name:"root"}],["bytes32 s",{type:"bytes32",name:"s"}],["string name",{type:"string",name:"name"}],["string symbol",{type:"string",name:"symbol"}],["string tokenURI",{type:"string",name:"tokenURI"}],["uint tokenId",{type:"uint256",name:"tokenId"}],["uint8 v",{type:"uint8",name:"v"}],["uint256 balance",{type:"uint256",name:"balance"}],["uint256 tokenId",{type:"uint256",name:"tokenId"}],["uint256 value",{type:"uint256",name:"value"}],["event:address indexed from",{type:"address",name:"from",indexed:!0}],["event:address indexed to",{type:"address",name:"to",indexed:!0}],["event:uint indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}],["event:uint256 indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}]]);function nc(e,t={}){if(function(e){return jo.test(e)}(e))return function(e,t={}){const n=function(e){return Io(jo,e)}(e);if(!n)throw new Yo({signature:e,type:"function"});const r=oc(n.parameters),s=[],i=r.length;for(let e=0;e<i;e++)s.push(ac(r[e],{modifiers:Uo,structs:t,type:"function"}));const a=[];if(n.returns){const e=oc(n.returns),r=e.length;for(let n=0;n<r;n++)a.push(ac(e[n],{modifiers:Uo,structs:t,type:"function"}))}return{name:n.name,type:"function",stateMutability:n.stateMutability??"nonpayable",inputs:s,outputs:a}}(e,t);if(function(e){return Oo.test(e)}(e))return function(e,t={}){const n=function(e){return Io(Oo,e)}(e);if(!n)throw new Yo({signature:e,type:"event"});const r=oc(n.parameters),s=[],i=r.length;for(let e=0;e<i;e++)s.push(ac(r[e],{modifiers:Do,structs:t,type:"event"}));return{name:n.name,type:"event",inputs:s}}(e,t);if(function(e){return $o.test(e)}(e))return function(e,t={}){const n=function(e){return Io($o,e)}(e);if(!n)throw new Yo({signature:e,type:"error"});const r=oc(n.parameters),s=[],i=r.length;for(let e=0;e<i;e++)s.push(ac(r[e],{structs:t,type:"error"}));return{name:n.name,type:"error",inputs:s}}(e,t);if(function(e){return _o.test(e)}(e))return function(e,t={}){const n=function(e){return Io(_o,e)}(e);if(!n)throw new Yo({signature:e,type:"constructor"});const r=oc(n.parameters),s=[],i=r.length;for(let e=0;e<i;e++)s.push(ac(r[e],{structs:t,type:"constructor"}));return{type:"constructor",stateMutability:n.stateMutability??"nonpayable",inputs:s}}(e,t);if(function(e){return Ro.test(e)}(e))return function(e){const t=function(e){return Io(Ro,e)}(e);if(!t)throw new Yo({signature:e,type:"fallback"});return{type:"fallback",stateMutability:t.stateMutability??"nonpayable"}}(e);if(function(e){return Co.test(e)}(e))return{type:"receive",stateMutability:"payable"};throw new Qo({signature:e})}const rc=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*(?:\spayable)?)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,sc=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,ic=/^u?int$/;function ac(e,t){const n=function(e,t,n){let r="";if(n)for(const e of Object.entries(n)){if(!e)continue;let t="";for(const n of e[1])t+=`[${n.type}${n.name?`:${n.name}`:""}]`;r+=`(${e[0]}{${t}})`}return t?`${t}:${e}${r}`:`${e}${r}`}(e,t?.type,t?.structs);if(tc.has(n))return tc.get(n);const r=Eo.test(e),s=Io(r?sc:rc,e);if(!s)throw new Go({param:e});if(s.name&&function(e){return"address"===e||"bool"===e||"function"===e||"string"===e||"tuple"===e||Po.test(e)||zo.test(e)||uc.test(e)}(s.name))throw new Vo({param:e,name:s.name});const i=s.name?{name:s.name}:{},a="indexed"===s.modifier?{indexed:!0}:{},o=t?.structs??{};let c,u={};if(r){c="tuple";const e=oc(s.type),t=[],n=e.length;for(let r=0;r<n;r++)t.push(ac(e[r],{structs:o}));u={components:t}}else if(s.type in o)c="tuple",u={components:o[s.type]};else if(ic.test(s.type))c=`${s.type}256`;else if("address payable"===s.type)c="address";else if(c=s.type,"struct"!==t?.type&&!cc(c))throw new Fo({type:c});if(s.modifier){if(!t?.modifiers?.has?.(s.modifier))throw new Zo({param:e,type:t?.type,modifier:s.modifier});if(Uo.has(s.modifier)&&!function(e,t){return t||"bytes"===e||"string"===e||"tuple"===e}(c,!!s.array))throw new Ho({param:e,type:t?.type,modifier:s.modifier})}const d={type:`${c}${s.array??""}`,...i,...a,...u};return tc.set(n,d),d}function oc(e,t=[],n="",r=0){const s=e.trim().length;for(let i=0;i<s;i++){const s=e[i],a=e.slice(i+1);switch(s){case",":return 0===r?oc(a,[...t,n.trim()]):oc(a,t,`${n}${s}`,r);case"(":return oc(a,t,`${n}${s}`,r+1);case")":return oc(a,t,`${n}${s}`,r-1);default:return oc(a,t,`${n}${s}`,r)}}if(""===n)return t;if(0!==r)throw new ec({current:n,depth:r});return t.push(n.trim()),t}function cc(e){return"address"===e||"bool"===e||"function"===e||"string"===e||Po.test(e)||zo.test(e)}const uc=/^(?:after|alias|anonymous|apply|auto|byte|calldata|case|catch|constant|copyof|default|defined|error|event|external|false|final|function|immutable|implements|in|indexed|inline|internal|let|mapping|match|memory|mutable|null|of|override|partial|private|promise|public|pure|reference|relocatable|return|returns|sizeof|static|storage|struct|super|supports|switch|this|true|try|typedef|typeof|var|view|virtual)$/;function dc(e){const t={},n=e.length;for(let r=0;r<n;r++){const n=e[r];if(!No(n))continue;const s=To(n);if(!s)throw new Yo({signature:n,type:"struct"});const i=s.properties.split(";"),a=[],o=i.length;for(let e=0;e<o;e++){const t=i[e].trim();if(!t)continue;const n=ac(t,{type:"struct"});a.push(n)}if(!a.length)throw new Jo({signature:n});t[s.name]=a}const r={},s=Object.entries(t),i=s.length;for(let e=0;e<i;e++){const[n,i]=s[e];r[n]=fc(i,t)}return r}const lc=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;function fc(e=[],t={},n=new Set){const r=[],s=e.length;for(let i=0;i<s;i++){const s=e[i];if(Eo.test(s.type))r.push(s);else{const e=Io(lc,s.type);if(!e?.type)throw new Wo({abiParameter:s});const{array:i,type:a}=e;if(a in t){if(n.has(a))throw new Xo({type:a});r.push({...s,type:`tuple${i??""}`,components:fc(t[a],t,new Set([...n,a]))})}else{if(!cc(a))throw new Lo({type:a});r.push(s)}}}return r}function pc(e){let t;if("string"==typeof e)t=nc(e);else{const n=dc(e),r=e.length;for(let s=0;s<r;s++){const r=e[s];if(!No(r)){t=nc(r,n);break}}}if(!t)throw new qo({signature:e});return t}function hc(e){const t=[];if("string"==typeof e){const n=oc(e),r=n.length;for(let e=0;e<r;e++)t.push(ac(n[e],{modifiers:Bo}))}else{const n=dc(e),r=e.length;for(let s=0;s<r;s++){const r=e[s];if(No(r))continue;const i=oc(r),a=i.length;for(let e=0;e<a;e++)t.push(ac(i[e],{modifiers:Bo,structs:n}))}}if(0===t.length)throw new Ko({params:e});return t}class mc extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&void 0!==t&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const e=this.keys().next().value;e&&this.delete(e)}return this}}const yc={checksum:new mc(8192)}.checksum;function bc(e,t={}){const{as:n=("string"==typeof e?"Hex":"Bytes")}=t,r=Nt(Mi(e));return"Bytes"===n?r:Vi(r)}const gc=/^0x[a-fA-F0-9]{40}$/;function wc(e,t={}){const{strict:n=!0}=t;if(!gc.test(e))throw new xc({address:e,cause:new Ic});if(n){if(e.toLowerCase()===e)return;if(vc(e)!==e)throw new xc({address:e,cause:new Pc})}}function vc(e){if(yc.has(e))return yc.get(e);wc(e,{strict:!1});const t=e.substring(2).toLowerCase(),n=bc(Oi(t),{as:"Bytes"}),r=t.split("");for(let e=0;e<40;e+=2)n[e>>1]>>4>=8&&r[e]&&(r[e]=r[e].toUpperCase()),(15&n[e>>1])>=8&&r[e+1]&&(r[e+1]=r[e+1].toUpperCase());const s=`0x${r.join("")}`;return yc.set(e,s),s}class xc extends gi{constructor({address:e,cause:t}){super(`Address "${e}" is invalid.`,{cause:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}class Ic extends gi{constructor(){super("Address is not a 20 byte (40 hexadecimal character) value."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidInputError"})}}class Pc extends gi{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}const zc=/^(.*)\[([0-9]*)\]$/,Ec=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Ac=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/,kc=2n**256n-1n;function Mc(e,t,n){const{checksumAddress:r,staticPosition:s}=n,i=Nc(t.type);if(i){const[n,a]=i;return function(e,t,n){const{checksumAddress:r,length:s,staticPosition:i}=n;if(!s){const n=i+_i(e.readBytes(Oc)),s=n+$c;e.setPosition(n);const a=_i(e.readBytes($c)),o=Tc(t);let c=0;const u=[];for(let n=0;n<a;++n){e.setPosition(s+(o?32*n:c));const[i,a]=Mc(e,t,{checksumAddress:r,staticPosition:s});c+=a,u.push(i)}return e.setPosition(i+32),[u,32]}if(Tc(t)){const n=i+_i(e.readBytes(Oc)),a=[];for(let i=0;i<s;++i){e.setPosition(n+32*i);const[s]=Mc(e,t,{checksumAddress:r,staticPosition:n});a.push(s)}return e.setPosition(i+32),[a,32]}let a=0;const o=[];for(let n=0;n<s;++n){const[n,s]=Mc(e,t,{checksumAddress:r,staticPosition:i+a});a+=s,o.push(n)}return[o,a]}(e,{...t,type:a},{checksumAddress:r,length:n,staticPosition:s})}if("tuple"===t.type)return function(e,t,n){const{checksumAddress:r,staticPosition:s}=n,i=0===t.components.length||t.components.some((({name:e})=>!e)),a=i?[]:{};let o=0;if(Tc(t)){const n=s+_i(e.readBytes(Oc));for(let s=0;s<t.components.length;++s){const c=t.components[s];e.setPosition(n+o);const[u,d]=Mc(e,c,{checksumAddress:r,staticPosition:n});o+=d,a[i?s:c?.name]=u}return e.setPosition(s+32),[a,32]}for(let n=0;n<t.components.length;++n){const c=t.components[n],[u,d]=Mc(e,c,{checksumAddress:r,staticPosition:s});a[i?n:c?.name]=u,o+=d}return[a,o]}(e,t,{checksumAddress:r,staticPosition:s});if("address"===t.type)return function(e,t={}){const{checksum:n=!1}=t,r=e.readBytes(32),s=e=>n?vc(e):e;return[s(Vi(Si(r,-20))),32]}(e,{checksum:r});if("bool"===t.type)return function(e){return[Ti(e.readBytes(32),{size:32}),32]}(e);if(t.type.startsWith("bytes"))return function(e,t,{staticPosition:n}){const[r,s]=t.type.split("bytes");if(!s){const t=_i(e.readBytes(32));e.setPosition(n+t);const r=_i(e.readBytes(32));if(0===r)return e.setPosition(n+32),["0x",32];const s=e.readBytes(r);return e.setPosition(n+32),[Vi(s),32]}const i=Vi(e.readBytes(Number.parseInt(s,10),32));return[i,32]}(e,t,{staticPosition:s});if(t.type.startsWith("uint")||t.type.startsWith("int"))return function(e,t){const n=t.type.startsWith("int"),r=Number.parseInt(t.type.split("int")[1]||"256",10),s=e.readBytes(32);return[r>48?Ni(s,{signed:n}):_i(s,{signed:n}),32]}(e,t);if("string"===t.type)return function(e,{staticPosition:t}){const n=_i(e.readBytes(32)),r=t+n;e.setPosition(r);const s=_i(e.readBytes(32));if(0===s)return e.setPosition(t+32),["",32];const i=e.readBytes(s,32),a=Ri(Ci(i));return e.setPosition(t+32),[a,32]}(e,{staticPosition:s});throw new Wc(t.type)}const $c=32,Oc=32;function jc({checksumAddress:e=!1,parameter:t,value:n}){const r=t,s=Nc(r.type);if(s){const[t,i]=s;return function(e,t){const{checksumAddress:n,length:r,parameter:s}=t,i=null===r;if(!Array.isArray(e))throw new Hc(e);if(!i&&e.length!==r)throw new Gc({expectedLength:r,givenLength:e.length,type:`${s.type}[${r}]`});let a=!1;const o=[];for(let t=0;t<e.length;t++){const r=jc({checksumAddress:n,parameter:s,value:e[t]});r.dynamic&&(a=!0),o.push(r)}if(i||a){const e=Sc(o);if(i){const t=Zi(o.length,{size:32});return{dynamic:!0,encoded:o.length>0?Ki(t,e):t}}if(a)return{dynamic:!0,encoded:e}}return{dynamic:!1,encoded:Ki(...o.map((({encoded:e})=>e)))}}(n,{checksumAddress:e,length:t,parameter:{...r,type:i}})}if("tuple"===r.type)return function(e,t){const{checksumAddress:n,parameter:r}=t;let s=!1;const i=[];for(let t=0;t<r.components.length;t++){const a=r.components[t],o=jc({checksumAddress:n,parameter:a,value:e[Array.isArray(e)?t:a.name]});i.push(o),o.dynamic&&(s=!0)}return{dynamic:s,encoded:s?Sc(i):Ki(...i.map((({encoded:e})=>e)))}}(n,{checksumAddress:e,parameter:r});if("address"===r.type)return function(e,t){const{checksum:n=!1}=t;return wc(e,{strict:n}),{dynamic:!1,encoded:Wi(e.toLowerCase())}}(n,{checksum:e});if("bool"===r.type)return function(e){if("boolean"!=typeof e)throw new gi(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:Wi(Gi(e))}}(n);if(r.type.startsWith("uint")||r.type.startsWith("int")){const e=r.type.startsWith("int"),[,,t="256"]=Ac.exec(r.type)??[];return function(e,{signed:t,size:n}){if("number"==typeof n){const r=2n**(BigInt(n)-(t?1n:0n))-1n,s=t?-r-1n:0n;if(e>r||e<s)throw new ta({max:r.toString(),min:s.toString(),signed:t,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:Zi(e,{size:32,signed:t})}}(n,{signed:e,size:Number(t)})}if(r.type.startsWith("bytes"))return function(e,{type:t}){const[,n]=t.split("bytes"),r=Ji(e);if(!n){let t=e;return r%32!=0&&(t=Yi(t,32*Math.ceil((e.length-2)/2/32))),{dynamic:!0,encoded:Ki(Wi(Zi(r,{size:32})),t)}}if(r!==Number.parseInt(n,10))throw new Vc({expectedSize:Number.parseInt(n,10),value:e});return{dynamic:!1,encoded:Yi(e)}}(n,{type:r.type});if("string"===r.type)return function(e){const t=Hi(e),n=Math.ceil(Ji(t)/32),r=[];for(let e=0;e<n;e++)r.push(Yi(Qi(t,32*e,32*(e+1))));return{dynamic:!0,encoded:Ki(Yi(Zi(Ji(t),{size:32})),...r)}}(n);throw new Wc(r.type)}function Sc(e){let t=0;for(let n=0;n<e.length;n++){const{dynamic:r,encoded:s}=e[n];t+=r?32:Ji(s)}const n=[],r=[];let s=0;for(let i=0;i<e.length;i++){const{dynamic:a,encoded:o}=e[i];a?(n.push(Zi(t+s,{size:32})),r.push(o),s+=Ji(o)):n.push(o)}return Ki(...n,...r)}function Nc(e){const t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}function Tc(e){const{type:t}=e;if("string"===t)return!0;if("bytes"===t)return!0;if(t.endsWith("[]"))return!0;if("tuple"===t)return e.components?.some(Tc);const n=Nc(e.type);return!(!n||!Tc({...e,type:n[1]}))}const _c={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new Bc({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new Cc({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new Rc({offset:e});const t=this.position-e;this.assertPosition(t),this.position=t},getReadCount(e){return this.positionReadCount.get(e||this.position)||0},incrementPosition(e){if(e<0)throw new Rc({offset:e});const t=this.position+e;this.assertPosition(t),this.position=t},inspectByte(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectBytes(e,t){const n=t??this.position;return this.assertPosition(n+e-1),this.bytes.subarray(n,n+e)},inspectUint8(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectUint16(e){const t=e??this.position;return this.assertPosition(t+1),this.dataView.getUint16(t)},inspectUint24(e){const t=e??this.position;return this.assertPosition(t+2),(this.dataView.getUint16(t)<<8)+this.dataView.getUint8(t+2)},inspectUint32(e){const t=e??this.position;return this.assertPosition(t+3),this.dataView.getUint32(t)},pushByte(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushBytes(e){this.assertPosition(this.position+e.length-1),this.bytes.set(e,this.position),this.position+=e.length},pushUint8(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushUint16(e){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,e),this.position+=2},pushUint24(e){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,e>>8),this.dataView.setUint8(this.position+2,255&e),this.position+=3},pushUint32(e){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,e),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const e=this.inspectByte();return this.position++,e},readBytes(e,t){this.assertReadLimit(),this._touch();const n=this.inspectBytes(e);return this.position+=t??e,n},readUint8(){this.assertReadLimit(),this._touch();const e=this.inspectUint8();return this.position+=1,e},readUint16(){this.assertReadLimit(),this._touch();const e=this.inspectUint16();return this.position+=2,e},readUint24(){this.assertReadLimit(),this._touch();const e=this.inspectUint24();return this.position+=3,e},readUint32(){this.assertReadLimit(),this._touch();const e=this.inspectUint32();return this.position+=4,e},get remaining(){return this.bytes.length-this.position},setPosition(e){const t=this.position;return this.assertPosition(e),this.position=e,()=>this.position=t},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const e=this.getReadCount();this.positionReadCount.set(this.position,e+1),e>0&&this.recursiveReadCount++}};class Rc extends gi{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.NegativeOffsetError"})}}class Cc extends gi{constructor({length:e,position:t}){super(`Position \`${t}\` is out of bounds (\`0 < position < ${e}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.PositionOutOfBoundsError"})}}class Bc extends gi{constructor({count:e,limit:t}){super(`Recursive read limit of \`${t}\` exceeded (recursive read count: \`${e}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.RecursiveReadLimitExceededError"})}}function Dc(e,t,n={}){const{as:r="Array",checksumAddress:s=!1}=n,i="string"==typeof t?$i(t):t,a=function(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(_c);return n.bytes=e,n.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=t,n}(i);if(0===ji(i)&&e.length>0)throw new Kc;if(ji(i)&&ji(i)<32)throw new Fc({data:"string"==typeof t?t:Vi(t),parameters:e,size:ji(i)});let o=0;const c="Array"===r?[]:{};for(let t=0;t<e.length;++t){const n=e[t];a.setPosition(o);const[i,u]=Mc(a,n,{checksumAddress:s,staticPosition:0});o+=u,"Array"===r?c.push(i):c[n.name??t]=i}return c}function Uc(e,t,n){const{checksumAddress:r=!1}=n??{};if(e.length!==t.length)throw new Zc({expectedLength:e.length,givenLength:t.length});const s=function({checksumAddress:e,parameters:t,values:n}){const r=[];for(let s=0;s<t.length;s++)r.push(jc({checksumAddress:e,parameter:t[s],value:n[s]}));return r}({checksumAddress:r,parameters:e,values:t}),i=Sc(s);return 0===i.length?"0x":i}function qc(e,t){if(e.length!==t.length)throw new Zc({expectedLength:e.length,givenLength:t.length});const n=[];for(let r=0;r<e.length;r++){const s=e[r],i=t[r];n.push(qc.encode(s,i))}return Ki(...n)}function Lc(e){return Array.isArray(e)&&"string"==typeof e[0]||"string"==typeof e?hc(e):e}(qc||(qc={})).encode=function e(t,n,r=!1){if("address"===t){const e=n;return wc(e),Wi(e.toLowerCase(),r?32:0)}if("string"===t)return Hi(n);if("bytes"===t)return n;if("bool"===t)return Wi(Gi(n),r?32:1);const s=t.match(Ac);if(s){const[e,t,i="256"]=s,a=Number.parseInt(i,10)/8;return Zi(n,{size:r?32:a,signed:"int"===t})}const i=t.match(Ec);if(i){const[e,t]=i;if(Number.parseInt(t,10)!==(n.length-2)/2)throw new Vc({expectedSize:Number.parseInt(t,10),value:n});return Yi(n,r?32:0)}const a=t.match(zc);if(a&&Array.isArray(n)){const[t,r]=a,s=[];for(let t=0;t<n.length;t++)s.push(e(r,n[t],!0));return 0===s.length?"0x":Ki(...s)}throw new Wc(t)};class Fc extends gi{constructor({data:e,parameters:t,size:n}){super(`Data size of ${n} bytes is too small for given parameters.`,{metaMessages:[`Params: (${Mo(t)})`,`Data: ${e} (${n} bytes)`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.DataSizeTooSmallError"})}}class Kc extends gi{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.'),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ZeroDataError"})}}class Gc extends gi{constructor({expectedLength:e,givenLength:t,type:n}){super(`Array length mismatch for type \`${n}\`. Expected: \`${e}\`. Given: \`${t}\`.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ArrayLengthMismatchError"})}}class Vc extends gi{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${Ji(t)}) does not match expected size (bytes${e}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.BytesSizeMismatchError"})}}class Zc extends gi{constructor({expectedLength:e,givenLength:t}){super(["ABI encoding parameters/values length mismatch.",`Expected length (parameters): ${e}`,`Given length (values): ${t}`].join("\n")),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.LengthMismatchError"})}}class Hc extends gi{constructor(e){super(`Value \`${e}\` is not a valid array.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidArrayError"})}}class Wc extends gi{constructor(e){super(`Type \`${e}\` is not a valid ABI Type.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidTypeError"})}}class Yc extends mt{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");at(e.outputLen),at(e.blockLen)}(e);const n=ht(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 r=this.blockLen,s=new Uint8Array(r);s.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<s.length;e++)s[e]^=54;this.iHash.update(s),this.oHash=e.create();for(let e=0;e<s.length;e++)s[e]^=106;this.oHash.update(s),dt(s)}update(e){return ct(this),this.iHash.update(e),this}digestInto(e){ct(this),ot(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:n,finished:r,destroyed:s,blockLen:i,outputLen:a}=this;return e.finished=r,e.destroyed=s,e.blockLen=i,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Qc=(e,t,n)=>new Yc(e,t).update(n).digest();Qc.create=(e,t)=>new Yc(e,t);const Jc=BigInt(0),Xc=BigInt(1),eu=BigInt(2),tu=BigInt(3),nu=BigInt(4),ru=BigInt(5),su=BigInt(8);function iu(e,t){const n=e%t;return n>=Jc?n:t+n}function au(e,t,n){let r=e;for(;t-- >Jc;)r*=r,r%=n;return r}function ou(e,t){if(e===Jc)throw new Error("invert: expected non-zero number");if(t<=Jc)throw new Error("invert: expected positive modulus, got "+t);let n=iu(e,t),r=t,s=Jc,i=Xc;for(;n!==Jc;){const e=r%n,t=s-i*(r/n);r=n,n=e,s=i,i=t}if(r!==Xc)throw new Error("invert: does not exist");return iu(s,t)}function cu(e,t){const n=(e.ORDER+Xc)/nu,r=e.pow(t,n);if(!e.eql(e.sqr(r),t))throw new Error("Cannot find square root");return r}function uu(e,t){const n=(e.ORDER-ru)/su,r=e.mul(t,eu),s=e.pow(r,n),i=e.mul(t,s),a=e.mul(e.mul(i,eu),s),o=e.mul(i,e.sub(a,e.ONE));if(!e.eql(e.sqr(o),t))throw new Error("Cannot find square root");return o}function du(e){return e%nu===tu?cu:e%su===ru?uu:function(e){if(e<BigInt(3))throw new Error("sqrt is not defined for small field");let t=e-Xc,n=0;for(;t%eu===Jc;)t/=eu,n++;let r=eu;const s=yu(e);for(;1===hu(s,r);)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return cu;let i=s.pow(r,t);const a=(t+Xc)/eu;return function(e,r){if(e.is0(r))return r;if(1!==hu(e,r))throw new Error("Cannot find square root");let s=n,o=e.mul(e.ONE,i),c=e.pow(r,t),u=e.pow(r,a);for(;!e.eql(c,e.ONE);){if(e.is0(c))return e.ZERO;let t=1,n=e.sqr(c);for(;!e.eql(n,e.ONE);)if(t++,n=e.sqr(n),t===s)throw new Error("Cannot find square root");const r=Xc<<BigInt(s-t-1),i=e.pow(o,r);s=t,o=e.sqr(i),c=e.mul(c,o),u=e.mul(u,i)}return u}}(e)}const lu=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function fu(e){return yi(e,lu.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"}))}function pu(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),s=t.reduce(((t,n,s)=>e.is0(n)?t:(r[s]=t,e.mul(t,n))),e.ONE),i=e.inv(s);return t.reduceRight(((t,n,s)=>e.is0(n)?t:(r[s]=e.mul(t,r[s]),e.mul(t,n))),i),r}function hu(e,t){const n=(e.ORDER-Xc)/eu,r=e.pow(t,n),s=e.eql(r,e.ONE),i=e.eql(r,e.ZERO),a=e.eql(r,e.neg(e.ONE));if(!s&&!i&&!a)throw new Error("invalid Legendre symbol result");return s?1:i?0:-1}function mu(e,t){void 0!==t&&at(t);const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function yu(e,t,n=!1,r={}){if(e<=Jc)throw new Error("invalid field: expected ORDER > 0, got "+e);const{nBitLength:s,nByteLength:i}=mu(e,t);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let a;const o=Object.freeze({ORDER:e,isLE:n,BITS:s,BYTES:i,MASK:fi(s),ZERO:Jc,ONE:Xc,create:t=>iu(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return Jc<=t&&t<e},is0:e=>e===Jc,isOdd:e=>(e&Xc)===Xc,neg:t=>iu(-t,e),eql:(e,t)=>e===t,sqr:t=>iu(t*t,e),add:(t,n)=>iu(t+n,e),sub:(t,n)=>iu(t-n,e),mul:(t,n)=>iu(t*n,e),pow:(e,t)=>function(e,t,n){if(n<Jc)throw new Error("invalid exponent, negatives unsupported");if(n===Jc)return e.ONE;if(n===Xc)return t;let r=e.ONE,s=t;for(;n>Jc;)n&Xc&&(r=e.mul(r,s)),s=e.sqr(s),n>>=Xc;return r}(o,e,t),div:(t,n)=>iu(t*ou(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>ou(t,e),sqrt:r.sqrt||(t=>(a||(a=du(e)),a(o,t))),toBytes:e=>n?ii(e,i):si(e,i),fromBytes:e=>{if(e.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+e.length);return n?ri(e):ni(e)},invertBatch:e=>pu(o,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(o)}function bu(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function gu(e){const t=bu(e);return t+Math.ceil(t/2)}const wu=BigInt(0),vu=BigInt(1);function xu(e,t){const n=t.negate();return e?n:t}function Iu(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Pu(e,t){Iu(e,t);const n=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:fi(e),maxNumber:n,shiftBy:BigInt(e)}}function zu(e,t,n){const{windowSize:r,mask:s,maxNumber:i,shiftBy:a}=n;let o=Number(e&s),c=e>>a;o>r&&(o-=i,c+=vu);const u=t*r;return{nextN:c,offset:u+Math.abs(o)-1,isZero:0===o,isNeg:o<0,isNegF:t%2!=0,offsetF:u}}const Eu=new WeakMap,Au=new WeakMap;function ku(e){return Au.get(e)||1}function Mu(e,t,n,r){!function(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach(((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)}))}(n,e),function(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach(((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)}))}(r,t);const s=n.length,i=r.length;if(s!==i)throw new Error("arrays of points and scalars must have equal length");const a=e.ZERO,o=function(e){let t;for(t=0;e>Fs;e>>=Ks,t+=1);return t}(BigInt(s));let c=1;o>12?c=o-3:o>4?c=o-2:o>0&&(c=2);const u=fi(c),d=new Array(Number(u)+1).fill(a);let l=a;for(let e=Math.floor((t.BITS-1)/c)*c;e>=0;e-=c){d.fill(a);for(let t=0;t<i;t++){const s=r[t],i=Number(s>>BigInt(e)&u);d[i]=d[i].add(n[t])}let t=a;for(let e=d.length-1,n=a;e>0;e--)n=n.add(d[e]),t=t.add(n);if(l=l.add(t),0!==e)for(let e=0;e<c;e++)l=l.double()}return l}function $u(e){return fu(e.Fp),yi(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...mu(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}function Ou(e){void 0!==e.lowS&&Zs("lowS",e.lowS),void 0!==e.prehash&&Zs("prehash",e.prehash)}class ju extends Error{constructor(e=""){super(e)}}const Su={Err:ju,_tlv:{encode:(e,t)=>{const{Err:n}=Su;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(1&t.length)throw new n("tlv.encode: unpadded data");const r=t.length/2,s=Hs(r);if(s.length/2&128)throw new n("tlv.encode: long form length too big");const i=r>127?Hs(s.length/2|128):"";return Hs(e)+i+s+t},decode(e,t){const{Err:n}=Su;let r=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[r++]!==e)throw new n("tlv.decode: wrong tlv");const s=t[r++];let i=0;if(!!(128&s)){const e=127&s;if(!e)throw new n("tlv.decode(long): indefinite length not supported");if(e>4)throw new n("tlv.decode(long): byte length is too big");const a=t.subarray(r,r+e);if(a.length!==e)throw new n("tlv.decode: length bytes not complete");if(0===a[0])throw new n("tlv.decode(long): zero leftmost byte");for(const e of a)i=i<<8|e;if(r+=e,i<128)throw new n("tlv.decode(long): not minimal encoding")}else i=s;const a=t.subarray(r,r+i);if(a.length!==i)throw new n("tlv.decode: wrong value length");return{v:a,l:t.subarray(r+i)}}},_int:{encode(e){const{Err:t}=Su;if(e<Tu)throw new t("integer: negative integers are not allowed");let n=Hs(e);if(8&Number.parseInt(n[0],16)&&(n="00"+n),1&n.length)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){const{Err:t}=Su;if(128&e[0])throw new t("invalid signature integer: negative");if(0===e[0]&&!(128&e[1]))throw new t("invalid signature integer: unnecessary leading zero");return ni(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=Su,s=ai("signature",e),{v:i,l:a}=r.decode(48,s);if(a.length)throw new t("invalid signature: left bytes after parsing");const{v:o,l:c}=r.decode(2,i),{v:u,l:d}=r.decode(2,c);if(d.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(o),s:n.decode(u)}},hexFromSig(e){const{_tlv:t,_int:n}=Su,r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}};function Nu(e,t){return Js(si(e,t))}const Tu=BigInt(0),_u=BigInt(1),Ru=BigInt(2),Cu=BigInt(3),Bu=BigInt(4);function Du(e){const t=function(e){const t=$u(e);yi(t,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});const{endo:n,Fp:r,a:s}=t;if(n){if(!r.eql(s,r.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...t})}(e),{Fp:n}=t,r=yu(t.n,t.nBitLength),s=t.toBytes||((e,t,r)=>{const s=t.toAffine();return oi(Uint8Array.from([4]),n.toBytes(s.x),n.toBytes(s.y))}),i=t.fromBytes||(e=>{const t=e.subarray(1);return{x:n.fromBytes(t.subarray(0,n.BYTES)),y:n.fromBytes(t.subarray(n.BYTES,2*n.BYTES))}});function a(e){const{a:r,b:s}=t,i=n.sqr(e),a=n.mul(i,e);return n.add(n.add(a,n.mul(e,r)),s)}function o(e,t){const r=n.sqr(t),s=a(e);return n.eql(r,s)}if(!o(t.Gx,t.Gy))throw new Error("bad curve params: generator point");const c=n.mul(n.pow(t.a,Cu),Bu),u=n.mul(n.sqr(t.b),BigInt(27));if(n.is0(n.add(c,u)))throw new Error("bad curve params: a or b");function d(e){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:s,n:i}=t;if(n&&"bigint"!=typeof e){if(Gs(e)&&(e=Js(e)),"string"!=typeof e||!n.includes(e.length))throw new Error("invalid private key");e=e.padStart(2*r,"0")}let a;try{a="bigint"==typeof e?e:ni(ai("private key",e,r))}catch(t){throw new Error("invalid private key, expected hex or "+r+" bytes, got "+typeof e)}return s&&(a=iu(a,i)),li("private key",a,_u,i),a}function l(e){if(!(e instanceof h))throw new Error("ProjectivePoint expected")}const f=bi(((e,t)=>{const{px:r,py:s,pz:i}=e;if(n.eql(i,n.ONE))return{x:r,y:s};const a=e.is0();null==t&&(t=a?n.ONE:n.inv(i));const o=n.mul(r,t),c=n.mul(s,t),u=n.mul(i,t);if(a)return{x:n.ZERO,y:n.ZERO};if(!n.eql(u,n.ONE))throw new Error("invZ was invalid");return{x:o,y:c}})),p=bi((e=>{if(e.is0()){if(t.allowInfinityPoint&&!n.is0(e.py))return;throw new Error("bad point: ZERO")}const{x:r,y:s}=e.toAffine();if(!n.isValid(r)||!n.isValid(s))throw new Error("bad point: x or y not FE");if(!o(r,s))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0}));class h{constructor(e,t,r){if(null==e||!n.isValid(e))throw new Error("x required");if(null==t||!n.isValid(t)||n.is0(t))throw new Error("y required");if(null==r||!n.isValid(r))throw new Error("z required");this.px=e,this.py=t,this.pz=r,Object.freeze(this)}static fromAffine(e){const{x:t,y:r}=e||{};if(!e||!n.isValid(t)||!n.isValid(r))throw new Error("invalid affine point");if(e instanceof h)throw new Error("projective point not allowed");const s=e=>n.eql(e,n.ZERO);return s(t)&&s(r)?h.ZERO:new h(t,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=pu(n,e.map((e=>e.pz)));return e.map(((e,n)=>e.toAffine(t[n]))).map(h.fromAffine)}static fromHex(e){const t=h.fromAffine(i(ai("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return h.BASE.multiply(d(e))}static msm(e,t){return Mu(h,r,e,t)}_setWindowSize(e){b.setWindowSize(this,e)}assertValidity(){p(this)}hasEvenY(){const{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){l(e);const{px:t,py:r,pz:s}=this,{px:i,py:a,pz:o}=e,c=n.eql(n.mul(t,o),n.mul(i,s)),u=n.eql(n.mul(r,o),n.mul(a,s));return c&&u}negate(){return new h(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:r}=t,s=n.mul(r,Cu),{px:i,py:a,pz:o}=this;let c=n.ZERO,u=n.ZERO,d=n.ZERO,l=n.mul(i,i),f=n.mul(a,a),p=n.mul(o,o),m=n.mul(i,a);return m=n.add(m,m),d=n.mul(i,o),d=n.add(d,d),c=n.mul(e,d),u=n.mul(s,p),u=n.add(c,u),c=n.sub(f,u),u=n.add(f,u),u=n.mul(c,u),c=n.mul(m,c),d=n.mul(s,d),p=n.mul(e,p),m=n.sub(l,p),m=n.mul(e,m),m=n.add(m,d),d=n.add(l,l),l=n.add(d,l),l=n.add(l,p),l=n.mul(l,m),u=n.add(u,l),p=n.mul(a,o),p=n.add(p,p),l=n.mul(p,m),c=n.sub(c,l),d=n.mul(p,f),d=n.add(d,d),d=n.add(d,d),new h(c,u,d)}add(e){l(e);const{px:r,py:s,pz:i}=this,{px:a,py:o,pz:c}=e;let u=n.ZERO,d=n.ZERO,f=n.ZERO;const p=t.a,m=n.mul(t.b,Cu);let y=n.mul(r,a),b=n.mul(s,o),g=n.mul(i,c),w=n.add(r,s),v=n.add(a,o);w=n.mul(w,v),v=n.add(y,b),w=n.sub(w,v),v=n.add(r,i);let x=n.add(a,c);return v=n.mul(v,x),x=n.add(y,g),v=n.sub(v,x),x=n.add(s,i),u=n.add(o,c),x=n.mul(x,u),u=n.add(b,g),x=n.sub(x,u),f=n.mul(p,v),u=n.mul(m,g),f=n.add(u,f),u=n.sub(b,f),f=n.add(b,f),d=n.mul(u,f),b=n.add(y,y),b=n.add(b,y),g=n.mul(p,g),v=n.mul(m,v),b=n.add(b,g),g=n.sub(y,g),g=n.mul(p,g),v=n.add(v,g),y=n.mul(b,v),d=n.add(d,y),y=n.mul(x,v),u=n.mul(w,u),u=n.sub(u,y),y=n.mul(w,b),f=n.mul(x,f),f=n.add(f,y),new h(u,d,f)}subtract(e){return this.add(e.negate())}is0(){return this.equals(h.ZERO)}wNAF(e){return b.wNAFCached(this,e,h.normalizeZ)}multiplyUnsafe(e){const{endo:r,n:s}=t;li("scalar",e,Tu,s);const i=h.ZERO;if(e===Tu)return i;if(this.is0()||e===_u)return this;if(!r||b.hasPrecomputes(this))return b.wNAFCachedUnsafe(this,e,h.normalizeZ);let{k1neg:a,k1:o,k2neg:c,k2:u}=r.splitScalar(e),d=i,l=i,f=this;for(;o>Tu||u>Tu;)o&_u&&(d=d.add(f)),u&_u&&(l=l.add(f)),f=f.double(),o>>=_u,u>>=_u;return a&&(d=d.negate()),c&&(l=l.negate()),l=new h(n.mul(l.px,r.beta),l.py,l.pz),d.add(l)}multiply(e){const{endo:r,n:s}=t;let i,a;if(li("scalar",e,_u,s),r){const{k1neg:t,k1:s,k2neg:o,k2:c}=r.splitScalar(e);let{p:u,f:d}=this.wNAF(s),{p:l,f:f}=this.wNAF(c);u=b.constTimeNegate(t,u),l=b.constTimeNegate(o,l),l=new h(n.mul(l.px,r.beta),l.py,l.pz),i=u.add(l),a=d.add(f)}else{const{p:t,f:n}=this.wNAF(e);i=t,a=n}return h.normalizeZ([i,a])[0]}multiplyAndAddUnsafe(e,t,n){const r=h.BASE,s=(e,t)=>t!==Tu&&t!==_u&&e.equals(r)?e.multiply(t):e.multiplyUnsafe(t),i=s(this,t).add(s(e,n));return i.is0()?void 0:i}toAffine(e){return f(this,e)}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e===_u)return!0;if(n)return n(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:n}=t;return e===_u?this:n?n(h,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return Zs("isCompressed",e),this.assertValidity(),s(h,this,e)}toHex(e=!0){return Zs("isCompressed",e),Js(this.toRawBytes(e))}}h.BASE=new h(t.Gx,t.Gy,n.ONE),h.ZERO=new h(n.ZERO,n.ONE,n.ZERO);const{endo:m,nBitLength:y}=t,b=(g=h,w=m?Math.ceil(y/2):y,{constTimeNegate:xu,hasPrecomputes:e=>1!==ku(e),unsafeLadder(e,t,n=g.ZERO){let r=e;for(;t>wu;)t&vu&&(n=n.add(r)),r=r.double(),t>>=vu;return n},precomputeWindow(e,t){const{windows:n,windowSize:r}=Pu(t,w),s=[];let i=e,a=i;for(let e=0;e<n;e++){a=i,s.push(a);for(let e=1;e<r;e++)a=a.add(i),s.push(a);i=a.double()}return s},wNAF(e,t,n){let r=g.ZERO,s=g.BASE;const i=Pu(e,w);for(let e=0;e<i.windows;e++){const{nextN:a,offset:o,isZero:c,isNeg:u,isNegF:d,offsetF:l}=zu(n,e,i);n=a,c?s=s.add(xu(d,t[l])):r=r.add(xu(u,t[o]))}return{p:r,f:s}},wNAFUnsafe(e,t,n,r=g.ZERO){const s=Pu(e,w);for(let e=0;e<s.windows&&n!==wu;e++){const{nextN:i,offset:a,isZero:o,isNeg:c}=zu(n,e,s);if(n=i,!o){const e=t[a];r=r.add(c?e.negate():e)}}return r},getPrecomputes(e,t,n){let r=Eu.get(t);return r||(r=this.precomputeWindow(t,e),1!==e&&Eu.set(t,n(r))),r},wNAFCached(e,t,n){const r=ku(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)},wNAFCachedUnsafe(e,t,n,r){const s=ku(e);return 1===s?this.unsafeLadder(e,t,r):this.wNAFUnsafe(s,this.getPrecomputes(s,e,n),t,r)},setWindowSize(e,t){Iu(t,w),Au.set(e,t),Eu.delete(e)}});var g,w;return{CURVE:t,ProjectivePoint:h,normPrivateKeyToScalar:d,weierstrassEquation:a,isWithinCurveOrder:function(e){return di(e,_u,t.n)}}}function Uu(e){const t=function(e){const t=$u(e);return yi(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(e),{Fp:n,n:r,nByteLength:s,nBitLength:i}=t,a=n.BYTES+1,o=2*n.BYTES+1;function c(e){return iu(e,r)}function u(e){return ou(e,r)}const{ProjectivePoint:d,normPrivateKeyToScalar:l,weierstrassEquation:f,isWithinCurveOrder:p}=Du({...t,toBytes(e,t,r){const s=t.toAffine(),i=n.toBytes(s.x),a=oi;return Zs("isCompressed",r),r?a(Uint8Array.from([t.hasEvenY()?2:3]),i):a(Uint8Array.from([4]),i,n.toBytes(s.y))},fromBytes(e){const t=e.length,r=e[0],s=e.subarray(1);if(t!==a||2!==r&&3!==r){if(t===o&&4===r){return{x:n.fromBytes(s.subarray(0,n.BYTES)),y:n.fromBytes(s.subarray(n.BYTES,2*n.BYTES))}}throw new Error("invalid Point, expected length of "+a+", or uncompressed "+o+", got "+t)}{const e=ni(s);if(!di(e,_u,n.ORDER))throw new Error("Point is not on curve");const t=f(e);let i;try{i=n.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("Point is not on curve"+t)}return 1==(1&r)!==((i&_u)===_u)&&(i=n.neg(i)),{x:e,y:i}}}});function h(e){return e>r>>_u}const m=(e,t,n)=>ni(e.slice(t,n));class y{constructor(e,t,n){li("r",e,_u,r),li("s",t,_u,r),this.r=e,this.s=t,null!=n&&(this.recovery=n),Object.freeze(this)}static fromCompact(e){const t=s;return e=ai("compactSignature",e,2*t),new y(m(e,0,t),m(e,t,2*t))}static fromDER(e){const{r:t,s:n}=Su.toSig(ai("DER",e));return new y(t,n)}assertValidity(){}addRecoveryBit(e){return new y(this.r,this.s,e)}recoverPublicKey(e){const{r:r,s:s,recovery:i}=this,a=v(ai("msgHash",e));if(null==i||![0,1,2,3].includes(i))throw new Error("recovery id invalid");const o=2===i||3===i?r+t.n:r;if(o>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const l=0==(1&i)?"02":"03",f=d.fromHex(l+Nu(o,n.BYTES)),p=u(o),h=c(-a*p),m=c(s*p),y=d.BASE.multiplyAndAddUnsafe(f,h,m);if(!y)throw new Error("point at infinify");return y.assertValidity(),y}hasHighS(){return h(this.s)}normalizeS(){return this.hasHighS()?new y(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return ti(this.toDERHex())}toDERHex(){return Su.hexFromSig(this)}toCompactRawBytes(){return ti(this.toCompactHex())}toCompactHex(){const e=s;return Nu(this.r,e)+Nu(this.s,e)}}const b={isValidPrivateKey(e){try{return l(e),!0}catch(e){return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const e=gu(t.n);return function(e,t,n=!1){const r=e.length,s=bu(t),i=gu(t);if(r<16||r<i||r>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+r);const a=iu(n?ri(e):ni(e),t-Xc)+Xc;return n?ii(a,s):si(a,s)}(t.randomBytes(e),t.n)},precompute:(e=8,t=d.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function g(e){if("bigint"==typeof e)return!1;if(e instanceof d)return!0;const r=ai("key",e).length,i=n.BYTES,a=i+1,o=2*i+1;return t.allowedPrivateKeyLengths||s===a?void 0:r===a||r===o}const w=t.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=ni(e),n=8*e.length-i;return n>0?t>>BigInt(n):t},v=t.bits2int_modN||function(e){return c(w(e))},x=fi(i);function I(e){return li("num < 2^"+i,e,Tu,x),si(e,s)}function P(e,r,s=z){if(["recovered","canonical"].some((e=>e in s)))throw new Error("sign() legacy options not supported");const{hash:i,randomBytes:a}=t;let{lowS:o,prehash:f,extraEntropy:m}=s;null==o&&(o=!0),e=ai("msgHash",e),Ou(s),f&&(e=ai("prehashed msgHash",i(e)));const b=v(e),g=l(r),x=[I(g),I(b)];if(null!=m&&!1!==m){const e=!0===m?a(n.BYTES):m;x.push(ai("extraEntropy",e))}const P=oi(...x),E=b;return{seed:P,k2sig:function(e){const t=w(e);if(!p(t))return;const n=u(t),r=d.BASE.multiply(t).toAffine(),s=c(r.x);if(s===Tu)return;const i=c(n*c(E+s*g));if(i===Tu)return;let a=(r.x===s?0:2)|Number(r.y&_u),l=i;return o&&h(i)&&(l=function(e){return h(e)?c(-e):e}(i),a^=1),new y(s,l,a)}}}const z={lowS:t.lowS,prehash:!1},E={lowS:t.lowS,prehash:!1};return d.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return d.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,n=!0){if(!0===g(e))throw new Error("first arg must be private key");if(!1===g(t))throw new Error("second arg must be public key");return d.fromHex(t).multiply(l(e)).toRawBytes(n)},sign:function(e,n,r=z){const{seed:s,k2sig:i}=P(e,n,r),a=t,o=function(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");let r=pi(e),s=pi(e),i=0;const a=()=>{r.fill(1),s.fill(0),i=0},o=(...e)=>n(s,r,...e),c=(e=pi(0))=>{s=o(hi([0]),e),r=o(),0!==e.length&&(s=o(hi([1]),e),r=o())},u=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){r=o();const t=r.slice();n.push(t),e+=r.length}return oi(...n)};return(e,t)=>{let n;for(a(),c(e);!(n=t(u()));)c();return a(),n}}(a.hash.outputLen,a.nByteLength,a.hmac);return o(s,i)},verify:function(e,n,r,s=E){const i=e;n=ai("msgHash",n),r=ai("publicKey",r);const{lowS:a,prehash:o,format:l}=s;if(Ou(s),"strict"in s)throw new Error("options.strict was renamed to lowS");if(void 0!==l&&"compact"!==l&&"der"!==l)throw new Error("format must be compact or der");const f="string"==typeof i||Gs(i),p=!f&&!l&&"object"==typeof i&&null!==i&&"bigint"==typeof i.r&&"bigint"==typeof i.s;if(!f&&!p)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let h,m;try{if(p&&(h=new y(i.r,i.s)),f){try{"compact"!==l&&(h=y.fromDER(i))}catch(e){if(!(e instanceof Su.Err))throw e}h||"der"===l||(h=y.fromCompact(i))}m=d.fromHex(r)}catch(e){return!1}if(!h)return!1;if(a&&h.hasHighS())return!1;o&&(n=t.hash(n));const{r:b,s:g}=h,w=v(n),x=u(g),I=c(w*x),P=c(b*x),z=d.BASE.multiplyAndAddUnsafe(m,I,P)?.toAffine();return!!z&&c(z.x)===b},ProjectivePoint:d,Signature:y,utils:b}}function qu(e,t){if(fu(e),!e.isValid(t.A)||!e.isValid(t.B)||!e.isValid(t.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const n=function(e,t){const n=e.ORDER;let r=Tu;for(let e=n-_u;e%Ru===Tu;e/=Ru)r+=_u;const s=r,i=Ru<<s-_u-_u,a=i*Ru,o=(n-_u)/a,c=(o-_u)/Ru,u=a-_u,d=i,l=e.pow(t,o),f=e.pow(t,(o+_u)/Ru);let p=(t,n)=>{let r=l,i=e.pow(n,u),a=e.sqr(i);a=e.mul(a,n);let o=e.mul(t,a);o=e.pow(o,c),o=e.mul(o,i),i=e.mul(o,n),a=e.mul(o,t);let p=e.mul(a,i);o=e.pow(p,d);let h=e.eql(o,e.ONE);i=e.mul(a,f),o=e.mul(p,r),a=e.cmov(i,a,h),p=e.cmov(o,p,h);for(let t=s;t>_u;t--){let n=t-Ru;n=Ru<<n-_u;let s=e.pow(p,n);const o=e.eql(s,e.ONE);i=e.mul(a,r),r=e.mul(r,r),s=e.mul(p,r),a=e.cmov(i,a,o),p=e.cmov(s,p,o)}return{isValid:h,value:a}};if(e.ORDER%Bu===Cu){const n=(e.ORDER-Cu)/Bu,r=e.sqrt(e.neg(t));p=(t,s)=>{let i=e.sqr(s);const a=e.mul(t,s);i=e.mul(i,a);let o=e.pow(i,n);o=e.mul(o,a);const c=e.mul(o,r),u=e.mul(e.sqr(o),s),d=e.eql(u,t);return{isValid:d,value:e.cmov(c,o,d)}}}return p}(e,t.Z);if(!e.isOdd)throw new Error("Fp.isOdd is not implemented!");return r=>{let s,i,a,o,c,u,d,l;s=e.sqr(r),s=e.mul(s,t.Z),i=e.sqr(s),i=e.add(i,s),a=e.add(i,e.ONE),a=e.mul(a,t.B),o=e.cmov(t.Z,e.neg(i),!e.eql(i,e.ZERO)),o=e.mul(o,t.A),i=e.sqr(a),u=e.sqr(o),c=e.mul(u,t.A),i=e.add(i,c),i=e.mul(i,a),u=e.mul(u,o),c=e.mul(u,t.B),i=e.add(i,c),d=e.mul(s,a);const{isValid:f,value:p}=n(i,u);l=e.mul(s,r),l=e.mul(l,p),d=e.cmov(d,a,f),l=e.cmov(l,p,f);const h=e.isOdd(r)===e.isOdd(l);l=e.cmov(e.neg(l),l,h);const m=pu(e,[o],!0)[0];return d=e.mul(d,m),{x:d,y:l}}}function Lu(e){return{hash:e,hmac:(t,...n)=>Qc(e,t,function(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];ot(r),t+=r.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const s=e[t];n.set(s,r),r+=s.length}return n}(...n)),randomBytes:bt}}function Fu(e,t){const n=t=>Uu({...e,...Lu(t)});return{...n(t),create:n}}const Ku=ni;function Gu(e,t){if(Zu(e),Zu(t),e<0||e>=1<<8*t)throw new Error("invalid I2OSP input: "+e);const n=Array.from({length:t}).fill(0);for(let r=t-1;r>=0;r--)n[r]=255&e,e>>>=8;return new Uint8Array(n)}function Vu(e,t){const n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e[r]^t[r];return n}function Zu(e){if(!Number.isSafeInteger(e))throw new Error("number expected")}function Hu(e,t,n){yi(n,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:r,k:s,m:i,hash:a,expand:o,DST:c}=n;Vs(e),Zu(t);const u="string"==typeof c?ci(c):c,d=r.toString(2).length,l=Math.ceil((d+s)/8),f=t*i*l;let p;if("xmd"===o)p=function(e,t,n,r){Vs(e),Vs(t),Zu(n),t.length>255&&(t=r(oi(ci("H2C-OVERSIZE-DST-"),t)));const{outputLen:s,blockLen:i}=r,a=Math.ceil(n/s);if(n>65535||a>255)throw new Error("expand_message_xmd: invalid lenInBytes");const o=oi(t,Gu(t.length,1)),c=Gu(0,i),u=Gu(n,2),d=new Array(a),l=r(oi(c,e,u,Gu(0,1),o));d[0]=r(oi(l,Gu(1,1),o));for(let e=1;e<=a;e++){const t=[Vu(l,d[e-1]),Gu(e+1,1),o];d[e]=r(oi(...t))}return oi(...d).slice(0,n)}(e,u,f,a);else if("xof"===o)p=function(e,t,n,r,s){if(Vs(e),Vs(t),Zu(n),t.length>255){const e=Math.ceil(2*r/8);t=s.create({dkLen:e}).update(ci("H2C-OVERSIZE-DST-")).update(t).digest()}if(n>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return s.create({dkLen:n}).update(e).update(Gu(n,2)).update(t).update(Gu(t.length,1)).digest()}(e,u,f,s,a);else{if("_internal_pass"!==o)throw new Error('expand must be "xmd" or "xof"');p=e}const h=new Array(t);for(let e=0;e<t;e++){const t=new Array(i);for(let n=0;n<i;n++){const s=l*(n+e*i),a=p.subarray(s,s+l);t[n]=iu(Ku(a),r)}h[e]=t}return h}const Wu=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Yu=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Qu=BigInt(0),Ju=BigInt(1),Xu=BigInt(2),ed=(e,t)=>(e+t/Xu)/t;function td(e){const t=Wu,n=BigInt(3),r=BigInt(6),s=BigInt(11),i=BigInt(22),a=BigInt(23),o=BigInt(44),c=BigInt(88),u=e*e*e%t,d=u*u*e%t,l=au(d,n,t)*d%t,f=au(l,n,t)*d%t,p=au(f,Xu,t)*u%t,h=au(p,s,t)*p%t,m=au(h,i,t)*h%t,y=au(m,o,t)*m%t,b=au(y,c,t)*y%t,g=au(b,o,t)*m%t,w=au(g,n,t)*d%t,v=au(w,a,t)*h%t,x=au(v,r,t)*u%t,I=au(x,Xu,t);if(!nd.eql(nd.sqr(I),e))throw new Error("Cannot find square root");return I}const nd=yu(Wu,void 0,void 0,{sqrt:td}),rd=Fu({a:Qu,b:BigInt(7),Fp:nd,n:Yu,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=Yu,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Ju*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,a=BigInt("0x100000000000000000000000000000000"),o=ed(i*e,t),c=ed(-r*e,t);let u=iu(e-o*n-c*s,t),d=iu(-o*r-c*i,t);const l=u>a,f=d>a;if(l&&(u=t-u),f&&(d=t-d),u>a||d>a)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:l,k1:u,k2neg:f,k2:d}}}},Es),sd={};function id(e,...t){let n=sd[e];if(void 0===n){const t=Es(Uint8Array.from(e,(e=>e.charCodeAt(0))));n=oi(t,t),sd[e]=n}return Es(oi(n,...t))}const ad=e=>e.toRawBytes(!0).slice(1),od=e=>si(e,32),cd=e=>iu(e,Wu),ud=e=>iu(e,Yu),dd=(()=>rd.ProjectivePoint)(),ld=(e,t,n)=>dd.BASE.multiplyAndAddUnsafe(e,t,n);function fd(e){let t=rd.utils.normPrivateKeyToScalar(e),n=dd.fromPrivateKey(t);return{scalar:n.hasEvenY()?t:ud(-t),bytes:ad(n)}}function pd(e){li("x",e,Ju,Wu);const t=cd(e*e);let n=td(cd(t*e+BigInt(7)));n%Xu!==Qu&&(n=cd(-n));const r=new dd(e,n,Ju);return r.assertValidity(),r}const hd=ni;function md(...e){return ud(hd(id("BIP0340/challenge",...e)))}function yd(e){return fd(e).bytes}function bd(e,t,n=bt(32)){const r=ai("message",e),{bytes:s,scalar:i}=fd(t),a=ai("auxRand",n,32),o=od(i^hd(id("BIP0340/aux",a))),c=id("BIP0340/nonce",o,s,r),u=ud(hd(c));if(u===Qu)throw new Error("sign failed: k is zero");const{bytes:d,scalar:l}=fd(u),f=md(d,s,r),p=new Uint8Array(64);if(p.set(d,0),p.set(od(ud(l+f*i)),32),!gd(p,r,s))throw new Error("sign: Invalid signature produced");return p}function gd(e,t,n){const r=ai("signature",e,64),s=ai("message",t),i=ai("publicKey",n,32);try{const e=pd(hd(i)),t=hd(r.subarray(0,32));if(!di(t,Ju,Wu))return!1;const n=hd(r.subarray(32,64));if(!di(n,Ju,Yu))return!1;const a=md(od(t),ad(e),s),o=ld(e,n,ud(-a));return!(!o||!o.hasEvenY()||o.toAffine().x!==t)}catch(e){return!1}}const wd=(()=>({getPublicKey:yd,sign:bd,verify:gd,utils:{randomPrivateKey:rd.utils.randomPrivateKey,lift_x:pd,pointToBytes:ad,numberToBytesBE:si,bytesToNumberBE:ni,taggedHash:id,mod:iu}}))(),vd=(()=>function(e,t){const n=t.map((e=>Array.from(e).reverse()));return(t,r)=>{const[s,i,a,o]=n.map((n=>n.reduce(((n,r)=>e.add(e.mul(n,t),r))))),[c,u]=pu(e,[i,o],!0);return t=e.mul(s,c),r=e.mul(r,e.mul(a,u)),{x:t,y:r}}}(nd,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map((e=>e.map((e=>BigInt(e)))))))(),xd=(()=>qu(nd,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:nd.create(BigInt("-11"))}))(),Id=(()=>function(e,t,n){if("function"!=typeof t)throw new Error("mapToCurve() must be defined");function r(n){return e.fromAffine(t(n))}function s(t){const n=t.clearCofactor();return n.equals(e.ZERO)?e.ZERO:(n.assertValidity(),n)}return{defaults:n,hashToCurve(e,t){const i=Hu(e,2,{...n,DST:n.DST,...t}),a=r(i[0]),o=r(i[1]);return s(a.add(o))},encodeToCurve:(e,t)=>s(r(Hu(e,1,{...n,DST:n.encodeDST,...t})[0])),mapToCurve(e){if(!Array.isArray(e))throw new Error("expected array of bigints");for(const t of e)if("bigint"!=typeof t)throw new Error("expected array of bigints");return s(r(e))}}}(rd.ProjectivePoint,(e=>{const{x:t,y:n}=xd(nd.create(e[0]));return vd(t,n)}),{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:nd.ORDER,m:1,k:128,expand:"xmd",hash:Es}))(),Pd=(()=>Id.hashToCurve)(),zd=(()=>Id.encodeToCurve)();var Ed=Object.freeze({__proto__:null,secp256k1:rd,schnorr:wd,secp256k1_hasher:Id,hashToCurve:Pd,encodeToCurve:zd});function Ad(e,t={}){const{recovered:n}=t;if(void 0===e.r)throw new jd({signature:e});if(void 0===e.s)throw new jd({signature:e});if(n&&void 0===e.yParity)throw new jd({signature:e});if(e.r<0n||e.r>kc)throw new Sd({value:e.r});if(e.s<0n||e.s>kc)throw new Nd({value:e.s});if("number"==typeof e.yParity&&0!==e.yParity&&1!==e.yParity)throw new Td({value:e.yParity})}function kd(e){if(130!==e.length&&132!==e.length)throw new Od({signature:e});const t=BigInt(Qi(e,0,32)),n=BigInt(Qi(e,32,64)),r=(()=>{const t=Number(`0x${e.slice(130)}`);if(!Number.isNaN(t))try{return $d(t)}catch{throw new Td({value:t})}})();return void 0===r?{r:t,s:n}:{r:t,s:n,yParity:r}}function Md(e){if(void 0!==e.r&&void 0!==e.s)return function(e){const t="string"==typeof e?kd(e):e instanceof Uint8Array?function(e){return kd(Vi(e))}(e):"string"==typeof e.r?function(e){const t=(()=>{const t=e.v?Number(e.v):void 0;let n=e.yParity?Number(e.yParity):void 0;if("number"==typeof t&&"number"!=typeof n&&(n=$d(t)),"number"!=typeof n)throw new Td({value:e.yParity});return n})();return{r:BigInt(e.r),s:BigInt(e.s),yParity:t}}(e):e.v?function(e){return{r:e.r,s:e.s,yParity:$d(e.v)}}(e):{r:e.r,s:e.s,...void 0!==e.yParity?{yParity:e.yParity}:{}};return Ad(t),t}(e)}function $d(e){if(0===e||27===e)return 0;if(1===e||28===e)return 1;if(e>=35)return e%2==0?1:0;throw new _d({value:e})}class Od extends gi{constructor({signature:e}){var t;super(`Value \`${e}\` is an invalid signature size.`,{metaMessages:["Expected: 64 bytes or 65 bytes.",`Received ${Ji((t=e,t instanceof Uint8Array?Vi(t):Array.isArray(t)?Vi(new Uint8Array(t)):t))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSerializedSizeError"})}}class jd extends gi{constructor({signature:e}){var t,n,r;super(`Signature \`${t=e,JSON.stringify(t,((e,t)=>"function"==typeof n?n(e,t):"bigint"==typeof t?t.toString()+"#__bigint":t),r)}\` is missing either an \`r\`, \`s\`, or \`yParity\` property.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.MissingPropertiesError"})}}class Sd extends gi{constructor({value:e}){super(`Value \`${e}\` is an invalid r value. r must be a positive integer less than 2^256.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidRError"})}}class Nd extends gi{constructor({value:e}){super(`Value \`${e}\` is an invalid s value. s must be a positive integer less than 2^256.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSError"})}}class Td extends gi{constructor({value:e}){super(`Value \`${e}\` is an invalid y-parity value. Y-parity must be 0 or 1.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidYParityError"})}}class _d extends gi{constructor({value:e}){super(`Value \`${e}\` is an invalid v value. v must be 27, 28 or >=35.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidVError"})}}function Rd(e,t={}){return"string"==typeof e.chainId?function(e){const{address:t,chainId:n,nonce:r}=e,s=Md(e);return{address:t,chainId:Number(n),nonce:BigInt(r),...s}}(e):{...e,...t.signature}}const Cd="0x8010801080108010801080108010801080108010801080108010801080108010",Bd=Lc("(uint256 chainId, address delegation, uint256 nonce, uint8 yParity, uint256 r, uint256 s), address to, bytes data");function Dd(e){if("string"==typeof e){if(Qi(e,-32)!==Cd)throw new Ud(e)}else Ad(e.authorization)}class Ud extends gi{constructor(e){super(`Value \`${e}\` is an invalid ERC-8010 wrapped signature.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SignatureErc8010.InvalidWrappedSignatureError"})}}function qd(e){const t="string"==typeof e?e:function(e){return"function"===e.type?`function ${e.name}(${Mo(e.inputs)})${e.stateMutability&&"nonpayable"!==e.stateMutability?` ${e.stateMutability}`:""}${e.outputs?.length?` returns (${Mo(e.outputs)})`:""}`:"event"===e.type?`event ${e.name}(${Mo(e.inputs)})`:"error"===e.type?`error ${e.name}(${Mo(e.inputs)})`:"constructor"===e.type?`constructor(${Mo(e.inputs)})${"payable"===e.stateMutability?" payable":""}`:"fallback"===e.type?"fallback() external"+("payable"===e.stateMutability?" payable":""):"receive() external payable"}(e);return function(e){let t=!0,n="",r=0,s="",i=!1;for(let a=0;a<e.length;a++){const o=e[a];if(["(",")",","].includes(o)&&(t=!0),"("===o&&r++,")"===o&&r--,t)if(0!==r)" "!==o?(s+=o,n+=o):","!==e[a-1]&&","!==n&&",("!==n&&(n="",t=!1);else if(" "===o&&["event","function","error",""].includes(s))s="";else if(s+=o,")"===o){i=!0;break}}if(!i)throw new gi("Unable to normalize signature.");return s}(t)}function Ld(e){return"string"!=typeof e&&"hash"in e&&e.hash?e.hash:bc(Hi(qd(e)))}const Fd="0x0000000000000000000000000000000000000000",Kd="0x6492649264926492649264926492649264926492649264926492649264926492";function Gd(e){try{return function(e){if(Qi(e,-32)!==Kd)throw new Vd(e)}(e),!0}catch{return!1}}class Vd extends gi{constructor(e){super(`Value \`${e}\` is an invalid ERC-6492 wrapped signature.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SignatureErc6492.InvalidWrappedSignatureError"})}}async function Zd(e,t){const{address:n,hash:r,erc6492VerifierAddress:s=t.universalSignatureVerifierAddress??e.chain?.contracts?.erc6492Verifier?.address,multicallAddress:i=t.multicallAddress??e.chain?.contracts?.multicall3?.address}=t,a=(()=>{const e=t.signature;return Z(e)?e:"object"==typeof e&&"r"in e&&"s"in e?function({r:e,s:t,to:n="hex",v:r,yParity:s}){const i=(()=>{if(0===s||1===s)return s;if(r&&(27n===r||28n===r||r>=35n))return r%2n===0n?1:0;throw new Error("Invalid `v` or `yParity` value")})(),a=`0x${new rd.Signature(ke(e),ke(t)).toCompactHex()}${0===i?"1b":"1c"}`;return"hex"===n?a:Ue(a)}(e):Se(e)})();try{return function(e){try{return Dd(e),!0}catch{return!1}}(a)?await async function(e,t){const{address:n,blockNumber:r,blockTag:s,hash:i,multicallAddress:a}=t,{authorization:o,data:c,signature:u,to:d}=function(e){Dd(e);const t=ea(Qi(e,-64,-32)),n=Qi(e,-t-64,-64),r=Qi(e,0,-t-64),[s,i,a]=Dc(Bd,n);return{authorization:Rd({address:s.delegation,chainId:Number(s.chainId),nonce:s.nonce,yParity:s.yParity,r:s.r,s:s.s}),signature:r,...a&&"0x"!==a?{data:a,to:i}:{}}}(t.signature),l=await async function(e,{address:t,blockNumber:n,blockTag:r="latest"}){const s=void 0!==n?Ne(n):void 0,i=await e.request({method:"eth_getCode",params:[t,s||r]},{dedupe:Boolean(s)});if("0x"!==i)return i}(e,{address:n,blockNumber:r,blockTag:s});if(l===Ht(["0xef0100",o.address]))return await async function(e,t){const{address:n,blockNumber:r,blockTag:s,hash:i,signature:a}=t,o=await K(e,Ea,"readContract")({address:n,abi:oa,args:[i,a],blockNumber:r,blockTag:s,functionName:"isValidSignature"}).catch((e=>{if(e instanceof Hn)throw new Hd;throw e}));if(o.startsWith("0x1626ba7e"))return!0;throw new Hd}(e,{address:n,blockNumber:r,blockTag:s,hash:i,signature:u});const f={address:o.address,chainId:Number(o.chainId),nonce:Number(o.nonce),r:Ne(o.r,{size:32}),s:Ne(o.s,{size:32}),yParity:o.yParity},p=await eo({address:n,authorization:f});if(!p)throw new Hd;const h=await K(e,Ea,"readContract")({...a?{address:a}:{code:pa},authorizationList:[f],abi:aa,blockNumber:r,blockTag:"pending",functionName:"aggregate3",args:[[...c?[{allowFailure:!0,target:d??n,callData:c}]:[],{allowFailure:!0,target:n,callData:pn({abi:oa,functionName:"isValidSignature",args:[i,u]})}]]}),m=h[h.length-1]?.returnData;if(m?.startsWith("0x1626ba7e"))return!0;throw new Hd}(e,{...t,multicallAddress:i,signature:a}):await async function(e,t){const{address:n,factory:r,factoryData:s,hash:i,signature:a,verifierAddress:o,...c}=t,u=await(async()=>r||s?Gd(a)?a:function(e){const{data:t,signature:n,to:r}=e;return Ki(Uc(Lc("address, bytes, bytes"),[r,t,n]),Kd)}({data:s,signature:a,to:r}):a)(),d=o?{to:o,data:pn({abi:ca,functionName:"isValidSig",args:[n,i,u]}),...c}:{data:ga({abi:ca,args:[n,i,u],bytecode:fa}),...c},{data:l}=await K(e,Pa,"call")(d).catch((e=>{if(e instanceof Zn)throw new Hd;throw e}));if(function(e,t={}){let n=e;if(t.size&&(Ae(n,{size:t.size}),n=Ee(n)),"0x00"===Ee(n))return!1;if("0x01"===Ee(n))return!0;throw new Pe(n)}(l??"0x0"))return!0;throw new Hd}(e,{...t,verifierAddress:s,signature:a})}catch(e){try{if(Us(Ft(n),await Nr({hash:r,signature:a})))return!0}catch{}if(e instanceof Hd)return!1;throw e}}class Hd extends Error{}function Wd({key:e,methods:t,name:n,request:r,retryCount:s=3,retryDelay:i=150,timeout:a,type:o},c){return{config:{key:e,methods:t,name:n,request:r,retryCount:s,retryDelay:i,timeout:a,type:o},request:no(r,{methods:t,retryCount:s,retryDelay:i,uid:Va()}),value:c}}function Yd(e,t={}){const{key:n="fallback",name:r="Fallback",rank:s=!1,shouldThrow:i=Qd,retryCount:a,retryDelay:o}=t;return({chain:t,pollingInterval:c=4e3,timeout:u,...d})=>{let l=e,f=()=>{};const p=Wd({key:n,name:r,async request({method:e,params:n}){let r;const s=async(a=0)=>{const o=l[a]({...d,chain:t,retryCount:0,timeout:u});try{const t=await o.request({method:e,params:n});return f({method:e,params:n,response:t,transport:o,status:"success"}),t}catch(c){if(f({error:c,method:e,params:n,transport:o,status:"error"}),i(c))throw c;if(a===l.length-1)throw c;if(r??=l.slice(a+1).some((n=>{const{include:r,exclude:s}=n({chain:t}).config.methods||{};return r?r.includes(e):!s||!s.includes(e)})),!r)throw c;return s(a+1)}};return s()},retryCount:a,retryDelay:o,type:"fallback"},{onResponse:e=>f=e,transports:l.map((e=>e({chain:t,retryCount:0})))});if(s){const e="object"==typeof s?s:{};!function({chain:e,interval:t=4e3,onTransports:n,ping:r,sampleCount:s=10,timeout:i=1e3,transports:a,weights:o={}}){const{stability:c=.7,latency:u=.3}=o,d=[],l=async()=>{const o=await Promise.all(a.map((async t=>{const n=t({chain:e,retryCount:0,timeout:i}),s=Date.now();let a,o;try{await(r?r({transport:n}):n.request({method:"net_listening"})),o=1}catch{o=0}finally{a=Date.now()}return{latency:a-s,success:o}})));d.push(o),d.length>s&&d.shift();const f=Math.max(...d.map((e=>Math.max(...e.map((({latency:e})=>e)))))),p=a.map(((e,t)=>{const n=d.map((e=>e[t].latency)),r=1-n.reduce(((e,t)=>e+t),0)/n.length/f,s=d.map((e=>e[t].success)),i=s.reduce(((e,t)=>e+t),0)/s.length;return 0===i?[0,t]:[u*r+c*i,t]})).sort(((e,t)=>t[0]-e[0]));n(p.map((([,e])=>a[e]))),await Oa(t),l()};l()}({chain:t,interval:e.interval??c,onTransports:e=>l=e,ping:e.ping,sampleCount:e.sampleCount,timeout:e.timeout,transports:l,weights:e.weights})}return p}}function Qd(e){return!(!("code"in e)||"number"!=typeof e.code||e.code!==fr.code&&e.code!==yr.code&&!Br.nodeMessage.test(e.message)&&5e3!==e.code)}class Jd extends J{constructor(){super("No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.",{docsPath:"/docs/clients/intro",name:"UrlRequiredError"})}}function Xd(e,t={}){const{batch:n,fetchOptions:r,key:s="http",methods:i,name:a="HTTP JSON-RPC",onFetchRequest:o,onFetchResponse:c,retryDelay:u,raw:d}=t;return({chain:l,retryCount:f,timeout:p})=>{const{batchSize:h=1e3,wait:m=0}="object"==typeof n?n:{},y=t.retryCount??f,b=p??t.timeout??1e4,g=e||l?.rpcUrls.default.http[0];if(!g)throw new Jd;const w=ao(g,{fetchOptions:r,onRequest:o,onResponse:c,timeout:b});return Wd({key:s,methods:i,name:a,async request({method:e,params:t}){const r={method:e,params:t},{schedule:s}=Ia({id:g,wait:m,shouldSplitBatch:e=>e.length>h,fn:e=>w.request({body:e}),sort:(e,t)=>e.id-t.id}),[{error:i,result:a}]=await(async e=>n?s(e):[await w.request({body:e})])(r);if(d)return{error:i,result:a};if(i)throw new er({body:r,error:i,url:g});return a},retryCount:y,retryDelay:u,timeout:b,type:"http"},{fetchOptions:r,url:g})}}const el={transaction:function(e,t){return function(e){return"deposit"===e.type||void 0!==e.sourceHash}(e)?function(e){!function(e){const{from:t,to:n}=e;if(t&&!Vt(t))throw new Dt({address:t});if(n&&!Vt(n))throw new Dt({address:n})}(e);const{sourceHash:t,data:n,from:r,gas:s,isSystemTx:i,mint:a,to:o,value:c}=e,u=[t,r,o??"0x",a?Oe(a):"0x",c?Oe(c):"0x",s?Oe(s):"0x",i?"0x1":"0x",n??"0x"];return Ht(["0x7e",Tr(u)])}(e):Ja(e,t)}};const tl={blockTime:2e3,contracts:{gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}},formatters:{block:os({format(e){const t=e.transactions?.map((e=>{if("string"==typeof e)return e;const t=ss(e);return"0x7e"===t.typeHex&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?ke(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}));return{transactions:t,stateRoot:e.stateRoot}}}),transaction:is({format(e){const t={};return"0x7e"===e.type&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?ke(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:Ba({format:e=>({l1GasPrice:e.l1GasPrice?ke(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?ke(e.l1GasUsed):null,l1Fee:e.l1Fee?ke(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null})})},serializers:el},nl=11155111,rl=ro({...tl,id:84532,network:"base-sepolia",name:"Base Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.base.org"]}},blockExplorers:{default:{name:"Basescan",url:"https://sepolia.basescan.org",apiUrl:"https://api-sepolia.basescan.org/api"}},contracts:{...tl.contracts,disputeGameFactory:{[nl]:{address:"0xd6E6dBf4F7EA0ac412fD8b65ED297e64BB7a06E1"}},l2OutputOracle:{[nl]:{address:"0x84457ca9D0163FbC4bbfe4Dfbb20ba46e48DF254"}},portal:{[nl]:{address:"0x49f53e41452c74589e85ca1677426ba426459e85",blockCreated:4446677}},l1StandardBridge:{[nl]:{address:"0xfd0Bf71F60660E2f608ed56e1659C450eB113120",blockCreated:4446677}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:1059647}},testnet:!0,sourceId:nl}),sl=ro({id:11155931,name:"RISE Testnet",nativeCurrency:{name:"RISE Testnet Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://testnet.riselabs.xyz"],webSocket:["wss://testnet.riselabs.xyz/ws"]}},blockExplorers:{default:{name:"Blockscout",url:"https://explorer.testnet.riselabs.xyz/",apiUrl:"https://explorer.testnet.riselabs.xyz/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11"}},testnet:!0});var il=Object.freeze({__proto__:null,baseSepolia:rl,riseTestnet:sl});const al=[sl,...Object.values(il).filter((e=>e.id!==sl.id))],ol="#__bigint";function cl(e,t,n){return JSON.stringify(e,((e,n)=>"function"==typeof t?t(e,n):"bigint"==typeof n?n.toString()+ol:n),n)}class ul extends Error{static setStaticOptions(e){ul.prototype.docsOrigin=e.docsOrigin,ul.prototype.showVersion=e.showVersion,ul.prototype.version=e.version}constructor(e,t={}){const n=(()=>{if(t.cause instanceof ul){if(t.cause.details)return t.cause.details;if(t.cause.shortMessage)return t.cause.shortMessage}return t.cause&&"details"in t.cause&&"string"==typeof t.cause.details?t.cause.details:t.cause?.message?t.cause.message:t.details})(),r=t.cause instanceof ul&&t.cause.docsPath||t.docsPath,s=t.docsOrigin??ul.prototype.docsOrigin,i=`${s}${r??""}`,a=Boolean(t.version??ul.prototype.showVersion),o=t.version??ul.prototype.version;super([e||"An error occurred.",...t.metaMessages?["",...t.metaMessages]:[],...n||r||a?["",n?`Details: ${n}`:void 0,r?`See: ${i}`:void 0,a?`Version: ${o}`:void 0]:[]].filter((e=>"string"==typeof e)).join("\n"),t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsOrigin",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"showVersion",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.cause=t.cause,this.details=n,this.docs=i,this.docsOrigin=s,this.docsPath=r,this.shortMessage=e,this.showVersion=a,this.version=o}walk(e){return dl(this,e)}}function dl(e,t){return t?.(e)?e:e&&"object"==typeof e&&"cause"in e&&e.cause?dl(e.cause,t):t?null:e}function ll(e){const t=e;if(t instanceof Error&&!("code"in t))return new Pl({cause:t,data:t,message:t.message,stack:t.stack});const{code:n}=t;return n===Pl.code?new Pl(t):n===pl.code?new pl(t):n===Il.code?new Il(t):n===vl.code?new vl(t):n===gl.code?new gl(t):n===xl.code?new xl(t):n===bl.code?new bl(t):n===zl.code?new zl(t):n===hl.code?new hl(t):n===ml.code?new ml(t):n===yl.code?new yl(t):n===wl.code?new wl(t):new Pl({cause:t instanceof Error?t:void 0,data:t,message:t.message,stack:t instanceof Error?t.stack:void 0})}Object.defineProperty(ul,"defaultStaticOptions",{enumerable:!0,configurable:!0,writable:!0,value:{docsOrigin:"https://oxlib.sh",showVersion:!1,version:"ox@0.1.1"}}),ul.setStaticOptions(ul.defaultStaticOptions);class fl extends Error{constructor(e){const{cause:t,code:n,message:r,data:s,stack:i}=e;super(r,{cause:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.BaseError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"stack",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=t,this.code=n,this.data=s,this.stack=i??""}}class pl extends fl{constructor(e={}){super({code:pl.code,data:e.data,message:e.message??"Missing or invalid parameters."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InvalidInputError"})}}Object.defineProperty(pl,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class hl extends fl{constructor(e={}){super({code:hl.code,data:e.data,message:e.message??"Requested resource not found."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.ResourceNotFoundError"})}}Object.defineProperty(hl,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class ml extends fl{constructor(e={}){super({code:ml.code,data:e.data,message:e.message??"Requested resource not available."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.ResourceUnavailableError"})}}Object.defineProperty(ml,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class yl extends fl{constructor(e={}){super({code:yl.code,data:e.data,message:e.message??"Transaction creation failed."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.TransactionRejectedError"})}}Object.defineProperty(yl,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class bl extends fl{constructor(e={}){super({code:bl.code,data:e.data,message:e.message??"Method is not implemented."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.MethodNotSupportedError"})}}Object.defineProperty(bl,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class gl extends fl{constructor(e={}){super({code:gl.code,data:e.data,message:e.message??"Rate limit exceeded."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.LimitExceededError"})}}Object.defineProperty(gl,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class wl extends fl{constructor(e={}){super({code:wl.code,data:e.data,message:e.message??"JSON-RPC version not supported."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.VersionNotSupportedError"})}}Object.defineProperty(wl,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});class vl extends fl{constructor(e={}){super({code:vl.code,data:e.data,message:e.message??"Input is not a valid JSON-RPC request."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InvalidRequestError"})}}Object.defineProperty(vl,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class xl extends fl{constructor(e={}){super({code:xl.code,data:e.data,message:e.message??"Method does not exist."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.MethodNotFoundError"})}}Object.defineProperty(xl,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class Il extends fl{constructor(e={}){super({code:Il.code,data:e.data,message:e.message??"Invalid method parameters."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InvalidParamsError"})}}Object.defineProperty(Il,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class Pl extends fl{constructor(e={}){super({cause:e.cause,code:Pl.code,data:e.data,message:e.message??"Internal JSON-RPC error.",stack:e.stack}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InternalError"})}}Object.defineProperty(Pl,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class zl extends fl{constructor(e={}){super({code:zl.code,data:e.data,message:e.message??"Failed to parse JSON-RPC response."}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.ParseError"})}}Object.defineProperty(zl,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class El extends Error{constructor(e,t){super(t),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ProviderRpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=e,this.details=t}}class Al extends El{constructor({message:e="The user rejected the request."}={}){super(4001,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UserRejectedRequestError"})}}Object.defineProperty(Al,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class kl extends El{constructor({message:e="The requested method and/or account has not been authorized by the user."}={}){super(4100,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UnauthorizedError"})}}Object.defineProperty(kl,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class Ml extends El{constructor({message:e="The provider does not support the requested method."}={}){super(4200,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UnsupportedMethodError"})}}Object.defineProperty(Ml,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class $l extends El{constructor({message:e="The provider is disconnected from all chains."}={}){super(4900,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.DisconnectedError"})}}Object.defineProperty($l,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});class Ol extends El{constructor({message:e="The provider is not connected to the requested chain."}={}){super(4901,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.ChainDisconnectedError"})}}Object.defineProperty(Ol,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});class jl extends El{constructor({message:e="An error occurred when attempting to switch chain."}={}){super(4902,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.SwitchChainError"})}}Object.defineProperty(jl,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902});class Sl extends El{constructor({message:e="This Wallet does not support a capability that was not marked as optional."}={}){super(5700,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:5700}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UnsupportedNonOptionalCapabilityError"})}}Object.defineProperty(Sl,"code",{enumerable:!0,configurable:!0,writable:!0,value:5700});class Nl extends El{constructor({message:e="This Wallet does not support the requested chain ID."}={}){super(5710,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:5710}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UnsupportedChainIdError"})}}Object.defineProperty(Nl,"code",{enumerable:!0,configurable:!0,writable:!0,value:5710});class Tl extends El{constructor({message:e="There is already a bundle submitted with this ID."}={}){super(5720,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:5720}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.DuplicateIdError"})}}Object.defineProperty(Tl,"code",{enumerable:!0,configurable:!0,writable:!0,value:5720});class _l extends El{constructor({message:e="This bundle id is unknown / has not been submitted."}={}){super(5730,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:5730}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UnknownBundleIdError"})}}Object.defineProperty(_l,"code",{enumerable:!0,configurable:!0,writable:!0,value:5730});class Rl extends El{constructor({message:e="The call bundle is too large for the Wallet to process."}={}){super(5740,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:5740}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.BundleTooLargeError"})}}Object.defineProperty(Rl,"code",{enumerable:!0,configurable:!0,writable:!0,value:5740});class Cl extends El{constructor({message:e="The Wallet can support atomicity after an upgrade, but the user rejected the upgrade."}={}){super(5750,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:5750}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.AtomicReadyWalletRejectedUpgradeError"})}}Object.defineProperty(Cl,"code",{enumerable:!0,configurable:!0,writable:!0,value:5750});class Bl extends El{constructor({message:e="The wallet does not support atomic execution but the request requires it."}={}){super(5760,e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:5760}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.AtomicityNotSupportedError"})}}function Dl(e,t={}){if(!e)throw new ql;return{...e,async request(t){try{const n=await e.request(t);return n&&"object"==typeof n&&"jsonrpc"in n?function(e,t={}){const{raw:n=!1}=t,r=e;if(n)return e;if(r.error)throw ll(r.error);return r.result}(n):n}catch(e){throw Ul(e)}}}}function Ul(e){const t=ll(e);if(t instanceof Pl){if(!t.data)return t;const{code:e}=t.data;if(e===$l.code)return new $l(t);if(e===Ol.code)return new Ol(t);if(e===Al.code)return new Al(t);if(e===kl.code)return new kl(t);if(e===Ml.code)return new Ml(t);if(e===jl.code)return new jl(t);if(e===Cl.code)return new Cl(t);if(e===Bl.code)return new Bl(t);if(e===Rl.code)return new Rl(t);if(e===_l.code)return new _l(t);if(e===Tl.code)return new Tl(t);if(e===Nl.code)return new Nl(t);if(e===Sl.code)return new Sl(t)}return t}Object.defineProperty(Bl,"code",{enumerable:!0,configurable:!0,writable:!0,value:5760});class ql extends ul{constructor(){super("`provider` is undefined."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.IsUndefinedError"})}}const Ll=()=>"IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in IntersectionObserverEntry.prototype&&"isVisible"in IntersectionObserverEntry.prototype;const Fl=function(e={}){const{prefix:t="[Porto]"}=e,n=new Set;return{error:Kl(console.error,{prefix:t}),errorOnce:Kl(console.error,{memo:n,prefix:t}),log:Kl(console.log,{prefix:t}),logOnce:Kl(console.log,{memo:n,prefix:t}),warn:Kl(console.warn,{prefix:t}),warnOnce:Kl(console.warn,{memo:n,prefix:t})}}();function Kl(e,t={}){const{memo:n,prefix:r}=t;return(...t)=>{const s=t.join(" ");n?.has(s)||(n?.add(s),e(`${r} ${s}`))}}function Gl(e){if(Array.isArray(e))return e.map(Gl);if("function"==typeof e)return;if("object"!=typeof e||null===e)return e;if(Object.getPrototypeOf(e)!==Object.prototype)try{return structuredClone(e)}catch{return}const t={};for(const[n,r]of Object.entries(e))t[n]=Gl(r);return t}function Vl(e,t){const n=[],r=new Set;for(const s of e){const e=t(s);r.has(e)||(r.add(e),n.push(s))}return n}function Zl(){return"undefined"!=typeof globalThis&&"crypto"in globalThis?globalThis.crypto.randomUUID():crypto.randomUUID()}function Hl(e,{enabled:t=!0,id:n}){if(!t||!n)return e();if(Hl.cache.get(n))return Hl.cache.get(n);const r=e().finally((()=>Hl.cache.delete(n)));return Hl.cache.set(n,r),r}function Wl(e,t={}){const{targetOrigin:n}=t,r=new Map;return{destroy(){for(const t of r.values())e.removeEventListener("message",t)},on(t,s,i){function a(e){e.data.topic===t&&(i&&e.data.id!==i||n&&e.origin!==n||s(e.data.payload,e))}return e.addEventListener("message",a),r.set(t,a),()=>e.removeEventListener("message",a)},async send(t,r,s){const i=Zl();return e.postMessage(Gl({id:i,payload:r,topic:t}),s??n??"*"),{id:i,payload:r,topic:t}},async sendAsync(e,t,n){const{id:r}=await this.send(e,t,n);return new Promise((t=>this.on(e,t,r)))}}}function Yl(e){const{from:t,to:n,waitForReady:r=!1}=e;let s=!1;const i=function(){let e=()=>{},t=()=>{};return{promise:new Promise(((n,r)=>{e=n,t=r})),reject:t,resolve:e}}();t.on("ready",i.resolve);const a={destroy(){t.destroy(),n.destroy(),s&&i.reject()},on:(e,n,r)=>t.on(e,n,r),send:async(e,t)=>(s=!0,r&&await i.promise.finally((()=>s=!1)),n.send(e,t)),sendAsync:async(e,t)=>(s=!0,r&&await i.promise.finally((()=>s=!1)),n.sendAsync(e,t))};return{...a,ready(e){a.send("ready",e)},waitForReady:()=>i.promise}}!function(e){e.cache=new Map}(Hl||(Hl={}));const Ql={local:"http://localhost:5175/dialog/",prod:"https://wallet.risechain.com/dialog",stg:"https://stg.wallet.risechain.com/dialog"};function Jl(e={}){const{skipProtocolCheck:t,skipUnsupported:n}=e,r=e=>!n&&function(){const e=navigator.userAgent.toLowerCase();return e.includes("safari")&&!e.includes("chrome")}()&&e?.some((e=>["wallet_connect","eth_requestAccounts"].includes(e.method)));return"undefined"==typeof window?Xl():{name:"iframe",setup(e){const{host:n,internal:s,theme:i,themeController:a}=e,{store:o}=s,c=function(e={}){if("undefined"==typeof window)return Xl();const{type:t="auto",size:n=ef}=e;return{name:"popup",setup(e){const{host:r,internal:s,themeController:i}=e,{store:a}=s,o=new URL(r);let c=null;const u="page"===t||"auto"===t&&(window.navigator?.userAgentData?.mobile||navigator.maxTouchPoints>1||/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(navigator.userAgent)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(navigator.userAgent.slice(0,4)))?"page":"popup";function d(){c&&rf(a)}const l=(()=>{const e=setInterval((()=>{c?.closed&&rf(a)}),100);return()=>clearInterval(e)})();let f;return i?._setup(null,!0),{close(){c&&(c.close(),c=null)},destroy(){this.close(),window.removeEventListener("focus",d),f?.destroy(),l()},open(){if("popup"===u){const e=(window.innerWidth-n.width)/2+window.screenX,t=window.screenY+100;c=window.open(af(r),"_blank",`width=${n.width},height=${n.height},left=${e},top=${t}`)}else c=window.open(af(r),"_blank");if(!c)throw new Error("Failed to open popup");f=Yl({from:Wl(window,{targetOrigin:o.origin}),to:Wl(c,{targetOrigin:o.origin}),waitForReady:!0}),i?._setup(f,!1),f.send("__internal",{mode:"page"===u?"page":"popup",referrer:nf(),theme:i?.getTheme()??e.theme,type:"init"}),f.on("rpc-response",(e=>sf(a,e))),window.removeEventListener("focus",d),window.addEventListener("focus",d)},secure:async()=>({frame:!0,host:!0,protocol:!0}),async syncRequests(e){e.some((e=>tf(e.request)))&&(c&&!c.closed||this.open(),c?.focus()),f?.send("rpc-requests",e)}}},supportsHeadless:!1}}().setup(e);let u=!1;const d=new URL(n),l=document.createElement("dialog");l.dataset.porto="",l.setAttribute("role","dialog"),l.setAttribute("aria-closed","true"),l.setAttribute("aria-label","Porto Wallet"),l.setAttribute("hidden","until-found"),Object.assign(l.style,{background:"transparent",border:"0",outline:"0",padding:"0",position:"fixed"}),document.body.appendChild(l);const f=document.createElement("iframe");f.setAttribute("data-testid","porto");const p=["payment",`publickey-credentials-get ${d.origin}`,`publickey-credentials-create ${d.origin}`];(function(){const e=navigator.userAgent.toLowerCase();return(e.includes("firefox")||e.includes("fxios"))&&!e.includes("seamonkey")})()||p.push("clipboard-write"),f.setAttribute("allow",p.join("; ")),f.setAttribute("tabindex","0"),f.setAttribute("sandbox","allow-forms allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox"),f.setAttribute("src",af(n)),f.setAttribute("title","Porto"),Object.assign(f.style,{backgroundColor:"transparent",border:"0",colorScheme:"light dark",height:"100%",left:"0",position:"fixed",top:"0",width:"100%"});const h=document.createElement("style");h.innerHTML="\n dialog[data-porto]::backdrop {\n background: transparent!important;\n }\n ",l.appendChild(h),l.appendChild(f);const m=Yl({from:Wl(window,{targetOrigin:d.origin}),to:Wl(f.contentWindow,{targetOrigin:d.origin}),waitForReady:!0});a?._setup(m,!0);const y=window.matchMedia("(max-width: 460px)"),b=()=>{m.send("__internal",{type:"resize",width:y.matches?460:461})};y.addEventListener("change",b),m.on("ready",(t=>{let n=e.internal.store.getState().chainIds.filter((e=>t.chainIds.includes(e)));0===n.length&&(n=t.chainIds),o.setState((e=>({...e,chainIds:n}))),m.send("__internal",{chainIds:n,mode:"iframe",referrer:nf(),theme:i,type:"init"}),b()})),m.on("rpc-response",(e=>{if(r([e._request])){const e=f.src;f.src=e}sf(o,e)})),m.on("__internal",(e=>{"switch"===e.type&&"popup"===e.mode&&(c.open(),c.syncRequests(o.getState().requestQueue))}));let g=null,w=null;const v=()=>rf(o),x=e=>{"Escape"===e.key&&rf(o)},I=new MutationObserver((e=>{for(const t of e){if("attributes"!==t.type)continue;const e=t.attributeName;e&&("inert"===e&&l.removeAttribute(e))}}));I.observe(l,{attributeOldValue:!0,attributes:!0});let P=!1;const z=()=>{P&&(P=!1,l.removeEventListener("click",v),document.removeEventListener("keydown",x),l.style.pointerEvents="none",w?.focus(),w=null,Object.assign(document.body.style,g??""),document.body.style.overflow=g?.overflow??"")};let E=!1;const A=()=>{if(E){E=!1,l.setAttribute("hidden","true"),l.setAttribute("aria-closed","true"),l.close();for(const e of l.parentNode?Array.from(l.parentNode.children):[])e!==l&&e.hasAttribute("inert")&&e.removeAttribute("inert")}};return{close(){c.close(),u=!1,m.send("__internal",{mode:"iframe",referrer:nf(),type:"init"}),A(),z()},destroy(){c.close(),u=!1,z(),A(),c.destroy(),m.destroy(),l.remove(),I.disconnect(),y.removeEventListener("change",b)},open(){u||(u=!0,E||(E=!0,document.activeElement instanceof HTMLElement&&(w=document.activeElement),l.removeAttribute("hidden"),l.removeAttribute("aria-closed"),l.showModal()),P||(P=!0,l.addEventListener("click",v),document.addEventListener("keydown",x),f.focus(),l.style.pointerEvents="auto",g=Object.assign({},document.body.style),document.body.style.overflow="hidden"),m.send("__internal",{mode:"iframe",referrer:nf(),type:"init"}))},async secure(){const{trustedHosts:e}=await m.waitForReady(),n=(()=>{if(t)return!0;const e=window.location.protocol.startsWith("https");return e||Fl.warnOnce("Detected insecure protocol (HTTP).",`\n\nThe Porto iframe is not supported on HTTP origins (${window.location.origin})`,"due to lack of WebAuthn support.","See https://porto.sh/sdk#secure-origins-https for more information."),e})(),r=Ll(),s=Boolean(e?.includes(window.location.hostname)),i=Boolean(r||s);return i||Fl.warnOnce([`Warning: Browser does not support IntersectionObserver v2 or host "${d.hostname}" is not trusted by Porto.`,"This may result in the dialog falling back to a popup.","",`Add "${d.hostname}" to the trusted hosts list to enable iframe dialog: https://github.com/ithacaxyz/porto/edit/main/src/trusted-hosts.ts`].join("\n")),{frame:i,host:s,protocol:n}},async syncRequests(e){const{methodPolicies:t}=await m.waitForReady(),n=await this.secure(),s=e?.every((e=>!0===t?.find((t=>t.method===e.request.method))?.modes?.headless)),i=r(e.map((e=>e.request)));if(s||!i&&n.protocol&&n.frame){const n=e.some((e=>tf(e.request,{methodPolicies:t,targetOrigin:d.origin})));!u&&n&&this.open(),m.send("rpc-requests",e)}else c.syncRequests(e)}}},supportsHeadless:!0}}function Xl(){return{name:"noop",setup:()=>({close(){},destroy(){},open(){},secure:async()=>({frame:!0,host:!0,protocol:!0}),async syncRequests(){}}),supportsHeadless:!0}}const ef={height:282,width:360};function tf(e,t={}){const{methodPolicies:n,targetOrigin:r}=t,s=n?.find((t=>t.method===e.method));return!s||(!s.modes?.headless||!("object"!=typeof s.modes.headless||!s.modes.headless.sameOrigin||r===window.location.origin))}function nf(){return{icon:(()=>{const e=document.querySelector('link[rel="icon"][media="(prefers-color-scheme: dark)"]')?.href,t=document.querySelector('link[rel="icon"][media="(prefers-color-scheme: light)"]')?.href??document.querySelector('link[rel="icon"]')?.href;if(e&&t&&e!==t)return{dark:e,light:t};return window.matchMedia("(prefers-color-scheme: dark)").matches?e:t})(),title:document.title}}function rf(e){e.setState((e=>({...e,requestQueue:e.requestQueue.map((e=>({account:e.account,error:new Al,request:e.request,status:"error"})))})))}function sf(e,t){e.setState((e=>({...e,requestQueue:e.requestQueue.map((e=>e.request.id!==t.id?e:t.error?{account:e.account,error:t.error,request:e.request,status:"error"}:{account:e.account,request:e.request,result:t.result,status:"success"}))})))}function af(e){const t=new URL(e),n=new URLSearchParams(window.location.search),r="porto.";for(const[e,s]of n.entries())e.startsWith(r)&&t.searchParams.set(e.slice(6),s);return t.toString()}function of(e,t){if(Df(e)>t)throw new Gf({givenSize:Df(e),maxSize:t})}const cf={zero:48,nine:57,A:65,F:70,a:97,f:102};function uf(e){return e>=cf.zero&&e<=cf.nine?e-cf.zero:e>=cf.A&&e<=cf.F?e-(cf.A-10):e>=cf.a&&e<=cf.f?e-(cf.a-10):void 0}function df(e,t){if(Pf(e)>t)throw new jf({givenSize:Pf(e),maxSize:t})}function lf(e,t={}){const{dir:n,size:r=32}=t;if(0===r)return e;const s=e.replace("0x","");if(s.length>2*r)throw new Nf({size:Math.ceil(s.length/2),targetSize:r,type:"Hex"});return`0x${s["right"===n?"padEnd":"padStart"](2*r,"0")}`}const ff=new TextEncoder,pf=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function hf(...e){return`0x${e.reduce(((e,t)=>e+t.replace("0x","")),"")}`}function mf(e){return e instanceof Uint8Array?bf(e):Array.isArray(e)?bf(new Uint8Array(e)):e}function yf(e,t={}){const n=`0x${Number(e)}`;return"number"==typeof t.size?(df(n,t.size),vf(n,t.size)):n}function bf(e,t={}){let n="";for(let t=0;t<e.length;t++)n+=pf[e[t]];const r=`0x${n}`;return"number"==typeof t.size?(df(r,t.size),xf(r,t.size)):r}function gf(e,t={}){const{signed:n,size:r}=t,s=BigInt(e);let i;r?i=n?(1n<<8n*BigInt(r)-1n)-1n:2n**(8n*BigInt(r))-1n:"number"==typeof e&&(i=BigInt(Number.MAX_SAFE_INTEGER));const a="bigint"==typeof i&&n?-i-1n:0;if(i&&s>i||s<a){const t="bigint"==typeof e?"n":"";throw new Mf({max:i?`${i}${t}`:void 0,min:`${a}${t}`,signed:n,size:r,value:`${e}${t}`})}const o=`0x${(n&&s<0?BigInt.asUintN(8*r,BigInt(s)):s).toString(16)}`;return r?vf(o,r):o}function wf(e,t={}){return bf(ff.encode(e),t)}function vf(e,t){return lf(e,{dir:"left",size:t})}function xf(e,t){return lf(e,{dir:"right",size:t})}function If(e,t,n,r={}){const{strict:s}=r;!function(e,t){if("number"==typeof t&&t>0&&t>Pf(e)-1)throw new Sf({offset:t,position:"start",size:Pf(e)})}(e,t);const i=`0x${e.replace("0x","").slice(2*(t??0),2*(n??e.length))}`;return s&&function(e,t,n){if("number"==typeof t&&"number"==typeof n&&Pf(e)!==n-t)throw new Sf({offset:n,position:"end",size:Pf(e)})}(i,t,n),i}function Pf(e){return Math.ceil((e.length-2)/2)}function zf(e){return function(e,t={}){const{dir:n="left"}=t;let r=e.replace("0x",""),s=0;for(let e=0;e<r.length-1&&"0"===r["left"===n?e:r.length-e-1].toString();e++)s++;return r="left"===n?r.slice(s):r.slice(0,r.length-s),"0"===r?"0x":"right"===n&&r.length%2==1?`0x${r}0`:`0x${r}`}(e,{dir:"left"})}function Ef(e,t={}){const{signed:n}=t;t.size&&df(e,t.size);const r=BigInt(e);if(!n)return r;const s=(e.length-2)/2,i=(1n<<8n*BigInt(s))-1n;return r<=i>>1n?r:r-i-1n}function Af(e,t={}){const{signed:n,size:r}=t;return Number(n||r?Ef(e,t):e)}function kf(e,t={}){const{strict:n=!1}=t;try{return function(e,t={}){const{strict:n=!1}=t;if(!e)throw new $f(e);if("string"!=typeof e)throw new $f(e);if(n&&!/^0x[0-9a-fA-F]*$/.test(e))throw new Of(e);if(!e.startsWith("0x"))throw new Of(e)}(e,{strict:n}),!0}catch{return!1}}class Mf extends ul{constructor({max:e,min:t,signed:n,size:r,value:s}){super(`Number \`${s}\` is not in safe${r?` ${8*r}-bit`:""}${n?" signed":" unsigned"} integer range ${e?`(\`${t}\` to \`${e}\`)`:`(above \`${t}\`)`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.IntegerOutOfRangeError"})}}class $f extends ul{constructor(e){super(`Value \`${"object"==typeof e?cl(e):e}\` of type \`${typeof e}\` is an invalid hex type.`,{metaMessages:['Hex types must be represented as `"0x${string}"`.']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexTypeError"})}}class Of extends ul{constructor(e){super(`Value \`${e}\` is an invalid hex value.`,{metaMessages:['Hex values must start with `"0x"` and contain only hexadecimal characters (0-9, a-f, A-F).']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexValueError"})}}class jf extends ul{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed \`${t}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeOverflowError"})}}class Sf extends ul{constructor({offset:e,position:t,size:n}){super(`Slice ${"start"===t?"starting":"ending"} at offset \`${e}\` is out-of-bounds (size: \`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SliceOffsetOutOfBoundsError"})}}class Nf extends ul{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}}const Tf=new TextEncoder;function _f(e){return e instanceof Uint8Array?e:"string"==typeof e?Cf(e):Rf(e)}function Rf(e){return e instanceof Uint8Array?e:new Uint8Array(e)}function Cf(e,t={}){const{size:n}=t;let r=e;n&&(df(e,n),r=xf(e,n));let s=r.slice(2);s.length%2&&(s=`0${s}`);const i=s.length/2,a=new Uint8Array(i);for(let e=0,t=0;e<i;e++){const n=uf(s.charCodeAt(t++)),r=uf(s.charCodeAt(t++));if(void 0===n||void 0===r)throw new ul(`Invalid byte sequence ("${s[t-2]}${s[t-1]}" in "${s}").`);a[e]=n<<4|r}return a}function Bf(e,t={}){const{size:n}=t,r=Tf.encode(e);return"number"==typeof n?(of(r,n),function(e,t){return function(e,t={}){const{dir:n,size:r=32}=t;if(0===r)return e;if(e.length>r)throw new Zf({size:e.length,targetSize:r,type:"Bytes"});const s=new Uint8Array(r);for(let t=0;t<r;t++){const i="right"===n;s[i?t:r-t-1]=e[i?t:e.length-t-1]}return s}(e,{dir:"right",size:t})}(r,n)):r}function Df(e){return e.length}function Uf(e,t,n,r={}){const{strict:s}=r;!function(e,t){if("number"==typeof t&&t>0&&t>Df(e)-1)throw new Vf({offset:t,position:"start",size:Df(e)})}(e,t);const i=e.slice(t,n);return s&&function(e,t,n){if("number"==typeof t&&"number"==typeof n&&Df(e)!==n-t)throw new Vf({offset:n,position:"end",size:Df(e)})}(i,t,n),i}function qf(e,t={}){const{size:n}=t;void 0!==n&&of(e,n);return Ef(bf(e,t),t)}function Lf(e,t={}){return bf(e,t)}function Ff(e){try{return function(e){if(!(e instanceof Uint8Array)){if(!e)throw new Kf(e);if("object"!=typeof e)throw new Kf(e);if(!("BYTES_PER_ELEMENT"in e))throw new Kf(e);if(1!==e.BYTES_PER_ELEMENT||"Uint8Array"!==e.constructor.name)throw new Kf(e)}}(e),!0}catch{return!1}}class Kf extends ul{constructor(e){super(`Value \`${"object"==typeof e?cl(e):e}\` of type \`${typeof e}\` is an invalid Bytes value.`,{metaMessages:["Bytes values must be of type `Bytes`."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.InvalidBytesTypeError"})}}class Gf extends ul{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed \`${t}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}}class Vf extends ul{constructor({offset:e,position:t,size:n}){super(`Slice ${"start"===t?"starting":"ending"} at offset \`${e}\` is out-of-bounds (size: \`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SliceOffsetOutOfBoundsError"})}}class Zf extends ul{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeExceedsPaddingSizeError"})}}class Hf extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&void 0!==t&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const e=this.keys().next().value;e&&this.delete(e)}return this}}const Wf={checksum:new Hf(8192)}.checksum;function Yf(e,t={}){const{as:n=("string"==typeof e?"Hex":"Bytes")}=t,r=Nt(_f(e));return"Bytes"===n?r:bf(r)}function Qf(e,t={}){const{as:n=("string"==typeof e?"Hex":"Bytes")}=t,r=Ms(_f(e));return"Bytes"===n?r:bf(r)}function Jf(e,t={}){const{compressed:n}=t,{prefix:r,x:s,y:i}=e;if(!1===n||"bigint"==typeof s&&"bigint"==typeof i){if(4!==r)throw new rp({prefix:r,cause:new ip})}else{if(!0!==n&&("bigint"!=typeof s||void 0!==i))throw new np({publicKey:e});if(3!==r&&2!==r)throw new rp({prefix:r,cause:new sp})}}function Xf(e){const t=(()=>{if(kf(e))return ep(e);if(Ff(e))return function(e){return ep(bf(e))}(e);const{prefix:t,x:n,y:r}=e;return"bigint"==typeof n&&"bigint"==typeof r?{prefix:t??4,x:n,y:r}:{prefix:t,x:n}})();return Jf(t),t}function ep(e){if(132!==e.length&&130!==e.length&&68!==e.length)throw new ap({publicKey:e});if(130===e.length){return{prefix:4,x:BigInt(If(e,0,32)),y:BigInt(If(e,32,64))}}if(132===e.length){return{prefix:Number(If(e,0,1)),x:BigInt(If(e,1,33)),y:BigInt(If(e,33,65))}}return{prefix:Number(If(e,0,1)),x:BigInt(If(e,1,33))}}function tp(e,t={}){Jf(e);const{prefix:n,x:r,y:s}=e,{includePrefix:i=!0}=t;return hf(i?gf(n,{size:1}):"0x",gf(r,{size:32}),"bigint"==typeof s?gf(s,{size:32}):"0x")}class np extends ul{constructor({publicKey:e}){super(`Value \`${cl(e)}\` is not a valid public key.`,{metaMessages:["Public key must contain:","- an `x` and `prefix` value (compressed)","- an `x`, `y`, and `prefix` value (uncompressed)"]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidError"})}}class rp extends ul{constructor({prefix:e,cause:t}){super(`Prefix "${e}" is invalid.`,{cause:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidPrefixError"})}}class sp extends ul{constructor(){super("Prefix must be 2 or 3 for compressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidCompressedPrefixError"})}}class ip extends ul{constructor(){super("Prefix must be 4 for uncompressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidUncompressedPrefixError"})}}class ap extends ul{constructor({publicKey:e}){super(`Value \`${e}\` is an invalid public key size.`,{metaMessages:["Expected: 33 bytes (compressed + prefix), 64 bytes (uncompressed) or 65 bytes (uncompressed + prefix).",`Received ${Pf(mf(e))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidSerializedSizeError"})}}const op=/^0x[a-fA-F0-9]{40}$/;function cp(e,t={}){const{strict:n=!0}=t;if(!op.test(e))throw new hp({address:e,cause:new mp});if(n){if(e.toLowerCase()===e)return;if(up(e)!==e)throw new hp({address:e,cause:new yp})}}function up(e){if(Wf.has(e))return Wf.get(e);cp(e,{strict:!1});const t=e.substring(2).toLowerCase(),n=Yf(Bf(t),{as:"Bytes"}),r=t.split("");for(let e=0;e<40;e+=2)n[e>>1]>>4>=8&&r[e]&&(r[e]=r[e].toUpperCase()),(15&n[e>>1])>=8&&r[e+1]&&(r[e+1]=r[e+1].toUpperCase());const s=`0x${r.join("")}`;return Wf.set(e,s),s}function dp(e,t={}){const{checksum:n=!1}=t;return cp(e),n?up(e):e}function lp(e,t={}){return dp(`0x${Yf(`0x${tp(e).slice(4)}`).substring(26)}`,t)}function fp(e,t){return cp(e,{strict:!1}),cp(t,{strict:!1}),e.toLowerCase()===t.toLowerCase()}function pp(e,t={}){const{strict:n=!0}=t??{};try{return cp(e,{strict:n}),!0}catch{return!1}}class hp extends ul{constructor({address:e,cause:t}){super(`Address "${e}" is invalid.`,{cause:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}class mp extends ul{constructor(){super("Address is not a 20 byte (40 hexadecimal character) value."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidInputError"})}}class yp extends ul{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}function bp(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:a,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);const s=a.prototype,i=Object.keys(s);for(let e=0;e<i.length;e++){const t=i[e];t in n||(n[t]=s[t].bind(n))}}const s=n?.Parent??Object;class i extends s{}function a(e){var t;const s=n?.Parent?new i:this;r(s,e),(t=s._zod).deferred??(t.deferred=[]);for(const e of s._zod.deferred)e();return s}return Object.defineProperty(i,"name",{value:e}),Object.defineProperty(a,"init",{value:r}),Object.defineProperty(a,Symbol.hasInstance,{value:t=>!!(n?.Parent&&t instanceof n.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}Object.freeze({status:"aborted"});class gp extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const wp={};function vp(e){return e&&Object.assign(wp,e),wp}function xp(e,t){return"bigint"==typeof t?t.toString():t}function Ip(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Pp(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}const zp=Symbol("evaluating");function Ep(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==zp)return void 0===r&&(r=zp,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Ap(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function kp(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}const Mp="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function $p(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const Op=new Set(["string","number","bigint","boolean","symbol","undefined"]);function jp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Sp(e,t,n){const r=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(r._zod.parent=e),r}function Np(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}function Tp(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!0!==e.issues[n]?.continue)return!0;return!1}function _p(e,t){return t.map((t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t}))}function Rp(e){return"string"==typeof e?e:e?.message}function Cp(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const s=Rp(e.inst?._zod.def?.error?.(e))??Rp(t?.error?.(e))??Rp(n.customError?.(e))??Rp(n.localeError?.(e))??"Invalid input";r.message=s}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}const Bp=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,xp,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Dp=bp("$ZodError",Bp),Up=bp("$ZodError",Bp,{Parent:Error}),qp=e=>(t,n,r,s)=>{const i=r?Object.assign(r,{async:!1}):{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new gp;if(a.issues.length){const t=new(s?.Err??e)(a.issues.map((e=>Cp(e,i,vp()))));throw Mp(t,s?.callee),t}return a.value},Lp=qp(Up),Fp=e=>async(t,n,r,s)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){const t=new(s?.Err??e)(a.issues.map((e=>Cp(e,i,vp()))));throw Mp(t,s?.callee),t}return a.value},Kp=Fp(Up),Gp=e=>(t,n,r)=>{const s=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new gp;return i.issues.length?{success:!1,error:new(e??Dp)(i.issues.map((e=>Cp(e,s,vp()))))}:{success:!0,data:i.value}},Vp=Gp(Up),Zp=e=>async(t,n,r)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},s);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map((e=>Cp(e,s,vp()))))}:{success:!0,data:i.value}},Hp=Zp(Up),Wp=e=>(t,n,r)=>{const s=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return qp(e)(t,n,s)},Yp=Wp(Up),Qp=e=>(t,n,r)=>qp(e)(t,n,r),Jp=Qp(Up),Xp=/^-?\d+n?$/,eh=/^-?\d+(?:\.\d+)?/,th=/^(?:true|false)$/i,nh=/^null$/i,rh=/^undefined$/i,sh=bp("$ZodCheck",((e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])})),ih={number:"number",bigint:"bigint",object:"date"},ah=bp("$ZodCheckGreaterThan",((e,t)=>{sh.init(e,t);const n=ih[typeof t.value];e._zod.onattach.push((e=>{const n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)})),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}})),oh=bp("$ZodCheckMinLength",((e,t)=>{var n;sh.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!(n=t,null==n||void 0===t.length);var n}),e._zod.onattach.push((e=>{const n=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(e._zod.bag.minimum=t.minimum)})),e._zod.check=n=>{const r=n.value;if(r.length>=t.minimum)return;const s=function(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}(r);n.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}})),ch=bp("$ZodCheckStringFormat",((e,t)=>{var n,r;sh.init(e,t),e._zod.onattach.push((e=>{const n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??(n.patterns=new Set),n.patterns.add(t.pattern))})),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})})),uh=bp("$ZodCheckRegex",((e,t)=>{ch.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}})),dh={major:4,minor:2,patch:1},lh=bp("$ZodType",((e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=dh;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const t of r)for(const n of t._zod.onattach)n(e);if(0===r.length)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push((()=>{e._zod.run=e._zod.parse}));else{const t=(e,t,n)=>{let r,s=Tp(e);for(const i of t){if(i._zod.def.when){if(!i._zod.def.when(e))continue}else if(s)continue;const t=e.issues.length,a=i._zod.check(e);if(a instanceof Promise&&!1===n?.async)throw new gp;if(r||a instanceof Promise)r=(r??Promise.resolve()).then((async()=>{await a;e.issues.length!==t&&(s||(s=Tp(e,t)))}));else{if(e.issues.length===t)continue;s||(s=Tp(e,t))}}return r?r.then((()=>e)):e},n=(n,s,i)=>{if(Tp(n))return n.aborted=!0,n;const a=t(s,r,i);if(a instanceof Promise){if(!1===i.async)throw new gp;return a.then((t=>e._zod.parse(t,i)))}return e._zod.parse(a,i)};e._zod.run=(s,i)=>{if(i.skipChecks)return e._zod.parse(s,i);if("backward"===i.direction){const t=e._zod.parse({value:s.value,issues:[]},{...i,skipChecks:!0});return t instanceof Promise?t.then((e=>n(e,s,i))):n(t,s,i)}const a=e._zod.parse(s,i);if(a instanceof Promise){if(!1===i.async)throw new gp;return a.then((e=>t(e,r,i)))}return t(a,r,i)}}e["~standard"]={validate:t=>{try{const n=Vp(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return Hp(e,t).then((e=>e.success?{value:e.data}:{issues:e.error?.issues}))}},vendor:"zod",version:1}})),fh=bp("$ZodString",((e,t)=>{var n;lh.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(n=e._zod.bag,new RegExp(`^${n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}})),ph=bp("$ZodNumber",((e,t)=>{lh.init(e,t),e._zod.pattern=e._zod.bag.pattern??eh,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(e){}const s=n.value;if("number"==typeof s&&!Number.isNaN(s)&&Number.isFinite(s))return n;const i="number"==typeof s?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:s,inst:e,...i?{received:i}:{}}),n}})),hh=bp("$ZodBoolean",((e,t)=>{lh.init(e,t),e._zod.pattern=th,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(e){}const s=n.value;return"boolean"==typeof s||n.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:e}),n}})),mh=bp("$ZodBigInt",((e,t)=>{lh.init(e,t),e._zod.pattern=Xp,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch(e){}return"bigint"==typeof n.value||n.issues.push({expected:"bigint",code:"invalid_type",input:n.value,inst:e}),n}})),yh=bp("$ZodUndefined",((e,t)=>{lh.init(e,t),e._zod.pattern=rh,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(t,n)=>{const r=t.value;return void 0===r||t.issues.push({expected:"undefined",code:"invalid_type",input:r,inst:e}),t}})),bh=bp("$ZodNull",((e,t)=>{lh.init(e,t),e._zod.pattern=nh,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{const r=t.value;return null===r||t.issues.push({expected:"null",code:"invalid_type",input:r,inst:e}),t}})),gh=bp("$ZodAny",((e,t)=>{lh.init(e,t),e._zod.parse=e=>e})),wh=bp("$ZodUnknown",((e,t)=>{lh.init(e,t),e._zod.parse=e=>e})),vh=bp("$ZodDate",((e,t)=>{lh.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch(e){}const s=n.value,i=s instanceof Date;return i&&!Number.isNaN(s.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:s,...i?{received:"Invalid Date"}:{},inst:e}),n}}));function xh(e,t,n){e.issues.length&&t.issues.push(..._p(n,e.issues)),t.value[n]=e.value}const Ih=bp("$ZodArray",((e,t)=>{lh.init(e,t),e._zod.parse=(n,r)=>{const s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),n;n.value=Array(s.length);const i=[];for(let e=0;e<s.length;e++){const a=s[e],o=t.element._zod.run({value:a,issues:[]},r);o instanceof Promise?i.push(o.then((t=>xh(t,n,e)))):xh(o,n,e)}return i.length?Promise.all(i).then((()=>n)):n}}));function Ph(e,t,n,r){e.issues.length&&t.issues.push(..._p(n,e.issues)),void 0===e.value?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function zh(e){const t=Object.keys(e.shape);for(const n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const n=(r=e.shape,Object.keys(r).filter((e=>"optional"===r[e]._zod.optin&&"optional"===r[e]._zod.optout)));var r;return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}const Eh=bp("$ZodObject",((e,t)=>{lh.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!n?.get){const e=t.shape;Object.defineProperty(t,"shape",{get:()=>{const n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}const r=Ip((()=>zh(t)));Ep(e._zod,"propValues",(()=>{const e=t.shape,n={};for(const t in e){const r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(const e of r.values)n[t].add(e)}}return n}));const s=$p,i=t.catchall;let a;e._zod.parse=(t,n)=>{a??(a=r.value);const o=t.value;if(!s(o))return t.issues.push({expected:"object",code:"invalid_type",input:o,inst:e}),t;t.value={};const c=[],u=a.shape;for(const e of a.keys){const r=u[e]._zod.run({value:o[e],issues:[]},n);r instanceof Promise?c.push(r.then((n=>Ph(n,t,e,o)))):Ph(r,t,e,o)}return i?function(e,t,n,r,s,i){const a=[],o=s.keySet,c=s.catchall._zod,u=c.def.type;for(const s in t){if(o.has(s))continue;if("never"===u){a.push(s);continue}const i=c.run({value:t[s],issues:[]},r);i instanceof Promise?e.push(i.then((e=>Ph(e,n,s,t)))):Ph(i,n,s,t)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i}),e.length?Promise.all(e).then((()=>n)):n}(c,o,t,n,r.value,e):c.length?Promise.all(c).then((()=>t)):t}}));function Ah(e,t,n,r){for(const n of e)if(0===n.issues.length)return t.value=n.value,t;const s=e.filter((e=>!Tp(e)));return 1===s.length?(t.value=s[0].value,s[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((e=>e.issues.map((e=>Cp(e,r,vp())))))}),t)}const kh=bp("$ZodUnion",((e,t)=>{lh.init(e,t),Ep(e._zod,"optin",(()=>t.options.some((e=>"optional"===e._zod.optin))?"optional":void 0)),Ep(e._zod,"optout",(()=>t.options.some((e=>"optional"===e._zod.optout))?"optional":void 0)),Ep(e._zod,"values",(()=>{if(t.options.every((e=>e._zod.values)))return new Set(t.options.flatMap((e=>Array.from(e._zod.values))))})),Ep(e._zod,"pattern",(()=>{if(t.options.every((e=>e._zod.pattern))){const e=t.options.map((e=>e._zod.pattern));return new RegExp(`^(${e.map((e=>Pp(e.source))).join("|")})$`)}}));const n=1===t.options.length,r=t.options[0]._zod.run;e._zod.parse=(s,i)=>{if(n)return r(s,i);let a=!1;const o=[];for(const e of t.options){const t=e._zod.run({value:s.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(0===t.issues.length)return t;o.push(t)}}return a?Promise.all(o).then((t=>Ah(t,s,e,i))):Ah(o,s,e,i)}})),Mh=bp("$ZodDiscriminatedUnion",((e,t)=>{t.inclusive=!1,kh.init(e,t);const n=e._zod.parse;Ep(e._zod,"propValues",(()=>{const e={};for(const n of t.options){const r=n._zod.propValues;if(!r||0===Object.keys(r).length)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(const[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(const r of n)e[t].add(r)}}return e}));const r=Ip((()=>{const e=t.options,n=new Map;for(const r of e){const e=r._zod.propValues?.[t.discriminator];if(!e||0===e.size)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(const t of e){if(n.has(t))throw new Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n}));e._zod.parse=(s,i)=>{const a=s.value;if(!$p(a))return s.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),s;const o=r.value.get(a?.[t.discriminator]);return o?o._zod.run(s,i):t.unionFallback?n(s,i):(s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:e}),s)}})),$h=bp("$ZodTuple",((e,t)=>{lh.init(e,t);const n=t.items;e._zod.parse=(r,s)=>{const i=r.value;if(!Array.isArray(i))return r.issues.push({input:i,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=[];const a=[],o=[...n].reverse().findIndex((e=>"optional"!==e._zod.optin)),c=-1===o?0:n.length-o;if(!t.rest){const t=i.length>n.length,s=i.length<c-1;if(t||s)return r.issues.push({...t?{code:"too_big",maximum:n.length}:{code:"too_small",minimum:n.length},input:i,inst:e,origin:"array"}),r}let u=-1;for(const e of n){if(u++,u>=i.length&&u>=c)continue;const t=e._zod.run({value:i[u],issues:[]},s);t instanceof Promise?a.push(t.then((e=>Oh(e,r,u)))):Oh(t,r,u)}if(t.rest){const e=i.slice(n.length);for(const n of e){u++;const e=t.rest._zod.run({value:n,issues:[]},s);e instanceof Promise?a.push(e.then((e=>Oh(e,r,u)))):Oh(e,r,u)}}return a.length?Promise.all(a).then((()=>r)):r}}));function Oh(e,t,n){e.issues.length&&t.issues.push(..._p(n,e.issues)),t.value[n]=e.value}const jh=bp("$ZodRecord",((e,t)=>{lh.init(e,t),e._zod.parse=(n,r)=>{const s=n.value;if(!function(e){if(!1===$p(e))return!1;const t=e.constructor;if(void 0===t)return!0;if("function"!=typeof t)return!0;const n=t.prototype;return!1!==$p(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),n;const i=[],a=t.keyType._zod.values;if(a){n.value={};const o=new Set;for(const e of a)if("string"==typeof e||"number"==typeof e||"symbol"==typeof e){o.add("number"==typeof e?e.toString():e);const a=t.valueType._zod.run({value:s[e],issues:[]},r);a instanceof Promise?i.push(a.then((t=>{t.issues.length&&n.issues.push(..._p(e,t.issues)),n.value[e]=t.value}))):(a.issues.length&&n.issues.push(..._p(e,a.issues)),n.value[e]=a.value)}let c;for(const e in s)o.has(e)||(c=c??[],c.push(e));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c})}else{n.value={};for(const a of Reflect.ownKeys(s)){if("__proto__"===a)continue;const o=t.keyType._zod.run({value:a,issues:[]},r);if(o instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(o.issues.length){"loose"===t.mode?n.value[a]=s[a]:n.issues.push({code:"invalid_key",origin:"record",issues:o.issues.map((e=>Cp(e,r,vp()))),input:a,path:[a],inst:e});continue}const c=t.valueType._zod.run({value:s[a],issues:[]},r);c instanceof Promise?i.push(c.then((e=>{e.issues.length&&n.issues.push(..._p(a,e.issues)),n.value[o.value]=e.value}))):(c.issues.length&&n.issues.push(..._p(a,c.issues)),n.value[o.value]=c.value)}}return i.length?Promise.all(i).then((()=>n)):n}})),Sh=bp("$ZodLiteral",((e,t)=>{if(lh.init(e,t),0===t.values.length)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map((e=>"string"==typeof e?jp(e):e?jp(e.toString()):String(e))).join("|")})$`),e._zod.parse=(r,s)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}));function Nh(e,t){return e.issues.length&&void 0===t?{issues:[],value:void 0}:e}const Th=bp("$ZodOptional",((e,t)=>{lh.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Ep(e._zod,"values",(()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0)),Ep(e._zod,"pattern",(()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Pp(e.source)})?$`):void 0})),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then((t=>Nh(t,e.value))):Nh(r,e.value)}return void 0===e.value?e:t.innerType._zod.run(e,n)}})),_h=bp("$ZodNullable",((e,t)=>{lh.init(e,t),Ep(e._zod,"optin",(()=>t.innerType._zod.optin)),Ep(e._zod,"optout",(()=>t.innerType._zod.optout)),Ep(e._zod,"pattern",(()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Pp(e.source)}|null)$`):void 0})),Ep(e._zod,"values",(()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0)),e._zod.parse=(e,n)=>null===e.value?e:t.innerType._zod.run(e,n)})),Rh=bp("$ZodPipe",((e,t)=>{lh.init(e,t),Ep(e._zod,"values",(()=>t.in._zod.values)),Ep(e._zod,"optin",(()=>t.in._zod.optin)),Ep(e._zod,"optout",(()=>t.out._zod.optout)),Ep(e._zod,"propValues",(()=>t.in._zod.propValues)),e._zod.parse=(e,n)=>{if("backward"===n.direction){const r=t.out._zod.run(e,n);return r instanceof Promise?r.then((e=>Ch(e,t.in,n))):Ch(r,t.in,n)}const r=t.in._zod.run(e,n);return r instanceof Promise?r.then((e=>Ch(e,t.out,n))):Ch(r,t.out,n)}}));function Ch(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Bh=bp("$ZodCodec",((e,t)=>{lh.init(e,t),Ep(e._zod,"values",(()=>t.in._zod.values)),Ep(e._zod,"optin",(()=>t.in._zod.optin)),Ep(e._zod,"optout",(()=>t.out._zod.optout)),Ep(e._zod,"propValues",(()=>t.in._zod.propValues)),e._zod.parse=(e,n)=>{if("forward"===(n.direction||"forward")){const r=t.in._zod.run(e,n);return r instanceof Promise?r.then((e=>Dh(e,t,n))):Dh(r,t,n)}{const r=t.out._zod.run(e,n);return r instanceof Promise?r.then((e=>Dh(e,t,n))):Dh(r,t,n)}}}));function Dh(e,t,n){if(e.issues.length)return e.aborted=!0,e;if("forward"===(n.direction||"forward")){const r=t.transform(e.value,e);return r instanceof Promise?r.then((r=>Uh(e,r,t.out,n))):Uh(e,r,t.out,n)}{const r=t.reverseTransform(e.value,e);return r instanceof Promise?r.then((r=>Uh(e,r,t.in,n))):Uh(e,r,t.in,n)}}function Uh(e,t,n,r){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},r)}const qh=bp("$ZodReadonly",((e,t)=>{lh.init(e,t),Ep(e._zod,"propValues",(()=>t.innerType._zod.propValues)),Ep(e._zod,"values",(()=>t.innerType._zod.values)),Ep(e._zod,"optin",(()=>t.innerType?._zod?.optin)),Ep(e._zod,"optout",(()=>t.innerType?._zod?.optout)),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Lh):Lh(r)}}));function Lh(e){return e.value=Object.freeze(e.value),e}const Fh=bp("$ZodTemplateLiteral",((e,t)=>{lh.init(e,t);const n=[];for(const e of t.parts)if("object"==typeof e&&null!==e){if(!e._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...e._zod.traits].shift()}`);const t=e._zod.pattern instanceof RegExp?e._zod.pattern.source:e._zod.pattern;if(!t)throw new Error(`Invalid template literal part: ${e._zod.traits}`);const r=t.startsWith("^")?1:0,s=t.endsWith("$")?t.length-1:t.length;n.push(t.slice(r,s))}else{if(null!==e&&!Op.has(typeof e))throw new Error(`Invalid template literal part: ${e}`);n.push(jp(`${e}`))}e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(n,r)=>"string"!=typeof n.value?(n.issues.push({input:n.value,inst:e,expected:"template_literal",code:"invalid_type"}),n):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(n.value)||n.issues.push({input:n.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),n)}));var Kh;class Gh{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const n=t[0];if(this._map.set(e,n),n&&"object"==typeof n&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};delete n.id;const r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function Vh(e,t){return new oh({check:"min_length",...Np(t),minimum:e})}function Zh(e,t){return new uh({check:"string_format",format:"regex",...Np(t),pattern:e})}(Kh=globalThis).__zod_globalRegistry??(Kh.__zod_globalRegistry=new Gh);const Hh=bp("ZodMiniType",((e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");lh.init(e,t),e.def=t,e.type=t.type,e.parse=(t,n)=>Lp(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Vp(e,t,n),e.parseAsync=async(t,n)=>Kp(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Hp(e,t,n),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map((e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e))]}),e.clone=(t,n)=>Sp(e,t,n),e.brand=()=>e,e.register=(t,n)=>(t.add(e,n),e)})),Wh=bp("ZodMiniString",((e,t)=>{fh.init(e,t),Hh.init(e,t)}));function Yh(e){return function(e,t){return new e({type:"string",...Np(t)})}(Wh,e)}const Qh=bp("ZodMiniNumber",((e,t)=>{ph.init(e,t),Hh.init(e,t)}));function Jh(e){return function(e,t){return new e({type:"number",checks:[],...Np(t)})}(Qh,e)}const Xh=bp("ZodMiniBoolean",((e,t)=>{hh.init(e,t),Hh.init(e,t)}));function em(e){return function(e,t){return new e({type:"boolean",...Np(t)})}(Xh,e)}const tm=bp("ZodMiniBigInt",((e,t)=>{mh.init(e,t),Hh.init(e,t)}));function nm(e){return function(e,t){return new e({type:"bigint",...Np(t)})}(tm,e)}const rm=bp("ZodMiniUndefined",((e,t)=>{yh.init(e,t),Hh.init(e,t)}));function sm(e){return function(e,t){return new e({type:"undefined",...Np(t)})}(rm,e)}const im=bp("ZodMiniNull",((e,t)=>{bh.init(e,t),Hh.init(e,t)}));function am(e){return function(e,t){return new e({type:"null",...Np(t)})}(im,e)}const om=bp("ZodMiniAny",((e,t)=>{gh.init(e,t),Hh.init(e,t)}));function cm(){return new om({type:"any"})}const um=bp("ZodMiniUnknown",((e,t)=>{wh.init(e,t),Hh.init(e,t)}));function dm(){return new um({type:"unknown"})}const lm=bp("ZodMiniDate",((e,t)=>{vh.init(e,t),Hh.init(e,t)}));function fm(e){return function(e,t){return new e({type:"date",...Np(t)})}(lm,e)}const pm=bp("ZodMiniArray",((e,t)=>{Ih.init(e,t),Hh.init(e,t)}));function hm(e,t){return new pm({type:"array",element:e,...Np(t)})}const mm=bp("ZodMiniObject",((e,t)=>{Eh.init(e,t),Hh.init(e,t),Ep(e,"shape",(()=>t.shape))}));function ym(e,t){const n={type:"object",shape:e??{},...Np(t)};return new mm(n)}function bm(e,t){return function(e,t){const n=e._zod.def;return Sp(e,kp(e._zod.def,{get shape(){const e={};for(const r in t){if(!(r in n.shape))throw new Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Ap(this,"shape",e),e},checks:[]}))}(e,t)}function gm(e,t){return function(e,t){const n=e._zod.def,r=kp(e._zod.def,{get shape(){const r={...e._zod.def.shape};for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Ap(this,"shape",r),r},checks:[]});return Sp(e,r)}(e,t)}function wm(e,t){return function(e,t,n){const r=kp(t._zod.def,{get shape(){const r=t._zod.def.shape,s={...r};if(n)for(const t in n){if(!(t in r))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(s[t]=e?new e({type:"optional",innerType:r[t]}):r[t])}else for(const t in r)s[t]=e?new e({type:"optional",innerType:r[t]}):r[t];return Ap(this,"shape",s),s},checks:[]});return Sp(t,r)}($m,e,t)}const vm=bp("ZodMiniUnion",((e,t)=>{kh.init(e,t),Hh.init(e,t)}));function xm(e,t){return new vm({type:"union",options:e,...Np(t)})}const Im=bp("ZodMiniDiscriminatedUnion",((e,t)=>{Mh.init(e,t),Hh.init(e,t)}));const Pm=bp("ZodMiniTuple",((e,t)=>{$h.init(e,t),Hh.init(e,t)}));function zm(e,t,n){const r=t instanceof lh;return new Pm({type:"tuple",items:e,rest:r?t:null,...Np(r?n:t)})}const Em=bp("ZodMiniRecord",((e,t)=>{jh.init(e,t),Hh.init(e,t)}));function Am(e,t,n){return new Em({type:"record",keyType:e,valueType:t,...Np(n)})}const km=bp("ZodMiniLiteral",((e,t)=>{Sh.init(e,t),Hh.init(e,t)}));function Mm(e,t){return new km({type:"literal",values:Array.isArray(e)?e:[e],...Np(t)})}const $m=bp("ZodMiniOptional",((e,t)=>{Th.init(e,t),Hh.init(e,t)}));function Om(e){return new $m({type:"optional",innerType:e})}const jm=bp("ZodMiniNullable",((e,t)=>{_h.init(e,t),Hh.init(e,t)}));function Sm(e){return new jm({type:"nullable",innerType:e})}function Nm(e){return Om(Sm(e))}const Tm=bp("ZodMiniPipe",((e,t)=>{Rh.init(e,t),Hh.init(e,t)})),_m=bp("ZodMiniCodec",((e,t)=>{Tm.init(e,t),Bh.init(e,t)}));function Rm(e,t,n){return new _m({type:"pipe",in:e,out:t,transform:n.decode,reverseTransform:n.encode})}const Cm=bp("ZodMiniReadonly",((e,t)=>{qh.init(e,t),Hh.init(e,t)}));function Bm(e){return new Cm({type:"readonly",innerType:e})}const Dm=bp("ZodMiniTemplateLiteral",((e,t)=>{Fh.init(e,t),Hh.init(e,t)}));function Um(e,t){return new Dm({type:"template_literal",parts:e,...Np(t)})}let qm=!1;function Lm(e){return lp(function(e){const{payload:t,signature:n}=e,{r:r,s:s,yParity:i}=n,a=new rd.Signature(BigInt(r),BigInt(s)).addRecoveryBit(i);return Xf(a.recoverPublicKey(mf(t).substring(2)))}(e))}function Fm(e){const{extraEntropy:t=qm,hash:n,payload:r,privateKey:s}=e,{r:i,s:a,recovery:o}=rd.sign(_f(r),_f(s),{extraEntropy:"boolean"==typeof t?t:mf(t).slice(2),lowS:!0,...n?{prehash:!0}:{}});return{r:i,s:a,yParity:o}}const Km=/^(.*)\[([0-9]*)\]$/,Gm=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Vm=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/,Zm=2n**256n-1n;function Hm(e,t={}){const{recovered:n}=t;if(void 0===e.r)throw new ty({signature:e});if(void 0===e.s)throw new ty({signature:e});if(n&&void 0===e.yParity)throw new ty({signature:e});if(e.r<0n||e.r>Zm)throw new ny({value:e.r});if(e.s<0n||e.s>Zm)throw new ry({value:e.s});if("number"==typeof e.yParity&&0!==e.yParity&&1!==e.yParity)throw new sy({value:e.yParity})}function Wm(e){if(130!==e.length&&132!==e.length)throw new ey({signature:e});const t=BigInt(If(e,0,32)),n=BigInt(If(e,32,64)),r=(()=>{const t=Number(`0x${e.slice(130)}`);if(!Number.isNaN(t))try{return Xm(t)}catch{throw new sy({value:t})}})();return void 0===r?{r:t,s:n}:{r:t,s:n,yParity:r}}function Ym(e){const t="string"==typeof e?Wm(e):e instanceof Uint8Array?function(e){return Wm(bf(e))}(e):"string"==typeof e.r?function(e){const t=(()=>{const t=e.v?Number(e.v):void 0;let n=e.yParity?Number(e.yParity):void 0;if("number"==typeof t&&"number"!=typeof n&&(n=Xm(t)),"number"!=typeof n)throw new sy({value:e.yParity});return n})();return{r:BigInt(e.r),s:BigInt(e.s),yParity:t}}(e):e.v?function(e){return{r:e.r,s:e.s,yParity:Xm(e.v)}}(e):{r:e.r,s:e.s,...void 0!==e.yParity?{yParity:e.yParity}:{}};return Hm(t),t}function Qm(e){Hm(e);const t=e.r,n=e.s;return hf(gf(t,{size:32}),gf(n,{size:32}),"number"==typeof e.yParity?gf(function(e){if(0===e)return 27;if(1===e)return 28;throw new sy({value:e})}(e.yParity),{size:1}):"0x")}function Jm(e){const{r:t,s:n,yParity:r}=e;return[r?"0x01":"0x",0n===t?"0x":zf(gf(t)),0n===n?"0x":zf(gf(n))]}function Xm(e){if(0===e||27===e)return 0;if(1===e||28===e)return 1;if(e>=35)return e%2==0?1:0;throw new iy({value:e})}class ey extends ul{constructor({signature:e}){super(`Value \`${e}\` is an invalid signature size.`,{metaMessages:["Expected: 64 bytes or 65 bytes.",`Received ${Pf(mf(e))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSerializedSizeError"})}}class ty extends ul{constructor({signature:e}){super(`Signature \`${cl(e)}\` is missing either an \`r\`, \`s\`, or \`yParity\` property.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.MissingPropertiesError"})}}class ny extends ul{constructor({value:e}){super(`Value \`${e}\` is an invalid r value. r must be a positive integer less than 2^256.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidRError"})}}class ry extends ul{constructor({value:e}){super(`Value \`${e}\` is an invalid s value. s must be a positive integer less than 2^256.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSError"})}}class sy extends ul{constructor({value:e}){super(`Value \`${e}\` is an invalid y-parity value. Y-parity must be 0 or 1.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidYParityError"})}}class iy extends ul{constructor({value:e}){super(`Value \`${e}\` is an invalid v value. v must be 27, 28 or >=35.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidVError"})}}class ay extends Error{constructor(e,t={}){const n=t.cause instanceof ay?t.cause.details:t.cause?.message?t.cause.message:t.details,r=t.cause instanceof ay&&t.cause.docsPath||t.docsPath;super([e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...r?[`Docs: https://abitype.dev${r}`]:[],...n?[`Details: ${n}`]:[],"Version: abitype@1.2.3"].join("\n")),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiTypeError"}),t.cause&&(this.cause=t.cause),this.details=n,this.docsPath=r,this.metaMessages=t.metaMessages,this.shortMessage=e}}function oy(e,t){const n=e.exec(t);return n?.groups}const cy=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,uy=/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/,dy=/^\(.+?\).*?$/,ly=/^tuple(?<array>(\[(\d*)\])*)$/;function fy(e){let t=e.type;if(ly.test(e.type)&&"components"in e){t="(";const n=e.components.length;for(let r=0;r<n;r++){t+=fy(e.components[r]),r<n-1&&(t+=", ")}const r=oy(ly,e.type);return t+=`)${r?.array||""}`,fy({...e,type:t})}return"indexed"in e&&e.indexed&&(t=`${t} indexed`),e.name?`${t} ${e.name}`:t}function py(e){let t="";const n=e.length;for(let r=0;r<n;r++){t+=fy(e[r]),r!==n-1&&(t+=", ")}return t}function hy(e){return"function"===e.type?`function ${e.name}(${py(e.inputs)})${e.stateMutability&&"nonpayable"!==e.stateMutability?` ${e.stateMutability}`:""}${e.outputs?.length?` returns (${py(e.outputs)})`:""}`:"event"===e.type?`event ${e.name}(${py(e.inputs)})`:"error"===e.type?`error ${e.name}(${py(e.inputs)})`:"constructor"===e.type?`constructor(${py(e.inputs)})${"payable"===e.stateMutability?" payable":""}`:"fallback"===e.type?"fallback() external"+("payable"===e.stateMutability?" payable":""):"receive() external payable"}const my=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const yy=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const by=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;const gy=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function wy(e){return gy.test(e)}function vy(e){return oy(gy,e)}const xy=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;const Iy=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;const Py=/^receive\(\) external payable$/;const zy=new Set(["memory","indexed","storage","calldata"]),Ey=new Set(["indexed"]),Ay=new Set(["calldata","memory","storage"]);class ky extends ay{constructor({signature:e}){super("Failed to parse ABI item.",{details:`parseAbiItem(${JSON.stringify(e,null,2)})`,docsPath:"/api/human#parseabiitem-1"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiItemError"})}}class My extends ay{constructor({type:e}){super("Unknown type.",{metaMessages:[`Type "${e}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownTypeError"})}}class $y extends ay{constructor({type:e}){super("Unknown type.",{metaMessages:[`Type "${e}" is not a valid ABI type.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSolidityTypeError"})}}class Oy extends ay{constructor({params:e}){super("Failed to parse ABI parameters.",{details:`parseAbiParameters(${JSON.stringify(e,null,2)})`,docsPath:"/api/human#parseabiparameters-1"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiParametersError"})}}class jy extends ay{constructor({param:e}){super("Invalid ABI parameter.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class Sy extends ay{constructor({param:e,name:t}){super("Invalid ABI parameter.",{details:e,metaMessages:[`"${t}" is a protected Solidity keyword. More info: https://docs.soliditylang.org/en/latest/cheatsheet.html`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SolidityProtectedKeywordError"})}}class Ny extends ay{constructor({param:e,type:t,modifier:n}){super("Invalid ABI parameter.",{details:e,metaMessages:[`Modifier "${n}" not allowed${t?` in "${t}" type`:""}.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidModifierError"})}}class Ty extends ay{constructor({param:e,type:t,modifier:n}){super("Invalid ABI parameter.",{details:e,metaMessages:[`Modifier "${n}" not allowed${t?` in "${t}" type`:""}.`,`Data location can only be specified for array, struct, or mapping types, but "${n}" was given.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidFunctionModifierError"})}}class _y extends ay{constructor({abiParameter:e}){super("Invalid ABI parameter.",{details:JSON.stringify(e,null,2),metaMessages:["ABI parameter type is invalid."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiTypeParameterError"})}}class Ry extends ay{constructor({signature:e,type:t}){super(`Invalid ${t} signature.`,{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class Cy extends ay{constructor({signature:e}){super("Unknown signature.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class By extends ay{constructor({signature:e}){super("Invalid struct signature.",{details:e,metaMessages:["No properties exist."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidStructSignatureError"})}}class Dy extends ay{constructor({type:e}){super("Circular reference detected.",{metaMessages:[`Struct "${e}" is a circular reference.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"CircularReferenceError"})}}class Uy extends ay{constructor({current:e,depth:t}){super("Unbalanced parentheses.",{metaMessages:[`"${e.trim()}" has too many ${t>0?"opening":"closing"} parentheses.`],details:`Depth "${t}"`}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParenthesisError"})}}const qy=new Map([["address",{type:"address"}],["bool",{type:"bool"}],["bytes",{type:"bytes"}],["bytes32",{type:"bytes32"}],["int",{type:"int256"}],["int256",{type:"int256"}],["string",{type:"string"}],["uint",{type:"uint256"}],["uint8",{type:"uint8"}],["uint16",{type:"uint16"}],["uint24",{type:"uint24"}],["uint32",{type:"uint32"}],["uint64",{type:"uint64"}],["uint96",{type:"uint96"}],["uint112",{type:"uint112"}],["uint160",{type:"uint160"}],["uint192",{type:"uint192"}],["uint256",{type:"uint256"}],["address owner",{type:"address",name:"owner"}],["address to",{type:"address",name:"to"}],["bool approved",{type:"bool",name:"approved"}],["bytes _data",{type:"bytes",name:"_data"}],["bytes data",{type:"bytes",name:"data"}],["bytes signature",{type:"bytes",name:"signature"}],["bytes32 hash",{type:"bytes32",name:"hash"}],["bytes32 r",{type:"bytes32",name:"r"}],["bytes32 root",{type:"bytes32",name:"root"}],["bytes32 s",{type:"bytes32",name:"s"}],["string name",{type:"string",name:"name"}],["string symbol",{type:"string",name:"symbol"}],["string tokenURI",{type:"string",name:"tokenURI"}],["uint tokenId",{type:"uint256",name:"tokenId"}],["uint8 v",{type:"uint8",name:"v"}],["uint256 balance",{type:"uint256",name:"balance"}],["uint256 tokenId",{type:"uint256",name:"tokenId"}],["uint256 value",{type:"uint256",name:"value"}],["event:address indexed from",{type:"address",name:"from",indexed:!0}],["event:address indexed to",{type:"address",name:"to",indexed:!0}],["event:uint indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}],["event:uint256 indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}]]);function Ly(e,t={}){if(function(e){return by.test(e)}(e))return function(e,t={}){const n=function(e){return oy(by,e)}(e);if(!n)throw new Ry({signature:e,type:"function"});const r=Zy(n.parameters),s=[],i=r.length;for(let e=0;e<i;e++)s.push(Vy(r[e],{modifiers:Ay,structs:t,type:"function"}));const a=[];if(n.returns){const e=Zy(n.returns),r=e.length;for(let n=0;n<r;n++)a.push(Vy(e[n],{modifiers:Ay,structs:t,type:"function"}))}return{name:n.name,type:"function",stateMutability:n.stateMutability??"nonpayable",inputs:s,outputs:a}}(e,t);if(function(e){return yy.test(e)}(e))return function(e,t={}){const n=function(e){return oy(yy,e)}(e);if(!n)throw new Ry({signature:e,type:"event"});const r=Zy(n.parameters),s=[],i=r.length;for(let e=0;e<i;e++)s.push(Vy(r[e],{modifiers:Ey,structs:t,type:"event"}));return{name:n.name,type:"event",inputs:s}}(e,t);if(function(e){return my.test(e)}(e))return function(e,t={}){const n=function(e){return oy(my,e)}(e);if(!n)throw new Ry({signature:e,type:"error"});const r=Zy(n.parameters),s=[],i=r.length;for(let e=0;e<i;e++)s.push(Vy(r[e],{structs:t,type:"error"}));return{name:n.name,type:"error",inputs:s}}(e,t);if(function(e){return xy.test(e)}(e))return function(e,t={}){const n=function(e){return oy(xy,e)}(e);if(!n)throw new Ry({signature:e,type:"constructor"});const r=Zy(n.parameters),s=[],i=r.length;for(let e=0;e<i;e++)s.push(Vy(r[e],{structs:t,type:"constructor"}));return{type:"constructor",stateMutability:n.stateMutability??"nonpayable",inputs:s}}(e,t);if(function(e){return Iy.test(e)}(e))return function(e){const t=function(e){return oy(Iy,e)}(e);if(!t)throw new Ry({signature:e,type:"fallback"});return{type:"fallback",stateMutability:t.stateMutability??"nonpayable"}}(e);if(function(e){return Py.test(e)}(e))return{type:"receive",stateMutability:"payable"};throw new Cy({signature:e})}const Fy=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*(?:\spayable)?)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,Ky=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,Gy=/^u?int$/;function Vy(e,t){const n=function(e,t,n){let r="";if(n)for(const e of Object.entries(n)){if(!e)continue;let t="";for(const n of e[1])t+=`[${n.type}${n.name?`:${n.name}`:""}]`;r+=`(${e[0]}{${t}})`}return t?`${t}:${e}${r}`:`${e}${r}`}(e,t?.type,t?.structs);if(qy.has(n))return qy.get(n);const r=dy.test(e),s=oy(r?Ky:Fy,e);if(!s)throw new jy({param:e});if(s.name&&function(e){return"address"===e||"bool"===e||"function"===e||"string"===e||"tuple"===e||cy.test(e)||uy.test(e)||Wy.test(e)}(s.name))throw new Sy({param:e,name:s.name});const i=s.name?{name:s.name}:{},a="indexed"===s.modifier?{indexed:!0}:{},o=t?.structs??{};let c,u={};if(r){c="tuple";const e=Zy(s.type),t=[],n=e.length;for(let r=0;r<n;r++)t.push(Vy(e[r],{structs:o}));u={components:t}}else if(s.type in o)c="tuple",u={components:o[s.type]};else if(Gy.test(s.type))c=`${s.type}256`;else if("address payable"===s.type)c="address";else if(c=s.type,"struct"!==t?.type&&!Hy(c))throw new $y({type:c});if(s.modifier){if(!t?.modifiers?.has?.(s.modifier))throw new Ny({param:e,type:t?.type,modifier:s.modifier});if(Ay.has(s.modifier)&&!function(e,t){return t||"bytes"===e||"string"===e||"tuple"===e}(c,!!s.array))throw new Ty({param:e,type:t?.type,modifier:s.modifier})}const d={type:`${c}${s.array??""}`,...i,...a,...u};return qy.set(n,d),d}function Zy(e,t=[],n="",r=0){const s=e.trim().length;for(let i=0;i<s;i++){const s=e[i],a=e.slice(i+1);switch(s){case",":return 0===r?Zy(a,[...t,n.trim()]):Zy(a,t,`${n}${s}`,r);case"(":return Zy(a,t,`${n}${s}`,r+1);case")":return Zy(a,t,`${n}${s}`,r-1);default:return Zy(a,t,`${n}${s}`,r)}}if(""===n)return t;if(0!==r)throw new Uy({current:n,depth:r});return t.push(n.trim()),t}function Hy(e){return"address"===e||"bool"===e||"function"===e||"string"===e||cy.test(e)||uy.test(e)}const Wy=/^(?:after|alias|anonymous|apply|auto|byte|calldata|case|catch|constant|copyof|default|defined|error|event|external|false|final|function|immutable|implements|in|indexed|inline|internal|let|mapping|match|memory|mutable|null|of|override|partial|private|promise|public|pure|reference|relocatable|return|returns|sizeof|static|storage|struct|super|supports|switch|this|true|try|typedef|typeof|var|view|virtual)$/;function Yy(e){const t={},n=e.length;for(let r=0;r<n;r++){const n=e[r];if(!wy(n))continue;const s=vy(n);if(!s)throw new Ry({signature:n,type:"struct"});const i=s.properties.split(";"),a=[],o=i.length;for(let e=0;e<o;e++){const t=i[e].trim();if(!t)continue;const n=Vy(t,{type:"struct"});a.push(n)}if(!a.length)throw new By({signature:n});t[s.name]=a}const r={},s=Object.entries(t),i=s.length;for(let e=0;e<i;e++){const[n,i]=s[e];r[n]=Jy(i,t)}return r}const Qy=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;function Jy(e=[],t={},n=new Set){const r=[],s=e.length;for(let i=0;i<s;i++){const s=e[i];if(dy.test(s.type))r.push(s);else{const e=oy(Qy,s.type);if(!e?.type)throw new _y({abiParameter:s});const{array:i,type:a}=e;if(a in t){if(n.has(a))throw new Dy({type:a});r.push({...s,type:`tuple${i??""}`,components:Jy(t[a],t,new Set([...n,a]))})}else{if(!Hy(a))throw new My({type:a});r.push(s)}}}return r}function Xy(e){let t;if("string"==typeof e)t=Ly(e);else{const n=Yy(e),r=e.length;for(let s=0;s<r;s++){const r=e[s];if(!wy(r)){t=Ly(r,n);break}}}if(!t)throw new ky({signature:e});return t}function eb(e){const t=[];if("string"==typeof e){const n=Zy(e),r=n.length;for(let e=0;e<r;e++)t.push(Vy(n[e],{modifiers:zy}))}else{const n=Yy(e),r=e.length;for(let s=0;s<r;s++){const r=e[s];if(wy(r))continue;const i=Zy(r),a=i.length;for(let e=0;e<a;e++)t.push(Vy(i[e],{modifiers:zy,structs:n}))}}if(0===t.length)throw new Oy({params:e});return t}function tb({checksumAddress:e=!1,parameter:t,value:n}){const r=t,s=function(e){const t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}(r.type);if(s){const[t,i]=s;return function(e,t){const{checksumAddress:n,length:r,parameter:s}=t,i=null===r;if(!Array.isArray(e))throw new pb(e);if(!i&&e.length!==r)throw new db({expectedLength:r,givenLength:e.length,type:`${s.type}[${r}]`});let a=!1;const o=[];for(let t=0;t<e.length;t++){const r=tb({checksumAddress:n,parameter:s,value:e[t]});r.dynamic&&(a=!0),o.push(r)}if(i||a){const e=nb(o);if(i){const t=gf(o.length,{size:32});return{dynamic:!0,encoded:o.length>0?hf(t,e):t}}if(a)return{dynamic:!0,encoded:e}}return{dynamic:!1,encoded:hf(...o.map((({encoded:e})=>e)))}}(n,{checksumAddress:e,length:t,parameter:{...r,type:i}})}if("tuple"===r.type)return function(e,t){const{checksumAddress:n,parameter:r}=t;let s=!1;const i=[];for(let t=0;t<r.components.length;t++){const a=r.components[t],o=tb({checksumAddress:n,parameter:a,value:e[Array.isArray(e)?t:a.name]});i.push(o),o.dynamic&&(s=!0)}return{dynamic:s,encoded:s?nb(i):hf(...i.map((({encoded:e})=>e)))}}(n,{checksumAddress:e,parameter:r});if("address"===r.type)return function(e,t){const{checksum:n=!1}=t;return cp(e,{strict:n}),{dynamic:!1,encoded:vf(e.toLowerCase())}}(n,{checksum:e});if("bool"===r.type)return function(e){if("boolean"!=typeof e)throw new ul(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:vf(yf(e))}}(n);if(r.type.startsWith("uint")||r.type.startsWith("int")){const e=r.type.startsWith("int"),[,,t="256"]=Vm.exec(r.type)??[];return function(e,{signed:t,size:n}){if("number"==typeof n){const r=2n**(BigInt(n)-(t?1n:0n))-1n,s=t?-r-1n:0n;if(e>r||e<s)throw new Mf({max:r.toString(),min:s.toString(),signed:t,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:gf(e,{size:32,signed:t})}}(n,{signed:e,size:Number(t)})}if(r.type.startsWith("bytes"))return function(e,{type:t}){const[,n]=t.split("bytes"),r=Pf(e);if(!n){let t=e;return r%32!=0&&(t=xf(t,32*Math.ceil((e.length-2)/2/32))),{dynamic:!0,encoded:hf(vf(gf(r,{size:32})),t)}}if(r!==Number.parseInt(n,10))throw new lb({expectedSize:Number.parseInt(n,10),value:e});return{dynamic:!1,encoded:xf(e)}}(n,{type:r.type});if("string"===r.type)return function(e){const t=wf(e),n=Math.ceil(Pf(t)/32),r=[];for(let e=0;e<n;e++)r.push(xf(If(t,32*e,32*(e+1))));return{dynamic:!0,encoded:hf(xf(gf(Pf(t),{size:32})),...r)}}(n);throw new hb(r.type)}function nb(e){let t=0;for(let n=0;n<e.length;n++){const{dynamic:r,encoded:s}=e[n];t+=r?32:Pf(s)}const n=[],r=[];let s=0;for(let i=0;i<e.length;i++){const{dynamic:a,encoded:o}=e[i];a?(n.push(gf(t+s,{size:32})),r.push(o),s+=Pf(o)):n.push(o)}return hf(...n,...r)}const rb={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new ab({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new ib({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new sb({offset:e});const t=this.position-e;this.assertPosition(t),this.position=t},getReadCount(e){return this.positionReadCount.get(e||this.position)||0},incrementPosition(e){if(e<0)throw new sb({offset:e});const t=this.position+e;this.assertPosition(t),this.position=t},inspectByte(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectBytes(e,t){const n=t??this.position;return this.assertPosition(n+e-1),this.bytes.subarray(n,n+e)},inspectUint8(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectUint16(e){const t=e??this.position;return this.assertPosition(t+1),this.dataView.getUint16(t)},inspectUint24(e){const t=e??this.position;return this.assertPosition(t+2),(this.dataView.getUint16(t)<<8)+this.dataView.getUint8(t+2)},inspectUint32(e){const t=e??this.position;return this.assertPosition(t+3),this.dataView.getUint32(t)},pushByte(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushBytes(e){this.assertPosition(this.position+e.length-1),this.bytes.set(e,this.position),this.position+=e.length},pushUint8(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushUint16(e){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,e),this.position+=2},pushUint24(e){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,e>>8),this.dataView.setUint8(this.position+2,255&e),this.position+=3},pushUint32(e){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,e),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const e=this.inspectByte();return this.position++,e},readBytes(e,t){this.assertReadLimit(),this._touch();const n=this.inspectBytes(e);return this.position+=t??e,n},readUint8(){this.assertReadLimit(),this._touch();const e=this.inspectUint8();return this.position+=1,e},readUint16(){this.assertReadLimit(),this._touch();const e=this.inspectUint16();return this.position+=2,e},readUint24(){this.assertReadLimit(),this._touch();const e=this.inspectUint24();return this.position+=3,e},readUint32(){this.assertReadLimit(),this._touch();const e=this.inspectUint32();return this.position+=4,e},get remaining(){return this.bytes.length-this.position},setPosition(e){const t=this.position;return this.assertPosition(e),this.position=e,()=>this.position=t},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const e=this.getReadCount();this.positionReadCount.set(this.position,e+1),e>0&&this.recursiveReadCount++}};class sb extends ul{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.NegativeOffsetError"})}}class ib extends ul{constructor({length:e,position:t}){super(`Position \`${t}\` is out of bounds (\`0 < position < ${e}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.PositionOutOfBoundsError"})}}class ab extends ul{constructor({count:e,limit:t}){super(`Recursive read limit of \`${t}\` exceeded (recursive read count: \`${e}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.RecursiveReadLimitExceededError"})}}function ob(e,t,n){const{checksumAddress:r=!1}=n??{};if(e.length!==t.length)throw new fb({expectedLength:e.length,givenLength:t.length});const s=function({checksumAddress:e,parameters:t,values:n}){const r=[];for(let s=0;s<t.length;s++)r.push(tb({checksumAddress:e,parameter:t[s],value:n[s]}));return r}({checksumAddress:r,parameters:e,values:t}),i=nb(s);return 0===i.length?"0x":i}function cb(e,t){if(e.length!==t.length)throw new fb({expectedLength:e.length,givenLength:t.length});const n=[];for(let r=0;r<e.length;r++){const s=e[r],i=t[r];n.push(cb.encode(s,i))}return hf(...n)}function ub(e){return Array.isArray(e)&&"string"==typeof e[0]||"string"==typeof e?eb(e):e}!function(e){e.encode=function e(t,n,r=!1){if("address"===t){const e=n;return cp(e),vf(e.toLowerCase(),r?32:0)}if("string"===t)return wf(n);if("bytes"===t)return n;if("bool"===t)return vf(yf(n),r?32:1);const s=t.match(Vm);if(s){const[e,t,i="256"]=s,a=Number.parseInt(i,10)/8;return gf(n,{size:r?32:a,signed:"int"===t})}const i=t.match(Gm);if(i){const[e,t]=i;if(Number.parseInt(t,10)!==(n.length-2)/2)throw new lb({expectedSize:Number.parseInt(t,10),value:n});return xf(n,r?32:0)}const a=t.match(Km);if(a&&Array.isArray(n)){const[t,r]=a,s=[];for(let t=0;t<n.length;t++)s.push(e(r,n[t],!0));return 0===s.length?"0x":hf(...s)}throw new hb(t)}}(cb||(cb={}));class db extends ul{constructor({expectedLength:e,givenLength:t,type:n}){super(`Array length mismatch for type \`${n}\`. Expected: \`${e}\`. Given: \`${t}\`.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ArrayLengthMismatchError"})}}class lb extends ul{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${Pf(t)}) does not match expected size (bytes${e}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.BytesSizeMismatchError"})}}class fb extends ul{constructor({expectedLength:e,givenLength:t}){super(["ABI encoding parameters/values length mismatch.",`Expected length (parameters): ${e}`,`Given length (values): ${t}`].join("\n")),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.LengthMismatchError"})}}class pb extends ul{constructor(e){super(`Value \`${e}\` is not a valid array.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidArrayError"})}}class hb extends ul{constructor(e){super(`Type \`${e}\` is not a valid ABI Type.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidTypeError"})}}function mb(e){const{domain:t={},message:n,primaryType:r}=e,s={EIP712Domain:bb(t),...e.types};!function(e){const{domain:t,message:n,primaryType:r,types:s}=e,i=(e,t)=>{for(const n of e){const{name:e,type:r}=n,a=t[e],o=r.match(Vm);if(o&&("number"==typeof a||"bigint"==typeof a)){const[,e,t]=o;gf(a,{signed:"int"===e,size:Number.parseInt(t??"",10)/8})}if("address"===r&&"string"==typeof a&&!pp(a))throw new hp({address:a,cause:new mp});const c=r.match(Gm);if(c){const[,e]=c;if(e&&Pf(a)!==Number.parseInt(e,10))throw new vb({expectedSize:Number.parseInt(e,10),givenSize:Pf(a)})}const u=s[r];u&&(Mb(r),i(u,a))}};if(s.EIP712Domain&&t){if("object"!=typeof t)throw new xb({domain:t});i(s.EIP712Domain,t)}if("EIP712Domain"!==r){if(!s[r])throw new Ib({primaryType:r,types:s});i(s[r],n)}}({domain:t,message:n,primaryType:r,types:s});const i=["0x19","0x01"];return t&&i.push(function(e){const{domain:t,types:n}=e;return wb({data:t,primaryType:"EIP712Domain",types:{...n,EIP712Domain:n?.EIP712Domain||bb(t)}})}({domain:t,types:s})),"EIP712Domain"!==r&&i.push(wb({data:n,primaryType:r,types:s})),hf(...i)}function yb(e){const{primaryType:t,types:n}=e;let r="";const s=kb({primaryType:t,types:n});s.delete(t);const i=[t,...Array.from(s).sort()];for(const e of i)r+=`${e}(${(n[e]??[]).map((({name:e,type:t})=>`${t} ${e}`)).join(",")})`;return r}function bb(e){return["string"==typeof e?.name&&{name:"name",type:"string"},e?.version&&{name:"version",type:"string"},("number"==typeof e?.chainId||"bigint"==typeof e?.chainId)&&{name:"chainId",type:"uint256"},e?.verifyingContract&&{name:"verifyingContract",type:"address"},e?.salt&&{name:"salt",type:"bytes32"}].filter(Boolean)}function gb(e){return Yf(mb(e))}function wb(e){const{data:t,primaryType:n,types:r}=e;return Yf(zb({data:t,primaryType:n,types:r}))}class vb extends ul{constructor({expectedSize:e,givenSize:t}){super(`Expected bytes${e}, got bytes${t}.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"TypedData.BytesSizeMismatchError"})}}class xb extends ul{constructor({domain:e}){super(`Invalid domain "${cl(e)}".`,{metaMessages:["Must be a valid EIP-712 domain."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"TypedData.InvalidDomainError"})}}class Ib extends ul{constructor({primaryType:e,types:t}){super(`Invalid primary type \`${e}\` must be one of \`${JSON.stringify(Object.keys(t))}\`.`,{metaMessages:["Check that the primary type is a key in `types`."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"TypedData.InvalidPrimaryTypeError"})}}class Pb extends ul{constructor({type:e}){super(`Struct type "${e}" is invalid.`,{metaMessages:["Struct type must not be a Solidity type."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"TypedData.InvalidStructTypeError"})}}function zb(e){const{data:t,primaryType:n,types:r}=e,s=[{type:"bytes32"}],i=[Eb({primaryType:n,types:r})];for(const e of r[n]??[]){const[n,a]=Ab({types:r,name:e.name,type:e.type,value:t[e.name]});s.push(n),i.push(a)}return ob(s,i)}function Eb(e){const{primaryType:t,types:n}=e;return Yf(wf(yb({primaryType:t,types:n})))}function Ab(e){let{types:t,name:n,type:r,value:s}=e;if(void 0!==t[r])return[{type:"bytes32"},Yf(zb({data:s,primaryType:r,types:t}))];if("bytes"===r){return s=`0x${(s.length%2?"0":"")+s.slice(2)}`,[{type:"bytes32"},Yf(s,{as:"Hex"})]}if("string"===r)return[{type:"bytes32"},Yf(Bf(s),{as:"Hex"})];if(r.lastIndexOf("]")===r.length-1){const e=r.slice(0,r.lastIndexOf("[")),i=s.map((r=>Ab({name:n,type:e,types:t,value:r})));return[{type:"bytes32"},Yf(ob(i.map((([e])=>e)),i.map((([,e])=>e))))]}return[{type:r},s]}function kb(e,t=new Set){const{primaryType:n,types:r}=e,s=n.match(/^\w*/u),i=s?.[0];if(t.has(i)||void 0===r[i])return t;t.add(i);for(const e of r[i])kb({primaryType:e.type,types:r},t);return t}function Mb(e){if("address"===e||"bool"===e||"string"===e||e.startsWith("bytes")||e.startsWith("uint")||e.startsWith("int"))throw new Pb({type:e})}function $b(e){let t=!0,n="",r=0,s="",i=!1;for(let a=0;a<e.length;a++){const o=e[a];if(["(",")",","].includes(o)&&(t=!0),"("===o&&r++,")"===o&&r--,t)if(0!==r)" "!==o?(s+=o,n+=o):","!==e[a-1]&&","!==n&&",("!==n&&(n="",t=!1);else if(" "===o&&["event","function","error",""].includes(s))s="";else if(s+=o,")"===o){i=!0;break}}if(!i)throw new ul("Unable to normalize signature.");return s}function Ob(e,t){const n=typeof e,r=t.type;switch(r){case"address":return pp(e,{strict:!1});case"bool":return"boolean"===n;case"function":case"string":return"string"===n;default:return"tuple"===r&&"components"in t?Object.values(t.components).every(((t,n)=>Ob(Object.values(e)[n],t))):/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(r)?"number"===n||"bigint"===n:/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(r)?"string"===n||e instanceof Uint8Array:!!/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(r)&&(Array.isArray(e)&&e.every((e=>Ob(e,{...t,type:r.replace(/(\[[0-9]{0,}\])$/,"")}))))}}function jb(e,t,n){for(const r in e){const s=e[r],i=t[r];if("tuple"===s.type&&"tuple"===i.type&&"components"in s&&"components"in i)return jb(s.components,i.components,n[r]);const a=[s.type,i.type];if(!(!a.includes("address")||!a.includes("bytes20"))||(a.includes("address")&&a.includes("string")||!(!a.includes("address")||!a.includes("bytes")))&&pp(n[r],{strict:!1}))return a}}function Sb(e,t,n){const{args:r=[],prepare:s=!0}=n??{},i=kf(t,{strict:!1}),a=e.filter((e=>i?"function"===e.type||"error"===e.type?Nb(e)===If(t,0,4):"event"===e.type&&Tb(e)===t:"name"in e&&e.name===t));if(0===a.length)throw new Rb({name:t});if(1===a.length)return{...a[0],...s?{hash:Tb(a[0])}:{}};let o;for(const e of a){if(!("inputs"in e))continue;if(!r||0===r.length){if(!e.inputs||0===e.inputs.length)return{...e,...s?{hash:Tb(e)}:{}};continue}if(!e.inputs)continue;if(0===e.inputs.length)continue;if(e.inputs.length!==r.length)continue;const t=r.every(((t,n)=>{const r="inputs"in e&&e.inputs[n];return!!r&&Ob(t,r)}));if(t){if(o&&"inputs"in o&&o.inputs){const t=jb(e.inputs,o.inputs,r);if(t)throw new _b({abiItem:e,type:t[0]},{abiItem:o,type:t[1]})}o=e}}const c=(()=>{if(o)return o;const[e,...t]=a;return{...e,overloads:t}})();if(!c)throw new Rb({name:t});return{...c,...s?{hash:Tb(c)}:{}}}function Nb(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return Sb(t,n)}return e[0]})();return If(Tb(t),0,4)}function Tb(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return Sb(t,n)}return e[0]})();return"string"!=typeof t&&"hash"in t&&t.hash?t.hash:Yf(wf(function(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return Sb(t,n)}return e[0]})();return $b("string"==typeof t?t:hy(t))}(t)))}class _b extends ul{constructor(e,t){super("Found ambiguous types in overloaded ABI Items.",{metaMessages:[`\`${e.type}\` in \`${$b(hy(e.abiItem))}\`, and`,`\`${t.type}\` in \`${$b(hy(t.abiItem))}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiItem.AmbiguityError"})}}class Rb extends ul{constructor({name:e,data:t,type:n="item"}){super(`ABI ${n}${e?` with name "${e}"`:t?` with data "${t}"`:""} not found.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiItem.NotFoundError"})}}function Cb(...e){const[t,n=[]]=(()=>{if(Array.isArray(e[0])){const[t,n,r]=e;return[Bb(t,n,{args:r}),r]}const[t,n]=e;return[t,n]})(),{overloads:r}=t,s=r?Bb([t,...r],t.name,{args:n}):t,i=Db(s),a=n.length>0?ob(s.inputs,n):void 0;return a?hf(i,a):i}function Bb(e,t,n){const r=Sb(e,t,n);if("function"!==r.type)throw new Rb({name:t,type:"function"});return r}function Db(e){return Nb(e)}const Ub=yu(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),qb=Fu({a:Ub.create(BigInt("-3")),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Fp:Ub,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},Es),Lb=yu(BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"));Fu({a:Lb.create(BigInt("-3")),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Fp:Lb,n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f"),h:BigInt(1),lowS:!1},ks);const Fb=yu(BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"));Fu({a:Fb.create(BigInt("-3")),b:BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),Fp:Fb,n:BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),Gx:BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650"),h:BigInt(1),lowS:!1,allowedPrivateKeyLengths:[130,131,132]},As);const Kb=qb,Gb=qb;function Vb(e){const{privateKey:t}=e;return Xf(Gb.ProjectivePoint.fromPrivateKey("string"==typeof t?t.slice(2):bf(t).slice(2)))}function Zb(e={}){const{as:t="Hex"}=e,n=Gb.utils.randomPrivateKey();return"Hex"===t?bf(n):n}function Hb(e){const{extraEntropy:t=qm,hash:n,payload:r,privateKey:s}=e,{r:i,s:a,recovery:o}=Gb.sign(r instanceof Uint8Array?r:Cf(r),s instanceof Uint8Array?s:Cf(s),{extraEntropy:"boolean"==typeof t?t:mf(t).slice(2),lowS:!0,...n?{prehash:!0}:{}});return{r:i,s:a,yParity:o}}function Wb(e,t=0){if(!/^(-?)([0-9]*)\.?([0-9]*)$/.test(e))throw new Yb({value:e});let[n="",r="0"]=e.split(".");const s=n.startsWith("-");if(s&&(n=n.slice(1)),r=r.replace(/(0+)$/,""),0===t)1===Math.round(Number(`.${r}`))&&(n=`${BigInt(n)+1n}`),r="";else if(r.length>t){const[e,s,i]=[r.slice(0,t-1),r.slice(t-1,t),r.slice(t)],a=Math.round(Number(`${s}.${i}`));r=a>9?`${BigInt(e)+BigInt(1)}0`.padStart(e.length+1,"0"):`${e}${a}`,r.length>t&&(r=r.slice(1),n=`${BigInt(n)+1n}`),r=r.slice(0,t)}else r=r.padEnd(t,"0");return BigInt(`${s?"-":""}${n}${r}`)}class Yb extends ul{constructor({value:e}){super(`Value \`${e}\` is not a valid decimal number.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Value.InvalidDecimalNumberError"})}}const Qb=new TextEncoder,Jb=new TextDecoder,Xb=Object.fromEntries(Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").map(((e,t)=>[t,e.charCodeAt(0)]))),eg={...Object.fromEntries(Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").map(((e,t)=>[e.charCodeAt(0),t]))),["=".charCodeAt(0)]:0,["-".charCodeAt(0)]:62,["_".charCodeAt(0)]:63};function tg(e,t={}){return function(e,t={}){const{pad:n=!0,url:r=!1}=t,s=new Uint8Array(4*Math.ceil(e.length/3));for(let t=0,n=0;n<e.length;t+=4,n+=3){const r=(e[n]<<16)+(e[n+1]<<8)+(0|e[n+2]);s[t]=Xb[r>>18],s[t+1]=Xb[r>>12&63],s[t+2]=Xb[r>>6&63],s[t+3]=Xb[63&r]}const i=e.length%3,a=4*Math.floor(e.length/3)+(i&&i+1);let o=Jb.decode(new Uint8Array(s.buffer,0,a));return n&&1===i&&(o+="=="),n&&2===i&&(o+="="),r&&(o=o.replaceAll("+","-").replaceAll("/","_")),o}(Cf(e),t)}function ng(e){const t=e.replace(/=+$/,""),n=t.length,r=new Uint8Array(n+3);Qb.encodeInto(t+"===",r);for(let e=0,n=0;e<t.length;e+=4,n+=3){const t=(eg[r[e]]<<18)+(eg[r[e+1]]<<12)+(eg[r[e+2]]<<6)+eg[r[e+3]];r[n]=t>>16,r[n+1]=t>>8&255,r[n+2]=255&t}const s=3*(n>>2)+(n%4&&n%4-1);return new Uint8Array(r.buffer,0,s)}const rg=Uint8Array.from([105,171,180,181,160,222,75,198,42,42,32,31,141,37,186,233]);async function sg(e){const{createFn:t=window.navigator.credentials.create.bind(window.navigator.credentials),...n}=e,r=function(e){const{attestation:t="none",authenticatorSelection:n={residentKey:"preferred",requireResidentKey:!1,userVerification:"required"},challenge:r=rg,excludeCredentialIds:s,extensions:i,name:a,rp:o={id:window.location.hostname,name:window.document.title},user:c}=e,u=c?.name??a;return{publicKey:{attestation:t,authenticatorSelection:n,challenge:"string"==typeof r?Cf(r):r,...s?{excludeCredentials:s?.map((e=>({id:ng(e),type:"public-key"})))}:{},pubKeyCredParams:[{type:"public-key",alg:-7}],...i&&{extensions:i},rp:o,user:{id:c?.id??Yf(Bf(u),{as:"Bytes"}),name:u,displayName:c?.displayName??u}}}}(n);try{const e=await t(r);if(!e)throw new og;const n=e.response,s=await async function(e){try{const t=e.getPublicKey();if(!t)throw new og;const n=new Uint8Array(t),r=await crypto.subtle.importKey("spki",new Uint8Array(n),{name:"ECDSA",namedCurve:"P-256",hash:"SHA-256"},!0,["verify"]);return Xf(new Uint8Array(await crypto.subtle.exportKey("raw",r)))}catch(t){if("Permission denied to access object"!==t.message)throw t;const n=new Uint8Array(e.attestationObject),r=32,s=88,i=e=>{const t=new Uint8Array([e,s,r]);for(let e=0;e<n.length-t.length;e++)if(t.every(((t,r)=>n[e+r]===t)))return e+t.length;throw new og},a=i(33),o=i(34);return Xf(new Uint8Array([4,...n.slice(a,a+r),...n.slice(o,o+r)]))}}(n);return{id:e.id,publicKey:s,raw:e}}catch(e){throw new og({cause:e})}}function ig(e){const{challenge:t,crossOrigin:n,extraClientData:r,flag:s,origin:i,rpId:a,signCount:o,userVerification:c="required"}=e,u=function(e={}){const{flag:t=5,rpId:n=window.location.hostname,signCount:r=0}=e;return hf(Qf(wf(n)),gf(t,{size:1}),gf(r,{size:4}))}({flag:s,rpId:a,signCount:o}),d=function(e){const{challenge:t,crossOrigin:n=!1,extraClientData:r,origin:s=window.location.origin}=e;return JSON.stringify({type:"webauthn.get",challenge:tg(t,{url:!0,pad:!1}),origin:s,crossOrigin:n,...r})}({challenge:t,crossOrigin:n,extraClientData:r,origin:i}),l=Qf(wf(d)),f=d.indexOf('"challenge"'),p=d.indexOf('"type"');return{metadata:{authenticatorData:u,clientDataJSON:d,challengeIndex:f,typeIndex:p,userVerificationRequired:"required"===c},payload:hf(u,l)}}async function ag(e){const{getFn:t=window.navigator.credentials.get.bind(window.navigator.credentials),...n}=e,r=function(e){const{credentialId:t,challenge:n,extensions:r,rpId:s=window.location.hostname,userVerification:i="required"}=e;return{publicKey:{...t?{allowCredentials:Array.isArray(t)?t.map((e=>({id:ng(e),type:"public-key"}))):[{id:ng(t),type:"public-key"}]}:{},challenge:Cf(n),...r&&{extensions:r},rpId:s,userVerification:i}}}(n);try{const e=await t(r);if(!e)throw new cg;const n=e.response,s=String.fromCharCode(...new Uint8Array(n.clientDataJSON)),i=s.indexOf('"challenge"'),a=s.indexOf('"type"'),o=function(e){const t=0===e[4]?5:4,n=t+32,r=0===e[n+2]?n+3:n+2,s=BigInt(bf(e.slice(t,n))),i=BigInt(bf(e.slice(r)));return{r:s,s:i>Kb.CURVE.n/2n?Kb.CURVE.n-i:i}}(new Uint8Array(n.signature));return{metadata:{authenticatorData:bf(new Uint8Array(n.authenticatorData)),clientDataJSON:s,challengeIndex:i,typeIndex:a,userVerificationRequired:"required"===r.publicKey.userVerification},signature:o,raw:e}}catch(e){throw new cg({cause:e})}}class og extends ul{constructor({cause:e}={}){super("Failed to create credential.",{cause:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"WebAuthnP256.CredentialCreationFailedError"})}}class cg extends ul{constructor({cause:e}={}){super("Failed to request credential.",{cause:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"WebAuthnP256.CredentialRequestFailedError"})}}const ug="0x3232323232323232323232323232323232323232",dg="0x32323232",lg={p256:"p256",secp256k1:"secp256k1",webauthnp256:"webauthn-p256"},fg={admin:"admin",normal:"session"},pg={0:"minute",1:"hour",2:"day",3:"week",4:"month",5:"year"},hg={address:"secp256k1",p256:"p256",secp256k1:"secp256k1","webauthn-p256":"webauthnp256"},mg={admin:"admin",session:"normal"},yg={address:2,p256:0,secp256k1:2,"webauthn-p256":1},bg={day:2,hour:1,minute:0,month:4,week:3,year:5};function gg(e={}){return function(e){const{chainId:t,expiry:n,feeToken:r,permissions:s,privateKey:i,role:a}=e,o=tp(Vb({privateKey:i}),{includePrefix:!1});return Ig({chainId:t,expiry:n,feeToken:r,permissions:s,privateKey:()=>i,publicKey:o,role:a,type:"p256"})}({...e,privateKey:Zb()})}async function wg(e){const{createFn:t,label:n,rpId:r,userId:s}=e,i=await sg({authenticatorSelection:{requireResidentKey:!0,residentKey:"required",userVerification:"required"},createFn:t,extensions:{credProps:!0},rp:r?{id:r,name:r}:void 0,user:{displayName:n,id:new Uint8Array(s??Bf(n)),name:n}});return Pg({...e,credential:{id:i.id,publicKey:i.publicKey},id:s?Lf(s):tp(i.publicKey,{includePrefix:!1})})}function vg(e={}){return function(e){const{privateKey:t}=e,n=tp(Vb({privateKey:t}),{includePrefix:!1});return Ig({chainId:e.chainId,expiry:e.expiry??0,feeToken:e.feeToken,permissions:e.permissions,privateKey:{privateKey:()=>t},publicKey:n,role:e.role,type:"webauthn-p256"})}({...e,privateKey:Zb()})}async function xg(e={}){return function(e){const{chainId:t,expiry:n,feeToken:r,keyPair:s,permissions:i,role:a}=e,{privateKey:o}=s,c=tp(s.publicKey,{includePrefix:!1});return Ig({chainId:t,expiry:n,feeToken:r,permissions:i,prehash:!0,privateKey:o,publicKey:c,role:a,type:"p256"})}({...e,keyPair:await async function(e={}){const{extractable:t=!1}=e,n=await globalThis.crypto.subtle.generateKey({name:"ECDSA",namedCurve:"P-256"},t,["sign","verify"]),r=await globalThis.crypto.subtle.exportKey("raw",n.publicKey),s=Xf(new Uint8Array(r));return{privateKey:n.privateKey,publicKey:s}}()})}function Ig(e,t={}){const{chainId:n=e.chainId}=t,{expiry:r=0,id:s,prehash:i=!1,role:a="admin",type:o}=e,c=(()=>{const t=e.publicKey;if("0x"===t)return t;if("secp256k1"===o||"address"===o){return 20===Pf(t)||0n===Ef(If(t,0,12))?If(t,-20):lp(ep(t))}return t})();return{...e,chainId:n,expiry:r,hash:zg({publicKey:c,type:o}),id:(s??c).toLowerCase(),prehash:i,publicKey:c.toLowerCase(),role:a,type:o}}function Pg(e){const{credential:t,id:n,rpId:r}=e,s=tp(t.publicKey,{includePrefix:!1});return Ig({chainId:e.chainId,expiry:e.expiry??0,feeToken:e.feeToken,id:n,permissions:e.permissions,privateKey:{credential:t,rpId:r},publicKey:s,role:e.role,type:"webauthn-p256"})}function zg(e){const{type:t}=e,n=Eg(e.publicKey);return Yf(ob([{type:"uint8"},{type:"bytes32"}],[yg[t],Yf(n)]))}function Eg(e){return Pf(e)<32?vf(e,32):e}async function Ag(e,t){const{address:n,storage:r,webAuthn:s,wrap:i=!0}=t,{privateKey:a,publicKey:o,type:c}=e;if(!a)throw new Error("Key does not have a private key to sign with.\n\nKey:\n"+cl(e,null,2));const u=n?gb({domain:{verifyingContract:n},message:{digest:t.payload},primaryType:"ERC1271Sign",types:{ERC1271Sign:[{name:"digest",type:"bytes32"}]}}):t.payload,[d,l]=await(async()=>{if("p256"===c){const{privateKey:t}=e;if("function"==typeof t)return[Qm(Hb({payload:u,privateKey:t()})),!1];if(t instanceof CryptoKey){const e=Qm(await async function(e){const{payload:t,privateKey:n}=e,r=await globalThis.crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},n,_f(t)),s=Rf(new Uint8Array(r)),i=qf(Uf(s,0,32));let a=qf(Uf(s,32,64));return a>Kb.CURVE.n/2n&&(a=Kb.CURVE.n-a),{r:i,s:a}}({payload:u,privateKey:t}));return[e,!0]}}if("secp256k1"===c)return[Qm(Fm({payload:u,privateKey:a()})),!1];if("webauthn-p256"===c){if(a.privateKey){const{payload:e,metadata:t}=ig({challenge:u,origin:"https://ithaca.xyz",rpId:"ithaca.xyz"}),{r:n,s:r}=Hb({hash:!0,payload:e,privateKey:a.privateKey()});return[$g({metadata:t,signature:{r:n,s:r}}),!1]}const{credential:t,rpId:n}=a,i=`porto.webauthnVerified.${e.hash}`,o=Date.now(),c=6e5;let d=!0;if(r){const e=await r.getItem(i);d=!e||o-e>c}const{signature:{r:l,s:f},raw:p,metadata:h}=await ag({challenge:u,credentialId:t.id,getFn:s?.getFn,rpId:n,userVerification:d?"required":"preferred"}),m=p.response;if(!m?.userHandle)throw new Error("No user handle in response",{cause:{response:m}});const y=Lf(new Uint8Array(m.userHandle));if(e.id&&pp(e.id)&&!fp(e.id,y))throw new Error(`supplied webauthn key "${e.id}" does not match signature webauthn key "${y}"`,{cause:{id:y,key:e}});d&&r&&await r.setItem(i,o);return[$g({metadata:h,signature:{r:l,s:f}}),!1]}throw new Error(`Key type "${c}" is not supported.\n\nKey:\n`+cl(e,null,2))})();return i?Og(d,{keyType:c,prehash:l,publicKey:o}):d}function kg(e,t={}){const{expiry:n=0,prehash:r=!1,publicKey:s,role:i="admin",type:a}=e,{feeTokens:o,orchestrator:c}=t,u=Object.entries(Mg(e,{feeTokens:o})).map((([e,t])=>{if("calls"===e){return t.map((({signature:e,to:t})=>({selector:e?kf(e)?e:Db(e):dg,to:t??ug,type:"call"})))}if("feeToken"!==e){if("spend"===e){return t.map((({limit:e,period:t,token:n})=>({limit:e,period:t,token:n,type:"spend"})))}throw new Error(`Invalid permission type "${e}".`)}})).flat().filter(Boolean);return"session"===e.role&&c&&u.push({selector:dg,to:c,type:"call"}),{expiry:n,permissions:u??[],prehash:r,publicKey:Eg(s),role:mg[i],type:hg[a]}}function Mg(e,t){const{permissions:n}=e,r=n?.calls?[...n.calls]:[],s=n?.spend?[...n.spend]:[],i=t.feeTokens?.filter((e=>e.feeToken));if(i&&i.length>0){const t=function(e,t){const{feeTokens:n}=t;if(!e.feeToken)return;const r=n.find((t=>e.feeToken.symbol===t.symbol||(e.feeToken.symbol?"native"===e.feeToken.symbol&&t.address===Fd:t.address===Fd)));if(!r)return;const s=Wb(e.feeToken.limit,r.decimals);return{...r,value:s}}(e,{feeTokens:i});if(t){let e=-1,n=bg.year;for(let r=0;r<s.length;r++){const i=s[r];if(i.token&&fp(t.address,i.token)){e=r;break}if(!i.token&&t.address===Fd){e=r;break}const a=bg[i.period];a<n&&(n=a)}-1!==e?(s[e]={...s[e],limit:s[e].limit+t.value},s.unshift(s.splice(e,1)[0])):"number"==typeof n&&s.unshift({limit:t.value,period:pg[n],token:t.address})}}return{...n,calls:r,spend:s}}function $g(e){const{metadata:t,signature:n}=e;return ob(ub(["struct WebAuthnAuth { bytes authenticatorData; string clientDataJSON; uint256 challengeIndex; uint256 typeIndex; bytes32 r; bytes32 s; }","WebAuthnAuth auth"]),[{authenticatorData:t.authenticatorData,challengeIndex:BigInt(t.challengeIndex),clientDataJSON:t.clientDataJSON,r:gf(n.r,{size:32}),s:gf(n.s,{size:32}),typeIndex:BigInt(t.typeIndex)}])}function Og(e,t){const{keyType:n,prehash:r=!1,publicKey:s}=t;return cb(["bytes","bytes32","bool"],[e,zg({publicKey:s,type:n}),r])}function jg(e){const t="string"==typeof e?{address:e}:e,n=t.sign?"privateKey":"porto",{address:r,sign:s,signMessage:i,signTransaction:a,signTypedData:o,type:c}=function(e){if("string"==typeof e){if(!Vt(e,{strict:!1}))throw new Dt({address:e});return{address:e,type:"json-rpc"}}if(!Vt(e.address,{strict:!1}))throw new Dt({address:e.address});return{address:e.address,nonceManager:e.nonceManager,sign:e.sign,signAuthorization:e.signAuthorization,signMessage:e.signMessage,signTransaction:e.signTransaction,signTypedData:e.signTypedData,source:"custom",type:"local"}}({address:t.address,sign({hash:e}){if("privateKey"===n)return t.sign({hash:e});throw new Error("`sign` not supported on porto accounts.")},signMessage({message:e}){return this.sign({hash:co(e)})},signTransaction(){throw new Error("`signTransaction` not supported on porto accounts.")},signTypedData(e){return this.sign({hash:mo(e)})}});return{address:r,keys:t.keys??void 0,sign:s,signMessage:i,signTransaction:a,signTypedData:o,source:n,type:c}}function Sg(e,t={}){const{keys:n}=t,r=lp(function(e){const{privateKey:t}=e;return Xf(rd.ProjectivePoint.fromPrivateKey(mf(t).slice(2)))}({privateKey:e}));return jg({address:r,keys:n,sign:async({hash:t})=>Qm(Fm({payload:t,privateKey:e})),source:"privateKey"})}function Ng(e,t={}){const{key:n,role:r}=t;if(null!==n)return"object"==typeof n?n:e.keys&&e.keys.length>0?"number"==typeof n?e.keys[n]:e.keys.find((e=>e.privateKey&&(!r||e.role===r))):void 0}async function Tg(e,t){const{storage:n,replaySafe:r=!0,wrap:s=!0,webAuthn:i}=t,a=Ng(e,t),o=r?gb({domain:{verifyingContract:e.address},message:{digest:t.payload},primaryType:"ERC1271Sign",types:{ERC1271Sign:[{name:"digest",type:"bytes32"}]}}):t.payload,c=a?({hash:e})=>Ag(a,{address:null,payload:e,storage:n,webAuthn:i,wrap:s}):"privateKey"===e.source?e.sign:void 0;if(!c)throw new Error("cannot find key to sign with.");return await c({hash:o})}function _g(e,t={}){return function(e,t={}){const{prepare:n=!0}=t,r=Array.isArray(e)||"string"==typeof e?Xy(e):e;return{...r,...n?{hash:Tb(r)}:{}}}(e,t)}const Rg=_g({inputs:[{name:"message",type:"string"}],name:"Error",type:"error"}),Cg="0x08c379a0",Bg=_g({inputs:[{name:"reason",type:"uint8"}],name:"Panic",type:"error"}),Dg="0x4e487b71";class Ug extends J{constructor(){super("Function is not recognized.",{metaMessages:["This could be due to any of the following:"," - The contract does not have the function,"," - The address is not a contract."],name:"FunctionSelectorNotRecognizedError"})}}function qg(e,t={}){return function(e,t={}){const{prepare:n=!0}=t,r=Array.isArray(e)||"string"==typeof e?pc(e):e;return{...r,...n?{hash:Ld(r)}:{}}}(e,t)}function Lg(e){return function(e){return Qi(Ld(e),0,4)}(e)}const Fg=()=>Um(["0x",Yh()],{message:"Needs string in format ^0x[A-Fa-f0-9]{40}$."}),Kg=()=>Um(["0x",Yh()],{message:"Needs string in format ^0x[A-Fa-f0-9]+$."}),Gg=()=>Rm(Kg(),Jh(),{decode:e=>Af(e),encode:e=>gf(e)}),Vg=()=>Rm(Kg(),nm({message:"Required bigint"}),{decode:e=>Ef(e),encode:e=>gf(e)});function Zg(e){return xm(e)}class Hg extends ul{constructor(){super(...arguments),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Schema.ValidationError"})}}function Wg(e){const t=e;let n=`Validation failed with ${t.issues.length} error${1===t.issues.length?"":"s"}:`;n+="\n";for(const e of t.issues)e&&(n+="\n",n+=Yg(e));return new Hg(n)}function Yg(e,t=0){const n=function(e){return 0===e.length?"":"at `"+e.map(((e,t)=>"number"==typeof e?`[${e}]`:"symbol"==typeof e?`[${e.toString()}]`:/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)&&t>0?`.${e}`:0===t&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)?e:`["${e}"]`)).join("")+"`"}(e.path),r="- "+(n?`${n}: `:""),s=" ".repeat(t+1);let i=r;switch(e.code){case"invalid_type":{const t=e.expected,n=e.input?function(e){const t=e.input;if(void 0===t)return"undefined";if(null===t)return"null";const n=typeof t;if("object"===n)return Array.isArray(t)?"array":t instanceof Date?"date":t instanceof Map?"map":t instanceof Set?"set":"object";return n}(e):"undefined";i+=`Expected ${t}. ${"Invalid input"!==e.message?e.message:""}`,"undefined"!==n&&(i+=`but received ${n}`);break}case"too_big":{const t=e.maximum,n=e.inclusive??!0,r=e.exact??!1;i+=r?`${e.origin} must be exactly ${t}`:`${e.origin} must be ${n?"at most":"less than"} ${t}`;break}case"too_small":{const t=e.minimum,n=e.inclusive??!0,r=e.exact??!1;i+=r?`${e.origin} must be exactly ${t}`:`${e.origin} must be ${n?"at least":"greater than"} ${t}`;break}case"invalid_format":switch(e.format){case"regex":case"template_literal":i+=`Must match pattern: ${e.pattern}`;break;case"starts_with":i+=`Must start with "${e.prefix}"`;break;case"ends_with":i+=`Must end with "${e.suffix}"`;break;case"includes":i+=`Must include "${e.includes}"`;break;default:i+=`Invalid ${e.format} format`}break;case"not_multiple_of":i+=`Number must be a multiple of ${e.divisor}`;break;case"unrecognized_keys":{const t=e.keys.map((e=>`"${e}"`)).join(", ");i+=`Unrecognized key${e.keys.length>1?"s":""}: ${t}`;break}case"invalid_union":{const n=e.errors&&e.errors.length>0;i+="Invalid union value.",n&&e.errors.forEach((e=>{e.length>0&&e.forEach((e=>{i+="\n",i+=s,i+=Yg(e,t+1)}))}));break}case"invalid_key":i+=`Invalid ${e.origin} key`,e.issues&&e.issues.length>0&&e.issues.forEach((e=>{i+="\n",i+=s,i+=Yg(e,t+1)}));break;case"invalid_element":i+=`Invalid ${e.origin} element at key "${e.key}"`,e.issues&&e.issues.length>0&&e.issues.forEach((e=>{i+="\n",i+=s,i+=Yg(e,t+1)}));break;case"invalid_value":{const t=e.values.map((e=>JSON.stringify(e))).join(", ");e.values.length>1?i+=`Expected one of: ${t}`:i+=`Expected ${t}`;break}case"custom":i+=e.message||"Custom validation failed";break;default:i+=e.message||"Validation failed"}return i}const Qg=ym({selector:Kg(),to:Fg(),type:Mm("call")}),Jg=ym({limit:Vg(),period:xm([Mm("minute"),Mm("hour"),Mm("day"),Mm("week"),Mm("month"),Mm("year")]),token:Om(xm([Fg(),am()])),type:Mm("spend")}),Xg=xm([Qg,Jg]),ew=ym({expiry:Gg(),prehash:Om(em()),publicKey:Kg(),role:xm([Mm("admin"),Mm("normal")]),type:xm([Mm("p256"),Mm("secp256k1"),Mm("webauthnp256")])}),tw=ym({...ew.shape,permissions:Bm(hm(Xg))});var nw,rw,sw,iw,aw,ow;!function(e){e.AssetDiffAsset=xm([ym({address:Om(xm([Fg(),am()])),decimals:Om(xm([Jh(),am()])),direction:xm([Mm("incoming"),Mm("outgoing")]),fiat:Om(ym({currency:Yh(),value:Rm(Yh(),Jh(),{decode:e=>Number(e),encode:e=>String(e)})})),name:Om(xm([Yh(),am()])),symbol:Yh(),type:Mm("erc20"),value:Vg()}),ym({address:Om(xm([Fg(),am()])),direction:xm([Mm("incoming"),Mm("outgoing")]),fiat:Om(ym({currency:Yh(),value:Rm(Yh(),Jh(),{decode:e=>Number(e),encode:e=>String(e)})})),name:Om(xm([Yh(),am()])),symbol:Yh(),type:Mm("erc721"),uri:Yh(),value:Vg()}),ym({address:am(),decimals:Om(xm([Jh(),am()])),direction:xm([Mm("incoming"),Mm("outgoing")]),fiat:Om(ym({currency:Yh(),value:Rm(Yh(),Jh(),{decode:e=>Number(e),encode:e=>String(e)})})),symbol:Yh(),type:am(),value:Vg()})]),e.Response=Am(Kg(),Bm(hm(Bm(zm([Fg(),Bm(hm(e.AssetDiffAsset))])))))}(nw||(nw={})),function(e){e.Request=Bm(hm(tw)),e.Response=Bm(hm(ym({...tw.shape,hash:Kg()})))}(rw||(rw={})),function(e){e.Response=Am(Kg(),ym({currency:Yh(),value:Yh()}))}(sw||(sw={})),function(e){e.Request=ym({feePayer:Om(Fg()),feeToken:Om(Fg()),nonce:Om(Vg())})}(iw||(iw={})),(aw||(aw={})).Request=Bm(hm(ym({address:Fg(),value:Vg()}))),function(e){e.Request=Bm(hm(ym({hash:Kg()}))),e.Response=Bm(hm(ym({hash:Kg()})))}(ow||(ow={}));const cw=ym({eoa:Fg(),executionData:Kg(),nonce:Kg(),signature:Kg()}),uw=ym({...cw.shape,chainId:Gg()}),dw=xm([ym({combinedGas:Vg(),encodedFundTransfers:Bm(hm(Kg())),encodedPreCalls:Bm(hm(Kg())),eoa:Fg(),executionData:Kg(),expiry:Vg(),funder:Fg(),funderSignature:Kg(),isMultichain:em(),nonce:Vg(),payer:Fg(),paymentAmount:Vg(),paymentMaxAmount:Vg(),paymentRecipient:Fg(),paymentSignature:Kg(),paymentToken:Fg(),settler:Fg(),settlerContext:Kg(),signature:Kg(),supportedAccountImplementation:Fg()}),ym({combinedGas:Vg(),encodedFundTransfers:Bm(hm(Kg())),encodedPreCalls:Bm(hm(Kg())),eoa:Fg(),executionData:Kg(),expiry:Vg(),funder:Fg(),funderSignature:Kg(),isMultichain:em(),nonce:Vg(),payer:Fg(),paymentRecipient:Fg(),paymentSignature:Kg(),paymentToken:Fg(),prePaymentAmount:Vg(),prePaymentMaxAmount:Vg(),settler:Fg(),settlerContext:Kg(),signature:Kg(),supportedAccountImplementation:Fg(),totalPaymentAmount:Vg(),totalPaymentMaxAmount:Vg()})]);ym({eoa:Fg(),executionData:Kg(),nonce:Vg()});const lw=ym({address:xm([Fg(),am()]),decimals:Om(Jh()),deficit:Vg(),fiat:Om(ym({currency:Yh(),value:Yh()})),name:Om(Yh()),required:Vg(),symbol:Om(Yh())}),fw=ym({additionalAuthorization:Nm(ym({address:Fg(),chainId:Gg(),nonce:Gg(),r:Kg(),s:Kg(),yParity:Gg()})),assetDeficits:Om(hm(lw)),authorizationAddress:Om(xm([Fg(),am()])),chainId:Gg(),ethPrice:Vg(),extraPayment:Vg(),feeTokenDeficit:Vg(),intent:dw,nativeFeeEstimate:ym({maxFeePerGas:Vg(),maxPriorityFeePerGas:Vg()}),orchestrator:Fg(),paymentTokenDecimals:Jh(),txGas:Vg()}),pw=ym({multiChainRoot:Om(xm([Kg(),am()])),quotes:Bm(hm(fw)).check(Vh(1)),ttl:Jh()}),hw=ym({...pw.shape,hash:Kg(),r:Kg(),s:Kg(),v:Om(Kg()),yParity:Om(Kg())}),mw=ym({address:Fg(),decimals:Jh(),feeToken:Om(em()),interop:Om(em()),nativeRate:Om(Vg()),symbol:Yh(),uid:Yh()}),yw=Yh().check(Zh(/^[A-Z0-9]+$/)),bw=ym({address:Fg(),chainId:Gg(),nonce:Gg()}),gw=ym({...bw.shape,r:Kg(),s:Kg(),yParity:Gg()}),ww=ym({data:Om(Kg()),to:Fg(),value:Om(Vg())});var vw,xw,Iw,Pw,zw,Ew,Aw,kw,Mw,$w,Ow,jw,Sw,Nw,Tw,_w,Rw,Cw,Bw,Dw,Uw;async function qw(e,t={}){const n=t.chainId?[t.chainId]:"all"!==t.chainIds?t.chainIds?t.chainIds:[e.chain.id]:void 0;try{const r="wallet_getCapabilities",s=await Na((()=>e.request({method:r,params:n?[n]:void 0},{retryCount:0})),{cacheKey:`${e.uid}.${r}.${n?.join(",")}`}),i=t.raw?s:Jp(jw.Response,s);return t.chainIds?i:Object.values(i)[0]}catch(e){throw Vw(e),e}}async function Lw(e,t){const{address:n,capabilities:r,chain:s=e.chain,key:i}=t,a=t.calls.map((e=>({data:e.abi?Cb(Bb(e.abi,e.functionName),e.args):e.data??"0x",to:e.to,value:e.value??0n})));try{const t="wallet_prepareCalls",o=await e.request({method:t,params:[Yp(_w.Parameters,{calls:a,capabilities:{...r,meta:{...r?.meta}},chainId:s?.id,from:n,key:i?{prehash:i.prehash,publicKey:i.publicKey,type:i.type}:void 0})]},{retryCount:0});return Object.assign(Jp(_w.Response,o),{_raw:o})}catch(e){throw Vw(e),Kw(e,{calls:t.calls}),e}}async function Fw(e,t){const{signature:n}=t,{signature:r,capabilities:{feeSignature:s,...i},...a}=t.response,o=Gw({capabilities:i,...a}),c=Lm({payload:Yf(wf(JSON.stringify(o))),signature:Wm(n)}),{quoteSigner:u}=await async function(e){const t="health",n=await Na((()=>e.request({method:t})),{cacheKey:`${e.uid}.${t}`});return Jp(kw.Response,n)}(e);return c===u}function Kw(e,{calls:t}={}){if(!(e instanceof J))return;const n=function(e,t){const n=e.walk((e=>"data"in e));if(!n?.data)return e;if(n.data===Lg(qg("error FnSelectorNotRecognized()")))return new Ug;let r=null;for(const e of t.calls){const t=e;if(t.abi)try{if(!Boolean(On({abi:t.abi,data:n.data})))continue;r=t}catch{}}return r?jr(n,{abi:r.abi,address:r.to,args:r.args,functionName:r.functionName}):e}(e,{calls:t??[]}),r=(e=>{try{if("ContractFunctionExecutionError"===e.name){const t="ContractFunctionRevertedError"===e.cause.name?e.cause.data:void 0;if(t)return function(e,t,n){if("Error"===t)return Rg;if("Panic"===t)return Bg;if(kf(t,{strict:!1})){const e=If(t,0,4);if(e===Cg)return Rg;if(e===Dg)return Bg}const r=Sb(e,t,n);if("error"!==r.type)throw new Rb({name:t,type:"error"});return r}([t.abiItem],t.errorName)}const t=e.walk((e=>!(e instanceof Error)&&3===e.code));if(!t)return;const{data:n,message:r}=t;return"0xd0d5039b"===n?_g("error Unauthorized()"):{inputs:[],name:(r??n).split("(")[0],type:"error"}}catch{return}})(n);if(n!==e||r)throw new Zw(Object.assign(n,{abiError:r}))}function Gw(e){if("object"==typeof e&&null!==e){if(Array.isArray(e))return e.map(Gw);const t={};for(const n of Object.keys(e).sort())t[n]=Gw(e[n]);return t}return e}function Vw(e){if("$ZodError"===e.name)throw Wg(e)}!function(e){e.Parameters=ym({address:Fg(),secret:Yh()}),e.Request=ym({method:Mm("account_getOnrampContactInfo"),params:Bm(zm([e.Parameters]))}),e.Response=ym({email:Om(Yh()),phone:Om(Yh()),phoneVerifiedAt:Om(Jh())})}(vw||(vw={})),function(e){e.Parameters=ym({address:Fg()}),e.Request=ym({method:Mm("account_onrampStatus"),params:Bm(zm([e.Parameters]))}),e.Response=ym({email:Om(Jh()),phone:Om(Jh())})}(xw||(xw={})),function(e){e.Parameters=ym({phone:Yh(),walletAddress:Fg()}),e.Request=ym({method:Mm("account_resendVerifyPhone"),params:Bm(zm([e.Parameters]))}),e.Response=am()}(Iw||(Iw={})),function(e){e.Parameters=ym({email:Yh().check(Zh(/^.*@.*$/)),walletAddress:Fg()}),e.Request=ym({method:Mm("account_setEmail"),params:Bm(zm([e.Parameters]))}),e.Response=am()}(Pw||(Pw={})),function(e){e.Parameters=ym({phone:Yh(),walletAddress:Fg()}),e.Request=ym({method:Mm("account_setPhone"),params:Bm(zm([e.Parameters]))}),e.Response=am()}(zw||(zw={})),function(e){e.Parameters=ym({chainId:Gg(),email:Yh(),signature:Kg(),token:Yh(),walletAddress:Fg()}),e.Request=ym({method:Mm("account_verifyEmail"),params:Bm(zm([e.Parameters]))}),e.Response=am()}(Ew||(Ew={})),function(e){e.Parameters=ym({code:Yh(),phone:Yh(),walletAddress:Fg()}),e.Request=ym({method:Mm("account_verifyPhone"),params:Bm(zm([e.Parameters]))}),e.Response=am()}(Aw||(Aw={})),function(e){e.Request=ym({method:Mm("health"),params:sm()}),e.Response=ym({quoteSigner:Fg(),status:Yh(),version:Yh()})}(kw||(kw={})),function(e){e.Parameters=ym({address:Fg(),chainId:Gg(),tokenAddress:Fg(),value:Vg()}),e.Request=ym({method:Mm("wallet_addFaucetFunds"),params:Bm(zm([e.Parameters]))}),e.Response=ym({message:Om(Yh()),transactionHash:Kg()})}(Mw||(Mw={})),function(e){e.Parameters=ym({chainId:Gg(),id:Kg()}),e.Request=ym({method:Mm("wallet_getAccounts"),params:Bm(zm([e.Parameters]))}),e.Response=Bm(hm(ym({address:Fg(),keys:rw.Response})))}($w||($w={})),function(e){e.Parameters=ym({address:Fg()}),e.Request=ym({method:Mm("wallet_getAuthorization"),params:Bm(zm([e.Parameters]))}),e.Response=ym({authorization:gw,data:Kg(),to:Fg()})}(Ow||(Ow={})),function(e){e.Request=ym({method:Mm("wallet_getCapabilities"),params:Om(zm([Bm(hm(Jh()))]))});const t=ym({address:Fg(),version:Om(xm([Yh(),am()]))});e.Response=Am(Kg(),ym({contracts:ym({accountImplementation:t,accountProxy:t,legacyAccountImplementations:Bm(hm(t)),legacyOrchestrators:Bm(hm(xm([ym({orchestrator:t,simulator:t}),t]))),orchestrator:t,simulator:t}),fees:ym({quoteConfig:ym({constantRate:Om(xm([Jh(),am()])),gas:Om(ym({intentBuffer:Om(Jh()),txBuffer:Om(Jh())})),rateTtl:Jh(),ttl:Jh()}),recipient:Fg(),tokens:Bm(hm(mw))})}))}(jw||(jw={})),function(e){const t=xm([Mm("native"),Mm("erc20"),Mm("erc721"),Yh()]);e.Parameters=ym({account:Fg(),assetFilter:Om(Am(Kg(),Bm(hm(ym({address:xm([Fg(),Mm("native")]),type:t}))))),assetTypeFilter:Om(Bm(hm(t))),chainFilter:Om(Bm(hm(Gg())))}),e.Request=ym({method:Mm("wallet_getAssets"),params:Bm(zm([e.Parameters]))}),e.Price=ym({currency:Yh(),value:Rm(Yh(),Jh(),{decode:e=>Number(e),encode:e=>String(e)})}),e.Response=Am(Yh(),Bm(hm(Zg([ym({address:Fg(),balance:Vg(),metadata:Sm(ym({decimals:Jh(),fiat:Nm(e.Price),name:Yh(),symbol:Yh()})),type:Mm("erc20")}),ym({address:Sm(Mm("native")),balance:Vg(),metadata:Sm(ym({decimals:Jh(),fiat:Nm(e.Price),name:Om(Yh()),symbol:Om(Yh())})),type:Mm("native")})]))))}(Sw||(Sw={})),function(e){e.Request=ym({method:Mm("wallet_getCallsStatus"),params:Bm(zm([Kg()]))}),e.Response=ym({id:Yh(),receipts:Om(Bm(hm(ym({blockHash:Kg(),blockNumber:Gg(),chainId:Gg(),gasUsed:Gg(),logs:Bm(hm(ym({address:Fg(),data:Kg(),topics:Bm(hm(Kg()))}))),status:Kg(),transactionHash:Kg()})))),status:Jh()})}(Nw||(Nw={})),function(e){e.Parameters=ym({address:Fg(),chainIds:Om(Bm(hm(Gg())))}),e.Request=ym({method:Mm("wallet_getKeys"),params:Bm(zm([e.Parameters]))}),e.Response=Am(Kg(),rw.Response)}(Tw||(Tw={})),function(e){e.Capabilities=ym({authorizeKeys:Om(rw.Request),meta:iw.Request,preCall:Om(em()),preCalls:Om(Bm(hm(cw))),requiredFunds:Om(aw.Request),revokeKeys:Om(ow.Request)}),e.ResponseCapabilities=ym({assetDiffs:Om(nw.Response),authorizeKeys:Nm(rw.Response),feePayerDigest:Om(Kg()),feeSignature:Om(Kg()),feeTotals:Om(sw.Response),revokeKeys:Nm(ow.Response)}),e.Parameters=ym({calls:Bm(hm(ww)),capabilities:e.Capabilities,chainId:Gg(),from:Om(Fg()),key:Om(ym({prehash:em(),publicKey:Kg(),type:ew.shape.type}))}),e.Request=ym({method:Mm("wallet_prepareCalls"),params:Bm(zm([e.Parameters]))}),e.Response=ym({capabilities:e.ResponseCapabilities,context:ym({preCall:Om(wm(uw)),quote:Om(wm(hw))}),digest:Kg(),key:Nm(ym({prehash:em(),publicKey:Kg(),type:ew.shape.type})),signature:Kg(),typedData:ym({domain:xm([ym({chainId:xm([Gg(),Jh()]),name:Yh(),verifyingContract:Fg(),version:Yh()}),ym({})]),message:Am(Yh(),dm()),primaryType:Yh(),types:Am(Yh(),dm())})})}(_w||(_w={})),function(e){e.Capabilities=ym({authorizeKeys:rw.Request}),e.Parameters=ym({address:Fg(),capabilities:e.Capabilities,chainId:Om(Jh()),delegation:Fg()}),e.Request=ym({method:Mm("wallet_prepareUpgradeAccount"),params:Bm(zm([e.Parameters]))}),e.Response=ym({capabilities:e.Capabilities,chainId:Gg(),context:ym({address:Fg(),authorization:bw,chainId:Gg(),preCall:cw}),digests:ym({auth:Kg(),exec:Kg()}),typedData:ym({domain:xm([ym({chainId:xm([Gg(),Jh()]),name:Yh(),verifyingContract:Fg(),version:Yh()}),ym({})]),message:Am(Yh(),dm()),primaryType:Yh(),types:Am(Yh(),dm())})})}(Rw||(Rw={})),function(e){e.Request=ym({method:Mm("wallet_feeTokens"),params:Om(sm())}),e.Response=Am(Kg(),Bm(hm(ym({address:Fg(),decimals:Jh(),nativeRate:Om(Vg()),symbol:Yh()}))))}(Cw||(Cw={})),function(e){e.Parameters=ym({capabilities:Om(ym({feeSignature:Om(Kg())})),context:ym({preCall:Om(wm(uw)),quote:Om(wm(hw))}),key:Om(ym({prehash:em(),publicKey:Kg(),type:ew.shape.type})),signature:Kg()}),e.Request=ym({method:Mm("wallet_sendPreparedCalls"),params:Bm(zm([e.Parameters]))}),e.Response=ym({id:Kg()})}(Bw||(Bw={})),function(e){e.Parameters=ym({context:ym({address:Fg(),authorization:bw,chainId:Gg(),preCall:cw}),signatures:ym({auth:Kg(),exec:Kg()})}),e.Request=ym({method:Mm("wallet_upgradeAccount"),params:Bm(zm([e.Parameters]))}),e.Response=sm()}(Dw||(Dw={})),function(e){e.Parameters=ym({address:Kg(),chainId:Gg(),digest:Kg(),signature:Kg()}),e.Request=ym({method:Mm("wallet_verifySignature"),params:Bm(zm([e.Parameters]))}),e.Response=ym({proof:Nm(ym({account:Fg(),initPreCall:Nm(cw),keyHash:Kg()})),valid:em()})}(Uw||(Uw={}));class Zw extends ul{constructor(e){super("An error occurred while executing calls.",{cause:e,metaMessages:[e.abiError&&"Reason: "+e.abiError.name].filter(Boolean)}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Rpc.ExecutionError"}),Object.defineProperty(this,"abiError",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abiError=e.abiError}}function Hw(e){return t=>{const n=e.public(t),r=e.relay(t);return Wd({key:Hw.type,name:"Relay Proxy",request:async({method:e,params:t},s)=>function(e){return!!e.startsWith("wallet_")||(!!e.startsWith("account_")||"health"===e)}(e)?r.request({method:e,params:t},s):n.request({method:e,params:t},s),type:Hw.type})}}!function(e){e.type="relayProxy"}(Hw||(Hw={}));const Ww=new Map;const Yw=ym({chainId:Om(Gg()),expiry:Gg(),hash:Kg(),id:Kg(),prehash:Om(em()),publicKey:Kg(),role:xm([Mm("admin"),Mm("session")]),type:xm([Mm("address"),Mm("p256"),Mm("secp256k1"),Mm("webauthn-p256")])}),Qw=Bm(hm(Zg([ym({signature:Yh(),to:Fg()}),ym({signature:Yh()}),ym({to:Fg()})])).check(Vh(1))),Jw=ym({limit:xm([Um([Jh(),".",Jh()]),Um([Jh()])]).check(Zh(/^\d+(\.\d+)?$/)),symbol:Om(xm([Mm("native"),yw]))}),Xw=ym({addresses:Bm(hm(Fg()))}),ev=Bm(hm(ym({limit:Vg(),period:xm([Mm("minute"),Mm("hour"),Mm("day"),Mm("week"),Mm("month"),Mm("year")]),token:Om(Fg())}))),tv=ym({calls:Om(Qw),signatureVerification:Om(Xw),spend:Om(ev)}),nv=ym({...Yw.shape,feeToken:Om(Sm(Jw)),permissions:Om(tv)}),rv=ym({address:Fg(),chainId:Om(Gg()),expiry:Jh(),id:Kg(),key:bm(Yw,{publicKey:!0,type:!0}),permissions:ym({calls:Qw,signatureVerification:Om(Xw),spend:Om(ev)})}),sv=ym({address:Om(Fg()),chainId:Om(Gg()),expiry:Jh().check((iv=1,new ah({check:"greater_than",...Np(av),value:iv,inclusive:!0}))),feeToken:Sm(Jw),key:Om(bm(Yw,{publicKey:!0,type:!0})),permissions:ym({calls:Qw,signatureVerification:Om(Xw),spend:Om(ev)})});var iv,av;const ov=rv;function cv(e,t){const{chainId:n,expiry:r,permissions:s,id:i,publicKey:a,type:o}=e,{address:c}=t;return{address:c,chainId:n,expiry:r,id:i,key:{publicKey:a,type:o},permissions:s??{}}}function uv(e){const{chainId:t,expiry:n,key:r}=e;return Ig({chainId:t,expiry:n,permissions:e.permissions??{},publicKey:r.publicKey,role:"session",type:r.type})}var dv,lv,fv,pv,hv,mv,yv,bv,gv,wv;!function(e){e.GetCapabilitiesResponse=ym({status:xm([Mm("supported"),Mm("unsupported")])})}(dv||(dv={})),function(e){e.Request=xm([em(),ym({chainId:Om(Gg()),label:Om(Yh())})])}(lv||(lv={})),function(e){e.Request=Zg([ym({chainId:Om(Jh()),domain:Om(Yh()),expirationTime:Om(fm()),issuedAt:Om(fm()),nonce:Yh(),notBefore:Om(fm()),requestId:Om(Yh()),resources:Om(Bm(hm(Yh()))),scheme:Om(Yh()),statement:Om(Yh()),uri:Om(Yh()),version:Om(Mm("1"))}),ym({authUrl:xm([Yh(),ym({logout:Yh(),nonce:Yh(),verify:Yh()})]),chainId:Om(Gg()),domain:Om(Yh()),expirationTime:Om(fm()),issuedAt:Om(fm()),notBefore:Om(fm()),requestId:Om(Yh()),resources:Om(Bm(hm(Yh()))),scheme:Om(Yh()),statement:Om(Yh()),uri:Om(Yh()),version:Om(Mm("1"))})]),e.Response=ym({message:Yh(),signature:Kg(),token:Om(Yh())})}(fv||(fv={})),function(e){e.GetCapabilitiesResponse=ym({supported:em(),tokens:Bm(hm(mw))}),e.Request=xm([yw,Fg()])}(pv||(pv={})),function(e){e.Request=sv}(hv||(hv={})),function(e){e.GetCapabilitiesResponse=ym({supported:em()})}(mv||(mv={})),function(e){e.GetCapabilitiesResponse=ym({supported:em()}),e.Request=ym({id:Om(xm([Kg(),am()]))}),e.Response=Bm(hm(rv))}(yv||(yv={})),function(e){e.Request=Bm(hm(ym({context:dm(),signature:Kg()}))),e.Response=e.Request}(bv||(bv={})),function(e){e.Request=Yh()}(gv||(gv={})),function(e){e.GetCapabilitiesResponse=ym({supported:em(),tokens:Bm(hm(mw))}),e.Request=Bm(hm(Zg([ym({address:Fg(),value:Vg()}),ym({symbol:yw,value:xm([Um([Jh(),".",Jh()]),Um([Jh()])]).check(Zh(/^\d+(\.\d+)?$/))})])))}(wv||(wv={}));const vv=ym({...bm(Yw,{id:!0,publicKey:!0,type:!0}).shape,credentialId:Om(Yh()),privateKey:Om(cm())});var xv,Iv,Pv,zv,Ev,Av,kv,Mv,$v,Ov,jv,Sv,Nv,Tv,_v,Rv,Cv,Bv,Dv,Uv,qv,Lv,Fv,Kv,Gv,Vv,Zv,Hv,Wv,Yv,Qv,Jv,Xv,ex,tx;!function(e){e.Parameters=ym({address:Fg(),secret:Yh()}),e.Request=ym({method:Mm("account_getOnrampContactInfo"),params:Bm(zm([e.Parameters]))}),e.Response=ym({email:Om(Yh()),phone:Om(Yh()),phoneVerifiedAt:Om(Jh())})}(xv||(xv={})),function(e){e.Parameters=ym({address:Fg()}),e.Request=ym({method:Mm("account_onrampStatus"),params:Bm(zm([e.Parameters]))}),e.Response=ym({email:Om(Jh()),phone:Om(Jh())})}(Iv||(Iv={})),function(e){e.Parameters=ym({email:Yh(),walletAddress:Fg()}),e.Request=ym({method:Mm("account_resendVerifyPhone"),params:Bm(zm([e.Parameters]))}),e.Response=am()}(Pv||(Pv={})),function(e){e.Parameters=ym({email:Yh(),walletAddress:Fg()}),e.Request=ym({method:Mm("account_setEmail"),params:Bm(zm([e.Parameters]))}),e.Response=am()}(zv||(zv={})),function(e){e.Parameters=ym({email:Yh(),walletAddress:Fg()}),e.Request=ym({method:Mm("account_setPhone"),params:Bm(zm([e.Parameters]))}),e.Response=am()}(Ev||(Ev={})),function(e){e.Parameters=ym({chainId:Gg(),email:Yh(),token:Yh(),walletAddress:Fg()}),e.Request=ym({method:Mm("account_verifyEmail"),params:Bm(zm([e.Parameters]))}),e.Response=am()}(Av||(Av={})),function(e){e.Parameters=ym({code:Yh(),phone:Yh(),walletAddress:Fg()}),e.Request=ym({method:Mm("account_verifyPhone"),params:Bm(zm([e.Parameters]))}),e.Response=am()}(kv||(kv={})),function(e){e.Parameters=ym({address:Om(Fg()),chainId:Om(Gg()),token:Om(Fg()),value:Om(Yh())}),e.Request=ym({method:Mm("wallet_addFunds"),params:Bm(zm([e.Parameters]))}),e.Response=ym({id:Kg()})}(Mv||(Mv={})),function(e){e.Request=ym({method:Mm("eth_accounts"),params:Om(dm())}),e.Response=Bm(hm(Fg()))}($v||($v={})),function(e){e.Request=ym({method:Mm("eth_chainId"),params:Om(dm())}),e.Response=Kg()}(Ov||(Ov={})),function(e){e.Request=ym({method:Mm("eth_requestAccounts"),params:Om(dm())}),e.Response=Bm(hm(Fg()))}(jv||(jv={})),function(e){e.Request=ym({method:Mm("eth_sendTransaction"),params:Bm(zm([ym({capabilities:Om(ym({feeToken:Om(pv.Request),merchantUrl:Om(gv.Request),preCalls:Om(bv.Request)})),chainId:Om(Gg()),data:Om(Kg()),from:Om(Fg()),to:Fg(),value:Om(Vg())})]))}),e.Response=Kg()}(Sv||(Sv={})),function(e){e.Request=ym({method:Mm("eth_signTypedData_v4"),params:Bm(zm([Fg(),Yh()]))}),e.Response=Kg()}(Nv||(Nv={})),function(e){e.Parameters=ym({address:Om(Fg()),chainId:Om(Gg())}),e.Request=ym({method:Mm("wallet_getAdmins"),params:Om(Bm(zm([e.Parameters])))}),e.Key=vv,e.Response=ym({address:Fg(),chainId:Gg(),keys:Bm(hm(e.Key))})}(Tv||(Tv={})),function(e){e.Capabilities=ym({feeToken:Om(pv.Request)}),e.Parameters=ym({address:Om(Fg()),capabilities:Om(e.Capabilities),chainId:Om(Gg()),key:bm(Yw,{publicKey:!0,type:!0})}),e.Request=ym({method:Mm("wallet_grantAdmin"),params:Bm(zm([e.Parameters]))}),e.Response=ym({address:Fg(),chainId:Gg(),key:Tv.Key})}(_v||(_v={})),function(e){e.Parameters=sv,e.Request=ym({method:Mm("wallet_grantPermissions"),params:Bm(zm([e.Parameters]))}),e.ResponseCapabilities=ym({preCalls:Om(bv.Response)}),e.Response=ym({...rv.shape,capabilities:Om(cm())})}(Rv||(Rv={})),function(e){e.Parameters=ym({address:Om(Fg())}),e.Request=ym({method:Mm("wallet_getAccountVersion"),params:Om(Bm(zm([e.Parameters])))}),e.Response=ym({current:Yh(),latest:Yh()})}(Cv||(Cv={})),function(e){e.Parameters=ym({address:Om(Fg()),chainIds:Om(Bm(hm(Gg())))}),e.Request=ym({method:Mm("wallet_getPermissions"),params:Om(Bm(zm([e.Parameters])))}),e.Response=yv.Response}(Bv||(Bv={})),function(e){e.Capabilities=ym({feeToken:Om(pv.Request)}),e.Parameters=ym({address:Om(Fg()),capabilities:Om(e.Capabilities),chainId:Om(Gg()),id:Kg()}),e.Request=ym({method:Mm("wallet_revokeAdmin"),params:Bm(zm([e.Parameters]))}),e.Response=void 0}(Dv||(Dv={})),function(e){e.Capabilities=ym({feeToken:Om(pv.Request)}),e.Parameters=ym({address:Om(Fg()),capabilities:Om(e.Capabilities),id:Kg()}),e.Request=ym({method:Mm("wallet_revokePermissions"),params:Bm(zm([e.Parameters]))}),e.Response=void 0}(Uv||(Uv={})),function(e){e.Request=ym({method:Mm("wallet_switchEthereumChain"),params:Bm(zm([ym({chainId:Kg()})]))})}(qv||(qv={})),function(e){e.Parameters=ym({context:dm(),signatures:ym({auth:Kg(),exec:Kg()})}),e.Request=ym({method:Mm("wallet_upgradeAccount"),params:Bm(zm([e.Parameters]))}),e.ResponseCapabilities=ym({admins:Om(Bm(hm(Tv.Key))),permissions:Om(yv.Response)}),e.Response=ym({address:Fg(),capabilities:Om(e.ResponseCapabilities)})}(Lv||(Lv={})),function(e){e.Request=ym({method:Mm("personal_sign"),params:Bm(zm([Kg(),Fg()]))}),e.Response=Kg()}(Fv||(Fv={})),function(e){e.Request=ym({method:Mm("porto_ping"),params:Om(sm())}),e.Response=Mm("pong")}(Kv||(Kv={})),function(e){e.Capabilities=ym({createAccount:Om(lv.Request),email:Om(em()),grantAdmins:Om(Bm(hm(bm(Yw,{publicKey:!0,type:!0})))),grantPermissions:Om(hv.Request),preCalls:Om(bv.Request),selectAccount:Om(xm([em(),ym({address:Fg(),key:Om(ym({credentialId:Om(Yh()),publicKey:Kg()}))})])),signInWithEthereum:Om(fv.Request)}),e.Parameters=ym({capabilities:Om(e.Capabilities),chainIds:Om(Bm(hm(Gg())))}),e.Request=ym({method:Mm("wallet_connect"),params:Om(Bm(zm([e.Parameters])))}),e.ResponseCapabilities=ym({admins:Om(Bm(hm(ym({...bm(Yw,{id:!0,publicKey:!0,type:!0}).shape,credentialId:Om(Yh())})))),permissions:Om(yv.Response),preCalls:Om(bv.Response),signInWithEthereum:Om(fv.Response)}),e.Response=ym({accounts:Bm(hm(ym({address:Fg(),capabilities:Om(e.ResponseCapabilities)}))),chainIds:Bm(hm(Gg()))})}(Gv||(Gv={})),function(e){e.Request=ym({method:Mm("wallet_disconnect"),params:Om(dm())}),e.Response=void 0}(Vv||(Vv={})),function(e){e.Parameters=Sw.Parameters,e.Request=Sw.Request,e.Response=Sw.Response}(Zv||(Zv={})),function(e){e.Request=ym({method:Mm("wallet_getCallsStatus"),params:zm([Kg()])}),e.Response=ym({atomic:em(),chainId:Gg(),id:Yh(),receipts:Om(Bm(hm(ym({blockHash:Kg(),blockNumber:Kg(),gasUsed:Kg(),logs:Bm(hm(ym({address:Fg(),data:Kg(),topics:Bm(hm(Kg()))}))),status:Kg(),transactionHash:Kg()})))),status:Jh(),version:Yh()})}(Hv||(Hv={})),function(e){e.Request=ym({method:Mm("wallet_getCapabilities"),params:Om(xm([Bm(zm([xm([Kg(),sm()])])),Bm(zm([xm([Kg(),sm()]),Bm(hm(Gg()))]))]))}),e.Response=Am(Kg(),ym({atomic:dv.GetCapabilitiesResponse,feeToken:pv.GetCapabilitiesResponse,merchant:mv.GetCapabilitiesResponse,permissions:yv.GetCapabilitiesResponse,requiredFunds:wv.GetCapabilitiesResponse}))}(Wv||(Wv={})),function(e){e.Parameters=ym({address:Fg(),chainIds:Om(Bm(hm(Gg())))}),e.Request=ym({method:Mm("wallet_getKeys"),params:Bm(zm([e.Parameters]))}),e.Response=Bm(hm(nv))}(Yv||(Yv={})),function(e){e.Capabilities=ym({feeToken:Om(pv.Request),merchantUrl:Om(gv.Request),permissions:Om(yv.Request),preCalls:Om(bv.Request),requiredFunds:Om(wv.Request)}),e.Parameters=ym({calls:Bm(hm(ym({data:Om(Kg()),to:Fg(),value:Om(Vg())}))),capabilities:Om(e.Capabilities),chainId:Om(Gg()),from:Om(Fg()),key:Om(bm(Yw,{prehash:!0,publicKey:!0,type:!0})),version:Om(Yh())}),e.Request=ym({method:Mm("wallet_prepareCalls"),params:Bm(zm([e.Parameters]))}),e.Response=ym({capabilities:Om(ym({..._w.ResponseCapabilities.shape,quote:Om(hw)})),chainId:Kg(),context:ym({account:ym({address:Fg()}),calls:e.Parameters.shape.calls,nonce:Vg(),quote:Om(wm(hw))}),digest:Kg(),key:bm(Yw,{prehash:!0,publicKey:!0,type:!0}),typedData:ym({domain:xm([ym({chainId:Gg(),name:Yh(),verifyingContract:Fg(),version:Yh()}),ym({})]),message:Am(Yh(),dm()),primaryType:Yh(),types:Am(Yh(),dm())})})}(Qv||(Qv={})),function(e){e.Capabilities=ym({...Gv.Capabilities.shape,label:Om(Yh())}),e.Parameters=ym({address:Fg(),capabilities:Om(e.Capabilities),chainId:Om(Gg())}),e.Request=ym({method:Mm("wallet_prepareUpgradeAccount"),params:Bm(zm([e.Parameters]))}),e.Response=ym({context:dm(),digests:ym({auth:Kg(),exec:Kg()})})}(Jv||(Jv={})),function(e){e.Capabilities=Qv.Capabilities,e.Request=ym({method:Mm("wallet_sendCalls"),params:Bm(zm([gm(Qv.Parameters,{key:!0})]))}),e.Response=ym({id:Kg()})}(Xv||(Xv={})),function(e){e.Parameters=ym({capabilities:Qv.Response.shape.capabilities,chainId:Kg(),context:Qv.Response.shape.context,key:Qv.Response.shape.key,signature:Kg()}),e.Request=ym({method:Mm("wallet_sendPreparedCalls"),params:Bm(zm([e.Parameters]))}),e.Response=Bm(hm(ym({capabilities:Om(Am(Yh(),dm())),id:Kg()})))}(ex||(ex={})),function(e){e.Parameters=ym({address:Fg(),chainId:Om(Gg()),digest:Kg(),signature:Kg()}),e.Request=ym({method:Mm("wallet_verifySignature"),params:Bm(zm([e.Parameters]))}),e.Response=ym({address:Fg(),chainId:Gg(),proof:Om(dm()),valid:em()})}(tx||(tx={}));const nx=function(e,t,n){return new Im({type:"union",options:t,discriminator:e,...Np(n)})}("method",[Av.Request,Mv.Request,$v.Request,Ov.Request,jv.Request,Sv.Request,Nv.Request,Cv.Request,Tv.Request,Bv.Request,_v.Request,Rv.Request,Jv.Request,Dv.Request,Uv.Request,Lv.Request,Fv.Request,Kv.Request,Gv.Request,Vv.Request,Zv.Request,Hv.Request,Wv.Request,Yv.Request,Qv.Request,Xv.Request,ex.Request,qv.Request,tx.Request]);function rx(e,t){const n=Vp(e,t);if(n.error){const e=n.error.issues.at(0);if("invalid_union"===e?.code&&"No matching discriminator"===e.note)throw new bl;throw new Il(Wg(n.error))}return{...t,_decoded:n.data}}async function sx(e){e.persist.hasHydrated()||await new Promise((t=>{e.persist.onFinishHydration((()=>t(!0))),setTimeout((()=>t(!0)),100)}))}function ix(e){if(e)return e.startsWith("/")?`${window.location.origin}${e}`:e}function ax(t){const{config:n,getMode:r,id:s,store:i}=t,{announceProvider:a}=n;function o(e={}){const t=c(),a=e.request??rx(nx,{method:"wallet_getCapabilities",params:e.chainIds?[void 0,e.chainIds]:void 0});return Na((()=>r().actions.getCapabilities({chainIds:e.chainIds,internal:{client:t,config:n,request:a,store:i}})),{cacheKey:`getCapabilities.${s}.${e.chainIds?.join(",")}`})}function c(e){const n="string"==typeof e?Af(e):e;return function(e,t={}){const{config:n,id:r,store:s}=e._internal,{chains:i,relay:a}=n,o=s.getState(),c=t.chainId??o.chainIds[0],u=i.find((e=>e.id===c));if(!u)throw new Error(["Could not find a compatible Porto chain on the given chain configuration.","",`Provided chains: [${i.map((e=>`${e.name} (id: ${e.id})`)).join(", ")}]`,`Needed chain (id): ${c}`,"Please add this chain (id) to your chain configuration."].join("\n"));const d=Hw({public:n.transports[u.id]??Yd(u.rpcUrls.default.http.map((e=>Xd(e)))),relay:a}),l=[r,cl(u)].filter(Boolean).join(":");if(Ww.has(l))return Ww.get(l);const f=Za({...t,chain:u,pollingInterval:1e3,transport:d});return Ww.set(l,f),f}({_internal:t},{chainId:n})}const u=new Map,d=[],l=function(){const t=new e.EventEmitter;return{get eventNames(){return t.eventNames.bind(t)},get listenerCount(){return t.listenerCount.bind(t)},get listeners(){return t.listeners.bind(t)},addListener:t.addListener.bind(t),emit:t.emit.bind(t),off:t.off.bind(t),on:t.on.bind(t),once:t.once.bind(t),removeAllListeners:t.removeAllListeners.bind(t),removeListener:t.removeListener.bind(t)}}(),f=Dl({...l,async request(e){await sx(i);return Hl((async()=>{let t;try{t=rx(nx,e)}catch(t){if(!(t instanceof bl))throw t;if(e.method.startsWith("wallet_"))throw new Ml;return c().request(e)}const s=i.getState();switch(t.method){case"account_verifyEmail":{if(0===s.accounts.length)throw new $l;const[e]=t._decoded.params,{chainId:a,email:o,token:u,walletAddress:d}=e,l=c(a);if(a&&a!==l.chain.id)throw new Ol;const f=d?s.accounts.find((e=>fp(e.address,d))):s.accounts[0];if(!f)throw new kl;return await r().actions.verifyEmail({account:f,chainId:a,email:o,internal:{client:l,config:n,request:t,store:i},token:u,walletAddress:d})}case"wallet_addFunds":{if(0===s.accounts.length)throw new $l;const{address:e,value:a,token:o}=t.params[0]??{},u=e?s.accounts.find((t=>fp(t.address,e))):s.accounts[0];if(!u)throw new kl;const d=c(),f=await r().actions.addFunds({address:u.address,internal:{client:d,config:n,request:t,store:i},token:o,value:a});return l.emit("message",{data:null,type:"assetsChanged"}),f}case"eth_accounts":if(0===s.accounts.length)throw new $l;return s.accounts.map(dx);case"eth_chainId":return gf(s.chainIds[0]);case"eth_requestAccounts":{if(s.accounts.length>0&&u.get("eth_requestAccounts"))return s.accounts.map(dx);const e=c(),{accounts:a}=await r().actions.loadAccounts({internal:{client:e,config:n,request:t,store:i}});return i.setState((e=>({...e,accounts:a}))),l.emit("connect",{chainId:gf(e.chain.id)}),u.set("eth_requestAccounts",!0),setTimeout((()=>u.delete("eth_requestAccounts")),1e3),a.map(dx)}case"eth_sendTransaction":{if(0===s.accounts.length)throw new $l;const[{capabilities:e,chainId:a,data:o="0x",from:u,to:d,value:l}]=t._decoded.params,f=c(a);if(a&&a!==f.chain.id)throw new Ol;const p=u?s.accounts.find((e=>fp(e.address,u))):s.accounts[0];if(!p)throw new kl;const{id:h}=await r().actions.sendCalls({account:p,asTxHash:!0,calls:[{data:o,to:d,value:l}],internal:{client:f,config:n,request:t,store:i},merchantUrl:ix(n.merchantUrl??e?.merchantUrl)});return h}case"eth_signTypedData_v4":{if(0===s.accounts.length)throw new $l;const[e,a]=t._decoded.params,o=s.accounts.find((t=>fp(t.address,e)));if(!o)throw new kl;const u=c();return await r().actions.signTypedData({account:o,data:a,internal:{client:u,config:n,request:t,store:i}})}case"wallet_grantAdmin":{if(0===s.accounts.length)throw new $l;const[{address:e,capabilities:a,chainId:o,key:u}]=t._decoded.params??[{}],d=e?s.accounts.find((t=>fp(t.address,e))):s.accounts[0];if(!d)throw new kl;const f=c(o),p=cx([...d.keys??[]])?.some((e=>e.publicKey?.toLowerCase()===u.publicKey.toLowerCase()));if(p)throw new Il({message:"Key already granted as admin."});const{key:h}=await r().actions.grantAdmin({account:d,feeToken:a?.feeToken,internal:{client:f,config:n,request:t,store:i},key:u});i.setState((e=>{const t=e.accounts.findIndex((e=>!d||fp(e.address,d.address)));return-1===t?e:{...e,accounts:e.accounts.map(((e,n)=>n===t?{...e,keys:[...e.keys??[],h]}:e))}}));const m=cx([...d.keys??[],h]);return l.emit("message",{data:null,type:"adminsChanged"}),Yp(_v.Response,{address:d.address,chainId:f.chain.id,key:m.at(-1)})}case"wallet_grantPermissions":{if(0===s.accounts.length)throw new $l;const[{address:e,chainId:a,...o}]=t._decoded.params??[{}],u=e?s.accounts.find((t=>fp(t.address,e))):s.accounts[0];if(!u)throw new kl;const d=c(a),{key:f}=await r().actions.grantPermissions({account:u,internal:{client:d,config:n,request:t,store:i},permissions:o});return i.setState((e=>{const t=e.accounts.findIndex((e=>!u||fp(e.address,u.address)));return-1===t?e:{...e,accounts:e.accounts.map(((e,n)=>n===t?{...e,keys:[...e.keys??[],f]}:e))}})),l.emit("message",{data:null,type:"permissionsChanged"}),Yp(Rv.Response,{...cv(f,{address:u.address})})}case"wallet_getAdmins":{if(0===s.accounts.length)throw new $l;const[{address:e,chainId:a}]=t._decoded.params??[{}],o=e?s.accounts.find((t=>fp(t.address,e))):s.accounts[0];if(!o)throw new kl;const u=c(a),d=cx(await r().actions.getKeys({account:o,internal:{client:u,config:n,request:t,store:i}}));return Yp(Tv.Response,{address:o.address,chainId:u.chain.id,keys:d})}case"wallet_prepareUpgradeAccount":{const[{address:e,capabilities:s,chainId:a}]=t._decoded.params??[{}],{email:o,label:u,grantPermissions:l}=s??{},f=c(a),{context:p,digests:h}=await r().actions.prepareUpgradeAccount({address:e,email:o,internal:{client:f,config:n,request:t,store:i},label:u,permissions:l});return d.push(p.account),{context:p,digests:h}}case"wallet_getAccountVersion":{if(0===s.accounts.length)throw new $l;const[{address:e}]=t._decoded.params??[{}],a=e?s.accounts.find((t=>fp(t.address,e))):s.accounts[0];if(!a)throw new kl;const o=c(),{current:u,latest:d}=await r().actions.getAccountVersion({address:a.address,internal:{client:o,config:n,request:t,store:i}});return{current:u,latest:d}}case"wallet_getKeys":{if(0===s.accounts.length)throw new $l;const[{address:e,chainIds:a}]=t._decoded.params??[{}],o=s.accounts.find((t=>fp(t.address,e)));if(!o)throw new kl;const u=c(),d=await r().actions.getKeys({account:o,chainIds:a,internal:{client:u,config:n,request:t,store:i}});return Yp(Yv.Response,d)}case"wallet_getPermissions":{if(0===s.accounts.length)throw new $l;const[{address:e,chainIds:a}]=t._decoded.params??[{}],o=e?s.accounts.find((t=>fp(t.address,e))):s.accounts[0];if(!o)throw new kl;const u=c();return ux(await r().actions.getKeys({account:o,chainIds:a,internal:{client:u,config:n,request:t,store:i}}),{address:o.address})}case"wallet_revokeAdmin":{if(0===s.accounts.length)throw new $l;const[{address:e,capabilities:a,id:o}]=t._decoded.params,u=e?s.accounts.find((t=>fp(t.address,e))):s.accounts[0];if(!u)throw new kl;const d=c();await r().actions.revokeAdmin({account:u,feeToken:a?.feeToken,id:o,internal:{client:d,config:n,request:t,store:i}});const f=u.keys?.filter((e=>e.id.toLowerCase()!==o.toLowerCase()));return i.setState((e=>({...e,accounts:e.accounts.map((e=>fp(e.address,u.address)?{...e,keys:f}:e))}))),void l.emit("message",{data:null,type:"adminsChanged"})}case"wallet_revokePermissions":{if(0===s.accounts.length)throw new $l;const[{address:e,capabilities:a,id:o}]=t._decoded.params,u=e?s.accounts.find((t=>fp(t.address,e))):s.accounts[0];if(!u)throw new kl;const d=c();await r().actions.revokePermissions({account:u,feeToken:a?.feeToken,id:o,internal:{client:d,config:n,request:t,store:i}});const f=u.keys?.filter((e=>e.id.toLowerCase()!==o.toLowerCase()));return i.setState((e=>({...e,accounts:e.accounts.map((e=>fp(e.address,u.address)?{...e,keys:f}:e))}))),void l.emit("message",{data:null,type:"permissionsChanged"})}case"wallet_upgradeAccount":{const[{context:e,signatures:s}]=t._decoded.params??[{}],a=c(),o=d.find((t=>fp(t.address,e.account.address)));if(!o)throw new kl;const{account:u}=await r().actions.upgradeAccount({account:o,context:e,internal:{client:a,config:n,request:t,store:i},signatures:s}),f=cx(u.keys??[]),p=ux(u.keys??[],{address:u.address});return i.setState((e=>({...e,accounts:[u]}))),l.emit("connect",{chainId:gf(a.chain.id)}),{address:u.address,capabilities:{admins:f,...p.length>0?{permissions:p}:{}}}}case"porto_ping":return"pong";case"personal_sign":{if(0===s.accounts.length)throw new $l;const[e,a]=t._decoded.params,o=s.accounts.find((e=>fp(e.address,a)));if(!o)throw new kl;const u=c();return await r().actions.signPersonalMessage({account:o,data:e,internal:{client:u,config:n,request:t,store:i}})}case"wallet_connect":{const[{capabilities:e,chainIds:a}]=t._decoded.params??[{}],o=c(a?.[0]),u=o.chain.id,{createAccount:d,email:f,grantAdmins:p,grantPermissions:h,selectAccount:m,signInWithEthereum:y}=e??{},b={client:o,config:n,request:t,store:i},{accounts:g}=await(async()=>{if(f||d){const{label:e}="object"==typeof d?d:{},{account:t}=await r().actions.createAccount({admins:p,email:f,internal:b,label:e,permissions:h,signInWithEthereum:y});return{accounts:[t]}}const e=s.accounts[0],{address:t,key:n}=(()=>{if(m)return"object"==typeof m?m:{address:void 0,key:void 0};for(const t of e?.keys??[])if("webauthn-p256"===t.type&&"admin"===t.role)return{address:e?.address,key:{credentialId:t.credentialId??t.privateKey?.credential?.id,publicKey:t.publicKey}};return{address:void 0,key:void 0}})(),i={internal:b,permissions:h,signInWithEthereum:y};try{return await r().actions.loadAccounts({address:t,key:n,...i})}catch(e){if(e instanceof Al)throw e;if(t&&n)return await r().actions.loadAccounts(i);throw e}})();i.setState((e=>({...e,accounts:g})));const w=[u,...i.getState().chainIds.filter((e=>e!==u))];return l.emit("connect",{chainId:gf(w[0])}),{accounts:g.map((e=>({address:dx(e),capabilities:{admins:e.keys?cx(e.keys):[],permissions:e.keys?ux(e.keys,{address:e.address}):[],...e.signInWithEthereum&&{signInWithEthereum:e.signInWithEthereum}}}))),chainIds:w.map((e=>gf(e)))}}case"wallet_disconnect":{const e=c();return await(r().actions.disconnect?.({internal:{client:e,config:n,request:t,store:i}})),i.setState((e=>({...e,accounts:[]}))),void l.emit("disconnect",new $l)}case"wallet_getAssets":{const[e]=t._decoded.params??[],{account:s,chainFilter:a,assetFilter:o,assetTypeFilter:u}=e,d=c(),l=await r().actions.getAssets({account:s,assetFilter:o,assetTypeFilter:u,chainFilter:a,internal:{client:d,config:n,request:t,store:i}}),f=Object.entries(l).reduce(((e,[t,n])=>(e[gf(Number(t))]=n,e)),{});return Yp(Zv.Response,f)}case"wallet_getCallsStatus":{const[e]=t._decoded.params??[],s=c();return await r().actions.getCallsStatus({id:e,internal:{client:s,config:n,request:t,store:i}})}case"wallet_getCapabilities":{const[e,n]=t.params??[];return await o({chainIds:n,request:t})}case"wallet_prepareCalls":{const[e]=t._decoded.params,{calls:a,capabilities:o,chainId:u,key:d,from:l}=e,f=c(u),p=l??s.accounts[0];if(!p)throw new kl;if(u&&u!==f.chain.id)throw new Ol;const{digest:h,...m}=await r().actions.prepareCalls({account:jg(p),calls:a,feeToken:o?.feeToken,internal:{client:f,config:n,request:t,store:i},key:d,merchantUrl:ix(n.merchantUrl??o?.merchantUrl),requiredFunds:o?.requiredFunds});return Yp(Qv.Response,{capabilities:m.capabilities,chainId:gf(m.chainId??f.chain.id),context:{...m.context,account:{address:m.account.address},calls:m.context.calls??[],nonce:m.context.nonce??0n},digest:h,key:m.key,typedData:m.typedData})}case"wallet_sendPreparedCalls":{const[e]=t._decoded.params,{chainId:s,context:a,key:o,signature:u}=e,{account:d}=e.context,l=c(s);if(s&&Af(s)!==l.chain.id)throw new Ol;return[{id:await r().actions.sendPreparedCalls({account:jg(d),context:a,internal:{client:l,config:n,request:t,store:i},key:o,signature:u})}]}case"wallet_sendCalls":{if(0===s.accounts.length)throw new $l;const[e]=t._decoded.params,{calls:a,capabilities:o,chainId:u,from:d}=e,l=c(u);if(u&&u!==l.chain.id)throw new Ol;const f=d?s.accounts.find((e=>fp(e.address,d))):s.accounts[0];if(!f)throw new kl;const{id:p}=await r().actions.sendCalls({account:f,calls:a,feeToken:o?.feeToken,internal:{client:l,config:n,request:t,store:i},merchantUrl:ix(n.merchantUrl??o?.merchantUrl),permissionsId:o?.permissions?.id,requiredFunds:o?.requiredFunds});return{id:p}}case"wallet_switchEthereumChain":{const[e]=t._decoded.params,{chainId:s}=e,a=Af(s);if(!n.chains.find((e=>e.id===a)))throw new Nl;const o=c(s);return await(r().actions.switchChain?.({chainId:o.chain.id,internal:{client:o,config:n,request:t,store:i}})),void i.setState((e=>({...e,chainIds:[a,...e.chainIds.filter((e=>e!==a))]})))}case"wallet_verifySignature":{const[e]=t._decoded.params,{address:n,chainId:r,digest:s,signature:i}=e,a=c(r),o=await async function(e,t){const{address:n,chain:r=e.chain,digest:s,signature:i}=t;try{async function a(){return{proof:null,valid:await Zd(e,{address:n,hash:s,signature:i})}}const o="wallet_verifySignature",c=await(async()=>{const t=await e.request({method:o,params:[Yp(Uw.Parameters,{address:n,chainId:r?.id,digest:s,signature:i})]},{retryCount:0}).catch(a);return t.valid?t:a()})();return Jp(Uw.Response,c)}catch(u){throw Vw(u),u}}(a,{address:n,digest:s,signature:i});return{...o,address:n,chainId:gf(a.chain.id)}}}}),{enabled:["eth_accounts","eth_chainId","eth_requestAccounts","wallet_getAssets","wallet_getCapabilities","wallet_getKeys","wallet_getPermissions","wallet_getAccountVersion","wallet_connect"].includes(e.method),id:cl(e)})}});const p=function(){let e=()=>{},t=()=>{};sx(i).then((()=>{o().catch((()=>{})),e(),e=i.subscribe((e=>e.accounts),(e=>{l.emit("accountsChanged",e.map(dx))}),{equalityFn:(e,t)=>e.every(((e,n)=>e.address===t[n]?.address))}),t(),t=i.subscribe((e=>e.chainIds[0]),((e,t)=>{e!==t&&l.emit("chainChanged",gf(e))}))}));const n=ox(f,a);return()=>{e(),t(),n()}}();return Object.assign(f,{_internal:{destroy:p}})}function ox(e,t){if(!t)return()=>{};if("undefined"==typeof window||!window.dispatchEvent)return()=>{};const{icon:n="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDIyIiBoZWlnaHQ9IjQyMiIgdmlld0JveD0iMCAwIDQyMiA0MjIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSI0MjIiIGhlaWdodD0iNDIyIiBmaWxsPSJibGFjayIvPgo8ZyBjbGlwLXBhdGg9InVybCgjY2xpcDBfMV8xNSkiPgo8cGF0aCBkPSJNODEgMjg2LjM2NkM4MSAyODAuODkzIDg1LjQ1MDUgMjc2LjQ1NSA5MC45NDA0IDI3Ni40NTVIMzI5LjUxMUMzMzUuMDAxIDI3Ni40NTUgMzM5LjQ1MiAyODAuODkzIDMzOS40NTIgMjg2LjM2NlYzMDYuMTg4QzMzOS40NTIgMzExLjY2MiAzMzUuMDAxIDMxNi4wOTkgMzI5LjUxMSAzMTYuMDk5SDkwLjk0MDRDODUuNDUwNSAzMTYuMDk5IDgxIDMxMS42NjIgODEgMzA2LjE4OFYyODYuMzY2WiIgZmlsbD0id2hpdGUiIGZpbGwtb3BhY2l0eT0iMC41Ii8+CjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNOTAuOTQwNCAyMzQuODI4Qzg1LjQ1MDUgMjM0LjgyOCA4MSAyMzkuMjY2IDgxIDI0NC43MzlWMjcxLjUzMUM4My44NDMyIDI2OS42MzMgODcuMjYyMiAyNjguNTI2IDkwLjk0MDQgMjY4LjUyNkgzMjkuNTExQzMzMy4xODggMjY4LjUyNiAzMzYuNjA4IDI2OS42MzMgMzM5LjQ1MiAyNzEuNTMxVjI0NC43MzlDMzM5LjQ1MiAyMzkuMjY2IDMzNS4wMDEgMjM0LjgyOCAzMjkuNTExIDIzNC44MjhIOTAuOTQwNFpNMzM5LjQ1MiAyODYuMzY2QzMzOS40NTIgMjgwLjg5MyAzMzUuMDAxIDI3Ni40NTUgMzI5LjUxMSAyNzYuNDU1SDkwLjk0MDRDODUuNDUwNSAyNzYuNDU1IDgxIDI4MC44OTMgODEgMjg2LjM2NlYzMDYuMTlDODEgMzExLjY2NCA4NS40NTA1IDMxNi4xMDEgOTAuOTQwNCAzMTYuMTAxSDMyOS41MTFDMzM1LjAwMSAzMTYuMTAxIDMzOS40NTIgMzExLjY2NCAzMzkuNDUyIDMwNi4xOVYyODYuMzY2WiIgZmlsbD0id2hpdGUiIGZpbGwtb3BhY2l0eT0iMC41Ii8+CjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNOTAuOTQwNCAxOTMuMjAxQzg1LjQ1MDUgMTkzLjIwMSA4MSAxOTcuNjM4IDgxIDIwMy4xMTJWMjI5LjkwM0M4My44NDMyIDIyOC4wMDYgODcuMjYyMiAyMjYuODk5IDkwLjk0MDQgMjI2Ljg5OUgzMjkuNTExQzMzMy4xODggMjI2Ljg5OSAzMzYuNjA4IDIyOC4wMDYgMzM5LjQ1MiAyMjkuOTAzVjIwMy4xMTJDMzM5LjQ1MiAxOTcuNjM4IDMzNS4wMDEgMTkzLjIwMSAzMjkuNTExIDE5My4yMDFIOTAuOTQwNFpNMzM5LjQ1MiAyNDQuNzM5QzMzOS40NTIgMjM5LjI2NSAzMzUuMDAxIDIzNC44MjggMzI5LjUxMSAyMzQuODI4SDkwLjk0MDRDODUuNDUwNSAyMzQuODI4IDgxIDIzOS4yNjUgODEgMjQ0LjczOVYyNzEuNTNDODEuMjE3NSAyNzEuMzg1IDgxLjQzODMgMjcxLjI0NSA4MS42NjI0IDI3MS4xMDlDODMuODMyNSAyNjkuNzk0IDg2LjMwNTQgMjY4LjkyNyA4OC45NTIzIDI2OC42MzVDODkuNjA1MSAyNjguNTYzIDkwLjI2ODQgMjY4LjUyNiA5MC45NDA0IDI2OC41MjZIMzI5LjUxMUMzMzAuMTgzIDI2OC41MjYgMzMwLjg0NiAyNjguNTYzIDMzMS40OTggMjY4LjYzNUMzMzQuNDE5IDI2OC45NTcgMzM3LjEyOCAyNjkuOTggMzM5LjQ1MiAyNzEuNTNWMjQ0LjczOVpNMzM5LjQ1MiAyODYuMzY2QzMzOS40NTIgMjgxLjAyMSAzMzUuMjA2IDI3Ni42NjMgMzI5Ljg5MyAyNzYuNDYyQzMyOS43NjcgMjc2LjQ1NyAzMjkuNjQgMjc2LjQ1NSAzMjkuNTExIDI3Ni40NTVIOTAuOTQwNEM4NS40NTA1IDI3Ni40NTUgODEgMjgwLjg5MyA4MSAyODYuMzY2VjMwNi4xODhDODEgMzExLjY2MiA4NS40NTA1IDMxNi4xMDEgOTAuOTQwNCAzMTYuMTAxSDMyOS41MTFDMzM1LjAwMSAzMTYuMTAxIDMzOS40NTIgMzExLjY2MiAzMzkuNDUyIDMwNi4xODhWMjg2LjM2NloiIGZpbGw9IndoaXRlIiBmaWxsLW9wYWNpdHk9IjAuNSIvPgo8cGF0aCBvcGFjaXR5PSIwLjMiIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNOTguMDE0NiAxMDRDODguNjE3NyAxMDQgODEgMTExLjU5NSA4MSAxMjAuOTY1VjE4OC4yNzZDODMuODQzMiAxODYuMzc5IDg3LjI2MjIgMTg1LjI3MiA5MC45NDA0IDE4NS4yNzJIMzI5LjUxMUMzMzMuMTg4IDE4NS4yNzIgMzM2LjYwOCAxODYuMzc5IDMzOS40NTIgMTg4LjI3NlYxMjAuOTY1QzMzOS40NTIgMTExLjU5NSAzMzEuODMzIDEwNCAzMjIuNDM3IDEwNEg5OC4wMTQ2Wk0zMzkuNDUyIDIwMy4xMTJDMzM5LjQ1MiAxOTcuNjM4IDMzNS4wMDEgMTkzLjIwMSAzMjkuNTExIDE5My4yMDFIOTAuOTQwNEM4NS40NTA1IDE5My4yMDEgODEgMTk3LjYzOCA4MSAyMDMuMTEyVjIyOS45MDNDODEuMjE3NSAyMjkuNzU4IDgxLjQzODMgMjI5LjYxOCA4MS42NjI0IDIyOS40ODJDODMuODMyNSAyMjguMTY3IDg2LjMwNTQgMjI3LjMgODguOTUyMyAyMjcuMDA4Qzg5LjYwNTEgMjI2LjkzNiA5MC4yNjg0IDIyNi44OTkgOTAuOTQwNCAyMjYuODk5SDMyOS41MTFDMzMwLjE4MyAyMjYuODk5IDMzMC44NDYgMjI2LjkzNiAzMzEuNDk4IDIyNy4wMDhDMzM0LjQxOSAyMjcuMzMgMzM3LjEyOCAyMjguMzUyIDMzOS40NTIgMjI5LjkwM1YyMDMuMTEyWk0zMzkuNDUyIDI0NC43MzlDMzM5LjQ1MiAyMzkuMzkzIDMzNS4yMDYgMjM1LjAzNiAzMjkuODkzIDIzNC44MzVDMzI5Ljc2NyAyMzQuODMgMzI5LjY0IDIzNC44MjggMzI5LjUxMSAyMzQuODI4SDkwLjk0MDRDODUuNDUwNSAyMzQuODI4IDgxIDIzOS4yNjUgODEgMjQ0LjczOVYyNzEuNTNMODEuMDcwNyAyNzEuNDgzQzgxLjI2NTMgMjcxLjM1NSA4MS40NjI1IDI3MS4yMyA4MS42NjI0IDI3MS4xMDlDODEuOTA4MyAyNzAuOTYgODIuMTU4MSAyNzAuODE3IDgyLjQxMTcgMjcwLjY3OUM4NC4zOTUzIDI2OS42MDUgODYuNjA1NCAyNjguODk0IDg4Ljk1MjMgMjY4LjYzNUM4OS4wMDUyIDI2OC42MjkgODkuMDU4IDI2OC42MjQgODkuMTExIDI2OC42MThDODkuNzEyNSAyNjguNTU3IDkwLjMyMjggMjY4LjUyNiA5MC45NDA0IDI2OC41MjZIMzI5LjUxMUMzMjkuNzM4IDI2OC41MjYgMzI5Ljk2NSAyNjguNTMgMzMwLjE5MiAyNjguNTM5QzMzMC42MzEgMjY4LjU1NSAzMzEuMDY3IDI2OC41ODcgMzMxLjQ5OCAyNjguNjM1QzMzNC40MTkgMjY4Ljk1NyAzMzcuMTI4IDI2OS45OCAzMzkuNDUyIDI3MS41M1YyNDQuNzM5Wk0zMzkuNDUyIDI4Ni4zNjZDMzM5LjQ1MiAyODEuMDIxIDMzNS4yMDYgMjc2LjY2MyAzMjkuODkzIDI3Ni40NjJMMzI5Ljg2NSAyNzYuNDYxQzMyOS43NDggMjc2LjQ1NyAzMjkuNjI5IDI3Ni40NTUgMzI5LjUxMSAyNzYuNDU1SDkwLjk0MDRDODUuNDUwNSAyNzYuNDU1IDgxIDI4MC44OTMgODEgMjg2LjM2NlYzMDYuMTg4QzgxIDMxMS42NjIgODUuNDUwNSAzMTYuMTAxIDkwLjk0MDQgMzE2LjEwMUgzMjkuNTExQzMzNS4wMDEgMzE2LjEwMSAzMzkuNDUyIDMxMS42NjIgMzM5LjQ1MiAzMDYuMTg4VjI4Ni4zNjZaIiBmaWxsPSJ3aGl0ZSIvPgo8cGF0aCBkPSJNMjY5Ljg2OCAxMzEuNzUyQzI2OS44NjggMTI2LjI3OCAyNzQuMzE4IDEyMS44NCAyNzkuODA4IDEyMS44NEgzMTEuNjE4QzMxNy4xMDggMTIxLjg0IDMyMS41NTggMTI2LjI3OCAzMjEuNTU4IDEzMS43NTJWMTYxLjQ4NUMzMjEuNTU4IDE2Ni45NTkgMzE3LjEwOCAxNzEuMzk2IDMxMS42MTggMTcxLjM5NkgyNzkuODA4QzI3NC4zMTggMTcxLjM5NiAyNjkuODY4IDE2Ni45NTkgMjY5Ljg2OCAxNjEuNDg1VjEzMS43NTJaIiBmaWxsPSJ3aGl0ZSIvPgo8L2c+CjxkZWZzPgo8Y2xpcFBhdGggaWQ9ImNsaXAwXzFfMTUiPgo8cmVjdCB3aWR0aD0iMjU5IiBoZWlnaHQ9IjIxMyIgZmlsbD0id2hpdGUiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDgxIDEwNCkiLz4KPC9jbGlwUGF0aD4KPC9kZWZzPgo8L3N2Zz4K",name:r="Rise Wallet",rdns:s="com.risechain.wallet"}="object"==typeof t?t:{};return function(e){const t=new CustomEvent("eip6963:announceProvider",{detail:Object.freeze(e)});window.dispatchEvent(t);const n=()=>window.dispatchEvent(t);return window.addEventListener("eip6963:requestProvider",n),()=>window.removeEventListener("eip6963:requestProvider",n)}({info:{icon:n,name:r,rdns:s,uuid:Zl()},provider:e})}function cx(e){return e.map((e=>{if("admin"===e.role)try{return Yp(Tv.Key,{id:e.id??e.publicKey,publicKey:e.publicKey,type:e.type,..."webauthn-p256"===e.type?{credentialId:e.privateKey?.credential?.id,privateKey:{credential:{id:e.privateKey?.credential?.id},rpId:e.privateKey?.rpId}}:{}})}catch{return}})).filter(Boolean)}function ux(e,{address:t}){return e.map((e=>{if(e.chainId&&"session"===e.role&&!(e.expiry>0&&e.expiry<BigInt(Math.floor(Date.now()/1e3))))try{return Yp(ov,cv(e,{address:t}))}catch{return}})).filter(Boolean)}function dx(e){return Ft(e.address)}function lx(e){return{...e,setup:e.setup??(()=>()=>{})}}async function fx(e){const{account:t,calls:n,permissionsId:r}=e;if(void 0!==r){if(null===r)return;const e=t.keys?.find((e=>e.publicKey===r&&e.privateKey));if(!e)throw new Error(`permission (id: ${r}) does not exist.`);return e}const s=t.keys?.find((e=>{if(!e.privateKey)return!1;if("session"!==e.role)return!1;if(e.expiry<BigInt(Math.floor(Date.now()/1e3)))return!1;const t=n.every((t=>e.permissions?.calls?.some((e=>{if(e.to&&e.to!==t.to)return!1;if(e.signature){if(!t.data)return!1;const n=If(t.data,0,4);if(kf(e.signature))return e.signature===n;if(Nb(e.signature)!==n)return!1}return!0}))));return!!t})),i=t.keys?.find((e=>"admin"===e.role&&e.privateKey));return s??i}const px=sv;function hx(e){const{expiry:t,feeToken:n,permissions:r,publicKey:s,type:i}=e;return{expiry:t,feeToken:n??null,key:{publicKey:s,type:i},permissions:r??{}}}async function mx(e,t={}){if(!e)return;const n={chainId:t.chainId??e.chainId,expiry:e.expiry??0,feeToken:e.feeToken,permissions:Mg(e,{feeTokens:t.feeTokens}),role:"session"};if(e?.key)return Ig({...n,publicKey:e.key.publicKey,type:e.key.type??"secp256k1"});if("function"==typeof globalThis.crypto?.subtle?.generateKey)try{return await xg(n)}catch(e){if(!function(e){if(!(e instanceof Error))return!1;const t=e.message?.toLowerCase()??"";return"TypeError"===e.name||"ReferenceError"===e.name||t.includes("subtle")||t.includes("generatekey")}(e))throw e}return gg(n)}const yx=/^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(:[0-9]{1,5})?$/,bx=/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(:[0-9]{1,5})?$/,gx=/^localhost(:[0-9]{1,5})?$/,wx=/^[a-zA-Z0-9]{8,}$/,vx=/^([a-zA-Z][a-zA-Z0-9+-.]*)$/,xx=/^(?:(?<scheme>[a-zA-Z][a-zA-Z0-9+-.]*):\/\/)?(?<domain>[a-zA-Z0-9+-.]*(?::[0-9]{1,5})?) (?:wants you to sign in with your Ethereum account:\n)(?<address>0x[a-fA-F0-9]{40})\n\n(?:(?<statement>.*)\n\n)?/,Ix=/(?:URI: (?<uri>.+))\n(?:Version: (?<version>.+))\n(?:Chain ID: (?<chainId>\d+))\n(?:Nonce: (?<nonce>[a-zA-Z0-9]+))\n(?:Issued At: (?<issuedAt>.+))(?:\nExpiration Time: (?<expirationTime>.+))?(?:\nNot Before: (?<notBefore>.+))?(?:\nRequest ID: (?<requestId>.+))?/;function Px(e){if(/[^a-z0-9:/?#[\]@!$&'()*+,;=.\-_~%]/i.test(e))return!1;if(/%[^0-9a-f]/i.test(e))return!1;if(/%[0-9a-f](:?[^0-9a-f]|$)/i.test(e))return!1;const t=function(e){return e.match(/(?:([^:/?#]+):)?(?:\/\/([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/)}(e),n=t[1],r=t[2],s=t[3],i=t[4],a=t[5];if(!(n?.length&&s&&s.length>=0))return!1;if(r?.length){if(0!==s.length&&!/^\//.test(s))return!1}else if(/^\/\//.test(s))return!1;if(!/^[a-z][a-z0-9+\-.]*$/.test(n.toLowerCase()))return!1;let o="";return o+=`${n}:`,r?.length&&(o+=`//${r}`),o+=s,i?.length&&(o+=`?${i}`),a?.length&&(o+=`#${a}`),o}class zx extends ul{constructor(e){const{field:t,metaMessages:n}=e;super(`Invalid Sign-In with Ethereum message field "${t}".`,{metaMessages:n}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Siwe.InvalidMessageFieldError"})}}async function Ex(e){const{address:t,authUrl:n,message:r,signature:s}=e,{chainId:i}=function(e){const{scheme:t,statement:n,...r}=e.match(xx)?.groups??{},{chainId:s,expirationTime:i,issuedAt:a,notBefore:o,requestId:c,...u}=e.match(Ix)?.groups??{},d=e.split("Resources:")[1]?.split("\n- ").slice(1);return{...r,...u,...s?{chainId:Number(s)}:{},...i?{expirationTime:new Date(i)}:{},...a?{issuedAt:new Date(a)}:{},...o?{notBefore:new Date(o)}:{},...c?{requestId:c}:{},...d?{resources:d}:{},...t?{scheme:t}:{},...n?{statement:n}:{}}}(r);return await fetch(n.verify,{body:JSON.stringify({address:t,chainId:i,message:r,signature:s,walletAddress:t}),credentials:"include",headers:{"Content-Type":"application/json"},method:"POST"}).then((e=>e.json()))}async function Ax(e,t,n){const{chainId:r=e.chain?.id,domain:s,uri:i,resources:a,version:o="1"}=t,{address:c}=n,u=t.authUrl?kx(t.authUrl):void 0;if(!r)throw new Error("`chainId` is required.");if(!s)throw new Error("`domain` is required.");if(!t.nonce&&!u?.nonce)throw new Error("`nonce` or `authUrl.nonce` is required.");if(!i)throw new Error("`uri` is required.");const d=await(async()=>{if(t.nonce)return t.nonce;if(!u?.nonce)throw new Error("`nonce` or `authUrl.nonce` is required.");const e=await fetch(u.nonce,{body:JSON.stringify({address:c,chainId:r,walletAddress:c}),headers:{"Content-Type":"application/json"},method:"POST"}),n=await e.json().catch((()=>{}));if(!n?.nonce)throw new Error("`nonce` or `authUrl.nonce` is required.");return n.nonce})(),l=function(e){const{chainId:t,domain:n,expirationTime:r,issuedAt:s=new Date,nonce:i,notBefore:a,requestId:o,resources:c,scheme:u,uri:d,version:l}=e;{if(t!==Math.floor(t))throw new zx({field:"chainId",metaMessages:["- Chain ID must be a EIP-155 chain ID.","- See https://eips.ethereum.org/EIPS/eip-155","",`Provided value: ${t}`]});if(!(yx.test(n)||bx.test(n)||gx.test(n)))throw new zx({field:"domain",metaMessages:["- Domain must be an RFC 3986 authority.","- See https://www.rfc-editor.org/rfc/rfc3986","",`Provided value: ${n}`]});if(!wx.test(i))throw new zx({field:"nonce",metaMessages:["- Nonce must be at least 8 characters.","- Nonce must be alphanumeric.","",`Provided value: ${i}`]});if(!Px(d))throw new zx({field:"uri",metaMessages:["- URI must be a RFC 3986 URI referring to the resource that is the subject of the signing.","- See https://www.rfc-editor.org/rfc/rfc3986","",`Provided value: ${d}`]});if("1"!==l)throw new zx({field:"version",metaMessages:["- Version must be '1'.","",`Provided value: ${l}`]});if(u&&!vx.test(u))throw new zx({field:"scheme",metaMessages:["- Scheme must be an RFC 3986 URI scheme.","- See https://www.rfc-editor.org/rfc/rfc3986#section-3.1","",`Provided value: ${u}`]});const r=e.statement;if(r?.includes("\n"))throw new zx({field:"statement",metaMessages:["- Statement must not include '\\n'.","",`Provided value: ${r}`]})}const f=dp(e.address,{checksum:!0}),p=`${u?`${u}://${n}`:n} wants you to sign in with your Ethereum account:\n${f}\n\n${e.statement?`${e.statement}\n`:""}`;let h=`URI: ${d}\nVersion: ${l}\nChain ID: ${t}\nNonce: ${i}\nIssued At: ${s.toISOString()}`;if(r&&(h+=`\nExpiration Time: ${r.toISOString()}`),a&&(h+=`\nNot Before: ${a.toISOString()}`),o&&(h+=`\nRequest ID: ${o}`),c){let e="\nResources:";for(const t of c){if(!Px(t))throw new zx({field:"resources",metaMessages:["- Every resource must be a RFC 3986 URI.","- See https://www.rfc-editor.org/rfc/rfc3986","",`Provided value: ${t}`]});e+=`\n- ${t}`}h+=e}return`${p}\n${h}`}({...t,address:n.address,chainId:r,domain:s,nonce:d,resources:a,uri:i,version:o});return l}function kx(e,t=""){if(!e)return;const n=(()=>{if("string"==typeof e){const t=e.replace(/\/$/,"");return{logout:t+"/logout",nonce:t+"/nonce",verify:t+"/verify"}}return e})();return{logout:Mx(n.logout,t),nonce:Mx(n.nonce,t),verify:Mx(n.verify,t)}}function Mx(e,t){return t&&e.startsWith("/")?t+e:e}function $x(e){return Yf(function(e){const t=mf(e);return hf("0x19",wf("Ethereum Signed Message:\n"+Pf(t)),t)}(e))}function Ox(e,t){const{as:n}=t,r=jx(e),s=function(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(rb);return n.bytes=e,n.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=t,n}(new Uint8Array(r.length));return r.encode(s),"Hex"===n?bf(s.bytes):s.bytes}function jx(e){return Array.isArray(e)?function(e){const t=e.reduce(((e,t)=>e+t.length),0),n=Sx(t);return{length:t<=55?1+t:1+n+t,encode(r){t<=55?r.pushByte(192+t):(r.pushByte(247+n),1===n?r.pushUint8(t):2===n?r.pushUint16(t):3===n?r.pushUint24(t):r.pushUint32(t));for(const{encode:t}of e)t(r)}}}(e.map((e=>jx(e)))):function(e){const t="string"==typeof e?Cf(e):e,n=Sx(t.length),r=1===t.length&&t[0]<128?1:t.length<=55?1+t.length:1+n+t.length;return{length:r,encode(e){1===t.length&&t[0]<128?e.pushBytes(t):t.length<=55?(e.pushByte(128+t.length),e.pushBytes(t)):(e.pushByte(183+n),1===n?e.pushUint8(t.length):2===n?e.pushUint16(t.length):3===n?e.pushUint24(t.length):e.pushUint32(t.length),e.pushBytes(t))}}}(e)}function Sx(e){if(e<=255)return 1;if(e<=65535)return 2;if(e<=16777215)return 3;if(e<=4294967295)return 4;throw new ul("Length is too large.")}function Nx(e){return function(e,t={}){const{presign:n}=t;return Yf(hf("0x05",function(e,t={}){const{as:n="Hex"}=t;return Ox(e,{as:n})}(function(e){const{address:t,chainId:n,nonce:r}=e,s=function(e){if(void 0!==e.r&&void 0!==e.s)return Ym(e)}(e);return[n?gf(n):"0x",t,r?gf(r):"0x",...s?Jm(s):[]]}(n?{address:e.address,chainId:e.chainId,nonce:e.nonce}:e))))}(e,{presign:!0})}async function Tx(e,t){const{account:n=e.account}=t,r=n?jg(n):void 0;if(!r)throw new Error("account is required.");const{domain:{name:s,version:i}}=await async function(e,t){const{address:n,factory:r,factoryData:s}=t;try{const[t,i,a,o,c,u,d]=await K(e,Ea,"readContract")({abi:Wa,address:n,functionName:"eip712Domain",factory:r,factoryData:s});return{domain:{name:i,version:a,chainId:Number(o),verifyingContract:c,salt:u},extensions:d,fields:t}}catch(e){const t=e;if("ContractFunctionExecutionError"===t.name&&"ContractFunctionZeroDataError"===t.cause.name)throw new Ha({address:n});throw t}}(e,{address:r.address});if(!e.chain)throw new Error("client.chain is required");return{chainId:e.chain.id,name:s,verifyingContract:r.address,version:i}}async function _x(e,t){const{account:n=e.account,chainIds:r}=t,s=n?jg(n):void 0;if(!s)throw new Error("account is required.");const i=await async function(e,t){const{address:n,chainIds:r}=t;try{const t="wallet_getKeys",s=await e.request({method:t,params:[Yp(Tw.Parameters,{address:n,chainIds:r})]});return Jp(Tw.Response,s)}catch(e){throw Vw(e),e}}(e,{address:s.address,chainIds:r});return Object.entries(i).flatMap((([e,t])=>t.map((t=>function(e,t){const{chainId:n}=t,{publicKey:r}=e,s=20===Pf(r)||0n===Ef(If(r,0,12)),i={};for(const t of e.permissions)"call"===t.type&&(i.calls??=[],i.calls.push({signature:t.selector,to:t.to===ug?void 0:t.to})),"spend"===t.type&&(i.spend??=[],i.spend.push({limit:t.limit,period:t.period,token:t.token}));return Ig({chainId:n,expiry:e.expiry,permissions:i,publicKey:e.publicKey,role:fg[e.role],type:s?"address":lg[e.type]})}(t,{chainId:Number(e)})))))}async function Rx(e,t){const{account:n=e.account,calls:r,chain:s=e.chain,feePayer:i,merchantUrl:a,nonce:o,preCalls:c,requiredFunds:u,revokeKeys:d}=t,l=n?jg(n):void 0,f=t.key??(l?Ng(l,{role:"admin"}):void 0),p=t.authorizeKeys?.some((e=>"session"===e.role)),{contracts:h,fees:{tokens:m}}=await qw(e,{chainId:s?.id}),y=p?h.orchestrator.address:void 0,b=(t.authorizeKeys??[]).map((e=>kg(e,{feeTokens:m,orchestrator:y}))),g=t.feeToken?t.feeToken:f?.permissions?.spend?.[0]?.token,w="boolean"==typeof c&&c,v="object"==typeof c?c.map((({context:e,signature:t})=>({...e.preCall,signature:t}))):void 0,x={address:l?.address,calls:r??[],capabilities:{authorizeKeys:b,meta:{feePayer:i,feeToken:g,nonce:o},preCall:w,preCalls:v,requiredFunds:u,revokeKeys:d?.map((e=>({hash:e.hash})))},chain:s,key:f?kg(f,{feeTokens:m}):void 0},I=await(async()=>{if(a){const t=Za({chain:e.chain,transport:Xd(a)});return await Lw(t,x).catch((t=>(console.error(t),Lw(e,x))))}return await Lw(e,x)})(),{capabilities:P,context:z,digest:E,signature:A,typedData:k}=I;if(a){if(!await Fw(e,{response:I._raw,signature:A}))throw new Error(`cannot verify integrity of \`wallet_prepareCalls\` response from ${a}`)}return{capabilities:{...P,quote:z.quote},context:z,digest:E,key:f,typedData:k}}async function Cx(e,t){const{address:n,authorizeKeys:r,chain:s=e.chain}=t;if(!s)throw new Error("chain is required.");const{contracts:i,fees:{tokens:a}}=await qw(e,{chainId:s.id}),o=t.delegation??i.accountProxy.address,c=r.some((e=>"session"===e.role))?i.orchestrator.address:void 0,u=r.map((e=>{const t="session"===e.role?e.permissions:{};return kg({...e,permissions:t},{feeTokens:a,orchestrator:c})})),{capabilities:d,chainId:l,context:f,digests:p,typedData:h}=await async function(e,t){const{address:n,chain:r=e.chain,delegation:s,...i}=t;try{const t="wallet_prepareUpgradeAccount",a=await e.request({method:t,params:[Yp(Rw.Parameters,Gl({address:n,capabilities:i,chainId:r?.id,delegation:s}))]},{retryCount:0});return Jp(Rw.Response,a)}catch(e){throw Vw(e),Kw(e),e}}(e,{address:n,authorizeKeys:u,chain:s,delegation:o});return{capabilities:d,chainId:l,context:{...f,account:jg({address:n,keys:r})},digests:p,typedData:h}}async function Bx(e,t){const{account:n=e.account,chain:r=e.chain,webAuthn:s}=t;if(!r)throw new Error("`chain` is required.");const i=n?jg(n):void 0;if(!i)throw new Error("`account` is required.");const a=t.key??Ng(i,t);if(!a&&!i.sign)throw new Error("`key` or `account` with `sign` is required");const o=await Promise.all((t.preCalls??[]).map((async n=>{if(n.signature)return n;const{authorizeKeys:a,key:o,calls:c,revokeKeys:u}=n,{context:d,digest:l}=await Rx(e,{account:i,authorizeKeys:a,calls:c,chain:r,feeToken:t.feeToken,key:o,preCalls:!0,revokeKeys:u});return{context:d,signature:await Ag(o,{address:null,payload:l,webAuthn:s})}}))),{capabilities:c,context:u,digest:d}=await Rx(e,{...t,account:i,chain:r,key:a,preCalls:o}),l=await(async()=>a?await Ag(a,{address:null,payload:d,webAuthn:s,wrap:!1}):await i.sign({hash:d}))();return await Dx(e,{capabilities:c.feeSignature?{feeSignature:c.feeSignature}:void 0,context:u,key:a,signature:l})}async function Dx(e,t){const{capabilities:n,context:r,key:s,signature:i}=t;return await async function(e,t){const{capabilities:n,context:r,key:s,signature:i}=t;try{const t="wallet_sendPreparedCalls",a=await e.request({method:t,params:[Yp(Bw.Parameters,{capabilities:n,context:{preCall:r.preCall,quote:r.quote},key:s?{prehash:s.prehash,publicKey:s.publicKey,type:s.type}:void 0,signature:i})]},{retryCount:0});return Jp(Bw.Response,a)}catch(e){throw Vw(e),Kw(e),e}}(e,{capabilities:n,context:r,key:s?kg(s):void 0,signature:i})}async function Ux(e,t){const{email:n,walletAddress:r}=t;return await async function(e,t){const{email:n,walletAddress:r}=t;try{const t="account_setEmail",s=await e.request({method:t,params:[Yp(Pw.Parameters,{email:n,walletAddress:r})]},{retryCount:0});return Jp(Pw.Response,s)}catch(e){throw Vw(e),Kw(e),e}}(e,{email:n,walletAddress:r})}async function qx(e,t){if(t.account){const{account:n}=t,r=[...n.keys??[],...t.authorizeKeys??[]].filter(((e,t,n)=>n.findIndex((t=>t.id===e.id))===t)),{digests:s,...i}=await Cx(e,{...t,address:n.address,authorizeKeys:r}),a={auth:await n.sign({hash:s.auth}),exec:await n.sign({hash:s.exec})};return await qx(e,{...i,signatures:a})}const{context:n,signatures:r}=t,s=jg(n.account);return await async function(e,t){const{context:n,signatures:r}=t;try{const t="wallet_upgradeAccount";await e.request({method:t,params:[Yp(Dw.Parameters,{context:n,signatures:r})]},{retryCount:0})}catch(e){throw Vw(e),Kw(e),e}}(e,{context:n,signatures:r}),s}async function Lx(e,t){const{chainId:n,email:r,signature:s,token:i,walletAddress:a}=t;return await async function(e,t){const{chainId:n,email:r,signature:s,token:i,walletAddress:a}=t;try{const t="account_verifyEmail",o=await e.request({method:t,params:[Yp(Ew.Parameters,{chainId:n,email:r,signature:s,token:i,walletAddress:a})]},{retryCount:0});return Jp(Ew.Response,o)}catch(e){throw Vw(e),Kw(e),e}}(e,{chainId:n,email:r,signature:s,token:i,walletAddress:a})}const Fx="0x8010801080108010801080108010801080108010801080108010801080108010",Kx=ub("(uint256 chainId, address delegation, uint256 nonce, uint8 yParity, uint256 r, uint256 s), address to, bytes data");function Gx(e){const{data:t,signature:n}=e;!function(e){if("string"==typeof e){if(If(e,-32)!==Fx)throw new Vx(e)}else Hm(e.authorization)}(e);const r=Lm({payload:Nx(e.authorization),signature:Ym(e.authorization)}),s=ob(Kx,[{...e.authorization,delegation:e.authorization.address,chainId:BigInt(e.authorization.chainId)},e.to??r,t??"0x"]);return hf(n,s,gf(Pf(s),{size:32}),Fx)}class Vx extends ul{constructor(e){super(`Value \`${e}\` is an invalid ERC-8010 wrapped signature.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SignatureErc8010.InvalidWrappedSignatureError"})}}async function Zx(e,t){const{address:n}=t,{authorization:r,data:s,to:i}=await async function(e,t){try{const n="wallet_getAuthorization",r=await Na((()=>e.request({method:n,params:[Yp(Ow.Parameters,t)]})),{cacheKey:`${e.uid}.${n}.${t.address}`});return Jp(Ow.Response,r)}catch(e){throw Vw(e),e}}(e,{address:n});return Gx({authorization:{...r,nonce:BigInt(r.nonce),r:BigInt(r.r),s:BigInt(r.s)},data:s,signature:t.signature,to:i})}function Hx(e,t){const{tokens:n}=t,r=n.filter((e=>e.interop));return e.map((e=>{if(e.address)return e;const t=r.find((t=>t.symbol===e.symbol));if(!t)throw new Error(`interop token not found: ${e.symbol}`);return{address:t.address,value:Wb(e.value,t.decimals)}}))}async function Wx(e,t){const{chain:n=e.chain}=t??{};return await qw(e,{chainId:n?.id}).then((e=>e.fees.tokens))}async function Yx(e,t){const{addressOrSymbol:n}=t;return(await Wx(e,t)).find(Yx.predicate(n))}async function Qx(e,t){const{chain:n=e.chain,store:r}=t??{},s=r?.getState()??{},i=t?.addressOrSymbol??s.feeToken,a=await Wx(e,{chain:n}).then((e=>e.filter((e=>e.feeToken)))),o=a?.find((e=>!!i&&("native"===i&&e.address===Fd||(!(!pp(i)||!fp(e.address,i))||i===e.symbol))));return o}function Jx(e={}){const t=e,{mock:n,multichain:r=!0,webAuthn:s}=t;let i,a;const o=(()=>{if("self"!==t.keystoreHost&&("undefined"==typeof window||"localhost"!==window.location?.hostname))return t.keystoreHost})();return lx({actions:{async addFunds(){throw new Ml},async createAccount(e){const{admins:t,email:r,label:a,permissions:c,internal:u,signInWithEthereum:d}=e,{client:l}=u,f=Sg(function(e={}){const{as:t="Hex"}=e,n=rd.utils.randomPrivateKey();return"Hex"===t?bf(n):n}()),p=await Wx(l),h=n?vg():await wg({createFn:s?.createFn,label:a||`${f.address.slice(0,8)}…${f.address.slice(-6)}`,rpId:o,userId:_f(f.address)}),m=await mx(c,{chainId:l.chain.id,feeTokens:p}),y=t?.map((e=>Ig(e))),b=await qx(l,{account:f,authorizeKeys:[h,...y??[],...m?[m]:[]]});i=f.address,r&&a&&await Ux(l,{email:a,walletAddress:b.address});const g=await(async()=>{if(!d)return;const e=await Ax(l,d,{address:b.address}),t=await Tg(f,{payload:$x(wf(e))});return{message:e,signature:await Zx(l,{address:b.address,signature:t})}})();return{account:{...b,signInWithEthereum:g}}},async getAccountVersion(e){const{address:t,internal:n}=e,{client:r}=n,{contracts:s}=await qw(r),{accountImplementation:i}=s,a=await Tx(r,{account:jg(i)}).then((e=>e.version)),o=await Tx(r,{account:t}).then((e=>e.version)).catch((()=>a));if(!o||!a)throw new Error("version not found.");return{current:o,latest:a}},async getAssets(e){const{account:t,chainFilter:n,assetFilter:r,assetTypeFilter:s,internal:i}=e,{client:a}=i,o=await async function(e,t){const{account:n,assetFilter:r,assetTypeFilter:s,chainFilter:i}=t;try{const t="wallet_getAssets",a=await e.request({method:t,params:[Yp(Sw.Parameters,{account:n,assetFilter:r,assetTypeFilter:s,chainFilter:i})]}),o=Jp(Sw.Response,a),c=Object.entries(o).reduce(((e,[t,n])=>(e[Af(t)]=n,e)),{}),u={};for(const e of Object.values(c))for(const t of e){const e=JSON.stringify(t.metadata);u[e]={...t,balance:t.balance+(u[e]?.balance??0n)}}return{...c,0:Object.values(u)}}catch(e){throw Vw(e),e}}(a,{account:t,assetFilter:r,assetTypeFilter:s,chainFilter:n});return o},async getCallsStatus(e){const{id:t,internal:n}=e,{client:r}=n,s=await async function(e,t){const{id:n}=t;try{const t="wallet_getCallsStatus",r=await e.request({method:t,params:[n]});return Jp(Nw.Response,r)}catch(e){throw Vw(e),e}}(r,{id:t});return{atomic:!0,chainId:gf(r.chain.id),id:t,receipts:s.receipts?.map((e=>({blockHash:e.blockHash,blockNumber:gf(e.blockNumber),gasUsed:gf(e.gasUsed),logs:e.logs,status:e.status,transactionHash:e.transactionHash}))),status:s.status,version:"1.0"}},async getCapabilities(e){const{chainIds:t,internal:n}=e,{client:s}=n,i={atomic:{status:"supported"},atomicBatch:{supported:!0},feeToken:{supported:!0,tokens:[]},merchant:{supported:!0},permissions:{supported:!0},requiredFunds:{supported:Boolean(r),tokens:[]}},a=await qw(s,{chainIds:t?t.map((e=>Af(e))):"all",raw:!0});return Object.entries(a).reduce(((e,[t,n])=>({...e,[t]:{...i,...n,feeToken:{supported:!0,tokens:n.fees.tokens},requiredFunds:{supported:Boolean(r),tokens:r?n.fees.tokens.filter((e=>e.interop)):[]}}})),{})},async getKeys(e){const{account:t,chainIds:n,internal:r}=e,{client:s}=r;return Vl([...await _x(s,{account:t,chainIds:n}),...t.keys??[]],(e=>e.publicKey))},async grantAdmin(e){const{account:t,internal:n}=e,{client:r}=n,i=Ig(e.key,{chainId:r.chain.id}),a=await Qx(r,{addressOrSymbol:e.feeToken,store:n.store}),{id:o}=await Bx(r,{account:t,authorizeKeys:[i],feeToken:a?.address,webAuthn:s});return await qa(r,{id:o,pollingInterval:500}),{key:i}},async grantPermissions(e){const{account:t,internal:n,permissions:r}=e,{client:s}=n,i=await Wx(s),a=await mx(r,{chainId:s.chain.id,feeTokens:i});if(!a)throw new Error("key to authorize not found.");const o=t.keys?.find((e=>"admin"===e.role&&e.privateKey));if(!o)throw new Error("admin key not found.");const{context:c,digest:u}=await Rx(s,{account:t,authorizeKeys:[a],key:o,preCalls:!0}),d=await Ag(o,{address:null,payload:u});return await Dx(s,{context:c,key:o,signature:d}),{key:a}},async loadAccounts(e){const{internal:t,permissions:r,signInWithEthereum:a}=e,{client:c}=t,u=await Wx(c),d=await mx(r,{chainId:c.chain.id,feeTokens:u}),{digest:l,digestType:f,message:p}=await(async()=>{if(a&&e.address){const t=await Ax(c,a,{address:e.address});return{context:void 0,digest:$x(wf(t)),digestType:"siwe",message:t}}return{context:void 0,digest:"0x",message:void 0}})(),{address:h,credentialId:m,webAuthnSignature:y}=await(async()=>{if(n){if(!i)throw new Error("address_internal not found.");return{address:i,credentialId:void 0}}if(e.address&&e.key)return{address:e.address,credentialId:e.key.credentialId};const t=await ag({challenge:l,getFn:s?.getFn,rpId:o}),r=t.raw.response;return{address:Lf(new Uint8Array(r.userHandle)),credentialId:t.raw.id,webAuthnSignature:t}})(),b=await _x(c,{account:h,chainIds:[c.chain.id]}),g=jg({address:h,keys:[...b,...d?[d]:[]].map(((e,t)=>0===t&&"webauthn-p256"===e.type?Pg({...e,credential:{id:m,publicKey:ep(e.publicKey)},id:h,rpId:o}):e))}),w=Ng(g,{role:"admin"}),v=await(async()=>{if("0x"!==l)return y?Og($g(y),{keyType:"webauthn-p256",publicKey:w.publicKey}):await Ag(w,{address:g.address,payload:l})})();if(d){const{context:e,digest:t}=await Rx(c,{account:g,authorizeKeys:[d],preCalls:!0}),n=await Ag(w,{address:null,payload:t});await Dx(c,{context:e,key:w,signature:n})}const x=await(async()=>{if(a){if("siwe"===f&&p&&v){const e=await Zx(c,{address:g.address,signature:v});return{message:p,signature:e}}{const e=await Ax(c,a,{address:g.address}),t=await Tg(g,{payload:$x(wf(e)),role:"admin"});return{message:e,signature:await Zx(c,{address:g.address,signature:t})}}}})();return{accounts:[{...g,signInWithEthereum:x}]}},async prepareCalls(e){const{account:t,calls:n,internal:s,merchantUrl:i}=e,{client:a}=s,o=e.key??await fx({account:t,calls:n});if(!o)throw new Error("cannot find authorized key to sign with.");const[c,u]=await Promise.all([Wx(a),Qx(a,{addressOrSymbol:e.feeToken,store:s.store})]),d=Hx(e.requiredFunds??[],{tokens:c}),{capabilities:l,context:f,digest:p,typedData:h}=await Rx(a,{account:t,calls:n,feeToken:u?.address,key:o,merchantUrl:i,requiredFunds:r?d:void 0}),m=f.quote?.quotes??[],y=m[m.length-1];return{account:t,capabilities:{...l,quote:f.quote},chainId:a.chain.id,context:{...f,account:t,calls:n,nonce:y?.intent.nonce},digest:p,key:o,typedData:h}},async prepareUpgradeAccount(e){const{address:t,email:r,label:i,internal:c,permissions:u}=e,{client:d}=c,[l,f]=await Promise.all([Wx(d),Qx(d,{store:c.store})]),p=n?vg():await wg({createFn:s?.createFn,label:i||`${t.slice(0,8)}…${t.slice(-6)}`,rpId:o,userId:_f(t)}),h=await mx(u,{chainId:d.chain.id,feeTokens:l}),{context:m,digests:y}=await Cx(d,{address:t,authorizeKeys:[p,...h?[h]:[]],feeToken:f?.address});return r&&(a=i),{context:m,digests:y}},async revokeAdmin(e){const{account:t,id:n,internal:r}=e,{client:i}=r,a=t.keys?.find((e=>e.id===n));if(a){if("webauthn-p256"===a.type&&1===t.keys?.filter((e=>"webauthn-p256"===e.type)).length)throw new Error("revoke the only WebAuthn key left.");try{const n=await Qx(i,{addressOrSymbol:e.feeToken,store:r.store}),{id:o}=await Bx(i,{account:t,feeToken:n?.address,revokeKeys:[a],webAuthn:s});await qa(i,{id:o})}catch(e){const t=e;if("Rpc.ExecutionError"===t.name&&"KeyDoesNotExist"===t.abiError?.name)return;throw e}}},async revokePermissions(e){const{account:t,id:n,internal:r}=e,{client:i}=r,a=t.keys?.find((e=>e.id===n));if(a){if("admin"===a.role)throw new Error("cannot revoke admins.");try{const n=await Qx(i,{addressOrSymbol:e.feeToken,store:r.store}),{id:o}=await Bx(i,{account:t,feeToken:n?.address,revokeKeys:[a],webAuthn:s});await qa(i,{id:o})}catch(e){const t=e;if("Rpc.ExecutionError"===t.name&&"KeyDoesNotExist"===t.abiError?.name)return;throw e}}},async sendCalls(e){const{account:t,asTxHash:n,calls:i,internal:a,merchantUrl:o}=e,{client:c}=a,u=await fx({account:t,calls:i,permissionsId:e.permissionsId}),[d,l]=await Promise.all([Wx(c),Qx(c,{addressOrSymbol:e.feeToken,store:a.store})]),f=Hx(e.requiredFunds??[],{tokens:d}),p=await Bx(c,{account:t,calls:i,feeToken:l?.address,key:u,merchantUrl:o,requiredFunds:r?f:void 0,webAuthn:s});if(n){const{id:e,receipts:t,status:n}=await qa(c,{id:p.id,pollingInterval:500});if(!t?.[0]){if("success"===n)throw new _l({message:"Call bundle with id: "+e+" not found."});throw new yl({message:"Transaction failed under call bundle id: "+e+"."})}return{id:t[0].transactionHash}}return p},async sendPreparedCalls(e){const{context:t,key:n,internal:r,signature:s}=e,{client:i}=r,{id:a}=await Dx(i,{context:t,key:n,signature:s});return a},async signPersonalMessage(e){const{account:t,data:n,internal:r}=e,{client:i}=r,a=t.keys?.find((e=>"admin"===e.role&&e.privateKey));if(!a)throw new Error("cannot find admin key to sign with.");const o=await Tg(t,{key:a,payload:$x(n),webAuthn:s});return Zx(i,{address:t.address,signature:o})},async signTypedData(e){const{account:t,internal:n}=e,{client:r}=n,i=t.keys?.find((e=>"admin"===e.role&&e.privateKey));if(!i)throw new Error("cannot find admin key to sign with.");const a=function(e,t){return JSON.parse(e,((e,n)=>{const r=n;return"string"==typeof r&&r.endsWith(ol)?BigInt(r.slice(0,-ol.length)):"function"==typeof t?t(e,r):r}))}(e.data),o="Orchestrator"===a.domain?.name,c=await Tg(t,{key:i,payload:gb(a),replaySafe:!o,webAuthn:s});return o?c:Zx(r,{address:t.address,signature:c})},async upgradeAccount(e){const{account:t,context:n,internal:r,signatures:s}=e,{client:i}=r;return await qx(i,{context:n,signatures:s}),a&&await Ux(i,{email:a,walletAddress:t.address}),{account:t}},async verifyEmail(e){const{account:t,chainId:n,email:r,token:i,internal:a,walletAddress:o}=e,{client:c}=a,u=t.keys?.find((e=>"admin"===e.role&&e.privateKey));if(!u)throw new Error("cannot find admin key to sign with.");const d=await Tg(t,{key:u,payload:Yf(wf(`${r}${i}`)),webAuthn:s});return await Lx(c,{chainId:n,email:r,signature:d,token:i,walletAddress:o})}},config:e,name:"rpc"})}async function Xx(e,t){const{config:{feeToken:n}}=e,{feeToken:r}=t??{};return r??n}function eI(e,{storage:t}){if(!e)return;const n=kx(e,"undefined"!=typeof window?window.location.origin:void 0);return n&&t.setItem("porto.authUrl",n),n}!function(e){e.predicate=function(e){return t=>!!e&&(pp(e)?fp(t.address,e):"native"===e?t.address===Fd:e===t.symbol)}}(Yx||(Yx={}));const tI=new Map,nI=e=>{const t=tI.get(e);return t?Object.fromEntries(Object.entries(t.stores).map((([e,t])=>[e,t.getState()]))):{}},rI=e=>{var t,n;if(!e)return;const r=e.split("\n"),s=r.findIndex((e=>e.includes("api.setState")));if(s<0)return;const i=(null==(t=r[s+1])?void 0:t.trim())||"";return null==(n=/.+ (.+) .+/.exec(i))?void 0:n[1]},sI=(e,t={})=>(n,r,s)=>{const{enabled:i,anonymousActionType:a,store:o,...c}=t;let u;try{u=(null==i||i)&&window.__REDUX_DEVTOOLS_EXTENSION__}catch(e){}if(!u)return e(n,r,s);const{connection:d,...l}=((e,t,n)=>{if(void 0===e)return{type:"untracked",connection:t.connect(n)};const r=tI.get(n.name);if(r)return{type:"tracked",store:e,...r};const s={connection:t.connect(n),stores:{}};return tI.set(n.name,s),{type:"tracked",store:e,...s}})(o,u,c);let f=!0;s.setState=(e,t,i)=>{const u=n(e,t);if(!f)return u;const l=void 0===i?{type:a||rI((new Error).stack)||"anonymous"}:"string"==typeof i?{type:i}:i;return void 0===o?(null==d||d.send(l,r()),u):(null==d||d.send({...l,type:`${o}/${l.type}`},{...nI(c.name),[o]:s.getState()}),u)},s.devtools={cleanup:()=>{d&&"function"==typeof d.unsubscribe&&d.unsubscribe(),((e,t)=>{if(void 0===t)return;const n=tI.get(e);n&&(delete n.stores[t],0===Object.keys(n.stores).length&&tI.delete(e))})(c.name,o)}};const p=(...e)=>{const t=f;f=!1,n(...e),f=t},h=e(s.setState,r,s);if("untracked"===l.type?null==d||d.init(h):(l.stores[l.store]=s,null==d||d.init(Object.fromEntries(Object.entries(l.stores).map((([e,t])=>[e,e===l.store?h:t.getState()]))))),s.dispatchFromDevtools&&"function"==typeof s.dispatch){let e=!1;const t=s.dispatch;s.dispatch=(...n)=>{"__setState"!==n[0].type||e||(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),e=!0),t(...n)}}return d.subscribe((e=>{var t;switch(e.type){case"ACTION":return"string"!=typeof e.payload?void console.error("[zustand devtools middleware] Unsupported action format"):iI(e.payload,(e=>{if("__setState"!==e.type)s.dispatchFromDevtools&&"function"==typeof s.dispatch&&s.dispatch(e);else{if(void 0===o)return void p(e.state);1!==Object.keys(e.state).length&&console.error('\n [zustand devtools middleware] Unsupported __setState action format.\n When using \'store\' option in devtools(), the \'state\' should have only one key, which is a value of \'store\' that was passed in devtools(),\n and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }\n ');const t=e.state[o];if(null==t)return;JSON.stringify(s.getState())!==JSON.stringify(t)&&p(t)}}));case"DISPATCH":switch(e.payload.type){case"RESET":return p(h),void 0===o?null==d?void 0:d.init(s.getState()):null==d?void 0:d.init(nI(c.name));case"COMMIT":return void 0===o?void(null==d||d.init(s.getState())):null==d?void 0:d.init(nI(c.name));case"ROLLBACK":return iI(e.state,(e=>{if(void 0===o)return p(e),void(null==d||d.init(s.getState()));p(e[o]),null==d||d.init(nI(c.name))}));case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return iI(e.state,(e=>{void 0!==o?JSON.stringify(s.getState())!==JSON.stringify(e[o])&&p(e[o]):p(e)}));case"IMPORT_STATE":{const{nextLiftedState:n}=e.payload,r=null==(t=n.computedStates.slice(-1)[0])?void 0:t.state;if(!r)return;return p(void 0===o?r:r[o]),void(null==d||d.send(null,n))}case"PAUSE_RECORDING":return f=!f}return}})),h},iI=(e,t)=>{let n;try{n=JSON.parse(e)}catch(e){console.error("[zustand devtools middleware] Could not parse the received json",e)}void 0!==n&&t(n)},aI=e=>(t,n,r)=>{const s=r.subscribe;r.subscribe=(e,t,n)=>{let i=e;if(t){const s=(null==n?void 0:n.equalityFn)||Object.is;let a=e(r.getState());i=n=>{const r=e(n);if(!s(a,r)){const e=a;t(a=r,e)}},(null==n?void 0:n.fireImmediately)&&t(a,a)}return s(i)};return e(t,n,r)};function oI(e,t){let n;try{n=e()}catch(e){return}const r={getItem:e=>{var r;const s=e=>null===e?null:JSON.parse(e,null==t?void 0:t.reviver),i=null!=(r=n.getItem(e))?r:null;return i instanceof Promise?i.then(s):s(i)},setItem:(e,r)=>n.setItem(e,JSON.stringify(r,null==t?void 0:t.replacer)),removeItem:e=>n.removeItem(e)};return r}const cI=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then:e=>cI(e)(n),catch(e){return this}}}catch(e){return{then(e){return this},catch:t=>cI(t)(e)}}},uI=(e,t)=>(n,r,s)=>{let i={storage:oI((()=>localStorage)),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},a=!1;const o=new Set,c=new Set;let u=i.storage;if(!u)return e(((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),n(...e)}),r,s);const d=()=>{const e=i.partialize({...r()});return u.setItem(i.name,{state:e,version:i.version})},l=s.setState;s.setState=(e,t)=>(l(e,t),d());const f=e(((...e)=>(n(...e),d())),r,s);let p;s.getInitialState=()=>f;const h=()=>{var e,t;if(!u)return;a=!1,o.forEach((e=>{var t;return e(null!=(t=r())?t:f)}));const s=(null==(t=i.onRehydrateStorage)?void 0:t.call(i,null!=(e=r())?e:f))||void 0;return cI(u.getItem.bind(u))(i.name).then((e=>{if(e){if("number"!=typeof e.version||e.version===i.version)return[!1,e.state];if(i.migrate){const t=i.migrate(e.state,e.version);return t instanceof Promise?t.then((e=>[!0,e])):[!0,t]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}return[!1,void 0]})).then((e=>{var t;const[s,a]=e;if(p=i.merge(a,null!=(t=r())?t:f),n(p,!0),s)return d()})).then((()=>{null==s||s(p,void 0),p=r(),a=!0,c.forEach((e=>e(p)))})).catch((e=>{null==s||s(void 0,e)}))};return s.persist={setOptions:e=>{i={...i,...e},e.storage&&(u=e.storage)},clearStorage:()=>{null==u||u.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>h(),hasHydrated:()=>a,onHydrate:e=>(o.add(e),()=>{o.delete(e)}),onFinishHydration:e=>(c.add(e),()=>{c.delete(e)})},i.skipHydration||h(),p||f},dI=e=>{let t;const n=new Set,r=(e,r)=>{const s="function"==typeof e?e(t):e;if(!Object.is(s,t)){const e=t;t=(null!=r?r:"object"!=typeof s||null===s)?s:Object.assign({},t,s),n.forEach((n=>n(t,e)))}},s=()=>t,i={setState:r,getState:s,getInitialState:()=>a,subscribe:e=>(n.add(e),()=>n.delete(e))},a=t=e(r,s,i);return i},lI=e=>e?dI(e):dI;function fI(e){return new Promise(((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)}))}function pI(e,t){const n=indexedDB.open(e);n.onupgradeneeded=()=>n.result.createObjectStore(t);const r=fI(n);return(e,n)=>r.then((r=>n(r.transaction(t,e).objectStore(t))))}let hI;function mI(){return hI||(hI=pI("keyval-store","keyval")),hI}const yI="undefined"!=typeof window&&"undefined"!=typeof document,bI={announceProvider:!0,chains:al,mode:yI?function(e={}){const{fallback:t=Jx(),host:n=Ql.prod,renderer:r=Jl(),theme:s,themeController:i}=e,a=new Set,o=function(e={}){let t=e.id??0;return{prepare:e=>function(e){return{...e,jsonrpc:"2.0"}}({id:t++,...e}),get id(){return t}}}();function c(e){return Dl({async request(t){const n=o.prepare(t);return e.setState((e=>{const t=e.accounts[0],r=t?.keys?.find((e=>"admin"===e.role&&"webauthn-p256"===e.type));return{...e,requestQueue:[...e.requestQueue,{account:t?{address:t.address,key:r?{credentialId:r?.credentialId,publicKey:r.publicKey}:void 0}:void 0,request:n,status:"pending"}]}})),new Promise(((t,r)=>{const s=i=>{const o=i.find((e=>e.request.id===n.id));if(!o&&0===i.length)return a.delete(s),void r(new Al);o&&("success"!==o.status&&"error"!==o.status||(a.delete(s),"success"===o.status?t(o.result):r(Ul(o.error)),e.setState((e=>({...e,requestQueue:e.requestQueue.filter((e=>e.request.id!==n.id))})))))};a.add(s)}))}},{schema:null})}return lx({actions:{async addFunds(e){const{internal:t}=e,{request:n,store:r}=t;if("wallet_addFunds"!==n.method)throw new Error("Cannot add funds for method: "+n.method);const s=c(r);return await s.request(n)},async createAccount(e){const{internal:t}=e,{client:n,config:r,request:s,store:i}=t,{storage:a}=r,o=c(i),u=await(async()=>{if("wallet_connect"===s.method){const[{capabilities:e,chainIds:t}]=s._decoded.params??[{}],i=eI(e?.signInWithEthereum?.authUrl??r.authUrl,{storage:a}),c=s.params?.[0]?.capabilities?.signInWithEthereum,u=await mx(e?.grantPermissions,{chainId:n.chain.id}),d=u?Yp(px,hx(u)):void 0,{accounts:l}=await o.request({...s,params:[{capabilities:{...s.params?.[0]?.capabilities,grantPermissions:d,signInWithEthereum:i||c?{...c,authUrl:i}:void 0},chainIds:t?.map((e=>gf(e)))}]}),[f]=l;if(!f)throw new Error("no account found.");const p=f.capabilities?.admins?.map((e=>Ig(e,{chainId:n.chain.id}))).filter(Boolean),h=f.capabilities?.permissions?.map((e=>{try{const t=uv(Jp(ov,e));return t.id===u?.id?{...t,...u,permissions:t.permissions}:t}catch{return}})).filter(Boolean),m=await(async()=>{if(!f.capabilities?.signInWithEthereum)return;const{message:e,signature:t}=f.capabilities.signInWithEthereum;if(!i)return{message:e,signature:t};const{token:n}=await Ex({address:f.address,authUrl:i,message:e,signature:t});return{message:e,signature:t,token:n}})();return{...jg({address:f.address,keys:[...p??[],...h??[]]}),signInWithEthereum:m}}throw new Error(`Account creation not supported on method: ${s.method}`)})();return{account:u}},async disconnect(e){const{internal:t}=e,{config:n}=t,{storage:r}=n,s=await r.getItem("porto.authUrl")||void 0,i=eI(n.authUrl??s,{storage:r});i&&await fetch(i.logout,{credentials:"include",method:"POST"}).catch((()=>{}))},async getAccountVersion(e){const{internal:n}=e,{store:s,request:i}=n;if("wallet_getAccountVersion"!==i.method)throw new Error("Cannot get version for method: "+i.method);if(!r.supportsHeadless)return t.actions.getAccountVersion(e);const a=c(s);return await a.request(i)},async getAssets(e){const{internal:n}=e,{store:s,request:i}=n;if("wallet_getAssets"!==i.method)throw new Error("Cannot get assets for method: "+i.method);if(!r.supportsHeadless)return t.actions.getAssets(e);const a=c(s),o=await a.request(i);return Jp(Zv.Response,o)},async getCallsStatus(e){const{internal:n}=e,{store:s,request:i}=n;if("wallet_getCallsStatus"!==i.method)throw new Error("Cannot get status for method: "+i.method);if(!r.supportsHeadless)return t.actions.getCallsStatus(e);const a=c(s);return await a.request(i)},async getCapabilities(e){const{internal:n}=e,{store:s,request:i}=n;if("wallet_getCapabilities"!==i.method)throw new Error("Cannot get capabilities for method: "+i.method);if(!r.supportsHeadless)return t.actions.getCapabilities(e);const a=c(s);return await a.request(i)},async getKeys(e){const{account:n,chainIds:s,internal:i}=e,{store:a}=i;return Vl([...await(async()=>{if(!r.supportsHeadless)return t.actions.getKeys(e);const i=c(a),o=await i.request({method:"wallet_getKeys",params:[Yp(Yv.Parameters,{address:n.address,chainIds:s})]});return Jp(Yv.Response,o)})(),...n.keys??[]],(e=>e.publicKey))},async grantAdmin(e){const{internal:t}=e,{request:n,store:r}=t;if("wallet_grantAdmin"!==n.method)throw new Error("Cannot authorize admin for method: "+n.method);const[s]=n._decoded.params,i=Ig(s.key);if(!i)throw new Error("no key found.");const a=await Xx(t,e),o=c(r);return await o.request({method:"wallet_grantAdmin",params:[{...n.params?.[0],capabilities:{...n.params?.[0]?.capabilities,feeToken:a}}]}),{key:i}},async grantPermissions(e){const{internal:t}=e,{client:n,request:r,store:s}=t;if("wallet_grantPermissions"!==r.method)throw new Error("Cannot grant permissions for method: "+r.method);const[{address:i,...a}]=r._decoded.params,o=await mx(a,{chainId:n.chain.id});if(!o)throw new Error("no key found.");const u=Yp(px,hx(o)),d=c(s);return await d.request({method:"wallet_grantPermissions",params:[u]}),{key:o}},async loadAccounts(e){const{internal:t}=e,{client:n,config:r,store:s}=t,{storage:i}=r,a=c(s),o=t.request;if("wallet_connect"!==o.method&&"eth_requestAccounts"!==o.method)throw new Error("Cannot load accounts for method: "+o.method);const u=await(async()=>{const[e]=o._decoded.params??[],{capabilities:t}=e??{},s=eI(t?.signInWithEthereum?.authUrl??r.authUrl,{storage:i}),c=o.params?.[0]?.capabilities?.signInWithEthereum,u=await mx(t?.grantPermissions,{chainId:n.chain.id}),d=u?Yp(px,hx(u)):void 0,{accounts:l}=await a.request({method:"wallet_connect",params:[{...o.params?.[0],capabilities:{...o.params?.[0]?.capabilities,grantPermissions:d,signInWithEthereum:s||c?{...c,authUrl:s}:void 0}}]});return Promise.all(l.map((async e=>{const t=e.capabilities?.admins?.map((e=>Ig(e))).filter(Boolean),n=e.capabilities?.permissions?.map((e=>{try{const t=uv(Jp(ov,e));return t.id===u?.id?{...t,...u,permissions:t.permissions}:t}catch{return}})).filter(Boolean),r=await(async()=>{if(!e.capabilities?.signInWithEthereum)return;const{message:t,signature:n}=e.capabilities.signInWithEthereum;if(!s)return{message:t,signature:n};const{token:r}=await Ex({address:e.address,authUrl:s,message:t,signature:n});return{message:t,signature:n,token:r}})();return{...jg({address:e.address,keys:[...t??[],...n??[]]}),signInWithEthereum:r}})))})();return{accounts:u}},async prepareCalls(e){const{account:n,internal:s}=e,{store:i,request:a}=s;if("wallet_prepareCalls"!==a.method)throw new Error("Cannot prepare calls for method: "+a.method);if(!r.supportsHeadless)return t.actions.prepareCalls(e);const o=await Xx(s,e),u=c(i),d=Jp(Qv.Response,await u.request({...a,params:[{...a.params?.[0],capabilities:{...a.params?.[0]?.capabilities,feeToken:o}}]}));return{account:n,chainId:Number(d.chainId),context:d.context,digest:d.digest,key:d.key,typedData:d.typedData}},async prepareUpgradeAccount(e){const{internal:n}=e,{client:s,store:i,request:a}=n;if("wallet_prepareUpgradeAccount"!==a.method)throw new Error("Cannot prepare upgrade for method: "+a.method);if(!r.supportsHeadless)return t.actions.prepareUpgradeAccount(e);const[{capabilities:o}]=a._decoded.params??[{}],u=await mx(o?.grantPermissions,{chainId:s.chain.id}),d=u?Yp(px,hx(u)):void 0,l=c(i),{context:f,digests:p}=await l.request({...a,params:[{...a.params?.[0],capabilities:{...a.params?.[0]?.capabilities,grantPermissions:d}}]}),h=f.account.keys?.map((e=>e.id===u?.id?{...e,...u}:e));return{context:{...f,account:{...f.account,keys:h}},digests:p}},async revokeAdmin(e){const{account:t,id:n,internal:r}=e,{store:s,request:i}=r;if("wallet_revokeAdmin"!==i.method)throw new Error("Cannot revoke admin for method: "+i.method);const a=t.keys?.find((e=>e.id===n));if(!a)return;if("webauthn-p256"===a.type&&1===t.keys?.filter((e=>"webauthn-p256"===e.type)).length)throw new Error("revoke the only WebAuthn key left.");const o=await Xx(r,e),u=c(s);return await u.request({...i,params:[{...i.params?.[0],capabilities:{...i.params?.[0]?.capabilities,feeToken:o}}]})},async revokePermissions(e){const{account:t,id:n,internal:r}=e,{store:s,request:i}=r;if("wallet_revokePermissions"!==i.method)throw new Error("Cannot revoke permissions for method: "+i.method);const a=t.keys?.find((e=>e.id===n));if(!a)return;if("admin"===a.role)throw new Error("cannot revoke permissions.");const o=c(s);return await o.request(i)},async sendCalls(e){const{account:n,asTxHash:s,calls:i,internal:a,merchantUrl:o,requiredFunds:u}=e,{client:d,store:l,request:f}=a,p=c(l),h=await Xx(a,e),m=await fx({account:n,calls:i,permissionsId:e.permissionsId});if(m&&"session"===m.role){if(!r.supportsHeadless)return t.actions.sendCalls(e);try{const e=await p.request(Yp(Qv.Request,{method:"wallet_prepareCalls",params:[{calls:i,capabilities:{..."wallet_sendCalls"===f._decoded.method?f._decoded.params?.[0]?.capabilities:void 0,feeToken:h,merchantUrl:o,requiredFunds:u},chainId:d.chain.id,from:n.address,key:m}]})),t=e.capabilities?.quote?.quotes??[],r=t.some(((e,n)=>!(n===t.length-1&&t.length>1)&&Ef(e.feeTokenDeficit)>0n));if(r)throw new Error("insufficient funds");const a=await Ag(m,{address:null,payload:e.digest,wrap:!1}),c=(await p.request({method:"wallet_sendPreparedCalls",params:[{...e,signature:a}]}))[0];if(!c)throw new Error("id not found");if(s){const{id:e,receipts:t,status:n}=await qa(d,{id:c.id,pollingInterval:500});if(!t?.[0]){if("success"===n)throw new _l({message:"Call bundle with id: "+e+" not found."});throw new yl({message:"Transaction failed under call bundle id: "+e+"."})}return{id:t[0].transactionHash}}return c}catch{}}if("eth_sendTransaction"===f.method){return{id:await p.request({...f,params:[{...f.params?.[0],capabilities:{feeToken:h,merchantUrl:o}}]})}}if("wallet_sendCalls"===f.method){return await p.request({method:"wallet_sendCalls",params:[{...f.params?.[0],capabilities:{...f.params?.[0]?.capabilities,feeToken:h,merchantUrl:o}}]})}throw new Error("Cannot execute for method: "+f.method)},async sendPreparedCalls(e){const{internal:n}=e,{store:s,request:i}=n;if("wallet_sendPreparedCalls"!==i.method)throw new Error("Cannot send prepared calls for method: "+i.method);if(!r.supportsHeadless)return t.actions.sendPreparedCalls(e);const a=c(s),o=await a.request(i),u=o[0]?.id;if(!u)throw new Error("id not found");return u},async signPersonalMessage(e){const{internal:t}=e,{store:n,request:r}=t;if("personal_sign"!==r.method)throw new Error("Cannot sign personal message for method: "+r.method);const s=c(n);return await s.request(r)},async signTypedData(e){const{internal:t}=e,{store:n,request:r}=t;if("eth_signTypedData_v4"!==r.method)throw new Error("Cannot sign typed data for method: "+r.method);const s=c(n);return await s.request(r)},async switchChain(e){const{internal:t}=e,{store:n,request:s}=t;if("wallet_switchEthereumChain"!==s.method)throw new Error("Cannot switch chain for method: "+s.method);if(!r.supportsHeadless)return;const i=c(n);return await i.request(s)},async upgradeAccount(e){const{account:t,internal:n}=e,{store:r,request:s}=n;if("wallet_upgradeAccount"!==s.method)throw new Error("Cannot upgrade account for method: "+s.method);const i=c(r);return await i.request(s),{account:t}},async verifyEmail(e){const{internal:t}=e,{request:n,store:r}=t;if("account_verifyEmail"!==n.method)throw new Error("Cannot verify email for method: "+n.method);const s=c(r);return await s.request(n)}},config:e,name:"dialog",setup(e){const{internal:t}=e,{store:o}=t,c=r.setup({host:n,internal:t,theme:s,themeController:i}),u=o.subscribe((e=>e.requestQueue),(e=>{for(const t of a)t(e);const t=e.map((e=>"pending"===e.status?e:void 0)).filter(Boolean);c.syncRequests(t).catch((()=>{})),0===t.length&&c.close()}));return()=>{u(),c.destroy()}}})}({host:Ql.prod}):Jx(),relay:Xd("https://relay.wallet.risechain.com"),storage:yI&&"undefined"!=typeof indexedDB?function(){const e="undefined"!=typeof indexedDB?pI("porto","store"):void 0;return{async getItem(t){const n=await function(e,t=mI()){return t("readonly",(t=>fI(t.get(e))))}(t,e);return null===n?null:n},async removeItem(t){await function(e,t=mI()){return t("readwrite",(t=>(t.delete(e),fI(t.transaction))))}(t,e)},async setItem(t,n){await function(e,t,n=mI()){return n("readwrite",(n=>(n.put(t,e),fI(n.transaction))))}(t,Gl(n),e)},sizeLimit:52428800}}():function(){const e=new Map;return{getItem:t=>e.get(t)??null,removeItem(t){e.delete(t)},setItem(t,n){e.set(t,n)},sizeLimit:Number.POSITIVE_INFINITY}}(),storageKey:"risewallet.store"};function gI(t){return e.__awaiter(this,void 0,void 0,(function*(){const e=function(e={}){const t=e.chains??bI.chains,n=Object.fromEntries(t.map((t=>[t.id,e.transports?.[t.id]??Xd()]))),r={announceProvider:e.announceProvider??bI.announceProvider,authUrl:e.authUrl,chains:t,feeToken:e.feeToken,merchantUrl:e.merchantUrl,mode:e.mode??bI.mode,relay:e.relay??bI.relay,storage:e.storage??bI.storage,storageKey:e.storageKey??bI.storageKey,transports:n},s=lI(sI(aI(uI((e=>({accounts:[],chainIds:r.chains.map((e=>e.id)),feeToken:r.feeToken,requestQueue:[]})),{merge(e,t){const n=e,s=r.chains.find((e=>e.id===n.chainIds[0]))?.id??r.chains[0].id,i=[s,...r.chains.map((e=>e.id)).filter((e=>e!==s))];return{...t,...n,chainIds:i}},name:r.storageKey,partialize:e=>({accounts:e.accounts.map((e=>Gl(e))),chainIds:e.chainIds}),storage:r.storage,version:5}))));let i=r.mode;const a={config:r,getMode:()=>i,id:Zl(),setMode:e=>(c?.(),i=e,c=e.setup({internal:a}),c),store:s},o=ax(a);let c=null!==i?i.setup({internal:a}):()=>{};return{_internal:a,config:r,destroy(){c(),o._internal.destroy()},provider:o}}();return e.provider}))}var wI=Object.freeze({__proto__:null,default:function(t,n){var r,s,i,a,o;return e.__awaiter(this,void 0,void 0,(function*(){const t=yield gI();if(!t)throw new Error("Failed to create Rise wallet provider");return null===(r=t.on)||void 0===r||r.call(t,"connect",n.connect),null===(s=t.on)||void 0===s||s.call(t,"disconnect",n.disconnect),null===(i=t.on)||void 0===i||i.call(t,"accountsChanged",n.accountsChanged),null===(a=t.on)||void 0===a||a.call(t,"chainChanged",n.chainChanged),null===(o=t.on)||void 0===o||o.call(t,"message",n.message),yield t.request({method:"eth_requestAccounts"}),e.convertWeb3Provider(t)}))}});exports.AbiErrorInputsNotFoundError=class extends J{constructor(e,{docsPath:t}){super([`Arguments (\`args\`) were provided to "${e}", but "${e}" on the ABI does not contain any parameters (\`inputs\`).`,"Cannot encode error result without knowing what the parameter types are.","Make sure you are using the correct ABI and that the inputs exist on it."].join("\n"),{docsPath:t,name:"AbiErrorInputsNotFoundError"})}},exports.AbiErrorNotFoundError=class extends J{constructor(e,{docsPath:t}={}){super([`Error ${e?`"${e}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the error exists on it."].join("\n"),{docsPath:t,name:"AbiErrorNotFoundError"})}},exports.AbiFunctionNotFoundError=ce,exports.AbiFunctionOutputsNotFoundError=ue,exports.AbiFunctionSignatureNotFoundError=class extends J{constructor(e,{docsPath:t}){super([`Encoded function signature "${e}" not found on ABI.`,"Make sure you are using the correct ABI and that the function exists on it.",`You can look up the signature here: https://openchain.xyz/signatures?query=${e}.`].join("\n"),{docsPath:t,name:"AbiFunctionSignatureNotFoundError"})}},exports.BaseError=J,exports.HttpRequestError=Xn,exports.InvalidArrayError=he,exports.batchGatewayAbi=[{name:"query",type:"function",stateMutability:"view",inputs:[{type:"tuple[]",name:"queries",components:[{type:"address",name:"sender"},{type:"string[]",name:"urls"},{type:"bytes",name:"data"}]}],outputs:[{type:"bool[]",name:"failures"},{type:"bytes[]",name:"responses"}]},{name:"HttpError",type:"error",inputs:[{type:"uint16",name:"status"},{type:"string",name:"message"}]}],exports.call=Pa,exports.concat=Zt,exports.concatHex=Ht,exports.decodeAbiParameters=En,exports.decodeErrorResult=On,exports.encodeAbiParameters=nn,exports.formatAbiItem=G,exports.getAbiItem=cn,exports.getUrl=Vn,exports.index=wI,exports.isAddressEqual=Us,exports.isHex=Z,exports.slice=Wt,exports.solidityError=mn,exports.stringify=jn,exports.toFunctionSelector=on;