superstack-wallet-sdk 0.4.13 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/src/client.js +1 -1
- package/dist/esm/src/client.js.map +1 -1
- package/dist/esm/src/index.js +1 -1
- package/dist/esm/src/index.js.map +1 -1
- package/dist/esm/src/storage.js +1 -1
- package/dist/esm/src/storage.js.map +1 -1
- package/dist/esm/types/client.d.ts +2 -2
- package/dist/esm/types/storage.d.ts +3 -0
- package/dist/index.cjs +123 -123
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
"use strict";var e=require("axios"),t=require("@solana/web3.js"),n=require("bs58"),r=require("uuid"),o=require("react"),s=require("lucide-react"),a=require("qs");function i(e){return e&&e.__esModule?e:{default:e}}function c(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var u,l,d,f,h=i(e),p=i(n),m=i(o),g=c(a);function b(e){return"version"in e}"undefined"!=typeof globalThis&&void 0===globalThis.globalThis&&(globalThis.global=globalThis),exports.Network=void 0,(u=exports.Network||(exports.Network={})).Solana="Solana",u.Ethereum="Ethereum",exports.WalletType=void 0,(l=exports.WalletType||(exports.WalletType={})).Phantom="Phantom",l.Embedded="Embedded",exports.SocialType=void 0,(d=exports.SocialType||(exports.SocialType={})).Email="Email",d.Google="Google",d.Twitter="Twitter",d.Phantom="Phantom",d.Phone="Phone",d.Okx="Okx",exports.VaultId=void 0,(f=exports.VaultId||(exports.VaultId={})).HyperbeatUltraHype="HyperbeatUltraHype",f.HyperbeatUltraUbtc="HyperbeatUltraUbtc",f.HyperbeatUsdt="HyperbeatUsdt",f.HyperbeatUsdc="HyperbeatUsdc",f.HyperbeatXaut="HyperbeatXaut",f.VentualsVlp="VentualsVlp",f.DnHype="DnHype",f.DnPump="DnPump";const y="embedded_wallet_state",w="superstack_wallet_type",v="embedded_wallet_access_token";class x{static saveState(e,t){const n={accessToken:e,socials:t,lastConnected:Date.now()};localStorage.setItem(y,JSON.stringify(n))}static saveAccessToken(e){localStorage.setItem(v,e)}static saveWalletType(e){localStorage.setItem(w,e)}static getWalletType(){return localStorage.getItem(w)}static getState(){try{const e=localStorage.getItem(y);if(!e)return null;const t=JSON.parse(e);return Date.now()-t.lastConnected<6048e5?t:(this.clear(),null)}catch(e){return null}}static getSocials(){try{const e=localStorage.getItem(y);if(!e)return null;return JSON.parse(e).socials}catch(e){return null}}static getAccessToken(){return localStorage.getItem(v)}static clear(){localStorage.removeItem(y),localStorage.removeItem(w),localStorage.removeItem(v)}}function E(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var P={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function s(e,t,r,s,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var i=new o(r,s||e,a),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],i]:e._events[c].push(i):(e._events[c]=i,e._eventsCount++),e}function a(e,t){0===--e._eventsCount?e._events=new r:delete e._events[t]}function i(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),i.prototype.eventNames=function(){var e,r,o=[];if(0===this._eventsCount)return o;for(r in e=this._events)t.call(e,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},i.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);o<s;o++)a[o]=r[o].fn;return a},i.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},i.prototype.emit=function(e,t,r,o,s,a){var i=n?n+e:e;if(!this._events[i])return!1;var c,u,l=this._events[i],d=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,r),!0;case 4:return l.fn.call(l.context,t,r,o),!0;case 5:return l.fn.call(l.context,t,r,o,s),!0;case 6:return l.fn.call(l.context,t,r,o,s,a),!0}for(u=1,c=new Array(d-1);u<d;u++)c[u-1]=arguments[u];l.fn.apply(l.context,c)}else{var f,h=l.length;for(u=0;u<h;u++)switch(l[u].once&&this.removeListener(e,l[u].fn,void 0,!0),d){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,t);break;case 3:l[u].fn.call(l[u].context,t,r);break;case 4:l[u].fn.call(l[u].context,t,r,o);break;default:if(!c)for(f=1,c=new Array(d-1);f<d;f++)c[f-1]=arguments[f];l[u].fn.apply(l[u].context,c)}}return!0},i.prototype.on=function(e,t,n){return s(this,e,t,n,!1)},i.prototype.once=function(e,t,n){return s(this,e,t,n,!0)},i.prototype.removeListener=function(e,t,r,o){var s=n?n+e:e;if(!this._events[s])return this;if(!t)return a(this,s),this;var i=this._events[s];if(i.fn)i.fn!==t||o&&!i.once||r&&i.context!==r||a(this,s);else{for(var c=0,u=[],l=i.length;c<l;c++)(i[c].fn!==t||o&&!i[c].once||r&&i[c].context!==r)&&u.push(i[c]);u.length?this._events[s]=1===u.length?u[0]:u:a(this,s)}return this},i.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&a(this,t)):(this._events=new r,this._eventsCount=0),this},i.prototype.off=i.prototype.removeListener,i.prototype.addListener=i.prototype.on,i.prefixed=n,i.EventEmitter=i,e.exports=i}(P);var k,A=E(P.exports);class I extends Error{constructor(e,t){super(e),this.error=t}}class N extends I{constructor(){super(...arguments),this.name="WalletNotReadyError"}}class S extends I{constructor(){super(...arguments),this.name="WalletConnectionError"}}class T extends I{constructor(){super(...arguments),this.name="WalletDisconnectedError"}}class $ extends I{constructor(){super(...arguments),this.name="WalletDisconnectionError"}}class B extends I{constructor(){super(...arguments),this.name="WalletAccountError"}}class C extends I{constructor(){super(...arguments),this.name="WalletPublicKeyError"}}class O extends I{constructor(){super(...arguments),this.name="WalletNotConnectedError"}}class R extends I{constructor(){super(...arguments),this.name="WalletSendTransactionError"}}class z extends I{constructor(){super(...arguments),this.name="WalletSignTransactionError"}}class _ extends I{constructor(){super(...arguments),this.name="WalletSignMessageError"}}!function(e){e.Installed="Installed",e.NotDetected="NotDetected",e.Loadable="Loadable",e.Unsupported="Unsupported"}(k||(k={}));class M extends A{get connected(){return!!this.publicKey}async autoConnect(){await this.connect()}async prepareTransaction(e,t,n={}){const r=this.publicKey;if(!r)throw new O;return e.feePayer=e.feePayer||r,e.recentBlockhash=e.recentBlockhash||(await t.getLatestBlockhash({commitment:n.preflightCommitment,minContextSlot:n.minContextSlot})).blockhash,e}}function F(e){return"version"in e}class j extends M{async sendTransaction(e,t,n={}){let r=!0;try{if(F(e)){if(!this.supportedTransactionVersions)throw new R("Sending versioned transactions isn't supported by this wallet");if(!this.supportedTransactionVersions.has(e.version))throw new R(`Sending transaction version ${e.version} isn't supported by this wallet`);try{const r=(e=await this.signTransaction(e)).serialize();return await t.sendRawTransaction(r,n)}catch(e){if(e instanceof z)throw r=!1,e;throw new R(e?.message,e)}}else try{const{signers:r,...o}=n;e=await this.prepareTransaction(e,t,o),r?.length&&e.partialSign(...r);const s=(e=await this.signTransaction(e)).serialize();return await t.sendRawTransaction(s,o)}catch(e){if(e instanceof z)throw r=!1,e;throw new R(e?.message,e)}}catch(e){throw r&&this.emit("error",e),e}}async signAllTransactions(e){for(const t of e)if(F(t)){if(!this.supportedTransactionVersions)throw new z("Signing versioned transactions isn't supported by this wallet");if(!this.supportedTransactionVersions.has(t.version))throw new z(`Signing transaction version ${t.version} isn't supported by this wallet`)}const t=[];for(const n of e)t.push(await this.signTransaction(n));return t}}class L extends j{}class U extends L{constructor(e={}){super(),this.name="Phantom",this.url="https://phantom.app",this.icon="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDgiIGhlaWdodD0iMTA4IiB2aWV3Qm94PSIwIDAgMTA4IDEwOCIgZmlsbD0ibm9uZSI+CjxyZWN0IHdpZHRoPSIxMDgiIGhlaWdodD0iMTA4IiByeD0iMjYiIGZpbGw9IiNBQjlGRjIiLz4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik00Ni41MjY3IDY5LjkyMjlDNDIuMDA1NCA3Ni44NTA5IDM0LjQyOTIgODUuNjE4MiAyNC4zNDggODUuNjE4MkMxOS41ODI0IDg1LjYxODIgMTUgODMuNjU2MyAxNSA3NS4xMzQyQzE1IDUzLjQzMDUgNDQuNjMyNiAxOS44MzI3IDcyLjEyNjggMTkuODMyN0M4Ny43NjggMTkuODMyNyA5NCAzMC42ODQ2IDk0IDQzLjAwNzlDOTQgNTguODI1OCA4My43MzU1IDc2LjkxMjIgNzMuNTMyMSA3Ni45MTIyQzcwLjI5MzkgNzYuOTEyMiA2OC43MDUzIDc1LjEzNDIgNjguNzA1MyA3Mi4zMTRDNjguNzA1MyA3MS41NzgzIDY4LjgyNzUgNzAuNzgxMiA2OS4wNzE5IDY5LjkyMjlDNjUuNTg5MyA3NS44Njk5IDU4Ljg2ODUgODEuMzg3OCA1Mi41NzU0IDgxLjM4NzhDNDcuOTkzIDgxLjM4NzggNDUuNjcxMyA3OC41MDYzIDQ1LjY3MTMgNzQuNDU5OEM0NS42NzEzIDcyLjk4ODQgNDUuOTc2OCA3MS40NTU2IDQ2LjUyNjcgNjkuOTIyOVpNODMuNjc2MSA0Mi41Nzk0QzgzLjY3NjEgNDYuMTcwNCA4MS41NTc1IDQ3Ljk2NTggNzkuMTg3NSA0Ny45NjU4Qzc2Ljc4MTYgNDcuOTY1OCA3NC42OTg5IDQ2LjE3MDQgNzQuNjk4OSA0Mi41Nzk0Qzc0LjY5ODkgMzguOTg4NSA3Ni43ODE2IDM3LjE5MzEgNzkuMTg3NSAzNy4xOTMxQzgxLjU1NzUgMzcuMTkzMSA4My42NzYxIDM4Ljk4ODUgODMuNjc2MSA0Mi41Nzk0Wk03MC4yMTAzIDQyLjU3OTVDNzAuMjEwMyA0Ni4xNzA0IDY4LjA5MTYgNDcuOTY1OCA2NS43MjE2IDQ3Ljk2NThDNjMuMzE1NyA0Ny45NjU4IDYxLjIzMyA0Ni4xNzA0IDYxLjIzMyA0Mi41Nzk1QzYxLjIzMyAzOC45ODg1IDYzLjMxNTcgMzcuMTkzMSA2NS43MjE2IDM3LjE5MzFDNjguMDkxNiAzNy4xOTMxIDcwLjIxMDMgMzguOTg4NSA3MC4yMTAzIDQyLjU3OTVaIiBmaWxsPSIjRkZGREY4Ii8+Cjwvc3ZnPg==",this.supportedTransactionVersions=new Set(["legacy",0]),this._readyState="undefined"==typeof window||"undefined"==typeof document?k.Unsupported:k.NotDetected,this._disconnected=()=>{const e=this._wallet;e&&(e.off("disconnect",this._disconnected),e.off("accountChanged",this._accountChanged),this._wallet=null,this._publicKey=null,this.emit("error",new T),this.emit("disconnect"))},this._accountChanged=e=>{const n=this._publicKey;if(n){try{e=new t.PublicKey(e.toBytes())}catch(e){return void this.emit("error",new C(null==e?void 0:e.message,e))}n.equals(e)||(this._publicKey=e,this.emit("connect",e))}},this._connecting=!1,this._wallet=null,this._publicKey=null,this._readyState!==k.Unsupported&&(function(){if(!navigator)return!1;const e=navigator.userAgent.toLowerCase(),t=e.includes("iphone")||e.includes("ipad"),n=e.includes("safari");return t&&n}()?(this._readyState=k.Loadable,this.emit("readyStateChange",this._readyState)):function(e){if("undefined"==typeof window||"undefined"==typeof document)return;const t=[];function n(){if(e())for(const e of t)e()}const r=setInterval(n,1e3);t.push(()=>clearInterval(r)),"loading"===document.readyState&&(document.addEventListener("DOMContentLoaded",n,{once:!0}),t.push(()=>document.removeEventListener("DOMContentLoaded",n))),"complete"!==document.readyState&&(window.addEventListener("load",n,{once:!0}),t.push(()=>window.removeEventListener("load",n))),n()}(()=>{var e,t,n;return!(!(null===(t=null===(e=window.phantom)||void 0===e?void 0:e.solana)||void 0===t?void 0:t.isPhantom)&&!(null===(n=window.solana)||void 0===n?void 0:n.isPhantom))&&(this._readyState=k.Installed,this.emit("readyStateChange",this._readyState),!0)}))}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get readyState(){return this._readyState}async autoConnect(){this.readyState===k.Installed&&await this.connect()}async connect(){var e;try{if(this.connected||this.connecting)return;if(this.readyState===k.Loadable){const e=encodeURIComponent(window.location.href),t=encodeURIComponent(window.location.origin);return void(window.location.href=`https://phantom.app/ul/browse/${e}?ref=${t}`)}if(this.readyState!==k.Installed)throw new N;this._connecting=!0;const n=(null===(e=window.phantom)||void 0===e?void 0:e.solana)||window.solana;if(!n.isConnected)try{await n.connect()}catch(e){throw new S(null==e?void 0:e.message,e)}if(!n.publicKey)throw new B;let r;try{r=new t.PublicKey(n.publicKey.toBytes())}catch(e){throw new C(null==e?void 0:e.message,e)}n.on("disconnect",this._disconnected),n.on("accountChanged",this._accountChanged),this._wallet=n,this._publicKey=r,this.emit("connect",r)}catch(e){throw this.emit("error",e),e}finally{this._connecting=!1}}async disconnect(){const e=this._wallet;if(e){e.off("disconnect",this._disconnected),e.off("accountChanged",this._accountChanged),this._wallet=null,this._publicKey=null;try{await e.disconnect()}catch(e){this.emit("error",new $(null==e?void 0:e.message,e))}}this.emit("disconnect")}async sendTransaction(e,t,n={}){try{const r=this._wallet;if(!r)throw new O;try{const{signers:o,...s}=n;F(e)?(null==o?void 0:o.length)&&e.sign(o):(e=await this.prepareTransaction(e,t,s),(null==o?void 0:o.length)&&e.partialSign(...o)),s.preflightCommitment=s.preflightCommitment||t.commitment;const{signature:a}=await r.signAndSendTransaction(e,s);return a}catch(e){if(e instanceof I)throw e;throw new R(null==e?void 0:e.message,e)}}catch(e){throw this.emit("error",e),e}}async signTransaction(e){try{const t=this._wallet;if(!t)throw new O;try{return await t.signTransaction(e)||e}catch(e){throw new z(null==e?void 0:e.message,e)}}catch(e){throw this.emit("error",e),e}}async signAllTransactions(e){try{const t=this._wallet;if(!t)throw new O;try{return await t.signAllTransactions(e)||e}catch(e){throw new z(null==e?void 0:e.message,e)}}catch(e){throw this.emit("error",e),e}}async signMessage(e){try{const t=this._wallet;if(!t)throw new O;try{const{signature:n}=await t.signMessage(e);return n}catch(e){throw new _(null==e?void 0:e.message,e)}}catch(e){throw this.emit("error",e),e}}}let D=class e extends Error{constructor(t,n={}){const r=n.cause instanceof e?n.cause.details:n.cause?.message?n.cause.message:n.details,o=n.cause instanceof e&&n.cause.docsPath||n.docsPath;super([t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...o?[`Docs: https://abitype.dev${o}`]:[],...r?[`Details: ${r}`]:[],"Version: abitype@1.1.0"].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=o,this.metaMessages=n.metaMessages,this.shortMessage=t}};function G(e,t){const n=e.exec(t);return n?.groups}const q=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,V=/^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)?$/,W=/^\(.+?\).*?$/,H=/^tuple(?<array>(\[(\d*)\])*)$/;function Y(e){let t=e.type;if(H.test(e.type)&&"components"in e){t="(";const n=e.components.length;for(let r=0;r<n;r++){t+=Y(e.components[r]),r<n-1&&(t+=", ")}const r=G(H,e.type);return t+=`)${r?.array??""}`,Y({...e,type:t})}return"indexed"in e&&e.indexed&&(t=`${t} indexed`),e.name?`${t} ${e.name}`:t}function Z(e){let t="";const n=e.length;for(let r=0;r<n;r++){t+=Y(e[r]),r!==n-1&&(t+=", ")}return t}function K(e){return"function"===e.type?`function ${e.name}(${Z(e.inputs)})${e.stateMutability&&"nonpayable"!==e.stateMutability?` ${e.stateMutability}`:""}${e.outputs?.length?` returns (${Z(e.outputs)})`:""}`:"event"===e.type?`event ${e.name}(${Z(e.inputs)})`:"error"===e.type?`error ${e.name}(${Z(e.inputs)})`:"constructor"===e.type?`constructor(${Z(e.inputs)})${"payable"===e.stateMutability?" payable":""}`:"fallback"===e.type?"fallback() external"+("payable"===e.stateMutability?" payable":""):"receive() external payable"}const J=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const Q=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const X=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;const ee=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function te(e){return ee.test(e)}function ne(e){return G(ee,e)}const re=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;const oe=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;const se=/^receive\(\) external payable$/;const ae=new Set(["memory","indexed","storage","calldata"]),ie=new Set(["indexed"]),ce=new Set(["calldata","memory","storage"]);class ue extends D{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 le extends D{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 de extends D{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 fe extends D{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 he extends D{constructor({param:e}){super("Invalid ABI parameter.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class pe extends D{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 me extends D{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 ge extends D{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 be extends D{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 ye extends D{constructor({signature:e,type:t}){super(`Invalid ${t} signature.`,{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class we extends D{constructor({signature:e}){super("Unknown signature.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class ve extends D{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 xe extends D{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 Ee extends D{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 Pe=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 ke(e,t={}){if(function(e){return X.test(e)}(e))return function(e,t={}){const n=function(e){return G(X,e)}(e);if(!n)throw new ye({signature:e,type:"function"});const r=Te(n.parameters),o=[],s=r.length;for(let e=0;e<s;e++)o.push(Se(r[e],{modifiers:ce,structs:t,type:"function"}));const a=[];if(n.returns){const e=Te(n.returns),r=e.length;for(let n=0;n<r;n++)a.push(Se(e[n],{modifiers:ce,structs:t,type:"function"}))}return{name:n.name,type:"function",stateMutability:n.stateMutability??"nonpayable",inputs:o,outputs:a}}(e,t);if(function(e){return Q.test(e)}(e))return function(e,t={}){const n=function(e){return G(Q,e)}(e);if(!n)throw new ye({signature:e,type:"event"});const r=Te(n.parameters),o=[],s=r.length;for(let e=0;e<s;e++)o.push(Se(r[e],{modifiers:ie,structs:t,type:"event"}));return{name:n.name,type:"event",inputs:o}}(e,t);if(function(e){return J.test(e)}(e))return function(e,t={}){const n=function(e){return G(J,e)}(e);if(!n)throw new ye({signature:e,type:"error"});const r=Te(n.parameters),o=[],s=r.length;for(let e=0;e<s;e++)o.push(Se(r[e],{structs:t,type:"error"}));return{name:n.name,type:"error",inputs:o}}(e,t);if(function(e){return re.test(e)}(e))return function(e,t={}){const n=function(e){return G(re,e)}(e);if(!n)throw new ye({signature:e,type:"constructor"});const r=Te(n.parameters),o=[],s=r.length;for(let e=0;e<s;e++)o.push(Se(r[e],{structs:t,type:"constructor"}));return{type:"constructor",stateMutability:n.stateMutability??"nonpayable",inputs:o}}(e,t);if(function(e){return oe.test(e)}(e))return function(e){const t=function(e){return G(oe,e)}(e);if(!t)throw new ye({signature:e,type:"fallback"});return{type:"fallback",stateMutability:t.stateMutability??"nonpayable"}}(e);if(function(e){return se.test(e)}(e))return{type:"receive",stateMutability:"payable"};throw new we({signature:e})}const Ae=/^(?<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$_]*))?$/,Ie=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,Ne=/^u?int$/;function Se(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}(e,t?.type,t?.structs);if(Pe.has(n))return Pe.get(n);const r=W.test(e),o=G(r?Ie:Ae,e);if(!o)throw new he({param:e});if(o.name&&function(e){return"address"===e||"bool"===e||"function"===e||"string"===e||"tuple"===e||q.test(e)||V.test(e)||Be.test(e)}(o.name))throw new pe({param:e,name:o.name});const s=o.name?{name:o.name}:{},a="indexed"===o.modifier?{indexed:!0}:{},i=t?.structs??{};let c,u={};if(r){c="tuple";const e=Te(o.type),t=[],n=e.length;for(let r=0;r<n;r++)t.push(Se(e[r],{structs:i}));u={components:t}}else if(o.type in i)c="tuple",u={components:i[o.type]};else if(Ne.test(o.type))c=`${o.type}256`;else if("address payable"===o.type)c="address";else if(c=o.type,"struct"!==t?.type&&!$e(c))throw new de({type:c});if(o.modifier){if(!t?.modifiers?.has?.(o.modifier))throw new me({param:e,type:t?.type,modifier:o.modifier});if(ce.has(o.modifier)&&!function(e,t){return t||"bytes"===e||"string"===e||"tuple"===e}(c,!!o.array))throw new ge({param:e,type:t?.type,modifier:o.modifier})}const l={type:`${c}${o.array??""}`,...s,...a,...u};return Pe.set(n,l),l}function Te(e,t=[],n="",r=0){const o=e.trim().length;for(let s=0;s<o;s++){const o=e[s],a=e.slice(s+1);switch(o){case",":return 0===r?Te(a,[...t,n.trim()]):Te(a,t,`${n}${o}`,r);case"(":return Te(a,t,`${n}${o}`,r+1);case")":return Te(a,t,`${n}${o}`,r-1);default:return Te(a,t,`${n}${o}`,r)}}if(""===n)return t;if(0!==r)throw new Ee({current:n,depth:r});return t.push(n.trim()),t}function $e(e){return"address"===e||"bool"===e||"function"===e||"string"===e||q.test(e)||V.test(e)}const Be=/^(?: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 Ce(e){const t={},n=e.length;for(let r=0;r<n;r++){const n=e[r];if(!te(n))continue;const o=ne(n);if(!o)throw new ye({signature:n,type:"struct"});const s=o.properties.split(";"),a=[],i=s.length;for(let e=0;e<i;e++){const t=s[e].trim();if(!t)continue;const n=Se(t,{type:"struct"});a.push(n)}if(!a.length)throw new ve({signature:n});t[o.name]=a}const r={},o=Object.entries(t),s=o.length;for(let e=0;e<s;e++){const[n,s]=o[e];r[n]=Re(s,t)}return r}const Oe=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;function Re(e,t,n=new Set){const r=[],o=e.length;for(let s=0;s<o;s++){const o=e[s];if(W.test(o.type))r.push(o);else{const e=G(Oe,o.type);if(!e?.type)throw new be({abiParameter:o});const{array:s,type:a}=e;if(a in t){if(n.has(a))throw new xe({type:a});r.push({...o,type:`tuple${s??""}`,components:Re(t[a]??[],t,new Set([...n,a]))})}else{if(!$e(a))throw new le({type:a});r.push(o)}}}return r}function ze(e){const t=Ce(e),n=[],r=e.length;for(let o=0;o<r;o++){const r=e[o];te(r)||n.push(ke(r,t))}return n}function _e(e){let t;if("string"==typeof e)t=ke(e);else{const n=Ce(e),r=e.length;for(let o=0;o<r;o++){const r=e[o];if(!te(r)){t=ke(r,n);break}}}if(!t)throw new ue({signature:e});return t}function Me(e){const t=[];if("string"==typeof e){const n=Te(e),r=n.length;for(let e=0;e<r;e++)t.push(Se(n[e],{modifiers:ae}))}else{const n=Ce(e),r=e.length;for(let o=0;o<r;o++){const r=e[o];if(te(r))continue;const s=Te(r),a=s.length;for(let e=0;e<a;e++)t.push(Se(s[e],{modifiers:ae,structs:n}))}}if(0===t.length)throw new fe({params:e});return t}function Fe(e,t,n){const r=e[t.name];if("function"==typeof r)return r;const o=e[n];return"function"==typeof o?o:n=>t(e,n)}function je(e,{includeName:t=!1}={}){if("function"!==e.type&&"event"!==e.type&&"error"!==e.type)throw new bt(e.type);return`${e.name}(${Le(e.inputs,{includeName:t})})`}function Le(e,{includeName:t=!1}={}){return e?e.map(e=>function(e,{includeName:t}){if(e.type.startsWith("tuple"))return`(${Le(e.components,{includeName:t})})${e.type.slice(5)}`;return e.type+(t&&e.name?` ${e.name}`:"")}(e,{includeName:t})).join(t?", ":","):""}function Ue(e,{strict:t=!0}={}){return!!e&&("string"==typeof e&&(t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")))}function De(e){return Ue(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const Ge="2.37.8";let qe=({docsBaseUrl:e,docsPath:t="",docsSlug:n})=>t?`${e??"https://viem.sh"}${t}${n?`#${n}`:""}`:void 0,Ve=`viem@${Ge}`,We=class e extends Error{constructor(t,n={}){const r=n.cause instanceof e?n.cause.details:n.cause?.message?n.cause.message:n.details,o=n.cause instanceof e&&n.cause.docsPath||n.docsPath,s=qe?.({...n,docsPath:o});super([t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...r?[`Details: ${r}`]:[],...Ve?[`Version: ${Ve}`]:[]].join("\n"),n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=o,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=t,this.version=Ge}walk(e){return He(this,e)}};function He(e,t){return t?.(e)?e:e&&"object"==typeof e&&"cause"in e&&void 0!==e.cause?He(e.cause,t):t?null:e}class Ye extends We{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 Ze extends We{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 Ke extends We{constructor({data:e,params:t,size:n}){super([`Data size of ${n} bytes is too small for given parameters.`].join("\n"),{metaMessages:[`Params: (${Le(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 Je extends We{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.',{name:"AbiDecodingZeroDataError"})}}class Qe extends We{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 Xe extends We{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${De(t)}) does not match expected size (bytes${e}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class et extends We{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 tt extends We{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"})}}class nt extends We{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"})}}class rt extends We{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 ot extends We{constructor({docsPath:e}){super("Cannot extract event signature from empty topics.",{docsPath:e,name:"AbiEventSignatureEmptyTopicsError"})}}class st extends We{constructor(e,{docsPath:t}){super([`Encoded event signature "${e}" not found on ABI.`,"Make sure you are using the correct ABI and that the event exists on it.",`You can look up the signature here: https://openchain.xyz/signatures?query=${e}.`].join("\n"),{docsPath:t,name:"AbiEventSignatureNotFoundError"})}}class at extends We{constructor(e,{docsPath:t}={}){super([`Event ${e?`"${e}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the event exists on it."].join("\n"),{docsPath:t,name:"AbiEventNotFoundError"})}}class it extends We{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 ct extends We{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 ut extends We{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"})}}class lt extends We{constructor(e,t){super("Found ambiguous types in overloaded ABI items.",{metaMessages:[`\`${e.type}\` in \`${je(e.abiItem)}\`, and`,`\`${t.type}\` in \`${je(t.abiItem)}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."],name:"AbiItemAmbiguityError"})}}let dt=class extends We{constructor({expectedSize:e,givenSize:t}){super(`Expected bytes${e}, got bytes${t}.`,{name:"BytesSizeMismatchError"})}};class ft extends We{constructor({abiItem:e,data:t,params:n,size:r}){super([`Data size of ${r} bytes is too small for non-indexed event parameters.`].join("\n"),{metaMessages:[`Params: (${Le(n,{includeName:!0})})`,`Data: ${t} (${r} bytes)`],name:"DecodeLogDataMismatch"}),Object.defineProperty(this,"abiItem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),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.abiItem=e,this.data=t,this.params=n,this.size=r}}class ht extends We{constructor({abiItem:e,param:t}){super([`Expected a topic for indexed event parameter${t.name?` "${t.name}"`:""} on event "${je(e,{includeName:!0})}".`].join("\n"),{name:"DecodeLogTopicsMismatch"}),Object.defineProperty(this,"abiItem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abiItem=e}}class pt extends We{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 mt extends We{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"})}}let gt=class extends We{constructor(e){super([`Value "${e}" is not a valid array.`].join("\n"),{name:"InvalidArrayError"})}};class bt extends We{constructor(e){super([`"${e}" is not a valid definition type.`,'Valid types: "function", "event", "error"'].join("\n"),{name:"InvalidDefinitionTypeError"})}}class yt extends We{constructor(e){super(`Filter type "${e}" is not supported.`,{name:"FilterTypeNotSupportedError"})}}let wt=class extends We{constructor({offset:e,position:t,size:n}){super(`Slice ${"start"===t?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}},vt=class extends We{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 xt extends We{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 Et(e,{dir:t,size:n=32}={}){return"string"==typeof e?Pt(e,{dir:t,size:n}):function(e,{dir:t,size:n=32}={}){if(null===n)return e;if(e.length>n)throw new vt({size:e.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let o=0;o<n;o++){const s="right"===t;r[s?o:n-o-1]=e[s?o:e.length-o-1]}return r}(e,{dir:t,size:n})}function Pt(e,{dir:t,size:n=32}={}){if(null===n)return e;const r=e.replace("0x","");if(r.length>2*n)throw new vt({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r["right"===t?"padEnd":"padStart"](2*n,"0")}`}let kt=class extends We{constructor({max:e,min:t,signed:n,size:r,value:o}){super(`Number "${o}" is not in safe ${r?`${8*r}-bit ${n?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}},At=class extends We{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 It extends We{constructor(e){super(`Hex value "${e}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`,{name:"InvalidHexBooleanError"})}}let Nt=class extends We{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}};function St(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 Tt(e,{size:t}){if(De(e)>t)throw new Nt({givenSize:De(e),maxSize:t})}function $t(e,t={}){const{signed:n}=t;t.size&&Tt(e,{size:t.size});const r=BigInt(e);if(!n)return r;const o=(e.length-2)/2;return r<=(1n<<8n*BigInt(o)-1n)-1n?r:r-BigInt(`0x${"f".padStart(2*o,"f")}`)-1n}function Bt(e,t={}){return Number($t(e,t))}const Ct=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Ot(e,t={}){return"number"==typeof e||"bigint"==typeof e?_t(e,t):"string"==typeof e?Ft(e,t):"boolean"==typeof e?Rt(e,t):zt(e,t)}function Rt(e,t={}){const n=`0x${Number(e)}`;return"number"==typeof t.size?(Tt(n,{size:t.size}),Et(n,{size:t.size})):n}function zt(e,t={}){let n="";for(let t=0;t<e.length;t++)n+=Ct[e[t]];const r=`0x${n}`;return"number"==typeof t.size?(Tt(r,{size:t.size}),Et(r,{dir:"right",size:t.size})):r}function _t(e,t={}){const{signed:n,size:r}=t,o=BigInt(e);let s;r?s=n?(1n<<8n*BigInt(r)-1n)-1n:2n**(8n*BigInt(r))-1n:"number"==typeof e&&(s=BigInt(Number.MAX_SAFE_INTEGER));const a="bigint"==typeof s&&n?-s-1n:0;if(s&&o>s||o<a){const t="bigint"==typeof e?"n":"";throw new kt({max:s?`${s}${t}`:void 0,min:`${a}${t}`,signed:n,size:r,value:`${e}${t}`})}const i=`0x${(n&&o<0?(1n<<BigInt(8*r))+BigInt(o):o).toString(16)}`;return r?Et(i,{size:r}):i}const Mt=new TextEncoder;function Ft(e,t={}){return zt(Mt.encode(e),t)}const jt=new TextEncoder;function Lt(e,t={}){return"number"==typeof e||"bigint"==typeof e?function(e,t){const n=_t(e,t);return Gt(n)}(e,t):"boolean"==typeof e?function(e,t={}){const n=new Uint8Array(1);if(n[0]=Number(e),"number"==typeof t.size)return Tt(n,{size:t.size}),Et(n,{size:t.size});return n}(e,t):Ue(e)?Gt(e,t):qt(e,t)}const Ut={zero:48,nine:57,A:65,F:70,a:97,f:102};function Dt(e){return e>=Ut.zero&&e<=Ut.nine?e-Ut.zero:e>=Ut.A&&e<=Ut.F?e-(Ut.A-10):e>=Ut.a&&e<=Ut.f?e-(Ut.a-10):void 0}function Gt(e,t={}){let n=e;t.size&&(Tt(n,{size:t.size}),n=Et(n,{dir:"right",size:t.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const o=r.length/2,s=new Uint8Array(o);for(let e=0,t=0;e<o;e++){const n=Dt(r.charCodeAt(t++)),o=Dt(r.charCodeAt(t++));if(void 0===n||void 0===o)throw new We(`Invalid byte sequence ("${r[t-2]}${r[t-1]}" in "${r}").`);s[e]=16*n+o}return s}function qt(e,t={}){const n=jt.encode(e);return"number"==typeof t.size?(Tt(n,{size:t.size}),Et(n,{dir:"right",size:t.size})):n}const Vt=BigInt(2**32-1),Wt=BigInt(32);function Ht(e,t=!1){return t?{h:Number(e&Vt),l:Number(e>>Wt&Vt)}:{h:0|Number(e>>Wt&Vt),l:0|Number(e&Vt)}}const Yt="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function Zt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Kt(e,...t){if(!((n=e)instanceof Uint8Array||ArrayBuffer.isView(n)&&"Uint8Array"===n.constructor.name))throw new Error("Uint8Array expected");
|
|
1
|
+
"use strict";var e=require("axios"),t=require("@solana/web3.js"),n=require("bs58"),r=require("uuid"),o=require("react"),s=require("lucide-react"),a=require("qs");function i(e){return e&&e.__esModule?e:{default:e}}function c(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var u,l,d,f,h=i(e),p=i(n),m=i(o),g=c(a);function b(e){return"version"in e}"undefined"!=typeof globalThis&&void 0===globalThis.globalThis&&(globalThis.global=globalThis),exports.Network=void 0,(u=exports.Network||(exports.Network={})).Solana="Solana",u.Ethereum="Ethereum",exports.WalletType=void 0,(l=exports.WalletType||(exports.WalletType={})).Phantom="Phantom",l.Embedded="Embedded",exports.SocialType=void 0,(d=exports.SocialType||(exports.SocialType={})).Email="Email",d.Google="Google",d.Twitter="Twitter",d.Phantom="Phantom",d.Phone="Phone",d.Okx="Okx",exports.VaultId=void 0,(f=exports.VaultId||(exports.VaultId={})).HyperbeatUltraHype="HyperbeatUltraHype",f.HyperbeatUltraUbtc="HyperbeatUltraUbtc",f.HyperbeatUsdt="HyperbeatUsdt",f.HyperbeatUsdc="HyperbeatUsdc",f.HyperbeatXaut="HyperbeatXaut",f.VentualsVlp="VentualsVlp",f.DnHype="DnHype",f.DnPump="DnPump";const y="embedded_wallet_state",w="superstack_wallet_type",v="embedded_wallet_access_token",x="switched_account_address";class E{static saveState(e,t){const n={accessToken:e,socials:t,lastConnected:Date.now()};localStorage.setItem(y,JSON.stringify(n))}static saveAccessToken(e){localStorage.setItem(v,e)}static saveWalletType(e){localStorage.setItem(w,e)}static saveSwitchedAccountAddress(e){localStorage.setItem(x,e)}static getWalletType(){return localStorage.getItem(w)}static getState(){try{const e=localStorage.getItem(y);if(!e)return null;const t=JSON.parse(e);return Date.now()-t.lastConnected<6048e5?t:(this.clear(),null)}catch(e){return null}}static getSocials(){try{const e=localStorage.getItem(y);if(!e)return null;return JSON.parse(e).socials}catch(e){return null}}static getAccessToken(){return localStorage.getItem(v)}static getSwitchedAccountAddress(){return localStorage.getItem(x)}static clear(){localStorage.removeItem(y),localStorage.removeItem(w),localStorage.removeItem(v),localStorage.removeItem(x)}}function P(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var k={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function s(e,t,r,s,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var i=new o(r,s||e,a),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],i]:e._events[c].push(i):(e._events[c]=i,e._eventsCount++),e}function a(e,t){0===--e._eventsCount?e._events=new r:delete e._events[t]}function i(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),i.prototype.eventNames=function(){var e,r,o=[];if(0===this._eventsCount)return o;for(r in e=this._events)t.call(e,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},i.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);o<s;o++)a[o]=r[o].fn;return a},i.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},i.prototype.emit=function(e,t,r,o,s,a){var i=n?n+e:e;if(!this._events[i])return!1;var c,u,l=this._events[i],d=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,r),!0;case 4:return l.fn.call(l.context,t,r,o),!0;case 5:return l.fn.call(l.context,t,r,o,s),!0;case 6:return l.fn.call(l.context,t,r,o,s,a),!0}for(u=1,c=new Array(d-1);u<d;u++)c[u-1]=arguments[u];l.fn.apply(l.context,c)}else{var f,h=l.length;for(u=0;u<h;u++)switch(l[u].once&&this.removeListener(e,l[u].fn,void 0,!0),d){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,t);break;case 3:l[u].fn.call(l[u].context,t,r);break;case 4:l[u].fn.call(l[u].context,t,r,o);break;default:if(!c)for(f=1,c=new Array(d-1);f<d;f++)c[f-1]=arguments[f];l[u].fn.apply(l[u].context,c)}}return!0},i.prototype.on=function(e,t,n){return s(this,e,t,n,!1)},i.prototype.once=function(e,t,n){return s(this,e,t,n,!0)},i.prototype.removeListener=function(e,t,r,o){var s=n?n+e:e;if(!this._events[s])return this;if(!t)return a(this,s),this;var i=this._events[s];if(i.fn)i.fn!==t||o&&!i.once||r&&i.context!==r||a(this,s);else{for(var c=0,u=[],l=i.length;c<l;c++)(i[c].fn!==t||o&&!i[c].once||r&&i[c].context!==r)&&u.push(i[c]);u.length?this._events[s]=1===u.length?u[0]:u:a(this,s)}return this},i.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&a(this,t)):(this._events=new r,this._eventsCount=0),this},i.prototype.off=i.prototype.removeListener,i.prototype.addListener=i.prototype.on,i.prefixed=n,i.EventEmitter=i,e.exports=i}(k);var A,I=P(k.exports);class N extends Error{constructor(e,t){super(e),this.error=t}}class S extends N{constructor(){super(...arguments),this.name="WalletNotReadyError"}}class T extends N{constructor(){super(...arguments),this.name="WalletConnectionError"}}class $ extends N{constructor(){super(...arguments),this.name="WalletDisconnectedError"}}class B extends N{constructor(){super(...arguments),this.name="WalletDisconnectionError"}}class C extends N{constructor(){super(...arguments),this.name="WalletAccountError"}}class O extends N{constructor(){super(...arguments),this.name="WalletPublicKeyError"}}class R extends N{constructor(){super(...arguments),this.name="WalletNotConnectedError"}}class z extends N{constructor(){super(...arguments),this.name="WalletSendTransactionError"}}class _ extends N{constructor(){super(...arguments),this.name="WalletSignTransactionError"}}class M extends N{constructor(){super(...arguments),this.name="WalletSignMessageError"}}!function(e){e.Installed="Installed",e.NotDetected="NotDetected",e.Loadable="Loadable",e.Unsupported="Unsupported"}(A||(A={}));class F extends I{get connected(){return!!this.publicKey}async autoConnect(){await this.connect()}async prepareTransaction(e,t,n={}){const r=this.publicKey;if(!r)throw new R;return e.feePayer=e.feePayer||r,e.recentBlockhash=e.recentBlockhash||(await t.getLatestBlockhash({commitment:n.preflightCommitment,minContextSlot:n.minContextSlot})).blockhash,e}}function j(e){return"version"in e}class L extends F{async sendTransaction(e,t,n={}){let r=!0;try{if(j(e)){if(!this.supportedTransactionVersions)throw new z("Sending versioned transactions isn't supported by this wallet");if(!this.supportedTransactionVersions.has(e.version))throw new z(`Sending transaction version ${e.version} isn't supported by this wallet`);try{const r=(e=await this.signTransaction(e)).serialize();return await t.sendRawTransaction(r,n)}catch(e){if(e instanceof _)throw r=!1,e;throw new z(e?.message,e)}}else try{const{signers:r,...o}=n;e=await this.prepareTransaction(e,t,o),r?.length&&e.partialSign(...r);const s=(e=await this.signTransaction(e)).serialize();return await t.sendRawTransaction(s,o)}catch(e){if(e instanceof _)throw r=!1,e;throw new z(e?.message,e)}}catch(e){throw r&&this.emit("error",e),e}}async signAllTransactions(e){for(const t of e)if(j(t)){if(!this.supportedTransactionVersions)throw new _("Signing versioned transactions isn't supported by this wallet");if(!this.supportedTransactionVersions.has(t.version))throw new _(`Signing transaction version ${t.version} isn't supported by this wallet`)}const t=[];for(const n of e)t.push(await this.signTransaction(n));return t}}class U extends L{}class D extends U{constructor(e={}){super(),this.name="Phantom",this.url="https://phantom.app",this.icon="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDgiIGhlaWdodD0iMTA4IiB2aWV3Qm94PSIwIDAgMTA4IDEwOCIgZmlsbD0ibm9uZSI+CjxyZWN0IHdpZHRoPSIxMDgiIGhlaWdodD0iMTA4IiByeD0iMjYiIGZpbGw9IiNBQjlGRjIiLz4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik00Ni41MjY3IDY5LjkyMjlDNDIuMDA1NCA3Ni44NTA5IDM0LjQyOTIgODUuNjE4MiAyNC4zNDggODUuNjE4MkMxOS41ODI0IDg1LjYxODIgMTUgODMuNjU2MyAxNSA3NS4xMzQyQzE1IDUzLjQzMDUgNDQuNjMyNiAxOS44MzI3IDcyLjEyNjggMTkuODMyN0M4Ny43NjggMTkuODMyNyA5NCAzMC42ODQ2IDk0IDQzLjAwNzlDOTQgNTguODI1OCA4My43MzU1IDc2LjkxMjIgNzMuNTMyMSA3Ni45MTIyQzcwLjI5MzkgNzYuOTEyMiA2OC43MDUzIDc1LjEzNDIgNjguNzA1MyA3Mi4zMTRDNjguNzA1MyA3MS41NzgzIDY4LjgyNzUgNzAuNzgxMiA2OS4wNzE5IDY5LjkyMjlDNjUuNTg5MyA3NS44Njk5IDU4Ljg2ODUgODEuMzg3OCA1Mi41NzU0IDgxLjM4NzhDNDcuOTkzIDgxLjM4NzggNDUuNjcxMyA3OC41MDYzIDQ1LjY3MTMgNzQuNDU5OEM0NS42NzEzIDcyLjk4ODQgNDUuOTc2OCA3MS40NTU2IDQ2LjUyNjcgNjkuOTIyOVpNODMuNjc2MSA0Mi41Nzk0QzgzLjY3NjEgNDYuMTcwNCA4MS41NTc1IDQ3Ljk2NTggNzkuMTg3NSA0Ny45NjU4Qzc2Ljc4MTYgNDcuOTY1OCA3NC42OTg5IDQ2LjE3MDQgNzQuNjk4OSA0Mi41Nzk0Qzc0LjY5ODkgMzguOTg4NSA3Ni43ODE2IDM3LjE5MzEgNzkuMTg3NSAzNy4xOTMxQzgxLjU1NzUgMzcuMTkzMSA4My42NzYxIDM4Ljk4ODUgODMuNjc2MSA0Mi41Nzk0Wk03MC4yMTAzIDQyLjU3OTVDNzAuMjEwMyA0Ni4xNzA0IDY4LjA5MTYgNDcuOTY1OCA2NS43MjE2IDQ3Ljk2NThDNjMuMzE1NyA0Ny45NjU4IDYxLjIzMyA0Ni4xNzA0IDYxLjIzMyA0Mi41Nzk1QzYxLjIzMyAzOC45ODg1IDYzLjMxNTcgMzcuMTkzMSA2NS43MjE2IDM3LjE5MzFDNjguMDkxNiAzNy4xOTMxIDcwLjIxMDMgMzguOTg4NSA3MC4yMTAzIDQyLjU3OTVaIiBmaWxsPSIjRkZGREY4Ii8+Cjwvc3ZnPg==",this.supportedTransactionVersions=new Set(["legacy",0]),this._readyState="undefined"==typeof window||"undefined"==typeof document?A.Unsupported:A.NotDetected,this._disconnected=()=>{const e=this._wallet;e&&(e.off("disconnect",this._disconnected),e.off("accountChanged",this._accountChanged),this._wallet=null,this._publicKey=null,this.emit("error",new $),this.emit("disconnect"))},this._accountChanged=e=>{const n=this._publicKey;if(n){try{e=new t.PublicKey(e.toBytes())}catch(e){return void this.emit("error",new O(null==e?void 0:e.message,e))}n.equals(e)||(this._publicKey=e,this.emit("connect",e))}},this._connecting=!1,this._wallet=null,this._publicKey=null,this._readyState!==A.Unsupported&&(function(){if(!navigator)return!1;const e=navigator.userAgent.toLowerCase(),t=e.includes("iphone")||e.includes("ipad"),n=e.includes("safari");return t&&n}()?(this._readyState=A.Loadable,this.emit("readyStateChange",this._readyState)):function(e){if("undefined"==typeof window||"undefined"==typeof document)return;const t=[];function n(){if(e())for(const e of t)e()}const r=setInterval(n,1e3);t.push(()=>clearInterval(r)),"loading"===document.readyState&&(document.addEventListener("DOMContentLoaded",n,{once:!0}),t.push(()=>document.removeEventListener("DOMContentLoaded",n))),"complete"!==document.readyState&&(window.addEventListener("load",n,{once:!0}),t.push(()=>window.removeEventListener("load",n))),n()}(()=>{var e,t,n;return!(!(null===(t=null===(e=window.phantom)||void 0===e?void 0:e.solana)||void 0===t?void 0:t.isPhantom)&&!(null===(n=window.solana)||void 0===n?void 0:n.isPhantom))&&(this._readyState=A.Installed,this.emit("readyStateChange",this._readyState),!0)}))}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get readyState(){return this._readyState}async autoConnect(){this.readyState===A.Installed&&await this.connect()}async connect(){var e;try{if(this.connected||this.connecting)return;if(this.readyState===A.Loadable){const e=encodeURIComponent(window.location.href),t=encodeURIComponent(window.location.origin);return void(window.location.href=`https://phantom.app/ul/browse/${e}?ref=${t}`)}if(this.readyState!==A.Installed)throw new S;this._connecting=!0;const n=(null===(e=window.phantom)||void 0===e?void 0:e.solana)||window.solana;if(!n.isConnected)try{await n.connect()}catch(e){throw new T(null==e?void 0:e.message,e)}if(!n.publicKey)throw new C;let r;try{r=new t.PublicKey(n.publicKey.toBytes())}catch(e){throw new O(null==e?void 0:e.message,e)}n.on("disconnect",this._disconnected),n.on("accountChanged",this._accountChanged),this._wallet=n,this._publicKey=r,this.emit("connect",r)}catch(e){throw this.emit("error",e),e}finally{this._connecting=!1}}async disconnect(){const e=this._wallet;if(e){e.off("disconnect",this._disconnected),e.off("accountChanged",this._accountChanged),this._wallet=null,this._publicKey=null;try{await e.disconnect()}catch(e){this.emit("error",new B(null==e?void 0:e.message,e))}}this.emit("disconnect")}async sendTransaction(e,t,n={}){try{const r=this._wallet;if(!r)throw new R;try{const{signers:o,...s}=n;j(e)?(null==o?void 0:o.length)&&e.sign(o):(e=await this.prepareTransaction(e,t,s),(null==o?void 0:o.length)&&e.partialSign(...o)),s.preflightCommitment=s.preflightCommitment||t.commitment;const{signature:a}=await r.signAndSendTransaction(e,s);return a}catch(e){if(e instanceof N)throw e;throw new z(null==e?void 0:e.message,e)}}catch(e){throw this.emit("error",e),e}}async signTransaction(e){try{const t=this._wallet;if(!t)throw new R;try{return await t.signTransaction(e)||e}catch(e){throw new _(null==e?void 0:e.message,e)}}catch(e){throw this.emit("error",e),e}}async signAllTransactions(e){try{const t=this._wallet;if(!t)throw new R;try{return await t.signAllTransactions(e)||e}catch(e){throw new _(null==e?void 0:e.message,e)}}catch(e){throw this.emit("error",e),e}}async signMessage(e){try{const t=this._wallet;if(!t)throw new R;try{const{signature:n}=await t.signMessage(e);return n}catch(e){throw new M(null==e?void 0:e.message,e)}}catch(e){throw this.emit("error",e),e}}}let G=class e extends Error{constructor(t,n={}){const r=n.cause instanceof e?n.cause.details:n.cause?.message?n.cause.message:n.details,o=n.cause instanceof e&&n.cause.docsPath||n.docsPath;super([t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...o?[`Docs: https://abitype.dev${o}`]:[],...r?[`Details: ${r}`]:[],"Version: abitype@1.1.0"].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=o,this.metaMessages=n.metaMessages,this.shortMessage=t}};function q(e,t){const n=e.exec(t);return n?.groups}const V=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,W=/^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)?$/,H=/^\(.+?\).*?$/,Y=/^tuple(?<array>(\[(\d*)\])*)$/;function Z(e){let t=e.type;if(Y.test(e.type)&&"components"in e){t="(";const n=e.components.length;for(let r=0;r<n;r++){t+=Z(e.components[r]),r<n-1&&(t+=", ")}const r=q(Y,e.type);return t+=`)${r?.array??""}`,Z({...e,type:t})}return"indexed"in e&&e.indexed&&(t=`${t} indexed`),e.name?`${t} ${e.name}`:t}function K(e){let t="";const n=e.length;for(let r=0;r<n;r++){t+=Z(e[r]),r!==n-1&&(t+=", ")}return t}function J(e){return"function"===e.type?`function ${e.name}(${K(e.inputs)})${e.stateMutability&&"nonpayable"!==e.stateMutability?` ${e.stateMutability}`:""}${e.outputs?.length?` returns (${K(e.outputs)})`:""}`:"event"===e.type?`event ${e.name}(${K(e.inputs)})`:"error"===e.type?`error ${e.name}(${K(e.inputs)})`:"constructor"===e.type?`constructor(${K(e.inputs)})${"payable"===e.stateMutability?" payable":""}`:"fallback"===e.type?"fallback() external"+("payable"===e.stateMutability?" payable":""):"receive() external payable"}const Q=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const X=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const ee=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;const te=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function ne(e){return te.test(e)}function re(e){return q(te,e)}const oe=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;const se=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;const ae=/^receive\(\) external payable$/;const ie=new Set(["memory","indexed","storage","calldata"]),ce=new Set(["indexed"]),ue=new Set(["calldata","memory","storage"]);class le extends G{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 de extends G{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 fe extends G{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 he extends G{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 pe extends G{constructor({param:e}){super("Invalid ABI parameter.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class me extends G{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 ge extends G{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 be extends G{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 ye extends G{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 we extends G{constructor({signature:e,type:t}){super(`Invalid ${t} signature.`,{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class ve extends G{constructor({signature:e}){super("Unknown signature.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class xe extends G{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 Ee extends G{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 Pe extends G{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 ke=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 Ae(e,t={}){if(function(e){return ee.test(e)}(e))return function(e,t={}){const n=function(e){return q(ee,e)}(e);if(!n)throw new we({signature:e,type:"function"});const r=$e(n.parameters),o=[],s=r.length;for(let e=0;e<s;e++)o.push(Te(r[e],{modifiers:ue,structs:t,type:"function"}));const a=[];if(n.returns){const e=$e(n.returns),r=e.length;for(let n=0;n<r;n++)a.push(Te(e[n],{modifiers:ue,structs:t,type:"function"}))}return{name:n.name,type:"function",stateMutability:n.stateMutability??"nonpayable",inputs:o,outputs:a}}(e,t);if(function(e){return X.test(e)}(e))return function(e,t={}){const n=function(e){return q(X,e)}(e);if(!n)throw new we({signature:e,type:"event"});const r=$e(n.parameters),o=[],s=r.length;for(let e=0;e<s;e++)o.push(Te(r[e],{modifiers:ce,structs:t,type:"event"}));return{name:n.name,type:"event",inputs:o}}(e,t);if(function(e){return Q.test(e)}(e))return function(e,t={}){const n=function(e){return q(Q,e)}(e);if(!n)throw new we({signature:e,type:"error"});const r=$e(n.parameters),o=[],s=r.length;for(let e=0;e<s;e++)o.push(Te(r[e],{structs:t,type:"error"}));return{name:n.name,type:"error",inputs:o}}(e,t);if(function(e){return oe.test(e)}(e))return function(e,t={}){const n=function(e){return q(oe,e)}(e);if(!n)throw new we({signature:e,type:"constructor"});const r=$e(n.parameters),o=[],s=r.length;for(let e=0;e<s;e++)o.push(Te(r[e],{structs:t,type:"constructor"}));return{type:"constructor",stateMutability:n.stateMutability??"nonpayable",inputs:o}}(e,t);if(function(e){return se.test(e)}(e))return function(e){const t=function(e){return q(se,e)}(e);if(!t)throw new we({signature:e,type:"fallback"});return{type:"fallback",stateMutability:t.stateMutability??"nonpayable"}}(e);if(function(e){return ae.test(e)}(e))return{type:"receive",stateMutability:"payable"};throw new ve({signature:e})}const Ie=/^(?<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$_]*))?$/,Ne=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,Se=/^u?int$/;function Te(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}(e,t?.type,t?.structs);if(ke.has(n))return ke.get(n);const r=H.test(e),o=q(r?Ne:Ie,e);if(!o)throw new pe({param:e});if(o.name&&function(e){return"address"===e||"bool"===e||"function"===e||"string"===e||"tuple"===e||V.test(e)||W.test(e)||Ce.test(e)}(o.name))throw new me({param:e,name:o.name});const s=o.name?{name:o.name}:{},a="indexed"===o.modifier?{indexed:!0}:{},i=t?.structs??{};let c,u={};if(r){c="tuple";const e=$e(o.type),t=[],n=e.length;for(let r=0;r<n;r++)t.push(Te(e[r],{structs:i}));u={components:t}}else if(o.type in i)c="tuple",u={components:i[o.type]};else if(Se.test(o.type))c=`${o.type}256`;else if("address payable"===o.type)c="address";else if(c=o.type,"struct"!==t?.type&&!Be(c))throw new fe({type:c});if(o.modifier){if(!t?.modifiers?.has?.(o.modifier))throw new ge({param:e,type:t?.type,modifier:o.modifier});if(ue.has(o.modifier)&&!function(e,t){return t||"bytes"===e||"string"===e||"tuple"===e}(c,!!o.array))throw new be({param:e,type:t?.type,modifier:o.modifier})}const l={type:`${c}${o.array??""}`,...s,...a,...u};return ke.set(n,l),l}function $e(e,t=[],n="",r=0){const o=e.trim().length;for(let s=0;s<o;s++){const o=e[s],a=e.slice(s+1);switch(o){case",":return 0===r?$e(a,[...t,n.trim()]):$e(a,t,`${n}${o}`,r);case"(":return $e(a,t,`${n}${o}`,r+1);case")":return $e(a,t,`${n}${o}`,r-1);default:return $e(a,t,`${n}${o}`,r)}}if(""===n)return t;if(0!==r)throw new Pe({current:n,depth:r});return t.push(n.trim()),t}function Be(e){return"address"===e||"bool"===e||"function"===e||"string"===e||V.test(e)||W.test(e)}const Ce=/^(?: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 Oe(e){const t={},n=e.length;for(let r=0;r<n;r++){const n=e[r];if(!ne(n))continue;const o=re(n);if(!o)throw new we({signature:n,type:"struct"});const s=o.properties.split(";"),a=[],i=s.length;for(let e=0;e<i;e++){const t=s[e].trim();if(!t)continue;const n=Te(t,{type:"struct"});a.push(n)}if(!a.length)throw new xe({signature:n});t[o.name]=a}const r={},o=Object.entries(t),s=o.length;for(let e=0;e<s;e++){const[n,s]=o[e];r[n]=ze(s,t)}return r}const Re=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;function ze(e,t,n=new Set){const r=[],o=e.length;for(let s=0;s<o;s++){const o=e[s];if(H.test(o.type))r.push(o);else{const e=q(Re,o.type);if(!e?.type)throw new ye({abiParameter:o});const{array:s,type:a}=e;if(a in t){if(n.has(a))throw new Ee({type:a});r.push({...o,type:`tuple${s??""}`,components:ze(t[a]??[],t,new Set([...n,a]))})}else{if(!Be(a))throw new de({type:a});r.push(o)}}}return r}function _e(e){const t=Oe(e),n=[],r=e.length;for(let o=0;o<r;o++){const r=e[o];ne(r)||n.push(Ae(r,t))}return n}function Me(e){let t;if("string"==typeof e)t=Ae(e);else{const n=Oe(e),r=e.length;for(let o=0;o<r;o++){const r=e[o];if(!ne(r)){t=Ae(r,n);break}}}if(!t)throw new le({signature:e});return t}function Fe(e){const t=[];if("string"==typeof e){const n=$e(e),r=n.length;for(let e=0;e<r;e++)t.push(Te(n[e],{modifiers:ie}))}else{const n=Oe(e),r=e.length;for(let o=0;o<r;o++){const r=e[o];if(ne(r))continue;const s=$e(r),a=s.length;for(let e=0;e<a;e++)t.push(Te(s[e],{modifiers:ie,structs:n}))}}if(0===t.length)throw new he({params:e});return t}function je(e,t,n){const r=e[t.name];if("function"==typeof r)return r;const o=e[n];return"function"==typeof o?o:n=>t(e,n)}function Le(e,{includeName:t=!1}={}){if("function"!==e.type&&"event"!==e.type&&"error"!==e.type)throw new yt(e.type);return`${e.name}(${Ue(e.inputs,{includeName:t})})`}function Ue(e,{includeName:t=!1}={}){return e?e.map(e=>function(e,{includeName:t}){if(e.type.startsWith("tuple"))return`(${Ue(e.components,{includeName:t})})${e.type.slice(5)}`;return e.type+(t&&e.name?` ${e.name}`:"")}(e,{includeName:t})).join(t?", ":","):""}function De(e,{strict:t=!0}={}){return!!e&&("string"==typeof e&&(t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")))}function Ge(e){return De(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const qe="2.37.8";let Ve=({docsBaseUrl:e,docsPath:t="",docsSlug:n})=>t?`${e??"https://viem.sh"}${t}${n?`#${n}`:""}`:void 0,We=`viem@${qe}`,He=class e extends Error{constructor(t,n={}){const r=n.cause instanceof e?n.cause.details:n.cause?.message?n.cause.message:n.details,o=n.cause instanceof e&&n.cause.docsPath||n.docsPath,s=Ve?.({...n,docsPath:o});super([t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...r?[`Details: ${r}`]:[],...We?[`Version: ${We}`]:[]].join("\n"),n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=o,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=t,this.version=qe}walk(e){return Ye(this,e)}};function Ye(e,t){return t?.(e)?e:e&&"object"==typeof e&&"cause"in e&&void 0!==e.cause?Ye(e.cause,t):t?null:e}class Ze extends He{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 Ke extends He{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 Je extends He{constructor({data:e,params:t,size:n}){super([`Data size of ${n} bytes is too small for given parameters.`].join("\n"),{metaMessages:[`Params: (${Ue(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 Qe extends He{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.',{name:"AbiDecodingZeroDataError"})}}class Xe extends He{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 et extends He{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${Ge(t)}) does not match expected size (bytes${e}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class tt extends He{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 nt extends He{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"})}}class rt extends He{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"})}}class ot extends He{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 st extends He{constructor({docsPath:e}){super("Cannot extract event signature from empty topics.",{docsPath:e,name:"AbiEventSignatureEmptyTopicsError"})}}class at extends He{constructor(e,{docsPath:t}){super([`Encoded event signature "${e}" not found on ABI.`,"Make sure you are using the correct ABI and that the event exists on it.",`You can look up the signature here: https://openchain.xyz/signatures?query=${e}.`].join("\n"),{docsPath:t,name:"AbiEventSignatureNotFoundError"})}}class it extends He{constructor(e,{docsPath:t}={}){super([`Event ${e?`"${e}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the event exists on it."].join("\n"),{docsPath:t,name:"AbiEventNotFoundError"})}}class ct extends He{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 ut extends He{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 lt extends He{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"})}}class dt extends He{constructor(e,t){super("Found ambiguous types in overloaded ABI items.",{metaMessages:[`\`${e.type}\` in \`${Le(e.abiItem)}\`, and`,`\`${t.type}\` in \`${Le(t.abiItem)}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."],name:"AbiItemAmbiguityError"})}}let ft=class extends He{constructor({expectedSize:e,givenSize:t}){super(`Expected bytes${e}, got bytes${t}.`,{name:"BytesSizeMismatchError"})}};class ht extends He{constructor({abiItem:e,data:t,params:n,size:r}){super([`Data size of ${r} bytes is too small for non-indexed event parameters.`].join("\n"),{metaMessages:[`Params: (${Ue(n,{includeName:!0})})`,`Data: ${t} (${r} bytes)`],name:"DecodeLogDataMismatch"}),Object.defineProperty(this,"abiItem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),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.abiItem=e,this.data=t,this.params=n,this.size=r}}class pt extends He{constructor({abiItem:e,param:t}){super([`Expected a topic for indexed event parameter${t.name?` "${t.name}"`:""} on event "${Le(e,{includeName:!0})}".`].join("\n"),{name:"DecodeLogTopicsMismatch"}),Object.defineProperty(this,"abiItem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abiItem=e}}class mt extends He{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 gt extends He{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"})}}let bt=class extends He{constructor(e){super([`Value "${e}" is not a valid array.`].join("\n"),{name:"InvalidArrayError"})}};class yt extends He{constructor(e){super([`"${e}" is not a valid definition type.`,'Valid types: "function", "event", "error"'].join("\n"),{name:"InvalidDefinitionTypeError"})}}class wt extends He{constructor(e){super(`Filter type "${e}" is not supported.`,{name:"FilterTypeNotSupportedError"})}}let vt=class extends He{constructor({offset:e,position:t,size:n}){super(`Slice ${"start"===t?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}},xt=class extends He{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 Et extends He{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 Pt(e,{dir:t,size:n=32}={}){return"string"==typeof e?kt(e,{dir:t,size:n}):function(e,{dir:t,size:n=32}={}){if(null===n)return e;if(e.length>n)throw new xt({size:e.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let o=0;o<n;o++){const s="right"===t;r[s?o:n-o-1]=e[s?o:e.length-o-1]}return r}(e,{dir:t,size:n})}function kt(e,{dir:t,size:n=32}={}){if(null===n)return e;const r=e.replace("0x","");if(r.length>2*n)throw new xt({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r["right"===t?"padEnd":"padStart"](2*n,"0")}`}let At=class extends He{constructor({max:e,min:t,signed:n,size:r,value:o}){super(`Number "${o}" is not in safe ${r?`${8*r}-bit ${n?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}},It=class extends He{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 Nt extends He{constructor(e){super(`Hex value "${e}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`,{name:"InvalidHexBooleanError"})}}let St=class extends He{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}};function Tt(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 $t(e,{size:t}){if(Ge(e)>t)throw new St({givenSize:Ge(e),maxSize:t})}function Bt(e,t={}){const{signed:n}=t;t.size&&$t(e,{size:t.size});const r=BigInt(e);if(!n)return r;const o=(e.length-2)/2;return r<=(1n<<8n*BigInt(o)-1n)-1n?r:r-BigInt(`0x${"f".padStart(2*o,"f")}`)-1n}function Ct(e,t={}){return Number(Bt(e,t))}const Ot=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Rt(e,t={}){return"number"==typeof e||"bigint"==typeof e?Mt(e,t):"string"==typeof e?jt(e,t):"boolean"==typeof e?zt(e,t):_t(e,t)}function zt(e,t={}){const n=`0x${Number(e)}`;return"number"==typeof t.size?($t(n,{size:t.size}),Pt(n,{size:t.size})):n}function _t(e,t={}){let n="";for(let t=0;t<e.length;t++)n+=Ot[e[t]];const r=`0x${n}`;return"number"==typeof t.size?($t(r,{size:t.size}),Pt(r,{dir:"right",size:t.size})):r}function Mt(e,t={}){const{signed:n,size:r}=t,o=BigInt(e);let s;r?s=n?(1n<<8n*BigInt(r)-1n)-1n:2n**(8n*BigInt(r))-1n:"number"==typeof e&&(s=BigInt(Number.MAX_SAFE_INTEGER));const a="bigint"==typeof s&&n?-s-1n:0;if(s&&o>s||o<a){const t="bigint"==typeof e?"n":"";throw new At({max:s?`${s}${t}`:void 0,min:`${a}${t}`,signed:n,size:r,value:`${e}${t}`})}const i=`0x${(n&&o<0?(1n<<BigInt(8*r))+BigInt(o):o).toString(16)}`;return r?Pt(i,{size:r}):i}const Ft=new TextEncoder;function jt(e,t={}){return _t(Ft.encode(e),t)}const Lt=new TextEncoder;function Ut(e,t={}){return"number"==typeof e||"bigint"==typeof e?function(e,t){const n=Mt(e,t);return qt(n)}(e,t):"boolean"==typeof e?function(e,t={}){const n=new Uint8Array(1);if(n[0]=Number(e),"number"==typeof t.size)return $t(n,{size:t.size}),Pt(n,{size:t.size});return n}(e,t):De(e)?qt(e,t):Vt(e,t)}const Dt={zero:48,nine:57,A:65,F:70,a:97,f:102};function Gt(e){return e>=Dt.zero&&e<=Dt.nine?e-Dt.zero:e>=Dt.A&&e<=Dt.F?e-(Dt.A-10):e>=Dt.a&&e<=Dt.f?e-(Dt.a-10):void 0}function qt(e,t={}){let n=e;t.size&&($t(n,{size:t.size}),n=Pt(n,{dir:"right",size:t.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const o=r.length/2,s=new Uint8Array(o);for(let e=0,t=0;e<o;e++){const n=Gt(r.charCodeAt(t++)),o=Gt(r.charCodeAt(t++));if(void 0===n||void 0===o)throw new He(`Invalid byte sequence ("${r[t-2]}${r[t-1]}" in "${r}").`);s[e]=16*n+o}return s}function Vt(e,t={}){const n=Lt.encode(e);return"number"==typeof t.size?($t(n,{size:t.size}),Pt(n,{dir:"right",size:t.size})):n}const Wt=BigInt(2**32-1),Ht=BigInt(32);function Yt(e,t=!1){return t?{h:Number(e&Wt),l:Number(e>>Ht&Wt)}:{h:0|Number(e>>Ht&Wt),l:0|Number(e&Wt)}}const Zt="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function Kt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Jt(e,...t){if(!((n=e)instanceof Uint8Array||ArrayBuffer.isView(n)&&"Uint8Array"===n.constructor.name))throw new Error("Uint8Array expected");
|
|
2
2
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3
|
-
var n;if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Jt(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 Qt(e,t){Kt(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Xt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function en(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function tn(e,t){return e<<32-t|e>>>t}function nn(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const rn=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])()?e=>e:function(e){for(let t=0;t<e.length;t++)e[t]=nn(e[t]);return e};function on(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)),Kt(e),e}class sn{}function an(e){const t=t=>e().update(on(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function cn(e=32){if(Yt&&"function"==typeof Yt.getRandomValues)return Yt.getRandomValues(new Uint8Array(e));if(Yt&&"function"==typeof Yt.randomBytes)return Uint8Array.from(Yt.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}const un=BigInt(0),ln=BigInt(1),dn=BigInt(2),fn=BigInt(7),hn=BigInt(256),pn=BigInt(113),mn=[],gn=[],bn=[];for(let e=0,t=ln,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],mn.push(2*(5*r+n)),gn.push((e+1)*(e+2)/2%64);let o=un;for(let e=0;e<7;e++)t=(t<<ln^(t>>fn)*pn)%hn,t&dn&&(o^=ln<<(ln<<BigInt(e))-ln);bn.push(o)}const yn=function(e,t=!1){const n=e.length;let r=new Uint32Array(n),o=new Uint32Array(n);for(let s=0;s<n;s++){const{h:n,l:a}=Ht(e[s],t);[r[s],o[s]]=[n,a]}return[r,o]}(bn,!0),wn=yn[0],vn=yn[1],xn=(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),En=(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 Pn extends sn{constructor(e,t,n,r=!1,o=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=o,Zt(n),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");var s;this.state=new Uint8Array(200),this.state32=(s=this.state,new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4)))}clone(){return this._cloneInto()}keccak(){rn(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,o=(t+2)%10,s=n[o],a=n[o+1],i=xn(s,a,1)^n[r],c=En(s,a,1)^n[r+1];for(let n=0;n<50;n+=10)e[t+n]^=i,e[t+n+1]^=c}let t=e[2],o=e[3];for(let n=0;n<24;n++){const r=gn[n],s=xn(t,o,r),a=En(t,o,r),i=mn[n];t=e[i],o=e[i+1],e[i]=s,e[i+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]^=wn[r],e[1]^=vn[r]}Xt(n)}(this.state32,this.rounds),rn(this.state32),this.posOut=0,this.pos=0}update(e){Jt(this),Kt(e=on(e));const{blockLen:t,state:n}=this,r=e.length;for(let o=0;o<r;){const s=Math.min(t-this.pos,r-o);for(let t=0;t<s;t++)n[this.pos++]^=e[o++];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,128&t&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){Jt(this,!1),Kt(e),this.finish();const t=this.state,{blockLen:n}=this;for(let r=0,o=e.length;r<o;){this.posOut>=n&&this.keccak();const s=Math.min(n-this.posOut,o-r);e.set(t.subarray(this.posOut,this.posOut+s),r),this.posOut+=s,r+=s}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Zt(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Qt(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,Xt(this.state)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:r,rounds:o,enableXOF:s}=this;return e||(e=new Pn(t,n,r,s,o)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=o,e.suffix=n,e.outputLen=r,e.enableXOF=s,e.destroyed=this.destroyed,e}}const kn=(()=>{return e=1,t=136,n=32,an(()=>new Pn(t,e,n));var e,t,n})();function An(e,t){const n=t||"hex",r=kn(Ue(e,{strict:!1})?Lt(e):e);return"bytes"===n?r:Ot(r)}function In(e){return An(Lt(e))}const Nn=e=>function(e){let t=!0,n="",r=0,o="",s=!1;for(let a=0;a<e.length;a++){const i=e[a];if(["(",")",","].includes(i)&&(t=!0),"("===i&&r++,")"===i&&r--,t)if(0!==r)" "!==i?(o+=i,n+=i):","!==e[a-1]&&","!==n&&",("!==n&&(n="",t=!1);else if(" "===i&&["event","function",""].includes(o))o="";else if(o+=i,")"===i){s=!0;break}}if(!s)throw new We("Unable to normalize signature.");return o}("string"==typeof e?e:K(e));function Sn(e){return In(Nn(e))}const Tn=Sn;let $n=class extends We{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"})}},Bn=class 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 Cn=new Bn(8192);function On(e,t){if(Cn.has(`${e}.${t}`))return Cn.get(`${e}.${t}`);const n=e.substring(2).toLowerCase(),r=An(qt(n),"bytes"),o=n.split("");for(let e=0;e<40;e+=2)r[e>>1]>>4>=8&&o[e]&&(o[e]=o[e].toUpperCase()),(15&r[e>>1])>=8&&o[e+1]&&(o[e+1]=o[e+1].toUpperCase());const s=`0x${o.join("")}`;return Cn.set(`${e}.${t}`,s),s}function Rn(e,t){if(!Mn(e,{strict:!1}))throw new $n({address:e});return On(e,t)}const zn=/^0x[a-fA-F0-9]{40}$/,_n=new Bn(8192);function Mn(e,t){const{strict:n=!0}=t??{},r=`${e}.${n}`;if(_n.has(r))return _n.get(r);const o=!(!zn.test(e)||e.toLowerCase()!==e&&n&&On(e)!==e);return _n.set(r,o),o}function Fn(e){return"string"==typeof e[0]?jn(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 jn(e){return`0x${e.reduce((e,t)=>e+t.replace("0x",""),"")}`}function Ln(e,t,n,{strict:r}={}){return Ue(e,{strict:!1})?function(e,t,n,{strict:r}={}){Un(e,t);const o=`0x${e.replace("0x","").slice(2*(t??0),2*(n??e.length))}`;r&&Dn(o,t,n);return o}(e,t,n,{strict:r}):Gn(e,t,n,{strict:r})}function Un(e,t){if("number"==typeof t&&t>0&&t>De(e)-1)throw new wt({offset:t,position:"start",size:De(e)})}function Dn(e,t,n){if("number"==typeof t&&"number"==typeof n&&De(e)!==n-t)throw new wt({offset:n,position:"end",size:De(e)})}function Gn(e,t,n,{strict:r}={}){Un(e,t);const o=e.slice(t,n);return r&&Dn(o,t,n),o}const qn=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Vn=/^(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 Wn(e,t){if(e.length!==t.length)throw new et({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(Hn({param:e[r],value:t[r]}));return n}({params:e,values:t}),r=Yn(n);return 0===r.length?"0x":r}function Hn({param:e,value:t}){const n=Zn(e.type);if(n){const[r,o]=n;return function(e,{length:t,param:n}){const r=null===t;if(!Array.isArray(e))throw new gt(e);if(!r&&e.length!==t)throw new Qe({expectedLength:t,givenLength:e.length,type:`${n.type}[${t}]`});let o=!1;const s=[];for(let t=0;t<e.length;t++){const r=Hn({param:n,value:e[t]});r.dynamic&&(o=!0),s.push(r)}if(r||o){const e=Yn(s);if(r){const t=_t(s.length,{size:32});return{dynamic:!0,encoded:s.length>0?Fn([t,e]):t}}if(o)return{dynamic:!0,encoded:e}}return{dynamic:!1,encoded:Fn(s.map(({encoded:e})=>e))}}(t,{length:r,param:{...e,type:o}})}if("tuple"===e.type)return function(e,{param:t}){let n=!1;const r=[];for(let o=0;o<t.components.length;o++){const s=t.components[o],a=Hn({param:s,value:e[Array.isArray(e)?o:s.name]});r.push(a),a.dynamic&&(n=!0)}return{dynamic:n,encoded:n?Yn(r):Fn(r.map(({encoded:e})=>e))}}(t,{param:e});if("address"===e.type)return function(e){if(!Mn(e))throw new $n({address:e});return{dynamic:!1,encoded:Pt(e.toLowerCase())}}(t);if("bool"===e.type)return function(e){if("boolean"!=typeof e)throw new We(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:Pt(Rt(e))}}(t);if(e.type.startsWith("uint")||e.type.startsWith("int")){const n=e.type.startsWith("int"),[,,r="256"]=Vn.exec(e.type)??[];return function(e,{signed:t,size:n=256}){if("number"==typeof n){const r=2n**(BigInt(n)-(t?1n:0n))-1n,o=t?-r-1n:0n;if(e>r||e<o)throw new kt({max:r.toString(),min:o.toString(),signed:t,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:_t(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=De(e);if(!n){let t=e;return r%32!=0&&(t=Pt(t,{dir:"right",size:32*Math.ceil((e.length-2)/2/32)})),{dynamic:!0,encoded:Fn([Pt(_t(r,{size:32})),t])}}if(r!==Number.parseInt(n,10))throw new Xe({expectedSize:Number.parseInt(n,10),value:e});return{dynamic:!1,encoded:Pt(e,{dir:"right"})}}(t,{param:e});if("string"===e.type)return function(e){const t=Ft(e),n=Math.ceil(De(t)/32),r=[];for(let e=0;e<n;e++)r.push(Pt(Ln(t,32*e,32*(e+1)),{dir:"right"}));return{dynamic:!0,encoded:Fn([Pt(_t(De(t),{size:32})),...r])}}(t);throw new pt(e.type,{docsPath:"/docs/contract/encodeAbiParameters"})}function Yn(e){let t=0;for(let n=0;n<e.length;n++){const{dynamic:r,encoded:o}=e[n];t+=r?32:De(o)}const n=[],r=[];let o=0;for(let s=0;s<e.length;s++){const{dynamic:a,encoded:i}=e[s];a?(n.push(_t(t+o,{size:32})),r.push(i),o+=De(i)):n.push(i)}return Fn([...n,...r])}function Zn(e){const t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}const Kn=e=>Ln(Sn(e),0,4);function Jn(e){const{abi:t,args:n=[],name:r}=e,o=Ue(r,{strict:!1}),s=t.filter(e=>o?"function"===e.type?Kn(e)===r:"event"===e.type&&Tn(e)===r:"name"in e&&e.name===r);if(0===s.length)return;if(1===s.length)return s[0];let a;for(const e of s){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&&Qn(t,r)});if(t){if(a&&"inputs"in a&&a.inputs){const t=Xn(e.inputs,a.inputs,n);if(t)throw new lt({abiItem:e,type:t[0]},{abiItem:a,type:t[1]})}a=e}}return a||s[0]}function Qn(e,t){const n=typeof e,r=t.type;switch(r){case"address":return Mn(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)=>Qn(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=>Qn(e,{...t,type:r.replace(/(\[[0-9]{0,}\])$/,"")})))}}function Xn(e,t,n){for(const r in e){const o=e[r],s=t[r];if("tuple"===o.type&&"tuple"===s.type&&"components"in o&&"components"in s)return Xn(o.components,s.components,n[r]);const a=[o.type,s.type];if((()=>!(!a.includes("address")||!a.includes("bytes20"))||(a.includes("address")&&a.includes("string")||!(!a.includes("address")||!a.includes("bytes")))&&Mn(n[r],{strict:!1}))())return a}}const er="/docs/contract/encodeEventTopics";function tr(e){const{abi:t,eventName:n,args:r}=e;let o=t[0];if(n){const e=Jn({abi:t,name:n});if(!e)throw new at(n,{docsPath:er});o=e}if("event"!==o.type)throw new at(void 0,{docsPath:er});const s=je(o),a=Tn(s);let i=[];if(r&&"inputs"in o){const e=o.inputs?.filter(e=>"indexed"in e&&e.indexed),t=Array.isArray(r)?r:Object.values(r).length>0?e?.map(e=>r[e.name])??[]:[];t.length>0&&(i=e?.map((e,n)=>Array.isArray(t[n])?t[n].map((r,o)=>nr({param:e,value:t[n][o]})):void 0!==t[n]&&null!==t[n]?nr({param:e,value:t[n]}):null)??[])}return[a,...i]}function nr({param:e,value:t}){if("string"===e.type||"bytes"===e.type)return An(Lt(t));if("tuple"===e.type||e.type.match(/^(.*)\[(\d+)?\]$/))throw new yt(e.type);return Wn([e],[t])}function rr(e,{method:t}){const n={};return"fallback"===e.transport.type&&e.transport.onResponse?.(({method:e,response:r,status:o,transport:s})=>{"success"===o&&t===e&&(n[r]=s.request)}),t=>n[t]||e.request}async function or(e,t){const{address:n,abi:r,args:o,eventName:s,fromBlock:a,strict:i,toBlock:c}=t,u=rr(e,{method:"eth_newFilter"}),l=s?tr({abi:r,args:o,eventName:s}):void 0,d=await e.request({method:"eth_newFilter",params:[{address:n,fromBlock:"bigint"==typeof a?_t(a):a,toBlock:"bigint"==typeof c?_t(c):c,topics:l}]});return{abi:r,args:o,eventName:s,id:d,request:u(d),strict:Boolean(i),type:"event"}}function sr(e){return"string"==typeof e?{address:e,type:"json-rpc"}:e}const ar="/docs/contract/encodeFunctionData";function ir(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 o=t[0];if(r){const e=Jn({abi:t,args:n,name:r});if(!e)throw new it(r,{docsPath:ar});o=e}if("function"!==o.type)throw new it(void 0,{docsPath:ar});return{abi:[o],functionName:Kn(je(o))}}(e),o=n[0];return jn([r,("inputs"in o&&o.inputs?Wn(o.inputs,t??[]):void 0)??"0x"])}const cr={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."},ur={inputs:[{name:"message",type:"string"}],name:"Error",type:"error"},lr={inputs:[{name:"reason",type:"uint256"}],name:"Panic",type:"error"};let dr=class extends We{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`,{name:"NegativeOffsetError"})}},fr=class extends We{constructor({length:e,position:t}){super(`Position \`${t}\` is out of bounds (\`0 < position < ${e}\`).`,{name:"PositionOutOfBoundsError"})}},hr=class extends We{constructor({count:e,limit:t}){super(`Recursive read limit of \`${t}\` exceeded (recursive read count: \`${e}\`).`,{name:"RecursiveReadLimitExceededError"})}};const pr={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 hr({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new fr({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new dr({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 dr({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 mr(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(pr);return n.bytes=e,n.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=t,n}function gr(e,t={}){void 0!==t.size&&Tt(e,{size:t.size});return $t(zt(e,t),t)}function br(e,t={}){let n=e;if(void 0!==t.size&&(Tt(n,{size:t.size}),n=St(n)),n.length>1||n[0]>1)throw new At(n);return Boolean(n[0])}function yr(e,t={}){void 0!==t.size&&Tt(e,{size:t.size});return Bt(zt(e,t),t)}function wr(e,t){const n="string"==typeof t?Gt(t):t,r=mr(n);if(0===De(n)&&e.length>0)throw new Je;if(De(t)&&De(t)<32)throw new Ke({data:"string"==typeof t?t:zt(t),params:e,size:De(t)});let o=0;const s=[];for(let t=0;t<e.length;++t){const n=e[t];r.setPosition(o);const[a,i]=vr(r,n,{staticPosition:0});o+=i,s.push(a)}return s}function vr(e,t,{staticPosition:n}){const r=Zn(t.type);if(r){const[o,s]=r;return function(e,t,{length:n,staticPosition:r}){if(!n){const n=r+yr(e.readBytes(Er)),o=n+xr;e.setPosition(n);const s=yr(e.readBytes(xr)),a=Pr(t);let i=0;const c=[];for(let n=0;n<s;++n){e.setPosition(o+(a?32*n:i));const[r,s]=vr(e,t,{staticPosition:o});i+=s,c.push(r)}return e.setPosition(r+32),[c,32]}if(Pr(t)){const o=r+yr(e.readBytes(Er)),s=[];for(let r=0;r<n;++r){e.setPosition(o+32*r);const[n]=vr(e,t,{staticPosition:o});s.push(n)}return e.setPosition(r+32),[s,32]}let o=0;const s=[];for(let a=0;a<n;++a){const[n,a]=vr(e,t,{staticPosition:r+o});o+=a,s.push(n)}return[s,o]}(e,{...t,type:s},{length:o,staticPosition:n})}if("tuple"===t.type)return function(e,t,{staticPosition:n}){const r=0===t.components.length||t.components.some(({name:e})=>!e),o=r?[]:{};let s=0;if(Pr(t)){const a=n+yr(e.readBytes(Er));for(let n=0;n<t.components.length;++n){const i=t.components[n];e.setPosition(a+s);const[c,u]=vr(e,i,{staticPosition:a});s+=u,o[r?n:i?.name]=c}return e.setPosition(n+32),[o,32]}for(let a=0;a<t.components.length;++a){const i=t.components[a],[c,u]=vr(e,i,{staticPosition:n});o[r?a:i?.name]=c,s+=u}return[o,s]}(e,t,{staticPosition:n});if("address"===t.type)return function(e){const t=e.readBytes(32);return[On(zt(Gn(t,-20))),32]}(e);if("bool"===t.type)return function(e){return[br(e.readBytes(32),{size:32}),32]}(e);if(t.type.startsWith("bytes"))return function(e,t,{staticPosition:n}){const[r,o]=t.type.split("bytes");if(!o){const t=yr(e.readBytes(32));e.setPosition(n+t);const r=yr(e.readBytes(32));if(0===r)return e.setPosition(n+32),["0x",32];const o=e.readBytes(r);return e.setPosition(n+32),[zt(o),32]}const s=zt(e.readBytes(Number.parseInt(o,10),32));return[s,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),o=e.readBytes(32);return[r>48?gr(o,{signed:n}):yr(o,{signed:n}),32]}(e,t);if("string"===t.type)return function(e,{staticPosition:t}){const n=yr(e.readBytes(32)),r=t+n;e.setPosition(r);const o=yr(e.readBytes(32));if(0===o)return e.setPosition(t+32),["",32];const s=e.readBytes(o,32),a=function(e,t={}){let n=e;return void 0!==t.size&&(Tt(n,{size:t.size}),n=St(n,{dir:"right"})),(new TextDecoder).decode(n)}(St(s));return e.setPosition(t+32),[a,32]}(e,{staticPosition:n});throw new mt(t.type,{docsPath:"/docs/contract/decodeAbiParameters"})}const xr=32,Er=32;function Pr(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(Pr);const n=Zn(e.type);return!(!n||!Pr({...e,type:n[1]}))}function kr(e){const{abi:t,data:n}=e,r=Ln(n,0,4);if("0x"===r)throw new Je;const o=[...t||[],ur,lr].find(e=>"error"===e.type&&r===Kn(je(e)));if(!o)throw new rt(r,{docsPath:"/docs/contract/decodeErrorResult"});return{abiItem:o,args:"inputs"in o&&o.inputs&&o.inputs.length>0?wr(o.inputs,Ln(n,4)):void 0,errorName:o.name}}const Ar=(e,t,n)=>JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString():t,n);function Ir({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]?Ar(t[n]):t[n]}`).join(", ")})`}const Nr={gwei:9,wei:18},Sr={ether:-9,wei:9};function Tr(e,t){let n=e.toString();const r=n.startsWith("-");r&&(n=n.slice(1)),n=n.padStart(t,"0");let[o,s]=[n.slice(0,n.length-t),n.slice(n.length-t)];return s=s.replace(/(0+)$/,""),`${r?"-":""}${o||"0"}${s?`.${s}`:""}`}function $r(e,t="wei"){return Tr(e,Nr[t])}function Br(e,t="wei"){return Tr(e,Sr[t])}class Cr extends We{constructor({address:e}){super(`State for account "${e}" is set multiple times.`,{name:"AccountStateConflictError"})}}class Or extends We{constructor(){super("state and stateDiff are set on the same account.",{name:"StateAssignmentConflictError"})}}function Rr(e){return e.reduce((e,{slot:t,value:n})=>`${e} ${t}: ${n}\n`,"")}function zr(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 _r extends We{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 Mr extends We{constructor({transaction:e}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",zr(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 Fr extends We{constructor({blockHash:e,blockNumber:t,blockTag:n,hash:r,index:o}){let s="Transaction";n&&void 0!==o&&(s=`Transaction at block time "${n}" at index "${o}"`),e&&void 0!==o&&(s=`Transaction at block hash "${e}" at index "${o}"`),t&&void 0!==o&&(s=`Transaction at block number "${t}" at index "${o}"`),r&&(s=`Transaction with hash "${r}"`),super(`${s} could not be found.`,{name:"TransactionNotFoundError"})}}class jr extends We{constructor({hash:e}){super(`Transaction receipt with hash "${e}" could not be found. The Transaction may not be processed on a block yet.`,{name:"TransactionReceiptNotFoundError"})}}class Lr extends We{constructor({hash:e}){super(`Timed out while waiting for transaction with hash "${e}" to be confirmed.`,{name:"WaitForTransactionReceiptTimeoutError"})}}class Ur extends We{constructor(e,{account:t,docsPath:n,chain:r,data:o,gas:s,gasPrice:a,maxFeePerGas:i,maxPriorityFeePerGas:c,nonce:u,to:l,value:d,stateOverride:f}){const h=t?sr(t):void 0;let p=zr({from:h?.address,to:l,value:void 0!==d&&`${$r(d)} ${r?.nativeCurrency?.symbol||"ETH"}`,data:o,gas:s,gasPrice:void 0!==a&&`${Br(a)} gwei`,maxFeePerGas:void 0!==i&&`${Br(i)} gwei`,maxPriorityFeePerGas:void 0!==c&&`${Br(c)} gwei`,nonce:u});f&&(p+=`\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+=Rr(n.state)),n.stateDiff&&(r+=" stateDiff:\n",r+=Rr(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:",p].filter(Boolean),name:"CallExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=e}}class Dr extends We{constructor(e,{abi:t,args:n,contractAddress:r,docsPath:o,functionName:s,sender:a}){const i=Jn({abi:t,args:n,name:s}),c=i?Ir({abiItem:i,args:n,includeFunctionName:!1,includeName:!1}):void 0,u=zr({address:r&&r,function:i?je(i,{includeName:!0}):void 0,args:c&&"()"!==c&&`${[...Array(s?.length??0).keys()].map(()=>" ").join("")}${c}`,sender:a});super(e.shortMessage||`An unknown error occurred while executing the contract function "${s}".`,{cause:e,docsPath:o,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=s,this.sender=a}}class Gr extends We{constructor({abi:e,data:t,functionName:n,message:r}){let o,s,a,i,c;if(t&&"0x"!==t)try{s=kr({abi:e,data:t});const{abiItem:n,errorName:r,args:o}=s;if("Error"===r)i=o[0];else if("Panic"===r){const[e]=o;i=cr[e]}else{const e=n?je(n,{includeName:!0}):void 0,t=n&&o?Ir({abiItem:n,args:o,includeFunctionName:!1,includeName:!1}):void 0;a=[e?`Error: ${e}`:"",t&&"()"!==t?` ${[...Array(r?.length??0).keys()].map(()=>" ").join("")}${t}`:""]}}catch(e){o=e}else r&&(i=r);o instanceof rt&&(c=o.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(i&&"execution reverted"!==i||c?[`The contract function "${n}" reverted with the following ${c?"signature":"reason"}:`,i||c].join("\n"):`The contract function "${n}" reverted.`,{cause:o,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=s,this.raw=t,this.reason=i,this.signature=c}}class qr extends We{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 Vr extends We{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 Wr extends We{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 Hr extends We{constructor({body:e,cause:t,details:n,headers:r,status:o,url:s}){super("HTTP request failed.",{cause:t,details:n,metaMessages:[o&&`Status: ${o}`,`URL: ${s}`,e&&`Request body: ${Ar(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=o,this.url=s}}class Yr extends We{constructor({body:e,error:t,url:n}){super("RPC Request failed.",{cause:t,details:t.message,metaMessages:[`URL: ${n}`,`Request body: ${Ar(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 Zr extends We{constructor({body:e,url:t}){super("The request took too long to respond.",{details:"The request timed out.",metaMessages:[`URL: ${t}`,`Request body: ${Ar(e)}`],name:"TimeoutError"})}}class Kr extends We{constructor(e,{code:t,docsPath:n,metaMessages:r,name:o,shortMessage:s}){super(s,{cause:e,docsPath:n,metaMessages:r||e?.metaMessages,name:o||"RpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=o||e.name,this.code=e instanceof Yr?e.code:t??-1}}class Jr extends Kr{constructor(e,t){super(e,t),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=t.data}}class Qr extends Kr{constructor(e){super(e,{code:Qr.code,name:"ParseRpcError",shortMessage:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."})}}Object.defineProperty(Qr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class Xr extends Kr{constructor(e){super(e,{code:Xr.code,name:"InvalidRequestRpcError",shortMessage:"JSON is not a valid request object."})}}Object.defineProperty(Xr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class eo extends Kr{constructor(e,{method:t}={}){super(e,{code:eo.code,name:"MethodNotFoundRpcError",shortMessage:`The method${t?` "${t}"`:""} does not exist / is not available.`})}}Object.defineProperty(eo,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class to extends Kr{constructor(e){super(e,{code:to.code,name:"InvalidParamsRpcError",shortMessage:["Invalid parameters were provided to the RPC method.","Double check you have provided the correct parameters."].join("\n")})}}Object.defineProperty(to,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class no extends Kr{constructor(e){super(e,{code:no.code,name:"InternalRpcError",shortMessage:"An internal error was received."})}}Object.defineProperty(no,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class ro extends Kr{constructor(e){super(e,{code:ro.code,name:"InvalidInputRpcError",shortMessage:["Missing or invalid parameters.","Double check you have provided the correct parameters."].join("\n")})}}Object.defineProperty(ro,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class oo extends Kr{constructor(e){super(e,{code:oo.code,name:"ResourceNotFoundRpcError",shortMessage:"Requested resource not found."}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ResourceNotFoundRpcError"})}}Object.defineProperty(oo,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class so extends Kr{constructor(e){super(e,{code:so.code,name:"ResourceUnavailableRpcError",shortMessage:"Requested resource not available."})}}Object.defineProperty(so,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class ao extends Kr{constructor(e){super(e,{code:ao.code,name:"TransactionRejectedRpcError",shortMessage:"Transaction creation failed."})}}Object.defineProperty(ao,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class io extends Kr{constructor(e,{method:t}={}){super(e,{code:io.code,name:"MethodNotSupportedRpcError",shortMessage:`Method${t?` "${t}"`:""} is not supported.`})}}Object.defineProperty(io,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class co extends Kr{constructor(e){super(e,{code:co.code,name:"LimitExceededRpcError",shortMessage:"Request exceeds defined limit."})}}Object.defineProperty(co,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class uo extends Kr{constructor(e){super(e,{code:uo.code,name:"JsonRpcVersionUnsupportedError",shortMessage:"Version of JSON-RPC protocol is not supported."})}}Object.defineProperty(uo,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});class lo extends Jr{constructor(e){super(e,{code:lo.code,name:"UserRejectedRequestError",shortMessage:"User rejected the request."})}}Object.defineProperty(lo,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class fo extends Jr{constructor(e){super(e,{code:fo.code,name:"UnauthorizedProviderError",shortMessage:"The requested method and/or account has not been authorized by the user."})}}Object.defineProperty(fo,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class ho extends Jr{constructor(e,{method:t}={}){super(e,{code:ho.code,name:"UnsupportedProviderMethodError",shortMessage:`The Provider does not support the requested method${t?` " ${t}"`:""}.`})}}Object.defineProperty(ho,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class po extends Jr{constructor(e){super(e,{code:po.code,name:"ProviderDisconnectedError",shortMessage:"The Provider is disconnected from all chains."})}}Object.defineProperty(po,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});class mo extends Jr{constructor(e){super(e,{code:mo.code,name:"ChainDisconnectedError",shortMessage:"The Provider is not connected to the requested chain."})}}Object.defineProperty(mo,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});class go extends Jr{constructor(e){super(e,{code:go.code,name:"SwitchChainError",shortMessage:"An error occurred when attempting to switch chain."})}}Object.defineProperty(go,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902});class bo extends Jr{constructor(e){super(e,{code:bo.code,name:"UnsupportedNonOptionalCapabilityError",shortMessage:"This Wallet does not support a capability that was not marked as optional."})}}Object.defineProperty(bo,"code",{enumerable:!0,configurable:!0,writable:!0,value:5700});class yo extends Jr{constructor(e){super(e,{code:yo.code,name:"UnsupportedChainIdError",shortMessage:"This Wallet does not support the requested chain ID."})}}Object.defineProperty(yo,"code",{enumerable:!0,configurable:!0,writable:!0,value:5710});class wo extends Jr{constructor(e){super(e,{code:wo.code,name:"DuplicateIdError",shortMessage:"There is already a bundle submitted with this ID."})}}Object.defineProperty(wo,"code",{enumerable:!0,configurable:!0,writable:!0,value:5720});class vo extends Jr{constructor(e){super(e,{code:vo.code,name:"UnknownBundleIdError",shortMessage:"This bundle id is unknown / has not been submitted"})}}Object.defineProperty(vo,"code",{enumerable:!0,configurable:!0,writable:!0,value:5730});class xo extends Jr{constructor(e){super(e,{code:xo.code,name:"BundleTooLargeError",shortMessage:"The call bundle is too large for the Wallet to process."})}}Object.defineProperty(xo,"code",{enumerable:!0,configurable:!0,writable:!0,value:5740});class Eo extends Jr{constructor(e){super(e,{code:Eo.code,name:"AtomicReadyWalletRejectedUpgradeError",shortMessage:"The Wallet can support atomicity after an upgrade, but the user rejected the upgrade."})}}Object.defineProperty(Eo,"code",{enumerable:!0,configurable:!0,writable:!0,value:5750});class Po extends Jr{constructor(e){super(e,{code:Po.code,name:"AtomicityNotSupportedError",shortMessage:"The wallet does not support atomic execution but the request requires it."})}}Object.defineProperty(Po,"code",{enumerable:!0,configurable:!0,writable:!0,value:5760});class ko extends Kr{constructor(e){super(e,{name:"UnknownRpcError",shortMessage:"An unknown RPC error occurred."})}}const Ao=3;function Io(e,{abi:t,address:n,args:r,docsPath:o,functionName:s,sender:a}){const i=e instanceof Wr?e:e instanceof We?e.walk(e=>"data"in e)||e.walk():{},{code:c,data:u,details:l,message:d,shortMessage:f}=i,h=e instanceof Je?new qr({functionName:s}):[Ao,no.code].includes(c)&&(u||l||d||f)?new Gr({abi:t,data:"object"==typeof u?u.data:u,functionName:s,message:i instanceof Yr?l:f??d}):e;return new Dr(h,{abi:t,args:r,contractAddress:n,docsPath:o,functionName:s,sender:a})}function No(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 So({hash:e,signature:t}){return n=await async function({hash:e,signature:t}){const n=Ue(e)?e:Ot(e),{secp256k1:r}=await Promise.resolve().then(function(){return Yl}),o=(()=>{if("object"==typeof t&&"r"in t&&"s"in t){const{r:e,s:n,v:o,yParity:s}=t,a=No(Number(s??o));return new r.Signature($t(e),$t(n)).addRecoveryBit(a)}const e=Ue(t)?t:Ot(t);if(65!==De(e))throw new Error("invalid signature length");const n=No(Bt(`0x${e.slice(130)}`));return r.Signature.fromCompact(e.substring(2,130)).addRecoveryBit(n)})();return`0x${o.recoverPublicKey(n.substring(2)).toHex(!1)}`}({hash:e,signature:t}),On(`0x${An(`0x${n.substring(4)}`).substring(26)}`);var n}function To(e,t="hex"){const n=$o(e),r=mr(new Uint8Array(n.length));return n.encode(r),"hex"===t?zt(r.bytes):r.bytes}function $o(e){return Array.isArray(e)?function(e){const t=e.reduce((e,t)=>e+t.length,0),n=Bo(t),r=t<=55?1+t:1+n+t;return{length:r,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=>$o(e))):function(e){const t="string"==typeof e?Gt(e):e,n=Bo(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 Bo(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 We("Length is too large.")}function Co(e){const{chainId:t,nonce:n,to:r}=e,o=e.contractAddress??e.address,s=An(jn(["0x05",To([t?_t(t):"0x",o,n?_t(n):"0x"])]));return"bytes"===r?Gt(s):s}async function Oo(e){const{authorization:t,signature:n}=e;return So({hash:Co(t),signature:n??t})}class Ro extends We{constructor(e,{account:t,docsPath:n,chain:r,data:o,gas:s,gasPrice:a,maxFeePerGas:i,maxPriorityFeePerGas:c,nonce:u,to:l,value:d}){const f=zr({from:t?.address,to:l,value:void 0!==d&&`${$r(d)} ${r?.nativeCurrency?.symbol||"ETH"}`,data:o,gas:s,gasPrice:void 0!==a&&`${Br(a)} gwei`,maxFeePerGas:void 0!==i&&`${Br(i)} gwei`,maxPriorityFeePerGas:void 0!==c&&`${Br(c)} gwei`,nonce:u});super(e.shortMessage,{cause:e,docsPath:n,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],"Estimate Gas Arguments:",f].filter(Boolean),name:"EstimateGasExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=e}}class zo extends We{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(zo,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(zo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});class _o extends We{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${Br(t)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:e,name:"FeeCapTooHighError"})}}Object.defineProperty(_o,"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 Mo extends We{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${Br(t)}`:""} gwei) cannot be lower than the block base fee.`,{cause:e,name:"FeeCapTooLowError"})}}Object.defineProperty(Mo,"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 Fo extends We{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(Fo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class jo extends We{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(jo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});class Lo extends We{constructor({cause:e,nonce:t}={}){super(`Nonce provided for the transaction ${t?`(${t}) `:""}exceeds the maximum allowed nonce.`,{cause:e,name:"NonceMaxValueError"})}}Object.defineProperty(Lo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});class Uo extends We{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(Uo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class Do extends We{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(Do,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class Go extends We{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(Go,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class qo extends We{constructor({cause:e}){super("The transaction type is not supported for this chain.",{cause:e,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(qo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class Vo extends We{constructor({cause:e,maxPriorityFeePerGas:t,maxFeePerGas:n}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${t?` = ${Br(t)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n?` = ${Br(n)} gwei`:""}).`].join("\n"),{cause:e,name:"TipAboveFeeCapError"})}}Object.defineProperty(Vo,"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 Wo extends We{constructor({cause:e}){super(`An error occurred while executing: ${e?.shortMessage}`,{cause:e,name:"UnknownNodeError"})}}function Ho(e,t){const n=(e.details||"").toLowerCase(),r=e instanceof We?e.walk(e=>e?.code===zo.code):e;return r instanceof We?new zo({cause:e,message:r.details}):zo.nodeMessage.test(n)?new zo({cause:e,message:e.details}):_o.nodeMessage.test(n)?new _o({cause:e,maxFeePerGas:t?.maxFeePerGas}):Mo.nodeMessage.test(n)?new Mo({cause:e,maxFeePerGas:t?.maxFeePerGas}):Fo.nodeMessage.test(n)?new Fo({cause:e,nonce:t?.nonce}):jo.nodeMessage.test(n)?new jo({cause:e,nonce:t?.nonce}):Lo.nodeMessage.test(n)?new Lo({cause:e,nonce:t?.nonce}):Uo.nodeMessage.test(n)?new Uo({cause:e}):Do.nodeMessage.test(n)?new Do({cause:e,gas:t?.gas}):Go.nodeMessage.test(n)?new Go({cause:e,gas:t?.gas}):qo.nodeMessage.test(n)?new qo({cause:e}):Vo.nodeMessage.test(n)?new Vo({cause:e,maxFeePerGas:t?.maxFeePerGas,maxPriorityFeePerGas:t?.maxPriorityFeePerGas}):new Wo({cause:e})}function Yo(e,{format:t}){if(!t)return{};const n={};return function t(r){const o=Object.keys(r);for(const s of o)s in e&&(n[s]=e[s]),r[s]&&"object"==typeof r[s]&&!Array.isArray(r[s])&&t(r[s])}(t(e||{})),n}const Zo={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function Ko(e){const t={};return void 0!==e.authorizationList&&(t.authorizationList=e.authorizationList.map(e=>({address:e.address,r:e.r?_t(BigInt(e.r)):e.r,s:e.s?_t(BigInt(e.s)):e.s,chainId:_t(e.chainId),nonce:_t(e.nonce),...void 0!==e.yParity?{yParity:_t(e.yParity)}:{},...void 0!==e.v&&void 0===e.yParity?{v:_t(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=>zt(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=_t(e.gas)),void 0!==e.gasPrice&&(t.gasPrice=_t(e.gasPrice)),void 0!==e.maxFeePerBlobGas&&(t.maxFeePerBlobGas=_t(e.maxFeePerBlobGas)),void 0!==e.maxFeePerGas&&(t.maxFeePerGas=_t(e.maxFeePerGas)),void 0!==e.maxPriorityFeePerGas&&(t.maxPriorityFeePerGas=_t(e.maxPriorityFeePerGas)),void 0!==e.nonce&&(t.nonce=_t(e.nonce)),void 0!==e.to&&(t.to=e.to),void 0!==e.type&&(t.type=Zo[e.type]),void 0!==e.value&&(t.value=_t(e.value)),t}function Jo(e){if(e&&0!==e.length)return e.reduce((e,{slot:t,value:n})=>{if(66!==t.length)throw new xt({size:t.length,targetSize:66,type:"hex"});if(66!==n.length)throw new xt({size:n.length,targetSize:66,type:"hex"});return e[t]=n,e},{})}function Qo(e){const{balance:t,nonce:n,state:r,stateDiff:o,code:s}=e,a={};if(void 0!==s&&(a.code=s),void 0!==t&&(a.balance=_t(t)),void 0!==n&&(a.nonce=_t(n)),void 0!==r&&(a.state=Jo(r)),void 0!==o){if(a.state)throw new Or;a.stateDiff=Jo(o)}return a}function Xo(e){if(!e)return;const t={};for(const{address:n,...r}of e){if(!Mn(n,{strict:!1}))throw new $n({address:n});if(t[n])throw new Cr({address:n});t[n]=Qo(r)}return t}const es=2n**256n-1n;function ts(e){const{account:t,gasPrice:n,maxFeePerGas:r,maxPriorityFeePerGas:o,to:s}=e,a=t?sr(t):void 0;if(a&&!Mn(a.address))throw new $n({address:a.address});if(s&&!Mn(s))throw new $n({address:s});if(void 0!==n&&(void 0!==r||void 0!==o))throw new _r;if(r&&r>es)throw new _o({maxFeePerGas:r});if(o&&r&&o>r)throw new Vo({maxFeePerGas:r,maxPriorityFeePerGas:o})}class ns extends We{constructor(){super("`baseFeeMultiplier` must be greater than 1.",{name:"BaseFeeScalarError"})}}class rs extends We{constructor(){super("Chain does not support EIP-1559 fees.",{name:"Eip1559FeesNotSupportedError"})}}class os extends We{constructor({maxPriorityFeePerGas:e}){super(`\`maxFeePerGas\` cannot be less than the \`maxPriorityFeePerGas\` (${Br(e)} gwei).`,{name:"MaxFeePerGasTooLowError"})}}class ss extends We{constructor({blockHash:e,blockNumber:t}){let n="Block";e&&(n=`Block at hash "${e}"`),t&&(n=`Block at number "${t}"`),super(`${n} could not be found.`,{name:"BlockNotFoundError"})}}const as={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function is(e){const t={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?Bt(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?Bt(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?as[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}function cs(e){const t=(e.transactions??[]).map(e=>"string"==typeof e?e:is(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}}async function us(e,{blockHash:t,blockNumber:n,blockTag:r=e.experimental_blockTag??"latest",includeTransactions:o}={}){const s=o??!1,a=void 0!==n?_t(n):void 0;let i=null;if(i=t?await e.request({method:"eth_getBlockByHash",params:[t,s]},{dedupe:!0}):await e.request({method:"eth_getBlockByNumber",params:[a||r,s]},{dedupe:Boolean(a)}),!i)throw new ss({blockHash:t,blockNumber:n});return(e.chain?.formatters?.block?.format||cs)(i)}async function ls(e){const t=await e.request({method:"eth_gasPrice"});return BigInt(t)}async function ds(e,t){const{block:n,chain:r=e.chain,request:o}=t||{};try{const t=r?.fees?.maxPriorityFeePerGas??r?.fees?.defaultPriorityFee;if("function"==typeof t){const r=n||await Fe(e,us,"getBlock")({}),s=await t({block:r,client:e,request:o});if(null===s)throw new Error;return s}if(void 0!==t)return t;return $t(await e.request({method:"eth_maxPriorityFeePerGas"}))}catch{const[t,r]=await Promise.all([n?Promise.resolve(n):Fe(e,us,"getBlock")({}),Fe(e,ls,"getGasPrice")({})]);if("bigint"!=typeof t.baseFeePerGas)throw new rs;const o=r-t.baseFeePerGas;return o<0n?0n:o}}async function fs(e,t){const{block:n,chain:r=e.chain,request:o,type:s="eip1559"}=t||{},a=await(async()=>"function"==typeof r?.fees?.baseFeeMultiplier?r.fees.baseFeeMultiplier({block:n,client:e,request:o}):r?.fees?.baseFeeMultiplier??1.2)();if(a<1)throw new ns;const i=10**(a.toString().split(".")[1]?.length??0),c=e=>e*BigInt(Math.ceil(a*i))/BigInt(i),u=n||await Fe(e,us,"getBlock")({});if("function"==typeof r?.fees?.estimateFeesPerGas){const t=await r.fees.estimateFeesPerGas({block:n,client:e,multiply:c,request:o,type:s});if(null!==t)return t}if("eip1559"===s){if("bigint"!=typeof u.baseFeePerGas)throw new rs;const t="bigint"==typeof o?.maxPriorityFeePerGas?o.maxPriorityFeePerGas:await ds(e,{block:u,chain:r,request:o}),n=c(u.baseFeePerGas);return{maxFeePerGas:o?.maxFeePerGas??n+t,maxPriorityFeePerGas:t}}return{gasPrice:o?.gasPrice??c(await Fe(e,ls,"getGasPrice")({}))}}async function hs(e,{address:t,blockTag:n="latest",blockNumber:r}){return Bt(await e.request({method:"eth_getTransactionCount",params:[t,"bigint"==typeof r?_t(r):n]},{dedupe:Boolean(r)}))}function ps(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=>Gt(e)):e.blobs,o=[];for(const e of r)o.push(Uint8Array.from(t.blobToKzgCommitment(e)));return"bytes"===n?o:o.map(e=>zt(e))}function ms(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=>Gt(e)):e.blobs,o="string"==typeof e.commitments[0]?e.commitments.map(e=>Gt(e)):e.commitments,s=[];for(let e=0;e<r.length;e++){const n=r[e],a=o[e];s.push(Uint8Array.from(t.computeBlobKzgProof(n,a)))}return"bytes"===n?s:s.map(e=>zt(e))}function gs(e,t,n){return e&t^~e&n}function bs(e,t,n){return e&t^e&n^t&n}class ys extends sn{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=en(this.buffer)}update(e){Jt(this),Kt(e=on(e));const{view:t,buffer:n,blockLen:r}=this,o=e.length;for(let s=0;s<o;){const a=Math.min(r-this.pos,o-s);if(a===r){const t=en(e);for(;r<=o-s;s+=r)this.process(t,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Jt(this),Qt(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:o}=this;let{pos:s}=this;t[s++]=128,Xt(this.buffer.subarray(s)),this.padOffset>r-s&&(this.process(n,0),s=0);for(let e=s;e<r;e++)t[e]=0;!function(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const o=BigInt(32),s=BigInt(4294967295),a=Number(n>>o&s),i=Number(n&s),c=r?4:0,u=r?0:4;e.setUint32(t+c,a,r),e.setUint32(t+u,i,r)}(n,r-8,BigInt(8*this.length),o),this.process(n,0);const a=en(e),i=this.outputLen;if(i%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=i/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],o)}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:o,destroyed:s,pos:a}=this;return e.destroyed=s,e.finished=o,e.length=r,e.pos=a,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}}const ws=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),vs=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]),xs=new Uint32Array(64);class Es extends ys{constructor(e=32){super(64,e,8,!1),this.A=0|ws[0],this.B=0|ws[1],this.C=0|ws[2],this.D=0|ws[3],this.E=0|ws[4],this.F=0|ws[5],this.G=0|ws[6],this.H=0|ws[7]}get(){const{A:e,B:t,C:n,D:r,E:o,F:s,G:a,H:i}=this;return[e,t,n,r,o,s,a,i]}set(e,t,n,r,o,s,a,i){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|o,this.F=0|s,this.G=0|a,this.H=0|i}process(e,t){for(let n=0;n<16;n++,t+=4)xs[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=xs[e-15],n=xs[e-2],r=tn(t,7)^tn(t,18)^t>>>3,o=tn(n,17)^tn(n,19)^n>>>10;xs[e]=o+xs[e-7]+r+xs[e-16]|0}let{A:n,B:r,C:o,D:s,E:a,F:i,G:c,H:u}=this;for(let e=0;e<64;e++){const t=u+(tn(a,6)^tn(a,11)^tn(a,25))+gs(a,i,c)+vs[e]+xs[e]|0,l=(tn(n,2)^tn(n,13)^tn(n,22))+bs(n,r,o)|0;u=c,c=i,i=a,a=s+t|0,s=o,o=r,r=n,n=t+l|0}n=n+this.A|0,r=r+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,i=i+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(n,r,o,s,a,i,c,u)}roundClean(){Xt(xs)}destroy(){this.set(0,0,0,0,0,0,0,0),Xt(this.buffer)}}const Ps=an(()=>new Es),ks=Ps;function As(e){const{commitment:t,version:n=1}=e,r=e.to??("string"==typeof t?"hex":"bytes"),o=ks(Ue(s=t,{strict:!1})?Lt(s):s);var s;return o.set([n],0),"bytes"===r?o:zt(o)}const Is=4096,Ns=131072,Ss=761855;class Ts extends We{constructor({maxSize:e,size:t}){super("Blob size is too large.",{metaMessages:[`Max: ${e} bytes`,`Given: ${t} bytes`],name:"BlobSizeTooLargeError"})}}class $s extends We{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}function Bs(e){const{data:t,kzg:n,to:r}=e,o=e.blobs??function(e){const t="string"==typeof e.data?Gt(e.data):e.data,n=De(t);if(!n)throw new $s;if(n>Ss)throw new Ts({maxSize:Ss,size:n});const r=[];let o=!0,s=0;for(;o;){const e=mr(new Uint8Array(Ns));let n=0;for(;n<Is;){const r=t.slice(s,s+31);if(e.pushByte(0),e.pushBytes(r),r.length<31){e.pushByte(128),o=!1;break}n++,s+=31}r.push(e)}return r.map(e=>zt(e.bytes))}({data:t}),s=e.commitments??ps({blobs:o,kzg:n,to:r}),a=e.proofs??ms({blobs:o,commitments:s,kzg:n,to:r}),i=[];for(let e=0;e<o.length;e++)i.push({blob:o[e],commitment:s[e],proof:a[e]});return i}async function Cs(e){return Bt(await e.request({method:"eth_chainId"},{dedupe:!0}))}const Os=["blobVersionedHashes","chainId","fees","gas","nonce","type"],Rs=new Map;async function zs(e,t){const{account:n=e.account,blobs:r,chain:o,gas:s,kzg:a,nonce:i,nonceManager:c,parameters:u=Os,type:l}=t,d=n?sr(n):n,f={...t,...d?{from:d?.address}:{}};let h,p;async function m(){return h||(h=await Fe(e,us,"getBlock")({blockTag:"latest"}),h)}async function g(){if(p)return p;if(o)return o.id;if(void 0!==t.chainId)return t.chainId;const n=await Fe(e,Cs,"getChainId")({});return p=n,p}if(u.includes("nonce")&&void 0===i&&d)if(c){const t=await g();f.nonce=await c.consume({address:d.address,chainId:t,client:e})}else f.nonce=await Fe(e,hs,"getTransactionCount")({address:d.address,blockTag:"pending"});if((u.includes("blobVersionedHashes")||u.includes("sidecars"))&&r&&a){const e=ps({blobs:r,kzg:a});if(u.includes("blobVersionedHashes")){const t=function(e){const{commitments:t,version:n}=e,r=e.to,o=[];for(const e of t)o.push(As({commitment:e,to:r,version:n}));return o}({commitments:e,to:"hex"});f.blobVersionedHashes=t}if(u.includes("sidecars")){const t=Bs({blobs:r,commitments:e,proofs:ms({blobs:r,commitments:e,kzg:a}),to:"hex"});f.sidecars=t}}if(u.includes("chainId")&&(f.chainId=await g()),(u.includes("fees")||u.includes("type"))&&void 0===l)try{f.type=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 Mr({transaction:e})}(f)}catch{let t=Rs.get(e.uid);if(void 0===t){const n=await m();t="bigint"==typeof n?.baseFeePerGas,Rs.set(e.uid,t)}f.type=t?"eip1559":"legacy"}if(u.includes("fees"))if("legacy"!==f.type&&"eip2930"!==f.type){if(void 0===f.maxFeePerGas||void 0===f.maxPriorityFeePerGas){const n=await m(),{maxFeePerGas:r,maxPriorityFeePerGas:s}=await fs(e,{block:n,chain:o,request:f});if(void 0===t.maxPriorityFeePerGas&&t.maxFeePerGas&&t.maxFeePerGas<s)throw new os({maxPriorityFeePerGas:s});f.maxPriorityFeePerGas=s,f.maxFeePerGas=r}}else{if(void 0!==t.maxFeePerGas||void 0!==t.maxPriorityFeePerGas)throw new rs;if(void 0===t.gasPrice){const t=await m(),{gasPrice:n}=await fs(e,{block:t,chain:o,request:f,type:"legacy"});f.gasPrice=n}}return u.includes("gas")&&void 0===s&&(f.gas=await Fe(e,_s,"estimateGas")({...f,account:d?{address:d.address,type:"json-rpc"}:d})),ts(f),delete f.parameters,f}async function _s(e,t){const{account:n=e.account}=t,r=n?sr(n):void 0;try{const{accessList:n,authorizationList:o,blobs:s,blobVersionedHashes:a,blockNumber:i,blockTag:c,data:u,gas:l,gasPrice:d,maxFeePerBlobGas:f,maxFeePerGas:h,maxPriorityFeePerGas:p,nonce:m,value:g,stateOverride:b,...y}=await zs(e,{...t,parameters:"local"===r?.type?void 0:["blobVersionedHashes"]}),w=("bigint"==typeof i?_t(i):void 0)||c,v=Xo(b),x=await(async()=>y.to?y.to:o&&o.length>0?await Oo({authorization:o[0]}).catch(()=>{throw new We("`to` is required. Could not infer from `authorizationList`")}):void 0)();ts(t);const E=e.chain?.formatters?.transactionRequest?.format,P=(E||Ko)({...Yo(y,{format:E}),from:r?.address,accessList:n,authorizationList:o,blobs:s,blobVersionedHashes:a,data:u,gas:l,gasPrice:d,maxFeePerBlobGas:f,maxFeePerGas:h,maxPriorityFeePerGas:p,nonce:m,to:x,value:g});return BigInt(await e.request({method:"eth_estimateGas",params:v?[P,w??e.experimental_blockTag??"latest",v]:w?[P,w]:[P]}))}catch(n){throw function(e,{docsPath:t,...n}){const r=(()=>{const t=Ho(e,n);return t instanceof Wo?e:t})();return new Ro(r,{docsPath:t,...n})}(n,{...t,account:r,chain:e.chain})}}function Ms(e,t){if(!Mn(e,{strict:!1}))throw new $n({address:e});if(!Mn(t,{strict:!1}))throw new $n({address:t});return e.toLowerCase()===t.toLowerCase()}const Fs="/docs/contract/decodeEventLog";function js(e){const{abi:t,data:n,strict:r,topics:o}=e,s=r??!0,[a,...i]=o;if(!a)throw new ot({docsPath:Fs});const c=t.find(e=>"event"===e.type&&a===Tn(je(e)));if(!c||!("name"in c)||"event"!==c.type)throw new st(a,{docsPath:Fs});const{name:u,inputs:l}=c,d=l?.some(e=>!("name"in e&&e.name)),f=d?[]:{},h=l.map((e,t)=>[e,t]).filter(([e])=>"indexed"in e&&e.indexed);for(let e=0;e<h.length;e++){const[t,n]=h[e],r=i[e];if(!r)throw new ht({abiItem:c,param:t});f[d?n:t.name||n]=Ls({param:t,value:r})}const p=l.filter(e=>!("indexed"in e&&e.indexed));if(p.length>0)if(n&&"0x"!==n)try{const e=wr(p,n);if(e)if(d)for(let t=0;t<l.length;t++)f[t]=f[t]??e.shift();else for(let t=0;t<p.length;t++)f[p[t].name]=e[t]}catch(e){if(s){if(e instanceof Ke||e instanceof fr)throw new ft({abiItem:c,data:n,params:p,size:De(n)});throw e}}else if(s)throw new ft({abiItem:c,data:"0x",params:p,size:0});return{eventName:u,args:Object.values(f).length>0?f:void 0}}function Ls({param:e,value:t}){if("string"===e.type||"bytes"===e.type||"tuple"===e.type||e.type.match(/^(.*)\[(\d+)?\]$/))return t;return(wr([e],t)||[])[0]}function Us(e){const{abi:t,args:n,logs:r,strict:o=!0}=e,s=(()=>{if(e.eventName)return Array.isArray(e.eventName)?e.eventName:[e.eventName]})();return r.map(e=>{try{const r=t.find(t=>"event"===t.type&&e.topics[0]===Tn(t));if(!r)return null;const a=js({...e,abi:[r],strict:o});return s&&!s.includes(a.eventName)?null:function(e){const{args:t,inputs:n,matchArgs:r}=e;if(!r)return!0;if(!t)return!1;function o(e,t,n){try{return"address"===e.type?Ms(t,n):"string"===e.type||"bytes"===e.type?An(Lt(t))===n:t===n}catch{return!1}}if(Array.isArray(t)&&Array.isArray(r))return r.every((e,r)=>{if(null==e)return!0;const s=n[r];if(!s)return!1;return(Array.isArray(e)?e:[e]).some(e=>o(s,e,t[r]))});return"object"==typeof t&&!Array.isArray(t)&&"object"==typeof r&&!Array.isArray(r)&&Object.entries(r).every(([e,r])=>{if(null==r)return!0;const s=n.find(t=>t.name===e);if(!s)return!1;return(Array.isArray(r)?r:[r]).some(n=>o(s,n,t[e]))})}({args:a.args,inputs:r.inputs,matchArgs:n})?{...a,...e}:null}catch(t){let n,r;if(t instanceof st)return null;if(t instanceof ft||t instanceof ht){if(o)return null;n=t.abiItem.name,r=t.abiItem.inputs?.some(e=>!("name"in e&&e.name))}return{...e,args:r?[]:{},eventName:n}}}).filter(Boolean)}function Ds(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}:{}}}async function Gs(e,{address:t,blockHash:n,fromBlock:r,toBlock:o,event:s,events:a,args:i,strict:c}={}){const u=c??!1,l=a??(s?[s]:void 0);let d,f=[];if(l){const e=l.flatMap(e=>tr({abi:[e],eventName:e.name,args:a?void 0:i}));f=[e],s&&(f=f[0])}d=n?await e.request({method:"eth_getLogs",params:[{address:t,topics:f,blockHash:n}]}):await e.request({method:"eth_getLogs",params:[{address:t,topics:f,fromBlock:"bigint"==typeof r?_t(r):r,toBlock:"bigint"==typeof o?_t(o):o}]});const h=d.map(e=>Ds(e));return l?Us({abi:l,args:i,logs:h,strict:u}):h}async function qs(e,t){const{abi:n,address:r,args:o,blockHash:s,eventName:a,fromBlock:i,toBlock:c,strict:u}=t,l=a?Jn({abi:n,name:a}):void 0,d=l?void 0:n.filter(e=>"event"===e.type);return Fe(e,Gs,"getLogs")({address:r,args:o,blockHash:s,event:l,events:d,fromBlock:i,toBlock:c,strict:u})}const Vs="/docs/contract/decodeFunctionResult";function Ws(e){const{abi:t,args:n,functionName:r,data:o}=e;let s=t[0];if(r){const e=Jn({abi:t,args:n,name:r});if(!e)throw new it(r,{docsPath:Vs});s=e}if("function"!==s.type)throw new it(void 0,{docsPath:Vs});if(!s.outputs)throw new ct(s.name,{docsPath:Vs});const a=wr(s.outputs,o);return a&&a.length>1?a:a&&1===a.length?a[0]:void 0}
|
|
4
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Hs=BigInt(0),Ys=BigInt(1);function Zs(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function Ks(e){if(!Zs(e))throw new Error("Uint8Array expected")}function Js(e,t){if("boolean"!=typeof t)throw new Error(e+" boolean expected, got "+t)}function Qs(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function Xs(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?Hs:BigInt("0x"+e)}const ea="function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex,ta=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function na(e){if(Ks(e),ea)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=ta[e[n]];return t}const ra=48,oa=57,sa=65,aa=70,ia=97,ca=102;function ua(e){return e>=ra&&e<=oa?e-ra:e>=sa&&e<=aa?e-(sa-10):e>=ia&&e<=ca?e-(ia-10):void 0}function la(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(ea)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,o=0;t<n;t++,o+=2){const n=ua(e.charCodeAt(o)),s=ua(e.charCodeAt(o+1));if(void 0===n||void 0===s){const t=e[o]+e[o+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+o)}r[t]=16*n+s}return r}function da(e){return Xs(na(e))}function fa(e){return Ks(e),Xs(na(Uint8Array.from(e).reverse()))}function ha(e,t){return la(e.toString(16).padStart(2*t,"0"))}function pa(e,t){return ha(e,t).reverse()}function ma(e,t,n){let r;if("string"==typeof t)try{r=la(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!Zs(t))throw new Error(e+" must be hex string or Uint8Array");r=Uint8Array.from(t)}const o=r.length;if("number"==typeof n&&o!==n)throw new Error(e+" of length "+n+" expected, got "+o);return r}function ga(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];Ks(r),t+=r.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const o=e[t];n.set(o,r),r+=o.length}return n}const ba=e=>"bigint"==typeof e&&Hs<=e;function ya(e,t,n){return ba(e)&&ba(t)&&ba(n)&&t<=e&&e<n}function wa(e,t,n,r){if(!ya(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}const va=e=>(Ys<<BigInt(e))-Ys,xa=e=>new Uint8Array(e),Ea=e=>Uint8Array.from(e);const Pa={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||Zs(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 ka(e,t,n={}){const r=(t,n,r)=>{const o=Pa[n];if("function"!=typeof o)throw new Error("invalid validator function");const s=e[t];if(!(r&&void 0===s||o(s,e)))throw new Error("param "+String(t)+" is invalid. Expected "+n+", got "+s)};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 Aa(e){const t=new WeakMap;return(n,...r)=>{const o=t.get(n);if(void 0!==o)return o;const s=e(n,...r);return t.set(n,s),s}}class Ia extends Error{constructor(e,t={}){const n=(()=>{if(t.cause instanceof Ia){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 Ia&&t.cause.docsPath||t.docsPath,o=`https://oxlib.sh${r??""}`,s=[e||"An error occurred.",...t.metaMessages?["",...t.metaMessages]:[],...n||r?["",n?`Details: ${n}`:void 0,r?`See: ${o}`:void 0]:[]].filter(e=>"string"==typeof e).join("\n");super(s,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=o,this.docsPath=r,this.shortMessage=e}walk(e){return Na(this,e)}}function Na(e,t){return t?.(e)?e:e&&"object"==typeof e&&"cause"in e&&e.cause?Na(e.cause,t):t?null:e}function Sa(e,t){if(Va(e)>t)throw new Xa({givenSize:Va(e),maxSize:t})}const Ta=48,$a=57,Ba=65,Ca=70,Oa=97,Ra=102;function za(e){return e>=Ta&&e<=$a?e-Ta:e>=Ba&&e<=Ca?e-(Ba-10):e>=Oa&&e<=Ra?e-(Oa-10):void 0}function _a(e,t={}){const{dir:n="left"}=t;let r=e,o=0;for(let e=0;e<r.length-1&&"0"===r["left"===n?e:r.length-e-1].toString();e++)o++;return r="left"===n?r.slice(o):r.slice(0,r.length-o),r}function Ma(e,t){if(di(e)>t)throw new yi({givenSize:di(e),maxSize:t})}function Fa(e,t={}){const{dir:n,size:r=32}=t;if(0===r)return e;const o=e.replace("0x","");if(o.length>2*r)throw new vi({size:Math.ceil(o.length/2),targetSize:r,type:"Hex"});return`0x${o["right"===n?"padEnd":"padStart"](2*r,"0")}`}function ja(e,t,n){return JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString()+"#__bigint":t,n)}const La=new TextDecoder,Ua=new TextEncoder;function Da(e){return e instanceof Uint8Array?e:"string"==typeof e?Ga(e):function(e){return e instanceof Uint8Array?e:new Uint8Array(e)}(e)}function Ga(e,t={}){const{size:n}=t;let r=e;n&&(Ma(e,n),r=ui(e,n));let o=r.slice(2);o.length%2&&(o=`0${o}`);const s=o.length/2,a=new Uint8Array(s);for(let e=0,t=0;e<s;e++){const n=za(o.charCodeAt(t++)),r=za(o.charCodeAt(t++));if(void 0===n||void 0===r)throw new Ia(`Invalid byte sequence ("${o[t-2]}${o[t-1]}" in "${o}").`);a[e]=16*n+r}return a}function qa(e,t={}){const{size:n}=t,r=Ua.encode(e);return"number"==typeof n?(Sa(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 ei({size:e.length,targetSize:r,type:"Bytes"});const o=new Uint8Array(r);for(let t=0;t<r;t++){const s="right"===n;o[s?t:r-t-1]=e[s?t:e.length-t-1]}return o}(e,{dir:"right",size:t})}(r,n)):r}function Va(e){return e.length}function Wa(e,t,n,r={}){const{strict:o}=r;return e.slice(t,n)}function Ha(e,t={}){const{size:n}=t;void 0!==n&&Sa(e,n);return fi(si(e,t),t)}function Ya(e,t={}){const{size:n}=t;let r=e;if(void 0!==n&&(Sa(r,n),r=Ja(r)),r.length>1||r[0]>1)throw new Qa(r);return Boolean(r[0])}function Za(e,t={}){const{size:n}=t;void 0!==n&&Sa(e,n);return hi(si(e,t),t)}function Ka(e,t={}){const{size:n}=t;let r=e;return void 0!==n&&(Sa(r,n),r=_a(r,{dir:"right"})),La.decode(r)}function Ja(e){return _a(e,{dir:"left"})}class Qa extends Ia{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"})}}let Xa=class extends Ia{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"})}},ei=class extends Ia{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 ti=new TextEncoder,ni=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function ri(...e){return`0x${e.reduce((e,t)=>e+t.replace("0x",""),"")}`}function oi(e,t={}){const n=`0x${Number(e)}`;return"number"==typeof t.size?(Ma(n,t.size),ci(n,t.size)):n}function si(e,t={}){let n="";for(let t=0;t<e.length;t++)n+=ni[e[t]];const r=`0x${n}`;return"number"==typeof t.size?(Ma(r,t.size),ui(r,t.size)):r}function ai(e,t={}){const{signed:n,size:r}=t,o=BigInt(e);let s;r?s=n?(1n<<8n*BigInt(r)-1n)-1n:2n**(8n*BigInt(r))-1n:"number"==typeof e&&(s=BigInt(Number.MAX_SAFE_INTEGER));const a="bigint"==typeof s&&n?-s-1n:0;if(s&&o>s||o<a){const t="bigint"==typeof e?"n":"";throw new mi({max:s?`${s}${t}`:void 0,min:`${a}${t}`,signed:n,size:r,value:`${e}${t}`})}const i=`0x${(n&&o<0?(1n<<BigInt(8*r))+BigInt(o):o).toString(16)}`;return r?ci(i,r):i}function ii(e,t={}){return si(ti.encode(e),t)}function ci(e,t){return Fa(e,{dir:"left",size:t})}function ui(e,t){return Fa(e,{dir:"right",size:t})}function li(e,t,n,r={}){const{strict:o}=r;!function(e,t){if("number"==typeof t&&t>0&&t>di(e)-1)throw new wi({offset:t,position:"start",size:di(e)})}(e,t);const s=`0x${e.replace("0x","").slice(2*(t??0),2*(n??e.length))}`;return o&&function(e,t,n){if("number"==typeof t&&"number"==typeof n&&di(e)!==n-t)throw new wi({offset:n,position:"end",size:di(e)})}(s,t,n),s}function di(e){return Math.ceil((e.length-2)/2)}function fi(e,t={}){const{signed:n}=t;t.size&&Ma(e,t.size);const r=BigInt(e);if(!n)return r;const o=(e.length-2)/2,s=(1n<<8n*BigInt(o))-1n;return r<=s>>1n?r:r-s-1n}function hi(e,t={}){const{signed:n,size:r}=t;return Number(n||r?fi(e,t):e)}function pi(e,t={}){const{strict:n=!1}=t;try{return function(e,t={}){const{strict:n=!1}=t;if(!e)throw new gi(e);if("string"!=typeof e)throw new gi(e);if(n&&!/^0x[0-9a-fA-F]*$/.test(e))throw new bi(e);if(!e.startsWith("0x"))throw new bi(e)}(e,{strict:n}),!0}catch{return!1}}class mi extends Ia{constructor({max:e,min:t,signed:n,size:r,value:o}){super(`Number \`${o}\` 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 gi extends Ia{constructor(e){super(`Value \`${"object"==typeof e?ja(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 bi extends Ia{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 yi extends Ia{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 wi extends Ia{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 vi extends Ia{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 xi(e){return{address:e.address,amount:ai(e.amount),index:ai(e.index),validatorIndex:ai(e.validatorIndex)}}function Ei(e){return{..."bigint"==typeof e.baseFeePerGas&&{baseFeePerGas:ai(e.baseFeePerGas)},..."bigint"==typeof e.blobBaseFee&&{blobBaseFee:ai(e.blobBaseFee)},..."string"==typeof e.feeRecipient&&{feeRecipient:e.feeRecipient},..."bigint"==typeof e.gasLimit&&{gasLimit:ai(e.gasLimit)},..."bigint"==typeof e.number&&{number:ai(e.number)},..."bigint"==typeof e.prevRandao&&{prevRandao:ai(e.prevRandao)},..."bigint"==typeof e.time&&{time:ai(e.time)},...e.withdrawals&&{withdrawals:e.withdrawals.map(xi)}}}const Pi=[{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"},{inputs:[],name:"getCurrentBlockTimestamp",outputs:[{internalType:"uint256",name:"timestamp",type:"uint256"}],stateMutability:"view",type:"function"}],ki=[{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"}]}],Ai=[{inputs:[{name:"dns",type:"bytes"}],name:"DNSDecodingFailed",type:"error"},{inputs:[{name:"ens",type:"string"}],name:"DNSEncodingFailed",type:"error"},{inputs:[],name:"EmptyAddress",type:"error"},{inputs:[{name:"status",type:"uint16"},{name:"message",type:"string"}],name:"HttpError",type:"error"},{inputs:[],name:"InvalidBatchGatewayResponse",type:"error"},{inputs:[{name:"errorData",type:"bytes"}],name:"ResolverError",type:"error"},{inputs:[{name:"name",type:"bytes"},{name:"resolver",type:"address"}],name:"ResolverNotContract",type:"error"},{inputs:[{name:"name",type:"bytes"}],name:"ResolverNotFound",type:"error"},{inputs:[{name:"primary",type:"string"},{name:"primaryAddress",type:"bytes"}],name:"ReverseAddressMismatch",type:"error"},{inputs:[{internalType:"bytes4",name:"selector",type:"bytes4"}],name:"UnsupportedResolverProfile",type:"error"}],Ii=[...Ai,{name:"resolveWithGateways",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes"},{name:"data",type:"bytes"},{name:"gateways",type:"string[]"}],outputs:[{name:"",type:"bytes"},{name:"address",type:"address"}]}],Ni=[...Ai,{name:"reverseWithGateways",type:"function",stateMutability:"view",inputs:[{type:"bytes",name:"reverseName"},{type:"uint256",name:"coinType"},{type:"string[]",name:"gateways"}],outputs:[{type:"string",name:"resolvedName"},{type:"address",name:"resolver"},{type:"address",name:"reverseResolver"}]}],Si=[{name:"text",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes32"},{name:"key",type:"string"}],outputs:[{name:"",type:"string"}]}],Ti=[{name:"addr",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes32"}],outputs:[{name:"",type:"address"}]},{name:"addr",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes32"},{name:"coinType",type:"uint256"}],outputs:[{name:"",type:"bytes"}]}],$i=[{name:"isValidSignature",type:"function",stateMutability:"view",inputs:[{name:"hash",type:"bytes32"},{name:"signature",type:"bytes"}],outputs:[{name:"",type:"bytes4"}]}],Bi=[{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"}],Ci="0x82ad56cb",Oi="0x608060405234801561001057600080fd5b5060405161018e38038061018e83398101604081905261002f91610124565b6000808351602085016000f59050803b61004857600080fd5b6000808351602085016000855af16040513d6000823e81610067573d81fd5b3d81f35b634e487b7160e01b600052604160045260246000fd5b600082601f83011261009257600080fd5b81516001600160401b038111156100ab576100ab61006b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156100d9576100d961006b565b6040528181528382016020018510156100f157600080fd5b60005b82811015610110576020818601810151838301820152016100f4565b506000918101602001919091529392505050565b6000806040838503121561013757600080fd5b82516001600160401b0381111561014d57600080fd5b61015985828601610081565b602085015190935090506001600160401b0381111561017757600080fd5b61018385828601610081565b915050925092905056fe",Ri="0x608060405234801561001057600080fd5b506040516102c03803806102c083398101604081905261002f916101e6565b836001600160a01b03163b6000036100e457600080836001600160a01b03168360405161005c9190610270565b6000604051808303816000865af19150503d8060008114610099576040519150601f19603f3d011682016040523d82523d6000602084013e61009e565b606091505b50915091508115806100b857506001600160a01b0386163b155b156100e1578060405163101bb98d60e01b81526004016100d8919061028c565b60405180910390fd5b50505b6000808451602086016000885af16040513d6000823e81610103573d81fd5b3d81f35b80516001600160a01b038116811461011e57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561015457818101518382015260200161013c565b50506000910152565b600082601f83011261016e57600080fd5b81516001600160401b0381111561018757610187610123565b604051601f8201601f19908116603f011681016001600160401b03811182821017156101b5576101b5610123565b6040528181528382016020018510156101cd57600080fd5b6101de826020830160208701610139565b949350505050565b600080600080608085870312156101fc57600080fd5b61020585610107565b60208601519094506001600160401b0381111561022157600080fd5b61022d8782880161015d565b93505061023c60408601610107565b60608601519092506001600160401b0381111561025857600080fd5b6102648782880161015d565b91505092959194509250565b60008251610282818460208701610139565b9190910192915050565b60208152600082518060208401526102ab816040850160208701610139565b601f01601f1916919091016040019291505056fe",zi="0x608060405234801561001057600080fd5b5060405161069438038061069483398101604081905261002f9161051e565b600061003c848484610048565b9050806000526001601ff35b60007f64926492649264926492649264926492649264926492649264926492649264926100748361040c565b036101e7576000606080848060200190518101906100929190610577565b60405192955090935091506000906001600160a01b038516906100b69085906105dd565b6000604051808303816000865af19150503d80600081146100f3576040519150601f19603f3d011682016040523d82523d6000602084013e6100f8565b606091505b50509050876001600160a01b03163b60000361016057806101605760405162461bcd60e51b815260206004820152601e60248201527f5369676e617475726556616c696461746f723a206465706c6f796d656e74000060448201526064015b60405180910390fd5b604051630b135d3f60e11b808252906001600160a01b038a1690631626ba7e90610190908b9087906004016105f9565b602060405180830381865afa1580156101ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d19190610633565b6001600160e01b03191614945050505050610405565b6001600160a01b0384163b1561027a57604051630b135d3f60e11b808252906001600160a01b03861690631626ba7e9061022790879087906004016105f9565b602060405180830381865afa158015610244573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102689190610633565b6001600160e01b031916149050610405565b81516041146102df5760405162461bcd60e51b815260206004820152603a602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e6174757265206c656e6774680000000000006064820152608401610157565b6102e7610425565b5060208201516040808401518451859392600091859190811061030c5761030c61065d565b016020015160f81c9050601b811480159061032b57508060ff16601c14155b1561038c5760405162461bcd60e51b815260206004820152603b602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e617475726520762076616c756500000000006064820152608401610157565b60408051600081526020810180835289905260ff83169181019190915260608101849052608081018390526001600160a01b0389169060019060a0016020604051602081039080840390855afa1580156103ea573d6000803e3d6000fd5b505050602060405103516001600160a01b0316149450505050505b9392505050565b600060208251101561041d57600080fd5b508051015190565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b038116811461045857600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561048c578181015183820152602001610474565b50506000910152565b600082601f8301126104a657600080fd5b81516001600160401b038111156104bf576104bf61045b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156104ed576104ed61045b565b60405281815283820160200185101561050557600080fd5b610516826020830160208701610471565b949350505050565b60008060006060848603121561053357600080fd5b835161053e81610443565b6020850151604086015191945092506001600160401b0381111561056157600080fd5b61056d86828701610495565b9150509250925092565b60008060006060848603121561058c57600080fd5b835161059781610443565b60208501519093506001600160401b038111156105b357600080fd5b6105bf86828701610495565b604086015190935090506001600160401b0381111561056157600080fd5b600082516105ef818460208701610471565b9190910192915050565b828152604060208201526000825180604084015261061e816060850160208701610471565b601f01601f1916919091016060019392505050565b60006020828403121561064557600080fd5b81516001600160e01b03198116811461040557600080fd5b634e487b7160e01b600052603260045260246000fdfe5369676e617475726556616c696461746f72237265636f7665725369676e6572",_i="0x608060405234801561001057600080fd5b506115b9806100206000396000f3fe6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e14610325578063bce38bd714610350578063c3077fa914610380578063ee82ac5e146103b2576100f3565b80634d2301cc1461026257806372425d9d1461029f57806382ad56cb146102ca57806386d516e8146102fa576100f3565b80633408e470116100c65780633408e470146101af578063399542e9146101da5780633e64a6961461020c57806342cbb15c14610237576100f3565b80630f28c97d146100f8578063174dea7114610123578063252dba421461015357806327e86d6e14610184575b600080fd5b34801561010457600080fd5b5061010d6103ef565b60405161011a9190610c0a565b60405180910390f35b61013d60048036038101906101389190610c94565b6103f7565b60405161014a9190610e94565b60405180910390f35b61016d60048036038101906101689190610f0c565b610615565b60405161017b92919061101b565b60405180910390f35b34801561019057600080fd5b506101996107ab565b6040516101a69190611064565b60405180910390f35b3480156101bb57600080fd5b506101c46107b7565b6040516101d19190610c0a565b60405180910390f35b6101f460048036038101906101ef91906110ab565b6107bf565b6040516102039392919061110b565b60405180910390f35b34801561021857600080fd5b506102216107e1565b60405161022e9190610c0a565b60405180910390f35b34801561024357600080fd5b5061024c6107e9565b6040516102599190610c0a565b60405180910390f35b34801561026e57600080fd5b50610289600480360381019061028491906111a7565b6107f1565b6040516102969190610c0a565b60405180910390f35b3480156102ab57600080fd5b506102b4610812565b6040516102c19190610c0a565b60405180910390f35b6102e460048036038101906102df919061122a565b61081a565b6040516102f19190610e94565b60405180910390f35b34801561030657600080fd5b5061030f6109e4565b60405161031c9190610c0a565b60405180910390f35b34801561033157600080fd5b5061033a6109ec565b6040516103479190611286565b60405180910390f35b61036a600480360381019061036591906110ab565b6109f4565b6040516103779190610e94565b60405180910390f35b61039a60048036038101906103959190610f0c565b610ba6565b6040516103a99392919061110b565b60405180910390f35b3480156103be57600080fd5b506103d960048036038101906103d491906112cd565b610bca565b6040516103e69190611064565b60405180910390f35b600042905090565b60606000808484905090508067ffffffffffffffff81111561041c5761041b6112fa565b5b60405190808252806020026020018201604052801561045557816020015b610442610bd5565b81526020019060019003908161043a5790505b5092503660005b828110156105c957600085828151811061047957610478611329565b5b6020026020010151905087878381811061049657610495611329565b5b90506020028101906104a89190611367565b925060008360400135905080860195508360000160208101906104cb91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16818580606001906104f2919061138f565b604051610500929190611431565b60006040518083038185875af1925050503d806000811461053d576040519150601f19603f3d011682016040523d82523d6000602084013e610542565b606091505b5083600001846020018290528215151515815250505081516020850135176105bc577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b826001019250505061045c565b5082341461060c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610603906114a7565b60405180910390fd5b50505092915050565b6000606043915060008484905090508067ffffffffffffffff81111561063e5761063d6112fa565b5b60405190808252806020026020018201604052801561067157816020015b606081526020019060019003908161065c5790505b5091503660005b828110156107a157600087878381811061069557610694611329565b5b90506020028101906106a791906114c7565b92508260000160208101906106bc91906111a7565b73ffffffffffffffffffffffffffffffffffffffff168380602001906106e2919061138f565b6040516106f0929190611431565b6000604051808303816000865af19150503d806000811461072d576040519150601f19603f3d011682016040523d82523d6000602084013e610732565b606091505b5086848151811061074657610745611329565b5b60200260200101819052819250505080610795576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161078c9061153b565b60405180910390fd5b81600101915050610678565b5050509250929050565b60006001430340905090565b600046905090565b6000806060439250434091506107d68686866109f4565b905093509350939050565b600048905090565b600043905090565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b600044905090565b606060008383905090508067ffffffffffffffff81111561083e5761083d6112fa565b5b60405190808252806020026020018201604052801561087757816020015b610864610bd5565b81526020019060019003908161085c5790505b5091503660005b828110156109db57600084828151811061089b5761089a611329565b5b602002602001015190508686838181106108b8576108b7611329565b5b90506020028101906108ca919061155b565b92508260000160208101906108df91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060400190610905919061138f565b604051610913929190611431565b6000604051808303816000865af19150503d8060008114610950576040519150601f19603f3d011682016040523d82523d6000602084013e610955565b606091505b5082600001836020018290528215151515815250505080516020840135176109cf577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b8160010191505061087e565b50505092915050565b600045905090565b600041905090565b606060008383905090508067ffffffffffffffff811115610a1857610a176112fa565b5b604051908082528060200260200182016040528015610a5157816020015b610a3e610bd5565b815260200190600190039081610a365790505b5091503660005b82811015610b9c576000848281518110610a7557610a74611329565b5b60200260200101519050868683818110610a9257610a91611329565b5b9050602002810190610aa491906114c7565b9250826000016020810190610ab991906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060200190610adf919061138f565b604051610aed929190611431565b6000604051808303816000865af19150503d8060008114610b2a576040519150601f19603f3d011682016040523d82523d6000602084013e610b2f565b606091505b508260000183602001829052821515151581525050508715610b90578060000151610b8f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b869061153b565b60405180910390fd5b5b81600101915050610a58565b5050509392505050565b6000806060610bb7600186866107bf565b8093508194508295505050509250925092565b600081409050919050565b6040518060400160405280600015158152602001606081525090565b6000819050919050565b610c0481610bf1565b82525050565b6000602082019050610c1f6000830184610bfb565b92915050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610c5457610c53610c2f565b5b8235905067ffffffffffffffff811115610c7157610c70610c34565b5b602083019150836020820283011115610c8d57610c8c610c39565b5b9250929050565b60008060208385031215610cab57610caa610c25565b5b600083013567ffffffffffffffff811115610cc957610cc8610c2a565b5b610cd585828601610c3e565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b60008115159050919050565b610d2281610d0d565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610d62578082015181840152602081019050610d47565b83811115610d71576000848401525b50505050565b6000601f19601f8301169050919050565b6000610d9382610d28565b610d9d8185610d33565b9350610dad818560208601610d44565b610db681610d77565b840191505092915050565b6000604083016000830151610dd96000860182610d19565b5060208301518482036020860152610df18282610d88565b9150508091505092915050565b6000610e0a8383610dc1565b905092915050565b6000602082019050919050565b6000610e2a82610ce1565b610e348185610cec565b935083602082028501610e4685610cfd565b8060005b85811015610e825784840389528151610e638582610dfe565b9450610e6e83610e12565b925060208a01995050600181019050610e4a565b50829750879550505050505092915050565b60006020820190508181036000830152610eae8184610e1f565b905092915050565b60008083601f840112610ecc57610ecb610c2f565b5b8235905067ffffffffffffffff811115610ee957610ee8610c34565b5b602083019150836020820283011115610f0557610f04610c39565b5b9250929050565b60008060208385031215610f2357610f22610c25565b5b600083013567ffffffffffffffff811115610f4157610f40610c2a565b5b610f4d85828601610eb6565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6000610f918383610d88565b905092915050565b6000602082019050919050565b6000610fb182610f59565b610fbb8185610f64565b935083602082028501610fcd85610f75565b8060005b858110156110095784840389528151610fea8582610f85565b9450610ff583610f99565b925060208a01995050600181019050610fd1565b50829750879550505050505092915050565b60006040820190506110306000830185610bfb565b81810360208301526110428184610fa6565b90509392505050565b6000819050919050565b61105e8161104b565b82525050565b60006020820190506110796000830184611055565b92915050565b61108881610d0d565b811461109357600080fd5b50565b6000813590506110a58161107f565b92915050565b6000806000604084860312156110c4576110c3610c25565b5b60006110d286828701611096565b935050602084013567ffffffffffffffff8111156110f3576110f2610c2a565b5b6110ff86828701610eb6565b92509250509250925092565b60006060820190506111206000830186610bfb565b61112d6020830185611055565b818103604083015261113f8184610e1f565b9050949350505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061117482611149565b9050919050565b61118481611169565b811461118f57600080fd5b50565b6000813590506111a18161117b565b92915050565b6000602082840312156111bd576111bc610c25565b5b60006111cb84828501611192565b91505092915050565b60008083601f8401126111ea576111e9610c2f565b5b8235905067ffffffffffffffff81111561120757611206610c34565b5b60208301915083602082028301111561122357611222610c39565b5b9250929050565b6000806020838503121561124157611240610c25565b5b600083013567ffffffffffffffff81111561125f5761125e610c2a565b5b61126b858286016111d4565b92509250509250929050565b61128081611169565b82525050565b600060208201905061129b6000830184611277565b92915050565b6112aa81610bf1565b81146112b557600080fd5b50565b6000813590506112c7816112a1565b92915050565b6000602082840312156112e3576112e2610c25565b5b60006112f1848285016112b8565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600080fd5b600080fd5b600080fd5b60008235600160800383360303811261138357611382611358565b5b80830191505092915050565b600080833560016020038436030381126113ac576113ab611358565b5b80840192508235915067ffffffffffffffff8211156113ce576113cd61135d565b5b6020830192506001820236038313156113ea576113e9611362565b5b509250929050565b600081905092915050565b82818337600083830152505050565b600061141883856113f2565b93506114258385846113fd565b82840190509392505050565b600061143e82848661140c565b91508190509392505050565b600082825260208201905092915050565b7f4d756c746963616c6c333a2076616c7565206d69736d61746368000000000000600082015250565b6000611491601a8361144a565b915061149c8261145b565b602082019050919050565b600060208201905081810360008301526114c081611484565b9050919050565b6000823560016040038336030381126114e3576114e2611358565b5b80830191505092915050565b7f4d756c746963616c6c333a2063616c6c206661696c6564000000000000000000600082015250565b600061152560178361144a565b9150611530826114ef565b602082019050919050565b6000602082019050818103600083015261155481611518565b9050919050565b60008235600160600383360303811261157757611576611358565b5b8083019150509291505056fea264697066735822122020c1bc9aacf8e4a6507193432a895a8e77094f45a1395583f07b24e860ef06cd64736f6c634300080c0033";class Mi extends We{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 Fi extends We{constructor(){super("No chain was provided to the Client.",{name:"ClientChainNotConfiguredError"})}}const ji="/docs/contract/encodeDeployData";function Li(e){const{abi:t,args:n,bytecode:r}=e;if(!n||0===n.length)return r;const o=t.find(e=>"type"in e&&"constructor"===e.type);if(!o)throw new Ye({docsPath:ji});if(!("inputs"in o))throw new Ze({docsPath:ji});if(!o.inputs||0===o.inputs.length)throw new Ze({docsPath:ji});return jn([r,Wn(o.inputs,n)])}function Ui({blockNumber:e,chain:t,contract:n}){const r=t?.contracts?.[n];if(!r)throw new Mi({chain:t,contract:{name:n}});if(e&&r.blockCreated&&r.blockCreated>e)throw new Mi({blockNumber:e,chain:t,contract:{name:n,blockCreated:r.blockCreated}});return r.address}function Di(e,{docsPath:t,...n}){const r=(()=>{const t=Ho(e,n);return t instanceof Wo?e:t})();return new Ur(r,{docsPath:t,...n})}function Gi(){let e=()=>{},t=()=>{};return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}const qi=new Map;function Vi({fn:e,id:t,shouldSplitBatch:n,wait:r=0,sort:o}){const s=async()=>{const t=i();a();const n=t.map(({args:e})=>e);0!==n.length&&e(n).then(e=>{o&&Array.isArray(e)&&e.sort(o);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=()=>qi.delete(t),i=()=>qi.get(t)||[],c=e=>qi.set(t,[...i(),e]);return{flush:a,async schedule(e){const{promise:t,resolve:o,reject:a}=Gi(),u=n?.([...i().map(({args:e})=>e),e]);u&&s();return i().length>0?(c({args:e,resolve:o,reject:a}),t):(c({args:e,resolve:o,reject:a}),setTimeout(s,r),t)}}}async function Wi(e,t){const{account:n=e.account,authorizationList:r,batch:o=Boolean(e.batch?.multicall),blockNumber:s,blockTag:a=e.experimental_blockTag??"latest",accessList:i,blobs:c,blockOverrides:u,code:l,data:d,factory:f,factoryData:h,gas:p,gasPrice:m,maxFeePerBlobGas:g,maxFeePerGas:b,maxPriorityFeePerGas:y,nonce:w,to:v,value:x,stateOverride:E,...P}=t,k=n?sr(n):void 0;if(l&&(f||h))throw new We("Cannot provide both `code` & `factory`/`factoryData` as parameters.");if(l&&v)throw new We("Cannot provide both `code` & `to` as parameters.");const A=l&&d,I=f&&h&&v&&d,N=A||I,S=A?Hi({code:l,data:d}):I?function(e){const{data:t,factory:n,factoryData:r,to:o}=e;return Li({abi:ze(["constructor(address, bytes, address, bytes)"]),bytecode:Ri,args:[o,t,n,r]})}({data:d,factory:f,factoryData:h,to:v}):d;try{ts(t);const n=("bigint"==typeof s?_t(s):void 0)||a,l=u?Ei(u):void 0,d=Xo(E),f=e.chain?.formatters?.transactionRequest?.format,h=(f||Ko)({...Yo(P,{format:f}),from:k?.address,accessList:i,authorizationList:r,blobs:c,data:S,gas:p,gasPrice:m,maxFeePerBlobGas:g,maxFeePerGas:b,maxPriorityFeePerGas:y,nonce:w,to:N?void 0:v,value:x});if(o&&function({request:e}){const{data:t,to:n,...r}=e;return!!t&&(!t.startsWith(Ci)&&(!!n&&!(Object.values(r).filter(e=>void 0!==e).length>0)))}({request:h})&&!d&&!l)try{return await async function(e,t){const{batchSize:n=1024,deployless:r=!1,wait:o=0}="object"==typeof e.batch?.multicall?e.batch.multicall:{},{blockNumber:s,blockTag:a=e.experimental_blockTag??"latest",data:i,to:c}=t,u=(()=>{if(r)return null;if(t.multicallAddress)return t.multicallAddress;if(e.chain)return Ui({blockNumber:s,chain:e.chain,contract:"multicall3"});throw new Fi})(),l="bigint"==typeof s?_t(s):void 0,d=l||a,{schedule:f}=Vi({id:`${e.uid}.${d}`,wait:o,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=ir({abi:Pi,args:[n],functionName:"aggregate3"}),o=await e.request({method:"eth_call",params:[{...null===u?{data:Hi({code:_i,data:r})}:{to:u,data:r}},d]});return Ws({abi:Pi,args:[n],functionName:"aggregate3",data:o||"0x"})}}),[{returnData:h,success:p}]=await f({data:i,to:c});if(!p)throw new Wr({data:h});return"0x"===h?{data:void 0}:{data:h}}(e,{...h,blockNumber:s,blockTag:a})}catch(e){if(!(e instanceof Fi||e instanceof Mi))throw e}const A=(()=>{const e=[h,n];return d&&l?[...e,d,l]:d?[...e,d]:l?[...e,{},l]:e})(),I=await e.request({method:"eth_call",params:A});return"0x"===I?{data:void 0}:{data:I}}catch(n){const r=function(e){if(!(e instanceof We))return;const t=e.walk();return"object"==typeof t?.data?t.data?.data:t.data}(n),{offchainLookup:o,offchainLookupSignature:s}=await Promise.resolve().then(function(){return Qc});if(!1!==e.ccipRead&&r?.slice(0,10)===s&&v)return{data:await o(e,{data:r,to:v})};if(N&&"0x101bb98d"===r?.slice(0,10))throw new Vr({factory:f});throw Di(n,{...t,account:k,chain:e.chain})}}function Hi(e){const{code:t,data:n}=e;return Li({abi:ze(["constructor(bytes, bytes)"]),bytecode:Oi,args:[t,n]})}async function Yi(e,t){const{abi:n,address:r,args:o,functionName:s,...a}=t,i=ir({abi:n,args:o,functionName:s});try{const{data:t}=await Fe(e,Wi,"call")({...a,data:i,to:r});return Ws({abi:n,args:o,functionName:s,data:t||"0x"})}catch(e){throw Io(e,{abi:n,address:r,args:o,docsPath:"/docs/contract/readContract",functionName:s})}}const Zi=new Map,Ki=new Map;let Ji=0;function Qi(e,t,n){const r=++Ji,o=()=>Zi.get(e)||[],s=()=>{const t=o();if(!t.some(e=>e.id===r))return;const n=Ki.get(e);if(1===t.length&&n){const e=n();e instanceof Promise&&e.catch(()=>{})}(()=>{const t=o();Zi.set(e,t.filter(e=>e.id!==r))})()},a=o();if(Zi.set(e,[...a,{id:r,fns:t}]),a&&a.length>0)return s;const i={};for(const e in t)i[e]=(...t)=>{const n=o();if(0!==n.length)for(const r of n)r.fns[e]?.(...t)};const c=n(i);return"function"==typeof c&&Ki.set(e,c),s}async function Xi(e){return new Promise(t=>setTimeout(t,e))}function ec(e,{emitOnBegin:t,initialWaitTime:n,interval:r}){let o=!0;const s=()=>o=!1;return(async()=>{let a;t&&(a=await e({unpoll:s}));const i=await(n?.(a))??r;await Xi(i);const c=async()=>{o&&(await e({unpoll:s}),await Xi(r),c())};c()})(),s}const tc=new Map,nc=new Map;async function rc(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,tc),r=t(e,nc);return{clear:()=>{n.clear(),r.clear()},promise:n,response:r}}(t),o=r.response.get();if(o&&n>0){if(Date.now()-o.created.getTime()<n)return o.data}let s=r.promise.get();s||(s=e(),r.promise.set(s));try{const e=await s;return r.response.set({created:new Date,data:e}),e}finally{r.promise.clear()}}async function oc(e,{cacheTime:t=e.cacheTime}={}){const n=await rc(()=>e.request({method:"eth_blockNumber"}),{cacheKey:(r=e.uid,`blockNumber.${r}`),cacheTime:t});var r;return BigInt(n)}async function sc(e,{filter:t}){const n="strict"in t&&t.strict,r=await t.request({method:"eth_getFilterChanges",params:[t.id]});if("string"==typeof r[0])return r;const o=r.map(e=>Ds(e));return"abi"in t&&t.abi?Us({abi:t.abi,logs:o,strict:n}):o}async function ac(e,{filter:t}){return t.request({method:"eth_uninstallFilter",params:[t.id]})}function ic(e,{delay:t=100,retryCount:n=2,shouldRetry:r=()=>!0}={}){return new Promise((o,s)=>{const a=async({count:i=0}={})=>{try{const t=await e();o(t)}catch(e){if(i<n&&await r({count:i,error:e}))return(async({error:e})=>{const n="function"==typeof t?t({count:i,error:e}):t;n&&await Xi(n),a({count:i+1})})({error:e});s(e)}};a()})}const cc={"0x0":"reverted","0x1":"success"};function uc(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=>Ds(e)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Bt(e.transactionIndex):null,status:e.status?cc[e.status]:null,type:e.type?as[e.type]||e.type:null};return e.blobGasPrice&&(t.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(t.blobGasUsed=BigInt(e.blobGasUsed)),t}let lc,dc=256;function fc(e=11){if(!lc||dc+e>512){lc="",dc=0;for(let e=0;e<256;e++)lc+=(256+256*Math.random()|0).toString(16).substring(1)}return lc.substring(dc,dc+++e)}function hc(e){if(!(e instanceof We))return!1;const t=e.walk(e=>e instanceof Gr);return t instanceof Gr&&("HttpError"===t.data?.errorName||("ResolverError"===t.data?.errorName||("ResolverNotContract"===t.data?.errorName||("ResolverNotFound"===t.data?.errorName||("ReverseAddressMismatch"===t.data?.errorName||"UnsupportedResolverProfile"===t.data?.errorName)))))}const pc="/docs/contract/encodeErrorResult";function mc(e){const{abi:t,errorName:n,args:r}=e;let o=t[0];if(n){const e=Jn({abi:t,args:r,name:n});if(!e)throw new nt(n,{docsPath:pc});o=e}if("error"!==o.type)throw new nt(void 0,{docsPath:pc});const s=je(o),a=Kn(s);let i="0x";if(r&&r.length>0){if(!o.inputs)throw new tt(o.name,{docsPath:pc});i=Wn(o.inputs,r)}return jn([a,i])}const gc="/docs/contract/encodeFunctionResult";const bc="x-batch-gateway:true";async function yc(e){const{data:t,ccipRequest:n}=e,{args:[r]}=function(e){const{abi:t,data:n}=e,r=Ln(n,0,4),o=t.find(e=>"function"===e.type&&r===Kn(je(e)));if(!o)throw new ut(r,{docsPath:"/docs/contract/decodeFunctionData"});return{functionName:o.name,args:"inputs"in o&&o.inputs&&o.inputs.length>0?wr(o.inputs,Ln(n,4)):void 0}}({abi:ki,data:t}),o=[],s=[];return await Promise.all(r.map(async(e,t)=>{try{s[t]=e.urls.includes(bc)?await yc({data:e.data,ccipRequest:n}):await n(e),o[t]=!1}catch(e){o[t]=!0,s[t]="HttpRequestError"===(r=e).name&&r.status?mc({abi:ki,errorName:"HttpError",args:[r.status,r.shortMessage]}):mc({abi:[ur],errorName:"Error",args:["shortMessage"in r?r.shortMessage:r.message]})}var r})),function(e){const{abi:t,functionName:n,result:r}=e;let o=t[0];if(n){const e=Jn({abi:t,name:n});if(!e)throw new it(n,{docsPath:gc});o=e}if("function"!==o.type)throw new it(void 0,{docsPath:gc});if(!o.outputs)throw new ct(o.name,{docsPath:gc});const s=(()=>{if(0===o.outputs.length)return[];if(1===o.outputs.length)return[r];if(Array.isArray(r))return r;throw new gt(r)})();return Wn(o.outputs,s)}({abi:ki,functionName:"query",result:[o,s]})}function wc(e){if(66!==e.length)return null;if(0!==e.indexOf("["))return null;if(65!==e.indexOf("]"))return null;const t=`0x${e.slice(1,65)}`;return Ue(t)?t:null}function vc(e){let t=new Uint8Array(32).fill(0);if(!e)return zt(t);const n=e.split(".");for(let e=n.length-1;e>=0;e-=1){const r=wc(n[e]),o=r?Lt(r):An(qt(n[e]),"bytes");t=An(Fn([t,o]),"bytes")}return zt(t)}function xc(e){return`[${e.slice(2)}]`}function Ec(e){const t=new Uint8Array(32).fill(0);return e?wc(e)||An(qt(e)):zt(t)}function Pc(e){const t=e.replace(/^\.|\.$/gm,"");if(0===t.length)return new Uint8Array(1);const n=new Uint8Array(qt(t).byteLength+2);let r=0;const o=t.split(".");for(let e=0;e<o.length;e++){let t=qt(o[e]);t.byteLength>255&&(t=qt(xc(Ec(o[e])))),n[r]=t.length,n.set(t,r+1),r+=t.length+1}return n.byteLength!==r+1?n.slice(0,r+1):n}class kc extends We{constructor({data:e}){super("Unable to extract image from metadata. The metadata may be malformed or invalid.",{metaMessages:["- Metadata must be a JSON object with at least an `image`, `image_url` or `image_data` property.","",`Provided data: ${JSON.stringify(e)}`],name:"EnsAvatarInvalidMetadataError"})}}class Ac extends We{constructor({reason:e}){super(`ENS NFT avatar URI is invalid. ${e}`,{name:"EnsAvatarInvalidNftUriError"})}}class Ic extends We{constructor({uri:e}){super(`Unable to resolve ENS avatar URI "${e}". The URI may be malformed, invalid, or does not respond with a valid image.`,{name:"EnsAvatarUriResolutionError"})}}class Nc extends We{constructor({namespace:e}){super(`ENS NFT avatar namespace "${e}" is not supported. Must be "erc721" or "erc1155".`,{name:"EnsAvatarUnsupportedNamespaceError"})}}const Sc=/(?<protocol>https?:\/\/[^/]*|ipfs:\/|ipns:\/|ar:\/)?(?<root>\/)?(?<subpath>ipfs\/|ipns\/)?(?<target>[\w\-.]+)(?<subtarget>\/.*)?/,Tc=/^(Qm[1-9A-HJ-NP-Za-km-z]{44,}|b[A-Za-z2-7]{58,}|B[A-Z2-7]{58,}|z[1-9A-HJ-NP-Za-km-z]{48,}|F[0-9A-F]{50,})(\/(?<target>[\w\-.]+))?(?<subtarget>\/.*)?$/,$c=/^data:([a-zA-Z\-/+]*);base64,([^"].*)/,Bc=/^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;function Cc(e,t){return e?e.endsWith("/")?e.slice(0,-1):e:t}function Oc({uri:e,gatewayUrls:t}){const n=$c.test(e);if(n)return{uri:e,isOnChain:!0,isEncoded:n};const r=Cc(t?.ipfs,"https://ipfs.io"),o=Cc(t?.arweave,"https://arweave.net"),s=e.match(Sc),{protocol:a,subpath:i,target:c,subtarget:u=""}=s?.groups||{},l="ipns:/"===a||"ipns/"===i,d="ipfs:/"===a||"ipfs/"===i||Tc.test(e);if(e.startsWith("http")&&!l&&!d){let n=e;return t?.arweave&&(n=e.replace(/https:\/\/arweave.net/g,t?.arweave)),{uri:n,isOnChain:!1,isEncoded:!1}}if((l||d)&&c)return{uri:`${r}/${l?"ipns":"ipfs"}/${c}${u}`,isOnChain:!1,isEncoded:!1};if("ar:/"===a&&c)return{uri:`${o}/${c}${u||""}`,isOnChain:!1,isEncoded:!1};let f=e.replace(Bc,"");if(f.startsWith("<svg")&&(f=`data:image/svg+xml;base64,${btoa(f)}`),f.startsWith("data:")||f.startsWith("{"))return{uri:f,isOnChain:!0,isEncoded:!1};throw new Ic({uri:e})}function Rc(e){if("object"!=typeof e||!("image"in e)&&!("image_url"in e)&&!("image_data"in e))throw new kc({data:e});return e.image||e.image_url||e.image_data}async function zc({gatewayUrls:e,uri:t}){const{uri:n,isOnChain:r}=Oc({uri:t,gatewayUrls:e});if(r)return n;const o=await async function(e){try{const t=await fetch(e,{method:"HEAD"});if(200===t.status){const e=t.headers.get("content-type");return e?.startsWith("image/")}return!1}catch(t){return("object"!=typeof t||void 0===t.response)&&!!Object.hasOwn(globalThis,"Image")&&new Promise(t=>{const n=new Image;n.onload=()=>{t(!0)},n.onerror=()=>{t(!1)},n.src=e})}}(n);if(o)return n;throw new Ic({uri:t})}async function _c(e,{gatewayUrls:t,record:n}){return/eip155:/i.test(n)?async function(e,{gatewayUrls:t,record:n}){const r=function(e){let t=e;t.startsWith("did:nft:")&&(t=t.replace("did:nft:","").replace(/_/g,"/"));const[n,r,o]=t.split("/"),[s,a]=n.split(":"),[i,c]=r.split(":");if(!s||"eip155"!==s.toLowerCase())throw new Ac({reason:"Only EIP-155 supported"});if(!a)throw new Ac({reason:"Chain ID not found"});if(!c)throw new Ac({reason:"Contract address not found"});if(!o)throw new Ac({reason:"Token ID not found"});if(!i)throw new Ac({reason:"ERC namespace not found"});return{chainID:Number.parseInt(a,10),namespace:i.toLowerCase(),contractAddress:c,tokenID:o}}(n),o=await async function(e,{nft:t}){if("erc721"===t.namespace)return Yi(e,{address:t.contractAddress,abi:[{name:"tokenURI",type:"function",stateMutability:"view",inputs:[{name:"tokenId",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"tokenURI",args:[BigInt(t.tokenID)]});if("erc1155"===t.namespace)return Yi(e,{address:t.contractAddress,abi:[{name:"uri",type:"function",stateMutability:"view",inputs:[{name:"_id",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"uri",args:[BigInt(t.tokenID)]});throw new Nc({namespace:t.namespace})}(e,{nft:r}),{uri:s,isOnChain:a,isEncoded:i}=Oc({uri:o,gatewayUrls:t});if(a&&(s.includes("data:application/json;base64,")||s.startsWith("{"))){const e=i?atob(s.replace("data:application/json;base64,","")):s;return zc({uri:Rc(JSON.parse(e)),gatewayUrls:t})}let c=r.tokenID;"erc1155"===r.namespace&&(c=c.replace("0x","").padStart(64,"0"));return async function({gatewayUrls:e,uri:t}){try{const n=await fetch(t).then(e=>e.json());return await zc({gatewayUrls:e,uri:Rc(n)})}catch{throw new Ic({uri:t})}}({gatewayUrls:t,uri:s.replace(/(?:0x)?{id}/,c)})}(e,{gatewayUrls:t,record:n}):zc({uri:n,gatewayUrls:t})}async function Mc(e,t){const{blockNumber:n,blockTag:r,key:o,name:s,gatewayUrls:a,strict:i}=t,{chain:c}=e,u=(()=>{if(t.universalResolverAddress)return t.universalResolverAddress;if(!c)throw new Error("client chain not configured. universalResolverAddress is required.");return Ui({blockNumber:n,chain:c,contract:"ensUniversalResolver"})})(),l=c?.ensTlds;if(l&&!l.some(e=>s.endsWith(e)))return null;try{const t={address:u,abi:Ii,args:[Ot(Pc(s)),ir({abi:Si,functionName:"text",args:[vc(s),o]}),a??[bc]],functionName:"resolveWithGateways",blockNumber:n,blockTag:r},i=Fe(e,Yi,"readContract"),c=await i(t);if("0x"===c[0])return null;const l=Ws({abi:Si,functionName:"text",data:c[0]});return""===l?null:l}catch(e){if(i)throw e;if(hc(e))return null;throw e}}async function Fc(e,t){const{account:n=e.account,blockNumber:r,blockTag:o="latest",blobs:s,data:a,gas:i,gasPrice:c,maxFeePerBlobGas:u,maxFeePerGas:l,maxPriorityFeePerGas:d,to:f,value:h,...p}=t,m=n?sr(n):void 0;try{ts(t);const n=("bigint"==typeof r?_t(r):void 0)||o,g=e.chain?.formatters?.transactionRequest?.format,b=(g||Ko)({...Yo(p,{format:g}),from:m?.address,blobs:s,data:a,gas:i,gasPrice:c,maxFeePerBlobGas:u,maxFeePerGas:l,maxPriorityFeePerGas:d,to:f,value:h}),y=await e.request({method:"eth_createAccessList",params:[b,n]});return{accessList:y.accessList,gasUsed:BigInt(y.gasUsed)}}catch(n){throw Di(n,{...t,account:m,chain:e.chain})}}async function jc(e,{address:t,args:n,event:r,events:o,fromBlock:s,strict:a,toBlock:i}={}){const c=o??(r?[r]:void 0),u=rr(e,{method:"eth_newFilter"});let l=[];if(c){const e=c.flatMap(e=>tr({abi:[e],eventName:e.name,args:n}));l=[e],r&&(l=l[0])}const d=await e.request({method:"eth_newFilter",params:[{address:t,fromBlock:"bigint"==typeof s?_t(s):s,toBlock:"bigint"==typeof i?_t(i):i,...l.length?{topics:l}:{}}]});return{abi:c,args:n,eventName:r?r.name:void 0,fromBlock:s,id:d,request:u(d),strict:Boolean(a),toBlock:i,type:"event"}}async function Lc(e){const t=rr(e,{method:"eth_newPendingTransactionFilter"}),n=await e.request({method:"eth_newPendingTransactionFilter"});return{id:n,request:t(n),type:"transaction"}}async function Uc(e,{address:t,blockNumber:n,blockTag:r="latest"}){const o=void 0!==n?_t(n):void 0,s=await e.request({method:"eth_getCode",params:[t,o||r]},{dedupe:Boolean(o)});if("0x"!==s)return s}class Dc extends We{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 Gc=[{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"}];async function qc(e,{blockCount:t,blockNumber:n,blockTag:r="latest",rewardPercentiles:o}){const s="bigint"==typeof n?_t(n):void 0;return function(e){return{baseFeePerGas:e.baseFeePerGas.map(e=>BigInt(e)),gasUsedRatio:e.gasUsedRatio,oldestBlock:BigInt(e.oldestBlock),reward:e.reward?.map(e=>e.map(e=>BigInt(e)))}}(await e.request({method:"eth_feeHistory",params:[_t(t),s||r,o]},{dedupe:Boolean(s)}))}const Vc=new Bn(8192);function Wc(e,t={}){return async(n,r={})=>{const{dedupe:o=!1,methods:s,retryDelay:a=150,retryCount:i=3,uid:c}={...t,...r},{method:u}=n;if(s?.exclude?.includes(u))throw new io(new Error("method not supported"),{method:u});if(s?.include&&!s.include.includes(u))throw new io(new Error("method not supported"),{method:u});return function(e,{enabled:t=!0,id:n}){if(!t||!n)return e();if(Vc.get(n))return Vc.get(n);const r=e().finally(()=>Vc.delete(n));return Vc.set(n,r),r}(()=>ic(async()=>{try{return await e(n)}catch(e){const t=e;switch(t.code){case Qr.code:throw new Qr(t);case Xr.code:throw new Xr(t);case eo.code:throw new eo(t,{method:n.method});case to.code:throw new to(t);case no.code:throw new no(t);case ro.code:throw new ro(t);case oo.code:throw new oo(t);case so.code:throw new so(t);case ao.code:throw new ao(t);case io.code:throw new io(t,{method:n.method});case co.code:throw new co(t);case uo.code:throw new uo(t);case lo.code:throw new lo(t);case fo.code:throw new fo(t);case ho.code:throw new ho(t);case po.code:throw new po(t);case mo.code:throw new mo(t);case go.code:throw new go(t);case bo.code:throw new bo(t);case yo.code:throw new yo(t);case wo.code:throw new wo(t);case vo.code:throw new vo(t);case xo.code:throw new xo(t);case Eo.code:throw new Eo(t);case Po.code:throw new Po(t);case 5e3:throw new lo(t);default:if(e instanceof We)throw e;throw new ko(t)}}},{delay:({count:e,error:t})=>{if(t&&t instanceof Hr){const e=t?.headers?.get("Retry-After");if(e?.match(/\d/))return 1e3*Number.parseInt(e,10)}return(1<<e)*a},retryCount:i,shouldRetry:({error:e})=>function(e){if("code"in e&&"number"==typeof e.code)return-1===e.code||(e.code===co.code||e.code===no.code);if(e instanceof Hr&&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:o,id:o?Ft(`${c}.${Ar(n)}`):void 0})}}class Hc extends We{constructor({callbackSelector:e,cause:t,data:n,extraData:r,sender:o,urls:s}){super(t.shortMessage||"An error occurred while fetching for an offchain result.",{cause:t,metaMessages:[...t.metaMessages||[],t.metaMessages?.length?"":[],"Offchain Gateway Call:",s&&[" Gateway URL(s):",...s.map(e=>` ${e}`)],` Sender: ${o}`,` Data: ${n}`,` Callback selector: ${e}`,` Extra data: ${r}`].flat(),name:"OffchainLookupError"})}}class Yc extends We{constructor({result:e,url:t}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${t}`,`Response: ${Ar(e)}`],name:"OffchainLookupResponseMalformedError"})}}class Zc extends We{constructor({sender:e,to:t}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${t}`,`OffchainLookup sender address: ${e}`],name:"OffchainLookupSenderMismatchError"})}}const Kc={name:"OffchainLookup",type:"error",inputs:[{name:"sender",type:"address"},{name:"urls",type:"string[]"},{name:"callData",type:"bytes"},{name:"callbackFunction",type:"bytes4"},{name:"extraData",type:"bytes"}]};async function Jc({data:e,sender:t,urls:n}){let r=new Error("An unknown error occurred.");for(let o=0;o<n.length;o++){const s=n[o],a=s.includes("{data}")?"GET":"POST",i="POST"===a?{data:e,sender:t}:void 0,c="POST"===a?{"Content-Type":"application/json"}:{};try{const n=await fetch(s.replace("{sender}",t.toLowerCase()).replace("{data}",e),{body:JSON.stringify(i),headers:c,method:a});let o;if(o=n.headers.get("Content-Type")?.startsWith("application/json")?(await n.json()).data:await n.text(),!n.ok){r=new Hr({body:i,details:o?.error?Ar(o.error):n.statusText,headers:n.headers,status:n.status,url:s});continue}if(!Ue(o)){r=new Yc({result:o,url:s});continue}return o}catch(e){r=new Hr({body:i,details:e.message,url:s})}}throw r}var Qc=Object.freeze({__proto__:null,ccipRequest:Jc,offchainLookup:async function(e,{blockNumber:t,blockTag:n,data:r,to:o}){const{args:s}=kr({data:r,abi:[Kc]}),[a,i,c,u,l]=s,{ccipRead:d}=e,f=d&&"function"==typeof d?.request?d.request:Jc;try{if(!Ms(o,a))throw new Zc({sender:a,to:o});const r=i.includes(bc)?await yc({data:c,ccipRequest:f}):await f({data:c,sender:a,urls:i}),{data:s}=await Wi(e,{blockNumber:t,blockTag:n,data:Fn([u,Wn([{type:"bytes"},{type:"bytes"}],[r,l])]),to:o});return s}catch(e){throw new Hc({callbackSelector:u,cause:e,data:r,extraData:l,sender:a,urls:i})}},offchainLookupAbiItem:Kc,offchainLookupSignature:"0x556f1830"});function Xc(){return{current:0,take(){return this.current++},reset(){this.current=0}}}const eu=Xc();function tu(e,t={}){return{async request(n){const{body:r,fetchFn:o=t.fetchFn??fetch,onRequest:s=t.onRequest,onResponse:a=t.onResponse,timeout:i=t.timeout??1e4}=n,c={...t.fetchOptions??{},...n.fetchOptions??{}},{headers:u,method:l,signal:d}=c;try{const t=await function(e,{errorInstance:t=new Error("timed out"),timeout:n,signal:r}){return new Promise((o,s)=>{(async()=>{let a;try{const t=new AbortController;n>0&&(a=setTimeout(()=>{r&&t.abort()},n)),o(await e({signal:t?.signal||null}))}catch(e){"AbortError"===e?.name&&s(t),s(e)}finally{clearTimeout(a)}})()})}(async({signal:t})=>{const n={...c,body:Array.isArray(r)?Ar(r.map(e=>({jsonrpc:"2.0",id:e.id??eu.take(),...e}))):Ar({jsonrpc:"2.0",id:r.id??eu.take(),...r}),headers:{"Content-Type":"application/json",...u},method:l||"POST",signal:d||(i>0?t:null)},a=new Request(e,n),f=await(s?.(a,n))??{...n,url:e};return await o(f.url??e,f)},{errorInstance:new Zr({body:r,url:e}),timeout:i,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 Hr({body:r,details:Ar(n.error)||t.statusText,headers:t.headers,status:t.status,url:e});return n}catch(t){if(t instanceof Hr)throw t;if(t instanceof Zr)throw t;throw new Hr({body:r,cause:t,url:e})}}}}function nu(e,t){return An(function(e){const t="string"==typeof e?Ft(e):"string"==typeof e.raw?e.raw:zt(e.raw);return Fn([Ft(`Ethereum Signed Message:\n${De(t)}`),t])}(e),t)}class ru extends We{constructor({domain:e}){super(`Invalid domain "${Ar(e)}".`,{metaMessages:["Must be a valid EIP-712 domain."]})}}class ou extends We{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 su extends We{constructor({type:e}){super(`Struct type "${e}" is invalid.`,{metaMessages:["Struct type must not be a Solidity type."],name:"InvalidStructTypeError"})}}function au({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 iu(e){if("address"===e||"bool"===e||"string"===e||e.startsWith("bytes")||e.startsWith("uint")||e.startsWith("int"))throw new su({type:e})}function cu(e){const{domain:t={},message:n,primaryType:r}=e,o={EIP712Domain:au({domain:t}),...e.types};!function(e){const{domain:t,message:n,primaryType:r,types:o}=e,s=(e,t)=>{for(const n of e){const{name:e,type:r}=n,a=t[e],i=r.match(Vn);if(i&&("number"==typeof a||"bigint"==typeof a)){const[e,t,n]=i;_t(a,{signed:"int"===t,size:Number.parseInt(n,10)/8})}if("address"===r&&"string"==typeof a&&!Mn(a))throw new $n({address:a});const c=r.match(qn);if(c){const[e,t]=c;if(t&&De(a)!==Number.parseInt(t,10))throw new dt({expectedSize:Number.parseInt(t,10),givenSize:De(a)})}const u=o[r];u&&(iu(r),s(u,a))}};if(o.EIP712Domain&&t){if("object"!=typeof t)throw new ru({domain:t});s(o.EIP712Domain,t)}if("EIP712Domain"!==r){if(!o[r])throw new ou({primaryType:r,types:o});s(o[r],n)}}({domain:t,message:n,primaryType:r,types:o});const s=["0x1901"];return t&&s.push(function({domain:e,types:t}){return uu({data:e,primaryType:"EIP712Domain",types:t})}({domain:t,types:o})),"EIP712Domain"!==r&&s.push(uu({data:n,primaryType:r,types:o})),An(Fn(s))}function uu({data:e,primaryType:t,types:n}){return An(lu({data:e,primaryType:t,types:n}))}function lu({data:e,primaryType:t,types:n}){const r=[{type:"bytes32"}],o=[du({primaryType:t,types:n})];for(const s of n[t]){const[t,a]=hu({types:n,name:s.name,type:s.type,value:e[s.name]});r.push(t),o.push(a)}return Wn(r,o)}function du({primaryType:e,types:t}){const n=Ot(function({primaryType:e,types:t}){let n="";const r=fu({primaryType:e,types:t});r.delete(e);const o=[e,...Array.from(r).sort()];for(const e of o)n+=`${e}(${t[e].map(({name:e,type:t})=>`${t} ${e}`).join(",")})`;return n}({primaryType:e,types:t}));return An(n)}function fu({primaryType:e,types:t},n=new Set){const r=e.match(/^\w*/u),o=r?.[0];if(n.has(o)||void 0===t[o])return n;n.add(o);for(const e of t[o])fu({primaryType:e.type,types:t},n);return n}function hu({types:e,name:t,type:n,value:r}){if(void 0!==e[n])return[{type:"bytes32"},An(lu({data:r,primaryType:n,types:e}))];if("bytes"===n){return[{type:"bytes32"},An(r=`0x${(r.length%2?"0":"")+r.slice(2)}`)]}if("string"===n)return[{type:"bytes32"},An(Ot(r))];if(n.lastIndexOf("]")===n.length-1){const o=n.slice(0,n.lastIndexOf("[")),s=r.map(n=>hu({name:t,type:o,types:e,value:n}));return[{type:"bytes32"},An(Wn(s.map(([e])=>e),s.map(([,e])=>e)))]}return[{type:n},r]}class pu 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 mu={checksum:new pu(8192)}.checksum;function gu(e,t={}){const{as:n=("string"==typeof e?"Hex":"Bytes")}=t,r=kn(Da(e));return"Bytes"===n?r:si(r)}const bu=/^0x[a-fA-F0-9]{40}$/;function yu(e,t={}){const{strict:n=!0}=t;if(!bu.test(e))throw new xu({address:e,cause:new Eu});if(n){if(e.toLowerCase()===e)return;if(wu(e)!==e)throw new xu({address:e,cause:new Pu})}}function wu(e){if(mu.has(e))return mu.get(e);yu(e,{strict:!1});const t=e.substring(2).toLowerCase(),n=gu(qa(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 o=`0x${r.join("")}`;return mu.set(e,o),o}function vu(e,t={}){const{strict:n=!0}=t??{};try{return yu(e,{strict:n}),!0}catch{return!1}}class xu extends Ia{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 Eu extends Ia{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 Pu extends Ia{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}const ku=/^(.*)\[([0-9]*)\]$/,Au=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Iu=/^(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)?$/,Nu=2n**256n-1n;function Su(e,t,n){const{checksumAddress:r,staticPosition:o}=n,s=Ou(t.type);if(s){const[n,a]=s;return function(e,t,n){const{checksumAddress:r,length:o,staticPosition:s}=n;if(!o){const n=s+Za(e.readBytes($u)),o=n+Tu;e.setPosition(n);const a=Za(e.readBytes(Tu)),i=Ru(t);let c=0;const u=[];for(let n=0;n<a;++n){e.setPosition(o+(i?32*n:c));const[s,a]=Su(e,t,{checksumAddress:r,staticPosition:o});c+=a,u.push(s)}return e.setPosition(s+32),[u,32]}if(Ru(t)){const n=s+Za(e.readBytes($u)),a=[];for(let s=0;s<o;++s){e.setPosition(n+32*s);const[o]=Su(e,t,{checksumAddress:r,staticPosition:n});a.push(o)}return e.setPosition(s+32),[a,32]}let a=0;const i=[];for(let n=0;n<o;++n){const[n,o]=Su(e,t,{checksumAddress:r,staticPosition:s+a});a+=o,i.push(n)}return[i,a]}(e,{...t,type:a},{checksumAddress:r,length:n,staticPosition:o})}if("tuple"===t.type)return function(e,t,n){const{checksumAddress:r,staticPosition:o}=n,s=0===t.components.length||t.components.some(({name:e})=>!e),a=s?[]:{};let i=0;if(Ru(t)){const n=o+Za(e.readBytes($u));for(let o=0;o<t.components.length;++o){const c=t.components[o];e.setPosition(n+i);const[u,l]=Su(e,c,{checksumAddress:r,staticPosition:n});i+=l,a[s?o:c?.name]=u}return e.setPosition(o+32),[a,32]}for(let n=0;n<t.components.length;++n){const c=t.components[n],[u,l]=Su(e,c,{checksumAddress:r,staticPosition:o});a[s?n:c?.name]=u,i+=l}return[a,i]}(e,t,{checksumAddress:r,staticPosition:o});if("address"===t.type)return function(e,t={}){const{checksum:n=!1}=t,r=e.readBytes(32),o=e=>n?wu(e):e;return[o(si(Wa(r,-20))),32]}(e,{checksum:r});if("bool"===t.type)return function(e){return[Ya(e.readBytes(32),{size:32}),32]}(e);if(t.type.startsWith("bytes"))return function(e,t,{staticPosition:n}){const[r,o]=t.type.split("bytes");if(!o){const t=Za(e.readBytes(32));e.setPosition(n+t);const r=Za(e.readBytes(32));if(0===r)return e.setPosition(n+32),["0x",32];const o=e.readBytes(r);return e.setPosition(n+32),[si(o),32]}const s=si(e.readBytes(Number.parseInt(o,10),32));return[s,32]}(e,t,{staticPosition:o});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),o=e.readBytes(32);return[r>48?Ha(o,{signed:n}):Za(o,{signed:n}),32]}(e,t);if("string"===t.type)return function(e,{staticPosition:t}){const n=Za(e.readBytes(32)),r=t+n;e.setPosition(r);const o=Za(e.readBytes(32));if(0===o)return e.setPosition(t+32),["",32];const s=e.readBytes(o,32),a=Ka(Ja(s));return e.setPosition(t+32),[a,32]}(e,{staticPosition:o});throw new Zu(t.type)}const Tu=32,$u=32;function Bu({checksumAddress:e=!1,parameter:t,value:n}){const r=t,o=Ou(r.type);if(o){const[t,s]=o;return function(e,t){const{checksumAddress:n,length:r,parameter:o}=t,s=null===r;if(!Array.isArray(e))throw new Yu(e);if(!s&&e.length!==r)throw new Vu({expectedLength:r,givenLength:e.length,type:`${o.type}[${r}]`});let a=!1;const i=[];for(let t=0;t<e.length;t++){const r=Bu({checksumAddress:n,parameter:o,value:e[t]});r.dynamic&&(a=!0),i.push(r)}if(s||a){const e=Cu(i);if(s){const t=ai(i.length,{size:32});return{dynamic:!0,encoded:i.length>0?ri(t,e):t}}if(a)return{dynamic:!0,encoded:e}}return{dynamic:!1,encoded:ri(...i.map(({encoded:e})=>e))}}(n,{checksumAddress:e,length:t,parameter:{...r,type:s}})}if("tuple"===r.type)return function(e,t){const{checksumAddress:n,parameter:r}=t;let o=!1;const s=[];for(let t=0;t<r.components.length;t++){const a=r.components[t],i=Bu({checksumAddress:n,parameter:a,value:e[Array.isArray(e)?t:a.name]});s.push(i),i.dynamic&&(o=!0)}return{dynamic:o,encoded:o?Cu(s):ri(...s.map(({encoded:e})=>e))}}(n,{checksumAddress:e,parameter:r});if("address"===r.type)return function(e,t){const{checksum:n=!1}=t;return yu(e,{strict:n}),{dynamic:!1,encoded:ci(e.toLowerCase())}}(n,{checksum:e});if("bool"===r.type)return function(e){if("boolean"!=typeof e)throw new Ia(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:ci(oi(e))}}(n);if(r.type.startsWith("uint")||r.type.startsWith("int")){const e=r.type.startsWith("int"),[,,t="256"]=Iu.exec(r.type)??[];return function(e,{signed:t,size:n}){if("number"==typeof n){const r=2n**(BigInt(n)-(t?1n:0n))-1n,o=t?-r-1n:0n;if(e>r||e<o)throw new mi({max:r.toString(),min:o.toString(),signed:t,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:ai(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=di(e);if(!n){let t=e;return r%32!=0&&(t=ui(t,32*Math.ceil((e.length-2)/2/32))),{dynamic:!0,encoded:ri(ci(ai(r,{size:32})),t)}}if(r!==Number.parseInt(n,10))throw new Wu({expectedSize:Number.parseInt(n,10),value:e});return{dynamic:!1,encoded:ui(e)}}(n,{type:r.type});if("string"===r.type)return function(e){const t=ii(e),n=Math.ceil(di(t)/32),r=[];for(let e=0;e<n;e++)r.push(ui(li(t,32*e,32*(e+1))));return{dynamic:!0,encoded:ri(ui(ai(di(t),{size:32})),...r)}}(n);throw new Zu(r.type)}function Cu(e){let t=0;for(let n=0;n<e.length;n++){const{dynamic:r,encoded:o}=e[n];t+=r?32:di(o)}const n=[],r=[];let o=0;for(let s=0;s<e.length;s++){const{dynamic:a,encoded:i}=e[s];a?(n.push(ai(t+o,{size:32})),r.push(i),o+=di(i)):n.push(i)}return ri(...n,...r)}function Ou(e){const t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}function Ru(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(Ru);const n=Ou(e.type);return!(!n||!Ru({...e,type:n[1]}))}const zu={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 Fu({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new Mu({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new _u({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 _u({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 _u extends Ia{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.NegativeOffsetError"})}}class Mu extends Ia{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 Fu extends Ia{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 ju(e,t,n={}){const{as:r="Array",checksumAddress:o=!1}=n,s="string"==typeof t?Ga(t):t,a=function(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(zu);return n.bytes=e,n.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=t,n}(s);if(0===Va(s)&&e.length>0)throw new qu;if(Va(s)&&Va(s)<32)throw new Gu({data:"string"==typeof t?t:si(t),parameters:e,size:Va(s)});let i=0;const c="Array"===r?[]:{};for(let t=0;t<e.length;++t){const n=e[t];a.setPosition(i);const[s,u]=Su(a,n,{checksumAddress:o,staticPosition:0});i+=u,"Array"===r?c.push(s):c[n.name??t]=s}return c}function Lu(e,t,n){const{checksumAddress:r=!1}={};if(e.length!==t.length)throw new Hu({expectedLength:e.length,givenLength:t.length});const o=function({checksumAddress:e,parameters:t,values:n}){const r=[];for(let o=0;o<t.length;o++)r.push(Bu({checksumAddress:e,parameter:t[o],value:n[o]}));return r}({checksumAddress:r,parameters:e,values:t}),s=Cu(o);return 0===s.length?"0x":s}function Uu(e,t){if(e.length!==t.length)throw new Hu({expectedLength:e.length,givenLength:t.length});const n=[];for(let r=0;r<e.length;r++){const o=e[r],s=t[r];n.push(Uu.encode(o,s))}return ri(...n)}function Du(e){return Array.isArray(e)&&"string"==typeof e[0]||"string"==typeof e?Me(e):e}!function(e){e.encode=function e(t,n,r=!1){if("address"===t){const e=n;return yu(e),ci(e.toLowerCase(),r?32:0)}if("string"===t)return ii(n);if("bytes"===t)return n;if("bool"===t)return ci(oi(n),r?32:1);const o=t.match(Iu);if(o){const[e,t,s="256"]=o,a=Number.parseInt(s,10)/8;return ai(n,{size:r?32:a,signed:"int"===t})}const s=t.match(Au);if(s){const[e,t]=s;if(Number.parseInt(t,10)!==(n.length-2)/2)throw new Wu({expectedSize:Number.parseInt(t,10),value:n});return ui(n,r?32:0)}const a=t.match(ku);if(a&&Array.isArray(n)){const[t,r]=a,o=[];for(let t=0;t<n.length;t++)o.push(e(r,n[t],!0));return 0===o.length?"0x":ri(...o)}throw new Zu(t)}}(Uu||(Uu={}));class Gu extends Ia{constructor({data:e,parameters:t,size:n}){super(`Data size of ${n} bytes is too small for given parameters.`,{metaMessages:[`Params: (${Z(t)})`,`Data: ${e} (${n} bytes)`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.DataSizeTooSmallError"})}}class qu extends Ia{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.'),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ZeroDataError"})}}class Vu extends Ia{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 Wu extends Ia{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${di(t)}) does not match expected size (bytes${e}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.BytesSizeMismatchError"})}}class Hu extends Ia{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 Yu extends Ia{constructor(e){super(`Value \`${e}\` is not a valid array.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidArrayError"})}}class Zu extends Ia{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 Ku extends sn{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");Zt(e.outputLen),Zt(e.blockLen)}(e);const n=on(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,o=new Uint8Array(r);o.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<o.length;e++)o[e]^=54;this.iHash.update(o),this.oHash=e.create();for(let e=0;e<o.length;e++)o[e]^=106;this.oHash.update(o),Xt(o)}update(e){return Jt(this),this.iHash.update(e),this}digestInto(e){Jt(this),Kt(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:o,blockLen:s,outputLen:a}=this;return e.finished=r,e.destroyed=o,e.blockLen=s,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 Ju=(e,t,n)=>new Ku(e,t).update(n).digest();Ju.create=(e,t)=>new Ku(e,t);
|
|
3
|
+
var n;if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Qt(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 Xt(e,t){Jt(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function en(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function tn(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function nn(e,t){return e<<32-t|e>>>t}function rn(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const on=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])()?e=>e:function(e){for(let t=0;t<e.length;t++)e[t]=rn(e[t]);return e};function sn(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)),Jt(e),e}class an{}function cn(e){const t=t=>e().update(sn(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function un(e=32){if(Zt&&"function"==typeof Zt.getRandomValues)return Zt.getRandomValues(new Uint8Array(e));if(Zt&&"function"==typeof Zt.randomBytes)return Uint8Array.from(Zt.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}const ln=BigInt(0),dn=BigInt(1),fn=BigInt(2),hn=BigInt(7),pn=BigInt(256),mn=BigInt(113),gn=[],bn=[],yn=[];for(let e=0,t=dn,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],gn.push(2*(5*r+n)),bn.push((e+1)*(e+2)/2%64);let o=ln;for(let e=0;e<7;e++)t=(t<<dn^(t>>hn)*mn)%pn,t&fn&&(o^=dn<<(dn<<BigInt(e))-dn);yn.push(o)}const wn=function(e,t=!1){const n=e.length;let r=new Uint32Array(n),o=new Uint32Array(n);for(let s=0;s<n;s++){const{h:n,l:a}=Yt(e[s],t);[r[s],o[s]]=[n,a]}return[r,o]}(yn,!0),vn=wn[0],xn=wn[1],En=(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),Pn=(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 kn extends an{constructor(e,t,n,r=!1,o=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=o,Kt(n),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");var s;this.state=new Uint8Array(200),this.state32=(s=this.state,new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4)))}clone(){return this._cloneInto()}keccak(){on(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,o=(t+2)%10,s=n[o],a=n[o+1],i=En(s,a,1)^n[r],c=Pn(s,a,1)^n[r+1];for(let n=0;n<50;n+=10)e[t+n]^=i,e[t+n+1]^=c}let t=e[2],o=e[3];for(let n=0;n<24;n++){const r=bn[n],s=En(t,o,r),a=Pn(t,o,r),i=gn[n];t=e[i],o=e[i+1],e[i]=s,e[i+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]^=vn[r],e[1]^=xn[r]}en(n)}(this.state32,this.rounds),on(this.state32),this.posOut=0,this.pos=0}update(e){Qt(this),Jt(e=sn(e));const{blockLen:t,state:n}=this,r=e.length;for(let o=0;o<r;){const s=Math.min(t-this.pos,r-o);for(let t=0;t<s;t++)n[this.pos++]^=e[o++];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,128&t&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){Qt(this,!1),Jt(e),this.finish();const t=this.state,{blockLen:n}=this;for(let r=0,o=e.length;r<o;){this.posOut>=n&&this.keccak();const s=Math.min(n-this.posOut,o-r);e.set(t.subarray(this.posOut,this.posOut+s),r),this.posOut+=s,r+=s}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Kt(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Xt(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,en(this.state)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:r,rounds:o,enableXOF:s}=this;return e||(e=new kn(t,n,r,s,o)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=o,e.suffix=n,e.outputLen=r,e.enableXOF=s,e.destroyed=this.destroyed,e}}const An=(()=>{return e=1,t=136,n=32,cn(()=>new kn(t,e,n));var e,t,n})();function In(e,t){const n=t||"hex",r=An(De(e,{strict:!1})?Ut(e):e);return"bytes"===n?r:Rt(r)}function Nn(e){return In(Ut(e))}const Sn=e=>function(e){let t=!0,n="",r=0,o="",s=!1;for(let a=0;a<e.length;a++){const i=e[a];if(["(",")",","].includes(i)&&(t=!0),"("===i&&r++,")"===i&&r--,t)if(0!==r)" "!==i?(o+=i,n+=i):","!==e[a-1]&&","!==n&&",("!==n&&(n="",t=!1);else if(" "===i&&["event","function",""].includes(o))o="";else if(o+=i,")"===i){s=!0;break}}if(!s)throw new He("Unable to normalize signature.");return o}("string"==typeof e?e:J(e));function Tn(e){return Nn(Sn(e))}const $n=Tn;let Bn=class extends He{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"})}},Cn=class 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 On=new Cn(8192);function Rn(e,t){if(On.has(`${e}.${t}`))return On.get(`${e}.${t}`);const n=e.substring(2).toLowerCase(),r=In(Vt(n),"bytes"),o=n.split("");for(let e=0;e<40;e+=2)r[e>>1]>>4>=8&&o[e]&&(o[e]=o[e].toUpperCase()),(15&r[e>>1])>=8&&o[e+1]&&(o[e+1]=o[e+1].toUpperCase());const s=`0x${o.join("")}`;return On.set(`${e}.${t}`,s),s}function zn(e,t){if(!Fn(e,{strict:!1}))throw new Bn({address:e});return Rn(e,t)}const _n=/^0x[a-fA-F0-9]{40}$/,Mn=new Cn(8192);function Fn(e,t){const{strict:n=!0}=t??{},r=`${e}.${n}`;if(Mn.has(r))return Mn.get(r);const o=!(!_n.test(e)||e.toLowerCase()!==e&&n&&Rn(e)!==e);return Mn.set(r,o),o}function jn(e){return"string"==typeof e[0]?Ln(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 Ln(e){return`0x${e.reduce((e,t)=>e+t.replace("0x",""),"")}`}function Un(e,t,n,{strict:r}={}){return De(e,{strict:!1})?function(e,t,n,{strict:r}={}){Dn(e,t);const o=`0x${e.replace("0x","").slice(2*(t??0),2*(n??e.length))}`;r&&Gn(o,t,n);return o}(e,t,n,{strict:r}):qn(e,t,n,{strict:r})}function Dn(e,t){if("number"==typeof t&&t>0&&t>Ge(e)-1)throw new vt({offset:t,position:"start",size:Ge(e)})}function Gn(e,t,n){if("number"==typeof t&&"number"==typeof n&&Ge(e)!==n-t)throw new vt({offset:n,position:"end",size:Ge(e)})}function qn(e,t,n,{strict:r}={}){Dn(e,t);const o=e.slice(t,n);return r&&Gn(o,t,n),o}const Vn=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Wn=/^(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 Hn(e,t){if(e.length!==t.length)throw new tt({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(Yn({param:e[r],value:t[r]}));return n}({params:e,values:t}),r=Zn(n);return 0===r.length?"0x":r}function Yn({param:e,value:t}){const n=Kn(e.type);if(n){const[r,o]=n;return function(e,{length:t,param:n}){const r=null===t;if(!Array.isArray(e))throw new bt(e);if(!r&&e.length!==t)throw new Xe({expectedLength:t,givenLength:e.length,type:`${n.type}[${t}]`});let o=!1;const s=[];for(let t=0;t<e.length;t++){const r=Yn({param:n,value:e[t]});r.dynamic&&(o=!0),s.push(r)}if(r||o){const e=Zn(s);if(r){const t=Mt(s.length,{size:32});return{dynamic:!0,encoded:s.length>0?jn([t,e]):t}}if(o)return{dynamic:!0,encoded:e}}return{dynamic:!1,encoded:jn(s.map(({encoded:e})=>e))}}(t,{length:r,param:{...e,type:o}})}if("tuple"===e.type)return function(e,{param:t}){let n=!1;const r=[];for(let o=0;o<t.components.length;o++){const s=t.components[o],a=Yn({param:s,value:e[Array.isArray(e)?o:s.name]});r.push(a),a.dynamic&&(n=!0)}return{dynamic:n,encoded:n?Zn(r):jn(r.map(({encoded:e})=>e))}}(t,{param:e});if("address"===e.type)return function(e){if(!Fn(e))throw new Bn({address:e});return{dynamic:!1,encoded:kt(e.toLowerCase())}}(t);if("bool"===e.type)return function(e){if("boolean"!=typeof e)throw new He(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:kt(zt(e))}}(t);if(e.type.startsWith("uint")||e.type.startsWith("int")){const n=e.type.startsWith("int"),[,,r="256"]=Wn.exec(e.type)??[];return function(e,{signed:t,size:n=256}){if("number"==typeof n){const r=2n**(BigInt(n)-(t?1n:0n))-1n,o=t?-r-1n:0n;if(e>r||e<o)throw new At({max:r.toString(),min:o.toString(),signed:t,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:Mt(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=Ge(e);if(!n){let t=e;return r%32!=0&&(t=kt(t,{dir:"right",size:32*Math.ceil((e.length-2)/2/32)})),{dynamic:!0,encoded:jn([kt(Mt(r,{size:32})),t])}}if(r!==Number.parseInt(n,10))throw new et({expectedSize:Number.parseInt(n,10),value:e});return{dynamic:!1,encoded:kt(e,{dir:"right"})}}(t,{param:e});if("string"===e.type)return function(e){const t=jt(e),n=Math.ceil(Ge(t)/32),r=[];for(let e=0;e<n;e++)r.push(kt(Un(t,32*e,32*(e+1)),{dir:"right"}));return{dynamic:!0,encoded:jn([kt(Mt(Ge(t),{size:32})),...r])}}(t);throw new mt(e.type,{docsPath:"/docs/contract/encodeAbiParameters"})}function Zn(e){let t=0;for(let n=0;n<e.length;n++){const{dynamic:r,encoded:o}=e[n];t+=r?32:Ge(o)}const n=[],r=[];let o=0;for(let s=0;s<e.length;s++){const{dynamic:a,encoded:i}=e[s];a?(n.push(Mt(t+o,{size:32})),r.push(i),o+=Ge(i)):n.push(i)}return jn([...n,...r])}function Kn(e){const t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}const Jn=e=>Un(Tn(e),0,4);function Qn(e){const{abi:t,args:n=[],name:r}=e,o=De(r,{strict:!1}),s=t.filter(e=>o?"function"===e.type?Jn(e)===r:"event"===e.type&&$n(e)===r:"name"in e&&e.name===r);if(0===s.length)return;if(1===s.length)return s[0];let a;for(const e of s){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&&Xn(t,r)});if(t){if(a&&"inputs"in a&&a.inputs){const t=er(e.inputs,a.inputs,n);if(t)throw new dt({abiItem:e,type:t[0]},{abiItem:a,type:t[1]})}a=e}}return a||s[0]}function Xn(e,t){const n=typeof e,r=t.type;switch(r){case"address":return Fn(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)=>Xn(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=>Xn(e,{...t,type:r.replace(/(\[[0-9]{0,}\])$/,"")})))}}function er(e,t,n){for(const r in e){const o=e[r],s=t[r];if("tuple"===o.type&&"tuple"===s.type&&"components"in o&&"components"in s)return er(o.components,s.components,n[r]);const a=[o.type,s.type];if((()=>!(!a.includes("address")||!a.includes("bytes20"))||(a.includes("address")&&a.includes("string")||!(!a.includes("address")||!a.includes("bytes")))&&Fn(n[r],{strict:!1}))())return a}}const tr="/docs/contract/encodeEventTopics";function nr(e){const{abi:t,eventName:n,args:r}=e;let o=t[0];if(n){const e=Qn({abi:t,name:n});if(!e)throw new it(n,{docsPath:tr});o=e}if("event"!==o.type)throw new it(void 0,{docsPath:tr});const s=Le(o),a=$n(s);let i=[];if(r&&"inputs"in o){const e=o.inputs?.filter(e=>"indexed"in e&&e.indexed),t=Array.isArray(r)?r:Object.values(r).length>0?e?.map(e=>r[e.name])??[]:[];t.length>0&&(i=e?.map((e,n)=>Array.isArray(t[n])?t[n].map((r,o)=>rr({param:e,value:t[n][o]})):void 0!==t[n]&&null!==t[n]?rr({param:e,value:t[n]}):null)??[])}return[a,...i]}function rr({param:e,value:t}){if("string"===e.type||"bytes"===e.type)return In(Ut(t));if("tuple"===e.type||e.type.match(/^(.*)\[(\d+)?\]$/))throw new wt(e.type);return Hn([e],[t])}function or(e,{method:t}){const n={};return"fallback"===e.transport.type&&e.transport.onResponse?.(({method:e,response:r,status:o,transport:s})=>{"success"===o&&t===e&&(n[r]=s.request)}),t=>n[t]||e.request}async function sr(e,t){const{address:n,abi:r,args:o,eventName:s,fromBlock:a,strict:i,toBlock:c}=t,u=or(e,{method:"eth_newFilter"}),l=s?nr({abi:r,args:o,eventName:s}):void 0,d=await e.request({method:"eth_newFilter",params:[{address:n,fromBlock:"bigint"==typeof a?Mt(a):a,toBlock:"bigint"==typeof c?Mt(c):c,topics:l}]});return{abi:r,args:o,eventName:s,id:d,request:u(d),strict:Boolean(i),type:"event"}}function ar(e){return"string"==typeof e?{address:e,type:"json-rpc"}:e}const ir="/docs/contract/encodeFunctionData";function cr(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 o=t[0];if(r){const e=Qn({abi:t,args:n,name:r});if(!e)throw new ct(r,{docsPath:ir});o=e}if("function"!==o.type)throw new ct(void 0,{docsPath:ir});return{abi:[o],functionName:Jn(Le(o))}}(e),o=n[0];return Ln([r,("inputs"in o&&o.inputs?Hn(o.inputs,t??[]):void 0)??"0x"])}const ur={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."},lr={inputs:[{name:"message",type:"string"}],name:"Error",type:"error"},dr={inputs:[{name:"reason",type:"uint256"}],name:"Panic",type:"error"};let fr=class extends He{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`,{name:"NegativeOffsetError"})}},hr=class extends He{constructor({length:e,position:t}){super(`Position \`${t}\` is out of bounds (\`0 < position < ${e}\`).`,{name:"PositionOutOfBoundsError"})}},pr=class extends He{constructor({count:e,limit:t}){super(`Recursive read limit of \`${t}\` exceeded (recursive read count: \`${e}\`).`,{name:"RecursiveReadLimitExceededError"})}};const mr={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 pr({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new hr({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new fr({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 fr({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 gr(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(mr);return n.bytes=e,n.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=t,n}function br(e,t={}){void 0!==t.size&&$t(e,{size:t.size});return Bt(_t(e,t),t)}function yr(e,t={}){let n=e;if(void 0!==t.size&&($t(n,{size:t.size}),n=Tt(n)),n.length>1||n[0]>1)throw new It(n);return Boolean(n[0])}function wr(e,t={}){void 0!==t.size&&$t(e,{size:t.size});return Ct(_t(e,t),t)}function vr(e,t){const n="string"==typeof t?qt(t):t,r=gr(n);if(0===Ge(n)&&e.length>0)throw new Qe;if(Ge(t)&&Ge(t)<32)throw new Je({data:"string"==typeof t?t:_t(t),params:e,size:Ge(t)});let o=0;const s=[];for(let t=0;t<e.length;++t){const n=e[t];r.setPosition(o);const[a,i]=xr(r,n,{staticPosition:0});o+=i,s.push(a)}return s}function xr(e,t,{staticPosition:n}){const r=Kn(t.type);if(r){const[o,s]=r;return function(e,t,{length:n,staticPosition:r}){if(!n){const n=r+wr(e.readBytes(Pr)),o=n+Er;e.setPosition(n);const s=wr(e.readBytes(Er)),a=kr(t);let i=0;const c=[];for(let n=0;n<s;++n){e.setPosition(o+(a?32*n:i));const[r,s]=xr(e,t,{staticPosition:o});i+=s,c.push(r)}return e.setPosition(r+32),[c,32]}if(kr(t)){const o=r+wr(e.readBytes(Pr)),s=[];for(let r=0;r<n;++r){e.setPosition(o+32*r);const[n]=xr(e,t,{staticPosition:o});s.push(n)}return e.setPosition(r+32),[s,32]}let o=0;const s=[];for(let a=0;a<n;++a){const[n,a]=xr(e,t,{staticPosition:r+o});o+=a,s.push(n)}return[s,o]}(e,{...t,type:s},{length:o,staticPosition:n})}if("tuple"===t.type)return function(e,t,{staticPosition:n}){const r=0===t.components.length||t.components.some(({name:e})=>!e),o=r?[]:{};let s=0;if(kr(t)){const a=n+wr(e.readBytes(Pr));for(let n=0;n<t.components.length;++n){const i=t.components[n];e.setPosition(a+s);const[c,u]=xr(e,i,{staticPosition:a});s+=u,o[r?n:i?.name]=c}return e.setPosition(n+32),[o,32]}for(let a=0;a<t.components.length;++a){const i=t.components[a],[c,u]=xr(e,i,{staticPosition:n});o[r?a:i?.name]=c,s+=u}return[o,s]}(e,t,{staticPosition:n});if("address"===t.type)return function(e){const t=e.readBytes(32);return[Rn(_t(qn(t,-20))),32]}(e);if("bool"===t.type)return function(e){return[yr(e.readBytes(32),{size:32}),32]}(e);if(t.type.startsWith("bytes"))return function(e,t,{staticPosition:n}){const[r,o]=t.type.split("bytes");if(!o){const t=wr(e.readBytes(32));e.setPosition(n+t);const r=wr(e.readBytes(32));if(0===r)return e.setPosition(n+32),["0x",32];const o=e.readBytes(r);return e.setPosition(n+32),[_t(o),32]}const s=_t(e.readBytes(Number.parseInt(o,10),32));return[s,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),o=e.readBytes(32);return[r>48?br(o,{signed:n}):wr(o,{signed:n}),32]}(e,t);if("string"===t.type)return function(e,{staticPosition:t}){const n=wr(e.readBytes(32)),r=t+n;e.setPosition(r);const o=wr(e.readBytes(32));if(0===o)return e.setPosition(t+32),["",32];const s=e.readBytes(o,32),a=function(e,t={}){let n=e;return void 0!==t.size&&($t(n,{size:t.size}),n=Tt(n,{dir:"right"})),(new TextDecoder).decode(n)}(Tt(s));return e.setPosition(t+32),[a,32]}(e,{staticPosition:n});throw new gt(t.type,{docsPath:"/docs/contract/decodeAbiParameters"})}const Er=32,Pr=32;function kr(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(kr);const n=Kn(e.type);return!(!n||!kr({...e,type:n[1]}))}function Ar(e){const{abi:t,data:n}=e,r=Un(n,0,4);if("0x"===r)throw new Qe;const o=[...t||[],lr,dr].find(e=>"error"===e.type&&r===Jn(Le(e)));if(!o)throw new ot(r,{docsPath:"/docs/contract/decodeErrorResult"});return{abiItem:o,args:"inputs"in o&&o.inputs&&o.inputs.length>0?vr(o.inputs,Un(n,4)):void 0,errorName:o.name}}const Ir=(e,t,n)=>JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString():t,n);function Nr({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]?Ir(t[n]):t[n]}`).join(", ")})`}const Sr={gwei:9,wei:18},Tr={ether:-9,wei:9};function $r(e,t){let n=e.toString();const r=n.startsWith("-");r&&(n=n.slice(1)),n=n.padStart(t,"0");let[o,s]=[n.slice(0,n.length-t),n.slice(n.length-t)];return s=s.replace(/(0+)$/,""),`${r?"-":""}${o||"0"}${s?`.${s}`:""}`}function Br(e,t="wei"){return $r(e,Sr[t])}function Cr(e,t="wei"){return $r(e,Tr[t])}class Or extends He{constructor({address:e}){super(`State for account "${e}" is set multiple times.`,{name:"AccountStateConflictError"})}}class Rr extends He{constructor(){super("state and stateDiff are set on the same account.",{name:"StateAssignmentConflictError"})}}function zr(e){return e.reduce((e,{slot:t,value:n})=>`${e} ${t}: ${n}\n`,"")}function _r(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 Mr extends He{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 Fr extends He{constructor({transaction:e}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",_r(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 jr extends He{constructor({blockHash:e,blockNumber:t,blockTag:n,hash:r,index:o}){let s="Transaction";n&&void 0!==o&&(s=`Transaction at block time "${n}" at index "${o}"`),e&&void 0!==o&&(s=`Transaction at block hash "${e}" at index "${o}"`),t&&void 0!==o&&(s=`Transaction at block number "${t}" at index "${o}"`),r&&(s=`Transaction with hash "${r}"`),super(`${s} could not be found.`,{name:"TransactionNotFoundError"})}}class Lr extends He{constructor({hash:e}){super(`Transaction receipt with hash "${e}" could not be found. The Transaction may not be processed on a block yet.`,{name:"TransactionReceiptNotFoundError"})}}class Ur extends He{constructor({hash:e}){super(`Timed out while waiting for transaction with hash "${e}" to be confirmed.`,{name:"WaitForTransactionReceiptTimeoutError"})}}class Dr extends He{constructor(e,{account:t,docsPath:n,chain:r,data:o,gas:s,gasPrice:a,maxFeePerGas:i,maxPriorityFeePerGas:c,nonce:u,to:l,value:d,stateOverride:f}){const h=t?ar(t):void 0;let p=_r({from:h?.address,to:l,value:void 0!==d&&`${Br(d)} ${r?.nativeCurrency?.symbol||"ETH"}`,data:o,gas:s,gasPrice:void 0!==a&&`${Cr(a)} gwei`,maxFeePerGas:void 0!==i&&`${Cr(i)} gwei`,maxPriorityFeePerGas:void 0!==c&&`${Cr(c)} gwei`,nonce:u});f&&(p+=`\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+=zr(n.state)),n.stateDiff&&(r+=" stateDiff:\n",r+=zr(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:",p].filter(Boolean),name:"CallExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=e}}class Gr extends He{constructor(e,{abi:t,args:n,contractAddress:r,docsPath:o,functionName:s,sender:a}){const i=Qn({abi:t,args:n,name:s}),c=i?Nr({abiItem:i,args:n,includeFunctionName:!1,includeName:!1}):void 0,u=_r({address:r&&r,function:i?Le(i,{includeName:!0}):void 0,args:c&&"()"!==c&&`${[...Array(s?.length??0).keys()].map(()=>" ").join("")}${c}`,sender:a});super(e.shortMessage||`An unknown error occurred while executing the contract function "${s}".`,{cause:e,docsPath:o,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=s,this.sender=a}}class qr extends He{constructor({abi:e,data:t,functionName:n,message:r}){let o,s,a,i,c;if(t&&"0x"!==t)try{s=Ar({abi:e,data:t});const{abiItem:n,errorName:r,args:o}=s;if("Error"===r)i=o[0];else if("Panic"===r){const[e]=o;i=ur[e]}else{const e=n?Le(n,{includeName:!0}):void 0,t=n&&o?Nr({abiItem:n,args:o,includeFunctionName:!1,includeName:!1}):void 0;a=[e?`Error: ${e}`:"",t&&"()"!==t?` ${[...Array(r?.length??0).keys()].map(()=>" ").join("")}${t}`:""]}}catch(e){o=e}else r&&(i=r);o instanceof ot&&(c=o.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(i&&"execution reverted"!==i||c?[`The contract function "${n}" reverted with the following ${c?"signature":"reason"}:`,i||c].join("\n"):`The contract function "${n}" reverted.`,{cause:o,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=s,this.raw=t,this.reason=i,this.signature=c}}class Vr extends He{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 Wr extends He{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 Hr extends He{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 Yr extends He{constructor({body:e,cause:t,details:n,headers:r,status:o,url:s}){super("HTTP request failed.",{cause:t,details:n,metaMessages:[o&&`Status: ${o}`,`URL: ${s}`,e&&`Request body: ${Ir(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=o,this.url=s}}class Zr extends He{constructor({body:e,error:t,url:n}){super("RPC Request failed.",{cause:t,details:t.message,metaMessages:[`URL: ${n}`,`Request body: ${Ir(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 Kr extends He{constructor({body:e,url:t}){super("The request took too long to respond.",{details:"The request timed out.",metaMessages:[`URL: ${t}`,`Request body: ${Ir(e)}`],name:"TimeoutError"})}}class Jr extends He{constructor(e,{code:t,docsPath:n,metaMessages:r,name:o,shortMessage:s}){super(s,{cause:e,docsPath:n,metaMessages:r||e?.metaMessages,name:o||"RpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=o||e.name,this.code=e instanceof Zr?e.code:t??-1}}class Qr extends Jr{constructor(e,t){super(e,t),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=t.data}}class Xr extends Jr{constructor(e){super(e,{code:Xr.code,name:"ParseRpcError",shortMessage:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."})}}Object.defineProperty(Xr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class eo extends Jr{constructor(e){super(e,{code:eo.code,name:"InvalidRequestRpcError",shortMessage:"JSON is not a valid request object."})}}Object.defineProperty(eo,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class to extends Jr{constructor(e,{method:t}={}){super(e,{code:to.code,name:"MethodNotFoundRpcError",shortMessage:`The method${t?` "${t}"`:""} does not exist / is not available.`})}}Object.defineProperty(to,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class no extends Jr{constructor(e){super(e,{code:no.code,name:"InvalidParamsRpcError",shortMessage:["Invalid parameters were provided to the RPC method.","Double check you have provided the correct parameters."].join("\n")})}}Object.defineProperty(no,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class ro extends Jr{constructor(e){super(e,{code:ro.code,name:"InternalRpcError",shortMessage:"An internal error was received."})}}Object.defineProperty(ro,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class oo extends Jr{constructor(e){super(e,{code:oo.code,name:"InvalidInputRpcError",shortMessage:["Missing or invalid parameters.","Double check you have provided the correct parameters."].join("\n")})}}Object.defineProperty(oo,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class so extends Jr{constructor(e){super(e,{code:so.code,name:"ResourceNotFoundRpcError",shortMessage:"Requested resource not found."}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ResourceNotFoundRpcError"})}}Object.defineProperty(so,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class ao extends Jr{constructor(e){super(e,{code:ao.code,name:"ResourceUnavailableRpcError",shortMessage:"Requested resource not available."})}}Object.defineProperty(ao,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class io extends Jr{constructor(e){super(e,{code:io.code,name:"TransactionRejectedRpcError",shortMessage:"Transaction creation failed."})}}Object.defineProperty(io,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class co extends Jr{constructor(e,{method:t}={}){super(e,{code:co.code,name:"MethodNotSupportedRpcError",shortMessage:`Method${t?` "${t}"`:""} is not supported.`})}}Object.defineProperty(co,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class uo extends Jr{constructor(e){super(e,{code:uo.code,name:"LimitExceededRpcError",shortMessage:"Request exceeds defined limit."})}}Object.defineProperty(uo,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class lo extends Jr{constructor(e){super(e,{code:lo.code,name:"JsonRpcVersionUnsupportedError",shortMessage:"Version of JSON-RPC protocol is not supported."})}}Object.defineProperty(lo,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});class fo extends Qr{constructor(e){super(e,{code:fo.code,name:"UserRejectedRequestError",shortMessage:"User rejected the request."})}}Object.defineProperty(fo,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class ho extends Qr{constructor(e){super(e,{code:ho.code,name:"UnauthorizedProviderError",shortMessage:"The requested method and/or account has not been authorized by the user."})}}Object.defineProperty(ho,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class po extends Qr{constructor(e,{method:t}={}){super(e,{code:po.code,name:"UnsupportedProviderMethodError",shortMessage:`The Provider does not support the requested method${t?` " ${t}"`:""}.`})}}Object.defineProperty(po,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class mo extends Qr{constructor(e){super(e,{code:mo.code,name:"ProviderDisconnectedError",shortMessage:"The Provider is disconnected from all chains."})}}Object.defineProperty(mo,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});class go extends Qr{constructor(e){super(e,{code:go.code,name:"ChainDisconnectedError",shortMessage:"The Provider is not connected to the requested chain."})}}Object.defineProperty(go,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});class bo extends Qr{constructor(e){super(e,{code:bo.code,name:"SwitchChainError",shortMessage:"An error occurred when attempting to switch chain."})}}Object.defineProperty(bo,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902});class yo extends Qr{constructor(e){super(e,{code:yo.code,name:"UnsupportedNonOptionalCapabilityError",shortMessage:"This Wallet does not support a capability that was not marked as optional."})}}Object.defineProperty(yo,"code",{enumerable:!0,configurable:!0,writable:!0,value:5700});class wo extends Qr{constructor(e){super(e,{code:wo.code,name:"UnsupportedChainIdError",shortMessage:"This Wallet does not support the requested chain ID."})}}Object.defineProperty(wo,"code",{enumerable:!0,configurable:!0,writable:!0,value:5710});class vo extends Qr{constructor(e){super(e,{code:vo.code,name:"DuplicateIdError",shortMessage:"There is already a bundle submitted with this ID."})}}Object.defineProperty(vo,"code",{enumerable:!0,configurable:!0,writable:!0,value:5720});class xo extends Qr{constructor(e){super(e,{code:xo.code,name:"UnknownBundleIdError",shortMessage:"This bundle id is unknown / has not been submitted"})}}Object.defineProperty(xo,"code",{enumerable:!0,configurable:!0,writable:!0,value:5730});class Eo extends Qr{constructor(e){super(e,{code:Eo.code,name:"BundleTooLargeError",shortMessage:"The call bundle is too large for the Wallet to process."})}}Object.defineProperty(Eo,"code",{enumerable:!0,configurable:!0,writable:!0,value:5740});class Po extends Qr{constructor(e){super(e,{code:Po.code,name:"AtomicReadyWalletRejectedUpgradeError",shortMessage:"The Wallet can support atomicity after an upgrade, but the user rejected the upgrade."})}}Object.defineProperty(Po,"code",{enumerable:!0,configurable:!0,writable:!0,value:5750});class ko extends Qr{constructor(e){super(e,{code:ko.code,name:"AtomicityNotSupportedError",shortMessage:"The wallet does not support atomic execution but the request requires it."})}}Object.defineProperty(ko,"code",{enumerable:!0,configurable:!0,writable:!0,value:5760});class Ao extends Jr{constructor(e){super(e,{name:"UnknownRpcError",shortMessage:"An unknown RPC error occurred."})}}const Io=3;function No(e,{abi:t,address:n,args:r,docsPath:o,functionName:s,sender:a}){const i=e instanceof Hr?e:e instanceof He?e.walk(e=>"data"in e)||e.walk():{},{code:c,data:u,details:l,message:d,shortMessage:f}=i,h=e instanceof Qe?new Vr({functionName:s}):[Io,ro.code].includes(c)&&(u||l||d||f)?new qr({abi:t,data:"object"==typeof u?u.data:u,functionName:s,message:i instanceof Zr?l:f??d}):e;return new Gr(h,{abi:t,args:r,contractAddress:n,docsPath:o,functionName:s,sender:a})}function So(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 To({hash:e,signature:t}){return n=await async function({hash:e,signature:t}){const n=De(e)?e:Rt(e),{secp256k1:r}=await Promise.resolve().then(function(){return Zl}),o=(()=>{if("object"==typeof t&&"r"in t&&"s"in t){const{r:e,s:n,v:o,yParity:s}=t,a=So(Number(s??o));return new r.Signature(Bt(e),Bt(n)).addRecoveryBit(a)}const e=De(t)?t:Rt(t);if(65!==Ge(e))throw new Error("invalid signature length");const n=So(Ct(`0x${e.slice(130)}`));return r.Signature.fromCompact(e.substring(2,130)).addRecoveryBit(n)})();return`0x${o.recoverPublicKey(n.substring(2)).toHex(!1)}`}({hash:e,signature:t}),Rn(`0x${In(`0x${n.substring(4)}`).substring(26)}`);var n}function $o(e,t="hex"){const n=Bo(e),r=gr(new Uint8Array(n.length));return n.encode(r),"hex"===t?_t(r.bytes):r.bytes}function Bo(e){return Array.isArray(e)?function(e){const t=e.reduce((e,t)=>e+t.length,0),n=Co(t),r=t<=55?1+t:1+n+t;return{length:r,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=>Bo(e))):function(e){const t="string"==typeof e?qt(e):e,n=Co(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 Co(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 He("Length is too large.")}function Oo(e){const{chainId:t,nonce:n,to:r}=e,o=e.contractAddress??e.address,s=In(Ln(["0x05",$o([t?Mt(t):"0x",o,n?Mt(n):"0x"])]));return"bytes"===r?qt(s):s}async function Ro(e){const{authorization:t,signature:n}=e;return To({hash:Oo(t),signature:n??t})}class zo extends He{constructor(e,{account:t,docsPath:n,chain:r,data:o,gas:s,gasPrice:a,maxFeePerGas:i,maxPriorityFeePerGas:c,nonce:u,to:l,value:d}){const f=_r({from:t?.address,to:l,value:void 0!==d&&`${Br(d)} ${r?.nativeCurrency?.symbol||"ETH"}`,data:o,gas:s,gasPrice:void 0!==a&&`${Cr(a)} gwei`,maxFeePerGas:void 0!==i&&`${Cr(i)} gwei`,maxPriorityFeePerGas:void 0!==c&&`${Cr(c)} gwei`,nonce:u});super(e.shortMessage,{cause:e,docsPath:n,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],"Estimate Gas Arguments:",f].filter(Boolean),name:"EstimateGasExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=e}}class _o extends He{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(_o,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(_o,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});class Mo extends He{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${Cr(t)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:e,name:"FeeCapTooHighError"})}}Object.defineProperty(Mo,"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 Fo extends He{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${Cr(t)}`:""} gwei) cannot be lower than the block base fee.`,{cause:e,name:"FeeCapTooLowError"})}}Object.defineProperty(Fo,"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 jo extends He{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(jo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class Lo extends He{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(Lo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});class Uo extends He{constructor({cause:e,nonce:t}={}){super(`Nonce provided for the transaction ${t?`(${t}) `:""}exceeds the maximum allowed nonce.`,{cause:e,name:"NonceMaxValueError"})}}Object.defineProperty(Uo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});class Do extends He{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(Do,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class Go extends He{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(Go,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class qo extends He{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(qo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class Vo extends He{constructor({cause:e}){super("The transaction type is not supported for this chain.",{cause:e,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(Vo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class Wo extends He{constructor({cause:e,maxPriorityFeePerGas:t,maxFeePerGas:n}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${t?` = ${Cr(t)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n?` = ${Cr(n)} gwei`:""}).`].join("\n"),{cause:e,name:"TipAboveFeeCapError"})}}Object.defineProperty(Wo,"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 Ho extends He{constructor({cause:e}){super(`An error occurred while executing: ${e?.shortMessage}`,{cause:e,name:"UnknownNodeError"})}}function Yo(e,t){const n=(e.details||"").toLowerCase(),r=e instanceof He?e.walk(e=>e?.code===_o.code):e;return r instanceof He?new _o({cause:e,message:r.details}):_o.nodeMessage.test(n)?new _o({cause:e,message:e.details}):Mo.nodeMessage.test(n)?new Mo({cause:e,maxFeePerGas:t?.maxFeePerGas}):Fo.nodeMessage.test(n)?new Fo({cause:e,maxFeePerGas:t?.maxFeePerGas}):jo.nodeMessage.test(n)?new jo({cause:e,nonce:t?.nonce}):Lo.nodeMessage.test(n)?new Lo({cause:e,nonce:t?.nonce}):Uo.nodeMessage.test(n)?new Uo({cause:e,nonce:t?.nonce}):Do.nodeMessage.test(n)?new Do({cause:e}):Go.nodeMessage.test(n)?new Go({cause:e,gas:t?.gas}):qo.nodeMessage.test(n)?new qo({cause:e,gas:t?.gas}):Vo.nodeMessage.test(n)?new Vo({cause:e}):Wo.nodeMessage.test(n)?new Wo({cause:e,maxFeePerGas:t?.maxFeePerGas,maxPriorityFeePerGas:t?.maxPriorityFeePerGas}):new Ho({cause:e})}function Zo(e,{format:t}){if(!t)return{};const n={};return function t(r){const o=Object.keys(r);for(const s of o)s in e&&(n[s]=e[s]),r[s]&&"object"==typeof r[s]&&!Array.isArray(r[s])&&t(r[s])}(t(e||{})),n}const Ko={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function Jo(e){const t={};return void 0!==e.authorizationList&&(t.authorizationList=e.authorizationList.map(e=>({address:e.address,r:e.r?Mt(BigInt(e.r)):e.r,s:e.s?Mt(BigInt(e.s)):e.s,chainId:Mt(e.chainId),nonce:Mt(e.nonce),...void 0!==e.yParity?{yParity:Mt(e.yParity)}:{},...void 0!==e.v&&void 0===e.yParity?{v:Mt(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=>_t(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=Mt(e.gas)),void 0!==e.gasPrice&&(t.gasPrice=Mt(e.gasPrice)),void 0!==e.maxFeePerBlobGas&&(t.maxFeePerBlobGas=Mt(e.maxFeePerBlobGas)),void 0!==e.maxFeePerGas&&(t.maxFeePerGas=Mt(e.maxFeePerGas)),void 0!==e.maxPriorityFeePerGas&&(t.maxPriorityFeePerGas=Mt(e.maxPriorityFeePerGas)),void 0!==e.nonce&&(t.nonce=Mt(e.nonce)),void 0!==e.to&&(t.to=e.to),void 0!==e.type&&(t.type=Ko[e.type]),void 0!==e.value&&(t.value=Mt(e.value)),t}function Qo(e){if(e&&0!==e.length)return e.reduce((e,{slot:t,value:n})=>{if(66!==t.length)throw new Et({size:t.length,targetSize:66,type:"hex"});if(66!==n.length)throw new Et({size:n.length,targetSize:66,type:"hex"});return e[t]=n,e},{})}function Xo(e){const{balance:t,nonce:n,state:r,stateDiff:o,code:s}=e,a={};if(void 0!==s&&(a.code=s),void 0!==t&&(a.balance=Mt(t)),void 0!==n&&(a.nonce=Mt(n)),void 0!==r&&(a.state=Qo(r)),void 0!==o){if(a.state)throw new Rr;a.stateDiff=Qo(o)}return a}function es(e){if(!e)return;const t={};for(const{address:n,...r}of e){if(!Fn(n,{strict:!1}))throw new Bn({address:n});if(t[n])throw new Or({address:n});t[n]=Xo(r)}return t}const ts=2n**256n-1n;function ns(e){const{account:t,gasPrice:n,maxFeePerGas:r,maxPriorityFeePerGas:o,to:s}=e,a=t?ar(t):void 0;if(a&&!Fn(a.address))throw new Bn({address:a.address});if(s&&!Fn(s))throw new Bn({address:s});if(void 0!==n&&(void 0!==r||void 0!==o))throw new Mr;if(r&&r>ts)throw new Mo({maxFeePerGas:r});if(o&&r&&o>r)throw new Wo({maxFeePerGas:r,maxPriorityFeePerGas:o})}class rs extends He{constructor(){super("`baseFeeMultiplier` must be greater than 1.",{name:"BaseFeeScalarError"})}}class os extends He{constructor(){super("Chain does not support EIP-1559 fees.",{name:"Eip1559FeesNotSupportedError"})}}class ss extends He{constructor({maxPriorityFeePerGas:e}){super(`\`maxFeePerGas\` cannot be less than the \`maxPriorityFeePerGas\` (${Cr(e)} gwei).`,{name:"MaxFeePerGasTooLowError"})}}class as extends He{constructor({blockHash:e,blockNumber:t}){let n="Block";e&&(n=`Block at hash "${e}"`),t&&(n=`Block at number "${t}"`),super(`${n} could not be found.`,{name:"BlockNotFoundError"})}}const is={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function cs(e){const t={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?Ct(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?Ct(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?is[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}function us(e){const t=(e.transactions??[]).map(e=>"string"==typeof e?e:cs(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}}async function ls(e,{blockHash:t,blockNumber:n,blockTag:r=e.experimental_blockTag??"latest",includeTransactions:o}={}){const s=o??!1,a=void 0!==n?Mt(n):void 0;let i=null;if(i=t?await e.request({method:"eth_getBlockByHash",params:[t,s]},{dedupe:!0}):await e.request({method:"eth_getBlockByNumber",params:[a||r,s]},{dedupe:Boolean(a)}),!i)throw new as({blockHash:t,blockNumber:n});return(e.chain?.formatters?.block?.format||us)(i)}async function ds(e){const t=await e.request({method:"eth_gasPrice"});return BigInt(t)}async function fs(e,t){const{block:n,chain:r=e.chain,request:o}=t||{};try{const t=r?.fees?.maxPriorityFeePerGas??r?.fees?.defaultPriorityFee;if("function"==typeof t){const r=n||await je(e,ls,"getBlock")({}),s=await t({block:r,client:e,request:o});if(null===s)throw new Error;return s}if(void 0!==t)return t;return Bt(await e.request({method:"eth_maxPriorityFeePerGas"}))}catch{const[t,r]=await Promise.all([n?Promise.resolve(n):je(e,ls,"getBlock")({}),je(e,ds,"getGasPrice")({})]);if("bigint"!=typeof t.baseFeePerGas)throw new os;const o=r-t.baseFeePerGas;return o<0n?0n:o}}async function hs(e,t){const{block:n,chain:r=e.chain,request:o,type:s="eip1559"}=t||{},a=await(async()=>"function"==typeof r?.fees?.baseFeeMultiplier?r.fees.baseFeeMultiplier({block:n,client:e,request:o}):r?.fees?.baseFeeMultiplier??1.2)();if(a<1)throw new rs;const i=10**(a.toString().split(".")[1]?.length??0),c=e=>e*BigInt(Math.ceil(a*i))/BigInt(i),u=n||await je(e,ls,"getBlock")({});if("function"==typeof r?.fees?.estimateFeesPerGas){const t=await r.fees.estimateFeesPerGas({block:n,client:e,multiply:c,request:o,type:s});if(null!==t)return t}if("eip1559"===s){if("bigint"!=typeof u.baseFeePerGas)throw new os;const t="bigint"==typeof o?.maxPriorityFeePerGas?o.maxPriorityFeePerGas:await fs(e,{block:u,chain:r,request:o}),n=c(u.baseFeePerGas);return{maxFeePerGas:o?.maxFeePerGas??n+t,maxPriorityFeePerGas:t}}return{gasPrice:o?.gasPrice??c(await je(e,ds,"getGasPrice")({}))}}async function ps(e,{address:t,blockTag:n="latest",blockNumber:r}){return Ct(await e.request({method:"eth_getTransactionCount",params:[t,"bigint"==typeof r?Mt(r):n]},{dedupe:Boolean(r)}))}function ms(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=>qt(e)):e.blobs,o=[];for(const e of r)o.push(Uint8Array.from(t.blobToKzgCommitment(e)));return"bytes"===n?o:o.map(e=>_t(e))}function gs(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=>qt(e)):e.blobs,o="string"==typeof e.commitments[0]?e.commitments.map(e=>qt(e)):e.commitments,s=[];for(let e=0;e<r.length;e++){const n=r[e],a=o[e];s.push(Uint8Array.from(t.computeBlobKzgProof(n,a)))}return"bytes"===n?s:s.map(e=>_t(e))}function bs(e,t,n){return e&t^~e&n}function ys(e,t,n){return e&t^e&n^t&n}class ws extends an{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=tn(this.buffer)}update(e){Qt(this),Jt(e=sn(e));const{view:t,buffer:n,blockLen:r}=this,o=e.length;for(let s=0;s<o;){const a=Math.min(r-this.pos,o-s);if(a===r){const t=tn(e);for(;r<=o-s;s+=r)this.process(t,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Qt(this),Xt(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:o}=this;let{pos:s}=this;t[s++]=128,en(this.buffer.subarray(s)),this.padOffset>r-s&&(this.process(n,0),s=0);for(let e=s;e<r;e++)t[e]=0;!function(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const o=BigInt(32),s=BigInt(4294967295),a=Number(n>>o&s),i=Number(n&s),c=r?4:0,u=r?0:4;e.setUint32(t+c,a,r),e.setUint32(t+u,i,r)}(n,r-8,BigInt(8*this.length),o),this.process(n,0);const a=tn(e),i=this.outputLen;if(i%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=i/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],o)}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:o,destroyed:s,pos:a}=this;return e.destroyed=s,e.finished=o,e.length=r,e.pos=a,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}}const vs=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),xs=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]),Es=new Uint32Array(64);class Ps extends ws{constructor(e=32){super(64,e,8,!1),this.A=0|vs[0],this.B=0|vs[1],this.C=0|vs[2],this.D=0|vs[3],this.E=0|vs[4],this.F=0|vs[5],this.G=0|vs[6],this.H=0|vs[7]}get(){const{A:e,B:t,C:n,D:r,E:o,F:s,G:a,H:i}=this;return[e,t,n,r,o,s,a,i]}set(e,t,n,r,o,s,a,i){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|o,this.F=0|s,this.G=0|a,this.H=0|i}process(e,t){for(let n=0;n<16;n++,t+=4)Es[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=Es[e-15],n=Es[e-2],r=nn(t,7)^nn(t,18)^t>>>3,o=nn(n,17)^nn(n,19)^n>>>10;Es[e]=o+Es[e-7]+r+Es[e-16]|0}let{A:n,B:r,C:o,D:s,E:a,F:i,G:c,H:u}=this;for(let e=0;e<64;e++){const t=u+(nn(a,6)^nn(a,11)^nn(a,25))+bs(a,i,c)+xs[e]+Es[e]|0,l=(nn(n,2)^nn(n,13)^nn(n,22))+ys(n,r,o)|0;u=c,c=i,i=a,a=s+t|0,s=o,o=r,r=n,n=t+l|0}n=n+this.A|0,r=r+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,i=i+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(n,r,o,s,a,i,c,u)}roundClean(){en(Es)}destroy(){this.set(0,0,0,0,0,0,0,0),en(this.buffer)}}const ks=cn(()=>new Ps),As=ks;function Is(e){const{commitment:t,version:n=1}=e,r=e.to??("string"==typeof t?"hex":"bytes"),o=As(De(s=t,{strict:!1})?Ut(s):s);var s;return o.set([n],0),"bytes"===r?o:_t(o)}const Ns=4096,Ss=131072,Ts=761855;class $s extends He{constructor({maxSize:e,size:t}){super("Blob size is too large.",{metaMessages:[`Max: ${e} bytes`,`Given: ${t} bytes`],name:"BlobSizeTooLargeError"})}}class Bs extends He{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}function Cs(e){const{data:t,kzg:n,to:r}=e,o=e.blobs??function(e){const t="string"==typeof e.data?qt(e.data):e.data,n=Ge(t);if(!n)throw new Bs;if(n>Ts)throw new $s({maxSize:Ts,size:n});const r=[];let o=!0,s=0;for(;o;){const e=gr(new Uint8Array(Ss));let n=0;for(;n<Ns;){const r=t.slice(s,s+31);if(e.pushByte(0),e.pushBytes(r),r.length<31){e.pushByte(128),o=!1;break}n++,s+=31}r.push(e)}return r.map(e=>_t(e.bytes))}({data:t}),s=e.commitments??ms({blobs:o,kzg:n,to:r}),a=e.proofs??gs({blobs:o,commitments:s,kzg:n,to:r}),i=[];for(let e=0;e<o.length;e++)i.push({blob:o[e],commitment:s[e],proof:a[e]});return i}async function Os(e){return Ct(await e.request({method:"eth_chainId"},{dedupe:!0}))}const Rs=["blobVersionedHashes","chainId","fees","gas","nonce","type"],zs=new Map;async function _s(e,t){const{account:n=e.account,blobs:r,chain:o,gas:s,kzg:a,nonce:i,nonceManager:c,parameters:u=Rs,type:l}=t,d=n?ar(n):n,f={...t,...d?{from:d?.address}:{}};let h,p;async function m(){return h||(h=await je(e,ls,"getBlock")({blockTag:"latest"}),h)}async function g(){if(p)return p;if(o)return o.id;if(void 0!==t.chainId)return t.chainId;const n=await je(e,Os,"getChainId")({});return p=n,p}if(u.includes("nonce")&&void 0===i&&d)if(c){const t=await g();f.nonce=await c.consume({address:d.address,chainId:t,client:e})}else f.nonce=await je(e,ps,"getTransactionCount")({address:d.address,blockTag:"pending"});if((u.includes("blobVersionedHashes")||u.includes("sidecars"))&&r&&a){const e=ms({blobs:r,kzg:a});if(u.includes("blobVersionedHashes")){const t=function(e){const{commitments:t,version:n}=e,r=e.to,o=[];for(const e of t)o.push(Is({commitment:e,to:r,version:n}));return o}({commitments:e,to:"hex"});f.blobVersionedHashes=t}if(u.includes("sidecars")){const t=Cs({blobs:r,commitments:e,proofs:gs({blobs:r,commitments:e,kzg:a}),to:"hex"});f.sidecars=t}}if(u.includes("chainId")&&(f.chainId=await g()),(u.includes("fees")||u.includes("type"))&&void 0===l)try{f.type=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 Fr({transaction:e})}(f)}catch{let t=zs.get(e.uid);if(void 0===t){const n=await m();t="bigint"==typeof n?.baseFeePerGas,zs.set(e.uid,t)}f.type=t?"eip1559":"legacy"}if(u.includes("fees"))if("legacy"!==f.type&&"eip2930"!==f.type){if(void 0===f.maxFeePerGas||void 0===f.maxPriorityFeePerGas){const n=await m(),{maxFeePerGas:r,maxPriorityFeePerGas:s}=await hs(e,{block:n,chain:o,request:f});if(void 0===t.maxPriorityFeePerGas&&t.maxFeePerGas&&t.maxFeePerGas<s)throw new ss({maxPriorityFeePerGas:s});f.maxPriorityFeePerGas=s,f.maxFeePerGas=r}}else{if(void 0!==t.maxFeePerGas||void 0!==t.maxPriorityFeePerGas)throw new os;if(void 0===t.gasPrice){const t=await m(),{gasPrice:n}=await hs(e,{block:t,chain:o,request:f,type:"legacy"});f.gasPrice=n}}return u.includes("gas")&&void 0===s&&(f.gas=await je(e,Ms,"estimateGas")({...f,account:d?{address:d.address,type:"json-rpc"}:d})),ns(f),delete f.parameters,f}async function Ms(e,t){const{account:n=e.account}=t,r=n?ar(n):void 0;try{const{accessList:n,authorizationList:o,blobs:s,blobVersionedHashes:a,blockNumber:i,blockTag:c,data:u,gas:l,gasPrice:d,maxFeePerBlobGas:f,maxFeePerGas:h,maxPriorityFeePerGas:p,nonce:m,value:g,stateOverride:b,...y}=await _s(e,{...t,parameters:"local"===r?.type?void 0:["blobVersionedHashes"]}),w=("bigint"==typeof i?Mt(i):void 0)||c,v=es(b),x=await(async()=>y.to?y.to:o&&o.length>0?await Ro({authorization:o[0]}).catch(()=>{throw new He("`to` is required. Could not infer from `authorizationList`")}):void 0)();ns(t);const E=e.chain?.formatters?.transactionRequest?.format,P=(E||Jo)({...Zo(y,{format:E}),from:r?.address,accessList:n,authorizationList:o,blobs:s,blobVersionedHashes:a,data:u,gas:l,gasPrice:d,maxFeePerBlobGas:f,maxFeePerGas:h,maxPriorityFeePerGas:p,nonce:m,to:x,value:g});return BigInt(await e.request({method:"eth_estimateGas",params:v?[P,w??e.experimental_blockTag??"latest",v]:w?[P,w]:[P]}))}catch(n){throw function(e,{docsPath:t,...n}){const r=(()=>{const t=Yo(e,n);return t instanceof Ho?e:t})();return new zo(r,{docsPath:t,...n})}(n,{...t,account:r,chain:e.chain})}}function Fs(e,t){if(!Fn(e,{strict:!1}))throw new Bn({address:e});if(!Fn(t,{strict:!1}))throw new Bn({address:t});return e.toLowerCase()===t.toLowerCase()}const js="/docs/contract/decodeEventLog";function Ls(e){const{abi:t,data:n,strict:r,topics:o}=e,s=r??!0,[a,...i]=o;if(!a)throw new st({docsPath:js});const c=t.find(e=>"event"===e.type&&a===$n(Le(e)));if(!c||!("name"in c)||"event"!==c.type)throw new at(a,{docsPath:js});const{name:u,inputs:l}=c,d=l?.some(e=>!("name"in e&&e.name)),f=d?[]:{},h=l.map((e,t)=>[e,t]).filter(([e])=>"indexed"in e&&e.indexed);for(let e=0;e<h.length;e++){const[t,n]=h[e],r=i[e];if(!r)throw new pt({abiItem:c,param:t});f[d?n:t.name||n]=Us({param:t,value:r})}const p=l.filter(e=>!("indexed"in e&&e.indexed));if(p.length>0)if(n&&"0x"!==n)try{const e=vr(p,n);if(e)if(d)for(let t=0;t<l.length;t++)f[t]=f[t]??e.shift();else for(let t=0;t<p.length;t++)f[p[t].name]=e[t]}catch(e){if(s){if(e instanceof Je||e instanceof hr)throw new ht({abiItem:c,data:n,params:p,size:Ge(n)});throw e}}else if(s)throw new ht({abiItem:c,data:"0x",params:p,size:0});return{eventName:u,args:Object.values(f).length>0?f:void 0}}function Us({param:e,value:t}){if("string"===e.type||"bytes"===e.type||"tuple"===e.type||e.type.match(/^(.*)\[(\d+)?\]$/))return t;return(vr([e],t)||[])[0]}function Ds(e){const{abi:t,args:n,logs:r,strict:o=!0}=e,s=(()=>{if(e.eventName)return Array.isArray(e.eventName)?e.eventName:[e.eventName]})();return r.map(e=>{try{const r=t.find(t=>"event"===t.type&&e.topics[0]===$n(t));if(!r)return null;const a=Ls({...e,abi:[r],strict:o});return s&&!s.includes(a.eventName)?null:function(e){const{args:t,inputs:n,matchArgs:r}=e;if(!r)return!0;if(!t)return!1;function o(e,t,n){try{return"address"===e.type?Fs(t,n):"string"===e.type||"bytes"===e.type?In(Ut(t))===n:t===n}catch{return!1}}if(Array.isArray(t)&&Array.isArray(r))return r.every((e,r)=>{if(null==e)return!0;const s=n[r];if(!s)return!1;return(Array.isArray(e)?e:[e]).some(e=>o(s,e,t[r]))});return"object"==typeof t&&!Array.isArray(t)&&"object"==typeof r&&!Array.isArray(r)&&Object.entries(r).every(([e,r])=>{if(null==r)return!0;const s=n.find(t=>t.name===e);if(!s)return!1;return(Array.isArray(r)?r:[r]).some(n=>o(s,n,t[e]))})}({args:a.args,inputs:r.inputs,matchArgs:n})?{...a,...e}:null}catch(t){let n,r;if(t instanceof at)return null;if(t instanceof ht||t instanceof pt){if(o)return null;n=t.abiItem.name,r=t.abiItem.inputs?.some(e=>!("name"in e&&e.name))}return{...e,args:r?[]:{},eventName:n}}}).filter(Boolean)}function Gs(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}:{}}}async function qs(e,{address:t,blockHash:n,fromBlock:r,toBlock:o,event:s,events:a,args:i,strict:c}={}){const u=c??!1,l=a??(s?[s]:void 0);let d,f=[];if(l){const e=l.flatMap(e=>nr({abi:[e],eventName:e.name,args:a?void 0:i}));f=[e],s&&(f=f[0])}d=n?await e.request({method:"eth_getLogs",params:[{address:t,topics:f,blockHash:n}]}):await e.request({method:"eth_getLogs",params:[{address:t,topics:f,fromBlock:"bigint"==typeof r?Mt(r):r,toBlock:"bigint"==typeof o?Mt(o):o}]});const h=d.map(e=>Gs(e));return l?Ds({abi:l,args:i,logs:h,strict:u}):h}async function Vs(e,t){const{abi:n,address:r,args:o,blockHash:s,eventName:a,fromBlock:i,toBlock:c,strict:u}=t,l=a?Qn({abi:n,name:a}):void 0,d=l?void 0:n.filter(e=>"event"===e.type);return je(e,qs,"getLogs")({address:r,args:o,blockHash:s,event:l,events:d,fromBlock:i,toBlock:c,strict:u})}const Ws="/docs/contract/decodeFunctionResult";function Hs(e){const{abi:t,args:n,functionName:r,data:o}=e;let s=t[0];if(r){const e=Qn({abi:t,args:n,name:r});if(!e)throw new ct(r,{docsPath:Ws});s=e}if("function"!==s.type)throw new ct(void 0,{docsPath:Ws});if(!s.outputs)throw new ut(s.name,{docsPath:Ws});const a=vr(s.outputs,o);return a&&a.length>1?a:a&&1===a.length?a[0]:void 0}
|
|
4
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ys=BigInt(0),Zs=BigInt(1);function Ks(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function Js(e){if(!Ks(e))throw new Error("Uint8Array expected")}function Qs(e,t){if("boolean"!=typeof t)throw new Error(e+" boolean expected, got "+t)}function Xs(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function ea(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?Ys:BigInt("0x"+e)}const ta="function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex,na=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function ra(e){if(Js(e),ta)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=na[e[n]];return t}const oa=48,sa=57,aa=65,ia=70,ca=97,ua=102;function la(e){return e>=oa&&e<=sa?e-oa:e>=aa&&e<=ia?e-(aa-10):e>=ca&&e<=ua?e-(ca-10):void 0}function da(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(ta)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,o=0;t<n;t++,o+=2){const n=la(e.charCodeAt(o)),s=la(e.charCodeAt(o+1));if(void 0===n||void 0===s){const t=e[o]+e[o+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+o)}r[t]=16*n+s}return r}function fa(e){return ea(ra(e))}function ha(e){return Js(e),ea(ra(Uint8Array.from(e).reverse()))}function pa(e,t){return da(e.toString(16).padStart(2*t,"0"))}function ma(e,t){return pa(e,t).reverse()}function ga(e,t,n){let r;if("string"==typeof t)try{r=da(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!Ks(t))throw new Error(e+" must be hex string or Uint8Array");r=Uint8Array.from(t)}const o=r.length;if("number"==typeof n&&o!==n)throw new Error(e+" of length "+n+" expected, got "+o);return r}function ba(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];Js(r),t+=r.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const o=e[t];n.set(o,r),r+=o.length}return n}const ya=e=>"bigint"==typeof e&&Ys<=e;function wa(e,t,n){return ya(e)&&ya(t)&&ya(n)&&t<=e&&e<n}function va(e,t,n,r){if(!wa(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}const xa=e=>(Zs<<BigInt(e))-Zs,Ea=e=>new Uint8Array(e),Pa=e=>Uint8Array.from(e);const ka={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||Ks(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 Aa(e,t,n={}){const r=(t,n,r)=>{const o=ka[n];if("function"!=typeof o)throw new Error("invalid validator function");const s=e[t];if(!(r&&void 0===s||o(s,e)))throw new Error("param "+String(t)+" is invalid. Expected "+n+", got "+s)};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 Ia(e){const t=new WeakMap;return(n,...r)=>{const o=t.get(n);if(void 0!==o)return o;const s=e(n,...r);return t.set(n,s),s}}class Na extends Error{constructor(e,t={}){const n=(()=>{if(t.cause instanceof Na){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 Na&&t.cause.docsPath||t.docsPath,o=`https://oxlib.sh${r??""}`,s=[e||"An error occurred.",...t.metaMessages?["",...t.metaMessages]:[],...n||r?["",n?`Details: ${n}`:void 0,r?`See: ${o}`:void 0]:[]].filter(e=>"string"==typeof e).join("\n");super(s,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=o,this.docsPath=r,this.shortMessage=e}walk(e){return Sa(this,e)}}function Sa(e,t){return t?.(e)?e:e&&"object"==typeof e&&"cause"in e&&e.cause?Sa(e.cause,t):t?null:e}function Ta(e,t){if(Wa(e)>t)throw new ei({givenSize:Wa(e),maxSize:t})}const $a=48,Ba=57,Ca=65,Oa=70,Ra=97,za=102;function _a(e){return e>=$a&&e<=Ba?e-$a:e>=Ca&&e<=Oa?e-(Ca-10):e>=Ra&&e<=za?e-(Ra-10):void 0}function Ma(e,t={}){const{dir:n="left"}=t;let r=e,o=0;for(let e=0;e<r.length-1&&"0"===r["left"===n?e:r.length-e-1].toString();e++)o++;return r="left"===n?r.slice(o):r.slice(0,r.length-o),r}function Fa(e,t){if(fi(e)>t)throw new wi({givenSize:fi(e),maxSize:t})}function ja(e,t={}){const{dir:n,size:r=32}=t;if(0===r)return e;const o=e.replace("0x","");if(o.length>2*r)throw new xi({size:Math.ceil(o.length/2),targetSize:r,type:"Hex"});return`0x${o["right"===n?"padEnd":"padStart"](2*r,"0")}`}function La(e,t,n){return JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString()+"#__bigint":t,n)}const Ua=new TextDecoder,Da=new TextEncoder;function Ga(e){return e instanceof Uint8Array?e:"string"==typeof e?qa(e):function(e){return e instanceof Uint8Array?e:new Uint8Array(e)}(e)}function qa(e,t={}){const{size:n}=t;let r=e;n&&(Fa(e,n),r=li(e,n));let o=r.slice(2);o.length%2&&(o=`0${o}`);const s=o.length/2,a=new Uint8Array(s);for(let e=0,t=0;e<s;e++){const n=_a(o.charCodeAt(t++)),r=_a(o.charCodeAt(t++));if(void 0===n||void 0===r)throw new Na(`Invalid byte sequence ("${o[t-2]}${o[t-1]}" in "${o}").`);a[e]=16*n+r}return a}function Va(e,t={}){const{size:n}=t,r=Da.encode(e);return"number"==typeof n?(Ta(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 ti({size:e.length,targetSize:r,type:"Bytes"});const o=new Uint8Array(r);for(let t=0;t<r;t++){const s="right"===n;o[s?t:r-t-1]=e[s?t:e.length-t-1]}return o}(e,{dir:"right",size:t})}(r,n)):r}function Wa(e){return e.length}function Ha(e,t,n,r={}){const{strict:o}=r;return e.slice(t,n)}function Ya(e,t={}){const{size:n}=t;void 0!==n&&Ta(e,n);return hi(ai(e,t),t)}function Za(e,t={}){const{size:n}=t;let r=e;if(void 0!==n&&(Ta(r,n),r=Qa(r)),r.length>1||r[0]>1)throw new Xa(r);return Boolean(r[0])}function Ka(e,t={}){const{size:n}=t;void 0!==n&&Ta(e,n);return pi(ai(e,t),t)}function Ja(e,t={}){const{size:n}=t;let r=e;return void 0!==n&&(Ta(r,n),r=Ma(r,{dir:"right"})),Ua.decode(r)}function Qa(e){return Ma(e,{dir:"left"})}class Xa extends Na{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"})}}let ei=class extends Na{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"})}},ti=class extends Na{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 ni=new TextEncoder,ri=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function oi(...e){return`0x${e.reduce((e,t)=>e+t.replace("0x",""),"")}`}function si(e,t={}){const n=`0x${Number(e)}`;return"number"==typeof t.size?(Fa(n,t.size),ui(n,t.size)):n}function ai(e,t={}){let n="";for(let t=0;t<e.length;t++)n+=ri[e[t]];const r=`0x${n}`;return"number"==typeof t.size?(Fa(r,t.size),li(r,t.size)):r}function ii(e,t={}){const{signed:n,size:r}=t,o=BigInt(e);let s;r?s=n?(1n<<8n*BigInt(r)-1n)-1n:2n**(8n*BigInt(r))-1n:"number"==typeof e&&(s=BigInt(Number.MAX_SAFE_INTEGER));const a="bigint"==typeof s&&n?-s-1n:0;if(s&&o>s||o<a){const t="bigint"==typeof e?"n":"";throw new gi({max:s?`${s}${t}`:void 0,min:`${a}${t}`,signed:n,size:r,value:`${e}${t}`})}const i=`0x${(n&&o<0?(1n<<BigInt(8*r))+BigInt(o):o).toString(16)}`;return r?ui(i,r):i}function ci(e,t={}){return ai(ni.encode(e),t)}function ui(e,t){return ja(e,{dir:"left",size:t})}function li(e,t){return ja(e,{dir:"right",size:t})}function di(e,t,n,r={}){const{strict:o}=r;!function(e,t){if("number"==typeof t&&t>0&&t>fi(e)-1)throw new vi({offset:t,position:"start",size:fi(e)})}(e,t);const s=`0x${e.replace("0x","").slice(2*(t??0),2*(n??e.length))}`;return o&&function(e,t,n){if("number"==typeof t&&"number"==typeof n&&fi(e)!==n-t)throw new vi({offset:n,position:"end",size:fi(e)})}(s,t,n),s}function fi(e){return Math.ceil((e.length-2)/2)}function hi(e,t={}){const{signed:n}=t;t.size&&Fa(e,t.size);const r=BigInt(e);if(!n)return r;const o=(e.length-2)/2,s=(1n<<8n*BigInt(o))-1n;return r<=s>>1n?r:r-s-1n}function pi(e,t={}){const{signed:n,size:r}=t;return Number(n||r?hi(e,t):e)}function mi(e,t={}){const{strict:n=!1}=t;try{return function(e,t={}){const{strict:n=!1}=t;if(!e)throw new bi(e);if("string"!=typeof e)throw new bi(e);if(n&&!/^0x[0-9a-fA-F]*$/.test(e))throw new yi(e);if(!e.startsWith("0x"))throw new yi(e)}(e,{strict:n}),!0}catch{return!1}}class gi extends Na{constructor({max:e,min:t,signed:n,size:r,value:o}){super(`Number \`${o}\` 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 bi extends Na{constructor(e){super(`Value \`${"object"==typeof e?La(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 yi extends Na{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 wi extends Na{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 vi extends Na{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 xi extends Na{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 Ei(e){return{address:e.address,amount:ii(e.amount),index:ii(e.index),validatorIndex:ii(e.validatorIndex)}}function Pi(e){return{..."bigint"==typeof e.baseFeePerGas&&{baseFeePerGas:ii(e.baseFeePerGas)},..."bigint"==typeof e.blobBaseFee&&{blobBaseFee:ii(e.blobBaseFee)},..."string"==typeof e.feeRecipient&&{feeRecipient:e.feeRecipient},..."bigint"==typeof e.gasLimit&&{gasLimit:ii(e.gasLimit)},..."bigint"==typeof e.number&&{number:ii(e.number)},..."bigint"==typeof e.prevRandao&&{prevRandao:ii(e.prevRandao)},..."bigint"==typeof e.time&&{time:ii(e.time)},...e.withdrawals&&{withdrawals:e.withdrawals.map(Ei)}}}const ki=[{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"},{inputs:[],name:"getCurrentBlockTimestamp",outputs:[{internalType:"uint256",name:"timestamp",type:"uint256"}],stateMutability:"view",type:"function"}],Ai=[{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"}]}],Ii=[{inputs:[{name:"dns",type:"bytes"}],name:"DNSDecodingFailed",type:"error"},{inputs:[{name:"ens",type:"string"}],name:"DNSEncodingFailed",type:"error"},{inputs:[],name:"EmptyAddress",type:"error"},{inputs:[{name:"status",type:"uint16"},{name:"message",type:"string"}],name:"HttpError",type:"error"},{inputs:[],name:"InvalidBatchGatewayResponse",type:"error"},{inputs:[{name:"errorData",type:"bytes"}],name:"ResolverError",type:"error"},{inputs:[{name:"name",type:"bytes"},{name:"resolver",type:"address"}],name:"ResolverNotContract",type:"error"},{inputs:[{name:"name",type:"bytes"}],name:"ResolverNotFound",type:"error"},{inputs:[{name:"primary",type:"string"},{name:"primaryAddress",type:"bytes"}],name:"ReverseAddressMismatch",type:"error"},{inputs:[{internalType:"bytes4",name:"selector",type:"bytes4"}],name:"UnsupportedResolverProfile",type:"error"}],Ni=[...Ii,{name:"resolveWithGateways",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes"},{name:"data",type:"bytes"},{name:"gateways",type:"string[]"}],outputs:[{name:"",type:"bytes"},{name:"address",type:"address"}]}],Si=[...Ii,{name:"reverseWithGateways",type:"function",stateMutability:"view",inputs:[{type:"bytes",name:"reverseName"},{type:"uint256",name:"coinType"},{type:"string[]",name:"gateways"}],outputs:[{type:"string",name:"resolvedName"},{type:"address",name:"resolver"},{type:"address",name:"reverseResolver"}]}],Ti=[{name:"text",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes32"},{name:"key",type:"string"}],outputs:[{name:"",type:"string"}]}],$i=[{name:"addr",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes32"}],outputs:[{name:"",type:"address"}]},{name:"addr",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes32"},{name:"coinType",type:"uint256"}],outputs:[{name:"",type:"bytes"}]}],Bi=[{name:"isValidSignature",type:"function",stateMutability:"view",inputs:[{name:"hash",type:"bytes32"},{name:"signature",type:"bytes"}],outputs:[{name:"",type:"bytes4"}]}],Ci=[{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"}],Oi="0x82ad56cb",Ri="0x608060405234801561001057600080fd5b5060405161018e38038061018e83398101604081905261002f91610124565b6000808351602085016000f59050803b61004857600080fd5b6000808351602085016000855af16040513d6000823e81610067573d81fd5b3d81f35b634e487b7160e01b600052604160045260246000fd5b600082601f83011261009257600080fd5b81516001600160401b038111156100ab576100ab61006b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156100d9576100d961006b565b6040528181528382016020018510156100f157600080fd5b60005b82811015610110576020818601810151838301820152016100f4565b506000918101602001919091529392505050565b6000806040838503121561013757600080fd5b82516001600160401b0381111561014d57600080fd5b61015985828601610081565b602085015190935090506001600160401b0381111561017757600080fd5b61018385828601610081565b915050925092905056fe",zi="0x608060405234801561001057600080fd5b506040516102c03803806102c083398101604081905261002f916101e6565b836001600160a01b03163b6000036100e457600080836001600160a01b03168360405161005c9190610270565b6000604051808303816000865af19150503d8060008114610099576040519150601f19603f3d011682016040523d82523d6000602084013e61009e565b606091505b50915091508115806100b857506001600160a01b0386163b155b156100e1578060405163101bb98d60e01b81526004016100d8919061028c565b60405180910390fd5b50505b6000808451602086016000885af16040513d6000823e81610103573d81fd5b3d81f35b80516001600160a01b038116811461011e57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561015457818101518382015260200161013c565b50506000910152565b600082601f83011261016e57600080fd5b81516001600160401b0381111561018757610187610123565b604051601f8201601f19908116603f011681016001600160401b03811182821017156101b5576101b5610123565b6040528181528382016020018510156101cd57600080fd5b6101de826020830160208701610139565b949350505050565b600080600080608085870312156101fc57600080fd5b61020585610107565b60208601519094506001600160401b0381111561022157600080fd5b61022d8782880161015d565b93505061023c60408601610107565b60608601519092506001600160401b0381111561025857600080fd5b6102648782880161015d565b91505092959194509250565b60008251610282818460208701610139565b9190910192915050565b60208152600082518060208401526102ab816040850160208701610139565b601f01601f1916919091016040019291505056fe",_i="0x608060405234801561001057600080fd5b5060405161069438038061069483398101604081905261002f9161051e565b600061003c848484610048565b9050806000526001601ff35b60007f64926492649264926492649264926492649264926492649264926492649264926100748361040c565b036101e7576000606080848060200190518101906100929190610577565b60405192955090935091506000906001600160a01b038516906100b69085906105dd565b6000604051808303816000865af19150503d80600081146100f3576040519150601f19603f3d011682016040523d82523d6000602084013e6100f8565b606091505b50509050876001600160a01b03163b60000361016057806101605760405162461bcd60e51b815260206004820152601e60248201527f5369676e617475726556616c696461746f723a206465706c6f796d656e74000060448201526064015b60405180910390fd5b604051630b135d3f60e11b808252906001600160a01b038a1690631626ba7e90610190908b9087906004016105f9565b602060405180830381865afa1580156101ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d19190610633565b6001600160e01b03191614945050505050610405565b6001600160a01b0384163b1561027a57604051630b135d3f60e11b808252906001600160a01b03861690631626ba7e9061022790879087906004016105f9565b602060405180830381865afa158015610244573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102689190610633565b6001600160e01b031916149050610405565b81516041146102df5760405162461bcd60e51b815260206004820152603a602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e6174757265206c656e6774680000000000006064820152608401610157565b6102e7610425565b5060208201516040808401518451859392600091859190811061030c5761030c61065d565b016020015160f81c9050601b811480159061032b57508060ff16601c14155b1561038c5760405162461bcd60e51b815260206004820152603b602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e617475726520762076616c756500000000006064820152608401610157565b60408051600081526020810180835289905260ff83169181019190915260608101849052608081018390526001600160a01b0389169060019060a0016020604051602081039080840390855afa1580156103ea573d6000803e3d6000fd5b505050602060405103516001600160a01b0316149450505050505b9392505050565b600060208251101561041d57600080fd5b508051015190565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b038116811461045857600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561048c578181015183820152602001610474565b50506000910152565b600082601f8301126104a657600080fd5b81516001600160401b038111156104bf576104bf61045b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156104ed576104ed61045b565b60405281815283820160200185101561050557600080fd5b610516826020830160208701610471565b949350505050565b60008060006060848603121561053357600080fd5b835161053e81610443565b6020850151604086015191945092506001600160401b0381111561056157600080fd5b61056d86828701610495565b9150509250925092565b60008060006060848603121561058c57600080fd5b835161059781610443565b60208501519093506001600160401b038111156105b357600080fd5b6105bf86828701610495565b604086015190935090506001600160401b0381111561056157600080fd5b600082516105ef818460208701610471565b9190910192915050565b828152604060208201526000825180604084015261061e816060850160208701610471565b601f01601f1916919091016060019392505050565b60006020828403121561064557600080fd5b81516001600160e01b03198116811461040557600080fd5b634e487b7160e01b600052603260045260246000fdfe5369676e617475726556616c696461746f72237265636f7665725369676e6572",Mi="0x608060405234801561001057600080fd5b506115b9806100206000396000f3fe6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e14610325578063bce38bd714610350578063c3077fa914610380578063ee82ac5e146103b2576100f3565b80634d2301cc1461026257806372425d9d1461029f57806382ad56cb146102ca57806386d516e8146102fa576100f3565b80633408e470116100c65780633408e470146101af578063399542e9146101da5780633e64a6961461020c57806342cbb15c14610237576100f3565b80630f28c97d146100f8578063174dea7114610123578063252dba421461015357806327e86d6e14610184575b600080fd5b34801561010457600080fd5b5061010d6103ef565b60405161011a9190610c0a565b60405180910390f35b61013d60048036038101906101389190610c94565b6103f7565b60405161014a9190610e94565b60405180910390f35b61016d60048036038101906101689190610f0c565b610615565b60405161017b92919061101b565b60405180910390f35b34801561019057600080fd5b506101996107ab565b6040516101a69190611064565b60405180910390f35b3480156101bb57600080fd5b506101c46107b7565b6040516101d19190610c0a565b60405180910390f35b6101f460048036038101906101ef91906110ab565b6107bf565b6040516102039392919061110b565b60405180910390f35b34801561021857600080fd5b506102216107e1565b60405161022e9190610c0a565b60405180910390f35b34801561024357600080fd5b5061024c6107e9565b6040516102599190610c0a565b60405180910390f35b34801561026e57600080fd5b50610289600480360381019061028491906111a7565b6107f1565b6040516102969190610c0a565b60405180910390f35b3480156102ab57600080fd5b506102b4610812565b6040516102c19190610c0a565b60405180910390f35b6102e460048036038101906102df919061122a565b61081a565b6040516102f19190610e94565b60405180910390f35b34801561030657600080fd5b5061030f6109e4565b60405161031c9190610c0a565b60405180910390f35b34801561033157600080fd5b5061033a6109ec565b6040516103479190611286565b60405180910390f35b61036a600480360381019061036591906110ab565b6109f4565b6040516103779190610e94565b60405180910390f35b61039a60048036038101906103959190610f0c565b610ba6565b6040516103a99392919061110b565b60405180910390f35b3480156103be57600080fd5b506103d960048036038101906103d491906112cd565b610bca565b6040516103e69190611064565b60405180910390f35b600042905090565b60606000808484905090508067ffffffffffffffff81111561041c5761041b6112fa565b5b60405190808252806020026020018201604052801561045557816020015b610442610bd5565b81526020019060019003908161043a5790505b5092503660005b828110156105c957600085828151811061047957610478611329565b5b6020026020010151905087878381811061049657610495611329565b5b90506020028101906104a89190611367565b925060008360400135905080860195508360000160208101906104cb91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16818580606001906104f2919061138f565b604051610500929190611431565b60006040518083038185875af1925050503d806000811461053d576040519150601f19603f3d011682016040523d82523d6000602084013e610542565b606091505b5083600001846020018290528215151515815250505081516020850135176105bc577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b826001019250505061045c565b5082341461060c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610603906114a7565b60405180910390fd5b50505092915050565b6000606043915060008484905090508067ffffffffffffffff81111561063e5761063d6112fa565b5b60405190808252806020026020018201604052801561067157816020015b606081526020019060019003908161065c5790505b5091503660005b828110156107a157600087878381811061069557610694611329565b5b90506020028101906106a791906114c7565b92508260000160208101906106bc91906111a7565b73ffffffffffffffffffffffffffffffffffffffff168380602001906106e2919061138f565b6040516106f0929190611431565b6000604051808303816000865af19150503d806000811461072d576040519150601f19603f3d011682016040523d82523d6000602084013e610732565b606091505b5086848151811061074657610745611329565b5b60200260200101819052819250505080610795576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161078c9061153b565b60405180910390fd5b81600101915050610678565b5050509250929050565b60006001430340905090565b600046905090565b6000806060439250434091506107d68686866109f4565b905093509350939050565b600048905090565b600043905090565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b600044905090565b606060008383905090508067ffffffffffffffff81111561083e5761083d6112fa565b5b60405190808252806020026020018201604052801561087757816020015b610864610bd5565b81526020019060019003908161085c5790505b5091503660005b828110156109db57600084828151811061089b5761089a611329565b5b602002602001015190508686838181106108b8576108b7611329565b5b90506020028101906108ca919061155b565b92508260000160208101906108df91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060400190610905919061138f565b604051610913929190611431565b6000604051808303816000865af19150503d8060008114610950576040519150601f19603f3d011682016040523d82523d6000602084013e610955565b606091505b5082600001836020018290528215151515815250505080516020840135176109cf577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b8160010191505061087e565b50505092915050565b600045905090565b600041905090565b606060008383905090508067ffffffffffffffff811115610a1857610a176112fa565b5b604051908082528060200260200182016040528015610a5157816020015b610a3e610bd5565b815260200190600190039081610a365790505b5091503660005b82811015610b9c576000848281518110610a7557610a74611329565b5b60200260200101519050868683818110610a9257610a91611329565b5b9050602002810190610aa491906114c7565b9250826000016020810190610ab991906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060200190610adf919061138f565b604051610aed929190611431565b6000604051808303816000865af19150503d8060008114610b2a576040519150601f19603f3d011682016040523d82523d6000602084013e610b2f565b606091505b508260000183602001829052821515151581525050508715610b90578060000151610b8f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b869061153b565b60405180910390fd5b5b81600101915050610a58565b5050509392505050565b6000806060610bb7600186866107bf565b8093508194508295505050509250925092565b600081409050919050565b6040518060400160405280600015158152602001606081525090565b6000819050919050565b610c0481610bf1565b82525050565b6000602082019050610c1f6000830184610bfb565b92915050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610c5457610c53610c2f565b5b8235905067ffffffffffffffff811115610c7157610c70610c34565b5b602083019150836020820283011115610c8d57610c8c610c39565b5b9250929050565b60008060208385031215610cab57610caa610c25565b5b600083013567ffffffffffffffff811115610cc957610cc8610c2a565b5b610cd585828601610c3e565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b60008115159050919050565b610d2281610d0d565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610d62578082015181840152602081019050610d47565b83811115610d71576000848401525b50505050565b6000601f19601f8301169050919050565b6000610d9382610d28565b610d9d8185610d33565b9350610dad818560208601610d44565b610db681610d77565b840191505092915050565b6000604083016000830151610dd96000860182610d19565b5060208301518482036020860152610df18282610d88565b9150508091505092915050565b6000610e0a8383610dc1565b905092915050565b6000602082019050919050565b6000610e2a82610ce1565b610e348185610cec565b935083602082028501610e4685610cfd565b8060005b85811015610e825784840389528151610e638582610dfe565b9450610e6e83610e12565b925060208a01995050600181019050610e4a565b50829750879550505050505092915050565b60006020820190508181036000830152610eae8184610e1f565b905092915050565b60008083601f840112610ecc57610ecb610c2f565b5b8235905067ffffffffffffffff811115610ee957610ee8610c34565b5b602083019150836020820283011115610f0557610f04610c39565b5b9250929050565b60008060208385031215610f2357610f22610c25565b5b600083013567ffffffffffffffff811115610f4157610f40610c2a565b5b610f4d85828601610eb6565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6000610f918383610d88565b905092915050565b6000602082019050919050565b6000610fb182610f59565b610fbb8185610f64565b935083602082028501610fcd85610f75565b8060005b858110156110095784840389528151610fea8582610f85565b9450610ff583610f99565b925060208a01995050600181019050610fd1565b50829750879550505050505092915050565b60006040820190506110306000830185610bfb565b81810360208301526110428184610fa6565b90509392505050565b6000819050919050565b61105e8161104b565b82525050565b60006020820190506110796000830184611055565b92915050565b61108881610d0d565b811461109357600080fd5b50565b6000813590506110a58161107f565b92915050565b6000806000604084860312156110c4576110c3610c25565b5b60006110d286828701611096565b935050602084013567ffffffffffffffff8111156110f3576110f2610c2a565b5b6110ff86828701610eb6565b92509250509250925092565b60006060820190506111206000830186610bfb565b61112d6020830185611055565b818103604083015261113f8184610e1f565b9050949350505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061117482611149565b9050919050565b61118481611169565b811461118f57600080fd5b50565b6000813590506111a18161117b565b92915050565b6000602082840312156111bd576111bc610c25565b5b60006111cb84828501611192565b91505092915050565b60008083601f8401126111ea576111e9610c2f565b5b8235905067ffffffffffffffff81111561120757611206610c34565b5b60208301915083602082028301111561122357611222610c39565b5b9250929050565b6000806020838503121561124157611240610c25565b5b600083013567ffffffffffffffff81111561125f5761125e610c2a565b5b61126b858286016111d4565b92509250509250929050565b61128081611169565b82525050565b600060208201905061129b6000830184611277565b92915050565b6112aa81610bf1565b81146112b557600080fd5b50565b6000813590506112c7816112a1565b92915050565b6000602082840312156112e3576112e2610c25565b5b60006112f1848285016112b8565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600080fd5b600080fd5b600080fd5b60008235600160800383360303811261138357611382611358565b5b80830191505092915050565b600080833560016020038436030381126113ac576113ab611358565b5b80840192508235915067ffffffffffffffff8211156113ce576113cd61135d565b5b6020830192506001820236038313156113ea576113e9611362565b5b509250929050565b600081905092915050565b82818337600083830152505050565b600061141883856113f2565b93506114258385846113fd565b82840190509392505050565b600061143e82848661140c565b91508190509392505050565b600082825260208201905092915050565b7f4d756c746963616c6c333a2076616c7565206d69736d61746368000000000000600082015250565b6000611491601a8361144a565b915061149c8261145b565b602082019050919050565b600060208201905081810360008301526114c081611484565b9050919050565b6000823560016040038336030381126114e3576114e2611358565b5b80830191505092915050565b7f4d756c746963616c6c333a2063616c6c206661696c6564000000000000000000600082015250565b600061152560178361144a565b9150611530826114ef565b602082019050919050565b6000602082019050818103600083015261155481611518565b9050919050565b60008235600160600383360303811261157757611576611358565b5b8083019150509291505056fea264697066735822122020c1bc9aacf8e4a6507193432a895a8e77094f45a1395583f07b24e860ef06cd64736f6c634300080c0033";class Fi extends He{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 ji extends He{constructor(){super("No chain was provided to the Client.",{name:"ClientChainNotConfiguredError"})}}const Li="/docs/contract/encodeDeployData";function Ui(e){const{abi:t,args:n,bytecode:r}=e;if(!n||0===n.length)return r;const o=t.find(e=>"type"in e&&"constructor"===e.type);if(!o)throw new Ze({docsPath:Li});if(!("inputs"in o))throw new Ke({docsPath:Li});if(!o.inputs||0===o.inputs.length)throw new Ke({docsPath:Li});return Ln([r,Hn(o.inputs,n)])}function Di({blockNumber:e,chain:t,contract:n}){const r=t?.contracts?.[n];if(!r)throw new Fi({chain:t,contract:{name:n}});if(e&&r.blockCreated&&r.blockCreated>e)throw new Fi({blockNumber:e,chain:t,contract:{name:n,blockCreated:r.blockCreated}});return r.address}function Gi(e,{docsPath:t,...n}){const r=(()=>{const t=Yo(e,n);return t instanceof Ho?e:t})();return new Dr(r,{docsPath:t,...n})}function qi(){let e=()=>{},t=()=>{};return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}const Vi=new Map;function Wi({fn:e,id:t,shouldSplitBatch:n,wait:r=0,sort:o}){const s=async()=>{const t=i();a();const n=t.map(({args:e})=>e);0!==n.length&&e(n).then(e=>{o&&Array.isArray(e)&&e.sort(o);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=()=>Vi.delete(t),i=()=>Vi.get(t)||[],c=e=>Vi.set(t,[...i(),e]);return{flush:a,async schedule(e){const{promise:t,resolve:o,reject:a}=qi(),u=n?.([...i().map(({args:e})=>e),e]);u&&s();return i().length>0?(c({args:e,resolve:o,reject:a}),t):(c({args:e,resolve:o,reject:a}),setTimeout(s,r),t)}}}async function Hi(e,t){const{account:n=e.account,authorizationList:r,batch:o=Boolean(e.batch?.multicall),blockNumber:s,blockTag:a=e.experimental_blockTag??"latest",accessList:i,blobs:c,blockOverrides:u,code:l,data:d,factory:f,factoryData:h,gas:p,gasPrice:m,maxFeePerBlobGas:g,maxFeePerGas:b,maxPriorityFeePerGas:y,nonce:w,to:v,value:x,stateOverride:E,...P}=t,k=n?ar(n):void 0;if(l&&(f||h))throw new He("Cannot provide both `code` & `factory`/`factoryData` as parameters.");if(l&&v)throw new He("Cannot provide both `code` & `to` as parameters.");const A=l&&d,I=f&&h&&v&&d,N=A||I,S=A?Yi({code:l,data:d}):I?function(e){const{data:t,factory:n,factoryData:r,to:o}=e;return Ui({abi:_e(["constructor(address, bytes, address, bytes)"]),bytecode:zi,args:[o,t,n,r]})}({data:d,factory:f,factoryData:h,to:v}):d;try{ns(t);const n=("bigint"==typeof s?Mt(s):void 0)||a,l=u?Pi(u):void 0,d=es(E),f=e.chain?.formatters?.transactionRequest?.format,h=(f||Jo)({...Zo(P,{format:f}),from:k?.address,accessList:i,authorizationList:r,blobs:c,data:S,gas:p,gasPrice:m,maxFeePerBlobGas:g,maxFeePerGas:b,maxPriorityFeePerGas:y,nonce:w,to:N?void 0:v,value:x});if(o&&function({request:e}){const{data:t,to:n,...r}=e;return!!t&&(!t.startsWith(Oi)&&(!!n&&!(Object.values(r).filter(e=>void 0!==e).length>0)))}({request:h})&&!d&&!l)try{return await async function(e,t){const{batchSize:n=1024,deployless:r=!1,wait:o=0}="object"==typeof e.batch?.multicall?e.batch.multicall:{},{blockNumber:s,blockTag:a=e.experimental_blockTag??"latest",data:i,to:c}=t,u=(()=>{if(r)return null;if(t.multicallAddress)return t.multicallAddress;if(e.chain)return Di({blockNumber:s,chain:e.chain,contract:"multicall3"});throw new ji})(),l="bigint"==typeof s?Mt(s):void 0,d=l||a,{schedule:f}=Wi({id:`${e.uid}.${d}`,wait:o,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=cr({abi:ki,args:[n],functionName:"aggregate3"}),o=await e.request({method:"eth_call",params:[{...null===u?{data:Yi({code:Mi,data:r})}:{to:u,data:r}},d]});return Hs({abi:ki,args:[n],functionName:"aggregate3",data:o||"0x"})}}),[{returnData:h,success:p}]=await f({data:i,to:c});if(!p)throw new Hr({data:h});return"0x"===h?{data:void 0}:{data:h}}(e,{...h,blockNumber:s,blockTag:a})}catch(e){if(!(e instanceof ji||e instanceof Fi))throw e}const A=(()=>{const e=[h,n];return d&&l?[...e,d,l]:d?[...e,d]:l?[...e,{},l]:e})(),I=await e.request({method:"eth_call",params:A});return"0x"===I?{data:void 0}:{data:I}}catch(n){const r=function(e){if(!(e instanceof He))return;const t=e.walk();return"object"==typeof t?.data?t.data?.data:t.data}(n),{offchainLookup:o,offchainLookupSignature:s}=await Promise.resolve().then(function(){return Xc});if(!1!==e.ccipRead&&r?.slice(0,10)===s&&v)return{data:await o(e,{data:r,to:v})};if(N&&"0x101bb98d"===r?.slice(0,10))throw new Wr({factory:f});throw Gi(n,{...t,account:k,chain:e.chain})}}function Yi(e){const{code:t,data:n}=e;return Ui({abi:_e(["constructor(bytes, bytes)"]),bytecode:Ri,args:[t,n]})}async function Zi(e,t){const{abi:n,address:r,args:o,functionName:s,...a}=t,i=cr({abi:n,args:o,functionName:s});try{const{data:t}=await je(e,Hi,"call")({...a,data:i,to:r});return Hs({abi:n,args:o,functionName:s,data:t||"0x"})}catch(e){throw No(e,{abi:n,address:r,args:o,docsPath:"/docs/contract/readContract",functionName:s})}}const Ki=new Map,Ji=new Map;let Qi=0;function Xi(e,t,n){const r=++Qi,o=()=>Ki.get(e)||[],s=()=>{const t=o();if(!t.some(e=>e.id===r))return;const n=Ji.get(e);if(1===t.length&&n){const e=n();e instanceof Promise&&e.catch(()=>{})}(()=>{const t=o();Ki.set(e,t.filter(e=>e.id!==r))})()},a=o();if(Ki.set(e,[...a,{id:r,fns:t}]),a&&a.length>0)return s;const i={};for(const e in t)i[e]=(...t)=>{const n=o();if(0!==n.length)for(const r of n)r.fns[e]?.(...t)};const c=n(i);return"function"==typeof c&&Ji.set(e,c),s}async function ec(e){return new Promise(t=>setTimeout(t,e))}function tc(e,{emitOnBegin:t,initialWaitTime:n,interval:r}){let o=!0;const s=()=>o=!1;return(async()=>{let a;t&&(a=await e({unpoll:s}));const i=await(n?.(a))??r;await ec(i);const c=async()=>{o&&(await e({unpoll:s}),await ec(r),c())};c()})(),s}const nc=new Map,rc=new Map;async function oc(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,nc),r=t(e,rc);return{clear:()=>{n.clear(),r.clear()},promise:n,response:r}}(t),o=r.response.get();if(o&&n>0){if(Date.now()-o.created.getTime()<n)return o.data}let s=r.promise.get();s||(s=e(),r.promise.set(s));try{const e=await s;return r.response.set({created:new Date,data:e}),e}finally{r.promise.clear()}}async function sc(e,{cacheTime:t=e.cacheTime}={}){const n=await oc(()=>e.request({method:"eth_blockNumber"}),{cacheKey:(r=e.uid,`blockNumber.${r}`),cacheTime:t});var r;return BigInt(n)}async function ac(e,{filter:t}){const n="strict"in t&&t.strict,r=await t.request({method:"eth_getFilterChanges",params:[t.id]});if("string"==typeof r[0])return r;const o=r.map(e=>Gs(e));return"abi"in t&&t.abi?Ds({abi:t.abi,logs:o,strict:n}):o}async function ic(e,{filter:t}){return t.request({method:"eth_uninstallFilter",params:[t.id]})}function cc(e,{delay:t=100,retryCount:n=2,shouldRetry:r=()=>!0}={}){return new Promise((o,s)=>{const a=async({count:i=0}={})=>{try{const t=await e();o(t)}catch(e){if(i<n&&await r({count:i,error:e}))return(async({error:e})=>{const n="function"==typeof t?t({count:i,error:e}):t;n&&await ec(n),a({count:i+1})})({error:e});s(e)}};a()})}const uc={"0x0":"reverted","0x1":"success"};function lc(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=>Gs(e)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Ct(e.transactionIndex):null,status:e.status?uc[e.status]:null,type:e.type?is[e.type]||e.type:null};return e.blobGasPrice&&(t.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(t.blobGasUsed=BigInt(e.blobGasUsed)),t}let dc,fc=256;function hc(e=11){if(!dc||fc+e>512){dc="",fc=0;for(let e=0;e<256;e++)dc+=(256+256*Math.random()|0).toString(16).substring(1)}return dc.substring(fc,fc+++e)}function pc(e){if(!(e instanceof He))return!1;const t=e.walk(e=>e instanceof qr);return t instanceof qr&&("HttpError"===t.data?.errorName||("ResolverError"===t.data?.errorName||("ResolverNotContract"===t.data?.errorName||("ResolverNotFound"===t.data?.errorName||("ReverseAddressMismatch"===t.data?.errorName||"UnsupportedResolverProfile"===t.data?.errorName)))))}const mc="/docs/contract/encodeErrorResult";function gc(e){const{abi:t,errorName:n,args:r}=e;let o=t[0];if(n){const e=Qn({abi:t,args:r,name:n});if(!e)throw new rt(n,{docsPath:mc});o=e}if("error"!==o.type)throw new rt(void 0,{docsPath:mc});const s=Le(o),a=Jn(s);let i="0x";if(r&&r.length>0){if(!o.inputs)throw new nt(o.name,{docsPath:mc});i=Hn(o.inputs,r)}return Ln([a,i])}const bc="/docs/contract/encodeFunctionResult";const yc="x-batch-gateway:true";async function wc(e){const{data:t,ccipRequest:n}=e,{args:[r]}=function(e){const{abi:t,data:n}=e,r=Un(n,0,4),o=t.find(e=>"function"===e.type&&r===Jn(Le(e)));if(!o)throw new lt(r,{docsPath:"/docs/contract/decodeFunctionData"});return{functionName:o.name,args:"inputs"in o&&o.inputs&&o.inputs.length>0?vr(o.inputs,Un(n,4)):void 0}}({abi:Ai,data:t}),o=[],s=[];return await Promise.all(r.map(async(e,t)=>{try{s[t]=e.urls.includes(yc)?await wc({data:e.data,ccipRequest:n}):await n(e),o[t]=!1}catch(e){o[t]=!0,s[t]="HttpRequestError"===(r=e).name&&r.status?gc({abi:Ai,errorName:"HttpError",args:[r.status,r.shortMessage]}):gc({abi:[lr],errorName:"Error",args:["shortMessage"in r?r.shortMessage:r.message]})}var r})),function(e){const{abi:t,functionName:n,result:r}=e;let o=t[0];if(n){const e=Qn({abi:t,name:n});if(!e)throw new ct(n,{docsPath:bc});o=e}if("function"!==o.type)throw new ct(void 0,{docsPath:bc});if(!o.outputs)throw new ut(o.name,{docsPath:bc});const s=(()=>{if(0===o.outputs.length)return[];if(1===o.outputs.length)return[r];if(Array.isArray(r))return r;throw new bt(r)})();return Hn(o.outputs,s)}({abi:Ai,functionName:"query",result:[o,s]})}function vc(e){if(66!==e.length)return null;if(0!==e.indexOf("["))return null;if(65!==e.indexOf("]"))return null;const t=`0x${e.slice(1,65)}`;return De(t)?t:null}function xc(e){let t=new Uint8Array(32).fill(0);if(!e)return _t(t);const n=e.split(".");for(let e=n.length-1;e>=0;e-=1){const r=vc(n[e]),o=r?Ut(r):In(Vt(n[e]),"bytes");t=In(jn([t,o]),"bytes")}return _t(t)}function Ec(e){return`[${e.slice(2)}]`}function Pc(e){const t=new Uint8Array(32).fill(0);return e?vc(e)||In(Vt(e)):_t(t)}function kc(e){const t=e.replace(/^\.|\.$/gm,"");if(0===t.length)return new Uint8Array(1);const n=new Uint8Array(Vt(t).byteLength+2);let r=0;const o=t.split(".");for(let e=0;e<o.length;e++){let t=Vt(o[e]);t.byteLength>255&&(t=Vt(Ec(Pc(o[e])))),n[r]=t.length,n.set(t,r+1),r+=t.length+1}return n.byteLength!==r+1?n.slice(0,r+1):n}class Ac extends He{constructor({data:e}){super("Unable to extract image from metadata. The metadata may be malformed or invalid.",{metaMessages:["- Metadata must be a JSON object with at least an `image`, `image_url` or `image_data` property.","",`Provided data: ${JSON.stringify(e)}`],name:"EnsAvatarInvalidMetadataError"})}}class Ic extends He{constructor({reason:e}){super(`ENS NFT avatar URI is invalid. ${e}`,{name:"EnsAvatarInvalidNftUriError"})}}class Nc extends He{constructor({uri:e}){super(`Unable to resolve ENS avatar URI "${e}". The URI may be malformed, invalid, or does not respond with a valid image.`,{name:"EnsAvatarUriResolutionError"})}}class Sc extends He{constructor({namespace:e}){super(`ENS NFT avatar namespace "${e}" is not supported. Must be "erc721" or "erc1155".`,{name:"EnsAvatarUnsupportedNamespaceError"})}}const Tc=/(?<protocol>https?:\/\/[^/]*|ipfs:\/|ipns:\/|ar:\/)?(?<root>\/)?(?<subpath>ipfs\/|ipns\/)?(?<target>[\w\-.]+)(?<subtarget>\/.*)?/,$c=/^(Qm[1-9A-HJ-NP-Za-km-z]{44,}|b[A-Za-z2-7]{58,}|B[A-Z2-7]{58,}|z[1-9A-HJ-NP-Za-km-z]{48,}|F[0-9A-F]{50,})(\/(?<target>[\w\-.]+))?(?<subtarget>\/.*)?$/,Bc=/^data:([a-zA-Z\-/+]*);base64,([^"].*)/,Cc=/^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;function Oc(e,t){return e?e.endsWith("/")?e.slice(0,-1):e:t}function Rc({uri:e,gatewayUrls:t}){const n=Bc.test(e);if(n)return{uri:e,isOnChain:!0,isEncoded:n};const r=Oc(t?.ipfs,"https://ipfs.io"),o=Oc(t?.arweave,"https://arweave.net"),s=e.match(Tc),{protocol:a,subpath:i,target:c,subtarget:u=""}=s?.groups||{},l="ipns:/"===a||"ipns/"===i,d="ipfs:/"===a||"ipfs/"===i||$c.test(e);if(e.startsWith("http")&&!l&&!d){let n=e;return t?.arweave&&(n=e.replace(/https:\/\/arweave.net/g,t?.arweave)),{uri:n,isOnChain:!1,isEncoded:!1}}if((l||d)&&c)return{uri:`${r}/${l?"ipns":"ipfs"}/${c}${u}`,isOnChain:!1,isEncoded:!1};if("ar:/"===a&&c)return{uri:`${o}/${c}${u||""}`,isOnChain:!1,isEncoded:!1};let f=e.replace(Cc,"");if(f.startsWith("<svg")&&(f=`data:image/svg+xml;base64,${btoa(f)}`),f.startsWith("data:")||f.startsWith("{"))return{uri:f,isOnChain:!0,isEncoded:!1};throw new Nc({uri:e})}function zc(e){if("object"!=typeof e||!("image"in e)&&!("image_url"in e)&&!("image_data"in e))throw new Ac({data:e});return e.image||e.image_url||e.image_data}async function _c({gatewayUrls:e,uri:t}){const{uri:n,isOnChain:r}=Rc({uri:t,gatewayUrls:e});if(r)return n;const o=await async function(e){try{const t=await fetch(e,{method:"HEAD"});if(200===t.status){const e=t.headers.get("content-type");return e?.startsWith("image/")}return!1}catch(t){return("object"!=typeof t||void 0===t.response)&&!!Object.hasOwn(globalThis,"Image")&&new Promise(t=>{const n=new Image;n.onload=()=>{t(!0)},n.onerror=()=>{t(!1)},n.src=e})}}(n);if(o)return n;throw new Nc({uri:t})}async function Mc(e,{gatewayUrls:t,record:n}){return/eip155:/i.test(n)?async function(e,{gatewayUrls:t,record:n}){const r=function(e){let t=e;t.startsWith("did:nft:")&&(t=t.replace("did:nft:","").replace(/_/g,"/"));const[n,r,o]=t.split("/"),[s,a]=n.split(":"),[i,c]=r.split(":");if(!s||"eip155"!==s.toLowerCase())throw new Ic({reason:"Only EIP-155 supported"});if(!a)throw new Ic({reason:"Chain ID not found"});if(!c)throw new Ic({reason:"Contract address not found"});if(!o)throw new Ic({reason:"Token ID not found"});if(!i)throw new Ic({reason:"ERC namespace not found"});return{chainID:Number.parseInt(a,10),namespace:i.toLowerCase(),contractAddress:c,tokenID:o}}(n),o=await async function(e,{nft:t}){if("erc721"===t.namespace)return Zi(e,{address:t.contractAddress,abi:[{name:"tokenURI",type:"function",stateMutability:"view",inputs:[{name:"tokenId",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"tokenURI",args:[BigInt(t.tokenID)]});if("erc1155"===t.namespace)return Zi(e,{address:t.contractAddress,abi:[{name:"uri",type:"function",stateMutability:"view",inputs:[{name:"_id",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"uri",args:[BigInt(t.tokenID)]});throw new Sc({namespace:t.namespace})}(e,{nft:r}),{uri:s,isOnChain:a,isEncoded:i}=Rc({uri:o,gatewayUrls:t});if(a&&(s.includes("data:application/json;base64,")||s.startsWith("{"))){const e=i?atob(s.replace("data:application/json;base64,","")):s;return _c({uri:zc(JSON.parse(e)),gatewayUrls:t})}let c=r.tokenID;"erc1155"===r.namespace&&(c=c.replace("0x","").padStart(64,"0"));return async function({gatewayUrls:e,uri:t}){try{const n=await fetch(t).then(e=>e.json());return await _c({gatewayUrls:e,uri:zc(n)})}catch{throw new Nc({uri:t})}}({gatewayUrls:t,uri:s.replace(/(?:0x)?{id}/,c)})}(e,{gatewayUrls:t,record:n}):_c({uri:n,gatewayUrls:t})}async function Fc(e,t){const{blockNumber:n,blockTag:r,key:o,name:s,gatewayUrls:a,strict:i}=t,{chain:c}=e,u=(()=>{if(t.universalResolverAddress)return t.universalResolverAddress;if(!c)throw new Error("client chain not configured. universalResolverAddress is required.");return Di({blockNumber:n,chain:c,contract:"ensUniversalResolver"})})(),l=c?.ensTlds;if(l&&!l.some(e=>s.endsWith(e)))return null;try{const t={address:u,abi:Ni,args:[Rt(kc(s)),cr({abi:Ti,functionName:"text",args:[xc(s),o]}),a??[yc]],functionName:"resolveWithGateways",blockNumber:n,blockTag:r},i=je(e,Zi,"readContract"),c=await i(t);if("0x"===c[0])return null;const l=Hs({abi:Ti,functionName:"text",data:c[0]});return""===l?null:l}catch(e){if(i)throw e;if(pc(e))return null;throw e}}async function jc(e,t){const{account:n=e.account,blockNumber:r,blockTag:o="latest",blobs:s,data:a,gas:i,gasPrice:c,maxFeePerBlobGas:u,maxFeePerGas:l,maxPriorityFeePerGas:d,to:f,value:h,...p}=t,m=n?ar(n):void 0;try{ns(t);const n=("bigint"==typeof r?Mt(r):void 0)||o,g=e.chain?.formatters?.transactionRequest?.format,b=(g||Jo)({...Zo(p,{format:g}),from:m?.address,blobs:s,data:a,gas:i,gasPrice:c,maxFeePerBlobGas:u,maxFeePerGas:l,maxPriorityFeePerGas:d,to:f,value:h}),y=await e.request({method:"eth_createAccessList",params:[b,n]});return{accessList:y.accessList,gasUsed:BigInt(y.gasUsed)}}catch(n){throw Gi(n,{...t,account:m,chain:e.chain})}}async function Lc(e,{address:t,args:n,event:r,events:o,fromBlock:s,strict:a,toBlock:i}={}){const c=o??(r?[r]:void 0),u=or(e,{method:"eth_newFilter"});let l=[];if(c){const e=c.flatMap(e=>nr({abi:[e],eventName:e.name,args:n}));l=[e],r&&(l=l[0])}const d=await e.request({method:"eth_newFilter",params:[{address:t,fromBlock:"bigint"==typeof s?Mt(s):s,toBlock:"bigint"==typeof i?Mt(i):i,...l.length?{topics:l}:{}}]});return{abi:c,args:n,eventName:r?r.name:void 0,fromBlock:s,id:d,request:u(d),strict:Boolean(a),toBlock:i,type:"event"}}async function Uc(e){const t=or(e,{method:"eth_newPendingTransactionFilter"}),n=await e.request({method:"eth_newPendingTransactionFilter"});return{id:n,request:t(n),type:"transaction"}}async function Dc(e,{address:t,blockNumber:n,blockTag:r="latest"}){const o=void 0!==n?Mt(n):void 0,s=await e.request({method:"eth_getCode",params:[t,o||r]},{dedupe:Boolean(o)});if("0x"!==s)return s}class Gc extends He{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 qc=[{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"}];async function Vc(e,{blockCount:t,blockNumber:n,blockTag:r="latest",rewardPercentiles:o}){const s="bigint"==typeof n?Mt(n):void 0;return function(e){return{baseFeePerGas:e.baseFeePerGas.map(e=>BigInt(e)),gasUsedRatio:e.gasUsedRatio,oldestBlock:BigInt(e.oldestBlock),reward:e.reward?.map(e=>e.map(e=>BigInt(e)))}}(await e.request({method:"eth_feeHistory",params:[Mt(t),s||r,o]},{dedupe:Boolean(s)}))}const Wc=new Cn(8192);function Hc(e,t={}){return async(n,r={})=>{const{dedupe:o=!1,methods:s,retryDelay:a=150,retryCount:i=3,uid:c}={...t,...r},{method:u}=n;if(s?.exclude?.includes(u))throw new co(new Error("method not supported"),{method:u});if(s?.include&&!s.include.includes(u))throw new co(new Error("method not supported"),{method:u});return function(e,{enabled:t=!0,id:n}){if(!t||!n)return e();if(Wc.get(n))return Wc.get(n);const r=e().finally(()=>Wc.delete(n));return Wc.set(n,r),r}(()=>cc(async()=>{try{return await e(n)}catch(e){const t=e;switch(t.code){case Xr.code:throw new Xr(t);case eo.code:throw new eo(t);case to.code:throw new to(t,{method:n.method});case no.code:throw new no(t);case ro.code:throw new ro(t);case oo.code:throw new oo(t);case so.code:throw new so(t);case ao.code:throw new ao(t);case io.code:throw new io(t);case co.code:throw new co(t,{method:n.method});case uo.code:throw new uo(t);case lo.code:throw new lo(t);case fo.code:throw new fo(t);case ho.code:throw new ho(t);case po.code:throw new po(t);case mo.code:throw new mo(t);case go.code:throw new go(t);case bo.code:throw new bo(t);case yo.code:throw new yo(t);case wo.code:throw new wo(t);case vo.code:throw new vo(t);case xo.code:throw new xo(t);case Eo.code:throw new Eo(t);case Po.code:throw new Po(t);case ko.code:throw new ko(t);case 5e3:throw new fo(t);default:if(e instanceof He)throw e;throw new Ao(t)}}},{delay:({count:e,error:t})=>{if(t&&t instanceof Yr){const e=t?.headers?.get("Retry-After");if(e?.match(/\d/))return 1e3*Number.parseInt(e,10)}return(1<<e)*a},retryCount:i,shouldRetry:({error:e})=>function(e){if("code"in e&&"number"==typeof e.code)return-1===e.code||(e.code===uo.code||e.code===ro.code);if(e instanceof Yr&&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:o,id:o?jt(`${c}.${Ir(n)}`):void 0})}}class Yc extends He{constructor({callbackSelector:e,cause:t,data:n,extraData:r,sender:o,urls:s}){super(t.shortMessage||"An error occurred while fetching for an offchain result.",{cause:t,metaMessages:[...t.metaMessages||[],t.metaMessages?.length?"":[],"Offchain Gateway Call:",s&&[" Gateway URL(s):",...s.map(e=>` ${e}`)],` Sender: ${o}`,` Data: ${n}`,` Callback selector: ${e}`,` Extra data: ${r}`].flat(),name:"OffchainLookupError"})}}class Zc extends He{constructor({result:e,url:t}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${t}`,`Response: ${Ir(e)}`],name:"OffchainLookupResponseMalformedError"})}}class Kc extends He{constructor({sender:e,to:t}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${t}`,`OffchainLookup sender address: ${e}`],name:"OffchainLookupSenderMismatchError"})}}const Jc={name:"OffchainLookup",type:"error",inputs:[{name:"sender",type:"address"},{name:"urls",type:"string[]"},{name:"callData",type:"bytes"},{name:"callbackFunction",type:"bytes4"},{name:"extraData",type:"bytes"}]};async function Qc({data:e,sender:t,urls:n}){let r=new Error("An unknown error occurred.");for(let o=0;o<n.length;o++){const s=n[o],a=s.includes("{data}")?"GET":"POST",i="POST"===a?{data:e,sender:t}:void 0,c="POST"===a?{"Content-Type":"application/json"}:{};try{const n=await fetch(s.replace("{sender}",t.toLowerCase()).replace("{data}",e),{body:JSON.stringify(i),headers:c,method:a});let o;if(o=n.headers.get("Content-Type")?.startsWith("application/json")?(await n.json()).data:await n.text(),!n.ok){r=new Yr({body:i,details:o?.error?Ir(o.error):n.statusText,headers:n.headers,status:n.status,url:s});continue}if(!De(o)){r=new Zc({result:o,url:s});continue}return o}catch(e){r=new Yr({body:i,details:e.message,url:s})}}throw r}var Xc=Object.freeze({__proto__:null,ccipRequest:Qc,offchainLookup:async function(e,{blockNumber:t,blockTag:n,data:r,to:o}){const{args:s}=Ar({data:r,abi:[Jc]}),[a,i,c,u,l]=s,{ccipRead:d}=e,f=d&&"function"==typeof d?.request?d.request:Qc;try{if(!Fs(o,a))throw new Kc({sender:a,to:o});const r=i.includes(yc)?await wc({data:c,ccipRequest:f}):await f({data:c,sender:a,urls:i}),{data:s}=await Hi(e,{blockNumber:t,blockTag:n,data:jn([u,Hn([{type:"bytes"},{type:"bytes"}],[r,l])]),to:o});return s}catch(e){throw new Yc({callbackSelector:u,cause:e,data:r,extraData:l,sender:a,urls:i})}},offchainLookupAbiItem:Jc,offchainLookupSignature:"0x556f1830"});function eu(){return{current:0,take(){return this.current++},reset(){this.current=0}}}const tu=eu();function nu(e,t={}){return{async request(n){const{body:r,fetchFn:o=t.fetchFn??fetch,onRequest:s=t.onRequest,onResponse:a=t.onResponse,timeout:i=t.timeout??1e4}=n,c={...t.fetchOptions??{},...n.fetchOptions??{}},{headers:u,method:l,signal:d}=c;try{const t=await function(e,{errorInstance:t=new Error("timed out"),timeout:n,signal:r}){return new Promise((o,s)=>{(async()=>{let a;try{const t=new AbortController;n>0&&(a=setTimeout(()=>{r&&t.abort()},n)),o(await e({signal:t?.signal||null}))}catch(e){"AbortError"===e?.name&&s(t),s(e)}finally{clearTimeout(a)}})()})}(async({signal:t})=>{const n={...c,body:Array.isArray(r)?Ir(r.map(e=>({jsonrpc:"2.0",id:e.id??tu.take(),...e}))):Ir({jsonrpc:"2.0",id:r.id??tu.take(),...r}),headers:{"Content-Type":"application/json",...u},method:l||"POST",signal:d||(i>0?t:null)},a=new Request(e,n),f=await(s?.(a,n))??{...n,url:e};return await o(f.url??e,f)},{errorInstance:new Kr({body:r,url:e}),timeout:i,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 Yr({body:r,details:Ir(n.error)||t.statusText,headers:t.headers,status:t.status,url:e});return n}catch(t){if(t instanceof Yr)throw t;if(t instanceof Kr)throw t;throw new Yr({body:r,cause:t,url:e})}}}}function ru(e,t){return In(function(e){const t="string"==typeof e?jt(e):"string"==typeof e.raw?e.raw:_t(e.raw);return jn([jt(`Ethereum Signed Message:\n${Ge(t)}`),t])}(e),t)}class ou extends He{constructor({domain:e}){super(`Invalid domain "${Ir(e)}".`,{metaMessages:["Must be a valid EIP-712 domain."]})}}class su extends He{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 au extends He{constructor({type:e}){super(`Struct type "${e}" is invalid.`,{metaMessages:["Struct type must not be a Solidity type."],name:"InvalidStructTypeError"})}}function iu({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 cu(e){if("address"===e||"bool"===e||"string"===e||e.startsWith("bytes")||e.startsWith("uint")||e.startsWith("int"))throw new au({type:e})}function uu(e){const{domain:t={},message:n,primaryType:r}=e,o={EIP712Domain:iu({domain:t}),...e.types};!function(e){const{domain:t,message:n,primaryType:r,types:o}=e,s=(e,t)=>{for(const n of e){const{name:e,type:r}=n,a=t[e],i=r.match(Wn);if(i&&("number"==typeof a||"bigint"==typeof a)){const[e,t,n]=i;Mt(a,{signed:"int"===t,size:Number.parseInt(n,10)/8})}if("address"===r&&"string"==typeof a&&!Fn(a))throw new Bn({address:a});const c=r.match(Vn);if(c){const[e,t]=c;if(t&&Ge(a)!==Number.parseInt(t,10))throw new ft({expectedSize:Number.parseInt(t,10),givenSize:Ge(a)})}const u=o[r];u&&(cu(r),s(u,a))}};if(o.EIP712Domain&&t){if("object"!=typeof t)throw new ou({domain:t});s(o.EIP712Domain,t)}if("EIP712Domain"!==r){if(!o[r])throw new su({primaryType:r,types:o});s(o[r],n)}}({domain:t,message:n,primaryType:r,types:o});const s=["0x1901"];return t&&s.push(function({domain:e,types:t}){return lu({data:e,primaryType:"EIP712Domain",types:t})}({domain:t,types:o})),"EIP712Domain"!==r&&s.push(lu({data:n,primaryType:r,types:o})),In(jn(s))}function lu({data:e,primaryType:t,types:n}){return In(du({data:e,primaryType:t,types:n}))}function du({data:e,primaryType:t,types:n}){const r=[{type:"bytes32"}],o=[fu({primaryType:t,types:n})];for(const s of n[t]){const[t,a]=pu({types:n,name:s.name,type:s.type,value:e[s.name]});r.push(t),o.push(a)}return Hn(r,o)}function fu({primaryType:e,types:t}){const n=Rt(function({primaryType:e,types:t}){let n="";const r=hu({primaryType:e,types:t});r.delete(e);const o=[e,...Array.from(r).sort()];for(const e of o)n+=`${e}(${t[e].map(({name:e,type:t})=>`${t} ${e}`).join(",")})`;return n}({primaryType:e,types:t}));return In(n)}function hu({primaryType:e,types:t},n=new Set){const r=e.match(/^\w*/u),o=r?.[0];if(n.has(o)||void 0===t[o])return n;n.add(o);for(const e of t[o])hu({primaryType:e.type,types:t},n);return n}function pu({types:e,name:t,type:n,value:r}){if(void 0!==e[n])return[{type:"bytes32"},In(du({data:r,primaryType:n,types:e}))];if("bytes"===n){return[{type:"bytes32"},In(r=`0x${(r.length%2?"0":"")+r.slice(2)}`)]}if("string"===n)return[{type:"bytes32"},In(Rt(r))];if(n.lastIndexOf("]")===n.length-1){const o=n.slice(0,n.lastIndexOf("[")),s=r.map(n=>pu({name:t,type:o,types:e,value:n}));return[{type:"bytes32"},In(Hn(s.map(([e])=>e),s.map(([,e])=>e)))]}return[{type:n},r]}class mu 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 gu={checksum:new mu(8192)}.checksum;function bu(e,t={}){const{as:n=("string"==typeof e?"Hex":"Bytes")}=t,r=An(Ga(e));return"Bytes"===n?r:ai(r)}const yu=/^0x[a-fA-F0-9]{40}$/;function wu(e,t={}){const{strict:n=!0}=t;if(!yu.test(e))throw new Eu({address:e,cause:new Pu});if(n){if(e.toLowerCase()===e)return;if(vu(e)!==e)throw new Eu({address:e,cause:new ku})}}function vu(e){if(gu.has(e))return gu.get(e);wu(e,{strict:!1});const t=e.substring(2).toLowerCase(),n=bu(Va(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 o=`0x${r.join("")}`;return gu.set(e,o),o}function xu(e,t={}){const{strict:n=!0}=t??{};try{return wu(e,{strict:n}),!0}catch{return!1}}class Eu extends Na{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 Pu extends Na{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 ku extends Na{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}const Au=/^(.*)\[([0-9]*)\]$/,Iu=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Nu=/^(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)?$/,Su=2n**256n-1n;function Tu(e,t,n){const{checksumAddress:r,staticPosition:o}=n,s=Ru(t.type);if(s){const[n,a]=s;return function(e,t,n){const{checksumAddress:r,length:o,staticPosition:s}=n;if(!o){const n=s+Ka(e.readBytes(Bu)),o=n+$u;e.setPosition(n);const a=Ka(e.readBytes($u)),i=zu(t);let c=0;const u=[];for(let n=0;n<a;++n){e.setPosition(o+(i?32*n:c));const[s,a]=Tu(e,t,{checksumAddress:r,staticPosition:o});c+=a,u.push(s)}return e.setPosition(s+32),[u,32]}if(zu(t)){const n=s+Ka(e.readBytes(Bu)),a=[];for(let s=0;s<o;++s){e.setPosition(n+32*s);const[o]=Tu(e,t,{checksumAddress:r,staticPosition:n});a.push(o)}return e.setPosition(s+32),[a,32]}let a=0;const i=[];for(let n=0;n<o;++n){const[n,o]=Tu(e,t,{checksumAddress:r,staticPosition:s+a});a+=o,i.push(n)}return[i,a]}(e,{...t,type:a},{checksumAddress:r,length:n,staticPosition:o})}if("tuple"===t.type)return function(e,t,n){const{checksumAddress:r,staticPosition:o}=n,s=0===t.components.length||t.components.some(({name:e})=>!e),a=s?[]:{};let i=0;if(zu(t)){const n=o+Ka(e.readBytes(Bu));for(let o=0;o<t.components.length;++o){const c=t.components[o];e.setPosition(n+i);const[u,l]=Tu(e,c,{checksumAddress:r,staticPosition:n});i+=l,a[s?o:c?.name]=u}return e.setPosition(o+32),[a,32]}for(let n=0;n<t.components.length;++n){const c=t.components[n],[u,l]=Tu(e,c,{checksumAddress:r,staticPosition:o});a[s?n:c?.name]=u,i+=l}return[a,i]}(e,t,{checksumAddress:r,staticPosition:o});if("address"===t.type)return function(e,t={}){const{checksum:n=!1}=t,r=e.readBytes(32),o=e=>n?vu(e):e;return[o(ai(Ha(r,-20))),32]}(e,{checksum:r});if("bool"===t.type)return function(e){return[Za(e.readBytes(32),{size:32}),32]}(e);if(t.type.startsWith("bytes"))return function(e,t,{staticPosition:n}){const[r,o]=t.type.split("bytes");if(!o){const t=Ka(e.readBytes(32));e.setPosition(n+t);const r=Ka(e.readBytes(32));if(0===r)return e.setPosition(n+32),["0x",32];const o=e.readBytes(r);return e.setPosition(n+32),[ai(o),32]}const s=ai(e.readBytes(Number.parseInt(o,10),32));return[s,32]}(e,t,{staticPosition:o});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),o=e.readBytes(32);return[r>48?Ya(o,{signed:n}):Ka(o,{signed:n}),32]}(e,t);if("string"===t.type)return function(e,{staticPosition:t}){const n=Ka(e.readBytes(32)),r=t+n;e.setPosition(r);const o=Ka(e.readBytes(32));if(0===o)return e.setPosition(t+32),["",32];const s=e.readBytes(o,32),a=Ja(Qa(s));return e.setPosition(t+32),[a,32]}(e,{staticPosition:o});throw new Ku(t.type)}const $u=32,Bu=32;function Cu({checksumAddress:e=!1,parameter:t,value:n}){const r=t,o=Ru(r.type);if(o){const[t,s]=o;return function(e,t){const{checksumAddress:n,length:r,parameter:o}=t,s=null===r;if(!Array.isArray(e))throw new Zu(e);if(!s&&e.length!==r)throw new Wu({expectedLength:r,givenLength:e.length,type:`${o.type}[${r}]`});let a=!1;const i=[];for(let t=0;t<e.length;t++){const r=Cu({checksumAddress:n,parameter:o,value:e[t]});r.dynamic&&(a=!0),i.push(r)}if(s||a){const e=Ou(i);if(s){const t=ii(i.length,{size:32});return{dynamic:!0,encoded:i.length>0?oi(t,e):t}}if(a)return{dynamic:!0,encoded:e}}return{dynamic:!1,encoded:oi(...i.map(({encoded:e})=>e))}}(n,{checksumAddress:e,length:t,parameter:{...r,type:s}})}if("tuple"===r.type)return function(e,t){const{checksumAddress:n,parameter:r}=t;let o=!1;const s=[];for(let t=0;t<r.components.length;t++){const a=r.components[t],i=Cu({checksumAddress:n,parameter:a,value:e[Array.isArray(e)?t:a.name]});s.push(i),i.dynamic&&(o=!0)}return{dynamic:o,encoded:o?Ou(s):oi(...s.map(({encoded:e})=>e))}}(n,{checksumAddress:e,parameter:r});if("address"===r.type)return function(e,t){const{checksum:n=!1}=t;return wu(e,{strict:n}),{dynamic:!1,encoded:ui(e.toLowerCase())}}(n,{checksum:e});if("bool"===r.type)return function(e){if("boolean"!=typeof e)throw new Na(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:ui(si(e))}}(n);if(r.type.startsWith("uint")||r.type.startsWith("int")){const e=r.type.startsWith("int"),[,,t="256"]=Nu.exec(r.type)??[];return function(e,{signed:t,size:n}){if("number"==typeof n){const r=2n**(BigInt(n)-(t?1n:0n))-1n,o=t?-r-1n:0n;if(e>r||e<o)throw new gi({max:r.toString(),min:o.toString(),signed:t,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:ii(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=fi(e);if(!n){let t=e;return r%32!=0&&(t=li(t,32*Math.ceil((e.length-2)/2/32))),{dynamic:!0,encoded:oi(ui(ii(r,{size:32})),t)}}if(r!==Number.parseInt(n,10))throw new Hu({expectedSize:Number.parseInt(n,10),value:e});return{dynamic:!1,encoded:li(e)}}(n,{type:r.type});if("string"===r.type)return function(e){const t=ci(e),n=Math.ceil(fi(t)/32),r=[];for(let e=0;e<n;e++)r.push(li(di(t,32*e,32*(e+1))));return{dynamic:!0,encoded:oi(li(ii(fi(t),{size:32})),...r)}}(n);throw new Ku(r.type)}function Ou(e){let t=0;for(let n=0;n<e.length;n++){const{dynamic:r,encoded:o}=e[n];t+=r?32:fi(o)}const n=[],r=[];let o=0;for(let s=0;s<e.length;s++){const{dynamic:a,encoded:i}=e[s];a?(n.push(ii(t+o,{size:32})),r.push(i),o+=fi(i)):n.push(i)}return oi(...n,...r)}function Ru(e){const t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}function zu(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(zu);const n=Ru(e.type);return!(!n||!zu({...e,type:n[1]}))}const _u={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 ju({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new Fu({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new Mu({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 Mu({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 Mu extends Na{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.NegativeOffsetError"})}}class Fu extends Na{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 ju extends Na{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 Lu(e,t,n={}){const{as:r="Array",checksumAddress:o=!1}=n,s="string"==typeof t?qa(t):t,a=function(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(_u);return n.bytes=e,n.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=t,n}(s);if(0===Wa(s)&&e.length>0)throw new Vu;if(Wa(s)&&Wa(s)<32)throw new qu({data:"string"==typeof t?t:ai(t),parameters:e,size:Wa(s)});let i=0;const c="Array"===r?[]:{};for(let t=0;t<e.length;++t){const n=e[t];a.setPosition(i);const[s,u]=Tu(a,n,{checksumAddress:o,staticPosition:0});i+=u,"Array"===r?c.push(s):c[n.name??t]=s}return c}function Uu(e,t,n){const{checksumAddress:r=!1}={};if(e.length!==t.length)throw new Yu({expectedLength:e.length,givenLength:t.length});const o=function({checksumAddress:e,parameters:t,values:n}){const r=[];for(let o=0;o<t.length;o++)r.push(Cu({checksumAddress:e,parameter:t[o],value:n[o]}));return r}({checksumAddress:r,parameters:e,values:t}),s=Ou(o);return 0===s.length?"0x":s}function Du(e,t){if(e.length!==t.length)throw new Yu({expectedLength:e.length,givenLength:t.length});const n=[];for(let r=0;r<e.length;r++){const o=e[r],s=t[r];n.push(Du.encode(o,s))}return oi(...n)}function Gu(e){return Array.isArray(e)&&"string"==typeof e[0]||"string"==typeof e?Fe(e):e}!function(e){e.encode=function e(t,n,r=!1){if("address"===t){const e=n;return wu(e),ui(e.toLowerCase(),r?32:0)}if("string"===t)return ci(n);if("bytes"===t)return n;if("bool"===t)return ui(si(n),r?32:1);const o=t.match(Nu);if(o){const[e,t,s="256"]=o,a=Number.parseInt(s,10)/8;return ii(n,{size:r?32:a,signed:"int"===t})}const s=t.match(Iu);if(s){const[e,t]=s;if(Number.parseInt(t,10)!==(n.length-2)/2)throw new Hu({expectedSize:Number.parseInt(t,10),value:n});return li(n,r?32:0)}const a=t.match(Au);if(a&&Array.isArray(n)){const[t,r]=a,o=[];for(let t=0;t<n.length;t++)o.push(e(r,n[t],!0));return 0===o.length?"0x":oi(...o)}throw new Ku(t)}}(Du||(Du={}));class qu extends Na{constructor({data:e,parameters:t,size:n}){super(`Data size of ${n} bytes is too small for given parameters.`,{metaMessages:[`Params: (${K(t)})`,`Data: ${e} (${n} bytes)`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.DataSizeTooSmallError"})}}class Vu extends Na{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.'),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ZeroDataError"})}}class Wu extends Na{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 Hu extends Na{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${fi(t)}) does not match expected size (bytes${e}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.BytesSizeMismatchError"})}}class Yu extends Na{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 Zu extends Na{constructor(e){super(`Value \`${e}\` is not a valid array.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidArrayError"})}}class Ku extends Na{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 Ju extends an{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");Kt(e.outputLen),Kt(e.blockLen)}(e);const n=sn(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,o=new Uint8Array(r);o.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<o.length;e++)o[e]^=54;this.iHash.update(o),this.oHash=e.create();for(let e=0;e<o.length;e++)o[e]^=106;this.oHash.update(o),en(o)}update(e){return Qt(this),this.iHash.update(e),this}digestInto(e){Qt(this),Jt(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:o,blockLen:s,outputLen:a}=this;return e.finished=r,e.destroyed=o,e.blockLen=s,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 Qu=(e,t,n)=>new Ju(e,t).update(n).digest();Qu.create=(e,t)=>new Ju(e,t);
|
|
5
5
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
6
|
-
const
|
|
6
|
+
const Xu=BigInt(0),el=BigInt(1),tl=BigInt(2),nl=BigInt(3),rl=BigInt(4),ol=BigInt(5),sl=BigInt(8);function al(e,t){const n=e%t;return n>=Xu?n:t+n}function il(e,t,n){let r=e;for(;t-- >Xu;)r*=r,r%=n;return r}function cl(e,t){if(e===Xu)throw new Error("invert: expected non-zero number");if(t<=Xu)throw new Error("invert: expected positive modulus, got "+t);let n=al(e,t),r=t,o=Xu,s=el;for(;n!==Xu;){const e=r%n,t=o-s*(r/n);r=n,n=e,o=s,s=t}if(r!==el)throw new Error("invert: does not exist");return al(o,t)}function ul(e,t){const n=(e.ORDER+el)/rl,r=e.pow(t,n);if(!e.eql(e.sqr(r),t))throw new Error("Cannot find square root");return r}function ll(e,t){const n=(e.ORDER-ol)/sl,r=e.mul(t,tl),o=e.pow(r,n),s=e.mul(t,o),a=e.mul(e.mul(s,tl),o),i=e.mul(s,e.sub(a,e.ONE));if(!e.eql(e.sqr(i),t))throw new Error("Cannot find square root");return i}function dl(e){return e%rl===nl?ul:e%sl===ol?ll:function(e){if(e<BigInt(3))throw new Error("sqrt is not defined for small field");let t=e-el,n=0;for(;t%tl===Xu;)t/=tl,n++;let r=tl;const o=gl(e);for(;1===pl(o,r);)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return ul;let s=o.pow(r,t);const a=(t+el)/tl;return function(e,r){if(e.is0(r))return r;if(1!==pl(e,r))throw new Error("Cannot find square root");let o=n,i=e.mul(e.ONE,s),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===o)throw new Error("Cannot find square root");const r=el<<BigInt(o-t-1),s=e.pow(i,r);o=t,i=e.sqr(s),c=e.mul(c,i),u=e.mul(u,s)}return u}}(e)}const fl=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function hl(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),o=t.reduce((t,n,o)=>e.is0(n)?t:(r[o]=t,e.mul(t,n)),e.ONE),s=e.inv(o);return t.reduceRight((t,n,o)=>e.is0(n)?t:(r[o]=e.mul(t,r[o]),e.mul(t,n)),s),r}function pl(e,t){const n=(e.ORDER-el)/tl,r=e.pow(t,n),o=e.eql(r,e.ONE),s=e.eql(r,e.ZERO),a=e.eql(r,e.neg(e.ONE));if(!o&&!s&&!a)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function ml(e,t){void 0!==t&&Kt(t);const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function gl(e,t,n=!1,r={}){if(e<=Xu)throw new Error("invalid field: expected ORDER > 0, got "+e);const{nBitLength:o,nByteLength:s}=ml(e,t);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let a;const i=Object.freeze({ORDER:e,isLE:n,BITS:o,BYTES:s,MASK:xa(o),ZERO:Xu,ONE:el,create:t=>al(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return Xu<=t&&t<e},is0:e=>e===Xu,isOdd:e=>(e&el)===el,neg:t=>al(-t,e),eql:(e,t)=>e===t,sqr:t=>al(t*t,e),add:(t,n)=>al(t+n,e),sub:(t,n)=>al(t-n,e),mul:(t,n)=>al(t*n,e),pow:(e,t)=>function(e,t,n){if(n<Xu)throw new Error("invalid exponent, negatives unsupported");if(n===Xu)return e.ONE;if(n===el)return t;let r=e.ONE,o=t;for(;n>Xu;)n&el&&(r=e.mul(r,o)),o=e.sqr(o),n>>=el;return r}(i,e,t),div:(t,n)=>al(t*cl(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>cl(t,e),sqrt:r.sqrt||(t=>(a||(a=dl(e)),a(i,t))),toBytes:e=>n?ma(e,s):pa(e,s),fromBytes:e=>{if(e.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+e.length);return n?ha(e):fa(e)},invertBatch:e=>hl(i,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(i)}function bl(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 yl(e){const t=bl(e);return t+Math.ceil(t/2)}
|
|
7
7
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
8
|
-
const
|
|
9
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Tl(e){void 0!==e.lowS&&Js("lowS",e.lowS),void 0!==e.prehash&&Js("prehash",e.prehash)}class $l extends Error{constructor(e=""){super(e)}}const Bl={Err:$l,_tlv:{encode:(e,t)=>{const{Err:n}=Bl;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,o=Qs(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");const s=r>127?Qs(o.length/2|128):"";return Qs(e)+s+o+t},decode(e,t){const{Err:n}=Bl;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 o=t[r++];let s=0;if(!!(128&o)){const e=127&o;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)s=s<<8|e;if(r+=e,s<128)throw new n("tlv.decode(long): not minimal encoding")}else s=o;const a=t.subarray(r,r+s);if(a.length!==s)throw new n("tlv.decode: wrong value length");return{v:a,l:t.subarray(r+s)}}},_int:{encode(e){const{Err:t}=Bl;if(e<Ol)throw new t("integer: negative integers are not allowed");let n=Qs(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}=Bl;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 da(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=Bl,o=ma("signature",e),{v:s,l:a}=r.decode(48,o);if(a.length)throw new t("invalid signature: left bytes after parsing");const{v:i,l:c}=r.decode(2,s),{v:u,l:l}=r.decode(2,c);if(l.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(i),s:n.decode(u)}},hexFromSig(e){const{_tlv:t,_int:n}=Bl,r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}};function Cl(e,t){return na(ha(e,t))}const Ol=BigInt(0),Rl=BigInt(1);BigInt(2);const zl=BigInt(3),_l=BigInt(4);function Ml(e){const t=function(e){const t=Sl(e);ka(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:o}=t;if(n){if(!r.eql(o,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=ml(t.n,t.nBitLength),o=t.toBytes||((e,t,r)=>{const o=t.toAffine();return ga(Uint8Array.from([4]),n.toBytes(o.x),n.toBytes(o.y))}),s=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:o}=t,s=n.sqr(e),a=n.mul(s,e);return n.add(n.add(a,n.mul(e,r)),o)}function i(e,t){const r=n.sqr(t),o=a(e);return n.eql(r,o)}if(!i(t.Gx,t.Gy))throw new Error("bad curve params: generator point");const c=n.mul(n.pow(t.a,zl),_l),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 l(e){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:o,n:s}=t;if(n&&"bigint"!=typeof e){if(Zs(e)&&(e=na(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:da(ma("private key",e,r))}catch(t){throw new Error("invalid private key, expected hex or "+r+" bytes, got "+typeof e)}return o&&(a=sl(a,s)),wa("private key",a,Rl,s),a}function d(e){if(!(e instanceof p))throw new Error("ProjectivePoint expected")}const f=Aa((e,t)=>{const{px:r,py:o,pz:s}=e;if(n.eql(s,n.ONE))return{x:r,y:o};const a=e.is0();null==t&&(t=a?n.ONE:n.inv(s));const i=n.mul(r,t),c=n.mul(o,t),u=n.mul(s,t);if(a)return{x:n.ZERO,y:n.ZERO};if(!n.eql(u,n.ONE))throw new Error("invZ was invalid");return{x:i,y:c}}),h=Aa(e=>{if(e.is0()){if(t.allowInfinityPoint&&!n.is0(e.py))return;throw new Error("bad point: ZERO")}const{x:r,y:o}=e.toAffine();if(!n.isValid(r)||!n.isValid(o))throw new Error("bad point: x or y not FE");if(!i(r,o))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class p{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 p)throw new Error("projective point not allowed");const o=e=>n.eql(e,n.ZERO);return o(t)&&o(r)?p.ZERO:new p(t,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=fl(n,e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(p.fromAffine)}static fromHex(e){const t=p.fromAffine(s(ma("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return p.BASE.multiply(l(e))}static msm(e,t){return Nl(p,r,e,t)}_setWindowSize(e){b.setWindowSize(this,e)}assertValidity(){h(this)}hasEvenY(){const{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){d(e);const{px:t,py:r,pz:o}=this,{px:s,py:a,pz:i}=e,c=n.eql(n.mul(t,i),n.mul(s,o)),u=n.eql(n.mul(r,i),n.mul(a,o));return c&&u}negate(){return new p(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:r}=t,o=n.mul(r,zl),{px:s,py:a,pz:i}=this;let c=n.ZERO,u=n.ZERO,l=n.ZERO,d=n.mul(s,s),f=n.mul(a,a),h=n.mul(i,i),m=n.mul(s,a);return m=n.add(m,m),l=n.mul(s,i),l=n.add(l,l),c=n.mul(e,l),u=n.mul(o,h),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),l=n.mul(o,l),h=n.mul(e,h),m=n.sub(d,h),m=n.mul(e,m),m=n.add(m,l),l=n.add(d,d),d=n.add(l,d),d=n.add(d,h),d=n.mul(d,m),u=n.add(u,d),h=n.mul(a,i),h=n.add(h,h),d=n.mul(h,m),c=n.sub(c,d),l=n.mul(h,f),l=n.add(l,l),l=n.add(l,l),new p(c,u,l)}add(e){d(e);const{px:r,py:o,pz:s}=this,{px:a,py:i,pz:c}=e;let u=n.ZERO,l=n.ZERO,f=n.ZERO;const h=t.a,m=n.mul(t.b,zl);let g=n.mul(r,a),b=n.mul(o,i),y=n.mul(s,c),w=n.add(r,o),v=n.add(a,i);w=n.mul(w,v),v=n.add(g,b),w=n.sub(w,v),v=n.add(r,s);let x=n.add(a,c);return v=n.mul(v,x),x=n.add(g,y),v=n.sub(v,x),x=n.add(o,s),u=n.add(i,c),x=n.mul(x,u),u=n.add(b,y),x=n.sub(x,u),f=n.mul(h,v),u=n.mul(m,y),f=n.add(u,f),u=n.sub(b,f),f=n.add(b,f),l=n.mul(u,f),b=n.add(g,g),b=n.add(b,g),y=n.mul(h,y),v=n.mul(m,v),b=n.add(b,y),y=n.sub(g,y),y=n.mul(h,y),v=n.add(v,y),g=n.mul(b,v),l=n.add(l,g),g=n.mul(x,v),u=n.mul(w,u),u=n.sub(u,g),g=n.mul(w,b),f=n.mul(x,f),f=n.add(f,g),new p(u,l,f)}subtract(e){return this.add(e.negate())}is0(){return this.equals(p.ZERO)}wNAF(e){return b.wNAFCached(this,e,p.normalizeZ)}multiplyUnsafe(e){const{endo:r,n:o}=t;wa("scalar",e,Ol,o);const s=p.ZERO;if(e===Ol)return s;if(this.is0()||e===Rl)return this;if(!r||b.hasPrecomputes(this))return b.wNAFCachedUnsafe(this,e,p.normalizeZ);let{k1neg:a,k1:i,k2neg:c,k2:u}=r.splitScalar(e),l=s,d=s,f=this;for(;i>Ol||u>Ol;)i&Rl&&(l=l.add(f)),u&Rl&&(d=d.add(f)),f=f.double(),i>>=Rl,u>>=Rl;return a&&(l=l.negate()),c&&(d=d.negate()),d=new p(n.mul(d.px,r.beta),d.py,d.pz),l.add(d)}multiply(e){const{endo:r,n:o}=t;let s,a;if(wa("scalar",e,Rl,o),r){const{k1neg:t,k1:o,k2neg:i,k2:c}=r.splitScalar(e);let{p:u,f:l}=this.wNAF(o),{p:d,f:f}=this.wNAF(c);u=b.constTimeNegate(t,u),d=b.constTimeNegate(i,d),d=new p(n.mul(d.px,r.beta),d.py,d.pz),s=u.add(d),a=l.add(f)}else{const{p:t,f:n}=this.wNAF(e);s=t,a=n}return p.normalizeZ([s,a])[0]}multiplyAndAddUnsafe(e,t,n){const r=p.BASE,o=(e,t)=>t!==Ol&&t!==Rl&&e.equals(r)?e.multiply(t):e.multiplyUnsafe(t),s=o(this,t).add(o(e,n));return s.is0()?void 0:s}toAffine(e){return f(this,e)}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e===Rl)return!0;if(n)return n(p,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:n}=t;return e===Rl?this:n?n(p,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return Js("isCompressed",e),this.assertValidity(),o(p,this,e)}toHex(e=!0){return Js("isCompressed",e),na(this.toRawBytes(e))}}p.BASE=new p(t.Gx,t.Gy,n.ONE),p.ZERO=new p(n.ZERO,n.ONE,n.ZERO);const{endo:m,nBitLength:g}=t,b=(y=p,w=m?Math.ceil(g/2):g,{constTimeNegate:vl,hasPrecomputes:e=>1!==Il(e),unsafeLadder(e,t,n=y.ZERO){let r=e;for(;t>yl;)t&wl&&(n=n.add(r)),r=r.double(),t>>=wl;return n},precomputeWindow(e,t){const{windows:n,windowSize:r}=El(t,w),o=[];let s=e,a=s;for(let e=0;e<n;e++){a=s,o.push(a);for(let e=1;e<r;e++)a=a.add(s),o.push(a);s=a.double()}return o},wNAF(e,t,n){let r=y.ZERO,o=y.BASE;const s=El(e,w);for(let e=0;e<s.windows;e++){const{nextN:a,offset:i,isZero:c,isNeg:u,isNegF:l,offsetF:d}=Pl(n,e,s);n=a,c?o=o.add(vl(l,t[d])):r=r.add(vl(u,t[i]))}return{p:r,f:o}},wNAFUnsafe(e,t,n,r=y.ZERO){const o=El(e,w);for(let e=0;e<o.windows&&n!==yl;e++){const{nextN:s,offset:a,isZero:i,isNeg:c}=Pl(n,e,o);if(n=s,!i){const e=t[a];r=r.add(c?e.negate():e)}}return r},getPrecomputes(e,t,n){let r=kl.get(t);return r||(r=this.precomputeWindow(t,e),1!==e&&kl.set(t,n(r))),r},wNAFCached(e,t,n){const r=Il(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)},wNAFCachedUnsafe(e,t,n,r){const o=Il(e);return 1===o?this.unsafeLadder(e,t,r):this.wNAFUnsafe(o,this.getPrecomputes(o,e,n),t,r)},setWindowSize(e,t){xl(t,w),Al.set(e,t),kl.delete(e)}});var y,w;return{CURVE:t,ProjectivePoint:p,normPrivateKeyToScalar:l,weierstrassEquation:a,isWithinCurveOrder:function(e){return ya(e,Rl,t.n)}}}function Fl(e){const t=function(e){const t=Sl(e);return ka(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:o,nBitLength:s}=t,a=n.BYTES+1,i=2*n.BYTES+1;function c(e){return sl(e,r)}function u(e){return il(e,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:d,weierstrassEquation:f,isWithinCurveOrder:h}=Ml({...t,toBytes(e,t,r){const o=t.toAffine(),s=n.toBytes(o.x),a=ga;return Js("isCompressed",r),r?a(Uint8Array.from([t.hasEvenY()?2:3]),s):a(Uint8Array.from([4]),s,n.toBytes(o.y))},fromBytes(e){const t=e.length,r=e[0],o=e.subarray(1);if(t!==a||2!==r&&3!==r){if(t===i&&4===r){return{x:n.fromBytes(o.subarray(0,n.BYTES)),y:n.fromBytes(o.subarray(n.BYTES,2*n.BYTES))}}throw new Error("invalid Point, expected length of "+a+", or uncompressed "+i+", got "+t)}{const e=da(o);if(!ya(e,Rl,n.ORDER))throw new Error("Point is not on curve");const t=f(e);let s;try{s=n.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("Point is not on curve"+t)}return!(1&~r)!==((s&Rl)===Rl)&&(s=n.neg(s)),{x:e,y:s}}}});function p(e){return e>r>>Rl}const m=(e,t,n)=>da(e.slice(t,n));class g{constructor(e,t,n){wa("r",e,Rl,r),wa("s",t,Rl,r),this.r=e,this.s=t,null!=n&&(this.recovery=n),Object.freeze(this)}static fromCompact(e){const t=o;return e=ma("compactSignature",e,2*t),new g(m(e,0,t),m(e,t,2*t))}static fromDER(e){const{r:t,s:n}=Bl.toSig(ma("DER",e));return new g(t,n)}assertValidity(){}addRecoveryBit(e){return new g(this.r,this.s,e)}recoverPublicKey(e){const{r:r,s:o,recovery:s}=this,a=v(ma("msgHash",e));if(null==s||![0,1,2,3].includes(s))throw new Error("recovery id invalid");const i=2===s||3===s?r+t.n:r;if(i>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const d=1&s?"03":"02",f=l.fromHex(d+Cl(i,n.BYTES)),h=u(i),p=c(-a*h),m=c(o*h),g=l.BASE.multiplyAndAddUnsafe(f,p,m);if(!g)throw new Error("point at infinify");return g.assertValidity(),g}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return la(this.toDERHex())}toDERHex(){return Bl.hexFromSig(this)}toCompactRawBytes(){return la(this.toCompactHex())}toCompactHex(){const e=o;return Cl(this.r,e)+Cl(this.s,e)}}const b={isValidPrivateKey(e){try{return d(e),!0}catch(e){return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{const e=bl(t.n);return function(e,t,n=!1){const r=e.length,o=gl(t),s=bl(t);if(r<16||r<s||r>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+r);const a=sl(n?fa(e):da(e),t-Xu)+Xu;return n?pa(a,o):ha(a,o)}(t.randomBytes(e),t.n)},precompute:(e=8,t=l.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function y(e){if("bigint"==typeof e)return!1;if(e instanceof l)return!0;const r=ma("key",e).length,s=n.BYTES,a=s+1,i=2*s+1;return t.allowedPrivateKeyLengths||o===a?void 0:r===a||r===i}const w=t.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=da(e),n=8*e.length-s;return n>0?t>>BigInt(n):t},v=t.bits2int_modN||function(e){return c(w(e))},x=va(s);function E(e){return wa("num < 2^"+s,e,Ol,x),ha(e,o)}function P(e,r,o=k){if(["recovered","canonical"].some(e=>e in o))throw new Error("sign() legacy options not supported");const{hash:s,randomBytes:a}=t;let{lowS:i,prehash:f,extraEntropy:m}=o;null==i&&(i=!0),e=ma("msgHash",e),Tl(o),f&&(e=ma("prehashed msgHash",s(e)));const b=v(e),y=d(r),x=[E(y),E(b)];if(null!=m&&!1!==m){const e=!0===m?a(n.BYTES):m;x.push(ma("extraEntropy",e))}const P=ga(...x),A=b;return{seed:P,k2sig:function(e){const t=w(e);if(!h(t))return;const n=u(t),r=l.BASE.multiply(t).toAffine(),o=c(r.x);if(o===Ol)return;const s=c(n*c(A+o*y));if(s===Ol)return;let a=(r.x===o?0:2)|Number(r.y&Rl),d=s;return i&&p(s)&&(d=function(e){return p(e)?c(-e):e}(s),a^=1),new g(o,d,a)}}}const k={lowS:t.lowS,prehash:!1},A={lowS:t.lowS,prehash:!1};return l.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return l.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,n=!0){if(!0===y(e))throw new Error("first arg must be private key");if(!1===y(t))throw new Error("second arg must be public key");return l.fromHex(t).multiply(d(e)).toRawBytes(n)},sign:function(e,n,r=k){const{seed:o,k2sig:s}=P(e,n,r),a=t,i=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=xa(e),o=xa(e),s=0;const a=()=>{r.fill(1),o.fill(0),s=0},i=(...e)=>n(o,r,...e),c=(e=xa(0))=>{o=i(Ea([0]),e),r=i(),0!==e.length&&(o=i(Ea([1]),e),r=i())},u=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){r=i();const t=r.slice();n.push(t),e+=r.length}return ga(...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 i(o,s)},verify:function(e,n,r,o=A){const s=e;n=ma("msgHash",n),r=ma("publicKey",r);const{lowS:a,prehash:i,format:d}=o;if(Tl(o),"strict"in o)throw new Error("options.strict was renamed to lowS");if(void 0!==d&&"compact"!==d&&"der"!==d)throw new Error("format must be compact or der");const f="string"==typeof s||Zs(s),h=!f&&!d&&"object"==typeof s&&null!==s&&"bigint"==typeof s.r&&"bigint"==typeof s.s;if(!f&&!h)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let p,m;try{if(h&&(p=new g(s.r,s.s)),f){try{"compact"!==d&&(p=g.fromDER(s))}catch(e){if(!(e instanceof Bl.Err))throw e}p||"der"===d||(p=g.fromCompact(s))}m=l.fromHex(r)}catch(e){return!1}if(!p)return!1;if(a&&p.hasHighS())return!1;i&&(n=t.hash(n));const{r:b,s:y}=p,w=v(n),x=u(y),E=c(w*x),P=c(b*x),k=l.BASE.multiplyAndAddUnsafe(m,E,P)?.toAffine();return!!k&&c(k.x)===b},ProjectivePoint:l,Signature:g,utils:b}}
|
|
10
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function
|
|
8
|
+
const wl=BigInt(0),vl=BigInt(1);function xl(e,t){const n=t.negate();return e?n:t}function El(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Pl(e,t){El(e,t);const n=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:xa(e),maxNumber:n,shiftBy:BigInt(e)}}function kl(e,t,n){const{windowSize:r,mask:o,maxNumber:s,shiftBy:a}=n;let i=Number(e&o),c=e>>a;i>r&&(i-=s,c+=vl);const u=t*r;return{nextN:c,offset:u+Math.abs(i)-1,isZero:0===i,isNeg:i<0,isNegF:t%2!=0,offsetF:u}}const Al=new WeakMap,Il=new WeakMap;function Nl(e){return Il.get(e)||1}function Sl(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 o=n.length,s=r.length;if(o!==s)throw new Error("arrays of points and scalars must have equal length");const a=e.ZERO,i=function(e){let t;for(t=0;e>Ys;e>>=Zs,t+=1);return t}(BigInt(o));let c=1;i>12?c=i-3:i>4?c=i-2:i>0&&(c=2);const u=xa(c),l=new Array(Number(u)+1).fill(a);let d=a;for(let e=Math.floor((t.BITS-1)/c)*c;e>=0;e-=c){l.fill(a);for(let t=0;t<s;t++){const o=r[t],s=Number(o>>BigInt(e)&u);l[s]=l[s].add(n[t])}let t=a;for(let e=l.length-1,n=a;e>0;e--)n=n.add(l[e]),t=t.add(n);if(d=d.add(t),0!==e)for(let e=0;e<c;e++)d=d.double()}return d}function Tl(e){return Aa(e.Fp,fl.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"})),Aa(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...ml(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}
|
|
9
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function $l(e){void 0!==e.lowS&&Qs("lowS",e.lowS),void 0!==e.prehash&&Qs("prehash",e.prehash)}class Bl extends Error{constructor(e=""){super(e)}}const Cl={Err:Bl,_tlv:{encode:(e,t)=>{const{Err:n}=Cl;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,o=Xs(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");const s=r>127?Xs(o.length/2|128):"";return Xs(e)+s+o+t},decode(e,t){const{Err:n}=Cl;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 o=t[r++];let s=0;if(!!(128&o)){const e=127&o;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)s=s<<8|e;if(r+=e,s<128)throw new n("tlv.decode(long): not minimal encoding")}else s=o;const a=t.subarray(r,r+s);if(a.length!==s)throw new n("tlv.decode: wrong value length");return{v:a,l:t.subarray(r+s)}}},_int:{encode(e){const{Err:t}=Cl;if(e<Rl)throw new t("integer: negative integers are not allowed");let n=Xs(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}=Cl;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 fa(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=Cl,o=ga("signature",e),{v:s,l:a}=r.decode(48,o);if(a.length)throw new t("invalid signature: left bytes after parsing");const{v:i,l:c}=r.decode(2,s),{v:u,l:l}=r.decode(2,c);if(l.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(i),s:n.decode(u)}},hexFromSig(e){const{_tlv:t,_int:n}=Cl,r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}};function Ol(e,t){return ra(pa(e,t))}const Rl=BigInt(0),zl=BigInt(1);BigInt(2);const _l=BigInt(3),Ml=BigInt(4);function Fl(e){const t=function(e){const t=Tl(e);Aa(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:o}=t;if(n){if(!r.eql(o,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=gl(t.n,t.nBitLength),o=t.toBytes||((e,t,r)=>{const o=t.toAffine();return ba(Uint8Array.from([4]),n.toBytes(o.x),n.toBytes(o.y))}),s=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:o}=t,s=n.sqr(e),a=n.mul(s,e);return n.add(n.add(a,n.mul(e,r)),o)}function i(e,t){const r=n.sqr(t),o=a(e);return n.eql(r,o)}if(!i(t.Gx,t.Gy))throw new Error("bad curve params: generator point");const c=n.mul(n.pow(t.a,_l),Ml),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 l(e){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:o,n:s}=t;if(n&&"bigint"!=typeof e){if(Ks(e)&&(e=ra(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:fa(ga("private key",e,r))}catch(t){throw new Error("invalid private key, expected hex or "+r+" bytes, got "+typeof e)}return o&&(a=al(a,s)),va("private key",a,zl,s),a}function d(e){if(!(e instanceof p))throw new Error("ProjectivePoint expected")}const f=Ia((e,t)=>{const{px:r,py:o,pz:s}=e;if(n.eql(s,n.ONE))return{x:r,y:o};const a=e.is0();null==t&&(t=a?n.ONE:n.inv(s));const i=n.mul(r,t),c=n.mul(o,t),u=n.mul(s,t);if(a)return{x:n.ZERO,y:n.ZERO};if(!n.eql(u,n.ONE))throw new Error("invZ was invalid");return{x:i,y:c}}),h=Ia(e=>{if(e.is0()){if(t.allowInfinityPoint&&!n.is0(e.py))return;throw new Error("bad point: ZERO")}const{x:r,y:o}=e.toAffine();if(!n.isValid(r)||!n.isValid(o))throw new Error("bad point: x or y not FE");if(!i(r,o))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class p{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 p)throw new Error("projective point not allowed");const o=e=>n.eql(e,n.ZERO);return o(t)&&o(r)?p.ZERO:new p(t,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=hl(n,e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(p.fromAffine)}static fromHex(e){const t=p.fromAffine(s(ga("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return p.BASE.multiply(l(e))}static msm(e,t){return Sl(p,r,e,t)}_setWindowSize(e){b.setWindowSize(this,e)}assertValidity(){h(this)}hasEvenY(){const{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){d(e);const{px:t,py:r,pz:o}=this,{px:s,py:a,pz:i}=e,c=n.eql(n.mul(t,i),n.mul(s,o)),u=n.eql(n.mul(r,i),n.mul(a,o));return c&&u}negate(){return new p(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:r}=t,o=n.mul(r,_l),{px:s,py:a,pz:i}=this;let c=n.ZERO,u=n.ZERO,l=n.ZERO,d=n.mul(s,s),f=n.mul(a,a),h=n.mul(i,i),m=n.mul(s,a);return m=n.add(m,m),l=n.mul(s,i),l=n.add(l,l),c=n.mul(e,l),u=n.mul(o,h),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),l=n.mul(o,l),h=n.mul(e,h),m=n.sub(d,h),m=n.mul(e,m),m=n.add(m,l),l=n.add(d,d),d=n.add(l,d),d=n.add(d,h),d=n.mul(d,m),u=n.add(u,d),h=n.mul(a,i),h=n.add(h,h),d=n.mul(h,m),c=n.sub(c,d),l=n.mul(h,f),l=n.add(l,l),l=n.add(l,l),new p(c,u,l)}add(e){d(e);const{px:r,py:o,pz:s}=this,{px:a,py:i,pz:c}=e;let u=n.ZERO,l=n.ZERO,f=n.ZERO;const h=t.a,m=n.mul(t.b,_l);let g=n.mul(r,a),b=n.mul(o,i),y=n.mul(s,c),w=n.add(r,o),v=n.add(a,i);w=n.mul(w,v),v=n.add(g,b),w=n.sub(w,v),v=n.add(r,s);let x=n.add(a,c);return v=n.mul(v,x),x=n.add(g,y),v=n.sub(v,x),x=n.add(o,s),u=n.add(i,c),x=n.mul(x,u),u=n.add(b,y),x=n.sub(x,u),f=n.mul(h,v),u=n.mul(m,y),f=n.add(u,f),u=n.sub(b,f),f=n.add(b,f),l=n.mul(u,f),b=n.add(g,g),b=n.add(b,g),y=n.mul(h,y),v=n.mul(m,v),b=n.add(b,y),y=n.sub(g,y),y=n.mul(h,y),v=n.add(v,y),g=n.mul(b,v),l=n.add(l,g),g=n.mul(x,v),u=n.mul(w,u),u=n.sub(u,g),g=n.mul(w,b),f=n.mul(x,f),f=n.add(f,g),new p(u,l,f)}subtract(e){return this.add(e.negate())}is0(){return this.equals(p.ZERO)}wNAF(e){return b.wNAFCached(this,e,p.normalizeZ)}multiplyUnsafe(e){const{endo:r,n:o}=t;va("scalar",e,Rl,o);const s=p.ZERO;if(e===Rl)return s;if(this.is0()||e===zl)return this;if(!r||b.hasPrecomputes(this))return b.wNAFCachedUnsafe(this,e,p.normalizeZ);let{k1neg:a,k1:i,k2neg:c,k2:u}=r.splitScalar(e),l=s,d=s,f=this;for(;i>Rl||u>Rl;)i&zl&&(l=l.add(f)),u&zl&&(d=d.add(f)),f=f.double(),i>>=zl,u>>=zl;return a&&(l=l.negate()),c&&(d=d.negate()),d=new p(n.mul(d.px,r.beta),d.py,d.pz),l.add(d)}multiply(e){const{endo:r,n:o}=t;let s,a;if(va("scalar",e,zl,o),r){const{k1neg:t,k1:o,k2neg:i,k2:c}=r.splitScalar(e);let{p:u,f:l}=this.wNAF(o),{p:d,f:f}=this.wNAF(c);u=b.constTimeNegate(t,u),d=b.constTimeNegate(i,d),d=new p(n.mul(d.px,r.beta),d.py,d.pz),s=u.add(d),a=l.add(f)}else{const{p:t,f:n}=this.wNAF(e);s=t,a=n}return p.normalizeZ([s,a])[0]}multiplyAndAddUnsafe(e,t,n){const r=p.BASE,o=(e,t)=>t!==Rl&&t!==zl&&e.equals(r)?e.multiply(t):e.multiplyUnsafe(t),s=o(this,t).add(o(e,n));return s.is0()?void 0:s}toAffine(e){return f(this,e)}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e===zl)return!0;if(n)return n(p,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:n}=t;return e===zl?this:n?n(p,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return Qs("isCompressed",e),this.assertValidity(),o(p,this,e)}toHex(e=!0){return Qs("isCompressed",e),ra(this.toRawBytes(e))}}p.BASE=new p(t.Gx,t.Gy,n.ONE),p.ZERO=new p(n.ZERO,n.ONE,n.ZERO);const{endo:m,nBitLength:g}=t,b=(y=p,w=m?Math.ceil(g/2):g,{constTimeNegate:xl,hasPrecomputes:e=>1!==Nl(e),unsafeLadder(e,t,n=y.ZERO){let r=e;for(;t>wl;)t&vl&&(n=n.add(r)),r=r.double(),t>>=vl;return n},precomputeWindow(e,t){const{windows:n,windowSize:r}=Pl(t,w),o=[];let s=e,a=s;for(let e=0;e<n;e++){a=s,o.push(a);for(let e=1;e<r;e++)a=a.add(s),o.push(a);s=a.double()}return o},wNAF(e,t,n){let r=y.ZERO,o=y.BASE;const s=Pl(e,w);for(let e=0;e<s.windows;e++){const{nextN:a,offset:i,isZero:c,isNeg:u,isNegF:l,offsetF:d}=kl(n,e,s);n=a,c?o=o.add(xl(l,t[d])):r=r.add(xl(u,t[i]))}return{p:r,f:o}},wNAFUnsafe(e,t,n,r=y.ZERO){const o=Pl(e,w);for(let e=0;e<o.windows&&n!==wl;e++){const{nextN:s,offset:a,isZero:i,isNeg:c}=kl(n,e,o);if(n=s,!i){const e=t[a];r=r.add(c?e.negate():e)}}return r},getPrecomputes(e,t,n){let r=Al.get(t);return r||(r=this.precomputeWindow(t,e),1!==e&&Al.set(t,n(r))),r},wNAFCached(e,t,n){const r=Nl(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)},wNAFCachedUnsafe(e,t,n,r){const o=Nl(e);return 1===o?this.unsafeLadder(e,t,r):this.wNAFUnsafe(o,this.getPrecomputes(o,e,n),t,r)},setWindowSize(e,t){El(t,w),Il.set(e,t),Al.delete(e)}});var y,w;return{CURVE:t,ProjectivePoint:p,normPrivateKeyToScalar:l,weierstrassEquation:a,isWithinCurveOrder:function(e){return wa(e,zl,t.n)}}}function jl(e){const t=function(e){const t=Tl(e);return Aa(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:o,nBitLength:s}=t,a=n.BYTES+1,i=2*n.BYTES+1;function c(e){return al(e,r)}function u(e){return cl(e,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:d,weierstrassEquation:f,isWithinCurveOrder:h}=Fl({...t,toBytes(e,t,r){const o=t.toAffine(),s=n.toBytes(o.x),a=ba;return Qs("isCompressed",r),r?a(Uint8Array.from([t.hasEvenY()?2:3]),s):a(Uint8Array.from([4]),s,n.toBytes(o.y))},fromBytes(e){const t=e.length,r=e[0],o=e.subarray(1);if(t!==a||2!==r&&3!==r){if(t===i&&4===r){return{x:n.fromBytes(o.subarray(0,n.BYTES)),y:n.fromBytes(o.subarray(n.BYTES,2*n.BYTES))}}throw new Error("invalid Point, expected length of "+a+", or uncompressed "+i+", got "+t)}{const e=fa(o);if(!wa(e,zl,n.ORDER))throw new Error("Point is not on curve");const t=f(e);let s;try{s=n.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("Point is not on curve"+t)}return!(1&~r)!==((s&zl)===zl)&&(s=n.neg(s)),{x:e,y:s}}}});function p(e){return e>r>>zl}const m=(e,t,n)=>fa(e.slice(t,n));class g{constructor(e,t,n){va("r",e,zl,r),va("s",t,zl,r),this.r=e,this.s=t,null!=n&&(this.recovery=n),Object.freeze(this)}static fromCompact(e){const t=o;return e=ga("compactSignature",e,2*t),new g(m(e,0,t),m(e,t,2*t))}static fromDER(e){const{r:t,s:n}=Cl.toSig(ga("DER",e));return new g(t,n)}assertValidity(){}addRecoveryBit(e){return new g(this.r,this.s,e)}recoverPublicKey(e){const{r:r,s:o,recovery:s}=this,a=v(ga("msgHash",e));if(null==s||![0,1,2,3].includes(s))throw new Error("recovery id invalid");const i=2===s||3===s?r+t.n:r;if(i>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const d=1&s?"03":"02",f=l.fromHex(d+Ol(i,n.BYTES)),h=u(i),p=c(-a*h),m=c(o*h),g=l.BASE.multiplyAndAddUnsafe(f,p,m);if(!g)throw new Error("point at infinify");return g.assertValidity(),g}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return da(this.toDERHex())}toDERHex(){return Cl.hexFromSig(this)}toCompactRawBytes(){return da(this.toCompactHex())}toCompactHex(){const e=o;return Ol(this.r,e)+Ol(this.s,e)}}const b={isValidPrivateKey(e){try{return d(e),!0}catch(e){return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{const e=yl(t.n);return function(e,t,n=!1){const r=e.length,o=bl(t),s=yl(t);if(r<16||r<s||r>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+r);const a=al(n?ha(e):fa(e),t-el)+el;return n?ma(a,o):pa(a,o)}(t.randomBytes(e),t.n)},precompute:(e=8,t=l.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function y(e){if("bigint"==typeof e)return!1;if(e instanceof l)return!0;const r=ga("key",e).length,s=n.BYTES,a=s+1,i=2*s+1;return t.allowedPrivateKeyLengths||o===a?void 0:r===a||r===i}const w=t.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=fa(e),n=8*e.length-s;return n>0?t>>BigInt(n):t},v=t.bits2int_modN||function(e){return c(w(e))},x=xa(s);function E(e){return va("num < 2^"+s,e,Rl,x),pa(e,o)}function P(e,r,o=k){if(["recovered","canonical"].some(e=>e in o))throw new Error("sign() legacy options not supported");const{hash:s,randomBytes:a}=t;let{lowS:i,prehash:f,extraEntropy:m}=o;null==i&&(i=!0),e=ga("msgHash",e),$l(o),f&&(e=ga("prehashed msgHash",s(e)));const b=v(e),y=d(r),x=[E(y),E(b)];if(null!=m&&!1!==m){const e=!0===m?a(n.BYTES):m;x.push(ga("extraEntropy",e))}const P=ba(...x),A=b;return{seed:P,k2sig:function(e){const t=w(e);if(!h(t))return;const n=u(t),r=l.BASE.multiply(t).toAffine(),o=c(r.x);if(o===Rl)return;const s=c(n*c(A+o*y));if(s===Rl)return;let a=(r.x===o?0:2)|Number(r.y&zl),d=s;return i&&p(s)&&(d=function(e){return p(e)?c(-e):e}(s),a^=1),new g(o,d,a)}}}const k={lowS:t.lowS,prehash:!1},A={lowS:t.lowS,prehash:!1};return l.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return l.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,n=!0){if(!0===y(e))throw new Error("first arg must be private key");if(!1===y(t))throw new Error("second arg must be public key");return l.fromHex(t).multiply(d(e)).toRawBytes(n)},sign:function(e,n,r=k){const{seed:o,k2sig:s}=P(e,n,r),a=t,i=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=Ea(e),o=Ea(e),s=0;const a=()=>{r.fill(1),o.fill(0),s=0},i=(...e)=>n(o,r,...e),c=(e=Ea(0))=>{o=i(Pa([0]),e),r=i(),0!==e.length&&(o=i(Pa([1]),e),r=i())},u=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){r=i();const t=r.slice();n.push(t),e+=r.length}return ba(...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 i(o,s)},verify:function(e,n,r,o=A){const s=e;n=ga("msgHash",n),r=ga("publicKey",r);const{lowS:a,prehash:i,format:d}=o;if($l(o),"strict"in o)throw new Error("options.strict was renamed to lowS");if(void 0!==d&&"compact"!==d&&"der"!==d)throw new Error("format must be compact or der");const f="string"==typeof s||Ks(s),h=!f&&!d&&"object"==typeof s&&null!==s&&"bigint"==typeof s.r&&"bigint"==typeof s.s;if(!f&&!h)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let p,m;try{if(h&&(p=new g(s.r,s.s)),f){try{"compact"!==d&&(p=g.fromDER(s))}catch(e){if(!(e instanceof Cl.Err))throw e}p||"der"===d||(p=g.fromCompact(s))}m=l.fromHex(r)}catch(e){return!1}if(!p)return!1;if(a&&p.hasHighS())return!1;i&&(n=t.hash(n));const{r:b,s:y}=p,w=v(n),x=u(y),E=c(w*x),P=c(b*x),k=l.BASE.multiplyAndAddUnsafe(m,E,P)?.toAffine();return!!k&&c(k.x)===b},ProjectivePoint:l,Signature:g,utils:b}}
|
|
10
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ll(e){return{hash:e,hmac:(t,...n)=>Qu(e,t,function(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];Jt(r),t+=r.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const o=e[t];n.set(o,r),r+=o.length}return n}(...n)),randomBytes:un}}
|
|
11
11
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
12
|
-
const Ll=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ul=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Dl=BigInt(0),Gl=BigInt(1),ql=BigInt(2),Vl=(e,t)=>(e+t/ql)/t;const Wl=ml(Ll,void 0,void 0,{sqrt:function(e){const t=Ll,n=BigInt(3),r=BigInt(6),o=BigInt(11),s=BigInt(22),a=BigInt(23),i=BigInt(44),c=BigInt(88),u=e*e*e%t,l=u*u*e%t,d=al(l,n,t)*l%t,f=al(d,n,t)*l%t,h=al(f,ql,t)*u%t,p=al(h,o,t)*h%t,m=al(p,s,t)*p%t,g=al(m,i,t)*m%t,b=al(g,c,t)*g%t,y=al(b,i,t)*m%t,w=al(y,n,t)*l%t,v=al(w,a,t)*p%t,x=al(v,r,t)*u%t,E=al(x,ql,t);if(!Wl.eql(Wl.sqr(E),e))throw new Error("Cannot find square root");return E}}),Hl=function(e,t){const n=t=>Fl({...e,...jl(t)});return{...n(t),create:n}}({a:Dl,b:BigInt(7),Fp:Wl,n:Ul,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=Ul,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Gl*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,a=BigInt("0x100000000000000000000000000000000"),i=Vl(s*e,t),c=Vl(-r*e,t);let u=sl(e-i*n-c*o,t),l=sl(-i*r-c*s,t);const d=u>a,f=l>a;if(d&&(u=t-u),f&&(l=t-l),u>a||l>a)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:d,k1:u,k2neg:f,k2:l}}}},Ps);var Yl=Object.freeze({__proto__:null,secp256k1:Hl});function Zl(e,t={}){const{recovered:n}=t;if(void 0===e.r)throw new ed({signature:e});if(void 0===e.s)throw new ed({signature:e});if(n&&void 0===e.yParity)throw new ed({signature:e});if(e.r<0n||e.r>Nu)throw new td({value:e.r});if(e.s<0n||e.s>Nu)throw new nd({value:e.s});if("number"==typeof e.yParity&&0!==e.yParity&&1!==e.yParity)throw new rd({value:e.yParity})}function Kl(e){if(130!==e.length&&132!==e.length)throw new Xl({signature:e});const t=BigInt(li(e,0,32)),n=BigInt(li(e,32,64)),r=(()=>{const t=Number(`0x${e.slice(130)}`);if(!Number.isNaN(t))try{return Ql(t)}catch{throw new rd({value:t})}})();return void 0===r?{r:t,s:n}:{r:t,s:n,yParity:r}}function Jl(e){if(void 0!==e.r&&void 0!==e.s)return function(e){const t="string"==typeof e?Kl(e):e instanceof Uint8Array?function(e){return Kl(si(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=Ql(t)),"number"!=typeof n)throw new rd({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:Ql(e.v)}}(e):{r:e.r,s:e.s,...void 0!==e.yParity?{yParity:e.yParity}:{}};return Zl(t),t}(e)}function Ql(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 od({value:e})}class Xl extends Ia{constructor({signature:e}){var t;super(`Value \`${e}\` is an invalid signature size.`,{metaMessages:["Expected: 64 bytes or 65 bytes.",`Received ${di((t=e,t instanceof Uint8Array?si(t):Array.isArray(t)?si(new Uint8Array(t)):t))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSerializedSizeError"})}}class ed extends Ia{constructor({signature:e}){super(`Signature \`${ja(e)}\` is missing either an \`r\`, \`s\`, or \`yParity\` property.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.MissingPropertiesError"})}}class td extends Ia{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 Ia{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 rd extends Ia{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 od extends Ia{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 sd(e,t={}){return"string"==typeof e.chainId?function(e){const{address:t,chainId:n,nonce:r}=e,o=Jl(e);return{address:t,chainId:Number(n),nonce:BigInt(r),...o}}(e):{...e,...t.signature}}const ad=Du("(uint256 chainId, address delegation, uint256 nonce, uint8 yParity, uint256 r, uint256 s), address to, bytes data");function id(e){if("string"==typeof e){if("0x8010801080108010801080108010801080108010801080108010801080108010"!==li(e,-32))throw new cd(e)}else Zl(e.authorization)}let cd=class extends Ia{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 ud(e,{address:t,blockNumber:n,blockTag:r,storageKeys:o}){const s=r??"latest",a=void 0!==n?_t(n):void 0;return function(e){return{...e,balance:e.balance?BigInt(e.balance):void 0,nonce:e.nonce?Bt(e.nonce):void 0,storageProof:e.storageProof?(t=e.storageProof,t.map(e=>({...e,value:BigInt(e.value)}))):void 0};var t}(await e.request({method:"eth_getProof",params:[t,o,a||s]}))}async function ld(e,{blockHash:t,blockNumber:n,blockTag:r,hash:o,index:s}){const a=r||"latest",i=void 0!==n?_t(n):void 0;let c=null;if(c=o?await e.request({method:"eth_getTransactionByHash",params:[o]},{dedupe:!0}):t?await e.request({method:"eth_getTransactionByBlockHashAndIndex",params:[t,_t(s)]},{dedupe:!0}):await e.request({method:"eth_getTransactionByBlockNumberAndIndex",params:[i||a,_t(s)]},{dedupe:Boolean(i)}),!c)throw new Fr({blockHash:t,blockNumber:n,blockTag:a,hash:o,index:s});return(e.chain?.formatters?.transaction?.format||is)(c)}async function dd(e,{hash:t}){const n=await e.request({method:"eth_getTransactionReceipt",params:[t]},{dedupe:!0});if(!n)throw new jr({hash:t});return(e.chain?.formatters?.transactionReceipt?.format||uc)(n)}async function fd(e,t){const{blockNumber:n,blockTag:r=e.experimental_blockTag??"latest",blocks:o,returnFullTransactions:s,traceTransfers:a,validation:i}=t;try{const t=[];for(const e of o){const n=e.blockOverrides?Ei(e.blockOverrides):void 0,r=e.calls.map(e=>{const t=e,n=t.account?sr(t.account):void 0,r=t.abi?ir(t):t.data,o={...t,data:t.dataSuffix?Fn([r||"0x",t.dataSuffix]):r,from:t.from??n?.address};return ts(o),Ko(o)}),o=e.stateOverrides?Xo(e.stateOverrides):void 0;t.push({blockOverrides:n,calls:r,stateOverrides:o})}const c=("bigint"==typeof n?_t(n):void 0)||r;return(await e.request({method:"eth_simulateV1",params:[{blockStateCalls:t,returnFullTransactions:s,traceTransfers:a,validation:i},c]})).map((e,t)=>({...cs(e),calls:e.calls.map((e,n)=>{const{abi:r,args:s,functionName:a,to:i}=o[t].calls[n],c=e.error?.data??e.returnData,u=BigInt(e.gasUsed),l=e.logs?.map(e=>Ds(e)),d="0x1"===e.status?"success":"failure",f=r&&"success"===d&&"0x"!==c?Ws({abi:r,data:c,functionName:a}):null,h=(()=>{if("success"===d)return;let t;return"0x"===e.error?.data?t=new Je:e.error&&(t=new Wr(e.error)),t?Io(t,{abi:r??[],address:i??"0x",args:s,functionName:a??"<unknown>"}):void 0})();return{data:c,gasUsed:u,logs:l,status:d,..."success"===d?{result:f}:{error:h}}})}))}catch(e){const t=e,n=Ho(t,{});if(n instanceof Wo)throw t;throw n}}function hd(e){let t=!0,n="",r=0,o="",s=!1;for(let a=0;a<e.length;a++){const i=e[a];if(["(",")",","].includes(i)&&(t=!0),"("===i&&r++,")"===i&&r--,t)if(0!==r)" "!==i?(o+=i,n+=i):","!==e[a-1]&&","!==n&&",("!==n&&(n="",t=!1);else if(" "===i&&["event","function","error",""].includes(o))o="";else if(o+=i,")"===i){s=!0;break}}if(!s)throw new Ia("Unable to normalize signature.");return o}function pd(e,t){const n=typeof e,r=t.type;switch(r){case"address":return vu(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)=>pd(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=>pd(e,{...t,type:r.replace(/(\[[0-9]{0,}\])$/,"")})))}}function md(e,t,n){for(const r in e){const o=e[r],s=t[r];if("tuple"===o.type&&"tuple"===s.type&&"components"in o&&"components"in s)return md(o.components,s.components,n[r]);const a=[o.type,s.type];if((()=>!(!a.includes("address")||!a.includes("bytes20"))||(a.includes("address")&&a.includes("string")||!(!a.includes("address")||!a.includes("bytes")))&&vu(n[r],{strict:!1}))())return a}}function gd(e,t={}){const{prepare:n=!0}=t,r=Array.isArray(e)||"string"==typeof e?_e(e):e;return{...r,...n?{hash:wd(r)}:{}}}function bd(e,t,n){const{args:r=[],prepare:o=!0}=n??{},s=pi(t,{strict:!1}),a=e.filter(e=>s?"function"===e.type||"error"===e.type?yd(e)===li(t,0,4):"event"===e.type&&wd(e)===t:"name"in e&&e.name===t);if(0===a.length)throw new xd({name:t});if(1===a.length)return{...a[0],...o?{hash:wd(a[0])}:{}};let i;for(const e of a){if(!("inputs"in e))continue;if(!r||0===r.length){if(!e.inputs||0===e.inputs.length)return{...e,...o?{hash:wd(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&&pd(t,r)});if(t){if(i&&"inputs"in i&&i.inputs){const t=md(e.inputs,i.inputs,r);if(t)throw new vd({abiItem:e,type:t[0]},{abiItem:i,type:t[1]})}i=e}}const c=(()=>{if(i)return i;const[e,...t]=a;return{...e,overloads:t}})();if(!c)throw new xd({name:t});return{...c,...o?{hash:wd(c)}:{}}}function yd(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return bd(t,n)}return e[0]})();return li(wd(t),0,4)}function wd(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return bd(t,n)}return e[0]})();return"string"!=typeof t&&"hash"in t&&t.hash?t.hash:gu(ii(function(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return bd(t,n)}return e[0]})();return hd("string"==typeof t?t:K(t))}(t)))}class vd extends Ia{constructor(e,t){super("Found ambiguous types in overloaded ABI Items.",{metaMessages:[`\`${e.type}\` in \`${hd(K(e.abiItem))}\`, and`,`\`${t.type}\` in \`${hd(K(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 xd extends Ia{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 Ed(e){const t=e.find(e=>"constructor"===e.type);if(!t)throw new xd({name:"constructor"});return t}function Pd(...e){const[t,n=[]]=(()=>{if(Array.isArray(e[0])){const[t,n,r]=e;return[Ad(t,n,{args:r}),r]}const[t,n]=e;return[t,n]})(),{overloads:r}=t,o=r?Ad([t,...r],t.name,{args:n}):t,s=yd(o);const a=n.length>0?Lu(o.inputs,n):void 0;return a?ri(s,a):s}function kd(e,t={}){return gd(e,t)}function Ad(e,t,n){const r=bd(e,t,n);if("function"!==r.type)throw new xd({name:t,type:"function"});return r}const Id="0x0000000000000000000000000000000000000000";async function Nd(e,t){const{blockNumber:n,blockTag:r,calls:o,stateOverrides:s,traceAssetChanges:a,traceTransfers:i,validation:c}=t,u=t.account?sr(t.account):void 0;if(a&&!u)throw new We("`account` is required when `traceAssetChanges` is true");const l=u?function(...e){const[t,n]=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return[Ed(t),n]}return e})(),{bytecode:r,args:o}=n;return ri(r,t.inputs?.length&&o?.length?Lu(t.inputs,o):"0x")}(gd("constructor(bytes, bytes)"),{bytecode:Oi,args:["0x6080604052348015600e575f80fd5b5061016d8061001c5f395ff3fe608060405234801561000f575f80fd5b5060043610610029575f3560e01c8063f8b2cb4f1461002d575b5f80fd5b610047600480360381019061004291906100db565b61005d565b604051610054919061011e565b60405180910390f35b5f8173ffffffffffffffffffffffffffffffffffffffff16319050919050565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100aa82610081565b9050919050565b6100ba816100a0565b81146100c4575f80fd5b50565b5f813590506100d5816100b1565b92915050565b5f602082840312156100f0576100ef61007d565b5b5f6100fd848285016100c7565b91505092915050565b5f819050919050565b61011881610106565b82525050565b5f6020820190506101315f83018461010f565b9291505056fea26469706673582212203b9fe929fe995c7cf9887f0bdba8a36dd78e8b73f149b17d2d9ad7cd09d2dc6264736f6c634300081a0033",Pd(kd("function getBalance(address)"),[u.address])]}):void 0;const d=a?await Promise.all(t.calls.map(async t=>{if(!t.data&&!t.abi)return;const{accessList:n}=await Fc(e,{account:u.address,...t,data:t.abi?ir(t):t.data});return n.map(({address:e,storageKeys:t})=>t.length>0?e:null)})).then(e=>e.flat().filter(Boolean)):[],f=await fd(e,{blockNumber:n,blockTag:r,blocks:[...a?[{calls:[{data:l}],stateOverrides:s},{calls:d.map((e,t)=>({abi:[kd("function balanceOf(address) returns (uint256)")],functionName:"balanceOf",args:[u.address],to:e,from:Id,nonce:t})),stateOverrides:[{address:Id,nonce:0}]}]:[],{calls:[...o,{}].map(e=>({...e,from:u?.address})),stateOverrides:s},...a?[{calls:[{data:l}]},{calls:d.map((e,t)=>({abi:[kd("function balanceOf(address) returns (uint256)")],functionName:"balanceOf",args:[u.address],to:e,from:Id,nonce:t})),stateOverrides:[{address:Id,nonce:0}]},{calls:d.map((e,t)=>({to:e,abi:[kd("function decimals() returns (uint256)")],functionName:"decimals",from:Id,nonce:t})),stateOverrides:[{address:Id,nonce:0}]},{calls:d.map((e,t)=>({to:e,abi:[kd("function tokenURI(uint256) returns (string)")],functionName:"tokenURI",args:[0n],from:Id,nonce:t})),stateOverrides:[{address:Id,nonce:0}]},{calls:d.map((e,t)=>({to:e,abi:[kd("function symbol() returns (string)")],functionName:"symbol",from:Id,nonce:t})),stateOverrides:[{address:Id,nonce:0}]}]:[]],traceTransfers:i,validation:c}),h=a?f[2]:f[0],[p,m,,g,b,y,w,v]=a?f:[],{calls:x,...E}=h,P=x.slice(0,-1)??[],k=[...p?.calls??[],...m?.calls??[]].map(e=>"success"===e.status?$t(e.data):null),A=[...g?.calls??[],...b?.calls??[]].map(e=>"success"===e.status?$t(e.data):null),I=(y?.calls??[]).map(e=>"success"===e.status?e.result:null),N=(v?.calls??[]).map(e=>"success"===e.status?e.result:null),S=(w?.calls??[]).map(e=>"success"===e.status?e.result:null),T=[];for(const[e,t]of A.entries()){const n=k[e];if("bigint"!=typeof t)continue;if("bigint"!=typeof n)continue;const r=I[e-1],o=N[e-1],s=S[e-1],a=(()=>0===e?{address:"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",decimals:18,symbol:"ETH"}:{address:d[e-1],decimals:s||r?Number(r??1):void 0,symbol:o??void 0})();T.some(e=>e.token.address===a.address)||T.push({token:a,value:{pre:n,post:t,diff:t-n}})}return{assetChanges:T,block:E,results:P}}const Sd="0x6492649264926492649264926492649264926492649264926492649264926492";function Td(e){try{return function(e){if(li(e,-32)!==Sd)throw new $d(e)}(e),!0}catch{return!1}}class $d extends Ia{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"})}}function Bd({r:e,s:t,to:n="hex",v:r,yParity:o}){const s=(()=>{if(0===o||1===o)return o;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 Hl.Signature($t(e),$t(t)).toCompactHex()}${0===s?"1b":"1c"}`;return"hex"===n?a:Gt(a)}async function Cd(e,t){const{address:n,hash:r,erc6492VerifierAddress:o=t.universalSignatureVerifierAddress??e.chain?.contracts?.erc6492Verifier?.address,multicallAddress:s=t.multicallAddress??e.chain?.contracts?.multicall3?.address}=t,a=(()=>{const e=t.signature;return Ue(e)?e:"object"==typeof e&&"r"in e&&"s"in e?Bd(e):zt(e)})();try{return function(e){try{return id(e),!0}catch{return!1}}(a)?await async function(e,t){const{address:n,blockNumber:r,blockTag:o,hash:s,multicallAddress:a}=t,{authorization:i,data:c,signature:u,to:l}=function(e){id(e);const t=hi(li(e,-64,-32)),n=li(e,-t-64,-64),r=li(e,0,-t-64),[o,s,a]=ju(ad,n);return{authorization:sd({address:o.delegation,chainId:Number(o.chainId),nonce:o.nonce,yParity:o.yParity,r:o.r,s:o.s}),signature:r,...a&&"0x"!==a?{data:a,to:s}:{}}}(t.signature),d=await Uc(e,{address:n,blockNumber:r,blockTag:o});if(d===jn(["0xef0100",i.address]))return await async function(e,t){const{address:n,blockNumber:r,blockTag:o,hash:s,signature:a}=t,i=await Fe(e,Yi,"readContract")({address:n,abi:$i,args:[s,a],blockNumber:r,blockTag:o,functionName:"isValidSignature"}).catch(e=>{if(e instanceof Dr)throw new Od;throw e});if(i.startsWith("0x1626ba7e"))return!0;throw new Od}(e,{address:n,blockNumber:r,blockTag:o,hash:s,signature:u});const f={address:i.address,chainId:Number(i.chainId),nonce:Number(i.nonce),r:_t(i.r,{size:32}),s:_t(i.s,{size:32}),yParity:i.yParity},h=await async function({address:e,authorization:t,signature:n}){return Ms(Rn(e),await Oo({authorization:t,signature:n}))}({address:n,authorization:f});if(!h)throw new Od;const p=await Fe(e,Yi,"readContract")({...a?{address:a}:{code:_i},authorizationList:[f],abi:Pi,blockNumber:r,blockTag:"pending",functionName:"aggregate3",args:[[...c?[{allowFailure:!0,target:l??n,callData:c}]:[],{allowFailure:!0,target:n,callData:ir({abi:$i,functionName:"isValidSignature",args:[s,u]})}]]}),m=p[p.length-1]?.returnData;if(m?.startsWith("0x1626ba7e"))return!0;throw new Od}(e,{...t,multicallAddress:s,signature:a}):await async function(e,t){const{address:n,factory:r,factoryData:o,hash:s,signature:a,verifierAddress:i,...c}=t,u=await(async()=>r||o?Td(a)?a:function(e){const{data:t,signature:n,to:r}=e;return ri(Lu(Du("address, bytes, bytes"),[r,t,n]),Sd)}({data:o,signature:a,to:r}):a)(),l=i?{to:i,data:ir({abi:Bi,functionName:"isValidSig",args:[n,s,u]}),...c}:{data:Li({abi:Bi,args:[n,s,u],bytecode:zi}),...c},{data:d}=await Fe(e,Wi,"call")(l).catch(e=>{if(e instanceof Ur)throw new Od;throw e});if(function(e,t={}){let n=e;if(t.size&&(Tt(n,{size:t.size}),n=St(n)),"0x00"===St(n))return!1;if("0x01"===St(n))return!0;throw new It(n)}(d??"0x0"))return!0;throw new Od}(e,{...t,verifierAddress:o,signature:a})}catch(e){try{if(Ms(Rn(n),await So({hash:r,signature:a})))return!0}catch{}if(e instanceof Od)return!1;throw e}}class Od extends Error{}function Rd(e,{emitOnBegin:t=!1,emitMissed:n=!1,onBlockNumber:r,onError:o,poll:s,pollingInterval:a=e.pollingInterval}){let i;return(void 0!==s?s:"webSocket"!==e.transport.type&&"ipc"!==e.transport.type&&("fallback"!==e.transport.type||"webSocket"!==e.transport.transports[0].config.type&&"ipc"!==e.transport.transports[0].config.type))?Qi(Ar(["watchBlockNumber",e.uid,t,n,a]),{onBlockNumber:r,onError:o},r=>ec(async()=>{try{const t=await Fe(e,oc,"getBlockNumber")({cacheTime:0});if(void 0!==i){if(t===i)return;if(t-i>1&&n)for(let e=i+1n;e<t;e++)r.onBlockNumber(e,i),i=e}(void 0===i||t>i)&&(r.onBlockNumber(t,i),i=t)}catch(e){r.onError?.(e)}},{emitOnBegin:t,interval:a})):Qi(Ar(["watchBlockNumber",e.uid,t,n]),{onBlockNumber:r,onError:o},t=>{let n=!0,r=()=>n=!1;return(async()=>{try{const o=(()=>{if("fallback"===e.transport.type){const t=e.transport.transports.find(e=>"webSocket"===e.config.type||"ipc"===e.config.type);return t?t.value:e.transport}return e.transport})(),{unsubscribe:s}=await o.subscribe({params:["newHeads"],onData(e){if(!n)return;const r=$t(e.result?.number);t.onBlockNumber(r,i),i=r},onError(e){t.onError?.(e)}});r=s,n||r()}catch(e){o?.(e)}})(),()=>r()})}const zd=/^(?:(?<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)?/,_d=/(?: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>.+))?/;async function Md(e,t){const{address:n,domain:r,message:o,nonce:s,scheme:a,signature:i,time:c=new Date,...u}=t,l=function(e){const{scheme:t,statement:n,...r}=e.match(zd)?.groups??{},{chainId:o,expirationTime:s,issuedAt:a,notBefore:i,requestId:c,...u}=e.match(_d)?.groups??{},l=e.split("Resources:")[1]?.split("\n- ").slice(1);return{...r,...u,...o?{chainId:Number(o)}:{},...s?{expirationTime:new Date(s)}:{},...a?{issuedAt:new Date(a)}:{},...i?{notBefore:new Date(i)}:{},...c?{requestId:c}:{},...l?{resources:l}:{},...t?{scheme:t}:{},...n?{statement:n}:{}}}(o);if(!l.address)return!1;const d=function(e){const{address:t,domain:n,message:r,nonce:o,scheme:s,time:a=new Date}=e;if(n&&r.domain!==n)return!1;if(o&&r.nonce!==o)return!1;if(s&&r.scheme!==s)return!1;if(r.expirationTime&&a>=r.expirationTime)return!1;if(r.notBefore&&a<r.notBefore)return!1;try{if(!r.address)return!1;if(!Mn(r.address,{strict:!1}))return!1;if(t&&!Ms(r.address,t))return!1}catch{return!1}return!0}({address:n,domain:r,message:l,nonce:s,scheme:a,time:c});if(!d)return!1;const f=nu(o);return Cd(e,{address:l.address,hash:f,signature:i,...u})}function Fd(e){return{call:t=>Wi(e,t),createAccessList:t=>Fc(e,t),createBlockFilter:()=>async function(e){const t=rr(e,{method:"eth_newBlockFilter"}),n=await e.request({method:"eth_newBlockFilter"});return{id:n,request:t(n),type:"block"}}(e),createContractEventFilter:t=>or(e,t),createEventFilter:t=>jc(e,t),createPendingTransactionFilter:()=>Lc(e),estimateContractGas:t=>async function(e,t){const{abi:n,address:r,args:o,functionName:s,dataSuffix:a,...i}=t,c=ir({abi:n,args:o,functionName:s});try{return await Fe(e,_s,"estimateGas")({data:`${c}${a?a.replace("0x",""):""}`,to:r,...i})}catch(e){const t=i.account?sr(i.account):void 0;throw Io(e,{abi:n,address:r,args:o,docsPath:"/docs/contract/estimateContractGas",functionName:s,sender:t?.address})}}(e,t),estimateGas:t=>_s(e,t),getBalance:t=>async function(e,{address:t,blockNumber:n,blockTag:r=e.experimental_blockTag??"latest"}){const o="bigint"==typeof n?_t(n):void 0,s=await e.request({method:"eth_getBalance",params:[t,o||r]});return BigInt(s)}(e,t),getBlobBaseFee:()=>async function(e){const t=await e.request({method:"eth_blobBaseFee"});return BigInt(t)}(e),getBlock:t=>us(e,t),getBlockNumber:t=>oc(e,t),getBlockTransactionCount:t=>async function(e,{blockHash:t,blockNumber:n,blockTag:r="latest"}={}){const o=void 0!==n?_t(n):void 0;let s;return s=t?await e.request({method:"eth_getBlockTransactionCountByHash",params:[t]},{dedupe:!0}):await e.request({method:"eth_getBlockTransactionCountByNumber",params:[o||r]},{dedupe:Boolean(o)}),Bt(s)}(e,t),getBytecode:t=>Uc(e,t),getChainId:()=>Cs(e),getCode:t=>Uc(e,t),getContractEvents:t=>qs(e,t),getEip712Domain:t=>async function(e,t){const{address:n,factory:r,factoryData:o}=t;try{const[t,s,a,i,c,u,l]=await Fe(e,Yi,"readContract")({abi:Gc,address:n,functionName:"eip712Domain",factory:r,factoryData:o});return{domain:{name:s,version:a,chainId:Number(i),verifyingContract:c,salt:u},extensions:l,fields:t}}catch(e){const t=e;if("ContractFunctionExecutionError"===t.name&&"ContractFunctionZeroDataError"===t.cause.name)throw new Dc({address:n});throw t}}(e,t),getEnsAddress:t=>async function(e,t){const{blockNumber:n,blockTag:r,coinType:o,name:s,gatewayUrls:a,strict:i}=t,{chain:c}=e,u=(()=>{if(t.universalResolverAddress)return t.universalResolverAddress;if(!c)throw new Error("client chain not configured. universalResolverAddress is required.");return Ui({blockNumber:n,chain:c,contract:"ensUniversalResolver"})})(),l=c?.ensTlds;if(l&&!l.some(e=>s.endsWith(e)))return null;const d=null!=o?[vc(s),BigInt(o)]:[vc(s)];try{const t=ir({abi:Ti,functionName:"addr",args:d}),o={address:u,abi:Ii,functionName:"resolveWithGateways",args:[Ot(Pc(s)),t,a??[bc]],blockNumber:n,blockTag:r},i=Fe(e,Yi,"readContract"),c=await i(o);if("0x"===c[0])return null;const l=Ws({abi:Ti,args:d,functionName:"addr",data:c[0]});return"0x"===l||"0x00"===St(l)?null:l}catch(e){if(i)throw e;if(hc(e))return null;throw e}}(e,t),getEnsAvatar:t=>async function(e,{blockNumber:t,blockTag:n,assetGatewayUrls:r,name:o,gatewayUrls:s,strict:a,universalResolverAddress:i}){const c=await Fe(e,Mc,"getEnsText")({blockNumber:t,blockTag:n,key:"avatar",name:o,universalResolverAddress:i,gatewayUrls:s,strict:a});if(!c)return null;try{return await _c(e,{record:c,gatewayUrls:r})}catch{return null}}(e,t),getEnsName:t=>async function(e,t){const{address:n,blockNumber:r,blockTag:o,coinType:s=60n,gatewayUrls:a,strict:i}=t,{chain:c}=e,u=(()=>{if(t.universalResolverAddress)return t.universalResolverAddress;if(!c)throw new Error("client chain not configured. universalResolverAddress is required.");return Ui({blockNumber:r,chain:c,contract:"ensUniversalResolver"})})();try{const t={address:u,abi:Ni,args:[n,s,a??[bc]],functionName:"reverseWithGateways",blockNumber:r,blockTag:o},i=Fe(e,Yi,"readContract"),[c]=await i(t);return c||null}catch(e){if(i)throw e;if(hc(e))return null;throw e}}(e,t),getEnsResolver:t=>async function(e,t){const{blockNumber:n,blockTag:r,name:o}=t,{chain:s}=e,a=(()=>{if(t.universalResolverAddress)return t.universalResolverAddress;if(!s)throw new Error("client chain not configured. universalResolverAddress is required.");return Ui({blockNumber:n,chain:s,contract:"ensUniversalResolver"})})(),i=s?.ensTlds;if(i&&!i.some(e=>o.endsWith(e)))throw new Error(`${o} is not a valid ENS TLD (${i?.join(", ")}) for chain "${s.name}" (id: ${s.id}).`);const[c]=await Fe(e,Yi,"readContract")({address:a,abi:[{inputs:[{type:"bytes"}],name:"findResolver",outputs:[{type:"address"},{type:"bytes32"},{type:"uint256"}],stateMutability:"view",type:"function"}],functionName:"findResolver",args:[Ot(Pc(o))],blockNumber:n,blockTag:r});return c}(e,t),getEnsText:t=>Mc(e,t),getFeeHistory:t=>qc(e,t),estimateFeesPerGas:t=>async function(e,t){return fs(e,t)}(e,t),getFilterChanges:e=>sc(0,e),getFilterLogs:e=>async function(e,{filter:t}){const n=t.strict??!1,r=(await t.request({method:"eth_getFilterLogs",params:[t.id]})).map(e=>Ds(e));return t.abi?Us({abi:t.abi,logs:r,strict:n}):r}(0,e),getGasPrice:()=>ls(e),getLogs:t=>Gs(e,t),getProof:t=>ud(e,t),estimateMaxPriorityFeePerGas:t=>async function(e,t){return ds(e,t)}(e,t),getStorageAt:t=>async function(e,{address:t,blockNumber:n,blockTag:r="latest",slot:o}){const s=void 0!==n?_t(n):void 0;return await e.request({method:"eth_getStorageAt",params:[t,o,s||r]})}(e,t),getTransaction:t=>ld(e,t),getTransactionConfirmations:t=>async function(e,{hash:t,transactionReceipt:n}){const[r,o]=await Promise.all([Fe(e,oc,"getBlockNumber")({}),t?Fe(e,ld,"getTransaction")({hash:t}):void 0]),s=n?.blockNumber||o?.blockNumber;return s?r-s+1n:0n}(e,t),getTransactionCount:t=>hs(e,t),getTransactionReceipt:t=>dd(e,t),multicall:t=>async function(e,t){const{account:n,authorizationList:r,allowFailure:o=!0,blockNumber:s,blockOverrides:a,blockTag:i,stateOverride:c}=t,u=t.contracts,{batchSize:l=t.batchSize??1024,deployless:d=t.deployless??!1}="object"==typeof e.batch?.multicall?e.batch.multicall:{},f=(()=>{if(t.multicallAddress)return t.multicallAddress;if(d)return null;if(e.chain)return Ui({blockNumber:s,chain:e.chain,contract:"multicall3"});throw new Error("client chain not configured. multicallAddress is required.")})(),h=[[]];let p=0,m=0;for(let e=0;e<u.length;e++){const{abi:t,address:r,args:s,functionName:a}=u[e];try{const e=ir({abi:t,args:s,functionName:a});m+=(e.length-2)/2,l>0&&m>l&&h[p].length>0&&(p++,m=(e.length-2)/2,h[p]=[]),h[p]=[...h[p],{allowFailure:!0,callData:e,target:r}]}catch(e){const i=Io(e,{abi:t,address:r,args:s,docsPath:"/docs/contract/multicall",functionName:a,sender:n});if(!o)throw i;h[p]=[...h[p],{allowFailure:!0,callData:"0x",target:r}]}}const g=await Promise.allSettled(h.map(t=>Fe(e,Yi,"readContract")({...null===f?{code:_i}:{address:f},abi:Pi,account:n,args:[t],authorizationList:r,blockNumber:s,blockOverrides:a,blockTag:i,functionName:"aggregate3",stateOverride:c}))),b=[];for(let e=0;e<g.length;e++){const t=g[e];if("rejected"===t.status){if(!o)throw t.reason;for(let n=0;n<h[e].length;n++)b.push({status:"failure",error:t.reason,result:void 0});continue}const n=t.value;for(let t=0;t<n.length;t++){const{returnData:r,success:s}=n[t],{callData:a}=h[e][t],{abi:i,address:c,functionName:l,args:d}=u[b.length];try{if("0x"===a)throw new Je;if(!s)throw new Wr({data:r});const e=Ws({abi:i,args:d,data:r,functionName:l});b.push(o?{result:e,status:"success"}:e)}catch(e){const t=Io(e,{abi:i,address:c,args:d,docsPath:"/docs/contract/multicall",functionName:l});if(!o)throw t;b.push({error:t,result:void 0,status:"failure"})}}}if(b.length!==u.length)throw new We("multicall results mismatch");return b}(e,t),prepareTransactionRequest:t=>zs(e,t),readContract:t=>Yi(e,t),sendRawTransaction:t=>async function(e,{serializedTransaction:t}){return e.request({method:"eth_sendRawTransaction",params:[t]},{retryCount:0})}(e,t),simulate:t=>fd(e,t),simulateBlocks:t=>fd(e,t),simulateCalls:t=>Nd(e,t),simulateContract:t=>async function(e,t){const{abi:n,address:r,args:o,dataSuffix:s,functionName:a,...i}=t,c=i.account?sr(i.account):e.account,u=ir({abi:n,args:o,functionName:a});try{const{data:l}=await Fe(e,Wi,"call")({batch:!1,data:`${u}${s?s.replace("0x",""):""}`,to:r,...i,account:c});return{result:Ws({abi:n,args:o,functionName:a,data:l||"0x"}),request:{abi:n.filter(e=>"name"in e&&e.name===t.functionName),address:r,args:o,dataSuffix:s,functionName:a,...i,account:c}}}catch(e){throw Io(e,{abi:n,address:r,args:o,docsPath:"/docs/contract/simulateContract",functionName:a,sender:c?.address})}}(e,t),verifyHash:t=>Cd(e,t),verifyMessage:t=>async function(e,{address:t,message:n,factory:r,factoryData:o,signature:s,...a}){return Cd(e,{address:t,factory:r,factoryData:o,hash:nu(n),signature:s,...a})}(e,t),verifySiweMessage:t=>Md(e,t),verifyTypedData:t=>async function(e,t){const{address:n,factory:r,factoryData:o,signature:s,message:a,primaryType:i,types:c,domain:u,...l}=t;return Cd(e,{address:n,factory:r,factoryData:o,hash:cu({message:a,primaryType:i,types:c,domain:u}),signature:s,...l})}(e,t),uninstallFilter:e=>ac(0,e),waitForTransactionReceipt:t=>async function(e,t){const{checkReplacement:n=!0,confirmations:r=1,hash:o,onReplaced:s,retryCount:a=6,retryDelay:i=({count:e})=>200*(1<<e),timeout:c=18e4}=t,u=Ar(["waitForTransactionReceipt",e.uid,o]),l=t.pollingInterval?t.pollingInterval:e.chain?.experimental_preconfirmationTime?e.chain.experimental_preconfirmationTime:e.pollingInterval;let d,f,h,p,m,g=!1;const{promise:b,resolve:y,reject:w}=Gi(),v=c?setTimeout(()=>{m?.(),p?.(),w(new Lr({hash:o}))},c):void 0;return p=Qi(u,{onReplaced:s,resolve:y,reject:w},async t=>{if(h=await Fe(e,dd,"getTransactionReceipt")({hash:o}).catch(()=>{}),h&&r<=1)return clearTimeout(v),t.resolve(h),void p?.();m=Fe(e,Rd,"watchBlockNumber")({emitMissed:!0,emitOnBegin:!0,poll:!0,pollingInterval:l,async onBlockNumber(s){const c=e=>{clearTimeout(v),m?.(),e(),p?.()};let u=s;if(!g)try{if(h){if(r>1&&(!h.blockNumber||u-h.blockNumber+1n<r))return;return void c(()=>t.resolve(h))}if(n&&!d&&(g=!0,await ic(async()=>{d=await Fe(e,ld,"getTransaction")({hash:o}),d.blockNumber&&(u=d.blockNumber)},{delay:i,retryCount:a}),g=!1),h=await Fe(e,dd,"getTransactionReceipt")({hash:o}),r>1&&(!h.blockNumber||u-h.blockNumber+1n<r))return;c(()=>t.resolve(h))}catch(n){if(n instanceof Fr||n instanceof jr){if(!d)return void(g=!1);try{f=d,g=!0;const n=await ic(()=>Fe(e,us,"getBlock")({blockNumber:u,includeTransactions:!0}),{delay:i,retryCount:a,shouldRetry:({error:e})=>e instanceof ss});g=!1;const o=n.transactions.find(({from:e,nonce:t})=>e===f.from&&t===f.nonce);if(!o)return;if(h=await Fe(e,dd,"getTransactionReceipt")({hash:o.hash}),r>1&&(!h.blockNumber||u-h.blockNumber+1n<r))return;let s="replaced";o.to===f.to&&o.value===f.value&&o.input===f.input?s="repriced":o.from===o.to&&0n===o.value&&(s="cancelled"),c(()=>{t.onReplaced?.({reason:s,replacedTransaction:f,transaction:o,transactionReceipt:h}),t.resolve(h)})}catch(e){c(()=>t.reject(e))}}else c(()=>t.reject(n))}}})}),b}(e,t),watchBlocks:t=>function(e,{blockTag:t=e.experimental_blockTag??"latest",emitMissed:n=!1,emitOnBegin:r=!1,onBlock:o,onError:s,includeTransactions:a,poll:i,pollingInterval:c=e.pollingInterval}){const u=void 0!==i?i:"webSocket"!==e.transport.type&&"ipc"!==e.transport.type&&("fallback"!==e.transport.type||"webSocket"!==e.transport.transports[0].config.type&&"ipc"!==e.transport.transports[0].config.type),l=a??!1;let d;return u?Qi(Ar(["watchBlocks",e.uid,t,n,r,l,c]),{onBlock:o,onError:s},o=>ec(async()=>{try{const r=await Fe(e,us,"getBlock")({blockTag:t,includeTransactions:l});if(null!==r.number&&null!=d?.number){if(r.number===d.number)return;if(r.number-d.number>1&&n)for(let t=d?.number+1n;t<r.number;t++){const n=await Fe(e,us,"getBlock")({blockNumber:t,includeTransactions:l});o.onBlock(n,d),d=n}}(null==d?.number||"pending"===t&&null==r?.number||null!==r.number&&r.number>d.number)&&(o.onBlock(r,d),d=r)}catch(e){o.onError?.(e)}},{emitOnBegin:r,interval:c})):(()=>{let n=!0,a=!0,i=()=>n=!1;return(async()=>{try{r&&Fe(e,us,"getBlock")({blockTag:t,includeTransactions:l}).then(e=>{n&&a&&(o(e,void 0),a=!1)}).catch(s);const c=(()=>{if("fallback"===e.transport.type){const t=e.transport.transports.find(e=>"webSocket"===e.config.type||"ipc"===e.config.type);return t?t.value:e.transport}return e.transport})(),{unsubscribe:u}=await c.subscribe({params:["newHeads"],async onData(t){if(!n)return;const r=await Fe(e,us,"getBlock")({blockNumber:t.result?.number,includeTransactions:l}).catch(()=>{});n&&(o(r,d),a=!1,d=r)},onError(e){s?.(e)}});i=u,n||i()}catch(e){s?.(e)}})(),()=>i()})()}(e,t),watchBlockNumber:t=>Rd(e,t),watchContractEvent:t=>function(e,t){const{abi:n,address:r,args:o,batch:s=!0,eventName:a,fromBlock:i,onError:c,onLogs:u,poll:l,pollingInterval:d=e.pollingInterval,strict:f}=t;return(void 0!==l?l:"bigint"==typeof i||"webSocket"!==e.transport.type&&"ipc"!==e.transport.type&&("fallback"!==e.transport.type||"webSocket"!==e.transport.transports[0].config.type&&"ipc"!==e.transport.transports[0].config.type))?(()=>{const t=f??!1;return Qi(Ar(["watchContractEvent",r,o,s,e.uid,a,d,t,i]),{onLogs:u,onError:c},c=>{let u,l;void 0!==i&&(u=i-1n);let f=!1;const h=ec(async()=>{if(f)try{let i;if(l)i=await Fe(e,sc,"getFilterChanges")({filter:l});else{const s=await Fe(e,oc,"getBlockNumber")({});i=u&&u<s?await Fe(e,qs,"getContractEvents")({abi:n,address:r,args:o,eventName:a,fromBlock:u+1n,toBlock:s,strict:t}):[],u=s}if(0===i.length)return;if(s)c.onLogs(i);else for(const e of i)c.onLogs([e])}catch(e){l&&e instanceof ro&&(f=!1),c.onError?.(e)}else{try{l=await Fe(e,or,"createContractEventFilter")({abi:n,address:r,args:o,eventName:a,strict:t,fromBlock:i})}catch{}f=!0}},{emitOnBegin:!0,interval:d});return async()=>{l&&await Fe(e,ac,"uninstallFilter")({filter:l}),h()}})})():(()=>{const t=f??!1,i=Ar(["watchContractEvent",r,o,s,e.uid,a,d,t]);let l=!0,h=()=>l=!1;return Qi(i,{onLogs:u,onError:c},t=>((async()=>{try{const s=(()=>{if("fallback"===e.transport.type){const t=e.transport.transports.find(e=>"webSocket"===e.config.type||"ipc"===e.config.type);return t?t.value:e.transport}return e.transport})(),i=a?tr({abi:n,eventName:a,args:o}):[],{unsubscribe:c}=await s.subscribe({params:["logs",{address:r,topics:i}],onData(e){if(!l)return;const r=e.result;try{const{eventName:e,args:o}=js({abi:n,data:r.data,topics:r.topics,strict:f}),s=Ds(r,{args:o,eventName:e});t.onLogs([s])}catch(e){let n,o;if(e instanceof ft||e instanceof ht){if(f)return;n=e.abiItem.name,o=e.abiItem.inputs?.some(e=>!("name"in e&&e.name))}const s=Ds(r,{args:o?[]:{},eventName:n});t.onLogs([s])}},onError(e){t.onError?.(e)}});h=c,l||h()}catch(e){c?.(e)}})(),()=>h()))})()}(e,t),watchEvent:t=>function(e,{address:t,args:n,batch:r=!0,event:o,events:s,fromBlock:a,onError:i,onLogs:c,poll:u,pollingInterval:l=e.pollingInterval,strict:d}){const f=void 0!==u?u:"bigint"==typeof a||"webSocket"!==e.transport.type&&"ipc"!==e.transport.type&&("fallback"!==e.transport.type||"webSocket"!==e.transport.transports[0].config.type&&"ipc"!==e.transport.transports[0].config.type),h=d??!1;return f?Qi(Ar(["watchEvent",t,n,r,e.uid,o,l,a]),{onLogs:c,onError:i},i=>{let c,u;void 0!==a&&(c=a-1n);let d=!1;const f=ec(async()=>{if(d)try{let a;if(u)a=await Fe(e,sc,"getFilterChanges")({filter:u});else{const r=await Fe(e,oc,"getBlockNumber")({});a=c&&c!==r?await Fe(e,Gs,"getLogs")({address:t,args:n,event:o,events:s,fromBlock:c+1n,toBlock:r}):[],c=r}if(0===a.length)return;if(r)i.onLogs(a);else for(const e of a)i.onLogs([e])}catch(e){u&&e instanceof ro&&(d=!1),i.onError?.(e)}else{try{u=await Fe(e,jc,"createEventFilter")({address:t,args:n,event:o,events:s,strict:h,fromBlock:a})}catch{}d=!0}},{emitOnBegin:!0,interval:l});return async()=>{u&&await Fe(e,ac,"uninstallFilter")({filter:u}),f()}}):(()=>{let r=!0,a=()=>r=!1;return(async()=>{try{const u=(()=>{if("fallback"===e.transport.type){const t=e.transport.transports.find(e=>"webSocket"===e.config.type||"ipc"===e.config.type);return t?t.value:e.transport}return e.transport})(),l=s??(o?[o]:void 0);let f=[];if(l){const e=l.flatMap(e=>tr({abi:[e],eventName:e.name,args:n}));f=[e],o&&(f=f[0])}const{unsubscribe:p}=await u.subscribe({params:["logs",{address:t,topics:f}],onData(e){if(!r)return;const t=e.result;try{const{eventName:e,args:n}=js({abi:l??[],data:t.data,topics:t.topics,strict:h}),r=Ds(t,{args:n,eventName:e});c([r])}catch(e){let n,r;if(e instanceof ft||e instanceof ht){if(d)return;n=e.abiItem.name,r=e.abiItem.inputs?.some(e=>!("name"in e&&e.name))}const o=Ds(t,{args:r?[]:{},eventName:n});c([o])}},onError(e){i?.(e)}});a=p,r||a()}catch(e){i?.(e)}})(),()=>a()})()}(e,t),watchPendingTransactions:t=>function(e,{batch:t=!0,onError:n,onTransactions:r,poll:o,pollingInterval:s=e.pollingInterval}){return(void 0!==o?o:"webSocket"!==e.transport.type&&"ipc"!==e.transport.type)?Qi(Ar(["watchPendingTransactions",e.uid,t,s]),{onTransactions:r,onError:n},n=>{let r;const o=ec(async()=>{try{if(!r)try{return void(r=await Fe(e,Lc,"createPendingTransactionFilter")({}))}catch(e){throw o(),e}const s=await Fe(e,sc,"getFilterChanges")({filter:r});if(0===s.length)return;if(t)n.onTransactions(s);else for(const e of s)n.onTransactions([e])}catch(e){n.onError?.(e)}},{emitOnBegin:!0,interval:s});return async()=>{r&&await Fe(e,ac,"uninstallFilter")({filter:r}),o()}}):(()=>{let t=!0,o=()=>t=!1;return(async()=>{try{const{unsubscribe:s}=await e.transport.subscribe({params:["newPendingTransactions"],onData(e){if(!t)return;const n=e.result;r([n])},onError(e){n?.(e)}});o=s,t||o()}catch(e){n?.(e)}})(),()=>o()})()}(e,t)}}function jd(e){const{key:t="public",name:n="Public Client"}=e,r=function(e){const{batch:t,chain:n,ccipRead:r,key:o="base",name:s="Base Client",type:a="base"}=e,i=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),l=e.pollingInterval??u,d=e.cacheTime??l,f=e.account?sr(e.account):void 0,{config:h,request:p,value:m}=e.transport({chain:n,pollingInterval:l}),g={account:f,batch:t,cacheTime:d,ccipRead:r,chain:n,key:o,name:s,pollingInterval:l,request:p,transport:{...h,...m},type:a,uid:fc(),...i?{experimental_blockTag:i}:{}};return Object.assign(g,{extend:function e(t){return n=>{const r=n(t);for(const e in g)delete r[e];const o={...t,...r};return Object.assign(o,{extend:e(o)})}}(g)})}({...e,key:t,name:n,type:"publicClient"});return r.extend(Fd)}class Ld extends We{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 Ud(e,t={}){const{batch:n,fetchFn:r,fetchOptions:o,key:s="http",methods:a,name:i="HTTP JSON-RPC",onFetchRequest:c,onFetchResponse:u,retryDelay:l,raw:d}=t;return({chain:f,retryCount:h,timeout:p})=>{const{batchSize:m=1e3,wait:g=0}="object"==typeof n?n:{},b=t.retryCount??h,y=p??t.timeout??1e4,w=e||f?.rpcUrls.default.http[0];if(!w)throw new Ld;const v=tu(w,{fetchFn:r,fetchOptions:o,onRequest:c,onResponse:u,timeout:y});return function({key:e,methods:t,name:n,request:r,retryCount:o=3,retryDelay:s=150,timeout:a,type:i},c){return{config:{key:e,methods:t,name:n,request:r,retryCount:o,retryDelay:s,timeout:a,type:i},request:Wc(r,{methods:t,retryCount:o,retryDelay:s,uid:fc()}),value:c}}({key:s,methods:a,name:i,async request({method:e,params:t}){const r={method:e,params:t},{schedule:o}=Vi({id:w,wait:g,shouldSplitBatch:e=>e.length>m,fn:e=>v.request({body:e}),sort:(e,t)=>e.id-t.id}),[{error:s,result:a}]=await(async e=>n?o(e):[await v.request({body:e})])(r);if(d)return{error:s,result:a};if(s)throw new Yr({body:r,error:s,url:w});return a},retryCount:b,retryDelay:l,timeout:y,type:"http"},{fetchOptions:o,url:w})}}function Dd(e,t,n){for(let n in t){let r=t[n];Object.defineProperty(e,n,{enumerable:!0,value:r,writable:!1})}}function Gd(e,t){if(null==e)return"null";if(null==t&&(t=new Set),"object"==typeof e){if(t.has(e))return"[Circular]";t.add(e)}if(Array.isArray(e))return"[ "+e.map(e=>Gd(e,t)).join(", ")+" ]";if(e instanceof Uint8Array){const t="0123456789abcdef";let n="0x";for(let r=0;r<e.length;r++)n+=t[e[r]>>4],n+=t[15&e[r]];return n}if("object"==typeof e&&"function"==typeof e.toJSON)return Gd(e.toJSON(),t);switch(typeof e){case"boolean":case"number":case"symbol":return e.toString();case"bigint":return BigInt(e).toString();case"string":return JSON.stringify(e);case"object":{const n=Object.keys(e);return n.sort(),"{ "+n.map(n=>`${Gd(n,t)}: ${Gd(e[n],t)}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function qd(e,t,n,r){if(!e)throw function(e,t,n){let r,o=e;{const r=[];if(n){if("message"in n||"code"in n||"name"in n)throw new Error(`value will overwrite populated values: ${Gd(n)}`);for(const e in n){if("shortMessage"===e)continue;const t=n[e];r.push(e+"="+Gd(t))}}r.push(`code=${t}`),r.push("version=6.15.0"),r.length&&(e+=" ("+r.join(", ")+")")}switch(t){case"INVALID_ARGUMENT":r=new TypeError(e);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":r=new RangeError(e);break;default:r=new Error(e)}return Dd(r,{code:t}),n&&Object.assign(r,n),null==r.shortMessage&&Dd(r,{shortMessage:o}),r}(t,n,r)}function Vd(e,t,n,r){qd(e,t,"INVALID_ARGUMENT",{argument:n,value:r})}function Wd(e,t){return function(e,t){if(e instanceof Uint8Array)return e;if("string"==typeof e&&e.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)){const t=new Uint8Array((e.length-2)/2);let n=2;for(let r=0;r<t.length;r++)t[r]=parseInt(e.substring(n,n+2),16),n+=2;return t}Vd(!1,"invalid BytesLike value",t,e)}(e,t)}["NFD","NFC","NFKD","NFKC"].reduce((e,t)=>{try{if("test"!=="test".normalize(t))throw new Error("bad");if("NFD"===t){const e=String.fromCharCode(233).normalize("NFD");if(e!==String.fromCharCode(101,769))throw new Error("broken")}e.push(t)}catch(e){}return e},[]);const Hd=BigInt(0),Yd=BigInt(1),Zd=9007199254740991;function Kd(e,t){const n=Xd(e,"value"),r=BigInt(tf(t,"width"));if(qd(n>>r===Hd,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:e}),n>>r-Yd){return-((~n&(Yd<<r)-Yd)+Yd)}return n}function Jd(e,t){const n=Xd(e,"value"),r=BigInt(tf(t,"bits"));return n&(Yd<<r)-Yd}function Qd(e,t){switch(typeof e){case"bigint":return e;case"number":return Vd(Number.isInteger(e),"underflow",t||"value",e),Vd(e>=-Zd&&e<=Zd,"overflow",t||"value",e),BigInt(e);case"string":try{if(""===e)throw new Error("empty string");return"-"===e[0]&&"-"!==e[1]?-BigInt(e.substring(1)):BigInt(e)}catch(n){Vd(!1,`invalid BigNumberish string: ${n.message}`,t||"value",e)}}Vd(!1,"invalid BigNumberish value",t||"value",e)}function Xd(e,t){const n=Qd(e,t);return qd(n>=Hd,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:e}),n}const ef="0123456789abcdef";function tf(e,t){switch(typeof e){case"bigint":return Vd(e>=-Zd&&e<=Zd,"overflow",t||"value",e),Number(e);case"number":return Vd(Number.isInteger(e),"underflow",t||"value",e),Vd(e>=-Zd&&e<=Zd,"overflow",t||"value",e),e;case"string":try{if(""===e)throw new Error("empty string");return tf(BigInt(e),t)}catch(n){Vd(!1,`invalid numeric string: ${n.message}`,t||"value",e)}}Vd(!1,"invalid numeric value",t||"value",e)}const nf=BigInt(-1),rf=BigInt(0),of=BigInt(1),sf=BigInt(5),af={};let cf="0000";for(;cf.length<80;)cf+=cf;function uf(e){let t=cf;for(;t.length<e;)t+=t;return BigInt("1"+t.substring(0,e))}function lf(e,t,n){const r=BigInt(t.width);if(t.signed){const t=of<<r-of;qd(null==n||e>=-t&&e<t,"overflow","NUMERIC_FAULT",{operation:n,fault:"overflow",value:e}),e=e>rf?Kd(Jd(e,r),r):-Kd(Jd(-e,r),r)}else{const t=of<<r;qd(null==n||e>=0&&e<t,"overflow","NUMERIC_FAULT",{operation:n,fault:"overflow",value:e}),e=(e%t+t)%t&t-of}return e}function df(e){"number"==typeof e&&(e=`fixed128x${e}`);let t=!0,n=128,r=18;if("string"==typeof e)if("fixed"===e);else if("ufixed"===e)t=!1;else{const o=e.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);Vd(o,"invalid fixed format","format",e),t="u"!==o[1],n=parseInt(o[2]),r=parseInt(o[3])}else if(e){const o=e,s=(e,t,n)=>null==o[e]?n:(Vd(typeof o[e]===t,"invalid fixed format ("+e+" not "+t+")","format."+e,o[e]),o[e]);t=s("signed","boolean",t),n=s("width","number",n),r=s("decimals","number",r)}Vd(n%8==0,"invalid FixedNumber width (not byte aligned)","format.width",n),Vd(r<=80,"invalid FixedNumber decimals (too large)","format.decimals",r);return{signed:t,width:n,decimals:r,name:(t?"":"u")+"fixed"+String(n)+"x"+String(r)}}class ff{format;#e;#t;#n;_value;constructor(e,t,n){!function(e,t,n){if(e!==t){let e=n,t="new";e+=".",t+=" "+n,qd(!1,`private constructor; use ${e}from* methods`,"UNSUPPORTED_OPERATION",{operation:t})}}(e,af,"FixedNumber"),this.#t=t,this.#e=n;const r=function(e,t){let n="";e<rf&&(n="-",e*=nf);let r=e.toString();if(0===t)return n+r;for(;r.length<=t;)r=cf+r;const o=r.length-t;for(r=r.substring(0,o)+"."+r.substring(o);"0"===r[0]&&"."!==r[1];)r=r.substring(1);for(;"0"===r[r.length-1]&&"."!==r[r.length-2];)r=r.substring(0,r.length-1);return n+r}(t,n.decimals);Dd(this,{format:n.name,_value:r}),this.#n=uf(n.decimals)}get signed(){return this.#e.signed}get width(){return this.#e.width}get decimals(){return this.#e.decimals}get value(){return this.#t}#r(e){Vd(this.format===e.format,"incompatible format; use fixedNumber.toFormat","other",e)}#o(e,t){return e=lf(e,this.#e,t),new ff(af,e,this.#e)}#s(e,t){return this.#r(e),this.#o(this.#t+e.#t,t)}addUnsafe(e){return this.#s(e)}add(e){return this.#s(e,"add")}#a(e,t){return this.#r(e),this.#o(this.#t-e.#t,t)}subUnsafe(e){return this.#a(e)}sub(e){return this.#a(e,"sub")}#i(e,t){return this.#r(e),this.#o(this.#t*e.#t/this.#n,t)}mulUnsafe(e){return this.#i(e)}mul(e){return this.#i(e,"mul")}mulSignal(e){this.#r(e);const t=this.#t*e.#t;return qd(t%this.#n===rf,"precision lost during signalling mul","NUMERIC_FAULT",{operation:"mulSignal",fault:"underflow",value:this}),this.#o(t/this.#n,"mulSignal")}#c(e,t){return qd(e.#t!==rf,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),this.#r(e),this.#o(this.#t*this.#n/e.#t,t)}divUnsafe(e){return this.#c(e)}div(e){return this.#c(e,"div")}divSignal(e){qd(e.#t!==rf,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),this.#r(e);const t=this.#t*this.#n;return qd(t%e.#t===rf,"precision lost during signalling div","NUMERIC_FAULT",{operation:"divSignal",fault:"underflow",value:this}),this.#o(t/e.#t,"divSignal")}cmp(e){let t=this.value,n=e.value;const r=this.decimals-e.decimals;return r>0?n*=uf(r):r<0&&(t*=uf(-r)),t<n?-1:t>n?1:0}eq(e){return 0===this.cmp(e)}lt(e){return this.cmp(e)<0}lte(e){return this.cmp(e)<=0}gt(e){return this.cmp(e)>0}gte(e){return this.cmp(e)>=0}floor(){let e=this.#t;return this.#t<rf&&(e-=this.#n-of),e=this.#t/this.#n*this.#n,this.#o(e,"floor")}ceiling(){let e=this.#t;return this.#t>rf&&(e+=this.#n-of),e=this.#t/this.#n*this.#n,this.#o(e,"ceiling")}round(e){if(null==e&&(e=0),e>=this.decimals)return this;const t=this.decimals-e,n=sf*uf(t-1);let r=this.value+n;const o=uf(t);return r=r/o*o,lf(r,this.#e,"round"),new ff(af,r,this.#e)}isZero(){return this.#t===rf}isNegative(){return this.#t<rf}toString(){return this._value}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return ff.fromString(this.toString(),e)}static fromValue(e,t,n){const r=null==t?0:tf(t),o=df(n);let s=Qd(e,"value");const a=r-o.decimals;if(a>0){const t=uf(a);qd(s%t===rf,"value loses precision for format","NUMERIC_FAULT",{operation:"fromValue",fault:"underflow",value:e}),s/=t}else a<0&&(s*=uf(-a));return lf(s,o,"fromValue"),new ff(af,s,o)}static fromString(e,t){const n=e.match(/^(-?)([0-9]*)\.?([0-9]*)$/);Vd(n&&n[2].length+n[3].length>0,"invalid FixedNumber string value","value",e);const r=df(t);let o=n[2]||"0",s=n[3]||"";for(;s.length<r.decimals;)s+=cf;qd(s.substring(r.decimals).match(/^0*$/),"too many decimals for format","NUMERIC_FAULT",{operation:"fromString",fault:"underflow",value:e}),s=s.substring(0,r.decimals);const a=BigInt(n[1]+o+s);return lf(a,r,"fromString"),new ff(af,a,r)}static fromBytes(e,t){let n=function(e){if(e instanceof Uint8Array){let t="0x0";for(const n of e)t+=ef[n>>4],t+=ef[15&n];return BigInt(t)}return Qd(e)}(Wd(e,"value"));const r=df(t);return r.signed&&(n=Kd(n,r.width)),lf(n,r,"fromBytes"),new ff(af,n,r)}}function hf(e){return function(e,t){let n=18;return n=tf(t,"unit"),ff.fromValue(e,n,{decimals:n,width:512}).toString()}(e,18)}const pf="0.38.13";function mf({projectId:e,originComponentName:t,...n}){const r=new URL("https://pay.coinbase.com/buy");void 0!==e&&r.searchParams.append("appId",e);for(const e of Object.keys(n)){const t=n[e];void 0!==t&&(["string","number","boolean"].includes(typeof t)?r.searchParams.append(e,t.toString()):r.searchParams.append(e,JSON.stringify(t)))}return t?r.searchParams.append("sdkVersion",`onchainkit@${pf}:${t}`):r.searchParams.append("sdkVersion",`onchainkit@${pf}`),r.searchParams.sort(),r.toString()}var gf=[],bf=[],yf="undefined"!=typeof Uint8Array?Uint8Array:Array,wf=!1;function vf(){wf=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)gf[t]=e[t],bf[e.charCodeAt(t)]=t;bf["-".charCodeAt(0)]=62,bf["_".charCodeAt(0)]=63}function xf(e){return gf[e>>18&63]+gf[e>>12&63]+gf[e>>6&63]+gf[63&e]}function Ef(e,t,n){for(var r,o=[],s=t;s<n;s+=3)r=(e[s]<<16)+(e[s+1]<<8)+e[s+2],o.push(xf(r));return o.join("")}function Pf(e){var t;wf||vf();for(var n=e.length,r=n%3,o="",s=[],a=16383,i=0,c=n-r;i<c;i+=a)s.push(Ef(e,i,i+a>c?c:i+a));return 1===r?(t=e[n-1],o+=gf[t>>2],o+=gf[t<<4&63],o+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],o+=gf[t>>10],o+=gf[t>>4&63],o+=gf[t<<2&63],o+="="),s.push(o),s.join("")}function kf(e,t,n,r,o){var s,a,i=8*o-r-1,c=(1<<i)-1,u=c>>1,l=-7,d=n?o-1:0,f=n?-1:1,h=e[t+d];for(d+=f,s=h&(1<<-l)-1,h>>=-l,l+=i;l>0;s=256*s+e[t+d],d+=f,l-=8);for(a=s&(1<<-l)-1,s>>=-l,l+=r;l>0;a=256*a+e[t+d],d+=f,l-=8);if(0===s)s=1-u;else{if(s===c)return a?NaN:1/0*(h?-1:1);a+=Math.pow(2,r),s-=u}return(h?-1:1)*a*Math.pow(2,s-r)}function Af(e,t,n,r,o,s){var a,i,c,u=8*s-o-1,l=(1<<u)-1,d=l>>1,f=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:s-1,p=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(i=isNaN(t)?1:0,a=l):(a=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-a))<1&&(a--,c*=2),(t+=a+d>=1?f/c:f*Math.pow(2,1-d))*c>=2&&(a++,c/=2),a+d>=l?(i=0,a=l):a+d>=1?(i=(t*c-1)*Math.pow(2,o),a+=d):(i=t*Math.pow(2,d-1)*Math.pow(2,o),a=0));o>=8;e[n+h]=255&i,h+=p,i/=256,o-=8);for(a=a<<o|i,u+=o;u>0;e[n+h]=255&a,h+=p,a/=256,u-=8);e[n+h-p]|=128*m}var If={}.toString,Nf=Array.isArray||function(e){return"[object Array]"==If.call(e)};function Sf(){return $f.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Tf(e,t){if(Sf()<t)throw new RangeError("Invalid typed array length");return $f.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=$f.prototype:(null===e&&(e=new $f(t)),e.length=t),e}function $f(e,t,n){if(!($f.TYPED_ARRAY_SUPPORT||this instanceof $f))return new $f(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return Of(this,e)}return Bf(this,e,t,n)}function Bf(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r);$f.TYPED_ARRAY_SUPPORT?(e=t).__proto__=$f.prototype:e=Rf(e,t);return e}(e,t,n,r):"string"==typeof t?function(e,t,n){"string"==typeof n&&""!==n||(n="utf8");if(!$f.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|Mf(t,n);e=Tf(e,r);var o=e.write(t,n);o!==r&&(e=e.slice(0,o));return e}(e,t,n):function(e,t){if(_f(t)){var n=0|zf(t.length);return 0===(e=Tf(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?Tf(e,0):Rf(e,t);if("Buffer"===t.type&&Nf(t.data))return Rf(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function Cf(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function Of(e,t){if(Cf(t),e=Tf(e,t<0?0:0|zf(t)),!$f.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function Rf(e,t){var n=t.length<0?0:0|zf(t.length);e=Tf(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function zf(e){if(e>=Sf())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Sf().toString(16)+" bytes");return 0|e}function _f(e){return!(null==e||!e._isBuffer)}function Mf(e,t){if(_f(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return lh(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return dh(e).length;default:if(r)return lh(e).length;t=(""+t).toLowerCase(),r=!0}}function Ff(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Xf(this,t,n);case"utf8":case"utf-8":return Zf(this,t,n);case"ascii":return Jf(this,t,n);case"latin1":case"binary":return Qf(this,t,n);case"base64":return Yf(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return eh(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function jf(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function Lf(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=$f.from(t,r)),_f(t))return 0===t.length?-1:Uf(e,t,n,r,o);if("number"==typeof t)return t&=255,$f.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):Uf(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function Uf(e,t,n,r,o){var s,a=1,i=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;a=2,i/=2,c/=2,n/=2}function u(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(o){var l=-1;for(s=n;s<i;s++)if(u(e,s)===u(t,-1===l?0:s-l)){if(-1===l&&(l=s),s-l+1===c)return l*a}else-1!==l&&(s-=s-l),l=-1}else for(n+c>i&&(n=i-c),s=n;s>=0;s--){for(var d=!0,f=0;f<c;f++)if(u(e,s+f)!==u(t,f)){d=!1;break}if(d)return s}return-1}function Df(e,t,n,r){n=Number(n)||0;var o=e.length-n;r?(r=Number(r))>o&&(r=o):r=o;var s=t.length;if(s%2!=0)throw new TypeError("Invalid hex string");r>s/2&&(r=s/2);for(var a=0;a<r;++a){var i=parseInt(t.substr(2*a,2),16);if(isNaN(i))return a;e[n+a]=i}return a}function Gf(e,t,n,r){return fh(lh(t,e.length-n),e,n,r)}function qf(e,t,n,r){return fh(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function Vf(e,t,n,r){return qf(e,t,n,r)}function Wf(e,t,n,r){return fh(dh(t),e,n,r)}function Hf(e,t,n,r){return fh(function(e,t){for(var n,r,o,s=[],a=0;a<e.length&&!((t-=2)<0);++a)r=(n=e.charCodeAt(a))>>8,o=n%256,s.push(o),s.push(r);return s}(t,e.length-n),e,n,r)}function Yf(e,t,n){return 0===t&&n===e.length?Pf(e):Pf(e.slice(t,n))}function Zf(e,t,n){n=Math.min(e.length,n);for(var r=[],o=t;o<n;){var s,a,i,c,u=e[o],l=null,d=u>239?4:u>223?3:u>191?2:1;if(o+d<=n)switch(d){case 1:u<128&&(l=u);break;case 2:128==(192&(s=e[o+1]))&&(c=(31&u)<<6|63&s)>127&&(l=c);break;case 3:s=e[o+1],a=e[o+2],128==(192&s)&&128==(192&a)&&(c=(15&u)<<12|(63&s)<<6|63&a)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:s=e[o+1],a=e[o+2],i=e[o+3],128==(192&s)&&128==(192&a)&&128==(192&i)&&(c=(15&u)<<18|(63&s)<<12|(63&a)<<6|63&i)>65535&&c<1114112&&(l=c)}null===l?(l=65533,d=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),o+=d}return function(e){var t=e.length;if(t<=Kf)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=Kf));return n}(r)}$f.TYPED_ARRAY_SUPPORT=void 0===globalThis.TYPED_ARRAY_SUPPORT||globalThis.TYPED_ARRAY_SUPPORT,Sf(),$f.poolSize=8192,$f._augment=function(e){return e.__proto__=$f.prototype,e},$f.from=function(e,t,n){return Bf(null,e,t,n)},$f.TYPED_ARRAY_SUPPORT&&($f.prototype.__proto__=Uint8Array.prototype,$f.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&$f[Symbol.species]),$f.alloc=function(e,t,n){return function(e,t,n,r){return Cf(t),t<=0?Tf(e,t):void 0!==n?"string"==typeof r?Tf(e,t).fill(n,r):Tf(e,t).fill(n):Tf(e,t)}(null,e,t,n)},$f.allocUnsafe=function(e){return Of(null,e)},$f.allocUnsafeSlow=function(e){return Of(null,e)},$f.isBuffer=function(e){return null!=e&&(!!e._isBuffer||hh(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&hh(e.slice(0,0))}(e))},$f.compare=function(e,t){if(!_f(e)||!_f(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,o=0,s=Math.min(n,r);o<s;++o)if(e[o]!==t[o]){n=e[o],r=t[o];break}return n<r?-1:r<n?1:0},$f.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},$f.concat=function(e,t){if(!Nf(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return $f.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=$f.allocUnsafe(t),o=0;for(n=0;n<e.length;++n){var s=e[n];if(!_f(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,o),o+=s.length}return r},$f.byteLength=Mf,$f.prototype._isBuffer=!0,$f.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)jf(this,t,t+1);return this},$f.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)jf(this,t,t+3),jf(this,t+1,t+2);return this},$f.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)jf(this,t,t+7),jf(this,t+1,t+6),jf(this,t+2,t+5),jf(this,t+3,t+4);return this},$f.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?Zf(this,0,e):Ff.apply(this,arguments)},$f.prototype.equals=function(e){if(!_f(e))throw new TypeError("Argument must be a Buffer");return this===e||0===$f.compare(this,e)},$f.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},$f.prototype.compare=function(e,t,n,r,o){if(!_f(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(this===e)return 0;for(var s=(o>>>=0)-(r>>>=0),a=(n>>>=0)-(t>>>=0),i=Math.min(s,a),c=this.slice(r,o),u=e.slice(t,n),l=0;l<i;++l)if(c[l]!==u[l]){s=c[l],a=u[l];break}return s<a?-1:a<s?1:0},$f.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},$f.prototype.indexOf=function(e,t,n){return Lf(this,e,t,n,!0)},$f.prototype.lastIndexOf=function(e,t,n){return Lf(this,e,t,n,!1)},$f.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-t;if((void 0===n||n>o)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var s=!1;;)switch(r){case"hex":return Df(this,e,t,n);case"utf8":case"utf-8":return Gf(this,e,t,n);case"ascii":return qf(this,e,t,n);case"latin1":case"binary":return Vf(this,e,t,n);case"base64":return Wf(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Hf(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}},$f.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Kf=4096;function Jf(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(127&e[o]);return r}function Qf(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(e[o]);return r}function Xf(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var o="",s=t;s<n;++s)o+=uh(e[s]);return o}function eh(e,t,n){for(var r=e.slice(t,n),o="",s=0;s<r.length;s+=2)o+=String.fromCharCode(r[s]+256*r[s+1]);return o}function th(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function nh(e,t,n,r,o,s){if(!_f(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<s)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function rh(e,t,n,r){t<0&&(t=65535+t+1);for(var o=0,s=Math.min(e.length-n,2);o<s;++o)e[n+o]=(t&255<<8*(r?o:1-o))>>>8*(r?o:1-o)}function oh(e,t,n,r){t<0&&(t=4294967295+t+1);for(var o=0,s=Math.min(e.length-n,4);o<s;++o)e[n+o]=t>>>8*(r?o:3-o)&255}function sh(e,t,n,r,o,s){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function ah(e,t,n,r,o){return o||sh(e,0,n,4),Af(e,t,n,r,23,4),n+4}function ih(e,t,n,r,o){return o||sh(e,0,n,8),Af(e,t,n,r,52,8),n+8}$f.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),$f.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=$f.prototype;else{var o=t-e;n=new $f(o,void 0);for(var s=0;s<o;++s)n[s]=this[s+e]}return n},$f.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||th(e,t,this.length);for(var r=this[e],o=1,s=0;++s<t&&(o*=256);)r+=this[e+s]*o;return r},$f.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||th(e,t,this.length);for(var r=this[e+--t],o=1;t>0&&(o*=256);)r+=this[e+--t]*o;return r},$f.prototype.readUInt8=function(e,t){return t||th(e,1,this.length),this[e]},$f.prototype.readUInt16LE=function(e,t){return t||th(e,2,this.length),this[e]|this[e+1]<<8},$f.prototype.readUInt16BE=function(e,t){return t||th(e,2,this.length),this[e]<<8|this[e+1]},$f.prototype.readUInt32LE=function(e,t){return t||th(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},$f.prototype.readUInt32BE=function(e,t){return t||th(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},$f.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||th(e,t,this.length);for(var r=this[e],o=1,s=0;++s<t&&(o*=256);)r+=this[e+s]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*t)),r},$f.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||th(e,t,this.length);for(var r=t,o=1,s=this[e+--r];r>0&&(o*=256);)s+=this[e+--r]*o;return s>=(o*=128)&&(s-=Math.pow(2,8*t)),s},$f.prototype.readInt8=function(e,t){return t||th(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},$f.prototype.readInt16LE=function(e,t){t||th(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},$f.prototype.readInt16BE=function(e,t){t||th(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},$f.prototype.readInt32LE=function(e,t){return t||th(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},$f.prototype.readInt32BE=function(e,t){return t||th(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},$f.prototype.readFloatLE=function(e,t){return t||th(e,4,this.length),kf(this,e,!0,23,4)},$f.prototype.readFloatBE=function(e,t){return t||th(e,4,this.length),kf(this,e,!1,23,4)},$f.prototype.readDoubleLE=function(e,t){return t||th(e,8,this.length),kf(this,e,!0,52,8)},$f.prototype.readDoubleBE=function(e,t){return t||th(e,8,this.length),kf(this,e,!1,52,8)},$f.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||nh(this,e,t,n,Math.pow(2,8*n)-1,0);var o=1,s=0;for(this[t]=255&e;++s<n&&(o*=256);)this[t+s]=e/o&255;return t+n},$f.prototype.writeUIntBE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||nh(this,e,t,n,Math.pow(2,8*n)-1,0);var o=n-1,s=1;for(this[t+o]=255&e;--o>=0&&(s*=256);)this[t+o]=e/s&255;return t+n},$f.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||nh(this,e,t,1,255,0),$f.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},$f.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||nh(this,e,t,2,65535,0),$f.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):rh(this,e,t,!0),t+2},$f.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||nh(this,e,t,2,65535,0),$f.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):rh(this,e,t,!1),t+2},$f.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||nh(this,e,t,4,4294967295,0),$f.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):oh(this,e,t,!0),t+4},$f.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||nh(this,e,t,4,4294967295,0),$f.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):oh(this,e,t,!1),t+4},$f.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);nh(this,e,t,n,o-1,-o)}var s=0,a=1,i=0;for(this[t]=255&e;++s<n&&(a*=256);)e<0&&0===i&&0!==this[t+s-1]&&(i=1),this[t+s]=(e/a|0)-i&255;return t+n},$f.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);nh(this,e,t,n,o-1,-o)}var s=n-1,a=1,i=0;for(this[t+s]=255&e;--s>=0&&(a*=256);)e<0&&0===i&&0!==this[t+s+1]&&(i=1),this[t+s]=(e/a|0)-i&255;return t+n},$f.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||nh(this,e,t,1,127,-128),$f.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},$f.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||nh(this,e,t,2,32767,-32768),$f.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):rh(this,e,t,!0),t+2},$f.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||nh(this,e,t,2,32767,-32768),$f.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):rh(this,e,t,!1),t+2},$f.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||nh(this,e,t,4,2147483647,-2147483648),$f.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):oh(this,e,t,!0),t+4},$f.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||nh(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),$f.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):oh(this,e,t,!1),t+4},$f.prototype.writeFloatLE=function(e,t,n){return ah(this,e,t,!0,n)},$f.prototype.writeFloatBE=function(e,t,n){return ah(this,e,t,!1,n)},$f.prototype.writeDoubleLE=function(e,t,n){return ih(this,e,t,!0,n)},$f.prototype.writeDoubleBE=function(e,t,n){return ih(this,e,t,!1,n)},$f.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var o,s=r-n;if(this===e&&n<t&&t<r)for(o=s-1;o>=0;--o)e[o+t]=this[o+n];else if(s<1e3||!$f.TYPED_ARRAY_SUPPORT)for(o=0;o<s;++o)e[o+t]=this[o+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+s),t);return s},$f.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var o=e.charCodeAt(0);o<256&&(e=o)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!$f.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var s;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(s=t;s<n;++s)this[s]=e;else{var a=_f(e)?e:lh(new $f(e,r).toString()),i=a.length;for(s=0;s<n-t;++s)this[s+t]=a[s%i]}return this};var ch=/[^+\/0-9A-Za-z-_]/g;function uh(e){return e<16?"0"+e.toString(16):e.toString(16)}function lh(e,t){var n;t=t||1/0;for(var r=e.length,o=null,s=[],a=0;a<r;++a){if((n=e.charCodeAt(a))>55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(a+1===r){(t-=3)>-1&&s.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&s.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&s.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;s.push(n)}else if(n<2048){if((t-=2)<0)break;s.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;s.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return s}function dh(e){return function(e){var t,n,r,o,s,a;wf||vf();var i=e.length;if(i%4>0)throw new Error("Invalid string. Length must be a multiple of 4");s="="===e[i-2]?2:"="===e[i-1]?1:0,a=new yf(3*i/4-s),r=s>0?i-4:i;var c=0;for(t=0,n=0;t<r;t+=4,n+=3)o=bf[e.charCodeAt(t)]<<18|bf[e.charCodeAt(t+1)]<<12|bf[e.charCodeAt(t+2)]<<6|bf[e.charCodeAt(t+3)],a[c++]=o>>16&255,a[c++]=o>>8&255,a[c++]=255&o;return 2===s?(o=bf[e.charCodeAt(t)]<<2|bf[e.charCodeAt(t+1)]>>4,a[c++]=255&o):1===s&&(o=bf[e.charCodeAt(t)]<<10|bf[e.charCodeAt(t+1)]<<4|bf[e.charCodeAt(t+2)]>>2,a[c++]=o>>8&255,a[c++]=255&o),a}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(ch,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function fh(e,t,n,r){for(var o=0;o<r&&!(o+n>=t.length||o>=e.length);++o)t[o+n]=e[o];return o}function hh(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}class ph{constructor(e){this.selectedWalletId=null,this.solanaConnection=null,this.ethereumProvider=null,this.walletInfo=null,this.phantomAdapter=null,this.walletType="embedded",this.ethereumNetwork=null,this.defaultNetwork=exports.Network.Solana,this.api=h.default.create({baseURL:e.baseURL,headers:{"Content-Type":"application/json"}}),this.middleAccountApi=h.default.create({baseURL:e.middleAccountBaseURL||"https://yeezy-payment-service-sit-a0dchfccbufeh5bx.z03.azurefd.net",headers:{"Content-Type":"application/json"}}),this.solanaCluster=e.solanaCluster,this.solanaConnection=new t.Connection(e.solanaCluster.rpcUrl),e.ethereumNetwork&&(this.ethereumNetwork={...e.ethereumNetwork,chainId:Number(e.ethereumNetwork.chainId)},this.ethereumProvider=jd({transport:Ud(e.ethereumNetwork.rpcUrl)})),this.defaultNetwork=e.defaultNetwork||exports.Network.Solana}setWallet(e){this.walletInfo=e}setWalletType(e){this.walletType=e,x.saveWalletType(e)}getWallet(){return this.walletInfo}getPhantomAdapter(){return this.phantomAdapter}getWalletType(){return this.walletType}get wallet(){var e;return(null===(e=this.walletInfo)||void 0===e?void 0:e.wallets.find(e=>e.network===this.defaultNetwork))||null}get address(){var e;return(null===(e=this.wallet)||void 0===e?void 0:e.address)||null}get network(){var e;return(null===(e=this.wallet)||void 0===e?void 0:e.network)||null}get ethereumWallet(){var e;return(null===(e=this.walletInfo)||void 0===e?void 0:e.wallets.find(e=>e.network===exports.Network.Ethereum&&"Main"===e.wallet_set))||null}get ethereumAddress(){var e;return(null===(e=this.ethereumWallet)||void 0===e?void 0:e.address)||null}get solanaWallet(){var e;return(null===(e=this.walletInfo)||void 0===e?void 0:e.wallets.find(e=>e.network===exports.Network.Solana&&"Main"===e.wallet_set))||null}get forwardSolanaWallet(){var e;return(null===(e=this.walletInfo)||void 0===e?void 0:e.wallets.find(e=>e.network===exports.Network.Solana&&"Forward-0"===e.wallet_set))||null}get forwardSolanaAddress(){var e;return(null===(e=this.forwardSolanaWallet)||void 0===e?void 0:e.address)||null}get forwardEthereumWallet(){var e;return(null===(e=this.walletInfo)||void 0===e?void 0:e.wallets.find(e=>e.network===exports.Network.Ethereum&&"Forward-0"===e.wallet_set))||null}get forwardEthereumAddress(){var e;return(null===(e=this.forwardEthereumWallet)||void 0===e?void 0:e.address)||null}get solanaAddress(){var e;return(null===(e=this.solanaWallet)||void 0===e?void 0:e.address)||null}get id(){var e;return(null===(e=this.walletInfo)||void 0===e?void 0:e.id)||null}get social_links(){var e;return(null===(e=this.walletInfo)||void 0===e?void 0:e.social_links)||null}async reconnect(){try{if("phantom"===x.getWalletType())return await this.connectPhantom();{const e=await this.getSession();return this.setWallet(e),e}}catch(e){return null}}async connectPhantom(){try{if(this.phantomAdapter||(this.phantomAdapter=new U),await this.phantomAdapter.connect(),!this.phantomAdapter.publicKey)throw new Error("Failed to connect to Phantom wallet");const e=this.phantomAdapter.publicKey.toString(),t={id:r.v4(),is_exported:!1,address:e,network:exports.Network.Solana,type:exports.WalletType.Phantom,wallets:[{id:e,address:e,network:exports.Network.Solana,wallet_type:exports.WalletType.Phantom,wallet_set:"Main"}],social_links:[],social_infos:[],account_info:{name:null}};return this.setWallet(t),this.setWalletType("phantom"),t}catch(e){throw console.error("Phantom connect error:",e),new Error(e instanceof Error?e.message:"Failed to connect to Phantom wallet")}}async updateAccountName(e){if(!this.walletInfo)throw new Error("No wallet info");const t=await this.api.post("/account/update",{name:e},{withCredentials:!0});return this.walletInfo.account_info.name=e,t.data}async signSolanaTransaction(e){try{if(!this.walletInfo)throw new Error("No wallet info");if(!this.solanaConnection)throw new Error("No rpc connection");const{blockhash:n}=await this.solanaConnection.getLatestBlockhash();if(b(e)?e.message.recentBlockhash=n:e.recentBlockhash=n,this.phantomAdapter&&this.phantomAdapter.publicKey)return await this.phantomAdapter.signTransaction(e);const r=this.solanaWallet;if(!r)throw new Error("No solana wallet available");const o={user_id:this.walletInfo.id,address:r.address,network:exports.Network.Solana,tx:{Solana:p.default.encode(b(e)?e.message.serialize():e.serializeMessage())}},s=await this.api.post("/sign2",o,{withCredentials:!0}),{signature:a}=s.data;return e.addSignature(new t.PublicKey(r.address),$f.from(p.default.decode(a))),e}catch(e){throw new Error(e instanceof Error?e.message:"Failed to sign transaction")}}async signEthereumEip712(e){if(!this.ethereumNetwork)throw new Error("No Ethereum network");if(!this.ethereumProvider)throw new Error("No Ethereum provider");if(!this.walletInfo)throw new Error("No wallet info");if(!this.ethereumAddress)throw new Error("No Ethereum address");const t={user_id:this.walletInfo.id,address:this.ethereumAddress,network:exports.Network.Ethereum,tx:{EthereumEip712:e}},n=await this.api.post("/sign2",t,{withCredentials:!0}),{signature:r}=n.data;return r}async sendSolanaTransaction(e){if(!this.solanaConnection)throw new Error("No rpc connection");try{return await this.solanaConnection.sendRawTransaction(e,{maxRetries:3,skipPreflight:!1})}catch(e){throw e}}async sendEthereumTransaction(e){if(!this.ethereumProvider)throw new Error("No Ethereum provider");try{return await this.ethereumProvider.sendRawTransaction({serializedTransaction:e})}catch(e){throw e}}async sendEmailVerificationCode(e){await this.api.post("/send_verification",{email:e})}async sendPhoneVerificationCode(e){e.startsWith("+")||(e=`+${e}`),await this.api.post("/send_verification",{phone:e,type:"phone"})}async verifyEmailVerificationCode({email:e,code:t}){const n={type:"Email",data:{network:this.defaultNetwork,email:e,code:t}},r=(await this.api.post("/login",n,{withCredentials:!0})).data;return this.setWallet(r),this.setWalletType("embedded"),r}async verifyPhoneVerificationCode({phone:e,code:t}){const n={type:"Phone",data:{network:this.defaultNetwork,phone:e,code:t}},r=(await this.api.post("/login",n,{withCredentials:!0})).data;return this.setWallet(r),this.setWalletType("embedded"),r}async twitterLogin(e){const t={type:"TwitterOAuth",data:{network:this.defaultNetwork,...e}},n=(await this.api.post("/login",t,{withCredentials:!0})).data;return this.setWallet(n),this.setWalletType("embedded"),n}async googleLogin(e){const t={type:"GoogleOAuth",data:{network:this.defaultNetwork,...e}},n=(await this.api.post("/login",t,{withCredentials:!0})).data;return this.setWallet(n),this.setWalletType("embedded"),n}async oauthLogin(e,t){const n={type:e,data:{network:t.network||this.defaultNetwork,...t}},r=(await this.api.post("/login",n,{withCredentials:!0})).data;return this.setWallet(r),this.setWalletType("embedded"),r}async loginWithChallenge(e,t){const n={type:e,data:{network:t.network||this.defaultNetwork,...t}},r=(await this.api.post("/login",n,{withCredentials:!0})).data;return this.setWallet(r),this.setWalletType("embedded"),r}async oauthInit(e){return(await this.api.post("/oauth/init",e)).data}async getSignChallenge(e){return(await this.api.get(`/challenge?method=${e.method}&id=${e.id}`)).data}async getSession(){const e=(await this.api.get("/session",{withCredentials:!0})).data,{access_token:t,...n}=e;return t&&x.saveAccessToken(t),e}async logout(){this.phantomAdapter?(this.phantomAdapter.disconnect(),this.phantomAdapter=null):await this.api.post("/logout",{},{withCredentials:!0}),this.setWallet(null),x.clear()}async getOAuth2ClientId(e){return(await this.api.get(`/oauth_id/${e}`)).data.client_id}setSelectedWallet(e){this.selectedWalletId=e}getSelectedWallet(){return this.selectedWalletId}async getSolanaBalance(){if(!this.solanaConnection||!this.solanaAddress)throw new Error("Solana connection not available");return(await this.solanaConnection.getBalance(new t.PublicKey(this.solanaAddress))/t.LAMPORTS_PER_SOL).toString()}async getEthereumBalance(){if(!this.ethereumProvider||!this.ethereumAddress)throw new Error("Ethereum provider not available");return hf(await this.ethereumProvider.getBalance({address:this.ethereumAddress}))}async fetchCoinbaseToken(e,t="solana"){return(await this.api.post("/ramp/coinbase",{addresses:[{address:e,blockchains:[t]}],assets:["solana"===t?"SOL":"ETH"]})).data.token}viemSignerAdapter(){return{signTypedData:async e=>{if(!this.ethereumNetwork)throw new Error("No Ethereum network");if(!this.ethereumProvider)throw new Error("No Ethereum provider");if(!this.walletInfo)throw new Error("No wallet info");if(!this.ethereumAddress)throw new Error("No Ethereum address");const t={user_id:this.walletInfo.id,address:this.ethereumAddress,network:exports.Network.Ethereum,tx:{EthereumEip712:e}},n=await this.api.post("/sign2",t,{withCredentials:!0}),{signature:r}=n.data,o=p.default.decode(r),s=o[64];return Bd({r:`0x${$f.from(o.slice(0,32)).toString("hex")}`,s:`0x${$f.from(o.slice(32,64)).toString("hex")}`,v:BigInt(s+27)})}}}async createMiddleAccount(e){try{return(await this.middleAccountApi.post("/create",e)).data}catch(e){throw new Error(e instanceof Error?e.message:"Failed to create middle account")}}async getCoinbaseOnrampUrlForMiddleAccount(e){try{const t={sessionToken:await this.fetchCoinbaseToken(e.middleAccountAddress,e.network===exports.Network.Solana?"solana":"ethereum"),presetCryptoAmount:Number(e.amount),redirectUrl:e.redirectUrl||window.location.href};return mf(t)}catch(e){throw new Error(e instanceof Error?e.message:"Failed to get Coinbase onramp URL")}}async getOrderState(e){try{return(await this.middleAccountApi.get(`/order/${e}`)).data}catch(e){throw new Error(e instanceof Error?e.message:"Failed to get order status")}}async transfer(e){var t,n;if(!this.walletInfo)throw new Error("No wallet info available");const r={user_id:this.walletInfo.id,from:e.from,to:e.to,amount:e.amount,decimals:e.decimals,token:e.token,network:e.network,chain_id:e.chain_id};try{return(await this.api.post("/transfer",r,{withCredentials:!0})).data}catch(e){if(null===(n=null===(t=e.response)||void 0===t?void 0:t.data)||void 0===n?void 0:n.error)throw new Error(e.response.data.error);throw new Error(e instanceof Error?e.message:"Transfer failed")}}async buildTransaction(e){var t,n;try{return(await this.api.post("/build_transaction",e,{withCredentials:!0})).data}catch(e){if(null===(n=null===(t=e.response)||void 0===t?void 0:t.data)||void 0===n?void 0:n.error)throw new Error(e.response.data.error);throw new Error(e instanceof Error?e.message:"Failed to build transaction")}}}var mh=function(){return mh=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},mh.apply(this,arguments)};function gh(e,t,n){if(n||2===arguments.length)for(var r,o=0,s=t.length;o<s;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}function bh(e){var t=Object.create(null);return function(n){return void 0===t[n]&&(t[n]=e(n)),t[n]}}"function"==typeof SuppressedError&&SuppressedError;var yh=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,wh=bh(function(e){return yh.test(e)||111===e.charCodeAt(0)&&110===e.charCodeAt(1)&&e.charCodeAt(2)<91}),vh="-ms-",xh="-moz-",Eh="-webkit-",Ph="comm",kh="rule",Ah="decl",Ih="@keyframes",Nh=Math.abs,Sh=String.fromCharCode,Th=Object.assign;function $h(e){return e.trim()}function Bh(e,t){return(e=t.exec(e))?e[0]:e}function Ch(e,t,n){return e.replace(t,n)}function Oh(e,t,n){return e.indexOf(t,n)}function Rh(e,t){return 0|e.charCodeAt(t)}function zh(e,t,n){return e.slice(t,n)}function _h(e){return e.length}function Mh(e){return e.length}function Fh(e,t){return t.push(e),e}function jh(e,t){return e.filter(function(e){return!Bh(e,t)})}var Lh=1,Uh=1,Dh=0,Gh=0,qh=0,Vh="";function Wh(e,t,n,r,o,s,a,i){return{value:e,root:t,parent:n,type:r,props:o,children:s,line:Lh,column:Uh,length:a,return:"",siblings:i}}function Hh(e,t){return Th(Wh("",null,null,"",null,null,0,e.siblings),e,{length:-e.length},t)}function Yh(e){for(;e.root;)e=Hh(e.root,{children:[e]});Fh(e,e.siblings)}function Zh(){return qh=Gh>0?Rh(Vh,--Gh):0,Uh--,10===qh&&(Uh=1,Lh--),qh}function Kh(){return qh=Gh<Dh?Rh(Vh,Gh++):0,Uh++,10===qh&&(Uh=1,Lh++),qh}function Jh(){return Rh(Vh,Gh)}function Qh(){return Gh}function Xh(e,t){return zh(Vh,e,t)}function ep(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function tp(e){return $h(Xh(Gh-1,op(91===e?e+2:40===e?e+1:e)))}function np(e){for(;(qh=Jh())&&qh<33;)Kh();return ep(e)>2||ep(qh)>3?"":" "}function rp(e,t){for(;--t&&Kh()&&!(qh<48||qh>102||qh>57&&qh<65||qh>70&&qh<97););return Xh(e,Qh()+(t<6&&32==Jh()&&32==Kh()))}function op(e){for(;Kh();)switch(qh){case e:return Gh;case 34:case 39:34!==e&&39!==e&&op(qh);break;case 40:41===e&&op(e);break;case 92:Kh()}return Gh}function sp(e,t){for(;Kh()&&e+qh!==57&&(e+qh!==84||47!==Jh()););return"/*"+Xh(t,Gh-1)+"*"+Sh(47===e?e:Kh())}function ap(e){for(;!ep(Jh());)Kh();return Xh(e,Gh)}function ip(e){return function(e){return Vh="",e}(cp("",null,null,null,[""],e=function(e){return Lh=Uh=1,Dh=_h(Vh=e),Gh=0,[]}(e),0,[0],e))}function cp(e,t,n,r,o,s,a,i,c){for(var u=0,l=0,d=a,f=0,h=0,p=0,m=1,g=1,b=1,y=0,w="",v=o,x=s,E=r,P=w;g;)switch(p=y,y=Kh()){case 40:if(108!=p&&58==Rh(P,d-1)){-1!=Oh(P+=Ch(tp(y),"&","&\f"),"&\f",Nh(u?i[u-1]:0))&&(b=-1);break}case 34:case 39:case 91:P+=tp(y);break;case 9:case 10:case 13:case 32:P+=np(p);break;case 92:P+=rp(Qh()-1,7);continue;case 47:switch(Jh()){case 42:case 47:Fh(lp(sp(Kh(),Qh()),t,n,c),c);break;default:P+="/"}break;case 123*m:i[u++]=_h(P)*b;case 125*m:case 59:case 0:switch(y){case 0:case 125:g=0;case 59+l:-1==b&&(P=Ch(P,/\f/g,"")),h>0&&_h(P)-d&&Fh(h>32?dp(P+";",r,n,d-1,c):dp(Ch(P," ","")+";",r,n,d-2,c),c);break;case 59:P+=";";default:if(Fh(E=up(P,t,n,u,l,o,i,w,v=[],x=[],d,s),s),123===y)if(0===l)cp(P,t,E,E,v,s,d,i,x);else switch(99===f&&110===Rh(P,3)?100:f){case 100:case 108:case 109:case 115:cp(e,E,E,r&&Fh(up(e,E,E,0,0,o,i,w,o,v=[],d,x),x),o,x,d,i,r?v:x);break;default:cp(P,E,E,E,[""],x,0,i,x)}}u=l=h=0,m=b=1,w=P="",d=a;break;case 58:d=1+_h(P),h=p;default:if(m<1)if(123==y)--m;else if(125==y&&0==m++&&125==Zh())continue;switch(P+=Sh(y),y*m){case 38:b=l>0?1:(P+="\f",-1);break;case 44:i[u++]=(_h(P)-1)*b,b=1;break;case 64:45===Jh()&&(P+=tp(Kh())),f=Jh(),l=d=_h(w=P+=ap(Qh())),y++;break;case 45:45===p&&2==_h(P)&&(m=0)}}return s}function up(e,t,n,r,o,s,a,i,c,u,l,d){for(var f=o-1,h=0===o?s:[""],p=Mh(h),m=0,g=0,b=0;m<r;++m)for(var y=0,w=zh(e,f+1,f=Nh(g=a[m])),v=e;y<p;++y)(v=$h(g>0?h[y]+" "+w:Ch(w,/&\f/g,h[y])))&&(c[b++]=v);return Wh(e,t,n,0===o?kh:i,c,u,l,d)}function lp(e,t,n,r){return Wh(e,t,n,Ph,Sh(qh),zh(e,2,-2),0,r)}function dp(e,t,n,r,o){return Wh(e,t,n,Ah,zh(e,0,r),zh(e,r+1,-1),r,o)}function fp(e,t,n){switch(function(e,t){return 45^Rh(e,0)?(((t<<2^Rh(e,0))<<2^Rh(e,1))<<2^Rh(e,2))<<2^Rh(e,3):0}(e,t)){case 5103:return Eh+"print-"+e+e;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return Eh+e+e;case 4789:return xh+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return Eh+e+xh+e+vh+e+e;case 5936:switch(Rh(e,t+11)){case 114:return Eh+e+vh+Ch(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return Eh+e+vh+Ch(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return Eh+e+vh+Ch(e,/[svh]\w+-[tblr]{2}/,"lr")+e}case 6828:case 4268:case 2903:return Eh+e+vh+e+e;case 6165:return Eh+e+vh+"flex-"+e+e;case 5187:return Eh+e+Ch(e,/(\w+).+(:[^]+)/,Eh+"box-$1$2"+vh+"flex-$1$2")+e;case 5443:return Eh+e+vh+"flex-item-"+Ch(e,/flex-|-self/g,"")+(Bh(e,/flex-|baseline/)?"":vh+"grid-row-"+Ch(e,/flex-|-self/g,""))+e;case 4675:return Eh+e+vh+"flex-line-pack"+Ch(e,/align-content|flex-|-self/g,"")+e;case 5548:return Eh+e+vh+Ch(e,"shrink","negative")+e;case 5292:return Eh+e+vh+Ch(e,"basis","preferred-size")+e;case 6060:return Eh+"box-"+Ch(e,"-grow","")+Eh+e+vh+Ch(e,"grow","positive")+e;case 4554:return Eh+Ch(e,/([^-])(transform)/g,"$1"+Eh+"$2")+e;case 6187:return Ch(Ch(Ch(e,/(zoom-|grab)/,Eh+"$1"),/(image-set)/,Eh+"$1"),e,"")+e;case 5495:case 3959:return Ch(e,/(image-set\([^]*)/,Eh+"$1$`$1");case 4968:return Ch(Ch(e,/(.+:)(flex-)?(.*)/,Eh+"box-pack:$3"+vh+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+Eh+e+e;case 4200:if(!Bh(e,/flex-|baseline/))return vh+"grid-column-align"+zh(e,t)+e;break;case 2592:case 3360:return vh+Ch(e,"template-","")+e;case 4384:case 3616:return n&&n.some(function(e,n){return t=n,Bh(e.props,/grid-\w+-end/)})?~Oh(e+(n=n[t].value),"span",0)?e:vh+Ch(e,"-start","")+e+vh+"grid-row-span:"+(~Oh(n,"span",0)?Bh(n,/\d+/):+Bh(n,/\d+/)-+Bh(e,/\d+/))+";":vh+Ch(e,"-start","")+e;case 4896:case 4128:return n&&n.some(function(e){return Bh(e.props,/grid-\w+-start/)})?e:vh+Ch(Ch(e,"-end","-span"),"span ","")+e;case 4095:case 3583:case 4068:case 2532:return Ch(e,/(.+)-inline(.+)/,Eh+"$1$2")+e;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(_h(e)-1-t>6)switch(Rh(e,t+1)){case 109:if(45!==Rh(e,t+4))break;case 102:return Ch(e,/(.+:)(.+)-([^]+)/,"$1"+Eh+"$2-$3$1"+xh+(108==Rh(e,t+3)?"$3":"$2-$3"))+e;case 115:return~Oh(e,"stretch",0)?fp(Ch(e,"stretch","fill-available"),t,n)+e:e}break;case 5152:case 5920:return Ch(e,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(t,n,r,o,s,a,i){return vh+n+":"+r+i+(o?vh+n+"-span:"+(s?a:+a-+r)+i:"")+e});case 4949:if(121===Rh(e,t+6))return Ch(e,":",":"+Eh)+e;break;case 6444:switch(Rh(e,45===Rh(e,14)?18:11)){case 120:return Ch(e,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+Eh+(45===Rh(e,14)?"inline-":"")+"box$3$1"+Eh+"$2$3$1"+vh+"$2box$3")+e;case 100:return Ch(e,":",":"+vh)+e}break;case 5719:case 2647:case 2135:case 3927:case 2391:return Ch(e,"scroll-","scroll-snap-")+e}return e}function hp(e,t){for(var n="",r=0;r<e.length;r++)n+=t(e[r],r,e,t)||"";return n}function pp(e,t,n,r){switch(e.type){case"@layer":if(e.children.length)break;case"@import":case Ah:return e.return=e.return||e.value;case Ph:return"";case Ih:return e.return=e.value+"{"+hp(e.children,r)+"}";case kh:if(!_h(e.value=e.props.join(",")))return""}return _h(n=hp(e.children,r))?e.return=e.value+"{"+n+"}":""}function mp(e,t,n,r){if(e.length>-1&&!e.return)switch(e.type){case Ah:return void(e.return=fp(e.value,e.length,n));case Ih:return hp([Hh(e,{value:Ch(e.value,"@","@"+Eh)})],r);case kh:if(e.length)return function(e,t){return e.map(t).join("")}(n=e.props,function(t){switch(Bh(t,r=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":Yh(Hh(e,{props:[Ch(t,/:(read-\w+)/,":-moz-$1")]})),Yh(Hh(e,{props:[t]})),Th(e,{props:jh(n,r)});break;case"::placeholder":Yh(Hh(e,{props:[Ch(t,/:(plac\w+)/,":"+Eh+"input-$1")]})),Yh(Hh(e,{props:[Ch(t,/:(plac\w+)/,":-moz-$1")]})),Yh(Hh(e,{props:[Ch(t,/:(plac\w+)/,vh+"input-$1")]})),Yh(Hh(e,{props:[t]})),Th(e,{props:jh(n,r)})}return""})}}var gp={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},bp="undefined"!=typeof process&&void 0!==process.env&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",yp="active",wp="data-styled-version",vp="6.1.19",xp="/*!sc*/\n",Ep="undefined"!=typeof window&&"undefined"!=typeof document,Pp=Boolean("boolean"==typeof SC_DISABLE_SPEEDY?SC_DISABLE_SPEEDY:"undefined"!=typeof process&&void 0!==process.env&&void 0!==process.env.REACT_APP_SC_DISABLE_SPEEDY&&""!==process.env.REACT_APP_SC_DISABLE_SPEEDY?"false"!==process.env.REACT_APP_SC_DISABLE_SPEEDY&&process.env.REACT_APP_SC_DISABLE_SPEEDY:"undefined"!=typeof process&&void 0!==process.env&&void 0!==process.env.SC_DISABLE_SPEEDY&&""!==process.env.SC_DISABLE_SPEEDY?"false"!==process.env.SC_DISABLE_SPEEDY&&process.env.SC_DISABLE_SPEEDY:"production"!==process.env.NODE_ENV),kp=/invalid hook call/i,Ap=new Set,Ip=function(e,t){if("production"!==process.env.NODE_ENV){var n=t?' with the id of "'.concat(t,'"'):"",r="The component ".concat(e).concat(n," has been created dynamically.\n")+"You may see this warning because you've called styled inside another component.\nTo resolve this only create new StyledComponents outside of any render method and function component.\nSee https://styled-components.com/docs/basics#define-styled-components-outside-of-the-render-method for more info.\n",s=console.error;try{var a=!0;console.error=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];kp.test(e)?(a=!1,Ap.delete(r)):s.apply(void 0,gh([e],t,!1))},o.useRef(),a&&!Ap.has(r)&&(console.warn(r),Ap.add(r))}catch(e){kp.test(e.message)&&Ap.delete(r)}finally{console.error=s}}},Np=Object.freeze([]),Sp=Object.freeze({});var Tp=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","track","u","ul","use","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"]),$p=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,Bp=/(^-|-$)/g;function Cp(e){return e.replace($p,"-").replace(Bp,"")}var Op=/(a)(d)/gi,Rp=function(e){return String.fromCharCode(e+(e>25?39:97))};function zp(e){var t,n="";for(t=Math.abs(e);t>52;t=t/52|0)n=Rp(t%52)+n;return(Rp(t%52)+n).replace(Op,"$1-$2")}var _p,Mp=function(e,t){for(var n=t.length;n;)e=33*e^t.charCodeAt(--n);return e},Fp=function(e){return Mp(5381,e)};function jp(e){return zp(Fp(e)>>>0)}function Lp(e){return"production"!==process.env.NODE_ENV&&"string"==typeof e&&e||e.displayName||e.name||"Component"}function Up(e){return"string"==typeof e&&("production"===process.env.NODE_ENV||e.charAt(0)===e.charAt(0).toLowerCase())}var Dp="function"==typeof Symbol&&Symbol.for,Gp=Dp?Symbol.for("react.memo"):60115,qp=Dp?Symbol.for("react.forward_ref"):60112,Vp={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},Wp={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},Hp={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},Yp=((_p={})[qp]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},_p[Gp]=Hp,_p);function Zp(e){return("type"in(t=e)&&t.type.$$typeof)===Gp?Hp:"$$typeof"in e?Yp[e.$$typeof]:Vp;var t}var Kp=Object.defineProperty,Jp=Object.getOwnPropertyNames,Qp=Object.getOwnPropertySymbols,Xp=Object.getOwnPropertyDescriptor,em=Object.getPrototypeOf,tm=Object.prototype;function nm(e,t,n){if("string"!=typeof t){if(tm){var r=em(t);r&&r!==tm&&nm(e,r,n)}var o=Jp(t);Qp&&(o=o.concat(Qp(t)));for(var s=Zp(e),a=Zp(t),i=0;i<o.length;++i){var c=o[i];if(!(c in Wp||n&&n[c]||a&&c in a||s&&c in s)){var u=Xp(t,c);try{Kp(e,c,u)}catch(e){}}}}return e}function rm(e){return"function"==typeof e}function om(e){return"object"==typeof e&&"styledComponentId"in e}function sm(e,t){return e&&t?"".concat(e," ").concat(t):e||t||""}function am(e,t){if(0===e.length)return"";for(var n=e[0],r=1;r<e.length;r++)n+=e[r];return n}function im(e){return null!==e&&"object"==typeof e&&e.constructor.name===Object.name&&!("props"in e&&e.$$typeof)}function cm(e,t,n){if(void 0===n&&(n=!1),!n&&!im(e)&&!Array.isArray(e))return t;if(Array.isArray(t))for(var r=0;r<t.length;r++)e[r]=cm(e[r],t[r]);else if(im(t))for(var r in t)e[r]=cm(e[r],t[r]);return e}function um(e,t){Object.defineProperty(e,"toString",{value:t})}var lm="production"!==process.env.NODE_ENV?{1:"Cannot create styled-component for component: %s.\n\n",2:"Can't collect styles once you've consumed a `ServerStyleSheet`'s styles! `ServerStyleSheet` is a one off instance for each server-side render cycle.\n\n- Are you trying to reuse it across renders?\n- Are you accidentally calling collectStyles twice?\n\n",3:"Streaming SSR is only supported in a Node.js environment; Please do not try to call this method in the browser.\n\n",4:"The `StyleSheetManager` expects a valid target or sheet prop!\n\n- Does this error occur on the client and is your target falsy?\n- Does this error occur on the server and is the sheet falsy?\n\n",5:"The clone method cannot be used on the client!\n\n- Are you running in a client-like environment on the server?\n- Are you trying to run SSR on the client?\n\n",6:"Trying to insert a new style tag, but the given Node is unmounted!\n\n- Are you using a custom target that isn't mounted?\n- Does your document not have a valid head element?\n- Have you accidentally removed a style tag manually?\n\n",7:'ThemeProvider: Please return an object from your "theme" prop function, e.g.\n\n```js\ntheme={() => ({})}\n```\n\n',8:'ThemeProvider: Please make your "theme" prop an object.\n\n',9:"Missing document `<head>`\n\n",10:"Cannot find a StyleSheet instance. Usually this happens if there are multiple copies of styled-components loaded at once. Check out this issue for how to troubleshoot and fix the common cases where this situation can happen: https://github.com/styled-components/styled-components/issues/1941#issuecomment-417862021\n\n",11:"_This error was replaced with a dev-time warning, it will be deleted for v4 final._ [createGlobalStyle] received children which will not be rendered. Please use the component without passing children elements.\n\n",12:"It seems you are interpolating a keyframe declaration (%s) into an untagged string. This was supported in styled-components v3, but is not longer supported in v4 as keyframes are now injected on-demand. Please wrap your string in the css\\`\\` helper which ensures the styles are injected correctly. See https://www.styled-components.com/docs/api#css\n\n",13:"%s is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.\n\n",14:'ThemeProvider: "theme" prop is required.\n\n',15:"A stylis plugin has been supplied that is not named. We need a name for each plugin to be able to prevent styling collisions between different stylis configurations within the same app. Before you pass your plugin to `<StyleSheetManager stylisPlugins={[]}>`, please make sure each plugin is uniquely-named, e.g.\n\n```js\nObject.defineProperty(importedPlugin, 'name', { value: 'some-unique-name' });\n```\n\n",16:"Reached the limit of how many styled components may be created at group %s.\nYou may only create up to 1,073,741,824 components. If you're creating components dynamically,\nas for instance in your render method then you may be running into this limitation.\n\n",17:"CSSStyleSheet could not be found on HTMLStyleElement.\nHas styled-components' style tag been unmounted or altered by another script?\n",18:"ThemeProvider: Please make sure your useTheme hook is within a `<ThemeProvider>`"}:{};function dm(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n=e[0],r=[],o=1,s=e.length;o<s;o+=1)r.push(e[o]);return r.forEach(function(e){n=n.replace(/%[a-z]/,e)}),n}function fm(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return"production"===process.env.NODE_ENV?new Error("An error occurred. See https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/errors.md#".concat(e," for more information.").concat(t.length>0?" Args: ".concat(t.join(", ")):"")):new Error(dm.apply(void 0,gh([lm[e]],t,!1)).trim())}var hm=function(){function e(e){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=e}return e.prototype.indexOfGroup=function(e){for(var t=0,n=0;n<e;n++)t+=this.groupSizes[n];return t},e.prototype.insertRules=function(e,t){if(e>=this.groupSizes.length){for(var n=this.groupSizes,r=n.length,o=r;e>=o;)if((o<<=1)<0)throw fm(16,"".concat(e));this.groupSizes=new Uint32Array(o),this.groupSizes.set(n),this.length=o;for(var s=r;s<o;s++)this.groupSizes[s]=0}for(var a=this.indexOfGroup(e+1),i=(s=0,t.length);s<i;s++)this.tag.insertRule(a,t[s])&&(this.groupSizes[e]++,a++)},e.prototype.clearGroup=function(e){if(e<this.length){var t=this.groupSizes[e],n=this.indexOfGroup(e),r=n+t;this.groupSizes[e]=0;for(var o=n;o<r;o++)this.tag.deleteRule(n)}},e.prototype.getGroup=function(e){var t="";if(e>=this.length||0===this.groupSizes[e])return t;for(var n=this.groupSizes[e],r=this.indexOfGroup(e),o=r+n,s=r;s<o;s++)t+="".concat(this.tag.getRule(s)).concat(xp);return t},e}(),pm=1<<30,mm=new Map,gm=new Map,bm=1,ym=function(e){if(mm.has(e))return mm.get(e);for(;gm.has(bm);)bm++;var t=bm++;if("production"!==process.env.NODE_ENV&&((0|t)<0||t>pm))throw fm(16,"".concat(t));return mm.set(e,t),gm.set(t,e),t},wm=function(e,t){bm=t+1,mm.set(e,t),gm.set(t,e)},vm="style[".concat(bp,"][").concat(wp,'="').concat(vp,'"]'),xm=new RegExp("^".concat(bp,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),Em=function(e,t,n){for(var r,o=n.split(","),s=0,a=o.length;s<a;s++)(r=o[s])&&e.registerName(t,r)},Pm=function(e,t){for(var n,r=(null!==(n=t.textContent)&&void 0!==n?n:"").split(xp),o=[],s=0,a=r.length;s<a;s++){var i=r[s].trim();if(i){var c=i.match(xm);if(c){var u=0|parseInt(c[1],10),l=c[2];0!==u&&(wm(l,u),Em(e,l,c[3]),e.getTag().insertRules(u,o)),o.length=0}else o.push(i)}}},km=function(e){for(var t=document.querySelectorAll(vm),n=0,r=t.length;n<r;n++){var o=t[n];o&&o.getAttribute(bp)!==yp&&(Pm(e,o),o.parentNode&&o.parentNode.removeChild(o))}};var Am=function(e){var t=document.head,n=e||t,r=document.createElement("style"),o=function(e){var t=Array.from(e.querySelectorAll("style[".concat(bp,"]")));return t[t.length-1]}(n),s=void 0!==o?o.nextSibling:null;r.setAttribute(bp,yp),r.setAttribute(wp,vp);var a="undefined"!=typeof __webpack_nonce__?__webpack_nonce__:null;return a&&r.setAttribute("nonce",a),n.insertBefore(r,s),r},Im=function(){function e(e){this.element=Am(e),this.element.appendChild(document.createTextNode("")),this.sheet=function(e){if(e.sheet)return e.sheet;for(var t=document.styleSheets,n=0,r=t.length;n<r;n++){var o=t[n];if(o.ownerNode===e)return o}throw fm(17)}(this.element),this.length=0}return e.prototype.insertRule=function(e,t){try{return this.sheet.insertRule(t,e),this.length++,!0}catch(e){return!1}},e.prototype.deleteRule=function(e){this.sheet.deleteRule(e),this.length--},e.prototype.getRule=function(e){var t=this.sheet.cssRules[e];return t&&t.cssText?t.cssText:""},e}(),Nm=function(){function e(e){this.element=Am(e),this.nodes=this.element.childNodes,this.length=0}return e.prototype.insertRule=function(e,t){if(e<=this.length&&e>=0){var n=document.createTextNode(t);return this.element.insertBefore(n,this.nodes[e]||null),this.length++,!0}return!1},e.prototype.deleteRule=function(e){this.element.removeChild(this.nodes[e]),this.length--},e.prototype.getRule=function(e){return e<this.length?this.nodes[e].textContent:""},e}(),Sm=function(){function e(e){this.rules=[],this.length=0}return e.prototype.insertRule=function(e,t){return e<=this.length&&(this.rules.splice(e,0,t),this.length++,!0)},e.prototype.deleteRule=function(e){this.rules.splice(e,1),this.length--},e.prototype.getRule=function(e){return e<this.length?this.rules[e]:""},e}(),Tm=Ep,$m={isServer:!Ep,useCSSOMInjection:!Pp},Bm=function(){function e(e,t,n){void 0===e&&(e=Sp),void 0===t&&(t={});var r=this;this.options=mh(mh({},$m),e),this.gs=t,this.names=new Map(n),this.server=!!e.isServer,!this.server&&Ep&&Tm&&(Tm=!1,km(this)),um(this,function(){return function(e){for(var t=e.getTag(),n=t.length,r="",o=function(n){var o=function(e){return gm.get(e)}(n);if(void 0===o)return"continue";var s=e.names.get(o),a=t.getGroup(n);if(void 0===s||!s.size||0===a.length)return"continue";var i="".concat(bp,".g").concat(n,'[id="').concat(o,'"]'),c="";void 0!==s&&s.forEach(function(e){e.length>0&&(c+="".concat(e,","))}),r+="".concat(a).concat(i,'{content:"').concat(c,'"}').concat(xp)},s=0;s<n;s++)o(s);return r}(r)})}return e.registerId=function(e){return ym(e)},e.prototype.rehydrate=function(){!this.server&&Ep&&km(this)},e.prototype.reconstructWithOptions=function(t,n){return void 0===n&&(n=!0),new e(mh(mh({},this.options),t),this.gs,n&&this.names||void 0)},e.prototype.allocateGSInstance=function(e){return this.gs[e]=(this.gs[e]||0)+1},e.prototype.getTag=function(){return this.tag||(this.tag=(e=function(e){var t=e.useCSSOMInjection,n=e.target;return e.isServer?new Sm(n):t?new Im(n):new Nm(n)}(this.options),new hm(e)));var e},e.prototype.hasNameForId=function(e,t){return this.names.has(e)&&this.names.get(e).has(t)},e.prototype.registerName=function(e,t){if(ym(e),this.names.has(e))this.names.get(e).add(t);else{var n=new Set;n.add(t),this.names.set(e,n)}},e.prototype.insertRules=function(e,t,n){this.registerName(e,t),this.getTag().insertRules(ym(e),n)},e.prototype.clearNames=function(e){this.names.has(e)&&this.names.get(e).clear()},e.prototype.clearRules=function(e){this.getTag().clearGroup(ym(e)),this.clearNames(e)},e.prototype.clearTag=function(){this.tag=void 0},e}(),Cm=/&/g,Om=/^\s*\/\/.*$/gm;function Rm(e,t){return e.map(function(e){return"rule"===e.type&&(e.value="".concat(t," ").concat(e.value),e.value=e.value.replaceAll(",",",".concat(t," ")),e.props=e.props.map(function(e){return"".concat(t," ").concat(e)})),Array.isArray(e.children)&&"@keyframes"!==e.type&&(e.children=Rm(e.children,t)),e})}var zm=new Bm,_m=function(){var e,t,n,r=Sp,o=r.options,s=void 0===o?Sp:o,a=r.plugins,i=void 0===a?Np:a,c=function(n,r,o){return o.startsWith(t)&&o.endsWith(t)&&o.replaceAll(t,"").length>0?".".concat(e):n},u=i.slice();u.push(function(e){e.type===kh&&e.value.includes("&")&&(e.props[0]=e.props[0].replace(Cm,t).replace(n,c))}),s.prefix&&u.push(mp),u.push(pp);var l=function(r,o,a,i){void 0===o&&(o=""),void 0===a&&(a=""),void 0===i&&(i="&"),e=i,t=o,n=new RegExp("\\".concat(t,"\\b"),"g");var c=r.replace(Om,""),l=ip(a||o?"".concat(a," ").concat(o," { ").concat(c," }"):c);s.namespace&&(l=Rm(l,s.namespace));var d,f=[];return hp(l,function(e){var t=Mh(e);return function(n,r,o,s){for(var a="",i=0;i<t;i++)a+=e[i](n,r,o,s)||"";return a}}(u.concat((d=function(e){return f.push(e)},function(e){e.root||(e=e.return)&&d(e)})))),f};return l.hash=i.length?i.reduce(function(e,t){return t.name||fm(15),Mp(e,t.name)},5381).toString():"",l}(),Mm=m.default.createContext({shouldForwardProp:void 0,styleSheet:zm,stylis:_m});function Fm(){return o.useContext(Mm)}Mm.Consumer,m.default.createContext(void 0);var jm=function(){function e(e,t){var n=this;this.inject=function(e,t){void 0===t&&(t=_m);var r=n.name+t.hash;e.hasNameForId(n.id,r)||e.insertRules(n.id,r,t(n.rules,r,"@keyframes"))},this.name=e,this.id="sc-keyframes-".concat(e),this.rules=t,um(this,function(){throw fm(12,String(n.name))})}return e.prototype.getName=function(e){return void 0===e&&(e=_m),this.name+e.hash},e}(),Lm=function(e){return e>="A"&&e<="Z"};function Um(e){for(var t="",n=0;n<e.length;n++){var r=e[n];if(1===n&&"-"===r&&"-"===e[0])return e;Lm(r)?t+="-"+r.toLowerCase():t+=r}return t.startsWith("ms-")?"-"+t:t}var Dm=function(e){return null==e||!1===e||""===e},Gm=function(e){var t,n,r=[];for(var o in e){var s=e[o];e.hasOwnProperty(o)&&!Dm(s)&&(Array.isArray(s)&&s.isCss||rm(s)?r.push("".concat(Um(o),":"),s,";"):im(s)?r.push.apply(r,gh(gh(["".concat(o," {")],Gm(s),!1),["}"],!1)):r.push("".concat(Um(o),": ").concat((t=o,null==(n=s)||"boolean"==typeof n||""===n?"":"number"!=typeof n||0===n||t in gp||t.startsWith("--")?String(n).trim():"".concat(n,"px")),";")))}return r};function qm(e,t,n,r){if(Dm(e))return[];if(om(e))return[".".concat(e.styledComponentId)];if(rm(e)){if(!rm(s=e)||s.prototype&&s.prototype.isReactComponent||!t)return[e];var o=e(t);return"production"===process.env.NODE_ENV||"object"!=typeof o||Array.isArray(o)||o instanceof jm||im(o)||null===o||console.error("".concat(Lp(e)," is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.")),qm(o,t,n,r)}var s;return e instanceof jm?n?(e.inject(n,r),[e.getName(r)]):[e]:im(e)?Gm(e):Array.isArray(e)?Array.prototype.concat.apply(Np,e.map(function(e){return qm(e,t,n,r)})):[e.toString()]}var Vm=Fp(vp),Wm=function(){function e(e,t,n){this.rules=e,this.staticRulesId="",this.isStatic="production"===process.env.NODE_ENV&&(void 0===n||n.isStatic)&&function(e){for(var t=0;t<e.length;t+=1){var n=e[t];if(rm(n)&&!om(n))return!1}return!0}(e),this.componentId=t,this.baseHash=Mp(Vm,t),this.baseStyle=n,Bm.registerId(t)}return e.prototype.generateAndInjectStyles=function(e,t,n){var r=this.baseStyle?this.baseStyle.generateAndInjectStyles(e,t,n):"";if(this.isStatic&&!n.hash)if(this.staticRulesId&&t.hasNameForId(this.componentId,this.staticRulesId))r=sm(r,this.staticRulesId);else{var o=am(qm(this.rules,e,t,n)),s=zp(Mp(this.baseHash,o)>>>0);if(!t.hasNameForId(this.componentId,s)){var a=n(o,".".concat(s),void 0,this.componentId);t.insertRules(this.componentId,s,a)}r=sm(r,s),this.staticRulesId=s}else{for(var i=Mp(this.baseHash,n.hash),c="",u=0;u<this.rules.length;u++){var l=this.rules[u];if("string"==typeof l)c+=l,"production"!==process.env.NODE_ENV&&(i=Mp(i,l));else if(l){var d=am(qm(l,e,t,n));i=Mp(i,d+u),c+=d}}if(c){var f=zp(i>>>0);t.hasNameForId(this.componentId,f)||t.insertRules(this.componentId,f,n(c,".".concat(f),void 0,this.componentId)),r=sm(r,f)}}return r},e}(),Hm=m.default.createContext(void 0);Hm.Consumer;var Ym={},Zm=new Set;function Km(e,t,n){var r=om(e),s=e,a=!Up(e),i=t.attrs,c=void 0===i?Np:i,u=t.componentId,l=void 0===u?function(e,t){var n="string"!=typeof e?"sc":Cp(e);Ym[n]=(Ym[n]||0)+1;var r="".concat(n,"-").concat(jp(vp+n+Ym[n]));return t?"".concat(t,"-").concat(r):r}(t.displayName,t.parentComponentId):u,d=t.displayName,f=void 0===d?function(e){return Up(e)?"styled.".concat(e):"Styled(".concat(Lp(e),")")}(e):d,h=t.displayName&&t.componentId?"".concat(Cp(t.displayName),"-").concat(t.componentId):t.componentId||l,p=r&&s.attrs?s.attrs.concat(c).filter(Boolean):c,g=t.shouldForwardProp;if(r&&s.shouldForwardProp){var b=s.shouldForwardProp;if(t.shouldForwardProp){var y=t.shouldForwardProp;g=function(e,t){return b(e,t)&&y(e,t)}}else g=b}var w=new Wm(n,h,r?s.componentStyle:void 0);function v(e,t){return function(e,t,n){var r=e.attrs,s=e.componentStyle,a=e.defaultProps,i=e.foldedComponentIds,c=e.styledComponentId,u=e.target,l=m.default.useContext(Hm),d=Fm(),f=e.shouldForwardProp||d.shouldForwardProp;"production"!==process.env.NODE_ENV&&o.useDebugValue(c);var h=function(e,t,n){return void 0===n&&(n=Sp),e.theme!==n.theme&&e.theme||t||n.theme}(t,l,a)||Sp,p=function(e,t,n){for(var r,o=mh(mh({},t),{className:void 0,theme:n}),s=0;s<e.length;s+=1){var a=rm(r=e[s])?r(o):r;for(var i in a)o[i]="className"===i?sm(o[i],a[i]):"style"===i?mh(mh({},o[i]),a[i]):a[i]}return t.className&&(o.className=sm(o.className,t.className)),o}(r,t,h),g=p.as||u,b={};for(var y in p)void 0===p[y]||"$"===y[0]||"as"===y||"theme"===y&&p.theme===h||("forwardedAs"===y?b.as=p.forwardedAs:f&&!f(y,g)||(b[y]=p[y],f||"development"!==process.env.NODE_ENV||wh(y)||Zm.has(y)||!Tp.has(g)||(Zm.add(y),console.warn('styled-components: it looks like an unknown prop "'.concat(y,'" is being sent through to the DOM, which will likely trigger a React console error. If you would like automatic filtering of unknown props, you can opt-into that behavior via `<StyleSheetManager shouldForwardProp={...}>` (connect an API like `@emotion/is-prop-valid`) or consider using transient props (`$` prefix for automatic filtering.)')))));var w=function(e,t){var n=Fm(),r=e.generateAndInjectStyles(t,n.styleSheet,n.stylis);return"production"!==process.env.NODE_ENV&&o.useDebugValue(r),r}(s,p);"production"!==process.env.NODE_ENV&&e.warnTooManyClasses&&e.warnTooManyClasses(w);var v=sm(i,c);return w&&(v+=" "+w),p.className&&(v+=" "+p.className),b[Up(g)&&!Tp.has(g)?"class":"className"]=v,n&&(b.ref=n),o.createElement(g,b)}(x,e,t)}v.displayName=f;var x=m.default.forwardRef(v);return x.attrs=p,x.componentStyle=w,x.displayName=f,x.shouldForwardProp=g,x.foldedComponentIds=r?sm(s.foldedComponentIds,s.styledComponentId):"",x.styledComponentId=h,x.target=r?s.target:e,Object.defineProperty(x,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(e){this._foldedDefaultProps=r?function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];for(var r=0,o=t;r<o.length;r++)cm(e,o[r],!0);return e}({},s.defaultProps,e):e}}),"production"!==process.env.NODE_ENV&&(Ip(f,h),x.warnTooManyClasses=function(e,t){var n={},r=!1;return function(o){if(!r&&(n[o]=!0,Object.keys(n).length>=200)){var s=t?' with the id of "'.concat(t,'"'):"";console.warn("Over ".concat(200," classes were generated for component ").concat(e).concat(s,".\n")+"Consider using the attrs method, together with a style object for frequently changed styles.\nExample:\n const Component = styled.div.attrs(props => ({\n style: {\n background: props.background,\n },\n }))`width: 100%;`\n\n <Component />"),r=!0,n={}}}}(f,h)),um(x,function(){return".".concat(x.styledComponentId)}),a&&nm(x,e,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0}),x}function Jm(e,t){for(var n=[e[0]],r=0,o=t.length;r<o;r+=1)n.push(t[r],e[r+1]);return n}var Qm=function(e){return Object.assign(e,{isCss:!0})};function Xm(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(rm(e)||im(e))return Qm(qm(Jm(Np,gh([e],t,!0))));var r=e;return 0===t.length&&1===r.length&&"string"==typeof r[0]?qm(r):Qm(qm(Jm(r,t)))}function eg(e,t,n){if(void 0===n&&(n=Sp),!t)throw fm(1,t);var r=function(r){for(var o=[],s=1;s<arguments.length;s++)o[s-1]=arguments[s];return e(t,n,Xm.apply(void 0,gh([r],o,!1)))};return r.attrs=function(r){return eg(e,t,mh(mh({},n),{attrs:Array.prototype.concat(n.attrs,r).filter(Boolean)}))},r.withConfig=function(r){return eg(e,t,mh(mh({},n),r))},r}var tg=function(e){return eg(Km,e)},ng=tg;Tp.forEach(function(e){ng[e]=tg(e)}),"production"!==process.env.NODE_ENV&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product&&console.warn("It looks like you've imported 'styled-components' on React Native.\nPerhaps you're looking to import 'styled-components/native'?\nRead more about this at https://www.styled-components.com/docs/basics#react-native");var rg="__sc-".concat(bp,"__");"production"!==process.env.NODE_ENV&&"test"!==process.env.NODE_ENV&&"undefined"!=typeof window&&(window[rg]||(window[rg]=0),1===window[rg]&&console.warn("It looks like there are several instances of 'styled-components' initialized in this application. This may cause dynamic styles to not render properly, errors during the rehydration process, a missing theme prop, and makes your application bigger without good reason.\n\nSee https://s-c.sh/2BAXzed for more info."),window[rg]+=1);const og={colors:{black:"#000000",white:"#FFFFFF",offWhite:"#F5F5F5",grey:{100:"#F7F7F7",200:"#E6E6E6",300:"#D1D1D1",400:"#B0B0B0",500:"#8C8C8C",600:"#696969",700:"#474747",800:"#2B2B2B",900:"#1A1A1A"},primary:"#000000",secondary:"#B0B0B0",error:"#FF4D4D",success:"#4CAF50",background:{main:"#FFFFFF",secondary:"#F5F5F5",overlay:"rgba(0, 0, 0, 0.7)"},text:{primary:"#000000",secondary:"#474747",tertiary:"#8C8C8C",inverse:"#FFFFFF"},button:{primary:{background:"#000000",text:"#FFFFFF",hover:"#2B2B2B",disabled:"#8C8C8C"},secondary:{background:"#F5F5F5",text:"#000000",hover:"#E6E6E6",disabled:"#D1D1D1"}},border:{light:"#E6E6E6",medium:"#D1D1D1",dark:"#8C8C8C"}},typography:{fontFamily:"'Montserrat', 'Arial', sans-serif",fontSizes:{xs:"0.75rem",sm:"0.875rem",md:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem","4xl":"2.25rem"},fontWeights:{light:300,regular:400,medium:500,semibold:600,bold:700}},spacing:{xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem","2xl":"3rem","3xl":"4rem"},borderRadius:{none:"0",sm:"0.125rem",md:"0.25rem",lg:"0.5rem",xl:"0.75rem","2xl":"1rem",full:"9999px"},shadows:{none:"none",sm:"0 1px 2px rgba(0, 0, 0, 0.05)",md:"0 4px 6px rgba(0, 0, 0, 0.05)",lg:"0 10px 15px rgba(0, 0, 0, 0.05)",xl:"0 20px 25px rgba(0, 0, 0, 0.05)"},transitions:{fast:"0.1s ease",normal:"0.2s ease",slow:"0.3s ease"}},sg=(function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];"production"!==process.env.NODE_ENV&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product&&console.warn("`keyframes` cannot be used on ReactNative, only on the web. To do animation in ReactNative please use Animated.");var r=am(Xm.apply(void 0,gh([e],t,!1))),o=jp(r);return new jm(o,r)})`
|
|
12
|
+
const Ul=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Dl=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Gl=BigInt(0),ql=BigInt(1),Vl=BigInt(2),Wl=(e,t)=>(e+t/Vl)/t;const Hl=gl(Ul,void 0,void 0,{sqrt:function(e){const t=Ul,n=BigInt(3),r=BigInt(6),o=BigInt(11),s=BigInt(22),a=BigInt(23),i=BigInt(44),c=BigInt(88),u=e*e*e%t,l=u*u*e%t,d=il(l,n,t)*l%t,f=il(d,n,t)*l%t,h=il(f,Vl,t)*u%t,p=il(h,o,t)*h%t,m=il(p,s,t)*p%t,g=il(m,i,t)*m%t,b=il(g,c,t)*g%t,y=il(b,i,t)*m%t,w=il(y,n,t)*l%t,v=il(w,a,t)*p%t,x=il(v,r,t)*u%t,E=il(x,Vl,t);if(!Hl.eql(Hl.sqr(E),e))throw new Error("Cannot find square root");return E}}),Yl=function(e,t){const n=t=>jl({...e,...Ll(t)});return{...n(t),create:n}}({a:Gl,b:BigInt(7),Fp:Hl,n:Dl,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=Dl,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-ql*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,a=BigInt("0x100000000000000000000000000000000"),i=Wl(s*e,t),c=Wl(-r*e,t);let u=al(e-i*n-c*o,t),l=al(-i*r-c*s,t);const d=u>a,f=l>a;if(d&&(u=t-u),f&&(l=t-l),u>a||l>a)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:d,k1:u,k2neg:f,k2:l}}}},ks);var Zl=Object.freeze({__proto__:null,secp256k1:Yl});function Kl(e,t={}){const{recovered:n}=t;if(void 0===e.r)throw new td({signature:e});if(void 0===e.s)throw new td({signature:e});if(n&&void 0===e.yParity)throw new td({signature:e});if(e.r<0n||e.r>Su)throw new nd({value:e.r});if(e.s<0n||e.s>Su)throw new rd({value:e.s});if("number"==typeof e.yParity&&0!==e.yParity&&1!==e.yParity)throw new od({value:e.yParity})}function Jl(e){if(130!==e.length&&132!==e.length)throw new ed({signature:e});const t=BigInt(di(e,0,32)),n=BigInt(di(e,32,64)),r=(()=>{const t=Number(`0x${e.slice(130)}`);if(!Number.isNaN(t))try{return Xl(t)}catch{throw new od({value:t})}})();return void 0===r?{r:t,s:n}:{r:t,s:n,yParity:r}}function Ql(e){if(void 0!==e.r&&void 0!==e.s)return function(e){const t="string"==typeof e?Jl(e):e instanceof Uint8Array?function(e){return Jl(ai(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=Xl(t)),"number"!=typeof n)throw new od({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:Xl(e.v)}}(e):{r:e.r,s:e.s,...void 0!==e.yParity?{yParity:e.yParity}:{}};return Kl(t),t}(e)}function Xl(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 sd({value:e})}class ed extends Na{constructor({signature:e}){var t;super(`Value \`${e}\` is an invalid signature size.`,{metaMessages:["Expected: 64 bytes or 65 bytes.",`Received ${fi((t=e,t instanceof Uint8Array?ai(t):Array.isArray(t)?ai(new Uint8Array(t)):t))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSerializedSizeError"})}}class td extends Na{constructor({signature:e}){super(`Signature \`${La(e)}\` is missing either an \`r\`, \`s\`, or \`yParity\` property.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.MissingPropertiesError"})}}class nd extends Na{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 rd extends Na{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 od extends Na{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 sd extends Na{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 ad(e,t={}){return"string"==typeof e.chainId?function(e){const{address:t,chainId:n,nonce:r}=e,o=Ql(e);return{address:t,chainId:Number(n),nonce:BigInt(r),...o}}(e):{...e,...t.signature}}const id=Gu("(uint256 chainId, address delegation, uint256 nonce, uint8 yParity, uint256 r, uint256 s), address to, bytes data");function cd(e){if("string"==typeof e){if("0x8010801080108010801080108010801080108010801080108010801080108010"!==di(e,-32))throw new ud(e)}else Kl(e.authorization)}let ud=class extends Na{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 ld(e,{address:t,blockNumber:n,blockTag:r,storageKeys:o}){const s=r??"latest",a=void 0!==n?Mt(n):void 0;return function(e){return{...e,balance:e.balance?BigInt(e.balance):void 0,nonce:e.nonce?Ct(e.nonce):void 0,storageProof:e.storageProof?(t=e.storageProof,t.map(e=>({...e,value:BigInt(e.value)}))):void 0};var t}(await e.request({method:"eth_getProof",params:[t,o,a||s]}))}async function dd(e,{blockHash:t,blockNumber:n,blockTag:r,hash:o,index:s}){const a=r||"latest",i=void 0!==n?Mt(n):void 0;let c=null;if(c=o?await e.request({method:"eth_getTransactionByHash",params:[o]},{dedupe:!0}):t?await e.request({method:"eth_getTransactionByBlockHashAndIndex",params:[t,Mt(s)]},{dedupe:!0}):await e.request({method:"eth_getTransactionByBlockNumberAndIndex",params:[i||a,Mt(s)]},{dedupe:Boolean(i)}),!c)throw new jr({blockHash:t,blockNumber:n,blockTag:a,hash:o,index:s});return(e.chain?.formatters?.transaction?.format||cs)(c)}async function fd(e,{hash:t}){const n=await e.request({method:"eth_getTransactionReceipt",params:[t]},{dedupe:!0});if(!n)throw new Lr({hash:t});return(e.chain?.formatters?.transactionReceipt?.format||lc)(n)}async function hd(e,t){const{blockNumber:n,blockTag:r=e.experimental_blockTag??"latest",blocks:o,returnFullTransactions:s,traceTransfers:a,validation:i}=t;try{const t=[];for(const e of o){const n=e.blockOverrides?Pi(e.blockOverrides):void 0,r=e.calls.map(e=>{const t=e,n=t.account?ar(t.account):void 0,r=t.abi?cr(t):t.data,o={...t,data:t.dataSuffix?jn([r||"0x",t.dataSuffix]):r,from:t.from??n?.address};return ns(o),Jo(o)}),o=e.stateOverrides?es(e.stateOverrides):void 0;t.push({blockOverrides:n,calls:r,stateOverrides:o})}const c=("bigint"==typeof n?Mt(n):void 0)||r;return(await e.request({method:"eth_simulateV1",params:[{blockStateCalls:t,returnFullTransactions:s,traceTransfers:a,validation:i},c]})).map((e,t)=>({...us(e),calls:e.calls.map((e,n)=>{const{abi:r,args:s,functionName:a,to:i}=o[t].calls[n],c=e.error?.data??e.returnData,u=BigInt(e.gasUsed),l=e.logs?.map(e=>Gs(e)),d="0x1"===e.status?"success":"failure",f=r&&"success"===d&&"0x"!==c?Hs({abi:r,data:c,functionName:a}):null,h=(()=>{if("success"===d)return;let t;return"0x"===e.error?.data?t=new Qe:e.error&&(t=new Hr(e.error)),t?No(t,{abi:r??[],address:i??"0x",args:s,functionName:a??"<unknown>"}):void 0})();return{data:c,gasUsed:u,logs:l,status:d,..."success"===d?{result:f}:{error:h}}})}))}catch(e){const t=e,n=Yo(t,{});if(n instanceof Ho)throw t;throw n}}function pd(e){let t=!0,n="",r=0,o="",s=!1;for(let a=0;a<e.length;a++){const i=e[a];if(["(",")",","].includes(i)&&(t=!0),"("===i&&r++,")"===i&&r--,t)if(0!==r)" "!==i?(o+=i,n+=i):","!==e[a-1]&&","!==n&&",("!==n&&(n="",t=!1);else if(" "===i&&["event","function","error",""].includes(o))o="";else if(o+=i,")"===i){s=!0;break}}if(!s)throw new Na("Unable to normalize signature.");return o}function md(e,t){const n=typeof e,r=t.type;switch(r){case"address":return xu(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)=>md(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=>md(e,{...t,type:r.replace(/(\[[0-9]{0,}\])$/,"")})))}}function gd(e,t,n){for(const r in e){const o=e[r],s=t[r];if("tuple"===o.type&&"tuple"===s.type&&"components"in o&&"components"in s)return gd(o.components,s.components,n[r]);const a=[o.type,s.type];if((()=>!(!a.includes("address")||!a.includes("bytes20"))||(a.includes("address")&&a.includes("string")||!(!a.includes("address")||!a.includes("bytes")))&&xu(n[r],{strict:!1}))())return a}}function bd(e,t={}){const{prepare:n=!0}=t,r=Array.isArray(e)||"string"==typeof e?Me(e):e;return{...r,...n?{hash:vd(r)}:{}}}function yd(e,t,n){const{args:r=[],prepare:o=!0}=n??{},s=mi(t,{strict:!1}),a=e.filter(e=>s?"function"===e.type||"error"===e.type?wd(e)===di(t,0,4):"event"===e.type&&vd(e)===t:"name"in e&&e.name===t);if(0===a.length)throw new Ed({name:t});if(1===a.length)return{...a[0],...o?{hash:vd(a[0])}:{}};let i;for(const e of a){if(!("inputs"in e))continue;if(!r||0===r.length){if(!e.inputs||0===e.inputs.length)return{...e,...o?{hash:vd(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&&md(t,r)});if(t){if(i&&"inputs"in i&&i.inputs){const t=gd(e.inputs,i.inputs,r);if(t)throw new xd({abiItem:e,type:t[0]},{abiItem:i,type:t[1]})}i=e}}const c=(()=>{if(i)return i;const[e,...t]=a;return{...e,overloads:t}})();if(!c)throw new Ed({name:t});return{...c,...o?{hash:vd(c)}:{}}}function wd(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return yd(t,n)}return e[0]})();return di(vd(t),0,4)}function vd(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return yd(t,n)}return e[0]})();return"string"!=typeof t&&"hash"in t&&t.hash?t.hash:bu(ci(function(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return yd(t,n)}return e[0]})();return pd("string"==typeof t?t:J(t))}(t)))}class xd extends Na{constructor(e,t){super("Found ambiguous types in overloaded ABI Items.",{metaMessages:[`\`${e.type}\` in \`${pd(J(e.abiItem))}\`, and`,`\`${t.type}\` in \`${pd(J(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 Ed extends Na{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 Pd(e){const t=e.find(e=>"constructor"===e.type);if(!t)throw new Ed({name:"constructor"});return t}function kd(...e){const[t,n=[]]=(()=>{if(Array.isArray(e[0])){const[t,n,r]=e;return[Id(t,n,{args:r}),r]}const[t,n]=e;return[t,n]})(),{overloads:r}=t,o=r?Id([t,...r],t.name,{args:n}):t,s=wd(o);const a=n.length>0?Uu(o.inputs,n):void 0;return a?oi(s,a):s}function Ad(e,t={}){return bd(e,t)}function Id(e,t,n){const r=yd(e,t,n);if("function"!==r.type)throw new Ed({name:t,type:"function"});return r}const Nd="0x0000000000000000000000000000000000000000";async function Sd(e,t){const{blockNumber:n,blockTag:r,calls:o,stateOverrides:s,traceAssetChanges:a,traceTransfers:i,validation:c}=t,u=t.account?ar(t.account):void 0;if(a&&!u)throw new He("`account` is required when `traceAssetChanges` is true");const l=u?function(...e){const[t,n]=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return[Pd(t),n]}return e})(),{bytecode:r,args:o}=n;return oi(r,t.inputs?.length&&o?.length?Uu(t.inputs,o):"0x")}(bd("constructor(bytes, bytes)"),{bytecode:Ri,args:["0x6080604052348015600e575f80fd5b5061016d8061001c5f395ff3fe608060405234801561000f575f80fd5b5060043610610029575f3560e01c8063f8b2cb4f1461002d575b5f80fd5b610047600480360381019061004291906100db565b61005d565b604051610054919061011e565b60405180910390f35b5f8173ffffffffffffffffffffffffffffffffffffffff16319050919050565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100aa82610081565b9050919050565b6100ba816100a0565b81146100c4575f80fd5b50565b5f813590506100d5816100b1565b92915050565b5f602082840312156100f0576100ef61007d565b5b5f6100fd848285016100c7565b91505092915050565b5f819050919050565b61011881610106565b82525050565b5f6020820190506101315f83018461010f565b9291505056fea26469706673582212203b9fe929fe995c7cf9887f0bdba8a36dd78e8b73f149b17d2d9ad7cd09d2dc6264736f6c634300081a0033",kd(Ad("function getBalance(address)"),[u.address])]}):void 0;const d=a?await Promise.all(t.calls.map(async t=>{if(!t.data&&!t.abi)return;const{accessList:n}=await jc(e,{account:u.address,...t,data:t.abi?cr(t):t.data});return n.map(({address:e,storageKeys:t})=>t.length>0?e:null)})).then(e=>e.flat().filter(Boolean)):[],f=await hd(e,{blockNumber:n,blockTag:r,blocks:[...a?[{calls:[{data:l}],stateOverrides:s},{calls:d.map((e,t)=>({abi:[Ad("function balanceOf(address) returns (uint256)")],functionName:"balanceOf",args:[u.address],to:e,from:Nd,nonce:t})),stateOverrides:[{address:Nd,nonce:0}]}]:[],{calls:[...o,{}].map(e=>({...e,from:u?.address})),stateOverrides:s},...a?[{calls:[{data:l}]},{calls:d.map((e,t)=>({abi:[Ad("function balanceOf(address) returns (uint256)")],functionName:"balanceOf",args:[u.address],to:e,from:Nd,nonce:t})),stateOverrides:[{address:Nd,nonce:0}]},{calls:d.map((e,t)=>({to:e,abi:[Ad("function decimals() returns (uint256)")],functionName:"decimals",from:Nd,nonce:t})),stateOverrides:[{address:Nd,nonce:0}]},{calls:d.map((e,t)=>({to:e,abi:[Ad("function tokenURI(uint256) returns (string)")],functionName:"tokenURI",args:[0n],from:Nd,nonce:t})),stateOverrides:[{address:Nd,nonce:0}]},{calls:d.map((e,t)=>({to:e,abi:[Ad("function symbol() returns (string)")],functionName:"symbol",from:Nd,nonce:t})),stateOverrides:[{address:Nd,nonce:0}]}]:[]],traceTransfers:i,validation:c}),h=a?f[2]:f[0],[p,m,,g,b,y,w,v]=a?f:[],{calls:x,...E}=h,P=x.slice(0,-1)??[],k=[...p?.calls??[],...m?.calls??[]].map(e=>"success"===e.status?Bt(e.data):null),A=[...g?.calls??[],...b?.calls??[]].map(e=>"success"===e.status?Bt(e.data):null),I=(y?.calls??[]).map(e=>"success"===e.status?e.result:null),N=(v?.calls??[]).map(e=>"success"===e.status?e.result:null),S=(w?.calls??[]).map(e=>"success"===e.status?e.result:null),T=[];for(const[e,t]of A.entries()){const n=k[e];if("bigint"!=typeof t)continue;if("bigint"!=typeof n)continue;const r=I[e-1],o=N[e-1],s=S[e-1],a=(()=>0===e?{address:"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",decimals:18,symbol:"ETH"}:{address:d[e-1],decimals:s||r?Number(r??1):void 0,symbol:o??void 0})();T.some(e=>e.token.address===a.address)||T.push({token:a,value:{pre:n,post:t,diff:t-n}})}return{assetChanges:T,block:E,results:P}}const Td="0x6492649264926492649264926492649264926492649264926492649264926492";function $d(e){try{return function(e){if(di(e,-32)!==Td)throw new Bd(e)}(e),!0}catch{return!1}}class Bd extends Na{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"})}}function Cd({r:e,s:t,to:n="hex",v:r,yParity:o}){const s=(()=>{if(0===o||1===o)return o;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 Yl.Signature(Bt(e),Bt(t)).toCompactHex()}${0===s?"1b":"1c"}`;return"hex"===n?a:qt(a)}async function Od(e,t){const{address:n,hash:r,erc6492VerifierAddress:o=t.universalSignatureVerifierAddress??e.chain?.contracts?.erc6492Verifier?.address,multicallAddress:s=t.multicallAddress??e.chain?.contracts?.multicall3?.address}=t,a=(()=>{const e=t.signature;return De(e)?e:"object"==typeof e&&"r"in e&&"s"in e?Cd(e):_t(e)})();try{return function(e){try{return cd(e),!0}catch{return!1}}(a)?await async function(e,t){const{address:n,blockNumber:r,blockTag:o,hash:s,multicallAddress:a}=t,{authorization:i,data:c,signature:u,to:l}=function(e){cd(e);const t=pi(di(e,-64,-32)),n=di(e,-t-64,-64),r=di(e,0,-t-64),[o,s,a]=Lu(id,n);return{authorization:ad({address:o.delegation,chainId:Number(o.chainId),nonce:o.nonce,yParity:o.yParity,r:o.r,s:o.s}),signature:r,...a&&"0x"!==a?{data:a,to:s}:{}}}(t.signature),d=await Dc(e,{address:n,blockNumber:r,blockTag:o});if(d===Ln(["0xef0100",i.address]))return await async function(e,t){const{address:n,blockNumber:r,blockTag:o,hash:s,signature:a}=t,i=await je(e,Zi,"readContract")({address:n,abi:Bi,args:[s,a],blockNumber:r,blockTag:o,functionName:"isValidSignature"}).catch(e=>{if(e instanceof Gr)throw new Rd;throw e});if(i.startsWith("0x1626ba7e"))return!0;throw new Rd}(e,{address:n,blockNumber:r,blockTag:o,hash:s,signature:u});const f={address:i.address,chainId:Number(i.chainId),nonce:Number(i.nonce),r:Mt(i.r,{size:32}),s:Mt(i.s,{size:32}),yParity:i.yParity},h=await async function({address:e,authorization:t,signature:n}){return Fs(zn(e),await Ro({authorization:t,signature:n}))}({address:n,authorization:f});if(!h)throw new Rd;const p=await je(e,Zi,"readContract")({...a?{address:a}:{code:Mi},authorizationList:[f],abi:ki,blockNumber:r,blockTag:"pending",functionName:"aggregate3",args:[[...c?[{allowFailure:!0,target:l??n,callData:c}]:[],{allowFailure:!0,target:n,callData:cr({abi:Bi,functionName:"isValidSignature",args:[s,u]})}]]}),m=p[p.length-1]?.returnData;if(m?.startsWith("0x1626ba7e"))return!0;throw new Rd}(e,{...t,multicallAddress:s,signature:a}):await async function(e,t){const{address:n,factory:r,factoryData:o,hash:s,signature:a,verifierAddress:i,...c}=t,u=await(async()=>r||o?$d(a)?a:function(e){const{data:t,signature:n,to:r}=e;return oi(Uu(Gu("address, bytes, bytes"),[r,t,n]),Td)}({data:o,signature:a,to:r}):a)(),l=i?{to:i,data:cr({abi:Ci,functionName:"isValidSig",args:[n,s,u]}),...c}:{data:Ui({abi:Ci,args:[n,s,u],bytecode:_i}),...c},{data:d}=await je(e,Hi,"call")(l).catch(e=>{if(e instanceof Dr)throw new Rd;throw e});if(function(e,t={}){let n=e;if(t.size&&($t(n,{size:t.size}),n=Tt(n)),"0x00"===Tt(n))return!1;if("0x01"===Tt(n))return!0;throw new Nt(n)}(d??"0x0"))return!0;throw new Rd}(e,{...t,verifierAddress:o,signature:a})}catch(e){try{if(Fs(zn(n),await To({hash:r,signature:a})))return!0}catch{}if(e instanceof Rd)return!1;throw e}}class Rd extends Error{}function zd(e,{emitOnBegin:t=!1,emitMissed:n=!1,onBlockNumber:r,onError:o,poll:s,pollingInterval:a=e.pollingInterval}){let i;return(void 0!==s?s:"webSocket"!==e.transport.type&&"ipc"!==e.transport.type&&("fallback"!==e.transport.type||"webSocket"!==e.transport.transports[0].config.type&&"ipc"!==e.transport.transports[0].config.type))?Xi(Ir(["watchBlockNumber",e.uid,t,n,a]),{onBlockNumber:r,onError:o},r=>tc(async()=>{try{const t=await je(e,sc,"getBlockNumber")({cacheTime:0});if(void 0!==i){if(t===i)return;if(t-i>1&&n)for(let e=i+1n;e<t;e++)r.onBlockNumber(e,i),i=e}(void 0===i||t>i)&&(r.onBlockNumber(t,i),i=t)}catch(e){r.onError?.(e)}},{emitOnBegin:t,interval:a})):Xi(Ir(["watchBlockNumber",e.uid,t,n]),{onBlockNumber:r,onError:o},t=>{let n=!0,r=()=>n=!1;return(async()=>{try{const o=(()=>{if("fallback"===e.transport.type){const t=e.transport.transports.find(e=>"webSocket"===e.config.type||"ipc"===e.config.type);return t?t.value:e.transport}return e.transport})(),{unsubscribe:s}=await o.subscribe({params:["newHeads"],onData(e){if(!n)return;const r=Bt(e.result?.number);t.onBlockNumber(r,i),i=r},onError(e){t.onError?.(e)}});r=s,n||r()}catch(e){o?.(e)}})(),()=>r()})}const _d=/^(?:(?<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)?/,Md=/(?: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>.+))?/;async function Fd(e,t){const{address:n,domain:r,message:o,nonce:s,scheme:a,signature:i,time:c=new Date,...u}=t,l=function(e){const{scheme:t,statement:n,...r}=e.match(_d)?.groups??{},{chainId:o,expirationTime:s,issuedAt:a,notBefore:i,requestId:c,...u}=e.match(Md)?.groups??{},l=e.split("Resources:")[1]?.split("\n- ").slice(1);return{...r,...u,...o?{chainId:Number(o)}:{},...s?{expirationTime:new Date(s)}:{},...a?{issuedAt:new Date(a)}:{},...i?{notBefore:new Date(i)}:{},...c?{requestId:c}:{},...l?{resources:l}:{},...t?{scheme:t}:{},...n?{statement:n}:{}}}(o);if(!l.address)return!1;const d=function(e){const{address:t,domain:n,message:r,nonce:o,scheme:s,time:a=new Date}=e;if(n&&r.domain!==n)return!1;if(o&&r.nonce!==o)return!1;if(s&&r.scheme!==s)return!1;if(r.expirationTime&&a>=r.expirationTime)return!1;if(r.notBefore&&a<r.notBefore)return!1;try{if(!r.address)return!1;if(!Fn(r.address,{strict:!1}))return!1;if(t&&!Fs(r.address,t))return!1}catch{return!1}return!0}({address:n,domain:r,message:l,nonce:s,scheme:a,time:c});if(!d)return!1;const f=ru(o);return Od(e,{address:l.address,hash:f,signature:i,...u})}function jd(e){return{call:t=>Hi(e,t),createAccessList:t=>jc(e,t),createBlockFilter:()=>async function(e){const t=or(e,{method:"eth_newBlockFilter"}),n=await e.request({method:"eth_newBlockFilter"});return{id:n,request:t(n),type:"block"}}(e),createContractEventFilter:t=>sr(e,t),createEventFilter:t=>Lc(e,t),createPendingTransactionFilter:()=>Uc(e),estimateContractGas:t=>async function(e,t){const{abi:n,address:r,args:o,functionName:s,dataSuffix:a,...i}=t,c=cr({abi:n,args:o,functionName:s});try{return await je(e,Ms,"estimateGas")({data:`${c}${a?a.replace("0x",""):""}`,to:r,...i})}catch(e){const t=i.account?ar(i.account):void 0;throw No(e,{abi:n,address:r,args:o,docsPath:"/docs/contract/estimateContractGas",functionName:s,sender:t?.address})}}(e,t),estimateGas:t=>Ms(e,t),getBalance:t=>async function(e,{address:t,blockNumber:n,blockTag:r=e.experimental_blockTag??"latest"}){const o="bigint"==typeof n?Mt(n):void 0,s=await e.request({method:"eth_getBalance",params:[t,o||r]});return BigInt(s)}(e,t),getBlobBaseFee:()=>async function(e){const t=await e.request({method:"eth_blobBaseFee"});return BigInt(t)}(e),getBlock:t=>ls(e,t),getBlockNumber:t=>sc(e,t),getBlockTransactionCount:t=>async function(e,{blockHash:t,blockNumber:n,blockTag:r="latest"}={}){const o=void 0!==n?Mt(n):void 0;let s;return s=t?await e.request({method:"eth_getBlockTransactionCountByHash",params:[t]},{dedupe:!0}):await e.request({method:"eth_getBlockTransactionCountByNumber",params:[o||r]},{dedupe:Boolean(o)}),Ct(s)}(e,t),getBytecode:t=>Dc(e,t),getChainId:()=>Os(e),getCode:t=>Dc(e,t),getContractEvents:t=>Vs(e,t),getEip712Domain:t=>async function(e,t){const{address:n,factory:r,factoryData:o}=t;try{const[t,s,a,i,c,u,l]=await je(e,Zi,"readContract")({abi:qc,address:n,functionName:"eip712Domain",factory:r,factoryData:o});return{domain:{name:s,version:a,chainId:Number(i),verifyingContract:c,salt:u},extensions:l,fields:t}}catch(e){const t=e;if("ContractFunctionExecutionError"===t.name&&"ContractFunctionZeroDataError"===t.cause.name)throw new Gc({address:n});throw t}}(e,t),getEnsAddress:t=>async function(e,t){const{blockNumber:n,blockTag:r,coinType:o,name:s,gatewayUrls:a,strict:i}=t,{chain:c}=e,u=(()=>{if(t.universalResolverAddress)return t.universalResolverAddress;if(!c)throw new Error("client chain not configured. universalResolverAddress is required.");return Di({blockNumber:n,chain:c,contract:"ensUniversalResolver"})})(),l=c?.ensTlds;if(l&&!l.some(e=>s.endsWith(e)))return null;const d=null!=o?[xc(s),BigInt(o)]:[xc(s)];try{const t=cr({abi:$i,functionName:"addr",args:d}),o={address:u,abi:Ni,functionName:"resolveWithGateways",args:[Rt(kc(s)),t,a??[yc]],blockNumber:n,blockTag:r},i=je(e,Zi,"readContract"),c=await i(o);if("0x"===c[0])return null;const l=Hs({abi:$i,args:d,functionName:"addr",data:c[0]});return"0x"===l||"0x00"===Tt(l)?null:l}catch(e){if(i)throw e;if(pc(e))return null;throw e}}(e,t),getEnsAvatar:t=>async function(e,{blockNumber:t,blockTag:n,assetGatewayUrls:r,name:o,gatewayUrls:s,strict:a,universalResolverAddress:i}){const c=await je(e,Fc,"getEnsText")({blockNumber:t,blockTag:n,key:"avatar",name:o,universalResolverAddress:i,gatewayUrls:s,strict:a});if(!c)return null;try{return await Mc(e,{record:c,gatewayUrls:r})}catch{return null}}(e,t),getEnsName:t=>async function(e,t){const{address:n,blockNumber:r,blockTag:o,coinType:s=60n,gatewayUrls:a,strict:i}=t,{chain:c}=e,u=(()=>{if(t.universalResolverAddress)return t.universalResolverAddress;if(!c)throw new Error("client chain not configured. universalResolverAddress is required.");return Di({blockNumber:r,chain:c,contract:"ensUniversalResolver"})})();try{const t={address:u,abi:Si,args:[n,s,a??[yc]],functionName:"reverseWithGateways",blockNumber:r,blockTag:o},i=je(e,Zi,"readContract"),[c]=await i(t);return c||null}catch(e){if(i)throw e;if(pc(e))return null;throw e}}(e,t),getEnsResolver:t=>async function(e,t){const{blockNumber:n,blockTag:r,name:o}=t,{chain:s}=e,a=(()=>{if(t.universalResolverAddress)return t.universalResolverAddress;if(!s)throw new Error("client chain not configured. universalResolverAddress is required.");return Di({blockNumber:n,chain:s,contract:"ensUniversalResolver"})})(),i=s?.ensTlds;if(i&&!i.some(e=>o.endsWith(e)))throw new Error(`${o} is not a valid ENS TLD (${i?.join(", ")}) for chain "${s.name}" (id: ${s.id}).`);const[c]=await je(e,Zi,"readContract")({address:a,abi:[{inputs:[{type:"bytes"}],name:"findResolver",outputs:[{type:"address"},{type:"bytes32"},{type:"uint256"}],stateMutability:"view",type:"function"}],functionName:"findResolver",args:[Rt(kc(o))],blockNumber:n,blockTag:r});return c}(e,t),getEnsText:t=>Fc(e,t),getFeeHistory:t=>Vc(e,t),estimateFeesPerGas:t=>async function(e,t){return hs(e,t)}(e,t),getFilterChanges:e=>ac(0,e),getFilterLogs:e=>async function(e,{filter:t}){const n=t.strict??!1,r=(await t.request({method:"eth_getFilterLogs",params:[t.id]})).map(e=>Gs(e));return t.abi?Ds({abi:t.abi,logs:r,strict:n}):r}(0,e),getGasPrice:()=>ds(e),getLogs:t=>qs(e,t),getProof:t=>ld(e,t),estimateMaxPriorityFeePerGas:t=>async function(e,t){return fs(e,t)}(e,t),getStorageAt:t=>async function(e,{address:t,blockNumber:n,blockTag:r="latest",slot:o}){const s=void 0!==n?Mt(n):void 0;return await e.request({method:"eth_getStorageAt",params:[t,o,s||r]})}(e,t),getTransaction:t=>dd(e,t),getTransactionConfirmations:t=>async function(e,{hash:t,transactionReceipt:n}){const[r,o]=await Promise.all([je(e,sc,"getBlockNumber")({}),t?je(e,dd,"getTransaction")({hash:t}):void 0]),s=n?.blockNumber||o?.blockNumber;return s?r-s+1n:0n}(e,t),getTransactionCount:t=>ps(e,t),getTransactionReceipt:t=>fd(e,t),multicall:t=>async function(e,t){const{account:n,authorizationList:r,allowFailure:o=!0,blockNumber:s,blockOverrides:a,blockTag:i,stateOverride:c}=t,u=t.contracts,{batchSize:l=t.batchSize??1024,deployless:d=t.deployless??!1}="object"==typeof e.batch?.multicall?e.batch.multicall:{},f=(()=>{if(t.multicallAddress)return t.multicallAddress;if(d)return null;if(e.chain)return Di({blockNumber:s,chain:e.chain,contract:"multicall3"});throw new Error("client chain not configured. multicallAddress is required.")})(),h=[[]];let p=0,m=0;for(let e=0;e<u.length;e++){const{abi:t,address:r,args:s,functionName:a}=u[e];try{const e=cr({abi:t,args:s,functionName:a});m+=(e.length-2)/2,l>0&&m>l&&h[p].length>0&&(p++,m=(e.length-2)/2,h[p]=[]),h[p]=[...h[p],{allowFailure:!0,callData:e,target:r}]}catch(e){const i=No(e,{abi:t,address:r,args:s,docsPath:"/docs/contract/multicall",functionName:a,sender:n});if(!o)throw i;h[p]=[...h[p],{allowFailure:!0,callData:"0x",target:r}]}}const g=await Promise.allSettled(h.map(t=>je(e,Zi,"readContract")({...null===f?{code:Mi}:{address:f},abi:ki,account:n,args:[t],authorizationList:r,blockNumber:s,blockOverrides:a,blockTag:i,functionName:"aggregate3",stateOverride:c}))),b=[];for(let e=0;e<g.length;e++){const t=g[e];if("rejected"===t.status){if(!o)throw t.reason;for(let n=0;n<h[e].length;n++)b.push({status:"failure",error:t.reason,result:void 0});continue}const n=t.value;for(let t=0;t<n.length;t++){const{returnData:r,success:s}=n[t],{callData:a}=h[e][t],{abi:i,address:c,functionName:l,args:d}=u[b.length];try{if("0x"===a)throw new Qe;if(!s)throw new Hr({data:r});const e=Hs({abi:i,args:d,data:r,functionName:l});b.push(o?{result:e,status:"success"}:e)}catch(e){const t=No(e,{abi:i,address:c,args:d,docsPath:"/docs/contract/multicall",functionName:l});if(!o)throw t;b.push({error:t,result:void 0,status:"failure"})}}}if(b.length!==u.length)throw new He("multicall results mismatch");return b}(e,t),prepareTransactionRequest:t=>_s(e,t),readContract:t=>Zi(e,t),sendRawTransaction:t=>async function(e,{serializedTransaction:t}){return e.request({method:"eth_sendRawTransaction",params:[t]},{retryCount:0})}(e,t),simulate:t=>hd(e,t),simulateBlocks:t=>hd(e,t),simulateCalls:t=>Sd(e,t),simulateContract:t=>async function(e,t){const{abi:n,address:r,args:o,dataSuffix:s,functionName:a,...i}=t,c=i.account?ar(i.account):e.account,u=cr({abi:n,args:o,functionName:a});try{const{data:l}=await je(e,Hi,"call")({batch:!1,data:`${u}${s?s.replace("0x",""):""}`,to:r,...i,account:c});return{result:Hs({abi:n,args:o,functionName:a,data:l||"0x"}),request:{abi:n.filter(e=>"name"in e&&e.name===t.functionName),address:r,args:o,dataSuffix:s,functionName:a,...i,account:c}}}catch(e){throw No(e,{abi:n,address:r,args:o,docsPath:"/docs/contract/simulateContract",functionName:a,sender:c?.address})}}(e,t),verifyHash:t=>Od(e,t),verifyMessage:t=>async function(e,{address:t,message:n,factory:r,factoryData:o,signature:s,...a}){return Od(e,{address:t,factory:r,factoryData:o,hash:ru(n),signature:s,...a})}(e,t),verifySiweMessage:t=>Fd(e,t),verifyTypedData:t=>async function(e,t){const{address:n,factory:r,factoryData:o,signature:s,message:a,primaryType:i,types:c,domain:u,...l}=t;return Od(e,{address:n,factory:r,factoryData:o,hash:uu({message:a,primaryType:i,types:c,domain:u}),signature:s,...l})}(e,t),uninstallFilter:e=>ic(0,e),waitForTransactionReceipt:t=>async function(e,t){const{checkReplacement:n=!0,confirmations:r=1,hash:o,onReplaced:s,retryCount:a=6,retryDelay:i=({count:e})=>200*(1<<e),timeout:c=18e4}=t,u=Ir(["waitForTransactionReceipt",e.uid,o]),l=t.pollingInterval?t.pollingInterval:e.chain?.experimental_preconfirmationTime?e.chain.experimental_preconfirmationTime:e.pollingInterval;let d,f,h,p,m,g=!1;const{promise:b,resolve:y,reject:w}=qi(),v=c?setTimeout(()=>{m?.(),p?.(),w(new Ur({hash:o}))},c):void 0;return p=Xi(u,{onReplaced:s,resolve:y,reject:w},async t=>{if(h=await je(e,fd,"getTransactionReceipt")({hash:o}).catch(()=>{}),h&&r<=1)return clearTimeout(v),t.resolve(h),void p?.();m=je(e,zd,"watchBlockNumber")({emitMissed:!0,emitOnBegin:!0,poll:!0,pollingInterval:l,async onBlockNumber(s){const c=e=>{clearTimeout(v),m?.(),e(),p?.()};let u=s;if(!g)try{if(h){if(r>1&&(!h.blockNumber||u-h.blockNumber+1n<r))return;return void c(()=>t.resolve(h))}if(n&&!d&&(g=!0,await cc(async()=>{d=await je(e,dd,"getTransaction")({hash:o}),d.blockNumber&&(u=d.blockNumber)},{delay:i,retryCount:a}),g=!1),h=await je(e,fd,"getTransactionReceipt")({hash:o}),r>1&&(!h.blockNumber||u-h.blockNumber+1n<r))return;c(()=>t.resolve(h))}catch(n){if(n instanceof jr||n instanceof Lr){if(!d)return void(g=!1);try{f=d,g=!0;const n=await cc(()=>je(e,ls,"getBlock")({blockNumber:u,includeTransactions:!0}),{delay:i,retryCount:a,shouldRetry:({error:e})=>e instanceof as});g=!1;const o=n.transactions.find(({from:e,nonce:t})=>e===f.from&&t===f.nonce);if(!o)return;if(h=await je(e,fd,"getTransactionReceipt")({hash:o.hash}),r>1&&(!h.blockNumber||u-h.blockNumber+1n<r))return;let s="replaced";o.to===f.to&&o.value===f.value&&o.input===f.input?s="repriced":o.from===o.to&&0n===o.value&&(s="cancelled"),c(()=>{t.onReplaced?.({reason:s,replacedTransaction:f,transaction:o,transactionReceipt:h}),t.resolve(h)})}catch(e){c(()=>t.reject(e))}}else c(()=>t.reject(n))}}})}),b}(e,t),watchBlocks:t=>function(e,{blockTag:t=e.experimental_blockTag??"latest",emitMissed:n=!1,emitOnBegin:r=!1,onBlock:o,onError:s,includeTransactions:a,poll:i,pollingInterval:c=e.pollingInterval}){const u=void 0!==i?i:"webSocket"!==e.transport.type&&"ipc"!==e.transport.type&&("fallback"!==e.transport.type||"webSocket"!==e.transport.transports[0].config.type&&"ipc"!==e.transport.transports[0].config.type),l=a??!1;let d;return u?Xi(Ir(["watchBlocks",e.uid,t,n,r,l,c]),{onBlock:o,onError:s},o=>tc(async()=>{try{const r=await je(e,ls,"getBlock")({blockTag:t,includeTransactions:l});if(null!==r.number&&null!=d?.number){if(r.number===d.number)return;if(r.number-d.number>1&&n)for(let t=d?.number+1n;t<r.number;t++){const n=await je(e,ls,"getBlock")({blockNumber:t,includeTransactions:l});o.onBlock(n,d),d=n}}(null==d?.number||"pending"===t&&null==r?.number||null!==r.number&&r.number>d.number)&&(o.onBlock(r,d),d=r)}catch(e){o.onError?.(e)}},{emitOnBegin:r,interval:c})):(()=>{let n=!0,a=!0,i=()=>n=!1;return(async()=>{try{r&&je(e,ls,"getBlock")({blockTag:t,includeTransactions:l}).then(e=>{n&&a&&(o(e,void 0),a=!1)}).catch(s);const c=(()=>{if("fallback"===e.transport.type){const t=e.transport.transports.find(e=>"webSocket"===e.config.type||"ipc"===e.config.type);return t?t.value:e.transport}return e.transport})(),{unsubscribe:u}=await c.subscribe({params:["newHeads"],async onData(t){if(!n)return;const r=await je(e,ls,"getBlock")({blockNumber:t.result?.number,includeTransactions:l}).catch(()=>{});n&&(o(r,d),a=!1,d=r)},onError(e){s?.(e)}});i=u,n||i()}catch(e){s?.(e)}})(),()=>i()})()}(e,t),watchBlockNumber:t=>zd(e,t),watchContractEvent:t=>function(e,t){const{abi:n,address:r,args:o,batch:s=!0,eventName:a,fromBlock:i,onError:c,onLogs:u,poll:l,pollingInterval:d=e.pollingInterval,strict:f}=t;return(void 0!==l?l:"bigint"==typeof i||"webSocket"!==e.transport.type&&"ipc"!==e.transport.type&&("fallback"!==e.transport.type||"webSocket"!==e.transport.transports[0].config.type&&"ipc"!==e.transport.transports[0].config.type))?(()=>{const t=f??!1;return Xi(Ir(["watchContractEvent",r,o,s,e.uid,a,d,t,i]),{onLogs:u,onError:c},c=>{let u,l;void 0!==i&&(u=i-1n);let f=!1;const h=tc(async()=>{if(f)try{let i;if(l)i=await je(e,ac,"getFilterChanges")({filter:l});else{const s=await je(e,sc,"getBlockNumber")({});i=u&&u<s?await je(e,Vs,"getContractEvents")({abi:n,address:r,args:o,eventName:a,fromBlock:u+1n,toBlock:s,strict:t}):[],u=s}if(0===i.length)return;if(s)c.onLogs(i);else for(const e of i)c.onLogs([e])}catch(e){l&&e instanceof oo&&(f=!1),c.onError?.(e)}else{try{l=await je(e,sr,"createContractEventFilter")({abi:n,address:r,args:o,eventName:a,strict:t,fromBlock:i})}catch{}f=!0}},{emitOnBegin:!0,interval:d});return async()=>{l&&await je(e,ic,"uninstallFilter")({filter:l}),h()}})})():(()=>{const t=f??!1,i=Ir(["watchContractEvent",r,o,s,e.uid,a,d,t]);let l=!0,h=()=>l=!1;return Xi(i,{onLogs:u,onError:c},t=>((async()=>{try{const s=(()=>{if("fallback"===e.transport.type){const t=e.transport.transports.find(e=>"webSocket"===e.config.type||"ipc"===e.config.type);return t?t.value:e.transport}return e.transport})(),i=a?nr({abi:n,eventName:a,args:o}):[],{unsubscribe:c}=await s.subscribe({params:["logs",{address:r,topics:i}],onData(e){if(!l)return;const r=e.result;try{const{eventName:e,args:o}=Ls({abi:n,data:r.data,topics:r.topics,strict:f}),s=Gs(r,{args:o,eventName:e});t.onLogs([s])}catch(e){let n,o;if(e instanceof ht||e instanceof pt){if(f)return;n=e.abiItem.name,o=e.abiItem.inputs?.some(e=>!("name"in e&&e.name))}const s=Gs(r,{args:o?[]:{},eventName:n});t.onLogs([s])}},onError(e){t.onError?.(e)}});h=c,l||h()}catch(e){c?.(e)}})(),()=>h()))})()}(e,t),watchEvent:t=>function(e,{address:t,args:n,batch:r=!0,event:o,events:s,fromBlock:a,onError:i,onLogs:c,poll:u,pollingInterval:l=e.pollingInterval,strict:d}){const f=void 0!==u?u:"bigint"==typeof a||"webSocket"!==e.transport.type&&"ipc"!==e.transport.type&&("fallback"!==e.transport.type||"webSocket"!==e.transport.transports[0].config.type&&"ipc"!==e.transport.transports[0].config.type),h=d??!1;return f?Xi(Ir(["watchEvent",t,n,r,e.uid,o,l,a]),{onLogs:c,onError:i},i=>{let c,u;void 0!==a&&(c=a-1n);let d=!1;const f=tc(async()=>{if(d)try{let a;if(u)a=await je(e,ac,"getFilterChanges")({filter:u});else{const r=await je(e,sc,"getBlockNumber")({});a=c&&c!==r?await je(e,qs,"getLogs")({address:t,args:n,event:o,events:s,fromBlock:c+1n,toBlock:r}):[],c=r}if(0===a.length)return;if(r)i.onLogs(a);else for(const e of a)i.onLogs([e])}catch(e){u&&e instanceof oo&&(d=!1),i.onError?.(e)}else{try{u=await je(e,Lc,"createEventFilter")({address:t,args:n,event:o,events:s,strict:h,fromBlock:a})}catch{}d=!0}},{emitOnBegin:!0,interval:l});return async()=>{u&&await je(e,ic,"uninstallFilter")({filter:u}),f()}}):(()=>{let r=!0,a=()=>r=!1;return(async()=>{try{const u=(()=>{if("fallback"===e.transport.type){const t=e.transport.transports.find(e=>"webSocket"===e.config.type||"ipc"===e.config.type);return t?t.value:e.transport}return e.transport})(),l=s??(o?[o]:void 0);let f=[];if(l){const e=l.flatMap(e=>nr({abi:[e],eventName:e.name,args:n}));f=[e],o&&(f=f[0])}const{unsubscribe:p}=await u.subscribe({params:["logs",{address:t,topics:f}],onData(e){if(!r)return;const t=e.result;try{const{eventName:e,args:n}=Ls({abi:l??[],data:t.data,topics:t.topics,strict:h}),r=Gs(t,{args:n,eventName:e});c([r])}catch(e){let n,r;if(e instanceof ht||e instanceof pt){if(d)return;n=e.abiItem.name,r=e.abiItem.inputs?.some(e=>!("name"in e&&e.name))}const o=Gs(t,{args:r?[]:{},eventName:n});c([o])}},onError(e){i?.(e)}});a=p,r||a()}catch(e){i?.(e)}})(),()=>a()})()}(e,t),watchPendingTransactions:t=>function(e,{batch:t=!0,onError:n,onTransactions:r,poll:o,pollingInterval:s=e.pollingInterval}){return(void 0!==o?o:"webSocket"!==e.transport.type&&"ipc"!==e.transport.type)?Xi(Ir(["watchPendingTransactions",e.uid,t,s]),{onTransactions:r,onError:n},n=>{let r;const o=tc(async()=>{try{if(!r)try{return void(r=await je(e,Uc,"createPendingTransactionFilter")({}))}catch(e){throw o(),e}const s=await je(e,ac,"getFilterChanges")({filter:r});if(0===s.length)return;if(t)n.onTransactions(s);else for(const e of s)n.onTransactions([e])}catch(e){n.onError?.(e)}},{emitOnBegin:!0,interval:s});return async()=>{r&&await je(e,ic,"uninstallFilter")({filter:r}),o()}}):(()=>{let t=!0,o=()=>t=!1;return(async()=>{try{const{unsubscribe:s}=await e.transport.subscribe({params:["newPendingTransactions"],onData(e){if(!t)return;const n=e.result;r([n])},onError(e){n?.(e)}});o=s,t||o()}catch(e){n?.(e)}})(),()=>o()})()}(e,t)}}function Ld(e){const{key:t="public",name:n="Public Client"}=e,r=function(e){const{batch:t,chain:n,ccipRead:r,key:o="base",name:s="Base Client",type:a="base"}=e,i=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),l=e.pollingInterval??u,d=e.cacheTime??l,f=e.account?ar(e.account):void 0,{config:h,request:p,value:m}=e.transport({chain:n,pollingInterval:l}),g={account:f,batch:t,cacheTime:d,ccipRead:r,chain:n,key:o,name:s,pollingInterval:l,request:p,transport:{...h,...m},type:a,uid:hc(),...i?{experimental_blockTag:i}:{}};return Object.assign(g,{extend:function e(t){return n=>{const r=n(t);for(const e in g)delete r[e];const o={...t,...r};return Object.assign(o,{extend:e(o)})}}(g)})}({...e,key:t,name:n,type:"publicClient"});return r.extend(jd)}class Ud extends He{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 Dd(e,t={}){const{batch:n,fetchFn:r,fetchOptions:o,key:s="http",methods:a,name:i="HTTP JSON-RPC",onFetchRequest:c,onFetchResponse:u,retryDelay:l,raw:d}=t;return({chain:f,retryCount:h,timeout:p})=>{const{batchSize:m=1e3,wait:g=0}="object"==typeof n?n:{},b=t.retryCount??h,y=p??t.timeout??1e4,w=e||f?.rpcUrls.default.http[0];if(!w)throw new Ud;const v=nu(w,{fetchFn:r,fetchOptions:o,onRequest:c,onResponse:u,timeout:y});return function({key:e,methods:t,name:n,request:r,retryCount:o=3,retryDelay:s=150,timeout:a,type:i},c){return{config:{key:e,methods:t,name:n,request:r,retryCount:o,retryDelay:s,timeout:a,type:i},request:Hc(r,{methods:t,retryCount:o,retryDelay:s,uid:hc()}),value:c}}({key:s,methods:a,name:i,async request({method:e,params:t}){const r={method:e,params:t},{schedule:o}=Wi({id:w,wait:g,shouldSplitBatch:e=>e.length>m,fn:e=>v.request({body:e}),sort:(e,t)=>e.id-t.id}),[{error:s,result:a}]=await(async e=>n?o(e):[await v.request({body:e})])(r);if(d)return{error:s,result:a};if(s)throw new Zr({body:r,error:s,url:w});return a},retryCount:b,retryDelay:l,timeout:y,type:"http"},{fetchOptions:o,url:w})}}function Gd(e,t,n){for(let n in t){let r=t[n];Object.defineProperty(e,n,{enumerable:!0,value:r,writable:!1})}}function qd(e,t){if(null==e)return"null";if(null==t&&(t=new Set),"object"==typeof e){if(t.has(e))return"[Circular]";t.add(e)}if(Array.isArray(e))return"[ "+e.map(e=>qd(e,t)).join(", ")+" ]";if(e instanceof Uint8Array){const t="0123456789abcdef";let n="0x";for(let r=0;r<e.length;r++)n+=t[e[r]>>4],n+=t[15&e[r]];return n}if("object"==typeof e&&"function"==typeof e.toJSON)return qd(e.toJSON(),t);switch(typeof e){case"boolean":case"number":case"symbol":return e.toString();case"bigint":return BigInt(e).toString();case"string":return JSON.stringify(e);case"object":{const n=Object.keys(e);return n.sort(),"{ "+n.map(n=>`${qd(n,t)}: ${qd(e[n],t)}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function Vd(e,t,n,r){if(!e)throw function(e,t,n){let r,o=e;{const r=[];if(n){if("message"in n||"code"in n||"name"in n)throw new Error(`value will overwrite populated values: ${qd(n)}`);for(const e in n){if("shortMessage"===e)continue;const t=n[e];r.push(e+"="+qd(t))}}r.push(`code=${t}`),r.push("version=6.15.0"),r.length&&(e+=" ("+r.join(", ")+")")}switch(t){case"INVALID_ARGUMENT":r=new TypeError(e);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":r=new RangeError(e);break;default:r=new Error(e)}return Gd(r,{code:t}),n&&Object.assign(r,n),null==r.shortMessage&&Gd(r,{shortMessage:o}),r}(t,n,r)}function Wd(e,t,n,r){Vd(e,t,"INVALID_ARGUMENT",{argument:n,value:r})}function Hd(e,t){return function(e,t){if(e instanceof Uint8Array)return e;if("string"==typeof e&&e.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)){const t=new Uint8Array((e.length-2)/2);let n=2;for(let r=0;r<t.length;r++)t[r]=parseInt(e.substring(n,n+2),16),n+=2;return t}Wd(!1,"invalid BytesLike value",t,e)}(e,t)}["NFD","NFC","NFKD","NFKC"].reduce((e,t)=>{try{if("test"!=="test".normalize(t))throw new Error("bad");if("NFD"===t){const e=String.fromCharCode(233).normalize("NFD");if(e!==String.fromCharCode(101,769))throw new Error("broken")}e.push(t)}catch(e){}return e},[]);const Yd=BigInt(0),Zd=BigInt(1),Kd=9007199254740991;function Jd(e,t){const n=ef(e,"value"),r=BigInt(nf(t,"width"));if(Vd(n>>r===Yd,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:e}),n>>r-Zd){return-((~n&(Zd<<r)-Zd)+Zd)}return n}function Qd(e,t){const n=ef(e,"value"),r=BigInt(nf(t,"bits"));return n&(Zd<<r)-Zd}function Xd(e,t){switch(typeof e){case"bigint":return e;case"number":return Wd(Number.isInteger(e),"underflow",t||"value",e),Wd(e>=-Kd&&e<=Kd,"overflow",t||"value",e),BigInt(e);case"string":try{if(""===e)throw new Error("empty string");return"-"===e[0]&&"-"!==e[1]?-BigInt(e.substring(1)):BigInt(e)}catch(n){Wd(!1,`invalid BigNumberish string: ${n.message}`,t||"value",e)}}Wd(!1,"invalid BigNumberish value",t||"value",e)}function ef(e,t){const n=Xd(e,t);return Vd(n>=Yd,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:e}),n}const tf="0123456789abcdef";function nf(e,t){switch(typeof e){case"bigint":return Wd(e>=-Kd&&e<=Kd,"overflow",t||"value",e),Number(e);case"number":return Wd(Number.isInteger(e),"underflow",t||"value",e),Wd(e>=-Kd&&e<=Kd,"overflow",t||"value",e),e;case"string":try{if(""===e)throw new Error("empty string");return nf(BigInt(e),t)}catch(n){Wd(!1,`invalid numeric string: ${n.message}`,t||"value",e)}}Wd(!1,"invalid numeric value",t||"value",e)}const rf=BigInt(-1),of=BigInt(0),sf=BigInt(1),af=BigInt(5),cf={};let uf="0000";for(;uf.length<80;)uf+=uf;function lf(e){let t=uf;for(;t.length<e;)t+=t;return BigInt("1"+t.substring(0,e))}function df(e,t,n){const r=BigInt(t.width);if(t.signed){const t=sf<<r-sf;Vd(null==n||e>=-t&&e<t,"overflow","NUMERIC_FAULT",{operation:n,fault:"overflow",value:e}),e=e>of?Jd(Qd(e,r),r):-Jd(Qd(-e,r),r)}else{const t=sf<<r;Vd(null==n||e>=0&&e<t,"overflow","NUMERIC_FAULT",{operation:n,fault:"overflow",value:e}),e=(e%t+t)%t&t-sf}return e}function ff(e){"number"==typeof e&&(e=`fixed128x${e}`);let t=!0,n=128,r=18;if("string"==typeof e)if("fixed"===e);else if("ufixed"===e)t=!1;else{const o=e.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);Wd(o,"invalid fixed format","format",e),t="u"!==o[1],n=parseInt(o[2]),r=parseInt(o[3])}else if(e){const o=e,s=(e,t,n)=>null==o[e]?n:(Wd(typeof o[e]===t,"invalid fixed format ("+e+" not "+t+")","format."+e,o[e]),o[e]);t=s("signed","boolean",t),n=s("width","number",n),r=s("decimals","number",r)}Wd(n%8==0,"invalid FixedNumber width (not byte aligned)","format.width",n),Wd(r<=80,"invalid FixedNumber decimals (too large)","format.decimals",r);return{signed:t,width:n,decimals:r,name:(t?"":"u")+"fixed"+String(n)+"x"+String(r)}}class hf{format;#e;#t;#n;_value;constructor(e,t,n){!function(e,t,n){if(e!==t){let e=n,t="new";e+=".",t+=" "+n,Vd(!1,`private constructor; use ${e}from* methods`,"UNSUPPORTED_OPERATION",{operation:t})}}(e,cf,"FixedNumber"),this.#t=t,this.#e=n;const r=function(e,t){let n="";e<of&&(n="-",e*=rf);let r=e.toString();if(0===t)return n+r;for(;r.length<=t;)r=uf+r;const o=r.length-t;for(r=r.substring(0,o)+"."+r.substring(o);"0"===r[0]&&"."!==r[1];)r=r.substring(1);for(;"0"===r[r.length-1]&&"."!==r[r.length-2];)r=r.substring(0,r.length-1);return n+r}(t,n.decimals);Gd(this,{format:n.name,_value:r}),this.#n=lf(n.decimals)}get signed(){return this.#e.signed}get width(){return this.#e.width}get decimals(){return this.#e.decimals}get value(){return this.#t}#r(e){Wd(this.format===e.format,"incompatible format; use fixedNumber.toFormat","other",e)}#o(e,t){return e=df(e,this.#e,t),new hf(cf,e,this.#e)}#s(e,t){return this.#r(e),this.#o(this.#t+e.#t,t)}addUnsafe(e){return this.#s(e)}add(e){return this.#s(e,"add")}#a(e,t){return this.#r(e),this.#o(this.#t-e.#t,t)}subUnsafe(e){return this.#a(e)}sub(e){return this.#a(e,"sub")}#i(e,t){return this.#r(e),this.#o(this.#t*e.#t/this.#n,t)}mulUnsafe(e){return this.#i(e)}mul(e){return this.#i(e,"mul")}mulSignal(e){this.#r(e);const t=this.#t*e.#t;return Vd(t%this.#n===of,"precision lost during signalling mul","NUMERIC_FAULT",{operation:"mulSignal",fault:"underflow",value:this}),this.#o(t/this.#n,"mulSignal")}#c(e,t){return Vd(e.#t!==of,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),this.#r(e),this.#o(this.#t*this.#n/e.#t,t)}divUnsafe(e){return this.#c(e)}div(e){return this.#c(e,"div")}divSignal(e){Vd(e.#t!==of,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),this.#r(e);const t=this.#t*this.#n;return Vd(t%e.#t===of,"precision lost during signalling div","NUMERIC_FAULT",{operation:"divSignal",fault:"underflow",value:this}),this.#o(t/e.#t,"divSignal")}cmp(e){let t=this.value,n=e.value;const r=this.decimals-e.decimals;return r>0?n*=lf(r):r<0&&(t*=lf(-r)),t<n?-1:t>n?1:0}eq(e){return 0===this.cmp(e)}lt(e){return this.cmp(e)<0}lte(e){return this.cmp(e)<=0}gt(e){return this.cmp(e)>0}gte(e){return this.cmp(e)>=0}floor(){let e=this.#t;return this.#t<of&&(e-=this.#n-sf),e=this.#t/this.#n*this.#n,this.#o(e,"floor")}ceiling(){let e=this.#t;return this.#t>of&&(e+=this.#n-sf),e=this.#t/this.#n*this.#n,this.#o(e,"ceiling")}round(e){if(null==e&&(e=0),e>=this.decimals)return this;const t=this.decimals-e,n=af*lf(t-1);let r=this.value+n;const o=lf(t);return r=r/o*o,df(r,this.#e,"round"),new hf(cf,r,this.#e)}isZero(){return this.#t===of}isNegative(){return this.#t<of}toString(){return this._value}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return hf.fromString(this.toString(),e)}static fromValue(e,t,n){const r=null==t?0:nf(t),o=ff(n);let s=Xd(e,"value");const a=r-o.decimals;if(a>0){const t=lf(a);Vd(s%t===of,"value loses precision for format","NUMERIC_FAULT",{operation:"fromValue",fault:"underflow",value:e}),s/=t}else a<0&&(s*=lf(-a));return df(s,o,"fromValue"),new hf(cf,s,o)}static fromString(e,t){const n=e.match(/^(-?)([0-9]*)\.?([0-9]*)$/);Wd(n&&n[2].length+n[3].length>0,"invalid FixedNumber string value","value",e);const r=ff(t);let o=n[2]||"0",s=n[3]||"";for(;s.length<r.decimals;)s+=uf;Vd(s.substring(r.decimals).match(/^0*$/),"too many decimals for format","NUMERIC_FAULT",{operation:"fromString",fault:"underflow",value:e}),s=s.substring(0,r.decimals);const a=BigInt(n[1]+o+s);return df(a,r,"fromString"),new hf(cf,a,r)}static fromBytes(e,t){let n=function(e){if(e instanceof Uint8Array){let t="0x0";for(const n of e)t+=tf[n>>4],t+=tf[15&n];return BigInt(t)}return Xd(e)}(Hd(e,"value"));const r=ff(t);return r.signed&&(n=Jd(n,r.width)),df(n,r,"fromBytes"),new hf(cf,n,r)}}function pf(e){return function(e,t){let n=18;return n=nf(t,"unit"),hf.fromValue(e,n,{decimals:n,width:512}).toString()}(e,18)}const mf="0.38.13";function gf({projectId:e,originComponentName:t,...n}){const r=new URL("https://pay.coinbase.com/buy");void 0!==e&&r.searchParams.append("appId",e);for(const e of Object.keys(n)){const t=n[e];void 0!==t&&(["string","number","boolean"].includes(typeof t)?r.searchParams.append(e,t.toString()):r.searchParams.append(e,JSON.stringify(t)))}return t?r.searchParams.append("sdkVersion",`onchainkit@${mf}:${t}`):r.searchParams.append("sdkVersion",`onchainkit@${mf}`),r.searchParams.sort(),r.toString()}var bf=[],yf=[],wf="undefined"!=typeof Uint8Array?Uint8Array:Array,vf=!1;function xf(){vf=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)bf[t]=e[t],yf[e.charCodeAt(t)]=t;yf["-".charCodeAt(0)]=62,yf["_".charCodeAt(0)]=63}function Ef(e){return bf[e>>18&63]+bf[e>>12&63]+bf[e>>6&63]+bf[63&e]}function Pf(e,t,n){for(var r,o=[],s=t;s<n;s+=3)r=(e[s]<<16)+(e[s+1]<<8)+e[s+2],o.push(Ef(r));return o.join("")}function kf(e){var t;vf||xf();for(var n=e.length,r=n%3,o="",s=[],a=16383,i=0,c=n-r;i<c;i+=a)s.push(Pf(e,i,i+a>c?c:i+a));return 1===r?(t=e[n-1],o+=bf[t>>2],o+=bf[t<<4&63],o+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],o+=bf[t>>10],o+=bf[t>>4&63],o+=bf[t<<2&63],o+="="),s.push(o),s.join("")}function Af(e,t,n,r,o){var s,a,i=8*o-r-1,c=(1<<i)-1,u=c>>1,l=-7,d=n?o-1:0,f=n?-1:1,h=e[t+d];for(d+=f,s=h&(1<<-l)-1,h>>=-l,l+=i;l>0;s=256*s+e[t+d],d+=f,l-=8);for(a=s&(1<<-l)-1,s>>=-l,l+=r;l>0;a=256*a+e[t+d],d+=f,l-=8);if(0===s)s=1-u;else{if(s===c)return a?NaN:1/0*(h?-1:1);a+=Math.pow(2,r),s-=u}return(h?-1:1)*a*Math.pow(2,s-r)}function If(e,t,n,r,o,s){var a,i,c,u=8*s-o-1,l=(1<<u)-1,d=l>>1,f=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:s-1,p=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(i=isNaN(t)?1:0,a=l):(a=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-a))<1&&(a--,c*=2),(t+=a+d>=1?f/c:f*Math.pow(2,1-d))*c>=2&&(a++,c/=2),a+d>=l?(i=0,a=l):a+d>=1?(i=(t*c-1)*Math.pow(2,o),a+=d):(i=t*Math.pow(2,d-1)*Math.pow(2,o),a=0));o>=8;e[n+h]=255&i,h+=p,i/=256,o-=8);for(a=a<<o|i,u+=o;u>0;e[n+h]=255&a,h+=p,a/=256,u-=8);e[n+h-p]|=128*m}var Nf={}.toString,Sf=Array.isArray||function(e){return"[object Array]"==Nf.call(e)};function Tf(){return Bf.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function $f(e,t){if(Tf()<t)throw new RangeError("Invalid typed array length");return Bf.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=Bf.prototype:(null===e&&(e=new Bf(t)),e.length=t),e}function Bf(e,t,n){if(!(Bf.TYPED_ARRAY_SUPPORT||this instanceof Bf))return new Bf(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return Rf(this,e)}return Cf(this,e,t,n)}function Cf(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r);Bf.TYPED_ARRAY_SUPPORT?(e=t).__proto__=Bf.prototype:e=zf(e,t);return e}(e,t,n,r):"string"==typeof t?function(e,t,n){"string"==typeof n&&""!==n||(n="utf8");if(!Bf.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|Ff(t,n);e=$f(e,r);var o=e.write(t,n);o!==r&&(e=e.slice(0,o));return e}(e,t,n):function(e,t){if(Mf(t)){var n=0|_f(t.length);return 0===(e=$f(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?$f(e,0):zf(e,t);if("Buffer"===t.type&&Sf(t.data))return zf(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function Of(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function Rf(e,t){if(Of(t),e=$f(e,t<0?0:0|_f(t)),!Bf.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function zf(e,t){var n=t.length<0?0:0|_f(t.length);e=$f(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function _f(e){if(e>=Tf())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Tf().toString(16)+" bytes");return 0|e}function Mf(e){return!(null==e||!e._isBuffer)}function Ff(e,t){if(Mf(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return dh(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return fh(e).length;default:if(r)return dh(e).length;t=(""+t).toLowerCase(),r=!0}}function jf(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return eh(this,t,n);case"utf8":case"utf-8":return Kf(this,t,n);case"ascii":return Qf(this,t,n);case"latin1":case"binary":return Xf(this,t,n);case"base64":return Zf(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return th(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function Lf(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function Uf(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=Bf.from(t,r)),Mf(t))return 0===t.length?-1:Df(e,t,n,r,o);if("number"==typeof t)return t&=255,Bf.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):Df(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function Df(e,t,n,r,o){var s,a=1,i=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;a=2,i/=2,c/=2,n/=2}function u(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(o){var l=-1;for(s=n;s<i;s++)if(u(e,s)===u(t,-1===l?0:s-l)){if(-1===l&&(l=s),s-l+1===c)return l*a}else-1!==l&&(s-=s-l),l=-1}else for(n+c>i&&(n=i-c),s=n;s>=0;s--){for(var d=!0,f=0;f<c;f++)if(u(e,s+f)!==u(t,f)){d=!1;break}if(d)return s}return-1}function Gf(e,t,n,r){n=Number(n)||0;var o=e.length-n;r?(r=Number(r))>o&&(r=o):r=o;var s=t.length;if(s%2!=0)throw new TypeError("Invalid hex string");r>s/2&&(r=s/2);for(var a=0;a<r;++a){var i=parseInt(t.substr(2*a,2),16);if(isNaN(i))return a;e[n+a]=i}return a}function qf(e,t,n,r){return hh(dh(t,e.length-n),e,n,r)}function Vf(e,t,n,r){return hh(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function Wf(e,t,n,r){return Vf(e,t,n,r)}function Hf(e,t,n,r){return hh(fh(t),e,n,r)}function Yf(e,t,n,r){return hh(function(e,t){for(var n,r,o,s=[],a=0;a<e.length&&!((t-=2)<0);++a)r=(n=e.charCodeAt(a))>>8,o=n%256,s.push(o),s.push(r);return s}(t,e.length-n),e,n,r)}function Zf(e,t,n){return 0===t&&n===e.length?kf(e):kf(e.slice(t,n))}function Kf(e,t,n){n=Math.min(e.length,n);for(var r=[],o=t;o<n;){var s,a,i,c,u=e[o],l=null,d=u>239?4:u>223?3:u>191?2:1;if(o+d<=n)switch(d){case 1:u<128&&(l=u);break;case 2:128==(192&(s=e[o+1]))&&(c=(31&u)<<6|63&s)>127&&(l=c);break;case 3:s=e[o+1],a=e[o+2],128==(192&s)&&128==(192&a)&&(c=(15&u)<<12|(63&s)<<6|63&a)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:s=e[o+1],a=e[o+2],i=e[o+3],128==(192&s)&&128==(192&a)&&128==(192&i)&&(c=(15&u)<<18|(63&s)<<12|(63&a)<<6|63&i)>65535&&c<1114112&&(l=c)}null===l?(l=65533,d=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),o+=d}return function(e){var t=e.length;if(t<=Jf)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=Jf));return n}(r)}Bf.TYPED_ARRAY_SUPPORT=void 0===globalThis.TYPED_ARRAY_SUPPORT||globalThis.TYPED_ARRAY_SUPPORT,Tf(),Bf.poolSize=8192,Bf._augment=function(e){return e.__proto__=Bf.prototype,e},Bf.from=function(e,t,n){return Cf(null,e,t,n)},Bf.TYPED_ARRAY_SUPPORT&&(Bf.prototype.__proto__=Uint8Array.prototype,Bf.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&Bf[Symbol.species]),Bf.alloc=function(e,t,n){return function(e,t,n,r){return Of(t),t<=0?$f(e,t):void 0!==n?"string"==typeof r?$f(e,t).fill(n,r):$f(e,t).fill(n):$f(e,t)}(null,e,t,n)},Bf.allocUnsafe=function(e){return Rf(null,e)},Bf.allocUnsafeSlow=function(e){return Rf(null,e)},Bf.isBuffer=function(e){return null!=e&&(!!e._isBuffer||ph(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&ph(e.slice(0,0))}(e))},Bf.compare=function(e,t){if(!Mf(e)||!Mf(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,o=0,s=Math.min(n,r);o<s;++o)if(e[o]!==t[o]){n=e[o],r=t[o];break}return n<r?-1:r<n?1:0},Bf.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Bf.concat=function(e,t){if(!Sf(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return Bf.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=Bf.allocUnsafe(t),o=0;for(n=0;n<e.length;++n){var s=e[n];if(!Mf(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,o),o+=s.length}return r},Bf.byteLength=Ff,Bf.prototype._isBuffer=!0,Bf.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)Lf(this,t,t+1);return this},Bf.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)Lf(this,t,t+3),Lf(this,t+1,t+2);return this},Bf.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)Lf(this,t,t+7),Lf(this,t+1,t+6),Lf(this,t+2,t+5),Lf(this,t+3,t+4);return this},Bf.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?Kf(this,0,e):jf.apply(this,arguments)},Bf.prototype.equals=function(e){if(!Mf(e))throw new TypeError("Argument must be a Buffer");return this===e||0===Bf.compare(this,e)},Bf.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},Bf.prototype.compare=function(e,t,n,r,o){if(!Mf(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(this===e)return 0;for(var s=(o>>>=0)-(r>>>=0),a=(n>>>=0)-(t>>>=0),i=Math.min(s,a),c=this.slice(r,o),u=e.slice(t,n),l=0;l<i;++l)if(c[l]!==u[l]){s=c[l],a=u[l];break}return s<a?-1:a<s?1:0},Bf.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},Bf.prototype.indexOf=function(e,t,n){return Uf(this,e,t,n,!0)},Bf.prototype.lastIndexOf=function(e,t,n){return Uf(this,e,t,n,!1)},Bf.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-t;if((void 0===n||n>o)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var s=!1;;)switch(r){case"hex":return Gf(this,e,t,n);case"utf8":case"utf-8":return qf(this,e,t,n);case"ascii":return Vf(this,e,t,n);case"latin1":case"binary":return Wf(this,e,t,n);case"base64":return Hf(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Yf(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}},Bf.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Jf=4096;function Qf(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(127&e[o]);return r}function Xf(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(e[o]);return r}function eh(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var o="",s=t;s<n;++s)o+=lh(e[s]);return o}function th(e,t,n){for(var r=e.slice(t,n),o="",s=0;s<r.length;s+=2)o+=String.fromCharCode(r[s]+256*r[s+1]);return o}function nh(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function rh(e,t,n,r,o,s){if(!Mf(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<s)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function oh(e,t,n,r){t<0&&(t=65535+t+1);for(var o=0,s=Math.min(e.length-n,2);o<s;++o)e[n+o]=(t&255<<8*(r?o:1-o))>>>8*(r?o:1-o)}function sh(e,t,n,r){t<0&&(t=4294967295+t+1);for(var o=0,s=Math.min(e.length-n,4);o<s;++o)e[n+o]=t>>>8*(r?o:3-o)&255}function ah(e,t,n,r,o,s){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function ih(e,t,n,r,o){return o||ah(e,0,n,4),If(e,t,n,r,23,4),n+4}function ch(e,t,n,r,o){return o||ah(e,0,n,8),If(e,t,n,r,52,8),n+8}Bf.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),Bf.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=Bf.prototype;else{var o=t-e;n=new Bf(o,void 0);for(var s=0;s<o;++s)n[s]=this[s+e]}return n},Bf.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||nh(e,t,this.length);for(var r=this[e],o=1,s=0;++s<t&&(o*=256);)r+=this[e+s]*o;return r},Bf.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||nh(e,t,this.length);for(var r=this[e+--t],o=1;t>0&&(o*=256);)r+=this[e+--t]*o;return r},Bf.prototype.readUInt8=function(e,t){return t||nh(e,1,this.length),this[e]},Bf.prototype.readUInt16LE=function(e,t){return t||nh(e,2,this.length),this[e]|this[e+1]<<8},Bf.prototype.readUInt16BE=function(e,t){return t||nh(e,2,this.length),this[e]<<8|this[e+1]},Bf.prototype.readUInt32LE=function(e,t){return t||nh(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Bf.prototype.readUInt32BE=function(e,t){return t||nh(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Bf.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||nh(e,t,this.length);for(var r=this[e],o=1,s=0;++s<t&&(o*=256);)r+=this[e+s]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*t)),r},Bf.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||nh(e,t,this.length);for(var r=t,o=1,s=this[e+--r];r>0&&(o*=256);)s+=this[e+--r]*o;return s>=(o*=128)&&(s-=Math.pow(2,8*t)),s},Bf.prototype.readInt8=function(e,t){return t||nh(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Bf.prototype.readInt16LE=function(e,t){t||nh(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},Bf.prototype.readInt16BE=function(e,t){t||nh(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},Bf.prototype.readInt32LE=function(e,t){return t||nh(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Bf.prototype.readInt32BE=function(e,t){return t||nh(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Bf.prototype.readFloatLE=function(e,t){return t||nh(e,4,this.length),Af(this,e,!0,23,4)},Bf.prototype.readFloatBE=function(e,t){return t||nh(e,4,this.length),Af(this,e,!1,23,4)},Bf.prototype.readDoubleLE=function(e,t){return t||nh(e,8,this.length),Af(this,e,!0,52,8)},Bf.prototype.readDoubleBE=function(e,t){return t||nh(e,8,this.length),Af(this,e,!1,52,8)},Bf.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||rh(this,e,t,n,Math.pow(2,8*n)-1,0);var o=1,s=0;for(this[t]=255&e;++s<n&&(o*=256);)this[t+s]=e/o&255;return t+n},Bf.prototype.writeUIntBE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||rh(this,e,t,n,Math.pow(2,8*n)-1,0);var o=n-1,s=1;for(this[t+o]=255&e;--o>=0&&(s*=256);)this[t+o]=e/s&255;return t+n},Bf.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||rh(this,e,t,1,255,0),Bf.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Bf.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||rh(this,e,t,2,65535,0),Bf.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):oh(this,e,t,!0),t+2},Bf.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||rh(this,e,t,2,65535,0),Bf.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):oh(this,e,t,!1),t+2},Bf.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||rh(this,e,t,4,4294967295,0),Bf.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):sh(this,e,t,!0),t+4},Bf.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||rh(this,e,t,4,4294967295,0),Bf.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):sh(this,e,t,!1),t+4},Bf.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);rh(this,e,t,n,o-1,-o)}var s=0,a=1,i=0;for(this[t]=255&e;++s<n&&(a*=256);)e<0&&0===i&&0!==this[t+s-1]&&(i=1),this[t+s]=(e/a|0)-i&255;return t+n},Bf.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);rh(this,e,t,n,o-1,-o)}var s=n-1,a=1,i=0;for(this[t+s]=255&e;--s>=0&&(a*=256);)e<0&&0===i&&0!==this[t+s+1]&&(i=1),this[t+s]=(e/a|0)-i&255;return t+n},Bf.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||rh(this,e,t,1,127,-128),Bf.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Bf.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||rh(this,e,t,2,32767,-32768),Bf.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):oh(this,e,t,!0),t+2},Bf.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||rh(this,e,t,2,32767,-32768),Bf.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):oh(this,e,t,!1),t+2},Bf.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||rh(this,e,t,4,2147483647,-2147483648),Bf.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):sh(this,e,t,!0),t+4},Bf.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||rh(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Bf.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):sh(this,e,t,!1),t+4},Bf.prototype.writeFloatLE=function(e,t,n){return ih(this,e,t,!0,n)},Bf.prototype.writeFloatBE=function(e,t,n){return ih(this,e,t,!1,n)},Bf.prototype.writeDoubleLE=function(e,t,n){return ch(this,e,t,!0,n)},Bf.prototype.writeDoubleBE=function(e,t,n){return ch(this,e,t,!1,n)},Bf.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var o,s=r-n;if(this===e&&n<t&&t<r)for(o=s-1;o>=0;--o)e[o+t]=this[o+n];else if(s<1e3||!Bf.TYPED_ARRAY_SUPPORT)for(o=0;o<s;++o)e[o+t]=this[o+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+s),t);return s},Bf.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var o=e.charCodeAt(0);o<256&&(e=o)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!Bf.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var s;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(s=t;s<n;++s)this[s]=e;else{var a=Mf(e)?e:dh(new Bf(e,r).toString()),i=a.length;for(s=0;s<n-t;++s)this[s+t]=a[s%i]}return this};var uh=/[^+\/0-9A-Za-z-_]/g;function lh(e){return e<16?"0"+e.toString(16):e.toString(16)}function dh(e,t){var n;t=t||1/0;for(var r=e.length,o=null,s=[],a=0;a<r;++a){if((n=e.charCodeAt(a))>55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(a+1===r){(t-=3)>-1&&s.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&s.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&s.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;s.push(n)}else if(n<2048){if((t-=2)<0)break;s.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;s.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return s}function fh(e){return function(e){var t,n,r,o,s,a;vf||xf();var i=e.length;if(i%4>0)throw new Error("Invalid string. Length must be a multiple of 4");s="="===e[i-2]?2:"="===e[i-1]?1:0,a=new wf(3*i/4-s),r=s>0?i-4:i;var c=0;for(t=0,n=0;t<r;t+=4,n+=3)o=yf[e.charCodeAt(t)]<<18|yf[e.charCodeAt(t+1)]<<12|yf[e.charCodeAt(t+2)]<<6|yf[e.charCodeAt(t+3)],a[c++]=o>>16&255,a[c++]=o>>8&255,a[c++]=255&o;return 2===s?(o=yf[e.charCodeAt(t)]<<2|yf[e.charCodeAt(t+1)]>>4,a[c++]=255&o):1===s&&(o=yf[e.charCodeAt(t)]<<10|yf[e.charCodeAt(t+1)]<<4|yf[e.charCodeAt(t+2)]>>2,a[c++]=o>>8&255,a[c++]=255&o),a}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(uh,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function hh(e,t,n,r){for(var o=0;o<r&&!(o+n>=t.length||o>=e.length);++o)t[o+n]=e[o];return o}function ph(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}class mh{constructor(e){this.selectedWalletId=null,this.solanaConnection=null,this.ethereumProvider=null,this.walletInfo=null,this.phantomAdapter=null,this.walletType="embedded",this.ethereumNetwork=null,this.defaultNetwork=exports.Network.Solana,this.api=h.default.create({baseURL:e.baseURL,headers:{"Content-Type":"application/json"}}),this.middleAccountApi=h.default.create({baseURL:e.middleAccountBaseURL||"https://yeezy-payment-service-sit-a0dchfccbufeh5bx.z03.azurefd.net",headers:{"Content-Type":"application/json"}}),this.solanaCluster=e.solanaCluster,this.solanaConnection=new t.Connection(e.solanaCluster.rpcUrl),e.ethereumNetwork&&(this.ethereumNetwork={...e.ethereumNetwork,chainId:Number(e.ethereumNetwork.chainId)},this.ethereumProvider=Ld({transport:Dd(e.ethereumNetwork.rpcUrl)})),this.defaultNetwork=e.defaultNetwork||exports.Network.Solana}setWallet(e){this.walletInfo=e}setWalletType(e){this.walletType=e,E.saveWalletType(e)}getWallet(){return this.walletInfo}getPhantomAdapter(){return this.phantomAdapter}getWalletType(){return this.walletType}get wallet(){var e;return(null===(e=this.walletInfo)||void 0===e?void 0:e.wallets.find(e=>e.network===this.defaultNetwork))||null}get address(){var e;return(null===(e=this.wallet)||void 0===e?void 0:e.address)||null}get network(){var e;return(null===(e=this.wallet)||void 0===e?void 0:e.network)||null}get ethereumWallet(){var e;return(null===(e=this.walletInfo)||void 0===e?void 0:e.wallets.find(e=>e.address===E.getSwitchedAccountAddress()||e.network===exports.Network.Ethereum&&"Main"===e.wallet_set))||null}get ethereumAddress(){var e;return(null===(e=this.ethereumWallet)||void 0===e?void 0:e.address)||null}get solanaWallet(){var e;return(null===(e=this.walletInfo)||void 0===e?void 0:e.wallets.find(e=>e.network===exports.Network.Solana&&"Main"===e.wallet_set))||null}get forwardSolanaWallet(){var e;return(null===(e=this.walletInfo)||void 0===e?void 0:e.wallets.find(e=>e.network===exports.Network.Solana&&"Forward-0"===e.wallet_set))||null}get forwardSolanaAddress(){var e;return(null===(e=this.forwardSolanaWallet)||void 0===e?void 0:e.address)||null}get forwardEthereumWallet(){var e;return(null===(e=this.walletInfo)||void 0===e?void 0:e.wallets.find(e=>e.network===exports.Network.Ethereum&&"Forward-0"===e.wallet_set))||null}get forwardEthereumAddress(){var e;return(null===(e=this.forwardEthereumWallet)||void 0===e?void 0:e.address)||null}get solanaAddress(){var e;return(null===(e=this.solanaWallet)||void 0===e?void 0:e.address)||null}get id(){var e;return(null===(e=this.walletInfo)||void 0===e?void 0:e.id)||null}get social_links(){var e;return(null===(e=this.walletInfo)||void 0===e?void 0:e.social_links)||null}async reconnect(){try{if("phantom"===E.getWalletType())return await this.connectPhantom();{const e=await this.getSession();return this.setWallet(e),e}}catch(e){return null}}async connectPhantom(){try{if(this.phantomAdapter||(this.phantomAdapter=new D),await this.phantomAdapter.connect(),!this.phantomAdapter.publicKey)throw new Error("Failed to connect to Phantom wallet");const e=this.phantomAdapter.publicKey.toString(),t={id:r.v4(),is_exported:!1,address:e,network:exports.Network.Solana,type:exports.WalletType.Phantom,wallets:[{id:e,address:e,network:exports.Network.Solana,wallet_type:exports.WalletType.Phantom,wallet_set:"Main"}],social_links:[],social_infos:[],account_info:{name:null}};return this.setWallet(t),this.setWalletType("phantom"),t}catch(e){throw console.error("Phantom connect error:",e),new Error(e instanceof Error?e.message:"Failed to connect to Phantom wallet")}}async updateAccountName(e){if(!this.walletInfo)throw new Error("No wallet info");const t=await this.api.post("/account/update",{name:e},{withCredentials:!0});return this.walletInfo.account_info.name=e,t.data}async signSolanaTransaction(e){try{if(!this.walletInfo)throw new Error("No wallet info");if(!this.solanaConnection)throw new Error("No rpc connection");const{blockhash:n}=await this.solanaConnection.getLatestBlockhash();if(b(e)?e.message.recentBlockhash=n:e.recentBlockhash=n,this.phantomAdapter&&this.phantomAdapter.publicKey)return await this.phantomAdapter.signTransaction(e);const r=this.solanaWallet;if(!r)throw new Error("No solana wallet available");const o={user_id:this.walletInfo.id,address:r.address,network:exports.Network.Solana,tx:{Solana:p.default.encode(b(e)?e.message.serialize():e.serializeMessage())}},s=await this.api.post("/sign2",o,{withCredentials:!0}),{signature:a}=s.data;return e.addSignature(new t.PublicKey(r.address),Bf.from(p.default.decode(a))),e}catch(e){throw new Error(e instanceof Error?e.message:"Failed to sign transaction")}}async signEthereumEip712(e){if(!this.ethereumNetwork)throw new Error("No Ethereum network");if(!this.ethereumProvider)throw new Error("No Ethereum provider");if(!this.walletInfo)throw new Error("No wallet info");if(!this.ethereumAddress)throw new Error("No Ethereum address");const t={user_id:this.walletInfo.id,address:this.ethereumAddress,network:exports.Network.Ethereum,tx:{EthereumEip712:e}},n=await this.api.post("/sign2",t,{withCredentials:!0}),{signature:r}=n.data;return r}async sendSolanaTransaction(e){if(!this.solanaConnection)throw new Error("No rpc connection");try{return await this.solanaConnection.sendRawTransaction(e,{maxRetries:3,skipPreflight:!1})}catch(e){throw e}}async sendEthereumTransaction(e){if(!this.ethereumProvider)throw new Error("No Ethereum provider");try{return await this.ethereumProvider.sendRawTransaction({serializedTransaction:e})}catch(e){throw e}}async sendEmailVerificationCode(e){await this.api.post("/send_verification",{email:e})}async sendPhoneVerificationCode(e){e.startsWith("+")||(e=`+${e}`),await this.api.post("/send_verification",{phone:e,type:"phone"})}async verifyEmailVerificationCode({email:e,code:t}){const n={type:"Email",data:{network:this.defaultNetwork,email:e,code:t}},r=(await this.api.post("/login",n,{withCredentials:!0})).data;return this.setWallet(r),this.setWalletType("embedded"),r}async verifyPhoneVerificationCode({phone:e,code:t}){const n={type:"Phone",data:{network:this.defaultNetwork,phone:e,code:t}},r=(await this.api.post("/login",n,{withCredentials:!0})).data;return this.setWallet(r),this.setWalletType("embedded"),r}async twitterLogin(e){const t={type:"TwitterOAuth",data:{network:this.defaultNetwork,...e}},n=(await this.api.post("/login",t,{withCredentials:!0})).data;return this.setWallet(n),this.setWalletType("embedded"),n}async googleLogin(e){const t={type:"GoogleOAuth",data:{network:this.defaultNetwork,...e}},n=(await this.api.post("/login",t,{withCredentials:!0})).data;return this.setWallet(n),this.setWalletType("embedded"),n}async oauthLogin(e,t){const n={type:e,data:{network:t.network||this.defaultNetwork,...t}},r=(await this.api.post("/login",n,{withCredentials:!0})).data;return this.setWallet(r),this.setWalletType("embedded"),r}async loginWithChallenge(e,t){const n={type:e,data:{network:t.network||this.defaultNetwork,...t}},r=(await this.api.post("/login",n,{withCredentials:!0})).data;return this.setWallet(r),this.setWalletType("embedded"),r}async oauthInit(e){return(await this.api.post("/oauth/init",e)).data}async getSignChallenge(e){return(await this.api.get(`/challenge?method=${e.method}&id=${e.id}`)).data}async getSession(){const e=(await this.api.get("/session",{withCredentials:!0})).data,{access_token:t,...n}=e;return t&&E.saveAccessToken(t),e}async logout(){this.phantomAdapter?(this.phantomAdapter.disconnect(),this.phantomAdapter=null):await this.api.post("/logout",{},{withCredentials:!0}),this.setWallet(null),E.clear()}async getOAuth2ClientId(e){return(await this.api.get(`/oauth_id/${e}`)).data.client_id}setSelectedWallet(e){this.selectedWalletId=e}getSelectedWallet(){return this.selectedWalletId}async getSolanaBalance(){if(!this.solanaConnection||!this.solanaAddress)throw new Error("Solana connection not available");return(await this.solanaConnection.getBalance(new t.PublicKey(this.solanaAddress))/t.LAMPORTS_PER_SOL).toString()}async getEthereumBalance(){if(!this.ethereumProvider||!this.ethereumAddress)throw new Error("Ethereum provider not available");return pf(await this.ethereumProvider.getBalance({address:this.ethereumAddress}))}async fetchCoinbaseToken(e,t="solana"){return(await this.api.post("/ramp/coinbase",{addresses:[{address:e,blockchains:[t]}],assets:["solana"===t?"SOL":"ETH"]})).data.token}viemSignerAdapter(){return{signTypedData:async e=>{if(!this.ethereumNetwork)throw new Error("No Ethereum network");if(!this.ethereumProvider)throw new Error("No Ethereum provider");if(!this.walletInfo)throw new Error("No wallet info");if(!this.ethereumAddress)throw new Error("No Ethereum address");const t={user_id:this.walletInfo.id,address:this.ethereumAddress,network:exports.Network.Ethereum,tx:{EthereumEip712:e}},n=await this.api.post("/sign2",t,{withCredentials:!0}),{signature:r}=n.data,o=p.default.decode(r),s=o[64];return Cd({r:`0x${Bf.from(o.slice(0,32)).toString("hex")}`,s:`0x${Bf.from(o.slice(32,64)).toString("hex")}`,v:BigInt(s+27)})}}}async createMiddleAccount(e){try{return(await this.middleAccountApi.post("/create",e)).data}catch(e){throw new Error(e instanceof Error?e.message:"Failed to create middle account")}}async getCoinbaseOnrampUrlForMiddleAccount(e){try{const t={sessionToken:await this.fetchCoinbaseToken(e.middleAccountAddress,e.network===exports.Network.Solana?"solana":"ethereum"),presetCryptoAmount:Number(e.amount),redirectUrl:e.redirectUrl||window.location.href};return gf(t)}catch(e){throw new Error(e instanceof Error?e.message:"Failed to get Coinbase onramp URL")}}async getOrderState(e){try{return(await this.middleAccountApi.get(`/order/${e}`)).data}catch(e){throw new Error(e instanceof Error?e.message:"Failed to get order status")}}async transfer(e){var t,n;if(!this.walletInfo)throw new Error("No wallet info available");const r={user_id:this.walletInfo.id,from:e.from,to:e.to,amount:e.amount,decimals:e.decimals,token:e.token,network:e.network,chain_id:e.chain_id};try{return(await this.api.post("/transfer",r,{withCredentials:!0})).data}catch(e){if(null===(n=null===(t=e.response)||void 0===t?void 0:t.data)||void 0===n?void 0:n.error)throw new Error(e.response.data.error);throw new Error(e instanceof Error?e.message:"Transfer failed")}}async buildTransaction(e){var t,n;try{return(await this.api.post("/build_transaction",e,{withCredentials:!0})).data}catch(e){if(null===(n=null===(t=e.response)||void 0===t?void 0:t.data)||void 0===n?void 0:n.error)throw new Error(e.response.data.error);throw new Error(e instanceof Error?e.message:"Failed to build transaction")}}}var gh=function(){return gh=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},gh.apply(this,arguments)};function bh(e,t,n){if(n||2===arguments.length)for(var r,o=0,s=t.length;o<s;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}function yh(e){var t=Object.create(null);return function(n){return void 0===t[n]&&(t[n]=e(n)),t[n]}}"function"==typeof SuppressedError&&SuppressedError;var wh=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,vh=yh(function(e){return wh.test(e)||111===e.charCodeAt(0)&&110===e.charCodeAt(1)&&e.charCodeAt(2)<91}),xh="-ms-",Eh="-moz-",Ph="-webkit-",kh="comm",Ah="rule",Ih="decl",Nh="@keyframes",Sh=Math.abs,Th=String.fromCharCode,$h=Object.assign;function Bh(e){return e.trim()}function Ch(e,t){return(e=t.exec(e))?e[0]:e}function Oh(e,t,n){return e.replace(t,n)}function Rh(e,t,n){return e.indexOf(t,n)}function zh(e,t){return 0|e.charCodeAt(t)}function _h(e,t,n){return e.slice(t,n)}function Mh(e){return e.length}function Fh(e){return e.length}function jh(e,t){return t.push(e),e}function Lh(e,t){return e.filter(function(e){return!Ch(e,t)})}var Uh=1,Dh=1,Gh=0,qh=0,Vh=0,Wh="";function Hh(e,t,n,r,o,s,a,i){return{value:e,root:t,parent:n,type:r,props:o,children:s,line:Uh,column:Dh,length:a,return:"",siblings:i}}function Yh(e,t){return $h(Hh("",null,null,"",null,null,0,e.siblings),e,{length:-e.length},t)}function Zh(e){for(;e.root;)e=Yh(e.root,{children:[e]});jh(e,e.siblings)}function Kh(){return Vh=qh>0?zh(Wh,--qh):0,Dh--,10===Vh&&(Dh=1,Uh--),Vh}function Jh(){return Vh=qh<Gh?zh(Wh,qh++):0,Dh++,10===Vh&&(Dh=1,Uh++),Vh}function Qh(){return zh(Wh,qh)}function Xh(){return qh}function ep(e,t){return _h(Wh,e,t)}function tp(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function np(e){return Bh(ep(qh-1,sp(91===e?e+2:40===e?e+1:e)))}function rp(e){for(;(Vh=Qh())&&Vh<33;)Jh();return tp(e)>2||tp(Vh)>3?"":" "}function op(e,t){for(;--t&&Jh()&&!(Vh<48||Vh>102||Vh>57&&Vh<65||Vh>70&&Vh<97););return ep(e,Xh()+(t<6&&32==Qh()&&32==Jh()))}function sp(e){for(;Jh();)switch(Vh){case e:return qh;case 34:case 39:34!==e&&39!==e&&sp(Vh);break;case 40:41===e&&sp(e);break;case 92:Jh()}return qh}function ap(e,t){for(;Jh()&&e+Vh!==57&&(e+Vh!==84||47!==Qh()););return"/*"+ep(t,qh-1)+"*"+Th(47===e?e:Jh())}function ip(e){for(;!tp(Qh());)Jh();return ep(e,qh)}function cp(e){return function(e){return Wh="",e}(up("",null,null,null,[""],e=function(e){return Uh=Dh=1,Gh=Mh(Wh=e),qh=0,[]}(e),0,[0],e))}function up(e,t,n,r,o,s,a,i,c){for(var u=0,l=0,d=a,f=0,h=0,p=0,m=1,g=1,b=1,y=0,w="",v=o,x=s,E=r,P=w;g;)switch(p=y,y=Jh()){case 40:if(108!=p&&58==zh(P,d-1)){-1!=Rh(P+=Oh(np(y),"&","&\f"),"&\f",Sh(u?i[u-1]:0))&&(b=-1);break}case 34:case 39:case 91:P+=np(y);break;case 9:case 10:case 13:case 32:P+=rp(p);break;case 92:P+=op(Xh()-1,7);continue;case 47:switch(Qh()){case 42:case 47:jh(dp(ap(Jh(),Xh()),t,n,c),c);break;default:P+="/"}break;case 123*m:i[u++]=Mh(P)*b;case 125*m:case 59:case 0:switch(y){case 0:case 125:g=0;case 59+l:-1==b&&(P=Oh(P,/\f/g,"")),h>0&&Mh(P)-d&&jh(h>32?fp(P+";",r,n,d-1,c):fp(Oh(P," ","")+";",r,n,d-2,c),c);break;case 59:P+=";";default:if(jh(E=lp(P,t,n,u,l,o,i,w,v=[],x=[],d,s),s),123===y)if(0===l)up(P,t,E,E,v,s,d,i,x);else switch(99===f&&110===zh(P,3)?100:f){case 100:case 108:case 109:case 115:up(e,E,E,r&&jh(lp(e,E,E,0,0,o,i,w,o,v=[],d,x),x),o,x,d,i,r?v:x);break;default:up(P,E,E,E,[""],x,0,i,x)}}u=l=h=0,m=b=1,w=P="",d=a;break;case 58:d=1+Mh(P),h=p;default:if(m<1)if(123==y)--m;else if(125==y&&0==m++&&125==Kh())continue;switch(P+=Th(y),y*m){case 38:b=l>0?1:(P+="\f",-1);break;case 44:i[u++]=(Mh(P)-1)*b,b=1;break;case 64:45===Qh()&&(P+=np(Jh())),f=Qh(),l=d=Mh(w=P+=ip(Xh())),y++;break;case 45:45===p&&2==Mh(P)&&(m=0)}}return s}function lp(e,t,n,r,o,s,a,i,c,u,l,d){for(var f=o-1,h=0===o?s:[""],p=Fh(h),m=0,g=0,b=0;m<r;++m)for(var y=0,w=_h(e,f+1,f=Sh(g=a[m])),v=e;y<p;++y)(v=Bh(g>0?h[y]+" "+w:Oh(w,/&\f/g,h[y])))&&(c[b++]=v);return Hh(e,t,n,0===o?Ah:i,c,u,l,d)}function dp(e,t,n,r){return Hh(e,t,n,kh,Th(Vh),_h(e,2,-2),0,r)}function fp(e,t,n,r,o){return Hh(e,t,n,Ih,_h(e,0,r),_h(e,r+1,-1),r,o)}function hp(e,t,n){switch(function(e,t){return 45^zh(e,0)?(((t<<2^zh(e,0))<<2^zh(e,1))<<2^zh(e,2))<<2^zh(e,3):0}(e,t)){case 5103:return Ph+"print-"+e+e;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return Ph+e+e;case 4789:return Eh+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return Ph+e+Eh+e+xh+e+e;case 5936:switch(zh(e,t+11)){case 114:return Ph+e+xh+Oh(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return Ph+e+xh+Oh(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return Ph+e+xh+Oh(e,/[svh]\w+-[tblr]{2}/,"lr")+e}case 6828:case 4268:case 2903:return Ph+e+xh+e+e;case 6165:return Ph+e+xh+"flex-"+e+e;case 5187:return Ph+e+Oh(e,/(\w+).+(:[^]+)/,Ph+"box-$1$2"+xh+"flex-$1$2")+e;case 5443:return Ph+e+xh+"flex-item-"+Oh(e,/flex-|-self/g,"")+(Ch(e,/flex-|baseline/)?"":xh+"grid-row-"+Oh(e,/flex-|-self/g,""))+e;case 4675:return Ph+e+xh+"flex-line-pack"+Oh(e,/align-content|flex-|-self/g,"")+e;case 5548:return Ph+e+xh+Oh(e,"shrink","negative")+e;case 5292:return Ph+e+xh+Oh(e,"basis","preferred-size")+e;case 6060:return Ph+"box-"+Oh(e,"-grow","")+Ph+e+xh+Oh(e,"grow","positive")+e;case 4554:return Ph+Oh(e,/([^-])(transform)/g,"$1"+Ph+"$2")+e;case 6187:return Oh(Oh(Oh(e,/(zoom-|grab)/,Ph+"$1"),/(image-set)/,Ph+"$1"),e,"")+e;case 5495:case 3959:return Oh(e,/(image-set\([^]*)/,Ph+"$1$`$1");case 4968:return Oh(Oh(e,/(.+:)(flex-)?(.*)/,Ph+"box-pack:$3"+xh+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+Ph+e+e;case 4200:if(!Ch(e,/flex-|baseline/))return xh+"grid-column-align"+_h(e,t)+e;break;case 2592:case 3360:return xh+Oh(e,"template-","")+e;case 4384:case 3616:return n&&n.some(function(e,n){return t=n,Ch(e.props,/grid-\w+-end/)})?~Rh(e+(n=n[t].value),"span",0)?e:xh+Oh(e,"-start","")+e+xh+"grid-row-span:"+(~Rh(n,"span",0)?Ch(n,/\d+/):+Ch(n,/\d+/)-+Ch(e,/\d+/))+";":xh+Oh(e,"-start","")+e;case 4896:case 4128:return n&&n.some(function(e){return Ch(e.props,/grid-\w+-start/)})?e:xh+Oh(Oh(e,"-end","-span"),"span ","")+e;case 4095:case 3583:case 4068:case 2532:return Oh(e,/(.+)-inline(.+)/,Ph+"$1$2")+e;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(Mh(e)-1-t>6)switch(zh(e,t+1)){case 109:if(45!==zh(e,t+4))break;case 102:return Oh(e,/(.+:)(.+)-([^]+)/,"$1"+Ph+"$2-$3$1"+Eh+(108==zh(e,t+3)?"$3":"$2-$3"))+e;case 115:return~Rh(e,"stretch",0)?hp(Oh(e,"stretch","fill-available"),t,n)+e:e}break;case 5152:case 5920:return Oh(e,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(t,n,r,o,s,a,i){return xh+n+":"+r+i+(o?xh+n+"-span:"+(s?a:+a-+r)+i:"")+e});case 4949:if(121===zh(e,t+6))return Oh(e,":",":"+Ph)+e;break;case 6444:switch(zh(e,45===zh(e,14)?18:11)){case 120:return Oh(e,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+Ph+(45===zh(e,14)?"inline-":"")+"box$3$1"+Ph+"$2$3$1"+xh+"$2box$3")+e;case 100:return Oh(e,":",":"+xh)+e}break;case 5719:case 2647:case 2135:case 3927:case 2391:return Oh(e,"scroll-","scroll-snap-")+e}return e}function pp(e,t){for(var n="",r=0;r<e.length;r++)n+=t(e[r],r,e,t)||"";return n}function mp(e,t,n,r){switch(e.type){case"@layer":if(e.children.length)break;case"@import":case Ih:return e.return=e.return||e.value;case kh:return"";case Nh:return e.return=e.value+"{"+pp(e.children,r)+"}";case Ah:if(!Mh(e.value=e.props.join(",")))return""}return Mh(n=pp(e.children,r))?e.return=e.value+"{"+n+"}":""}function gp(e,t,n,r){if(e.length>-1&&!e.return)switch(e.type){case Ih:return void(e.return=hp(e.value,e.length,n));case Nh:return pp([Yh(e,{value:Oh(e.value,"@","@"+Ph)})],r);case Ah:if(e.length)return function(e,t){return e.map(t).join("")}(n=e.props,function(t){switch(Ch(t,r=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":Zh(Yh(e,{props:[Oh(t,/:(read-\w+)/,":-moz-$1")]})),Zh(Yh(e,{props:[t]})),$h(e,{props:Lh(n,r)});break;case"::placeholder":Zh(Yh(e,{props:[Oh(t,/:(plac\w+)/,":"+Ph+"input-$1")]})),Zh(Yh(e,{props:[Oh(t,/:(plac\w+)/,":-moz-$1")]})),Zh(Yh(e,{props:[Oh(t,/:(plac\w+)/,xh+"input-$1")]})),Zh(Yh(e,{props:[t]})),$h(e,{props:Lh(n,r)})}return""})}}var bp={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},yp="undefined"!=typeof process&&void 0!==process.env&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",wp="active",vp="data-styled-version",xp="6.1.19",Ep="/*!sc*/\n",Pp="undefined"!=typeof window&&"undefined"!=typeof document,kp=Boolean("boolean"==typeof SC_DISABLE_SPEEDY?SC_DISABLE_SPEEDY:"undefined"!=typeof process&&void 0!==process.env&&void 0!==process.env.REACT_APP_SC_DISABLE_SPEEDY&&""!==process.env.REACT_APP_SC_DISABLE_SPEEDY?"false"!==process.env.REACT_APP_SC_DISABLE_SPEEDY&&process.env.REACT_APP_SC_DISABLE_SPEEDY:"undefined"!=typeof process&&void 0!==process.env&&void 0!==process.env.SC_DISABLE_SPEEDY&&""!==process.env.SC_DISABLE_SPEEDY?"false"!==process.env.SC_DISABLE_SPEEDY&&process.env.SC_DISABLE_SPEEDY:"production"!==process.env.NODE_ENV),Ap=/invalid hook call/i,Ip=new Set,Np=function(e,t){if("production"!==process.env.NODE_ENV){var n=t?' with the id of "'.concat(t,'"'):"",r="The component ".concat(e).concat(n," has been created dynamically.\n")+"You may see this warning because you've called styled inside another component.\nTo resolve this only create new StyledComponents outside of any render method and function component.\nSee https://styled-components.com/docs/basics#define-styled-components-outside-of-the-render-method for more info.\n",s=console.error;try{var a=!0;console.error=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];Ap.test(e)?(a=!1,Ip.delete(r)):s.apply(void 0,bh([e],t,!1))},o.useRef(),a&&!Ip.has(r)&&(console.warn(r),Ip.add(r))}catch(e){Ap.test(e.message)&&Ip.delete(r)}finally{console.error=s}}},Sp=Object.freeze([]),Tp=Object.freeze({});var $p=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","track","u","ul","use","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"]),Bp=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,Cp=/(^-|-$)/g;function Op(e){return e.replace(Bp,"-").replace(Cp,"")}var Rp=/(a)(d)/gi,zp=function(e){return String.fromCharCode(e+(e>25?39:97))};function _p(e){var t,n="";for(t=Math.abs(e);t>52;t=t/52|0)n=zp(t%52)+n;return(zp(t%52)+n).replace(Rp,"$1-$2")}var Mp,Fp=function(e,t){for(var n=t.length;n;)e=33*e^t.charCodeAt(--n);return e},jp=function(e){return Fp(5381,e)};function Lp(e){return _p(jp(e)>>>0)}function Up(e){return"production"!==process.env.NODE_ENV&&"string"==typeof e&&e||e.displayName||e.name||"Component"}function Dp(e){return"string"==typeof e&&("production"===process.env.NODE_ENV||e.charAt(0)===e.charAt(0).toLowerCase())}var Gp="function"==typeof Symbol&&Symbol.for,qp=Gp?Symbol.for("react.memo"):60115,Vp=Gp?Symbol.for("react.forward_ref"):60112,Wp={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},Hp={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},Yp={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},Zp=((Mp={})[Vp]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},Mp[qp]=Yp,Mp);function Kp(e){return("type"in(t=e)&&t.type.$$typeof)===qp?Yp:"$$typeof"in e?Zp[e.$$typeof]:Wp;var t}var Jp=Object.defineProperty,Qp=Object.getOwnPropertyNames,Xp=Object.getOwnPropertySymbols,em=Object.getOwnPropertyDescriptor,tm=Object.getPrototypeOf,nm=Object.prototype;function rm(e,t,n){if("string"!=typeof t){if(nm){var r=tm(t);r&&r!==nm&&rm(e,r,n)}var o=Qp(t);Xp&&(o=o.concat(Xp(t)));for(var s=Kp(e),a=Kp(t),i=0;i<o.length;++i){var c=o[i];if(!(c in Hp||n&&n[c]||a&&c in a||s&&c in s)){var u=em(t,c);try{Jp(e,c,u)}catch(e){}}}}return e}function om(e){return"function"==typeof e}function sm(e){return"object"==typeof e&&"styledComponentId"in e}function am(e,t){return e&&t?"".concat(e," ").concat(t):e||t||""}function im(e,t){if(0===e.length)return"";for(var n=e[0],r=1;r<e.length;r++)n+=e[r];return n}function cm(e){return null!==e&&"object"==typeof e&&e.constructor.name===Object.name&&!("props"in e&&e.$$typeof)}function um(e,t,n){if(void 0===n&&(n=!1),!n&&!cm(e)&&!Array.isArray(e))return t;if(Array.isArray(t))for(var r=0;r<t.length;r++)e[r]=um(e[r],t[r]);else if(cm(t))for(var r in t)e[r]=um(e[r],t[r]);return e}function lm(e,t){Object.defineProperty(e,"toString",{value:t})}var dm="production"!==process.env.NODE_ENV?{1:"Cannot create styled-component for component: %s.\n\n",2:"Can't collect styles once you've consumed a `ServerStyleSheet`'s styles! `ServerStyleSheet` is a one off instance for each server-side render cycle.\n\n- Are you trying to reuse it across renders?\n- Are you accidentally calling collectStyles twice?\n\n",3:"Streaming SSR is only supported in a Node.js environment; Please do not try to call this method in the browser.\n\n",4:"The `StyleSheetManager` expects a valid target or sheet prop!\n\n- Does this error occur on the client and is your target falsy?\n- Does this error occur on the server and is the sheet falsy?\n\n",5:"The clone method cannot be used on the client!\n\n- Are you running in a client-like environment on the server?\n- Are you trying to run SSR on the client?\n\n",6:"Trying to insert a new style tag, but the given Node is unmounted!\n\n- Are you using a custom target that isn't mounted?\n- Does your document not have a valid head element?\n- Have you accidentally removed a style tag manually?\n\n",7:'ThemeProvider: Please return an object from your "theme" prop function, e.g.\n\n```js\ntheme={() => ({})}\n```\n\n',8:'ThemeProvider: Please make your "theme" prop an object.\n\n',9:"Missing document `<head>`\n\n",10:"Cannot find a StyleSheet instance. Usually this happens if there are multiple copies of styled-components loaded at once. Check out this issue for how to troubleshoot and fix the common cases where this situation can happen: https://github.com/styled-components/styled-components/issues/1941#issuecomment-417862021\n\n",11:"_This error was replaced with a dev-time warning, it will be deleted for v4 final._ [createGlobalStyle] received children which will not be rendered. Please use the component without passing children elements.\n\n",12:"It seems you are interpolating a keyframe declaration (%s) into an untagged string. This was supported in styled-components v3, but is not longer supported in v4 as keyframes are now injected on-demand. Please wrap your string in the css\\`\\` helper which ensures the styles are injected correctly. See https://www.styled-components.com/docs/api#css\n\n",13:"%s is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.\n\n",14:'ThemeProvider: "theme" prop is required.\n\n',15:"A stylis plugin has been supplied that is not named. We need a name for each plugin to be able to prevent styling collisions between different stylis configurations within the same app. Before you pass your plugin to `<StyleSheetManager stylisPlugins={[]}>`, please make sure each plugin is uniquely-named, e.g.\n\n```js\nObject.defineProperty(importedPlugin, 'name', { value: 'some-unique-name' });\n```\n\n",16:"Reached the limit of how many styled components may be created at group %s.\nYou may only create up to 1,073,741,824 components. If you're creating components dynamically,\nas for instance in your render method then you may be running into this limitation.\n\n",17:"CSSStyleSheet could not be found on HTMLStyleElement.\nHas styled-components' style tag been unmounted or altered by another script?\n",18:"ThemeProvider: Please make sure your useTheme hook is within a `<ThemeProvider>`"}:{};function fm(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n=e[0],r=[],o=1,s=e.length;o<s;o+=1)r.push(e[o]);return r.forEach(function(e){n=n.replace(/%[a-z]/,e)}),n}function hm(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return"production"===process.env.NODE_ENV?new Error("An error occurred. See https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/errors.md#".concat(e," for more information.").concat(t.length>0?" Args: ".concat(t.join(", ")):"")):new Error(fm.apply(void 0,bh([dm[e]],t,!1)).trim())}var pm=function(){function e(e){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=e}return e.prototype.indexOfGroup=function(e){for(var t=0,n=0;n<e;n++)t+=this.groupSizes[n];return t},e.prototype.insertRules=function(e,t){if(e>=this.groupSizes.length){for(var n=this.groupSizes,r=n.length,o=r;e>=o;)if((o<<=1)<0)throw hm(16,"".concat(e));this.groupSizes=new Uint32Array(o),this.groupSizes.set(n),this.length=o;for(var s=r;s<o;s++)this.groupSizes[s]=0}for(var a=this.indexOfGroup(e+1),i=(s=0,t.length);s<i;s++)this.tag.insertRule(a,t[s])&&(this.groupSizes[e]++,a++)},e.prototype.clearGroup=function(e){if(e<this.length){var t=this.groupSizes[e],n=this.indexOfGroup(e),r=n+t;this.groupSizes[e]=0;for(var o=n;o<r;o++)this.tag.deleteRule(n)}},e.prototype.getGroup=function(e){var t="";if(e>=this.length||0===this.groupSizes[e])return t;for(var n=this.groupSizes[e],r=this.indexOfGroup(e),o=r+n,s=r;s<o;s++)t+="".concat(this.tag.getRule(s)).concat(Ep);return t},e}(),mm=1<<30,gm=new Map,bm=new Map,ym=1,wm=function(e){if(gm.has(e))return gm.get(e);for(;bm.has(ym);)ym++;var t=ym++;if("production"!==process.env.NODE_ENV&&((0|t)<0||t>mm))throw hm(16,"".concat(t));return gm.set(e,t),bm.set(t,e),t},vm=function(e,t){ym=t+1,gm.set(e,t),bm.set(t,e)},xm="style[".concat(yp,"][").concat(vp,'="').concat(xp,'"]'),Em=new RegExp("^".concat(yp,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),Pm=function(e,t,n){for(var r,o=n.split(","),s=0,a=o.length;s<a;s++)(r=o[s])&&e.registerName(t,r)},km=function(e,t){for(var n,r=(null!==(n=t.textContent)&&void 0!==n?n:"").split(Ep),o=[],s=0,a=r.length;s<a;s++){var i=r[s].trim();if(i){var c=i.match(Em);if(c){var u=0|parseInt(c[1],10),l=c[2];0!==u&&(vm(l,u),Pm(e,l,c[3]),e.getTag().insertRules(u,o)),o.length=0}else o.push(i)}}},Am=function(e){for(var t=document.querySelectorAll(xm),n=0,r=t.length;n<r;n++){var o=t[n];o&&o.getAttribute(yp)!==wp&&(km(e,o),o.parentNode&&o.parentNode.removeChild(o))}};var Im=function(e){var t=document.head,n=e||t,r=document.createElement("style"),o=function(e){var t=Array.from(e.querySelectorAll("style[".concat(yp,"]")));return t[t.length-1]}(n),s=void 0!==o?o.nextSibling:null;r.setAttribute(yp,wp),r.setAttribute(vp,xp);var a="undefined"!=typeof __webpack_nonce__?__webpack_nonce__:null;return a&&r.setAttribute("nonce",a),n.insertBefore(r,s),r},Nm=function(){function e(e){this.element=Im(e),this.element.appendChild(document.createTextNode("")),this.sheet=function(e){if(e.sheet)return e.sheet;for(var t=document.styleSheets,n=0,r=t.length;n<r;n++){var o=t[n];if(o.ownerNode===e)return o}throw hm(17)}(this.element),this.length=0}return e.prototype.insertRule=function(e,t){try{return this.sheet.insertRule(t,e),this.length++,!0}catch(e){return!1}},e.prototype.deleteRule=function(e){this.sheet.deleteRule(e),this.length--},e.prototype.getRule=function(e){var t=this.sheet.cssRules[e];return t&&t.cssText?t.cssText:""},e}(),Sm=function(){function e(e){this.element=Im(e),this.nodes=this.element.childNodes,this.length=0}return e.prototype.insertRule=function(e,t){if(e<=this.length&&e>=0){var n=document.createTextNode(t);return this.element.insertBefore(n,this.nodes[e]||null),this.length++,!0}return!1},e.prototype.deleteRule=function(e){this.element.removeChild(this.nodes[e]),this.length--},e.prototype.getRule=function(e){return e<this.length?this.nodes[e].textContent:""},e}(),Tm=function(){function e(e){this.rules=[],this.length=0}return e.prototype.insertRule=function(e,t){return e<=this.length&&(this.rules.splice(e,0,t),this.length++,!0)},e.prototype.deleteRule=function(e){this.rules.splice(e,1),this.length--},e.prototype.getRule=function(e){return e<this.length?this.rules[e]:""},e}(),$m=Pp,Bm={isServer:!Pp,useCSSOMInjection:!kp},Cm=function(){function e(e,t,n){void 0===e&&(e=Tp),void 0===t&&(t={});var r=this;this.options=gh(gh({},Bm),e),this.gs=t,this.names=new Map(n),this.server=!!e.isServer,!this.server&&Pp&&$m&&($m=!1,Am(this)),lm(this,function(){return function(e){for(var t=e.getTag(),n=t.length,r="",o=function(n){var o=function(e){return bm.get(e)}(n);if(void 0===o)return"continue";var s=e.names.get(o),a=t.getGroup(n);if(void 0===s||!s.size||0===a.length)return"continue";var i="".concat(yp,".g").concat(n,'[id="').concat(o,'"]'),c="";void 0!==s&&s.forEach(function(e){e.length>0&&(c+="".concat(e,","))}),r+="".concat(a).concat(i,'{content:"').concat(c,'"}').concat(Ep)},s=0;s<n;s++)o(s);return r}(r)})}return e.registerId=function(e){return wm(e)},e.prototype.rehydrate=function(){!this.server&&Pp&&Am(this)},e.prototype.reconstructWithOptions=function(t,n){return void 0===n&&(n=!0),new e(gh(gh({},this.options),t),this.gs,n&&this.names||void 0)},e.prototype.allocateGSInstance=function(e){return this.gs[e]=(this.gs[e]||0)+1},e.prototype.getTag=function(){return this.tag||(this.tag=(e=function(e){var t=e.useCSSOMInjection,n=e.target;return e.isServer?new Tm(n):t?new Nm(n):new Sm(n)}(this.options),new pm(e)));var e},e.prototype.hasNameForId=function(e,t){return this.names.has(e)&&this.names.get(e).has(t)},e.prototype.registerName=function(e,t){if(wm(e),this.names.has(e))this.names.get(e).add(t);else{var n=new Set;n.add(t),this.names.set(e,n)}},e.prototype.insertRules=function(e,t,n){this.registerName(e,t),this.getTag().insertRules(wm(e),n)},e.prototype.clearNames=function(e){this.names.has(e)&&this.names.get(e).clear()},e.prototype.clearRules=function(e){this.getTag().clearGroup(wm(e)),this.clearNames(e)},e.prototype.clearTag=function(){this.tag=void 0},e}(),Om=/&/g,Rm=/^\s*\/\/.*$/gm;function zm(e,t){return e.map(function(e){return"rule"===e.type&&(e.value="".concat(t," ").concat(e.value),e.value=e.value.replaceAll(",",",".concat(t," ")),e.props=e.props.map(function(e){return"".concat(t," ").concat(e)})),Array.isArray(e.children)&&"@keyframes"!==e.type&&(e.children=zm(e.children,t)),e})}var _m=new Cm,Mm=function(){var e,t,n,r=Tp,o=r.options,s=void 0===o?Tp:o,a=r.plugins,i=void 0===a?Sp:a,c=function(n,r,o){return o.startsWith(t)&&o.endsWith(t)&&o.replaceAll(t,"").length>0?".".concat(e):n},u=i.slice();u.push(function(e){e.type===Ah&&e.value.includes("&")&&(e.props[0]=e.props[0].replace(Om,t).replace(n,c))}),s.prefix&&u.push(gp),u.push(mp);var l=function(r,o,a,i){void 0===o&&(o=""),void 0===a&&(a=""),void 0===i&&(i="&"),e=i,t=o,n=new RegExp("\\".concat(t,"\\b"),"g");var c=r.replace(Rm,""),l=cp(a||o?"".concat(a," ").concat(o," { ").concat(c," }"):c);s.namespace&&(l=zm(l,s.namespace));var d,f=[];return pp(l,function(e){var t=Fh(e);return function(n,r,o,s){for(var a="",i=0;i<t;i++)a+=e[i](n,r,o,s)||"";return a}}(u.concat((d=function(e){return f.push(e)},function(e){e.root||(e=e.return)&&d(e)})))),f};return l.hash=i.length?i.reduce(function(e,t){return t.name||hm(15),Fp(e,t.name)},5381).toString():"",l}(),Fm=m.default.createContext({shouldForwardProp:void 0,styleSheet:_m,stylis:Mm});function jm(){return o.useContext(Fm)}Fm.Consumer,m.default.createContext(void 0);var Lm=function(){function e(e,t){var n=this;this.inject=function(e,t){void 0===t&&(t=Mm);var r=n.name+t.hash;e.hasNameForId(n.id,r)||e.insertRules(n.id,r,t(n.rules,r,"@keyframes"))},this.name=e,this.id="sc-keyframes-".concat(e),this.rules=t,lm(this,function(){throw hm(12,String(n.name))})}return e.prototype.getName=function(e){return void 0===e&&(e=Mm),this.name+e.hash},e}(),Um=function(e){return e>="A"&&e<="Z"};function Dm(e){for(var t="",n=0;n<e.length;n++){var r=e[n];if(1===n&&"-"===r&&"-"===e[0])return e;Um(r)?t+="-"+r.toLowerCase():t+=r}return t.startsWith("ms-")?"-"+t:t}var Gm=function(e){return null==e||!1===e||""===e},qm=function(e){var t,n,r=[];for(var o in e){var s=e[o];e.hasOwnProperty(o)&&!Gm(s)&&(Array.isArray(s)&&s.isCss||om(s)?r.push("".concat(Dm(o),":"),s,";"):cm(s)?r.push.apply(r,bh(bh(["".concat(o," {")],qm(s),!1),["}"],!1)):r.push("".concat(Dm(o),": ").concat((t=o,null==(n=s)||"boolean"==typeof n||""===n?"":"number"!=typeof n||0===n||t in bp||t.startsWith("--")?String(n).trim():"".concat(n,"px")),";")))}return r};function Vm(e,t,n,r){if(Gm(e))return[];if(sm(e))return[".".concat(e.styledComponentId)];if(om(e)){if(!om(s=e)||s.prototype&&s.prototype.isReactComponent||!t)return[e];var o=e(t);return"production"===process.env.NODE_ENV||"object"!=typeof o||Array.isArray(o)||o instanceof Lm||cm(o)||null===o||console.error("".concat(Up(e)," is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.")),Vm(o,t,n,r)}var s;return e instanceof Lm?n?(e.inject(n,r),[e.getName(r)]):[e]:cm(e)?qm(e):Array.isArray(e)?Array.prototype.concat.apply(Sp,e.map(function(e){return Vm(e,t,n,r)})):[e.toString()]}var Wm=jp(xp),Hm=function(){function e(e,t,n){this.rules=e,this.staticRulesId="",this.isStatic="production"===process.env.NODE_ENV&&(void 0===n||n.isStatic)&&function(e){for(var t=0;t<e.length;t+=1){var n=e[t];if(om(n)&&!sm(n))return!1}return!0}(e),this.componentId=t,this.baseHash=Fp(Wm,t),this.baseStyle=n,Cm.registerId(t)}return e.prototype.generateAndInjectStyles=function(e,t,n){var r=this.baseStyle?this.baseStyle.generateAndInjectStyles(e,t,n):"";if(this.isStatic&&!n.hash)if(this.staticRulesId&&t.hasNameForId(this.componentId,this.staticRulesId))r=am(r,this.staticRulesId);else{var o=im(Vm(this.rules,e,t,n)),s=_p(Fp(this.baseHash,o)>>>0);if(!t.hasNameForId(this.componentId,s)){var a=n(o,".".concat(s),void 0,this.componentId);t.insertRules(this.componentId,s,a)}r=am(r,s),this.staticRulesId=s}else{for(var i=Fp(this.baseHash,n.hash),c="",u=0;u<this.rules.length;u++){var l=this.rules[u];if("string"==typeof l)c+=l,"production"!==process.env.NODE_ENV&&(i=Fp(i,l));else if(l){var d=im(Vm(l,e,t,n));i=Fp(i,d+u),c+=d}}if(c){var f=_p(i>>>0);t.hasNameForId(this.componentId,f)||t.insertRules(this.componentId,f,n(c,".".concat(f),void 0,this.componentId)),r=am(r,f)}}return r},e}(),Ym=m.default.createContext(void 0);Ym.Consumer;var Zm={},Km=new Set;function Jm(e,t,n){var r=sm(e),s=e,a=!Dp(e),i=t.attrs,c=void 0===i?Sp:i,u=t.componentId,l=void 0===u?function(e,t){var n="string"!=typeof e?"sc":Op(e);Zm[n]=(Zm[n]||0)+1;var r="".concat(n,"-").concat(Lp(xp+n+Zm[n]));return t?"".concat(t,"-").concat(r):r}(t.displayName,t.parentComponentId):u,d=t.displayName,f=void 0===d?function(e){return Dp(e)?"styled.".concat(e):"Styled(".concat(Up(e),")")}(e):d,h=t.displayName&&t.componentId?"".concat(Op(t.displayName),"-").concat(t.componentId):t.componentId||l,p=r&&s.attrs?s.attrs.concat(c).filter(Boolean):c,g=t.shouldForwardProp;if(r&&s.shouldForwardProp){var b=s.shouldForwardProp;if(t.shouldForwardProp){var y=t.shouldForwardProp;g=function(e,t){return b(e,t)&&y(e,t)}}else g=b}var w=new Hm(n,h,r?s.componentStyle:void 0);function v(e,t){return function(e,t,n){var r=e.attrs,s=e.componentStyle,a=e.defaultProps,i=e.foldedComponentIds,c=e.styledComponentId,u=e.target,l=m.default.useContext(Ym),d=jm(),f=e.shouldForwardProp||d.shouldForwardProp;"production"!==process.env.NODE_ENV&&o.useDebugValue(c);var h=function(e,t,n){return void 0===n&&(n=Tp),e.theme!==n.theme&&e.theme||t||n.theme}(t,l,a)||Tp,p=function(e,t,n){for(var r,o=gh(gh({},t),{className:void 0,theme:n}),s=0;s<e.length;s+=1){var a=om(r=e[s])?r(o):r;for(var i in a)o[i]="className"===i?am(o[i],a[i]):"style"===i?gh(gh({},o[i]),a[i]):a[i]}return t.className&&(o.className=am(o.className,t.className)),o}(r,t,h),g=p.as||u,b={};for(var y in p)void 0===p[y]||"$"===y[0]||"as"===y||"theme"===y&&p.theme===h||("forwardedAs"===y?b.as=p.forwardedAs:f&&!f(y,g)||(b[y]=p[y],f||"development"!==process.env.NODE_ENV||vh(y)||Km.has(y)||!$p.has(g)||(Km.add(y),console.warn('styled-components: it looks like an unknown prop "'.concat(y,'" is being sent through to the DOM, which will likely trigger a React console error. If you would like automatic filtering of unknown props, you can opt-into that behavior via `<StyleSheetManager shouldForwardProp={...}>` (connect an API like `@emotion/is-prop-valid`) or consider using transient props (`$` prefix for automatic filtering.)')))));var w=function(e,t){var n=jm(),r=e.generateAndInjectStyles(t,n.styleSheet,n.stylis);return"production"!==process.env.NODE_ENV&&o.useDebugValue(r),r}(s,p);"production"!==process.env.NODE_ENV&&e.warnTooManyClasses&&e.warnTooManyClasses(w);var v=am(i,c);return w&&(v+=" "+w),p.className&&(v+=" "+p.className),b[Dp(g)&&!$p.has(g)?"class":"className"]=v,n&&(b.ref=n),o.createElement(g,b)}(x,e,t)}v.displayName=f;var x=m.default.forwardRef(v);return x.attrs=p,x.componentStyle=w,x.displayName=f,x.shouldForwardProp=g,x.foldedComponentIds=r?am(s.foldedComponentIds,s.styledComponentId):"",x.styledComponentId=h,x.target=r?s.target:e,Object.defineProperty(x,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(e){this._foldedDefaultProps=r?function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];for(var r=0,o=t;r<o.length;r++)um(e,o[r],!0);return e}({},s.defaultProps,e):e}}),"production"!==process.env.NODE_ENV&&(Np(f,h),x.warnTooManyClasses=function(e,t){var n={},r=!1;return function(o){if(!r&&(n[o]=!0,Object.keys(n).length>=200)){var s=t?' with the id of "'.concat(t,'"'):"";console.warn("Over ".concat(200," classes were generated for component ").concat(e).concat(s,".\n")+"Consider using the attrs method, together with a style object for frequently changed styles.\nExample:\n const Component = styled.div.attrs(props => ({\n style: {\n background: props.background,\n },\n }))`width: 100%;`\n\n <Component />"),r=!0,n={}}}}(f,h)),lm(x,function(){return".".concat(x.styledComponentId)}),a&&rm(x,e,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0}),x}function Qm(e,t){for(var n=[e[0]],r=0,o=t.length;r<o;r+=1)n.push(t[r],e[r+1]);return n}var Xm=function(e){return Object.assign(e,{isCss:!0})};function eg(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(om(e)||cm(e))return Xm(Vm(Qm(Sp,bh([e],t,!0))));var r=e;return 0===t.length&&1===r.length&&"string"==typeof r[0]?Vm(r):Xm(Vm(Qm(r,t)))}function tg(e,t,n){if(void 0===n&&(n=Tp),!t)throw hm(1,t);var r=function(r){for(var o=[],s=1;s<arguments.length;s++)o[s-1]=arguments[s];return e(t,n,eg.apply(void 0,bh([r],o,!1)))};return r.attrs=function(r){return tg(e,t,gh(gh({},n),{attrs:Array.prototype.concat(n.attrs,r).filter(Boolean)}))},r.withConfig=function(r){return tg(e,t,gh(gh({},n),r))},r}var ng=function(e){return tg(Jm,e)},rg=ng;$p.forEach(function(e){rg[e]=ng(e)}),"production"!==process.env.NODE_ENV&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product&&console.warn("It looks like you've imported 'styled-components' on React Native.\nPerhaps you're looking to import 'styled-components/native'?\nRead more about this at https://www.styled-components.com/docs/basics#react-native");var og="__sc-".concat(yp,"__");"production"!==process.env.NODE_ENV&&"test"!==process.env.NODE_ENV&&"undefined"!=typeof window&&(window[og]||(window[og]=0),1===window[og]&&console.warn("It looks like there are several instances of 'styled-components' initialized in this application. This may cause dynamic styles to not render properly, errors during the rehydration process, a missing theme prop, and makes your application bigger without good reason.\n\nSee https://s-c.sh/2BAXzed for more info."),window[og]+=1);const sg={colors:{black:"#000000",white:"#FFFFFF",offWhite:"#F5F5F5",grey:{100:"#F7F7F7",200:"#E6E6E6",300:"#D1D1D1",400:"#B0B0B0",500:"#8C8C8C",600:"#696969",700:"#474747",800:"#2B2B2B",900:"#1A1A1A"},primary:"#000000",secondary:"#B0B0B0",error:"#FF4D4D",success:"#4CAF50",background:{main:"#FFFFFF",secondary:"#F5F5F5",overlay:"rgba(0, 0, 0, 0.7)"},text:{primary:"#000000",secondary:"#474747",tertiary:"#8C8C8C",inverse:"#FFFFFF"},button:{primary:{background:"#000000",text:"#FFFFFF",hover:"#2B2B2B",disabled:"#8C8C8C"},secondary:{background:"#F5F5F5",text:"#000000",hover:"#E6E6E6",disabled:"#D1D1D1"}},border:{light:"#E6E6E6",medium:"#D1D1D1",dark:"#8C8C8C"}},typography:{fontFamily:"'Montserrat', 'Arial', sans-serif",fontSizes:{xs:"0.75rem",sm:"0.875rem",md:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem","4xl":"2.25rem"},fontWeights:{light:300,regular:400,medium:500,semibold:600,bold:700}},spacing:{xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem","2xl":"3rem","3xl":"4rem"},borderRadius:{none:"0",sm:"0.125rem",md:"0.25rem",lg:"0.5rem",xl:"0.75rem","2xl":"1rem",full:"9999px"},shadows:{none:"none",sm:"0 1px 2px rgba(0, 0, 0, 0.05)",md:"0 4px 6px rgba(0, 0, 0, 0.05)",lg:"0 10px 15px rgba(0, 0, 0, 0.05)",xl:"0 20px 25px rgba(0, 0, 0, 0.05)"},transitions:{fast:"0.1s ease",normal:"0.2s ease",slow:"0.3s ease"}},ag=(function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];"production"!==process.env.NODE_ENV&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product&&console.warn("`keyframes` cannot be used on ReactNative, only on the web. To do animation in ReactNative please use Animated.");var r=im(eg.apply(void 0,bh([e],t,!1))),o=Lp(r);return new Lm(o,r)})`
|
|
13
13
|
from {
|
|
14
14
|
transform: rotate(0deg);
|
|
15
15
|
}
|
|
16
16
|
to {
|
|
17
17
|
transform: rotate(360deg);
|
|
18
18
|
}
|
|
19
|
-
`,
|
|
19
|
+
`,ig=rg.div`
|
|
20
20
|
position: fixed;
|
|
21
21
|
inset: 0;
|
|
22
|
-
background-color: ${
|
|
22
|
+
background-color: ${sg.colors.background.overlay};
|
|
23
23
|
display: flex;
|
|
24
24
|
align-items: center;
|
|
25
25
|
justify-content: center;
|
|
26
26
|
z-index: 50;
|
|
27
|
-
`,
|
|
28
|
-
background-color: ${
|
|
29
|
-
border-radius: ${
|
|
30
|
-
box-shadow: ${
|
|
31
|
-
padding: ${
|
|
27
|
+
`,cg=rg.div`
|
|
28
|
+
background-color: ${sg.colors.background.main};
|
|
29
|
+
border-radius: ${sg.borderRadius.md};
|
|
30
|
+
box-shadow: ${sg.shadows.xl};
|
|
31
|
+
padding: ${sg.spacing.xl};
|
|
32
32
|
width: 100%;
|
|
33
33
|
max-width: 28rem;
|
|
34
|
-
`,
|
|
34
|
+
`,ug=rg.div`
|
|
35
35
|
display: flex;
|
|
36
36
|
justify-content: space-between;
|
|
37
37
|
align-items: center;
|
|
38
|
-
margin-bottom: ${
|
|
39
|
-
`,
|
|
40
|
-
font-size: ${
|
|
41
|
-
font-weight: ${
|
|
42
|
-
color: ${
|
|
38
|
+
margin-bottom: ${sg.spacing.lg};
|
|
39
|
+
`,lg=rg.h2`
|
|
40
|
+
font-size: ${sg.typography.fontSizes["2xl"]};
|
|
41
|
+
font-weight: ${sg.typography.fontWeights.bold};
|
|
42
|
+
color: ${sg.colors.text.primary};
|
|
43
43
|
text-transform: uppercase;
|
|
44
44
|
letter-spacing: 1px;
|
|
45
45
|
margin: 0;
|
|
46
|
-
`,
|
|
46
|
+
`,dg=rg.button`
|
|
47
47
|
background: none;
|
|
48
48
|
border: none;
|
|
49
|
-
color: ${
|
|
49
|
+
color: ${sg.colors.text.tertiary};
|
|
50
50
|
cursor: pointer;
|
|
51
51
|
|
|
52
52
|
&:hover {
|
|
53
|
-
color: ${
|
|
53
|
+
color: ${sg.colors.text.primary};
|
|
54
54
|
}
|
|
55
|
-
`,
|
|
55
|
+
`,fg=rg.svg`
|
|
56
56
|
width: 1.5rem;
|
|
57
57
|
height: 1.5rem;
|
|
58
|
-
`,
|
|
58
|
+
`,hg=rg.div`
|
|
59
59
|
display: flex;
|
|
60
60
|
flex-direction: column;
|
|
61
61
|
align-items: center;
|
|
62
62
|
justify-content: center;
|
|
63
|
-
gap: ${
|
|
64
|
-
padding: ${
|
|
65
|
-
`,
|
|
66
|
-
animation: ${
|
|
63
|
+
gap: ${sg.spacing.lg};
|
|
64
|
+
padding: ${sg.spacing.xl} 0;
|
|
65
|
+
`,pg=rg.div`
|
|
66
|
+
animation: ${ag} 1s linear infinite;
|
|
67
67
|
display: flex;
|
|
68
68
|
align-items: center;
|
|
69
69
|
justify-content: center;
|
|
@@ -72,106 +72,106 @@ const Ll=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff
|
|
|
72
72
|
width: 2rem;
|
|
73
73
|
height: 2rem;
|
|
74
74
|
}
|
|
75
|
-
`,
|
|
76
|
-
font-size: ${
|
|
77
|
-
color: ${
|
|
75
|
+
`,mg=rg.p`
|
|
76
|
+
font-size: ${sg.typography.fontSizes.md};
|
|
77
|
+
color: ${sg.colors.text.secondary};
|
|
78
78
|
text-align: center;
|
|
79
|
-
`,
|
|
79
|
+
`,gg=rg.div`
|
|
80
80
|
display: flex;
|
|
81
81
|
flex-direction: column;
|
|
82
|
-
gap: ${
|
|
83
|
-
`,
|
|
82
|
+
gap: ${sg.spacing.md};
|
|
83
|
+
`,bg=rg.input.attrs({className:"superstack-wallet-input"})`
|
|
84
84
|
width: 100%;
|
|
85
|
-
padding: ${
|
|
86
|
-
border: 1px solid ${
|
|
87
|
-
border-radius: ${
|
|
88
|
-
font-size: ${
|
|
89
|
-
font-family: ${
|
|
90
|
-
transition: border-color ${
|
|
91
|
-
color: ${
|
|
92
|
-
background-color: ${
|
|
93
|
-
margin-bottom: ${
|
|
85
|
+
padding: ${sg.spacing.md};
|
|
86
|
+
border: 1px solid ${sg.colors.border.light};
|
|
87
|
+
border-radius: ${sg.borderRadius.sm};
|
|
88
|
+
font-size: ${sg.typography.fontSizes.md};
|
|
89
|
+
font-family: ${sg.typography.fontFamily};
|
|
90
|
+
transition: border-color ${sg.transitions.normal};
|
|
91
|
+
color: ${sg.colors.text.primary};
|
|
92
|
+
background-color: ${sg.colors.background.main};
|
|
93
|
+
margin-bottom: ${sg.spacing.md};
|
|
94
94
|
|
|
95
95
|
&:focus {
|
|
96
96
|
outline: none;
|
|
97
|
-
border-color: ${
|
|
97
|
+
border-color: ${sg.colors.border.dark};
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
&:disabled {
|
|
101
|
-
background-color: ${
|
|
101
|
+
background-color: ${sg.colors.background.secondary};
|
|
102
102
|
cursor: not-allowed;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
&::placeholder {
|
|
106
|
-
color: ${
|
|
106
|
+
color: ${sg.colors.text.tertiary};
|
|
107
107
|
opacity: 0.8;
|
|
108
108
|
}
|
|
109
|
-
`,
|
|
109
|
+
`,yg=rg.button`
|
|
110
110
|
width: 100%;
|
|
111
|
-
padding: ${
|
|
112
|
-
background-color: ${
|
|
113
|
-
color: ${
|
|
114
|
-
border-radius: ${
|
|
115
|
-
font-weight: ${
|
|
111
|
+
padding: ${sg.spacing.md};
|
|
112
|
+
background-color: ${sg.colors.button.primary.background};
|
|
113
|
+
color: ${sg.colors.button.primary.text};
|
|
114
|
+
border-radius: ${sg.borderRadius.sm};
|
|
115
|
+
font-weight: ${sg.typography.fontWeights.medium};
|
|
116
116
|
text-transform: uppercase;
|
|
117
117
|
letter-spacing: 1px;
|
|
118
|
-
transition: background-color ${
|
|
119
|
-
font-size: ${
|
|
118
|
+
transition: background-color ${sg.transitions.normal};
|
|
119
|
+
font-size: ${sg.typography.fontSizes.md};
|
|
120
120
|
border: none;
|
|
121
121
|
cursor: pointer;
|
|
122
122
|
|
|
123
123
|
&:hover {
|
|
124
|
-
background-color: ${
|
|
124
|
+
background-color: ${sg.colors.button.primary.hover};
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
&:disabled {
|
|
128
|
-
background-color: ${
|
|
128
|
+
background-color: ${sg.colors.button.primary.disabled};
|
|
129
129
|
cursor: not-allowed;
|
|
130
130
|
}
|
|
131
|
-
`,
|
|
131
|
+
`,wg=rg.div`
|
|
132
132
|
display: flex;
|
|
133
133
|
align-items: center;
|
|
134
|
-
margin: ${
|
|
135
|
-
`,
|
|
134
|
+
margin: ${sg.spacing.lg} 0;
|
|
135
|
+
`,vg=rg.div`
|
|
136
136
|
flex-grow: 1;
|
|
137
137
|
height: 1px;
|
|
138
|
-
background-color: ${
|
|
139
|
-
`,
|
|
140
|
-
padding: 0 ${
|
|
141
|
-
font-size: ${
|
|
142
|
-
color: ${
|
|
138
|
+
background-color: ${sg.colors.border.light};
|
|
139
|
+
`,xg=rg.span`
|
|
140
|
+
padding: 0 ${sg.spacing.md};
|
|
141
|
+
font-size: ${sg.typography.fontSizes.sm};
|
|
142
|
+
color: ${sg.colors.text.tertiary};
|
|
143
143
|
text-transform: uppercase;
|
|
144
144
|
letter-spacing: 0.5px;
|
|
145
|
-
`;
|
|
145
|
+
`;rg.div`
|
|
146
146
|
height: 1px;
|
|
147
|
-
background-color: ${
|
|
147
|
+
background-color: ${sg.colors.border.light};
|
|
148
148
|
width: 100%;
|
|
149
|
-
margin: ${
|
|
150
|
-
`;const
|
|
149
|
+
margin: ${sg.spacing.lg} 0;
|
|
150
|
+
`;const Eg=rg.div`
|
|
151
151
|
display: flex;
|
|
152
152
|
align-items: center;
|
|
153
153
|
/* grid-template-columns: repeat(2, 1fr); */
|
|
154
|
-
gap: ${
|
|
155
|
-
`,
|
|
154
|
+
gap: ${sg.spacing.md};
|
|
155
|
+
`,Pg=rg.button`
|
|
156
156
|
display: flex;
|
|
157
157
|
align-items: center;
|
|
158
158
|
justify-content: center;
|
|
159
|
-
padding: ${
|
|
160
|
-
border: 1px solid ${
|
|
161
|
-
border-radius: ${
|
|
162
|
-
background-color: ${
|
|
163
|
-
transition: background-color ${
|
|
164
|
-
color: ${
|
|
165
|
-
font-weight: ${
|
|
166
|
-
font-size: ${
|
|
159
|
+
padding: ${sg.spacing.md};
|
|
160
|
+
border: 1px solid ${sg.colors.border.light};
|
|
161
|
+
border-radius: ${sg.borderRadius.sm};
|
|
162
|
+
background-color: ${sg.colors.background.main};
|
|
163
|
+
transition: background-color ${sg.transitions.normal};
|
|
164
|
+
color: ${sg.colors.text.primary};
|
|
165
|
+
font-weight: ${sg.typography.fontWeights.medium};
|
|
166
|
+
font-size: ${sg.typography.fontSizes.md};
|
|
167
167
|
min-width: 120px;
|
|
168
168
|
flex: 1;
|
|
169
169
|
|
|
170
170
|
&:hover {
|
|
171
|
-
background-color: ${
|
|
171
|
+
background-color: ${sg.colors.background.secondary};
|
|
172
172
|
}
|
|
173
|
-
`,
|
|
174
|
-
margin-right: ${
|
|
173
|
+
`,kg=rg.div`
|
|
174
|
+
margin-right: ${sg.spacing.sm};
|
|
175
175
|
display: flex;
|
|
176
176
|
align-items: center;
|
|
177
177
|
justify-content: center;
|
|
@@ -181,24 +181,24 @@ const Ll=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff
|
|
|
181
181
|
height: 20px;
|
|
182
182
|
display: block;
|
|
183
183
|
}
|
|
184
|
-
`,
|
|
184
|
+
`,Ag=rg.div`
|
|
185
185
|
display: flex;
|
|
186
186
|
flex-direction: column;
|
|
187
|
-
gap: ${
|
|
188
|
-
`,
|
|
189
|
-
font-size: ${
|
|
190
|
-
font-weight: ${
|
|
191
|
-
color: ${
|
|
192
|
-
margin-bottom: ${
|
|
193
|
-
`,
|
|
194
|
-
font-size: ${
|
|
195
|
-
color: ${
|
|
196
|
-
margin-bottom: ${
|
|
197
|
-
`,
|
|
187
|
+
gap: ${sg.spacing.lg};
|
|
188
|
+
`,Ig=rg.h3`
|
|
189
|
+
font-size: ${sg.typography.fontSizes.xl};
|
|
190
|
+
font-weight: ${sg.typography.fontWeights.semibold};
|
|
191
|
+
color: ${sg.colors.text.primary};
|
|
192
|
+
margin-bottom: ${sg.spacing.sm};
|
|
193
|
+
`,Ng=rg.p`
|
|
194
|
+
font-size: ${sg.typography.fontSizes.md};
|
|
195
|
+
color: ${sg.colors.text.secondary};
|
|
196
|
+
margin-bottom: ${sg.spacing.lg};
|
|
197
|
+
`,Sg=rg.div`
|
|
198
198
|
display: flex;
|
|
199
|
-
gap: ${
|
|
199
|
+
gap: ${sg.spacing.sm};
|
|
200
200
|
justify-content: center;
|
|
201
|
-
margin-bottom: ${
|
|
201
|
+
margin-bottom: ${sg.spacing.lg};
|
|
202
202
|
position: relative;
|
|
203
203
|
|
|
204
204
|
&::after {
|
|
@@ -208,30 +208,30 @@ const Ll=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff
|
|
|
208
208
|
left: 0;
|
|
209
209
|
width: 100%;
|
|
210
210
|
text-align: center;
|
|
211
|
-
font-size: ${
|
|
212
|
-
color: ${
|
|
211
|
+
font-size: ${sg.typography.fontSizes.xs};
|
|
212
|
+
color: ${sg.colors.text.tertiary};
|
|
213
213
|
}
|
|
214
214
|
|
|
215
215
|
/* Show a tooltip on hover to inform users they can paste the code */
|
|
216
216
|
&:hover::after {
|
|
217
217
|
content: "Tip: You can paste your full verification code";
|
|
218
218
|
}
|
|
219
|
-
`,
|
|
219
|
+
`,Tg=rg.div`
|
|
220
220
|
position: relative;
|
|
221
221
|
width: 2.5rem;
|
|
222
222
|
height: 2.5rem;
|
|
223
223
|
display: flex;
|
|
224
224
|
align-items: center;
|
|
225
225
|
justify-content: center;
|
|
226
|
-
|
|
226
|
+
`,$g=rg.input`
|
|
227
227
|
width: 100%;
|
|
228
228
|
height: 100%;
|
|
229
229
|
text-align: center;
|
|
230
|
-
font-size: ${
|
|
231
|
-
border: 1px solid ${
|
|
232
|
-
border-radius: ${
|
|
233
|
-
transition: all ${
|
|
234
|
-
font-family: ${
|
|
230
|
+
font-size: ${sg.typography.fontSizes.xl};
|
|
231
|
+
border: 1px solid ${sg.colors.border.light};
|
|
232
|
+
border-radius: ${sg.borderRadius.sm};
|
|
233
|
+
transition: all ${sg.transitions.normal};
|
|
234
|
+
font-family: ${sg.typography.fontFamily};
|
|
235
235
|
padding: 0;
|
|
236
236
|
box-sizing: border-box;
|
|
237
237
|
|
|
@@ -252,46 +252,46 @@ const Ll=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff
|
|
|
252
252
|
/* Remove default box-shadow on iOS */
|
|
253
253
|
&:focus {
|
|
254
254
|
outline: none;
|
|
255
|
-
border-color: ${
|
|
256
|
-
box-shadow: 0 0 0 1px ${
|
|
255
|
+
border-color: ${sg.colors.border.dark};
|
|
256
|
+
box-shadow: 0 0 0 1px ${sg.colors.border.dark};
|
|
257
257
|
}
|
|
258
258
|
|
|
259
259
|
/* Disable default iOS zoom on focus */
|
|
260
260
|
@media screen and (max-width: 768px) {
|
|
261
261
|
font-size: 16px;
|
|
262
262
|
}
|
|
263
|
-
|
|
263
|
+
`,Bg=rg.button`
|
|
264
264
|
background: none;
|
|
265
265
|
border: none;
|
|
266
|
-
color: ${
|
|
267
|
-
font-size: ${
|
|
266
|
+
color: ${sg.colors.text.secondary};
|
|
267
|
+
font-size: ${sg.typography.fontSizes.sm};
|
|
268
268
|
text-align: center;
|
|
269
|
-
margin-top: ${
|
|
270
|
-
margin-bottom: ${
|
|
271
|
-
padding: ${
|
|
269
|
+
margin-top: ${sg.spacing.md};
|
|
270
|
+
margin-bottom: ${sg.spacing.sm};
|
|
271
|
+
padding: ${sg.spacing.sm} ${sg.spacing.md};
|
|
272
272
|
text-transform: uppercase;
|
|
273
273
|
letter-spacing: 0.5px;
|
|
274
274
|
width: 100%;
|
|
275
275
|
cursor: pointer;
|
|
276
|
-
transition: color ${
|
|
276
|
+
transition: color ${sg.transitions.normal};
|
|
277
277
|
display: flex;
|
|
278
278
|
align-items: center;
|
|
279
279
|
justify-content: center;
|
|
280
280
|
|
|
281
281
|
&:hover {
|
|
282
|
-
color: ${
|
|
282
|
+
color: ${sg.colors.text.primary};
|
|
283
283
|
text-decoration: underline;
|
|
284
284
|
}
|
|
285
285
|
|
|
286
286
|
&:before {
|
|
287
287
|
content: "←";
|
|
288
|
-
margin-right: ${
|
|
289
|
-
font-size: ${
|
|
288
|
+
margin-right: ${sg.spacing.sm};
|
|
289
|
+
font-size: ${sg.typography.fontSizes.md};
|
|
290
290
|
}
|
|
291
|
-
`,
|
|
292
|
-
font-size: ${
|
|
293
|
-
color: ${
|
|
291
|
+
`,Cg=rg.p`
|
|
292
|
+
font-size: ${sg.typography.fontSizes.sm};
|
|
293
|
+
color: ${sg.colors.text.tertiary};
|
|
294
294
|
text-align: center;
|
|
295
|
-
margin-top: ${
|
|
296
|
-
`;async function Cg(e){const t=e.toLowerCase(),n=r.v4(),o=await async function(e){const t=new TextEncoder,n=t.encode(e),r=await crypto.subtle.digest("SHA-256",n),o=Array.from(new Uint8Array(r));return btoa(String.fromCharCode(...o)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}(n);return sessionStorage.setItem(`${t}_oauthCodeVerifier`,JSON.stringify({code_verifier:n,code_challenge:o,timestamp:Date.now()})),{codeVerifier:n,codeChallenge:o}}const Og=()=>{if("undefined"!=typeof document&&document.getElementById("superstack-wallet-styles"))return;if("undefined"==typeof document)return;const e=document.createElement("link");e.id="superstack-wallet-fonts",e.rel="stylesheet",e.href="https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700&display=swap",document.head.appendChild(e);const t=document.createElement("style");t.id="superstack-wallet-styles",t.textContent=`\n /* 只影响嵌入钱包模态框 */\n #embedded-wallet-modal {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 9999;\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: rgba(0, 0, 0, 0.5);\n }\n \n /* 以下类选择器都只对SDK自己的元素生效 */\n .superstack-wallet-container {\n font-family: 'Montserrat', sans-serif;\n color: ${og.colors.text.primary};\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n }\n \n /* 直接选择SDK组件,而不是使用通配符 */\n .superstack-wallet-container h1,\n .superstack-wallet-container h2,\n .superstack-wallet-container h3,\n .superstack-wallet-container h4,\n .superstack-wallet-container h5,\n .superstack-wallet-container h6 {\n font-family: 'Montserrat', sans-serif;\n font-weight: ${og.typography.fontWeights.semibold};\n line-height: 1.2;\n margin-bottom: ${og.spacing.md};\n }\n \n .superstack-wallet-container p {\n font-family: 'Montserrat', sans-serif;\n margin-bottom: ${og.spacing.md};\n }\n \n /* 为SDK定义的按钮添加类名 */\n .superstack-wallet-btn {\n font-family: 'Montserrat', sans-serif;\n cursor: pointer;\n }\n \n /* 为SDK定义的输入域添加类名 */\n .superstack-wallet-input {\n font-family: 'Montserrat', sans-serif;\n }\n \n /* 模态内容应该有自己的样式,不影响外部 */\n #embedded-wallet-modal .modal-content {\n background-color: ${og.colors.background.main};\n border-radius: ${og.borderRadius.md};\n padding: ${og.spacing.lg};\n box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);\n max-width: 480px;\n width: 100%;\n }\n `,document.head.appendChild(t)};var Rg=Object.freeze({__proto__:null,injectStyles:Og,theme:og});function zg({client:e,isOpen:t,onClose:n,onLogin:s,isLoading:a=!1}){const[i,c]=o.useState(""),[u,l]=o.useState(""),[d,f]=o.useState(!1),[h,p]=o.useState(!1),[m,b]=o.useState(["","","","","",""]),[y,w]=o.useState(!1),[v,x]=o.useState(!1),[E,P]=o.useState(!1),k=o.useMemo(()=>Array(6).fill(null).map(()=>o.createRef()),[]),A=e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e),I=e=>/^\+[1-9]\d{1,3}\d{6,14}$/.test(e);return o.useEffect(()=>{m.forEach((e,t)=>{if(k[t]&&k[t].current){const n=k[t].current;n&&e&&(n.style.fontSize=og.typography.fontSizes.xl)}})},[m,k]),{email:i,setEmail:c,emailSent:h,setEmailSent:p,sendingCode:y,setVerificationCode:b,verificationCode:m,verifyingCode:v,connectingPhantom:E,inputRefs:k,handleCodeChange:(e,t)=>{var n,r,o;if(t.length<=1){const r=[...m];r[e]=t,b(r),t&&e<5&&(null===(n=k[e+1].current)||void 0===n||n.focus())}else if(t.length>1){const e=t.replace(/\D/g,"").slice(0,6).split(""),n=[...Array(6).fill("")];e.forEach((e,t)=>{t<6&&(n[t]=e)}),b(n);const s=n.findIndex(e=>""===e);-1!==s?null===(r=k[s].current)||void 0===r||r.focus():n[5]&&(null===(o=k[5].current)||void 0===o||o.focus())}},handleKeyDown:(e,t)=>{var n;"Backspace"===t.key&&!m[e]&&e>0&&(null===(n=k[e-1].current)||void 0===n||n.focus())},handleContainerPaste:e=>{var t,n;e.preventDefault();const r=e.clipboardData.getData("text").replace(/\D/g,"").slice(0,6).split(""),o=[...Array(6).fill("")];r.forEach((e,t)=>{t<6&&(o[t]=e)}),b(o);const s=o.findIndex(e=>""===e);-1!==s?null===(t=k[s].current)||void 0===t||t.focus():o[5]&&(null===(n=k[5].current)||void 0===n||n.focus())},handleSendVerificationCode:async(t=i)=>{try{if(!A(t))return void alert("Please enter a valid email address");w(!0),await e.sendEmailVerificationCode(t),p(!0)}catch(e){alert("Failed to send verification code"),console.error("Failed to send verification code",e)}finally{w(!1)}},handleCodeSubmit:async(t=m.join(""),r=i)=>{try{if(6!==t.length)return void alert("Please enter a valid verification code");x(!0);const o=await e.verifyEmailVerificationCode({email:r,code:t});o&&(null==s||s(o),null==n||n())}catch(e){alert("Failed to verify code"),console.error("Failed to verify code",e)}finally{x(!1)}},handlePhoneCodeSubmit:async(t=m.join(""),r=u)=>{try{if(6!==t.length)return void alert("Please enter a valid verification code");x(!0);const o=await e.verifyPhoneVerificationCode({phone:r,code:t});o&&(null==s||s(o),null==n||n())}catch(e){alert("Failed to verify code"),console.error("Failed to verify code",e)}finally{x(!1)}},handleSendPhoneVerificationCode:async(t=u)=>{try{if(!I(t))return void alert("Please enter a valid phone number");await e.sendPhoneVerificationCode(t),f(!0)}catch(e){alert("Failed to send verification code"),console.error("Failed to send verification code",e)}finally{w(!1)}},handleGetChallenge:async(t,n)=>await e.getSignChallenge({method:null!=n?n:"phantom",id:t}),handleLoginWithChallenge:async(t,r)=>{try{const o=await e.loginWithChallenge(t,r);o&&(null==s||s(o),null==n||n())}catch(e){alert("Failed to login with challenge"),console.error("Failed to login with challenge",e)}finally{x(!1)}},phone:u,setPhone:l,phoneSent:d,setPhoneSent:f,onOauthLogin:async t=>{const n=function(e){const t=e.toLowerCase(),n=r.v4();return sessionStorage.setItem(`${t}_oauthState`,JSON.stringify({state:n,timestamp:Date.now()})),n}(t),{codeVerifier:o,codeChallenge:s}=await Cg(t),a=new URL(window.location.href);a.searchParams.forEach((e,t)=>{a.searchParams.delete(t)});const i=a.toString(),c=await e.oauthInit({provider:t,redirect_uri:i,state:n,code_challenge:s}),{url:u,client_id:l}=c;if(!u&&!l)throw console.error("OAuth init failed."),new Error("init failed");const d={client_id:l,redirect_uri:u,state:n,code_challenge:s},f="google"===t?await async function(e){const t={response_type:"code",client_id:e.client_id,redirect_uri:e.redirect_uri,scope:["openid","email","profile"].join("%20"),code_challenge:e.code_challenge,code_challenge_method:"S256",state:e.state};return`https://accounts.google.com/o/oauth2/v2/auth?${g.stringify(t,{encode:!1})}`}(d):await async function(e){const t={response_type:"code",client_id:e.client_id,redirect_uri:e.redirect_uri,scope:["tweet.read","users.read"].join("%20"),code_challenge:e.code_challenge,code_challenge_method:"S256",state:e.state};return`https://twitter.com/i/oauth2/authorize?${g.stringify(t,{encode:!1})}`}(d);window.location.href=f},handlePhantomLogin:async()=>{try{P(!0);const t=await e.connectPhantom();t&&(null==s||s(t),null==n||n())}catch(e){console.error("Phantom login error:",e),alert("Failed to connect to Phantom wallet. Please make sure you have the Phantom extension installed.")}finally{P(!1)}},isOpen:t,onClose:n,onLogin:s,isLoading:a}}const _g=({client:e,isOpen:t,onClose:n,onLogin:r,isLoading:o=!1,enableEmail:a=!0,enablePhone:i=!1,enableGoogle:c=!0,enableTwitter:u=!1,enablePhantom:l=!0})=>{const{email:d,setEmail:f,emailSent:h,sendingCode:p,setEmailSent:g,verifyingCode:b,verificationCode:y,connectingPhantom:w,inputRefs:v,handleCodeChange:x,handleKeyDown:E,handleContainerPaste:P,handleSendVerificationCode:k,handleCodeSubmit:A,onOauthLogin:I,handlePhantomLogin:N}=zg({client:e,isOpen:t,onClose:n,onLogin:r,isLoading:o});return t?m.default.createElement(ag,null,m.default.createElement(ig,null,m.default.createElement(cg,null,m.default.createElement(ug,null,"Connect Wallet"),m.default.createElement(lg,{onClick:n},m.default.createElement(dg,{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},m.default.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})))),o?m.default.createElement(fg,null,m.default.createElement(hg,null,m.default.createElement(s.Loader2,{size:24})),m.default.createElement(pg,null,"Loading...")):m.default.createElement(m.default.Fragment,null,h?m.default.createElement(kg,null,m.default.createElement("div",null,m.default.createElement(Ag,null,"Enter Verification Code"),m.default.createElement(Ig,null,"We sent a verification code to ",d)),m.default.createElement(Ng,{onPaste:P},y.map((e,t)=>m.default.createElement(Sg,{key:t},m.default.createElement(Tg,{ref:v[t],type:"text",maxLength:1,value:e,onChange:e=>x(t,e.target.value),onKeyDown:e=>E(t,e),onPaste:e=>{0!==t&&(e.preventDefault(),P(e))}})))),m.default.createElement(bg,{onClick:()=>A(),disabled:6!==y.join("").length||b},b?"Verifying...":"Verify Code"),m.default.createElement($g,{onClick:()=>g(!1)},"Back to Email")):m.default.createElement(mg,null,a&&m.default.createElement(mg,null,m.default.createElement(gg,{type:"email",value:d,onChange:e=>f(e.target.value),placeholder:"Enter your email",disabled:p}),m.default.createElement(bg,{onClick:()=>k(),disabled:!d||p},p?"Sending...":"Send Verification Code")),(c||u||l)&&a&&m.default.createElement(yg,null,m.default.createElement(wg,null),m.default.createElement(vg,null,"Or continue with"),m.default.createElement(wg,null)),(c||u||l)&&m.default.createElement(m.default.Fragment,null,m.default.createElement(xg,null,c&&m.default.createElement(Eg,{onClick:()=>I("google")},m.default.createElement(Pg,null,m.default.createElement("img",{src:"https://cdn.jsdelivr.net/gh/devicons/devicon/icons/google/google-original.svg",alt:"Google",width:20,height:20})),"Google"),u&&m.default.createElement(Eg,{onClick:()=>I("twitter")},m.default.createElement(Pg,null,m.default.createElement("img",{src:"https://cdn.jsdelivr.net/gh/devicons/devicon/icons/twitter/twitter-original.svg",alt:"Twitter",width:20,height:20})),"X")),l&&m.default.createElement(Eg,{onClick:N,disabled:w},m.default.createElement(Pg,null,m.default.createElement("img",{src:"https://explorer-api.walletconnect.com/v3/logo/md/b6ec7b81-bb4f-427d-e290-7631e6e50d00?projectId=34357d3c125c2bcf2ce2bc3309d98715",alt:"Phantom",width:20,height:20})),w?"Connecting...":"Phantom")),!a&&!i&&!c&&!u&&!l&&m.default.createElement("div",{style:{textAlign:"center",padding:"20px",color:"#666"}},"No login methods are currently enabled."))),m.default.createElement(Bg,null,"By connecting your wallet, you agree to our Terms of Service and Privacy Policy"))):null};class Mg{constructor(){this.container=null,this.root=null}createContainer(){if("undefined"==typeof document)return null;this.removeExistingContainer();const e=document.createElement("div");return e.id="embedded-wallet-modal",document.body.appendChild(e),e}removeExistingContainer(){if("undefined"==typeof document)return;const e=document.getElementById("embedded-wallet-modal");e&&e.parentNode&&e.parentNode.removeChild(e)}showLoginModal({client:e,isLoading:t=!1,onClose:n,onLogin:r,enableEmail:o=!0,enablePhone:s=!1,enableGoogle:a=!0,enableTwitter:i=!1,enablePhantom:c=!0}){return new Promise((u,l)=>{try{if("undefined"==typeof window)return void u();import("react-dom/client").then(({createRoot:l})=>{if(this.container=this.createContainer(),!this.container)return void u();this.root=l(this.container);const d=()=>{this.hideModal(),null==n||n()},f=e=>{this.hideModal(),null==r||r(e)};this.root&&this.root.render(m.default.createElement(_g,{client:e,isOpen:!0,onClose:d,isLoading:t,onLogin:f,enableEmail:o,enablePhone:s,enableGoogle:a,enableTwitter:i,enablePhantom:c})),u()}).catch(e=>{console.error("Error importing createRoot:",e),l(e)})}catch(e){console.error("Error showing modal:",e),l(e)}})}hideModal(){this.root&&(this.root.unmount(),this.container&&this.container.parentNode&&(document.body.removeChild(this.container),this.container=null))}}const Fg={isAuthenticated:!1,isConnecting:!1,isInitialized:!1,walletInfo:null,wallet:null,session:null,error:null,enableEmail:!0,enablePhone:!1,enableGoogle:!0,enableTwitter:!1,enablePhantom:!0},jg=o.createContext({});function Lg(e,t){switch(t.type){case"SET_CONNECTING":return{...e,isConnecting:t.payload};case"SET_INITIALIZED":return{...e,isInitialized:t.payload};case"SET_SESSION":return{...e,isAuthenticated:!0,session:t.payload,error:null};case"SET_WALLET_INFO":return{...e,walletInfo:t.payload};case"SET_WALLET":return{...e,wallet:t.payload};case"SET_ERROR":return{...e,error:t.payload};case"RESET":return{...Fg,isInitialized:!0};default:return e}}function Ug(){const e=o.useContext(jg);if(!e)throw new Error("useWallet must be used within a WalletProvider");return e}"undefined"!=typeof window&&Promise.resolve().then(function(){return Rg}).then(({injectStyles:e})=>{e()}),exports.ACCESS_TOKEN_KEY=v,exports.STORAGE_STATE_KEY=y,exports.Storage=x,exports.WALLET_TYPE_KEY=w,exports.WalletClient=ph,exports.WalletProvider=function({children:e,config:t}){var n,r,s,a,i,c;const u=o.useRef(null);u.current||(u.current=new ph(t));const l=u.current,d=o.useRef(null!==(n=t.modalManager)&&void 0!==n?n:null),[f,h]=o.useReducer(Lg,{...Fg,enableEmail:null===(r=t.enableEmail)||void 0===r||r,enablePhone:null!==(s=t.enablePhone)&&void 0!==s&&s,enableGoogle:null===(a=t.enableGoogle)||void 0===a||a,enableTwitter:null!==(i=t.enableTwitter)&&void 0!==i&&i,enablePhantom:null===(c=t.enablePhantom)||void 0===c||c}),{walletInfo:p}=f,g=o.useRef(!1),b=o.useCallback(()=>(d.current||"undefined"==typeof window||(d.current=new Mg),d.current),[]);o.useEffect(()=>{t.modalManager&&(d.current=t.modalManager)},[t.modalManager]),o.useEffect(()=>{!async function(){if(!(p||g.current||f.isInitialized)){g.current=!0;try{const e=await l.reconnect();e&&(h({type:"SET_WALLET_INFO",payload:e}),h({type:"SET_WALLET",payload:l}))}catch(e){console.error("Auto reconnect failed:",e)}finally{h({type:"SET_INITIALIZED",payload:!0})}}}()},[l]),o.useEffect(()=>{const e=async()=>{try{if(v.isConnecting)return;h({type:"SET_CONNECTING",payload:!0});const e=new URLSearchParams(window.location.search),t=e.get("wallet_oauth_provider"),n=e.get("wallet_oauth_state"),r=e.get("wallet_oauth_code");if(t&&n&&r){const e=function(e){const t=e.toLowerCase(),n=sessionStorage.getItem(`${t}_oauthCodeVerifier`);if(!n)return null;const r=JSON.parse(n);return sessionStorage.removeItem(`${t}_oauthCodeVerifier`),Date.now()-r.timestamp>6e5?null:{codeVerifier:r.code_verifier,codeChallenge:r.code_challenge}}(t);if(!e)throw new Error("No code verifier found");const{codeVerifier:o,codeChallenge:s}=e;let a;if("twitter"===t)a="TwitterOAuth";else{if("google"!==t)throw new Error("Unsupported provider");a="GoogleOAuth"}b().showLoginModal({client:l,isLoading:!0,enableEmail:f.enableEmail,enablePhone:f.enablePhone,enableGoogle:f.enableGoogle,enableTwitter:f.enableTwitter,enablePhantom:f.enablePhantom});const i=await l.oauthLogin(a,{state:n,code:r,code_verifier:o});if(i){h({type:"SET_WALLET_INFO",payload:i}),h({type:"SET_WALLET",payload:l});const e=new URL(window.location.href);e.searchParams.delete("wallet_oauth_provider"),e.searchParams.delete("wallet_oauth_state"),e.searchParams.delete("wallet_oauth_code"),history.replaceState(null,"",e.toString())}}}catch(e){console.log("oauth login error: ",e)}finally{h({type:"SET_CONNECTING",payload:!1}),await b().hideModal()}};return e(),window.addEventListener("popstate",e),()=>{window.removeEventListener("popstate",e)}},[]);const y=o.useCallback(async()=>{try{h({type:"SET_CONNECTING",payload:!0});b().showLoginModal({client:l,enableEmail:f.enableEmail,enablePhone:f.enablePhone,enableGoogle:f.enableGoogle,enableTwitter:f.enableTwitter,enablePhantom:f.enablePhantom,onClose:()=>{h({type:"SET_CONNECTING",payload:!1})},onLogin:e=>{h({type:"SET_CONNECTING",payload:!1}),h({type:"SET_WALLET_INFO",payload:e}),h({type:"SET_WALLET",payload:l})}})}catch(e){h({type:"SET_ERROR",payload:e instanceof Error?e.message:"Failed to connect"}),h({type:"SET_CONNECTING",payload:!1})}},[l]),w=o.useCallback(async()=>{await l.logout(),h({type:"RESET"})},[l]);o.useEffect(()=>{var e;"phantom"===x.getWalletType()&&l.getPhantomAdapter()&&(null===(e=l.getPhantomAdapter())||void 0===e||e.on("disconnect",()=>{w()}))},[l]);const v={...f,connect:y,disconnect:w};return m.default.createElement(jg.Provider,{value:v},e)},exports.injectStyles=Og,exports.isVersionedTransaction=b,exports.theme=og,exports.useActiveWallet=function(){const{wallet:e}=Ug();return{wallet:e}},exports.useCoinbaseOnramp=function(){const{wallet:e}=Ug(),t=null==e?void 0:e.solanaAddress,n=null==e?void 0:e.ethereumAddress;return{getCoinbaseOnrampUrl:async(r,o="solana",s)=>{if(!e||!t||!n)throw new Error("Wallet not found");const a="solana"===o?t:n;return mf({sessionToken:await(null==e?void 0:e.fetchCoinbaseToken(a,o)),presetCryptoAmount:Number(r),redirectUrl:s||window.location.href})}}},exports.useConnect=function(){const{connect:e,disconnect:t,isConnecting:n}=Ug();return{connect:e,disconnect:t,isConnecting:n}},exports.useLoginModal=zg,exports.useWallet=Ug,exports.useWalletStatus=function(){const{error:e,session:t,isInitialized:n,wallet:r}=Ug();return{isAuthenticated:null!==r,authenticated:null!==r,error:e,session:t,isInitialized:n,ready:n}};
|
|
295
|
+
margin-top: ${sg.spacing.lg};
|
|
296
|
+
`;async function Og(e){const t=e.toLowerCase(),n=r.v4(),o=await async function(e){const t=new TextEncoder,n=t.encode(e),r=await crypto.subtle.digest("SHA-256",n),o=Array.from(new Uint8Array(r));return btoa(String.fromCharCode(...o)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}(n);return sessionStorage.setItem(`${t}_oauthCodeVerifier`,JSON.stringify({code_verifier:n,code_challenge:o,timestamp:Date.now()})),{codeVerifier:n,codeChallenge:o}}const Rg=()=>{if("undefined"!=typeof document&&document.getElementById("superstack-wallet-styles"))return;if("undefined"==typeof document)return;const e=document.createElement("link");e.id="superstack-wallet-fonts",e.rel="stylesheet",e.href="https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700&display=swap",document.head.appendChild(e);const t=document.createElement("style");t.id="superstack-wallet-styles",t.textContent=`\n /* 只影响嵌入钱包模态框 */\n #embedded-wallet-modal {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 9999;\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: rgba(0, 0, 0, 0.5);\n }\n \n /* 以下类选择器都只对SDK自己的元素生效 */\n .superstack-wallet-container {\n font-family: 'Montserrat', sans-serif;\n color: ${sg.colors.text.primary};\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n }\n \n /* 直接选择SDK组件,而不是使用通配符 */\n .superstack-wallet-container h1,\n .superstack-wallet-container h2,\n .superstack-wallet-container h3,\n .superstack-wallet-container h4,\n .superstack-wallet-container h5,\n .superstack-wallet-container h6 {\n font-family: 'Montserrat', sans-serif;\n font-weight: ${sg.typography.fontWeights.semibold};\n line-height: 1.2;\n margin-bottom: ${sg.spacing.md};\n }\n \n .superstack-wallet-container p {\n font-family: 'Montserrat', sans-serif;\n margin-bottom: ${sg.spacing.md};\n }\n \n /* 为SDK定义的按钮添加类名 */\n .superstack-wallet-btn {\n font-family: 'Montserrat', sans-serif;\n cursor: pointer;\n }\n \n /* 为SDK定义的输入域添加类名 */\n .superstack-wallet-input {\n font-family: 'Montserrat', sans-serif;\n }\n \n /* 模态内容应该有自己的样式,不影响外部 */\n #embedded-wallet-modal .modal-content {\n background-color: ${sg.colors.background.main};\n border-radius: ${sg.borderRadius.md};\n padding: ${sg.spacing.lg};\n box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);\n max-width: 480px;\n width: 100%;\n }\n `,document.head.appendChild(t)};var zg=Object.freeze({__proto__:null,injectStyles:Rg,theme:sg});function _g({client:e,isOpen:t,onClose:n,onLogin:s,isLoading:a=!1}){const[i,c]=o.useState(""),[u,l]=o.useState(""),[d,f]=o.useState(!1),[h,p]=o.useState(!1),[m,b]=o.useState(["","","","","",""]),[y,w]=o.useState(!1),[v,x]=o.useState(!1),[E,P]=o.useState(!1),k=o.useMemo(()=>Array(6).fill(null).map(()=>o.createRef()),[]),A=e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e),I=e=>/^\+[1-9]\d{1,3}\d{6,14}$/.test(e);return o.useEffect(()=>{m.forEach((e,t)=>{if(k[t]&&k[t].current){const n=k[t].current;n&&e&&(n.style.fontSize=sg.typography.fontSizes.xl)}})},[m,k]),{email:i,setEmail:c,emailSent:h,setEmailSent:p,sendingCode:y,setVerificationCode:b,verificationCode:m,verifyingCode:v,connectingPhantom:E,inputRefs:k,handleCodeChange:(e,t)=>{var n,r,o;if(t.length<=1){const r=[...m];r[e]=t,b(r),t&&e<5&&(null===(n=k[e+1].current)||void 0===n||n.focus())}else if(t.length>1){const e=t.replace(/\D/g,"").slice(0,6).split(""),n=[...Array(6).fill("")];e.forEach((e,t)=>{t<6&&(n[t]=e)}),b(n);const s=n.findIndex(e=>""===e);-1!==s?null===(r=k[s].current)||void 0===r||r.focus():n[5]&&(null===(o=k[5].current)||void 0===o||o.focus())}},handleKeyDown:(e,t)=>{var n;"Backspace"===t.key&&!m[e]&&e>0&&(null===(n=k[e-1].current)||void 0===n||n.focus())},handleContainerPaste:e=>{var t,n;e.preventDefault();const r=e.clipboardData.getData("text").replace(/\D/g,"").slice(0,6).split(""),o=[...Array(6).fill("")];r.forEach((e,t)=>{t<6&&(o[t]=e)}),b(o);const s=o.findIndex(e=>""===e);-1!==s?null===(t=k[s].current)||void 0===t||t.focus():o[5]&&(null===(n=k[5].current)||void 0===n||n.focus())},handleSendVerificationCode:async(t=i)=>{try{if(!A(t))return void alert("Please enter a valid email address");w(!0),await e.sendEmailVerificationCode(t),p(!0)}catch(e){alert("Failed to send verification code"),console.error("Failed to send verification code",e)}finally{w(!1)}},handleCodeSubmit:async(t=m.join(""),r=i)=>{try{if(6!==t.length)return void alert("Please enter a valid verification code");x(!0);const o=await e.verifyEmailVerificationCode({email:r,code:t});o&&(null==s||s(o),null==n||n())}catch(e){alert("Failed to verify code"),console.error("Failed to verify code",e)}finally{x(!1)}},handlePhoneCodeSubmit:async(t=m.join(""),r=u)=>{try{if(6!==t.length)return void alert("Please enter a valid verification code");x(!0);const o=await e.verifyPhoneVerificationCode({phone:r,code:t});o&&(null==s||s(o),null==n||n())}catch(e){alert("Failed to verify code"),console.error("Failed to verify code",e)}finally{x(!1)}},handleSendPhoneVerificationCode:async(t=u)=>{try{if(!I(t))return void alert("Please enter a valid phone number");await e.sendPhoneVerificationCode(t),f(!0)}catch(e){alert("Failed to send verification code"),console.error("Failed to send verification code",e)}finally{w(!1)}},handleGetChallenge:async(t,n)=>await e.getSignChallenge({method:null!=n?n:"phantom",id:t}),handleLoginWithChallenge:async(t,r)=>{try{const o=await e.loginWithChallenge(t,r);o&&(null==s||s(o),null==n||n())}catch(e){alert("Failed to login with challenge"),console.error("Failed to login with challenge",e)}finally{x(!1)}},phone:u,setPhone:l,phoneSent:d,setPhoneSent:f,onOauthLogin:async t=>{const n=function(e){const t=e.toLowerCase(),n=r.v4();return sessionStorage.setItem(`${t}_oauthState`,JSON.stringify({state:n,timestamp:Date.now()})),n}(t),{codeVerifier:o,codeChallenge:s}=await Og(t),a=new URL(window.location.href);a.searchParams.forEach((e,t)=>{a.searchParams.delete(t)});const i=a.toString(),c=await e.oauthInit({provider:t,redirect_uri:i,state:n,code_challenge:s}),{url:u,client_id:l}=c;if(!u&&!l)throw console.error("OAuth init failed."),new Error("init failed");const d={client_id:l,redirect_uri:u,state:n,code_challenge:s},f="google"===t?await async function(e){const t={response_type:"code",client_id:e.client_id,redirect_uri:e.redirect_uri,scope:["openid","email","profile"].join("%20"),code_challenge:e.code_challenge,code_challenge_method:"S256",state:e.state};return`https://accounts.google.com/o/oauth2/v2/auth?${g.stringify(t,{encode:!1})}`}(d):await async function(e){const t={response_type:"code",client_id:e.client_id,redirect_uri:e.redirect_uri,scope:["tweet.read","users.read"].join("%20"),code_challenge:e.code_challenge,code_challenge_method:"S256",state:e.state};return`https://twitter.com/i/oauth2/authorize?${g.stringify(t,{encode:!1})}`}(d);window.location.href=f},handlePhantomLogin:async()=>{try{P(!0);const t=await e.connectPhantom();t&&(null==s||s(t),null==n||n())}catch(e){console.error("Phantom login error:",e),alert("Failed to connect to Phantom wallet. Please make sure you have the Phantom extension installed.")}finally{P(!1)}},isOpen:t,onClose:n,onLogin:s,isLoading:a}}const Mg=({client:e,isOpen:t,onClose:n,onLogin:r,isLoading:o=!1,enableEmail:a=!0,enablePhone:i=!1,enableGoogle:c=!0,enableTwitter:u=!1,enablePhantom:l=!0})=>{const{email:d,setEmail:f,emailSent:h,sendingCode:p,setEmailSent:g,verifyingCode:b,verificationCode:y,connectingPhantom:w,inputRefs:v,handleCodeChange:x,handleKeyDown:E,handleContainerPaste:P,handleSendVerificationCode:k,handleCodeSubmit:A,onOauthLogin:I,handlePhantomLogin:N}=_g({client:e,isOpen:t,onClose:n,onLogin:r,isLoading:o});return t?m.default.createElement(ig,null,m.default.createElement(cg,null,m.default.createElement(ug,null,m.default.createElement(lg,null,"Connect Wallet"),m.default.createElement(dg,{onClick:n},m.default.createElement(fg,{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},m.default.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})))),o?m.default.createElement(hg,null,m.default.createElement(pg,null,m.default.createElement(s.Loader2,{size:24})),m.default.createElement(mg,null,"Loading...")):m.default.createElement(m.default.Fragment,null,h?m.default.createElement(Ag,null,m.default.createElement("div",null,m.default.createElement(Ig,null,"Enter Verification Code"),m.default.createElement(Ng,null,"We sent a verification code to ",d)),m.default.createElement(Sg,{onPaste:P},y.map((e,t)=>m.default.createElement(Tg,{key:t},m.default.createElement($g,{ref:v[t],type:"text",maxLength:1,value:e,onChange:e=>x(t,e.target.value),onKeyDown:e=>E(t,e),onPaste:e=>{0!==t&&(e.preventDefault(),P(e))}})))),m.default.createElement(yg,{onClick:()=>A(),disabled:6!==y.join("").length||b},b?"Verifying...":"Verify Code"),m.default.createElement(Bg,{onClick:()=>g(!1)},"Back to Email")):m.default.createElement(gg,null,a&&m.default.createElement(gg,null,m.default.createElement(bg,{type:"email",value:d,onChange:e=>f(e.target.value),placeholder:"Enter your email",disabled:p}),m.default.createElement(yg,{onClick:()=>k(),disabled:!d||p},p?"Sending...":"Send Verification Code")),(c||u||l)&&a&&m.default.createElement(wg,null,m.default.createElement(vg,null),m.default.createElement(xg,null,"Or continue with"),m.default.createElement(vg,null)),(c||u||l)&&m.default.createElement(m.default.Fragment,null,m.default.createElement(Eg,null,c&&m.default.createElement(Pg,{onClick:()=>I("google")},m.default.createElement(kg,null,m.default.createElement("img",{src:"https://cdn.jsdelivr.net/gh/devicons/devicon/icons/google/google-original.svg",alt:"Google",width:20,height:20})),"Google"),u&&m.default.createElement(Pg,{onClick:()=>I("twitter")},m.default.createElement(kg,null,m.default.createElement("img",{src:"https://cdn.jsdelivr.net/gh/devicons/devicon/icons/twitter/twitter-original.svg",alt:"Twitter",width:20,height:20})),"X")),l&&m.default.createElement(Pg,{onClick:N,disabled:w},m.default.createElement(kg,null,m.default.createElement("img",{src:"https://explorer-api.walletconnect.com/v3/logo/md/b6ec7b81-bb4f-427d-e290-7631e6e50d00?projectId=34357d3c125c2bcf2ce2bc3309d98715",alt:"Phantom",width:20,height:20})),w?"Connecting...":"Phantom")),!a&&!i&&!c&&!u&&!l&&m.default.createElement("div",{style:{textAlign:"center",padding:"20px",color:"#666"}},"No login methods are currently enabled."))),m.default.createElement(Cg,null,"By connecting your wallet, you agree to our Terms of Service and Privacy Policy"))):null};class Fg{constructor(){this.container=null,this.root=null}createContainer(){if("undefined"==typeof document)return null;this.removeExistingContainer();const e=document.createElement("div");return e.id="embedded-wallet-modal",document.body.appendChild(e),e}removeExistingContainer(){if("undefined"==typeof document)return;const e=document.getElementById("embedded-wallet-modal");e&&e.parentNode&&e.parentNode.removeChild(e)}showLoginModal({client:e,isLoading:t=!1,onClose:n,onLogin:r,enableEmail:o=!0,enablePhone:s=!1,enableGoogle:a=!0,enableTwitter:i=!1,enablePhantom:c=!0}){return new Promise((u,l)=>{try{if("undefined"==typeof window)return void u();import("react-dom/client").then(({createRoot:l})=>{if(this.container=this.createContainer(),!this.container)return void u();this.root=l(this.container);const d=()=>{this.hideModal(),null==n||n()},f=e=>{this.hideModal(),null==r||r(e)};this.root&&this.root.render(m.default.createElement(Mg,{client:e,isOpen:!0,onClose:d,isLoading:t,onLogin:f,enableEmail:o,enablePhone:s,enableGoogle:a,enableTwitter:i,enablePhantom:c})),u()}).catch(e=>{console.error("Error importing createRoot:",e),l(e)})}catch(e){console.error("Error showing modal:",e),l(e)}})}hideModal(){this.root&&(this.root.unmount(),this.container&&this.container.parentNode&&(document.body.removeChild(this.container),this.container=null))}}const jg={isAuthenticated:!1,isConnecting:!1,isInitialized:!1,walletInfo:null,wallet:null,session:null,error:null,enableEmail:!0,enablePhone:!1,enableGoogle:!0,enableTwitter:!1,enablePhantom:!0},Lg=o.createContext({});function Ug(e,t){switch(t.type){case"SET_CONNECTING":return{...e,isConnecting:t.payload};case"SET_INITIALIZED":return{...e,isInitialized:t.payload};case"SET_SESSION":return{...e,isAuthenticated:!0,session:t.payload,error:null};case"SET_WALLET_INFO":return{...e,walletInfo:t.payload};case"SET_WALLET":return{...e,wallet:t.payload};case"SET_ERROR":return{...e,error:t.payload};case"RESET":return{...jg,isInitialized:!0};default:return e}}function Dg(){const e=o.useContext(Lg);if(!e)throw new Error("useWallet must be used within a WalletProvider");return e}"undefined"!=typeof window&&Promise.resolve().then(function(){return zg}).then(({injectStyles:e})=>{e()}),exports.ACCESS_TOKEN_KEY=v,exports.STORAGE_STATE_KEY=y,exports.SWITCHED_ACCOUNT_ADDRESS=x,exports.Storage=E,exports.WALLET_TYPE_KEY=w,exports.WalletClient=mh,exports.WalletProvider=function({children:e,config:t}){var n,r,s,a,i,c;const u=o.useRef(null);u.current||(u.current=new mh(t));const l=u.current,d=o.useRef(null!==(n=t.modalManager)&&void 0!==n?n:null),[f,h]=o.useReducer(Ug,{...jg,enableEmail:null===(r=t.enableEmail)||void 0===r||r,enablePhone:null!==(s=t.enablePhone)&&void 0!==s&&s,enableGoogle:null===(a=t.enableGoogle)||void 0===a||a,enableTwitter:null!==(i=t.enableTwitter)&&void 0!==i&&i,enablePhantom:null===(c=t.enablePhantom)||void 0===c||c}),{walletInfo:p}=f,g=o.useRef(!1),b=o.useCallback(()=>(d.current||"undefined"==typeof window||(d.current=new Fg),d.current),[]);o.useEffect(()=>{t.modalManager&&(d.current=t.modalManager)},[t.modalManager]),o.useEffect(()=>{!async function(){if(!(p||g.current||f.isInitialized)){g.current=!0;try{const e=await l.reconnect();e&&(h({type:"SET_WALLET_INFO",payload:e}),h({type:"SET_WALLET",payload:l}))}catch(e){console.error("Auto reconnect failed:",e)}finally{h({type:"SET_INITIALIZED",payload:!0})}}}()},[l]),o.useEffect(()=>{const e=async()=>{try{if(v.isConnecting)return;h({type:"SET_CONNECTING",payload:!0});const e=new URLSearchParams(window.location.search),t=e.get("wallet_oauth_provider"),n=e.get("wallet_oauth_state"),r=e.get("wallet_oauth_code");if(t&&n&&r){const e=function(e){const t=e.toLowerCase(),n=sessionStorage.getItem(`${t}_oauthCodeVerifier`);if(!n)return null;const r=JSON.parse(n);return sessionStorage.removeItem(`${t}_oauthCodeVerifier`),Date.now()-r.timestamp>6e5?null:{codeVerifier:r.code_verifier,codeChallenge:r.code_challenge}}(t);if(!e)throw new Error("No code verifier found");const{codeVerifier:o,codeChallenge:s}=e;let a;if("twitter"===t)a="TwitterOAuth";else{if("google"!==t)throw new Error("Unsupported provider");a="GoogleOAuth"}b().showLoginModal({client:l,isLoading:!0,enableEmail:f.enableEmail,enablePhone:f.enablePhone,enableGoogle:f.enableGoogle,enableTwitter:f.enableTwitter,enablePhantom:f.enablePhantom});const i=await l.oauthLogin(a,{state:n,code:r,code_verifier:o});if(i){h({type:"SET_WALLET_INFO",payload:i}),h({type:"SET_WALLET",payload:l});const e=new URL(window.location.href);e.searchParams.delete("wallet_oauth_provider"),e.searchParams.delete("wallet_oauth_state"),e.searchParams.delete("wallet_oauth_code"),history.replaceState(null,"",e.toString())}}}catch(e){console.log("oauth login error: ",e)}finally{h({type:"SET_CONNECTING",payload:!1}),await b().hideModal()}};return e(),window.addEventListener("popstate",e),()=>{window.removeEventListener("popstate",e)}},[]);const y=o.useCallback(async()=>{try{h({type:"SET_CONNECTING",payload:!0});b().showLoginModal({client:l,enableEmail:f.enableEmail,enablePhone:f.enablePhone,enableGoogle:f.enableGoogle,enableTwitter:f.enableTwitter,enablePhantom:f.enablePhantom,onClose:()=>{h({type:"SET_CONNECTING",payload:!1})},onLogin:e=>{h({type:"SET_CONNECTING",payload:!1}),h({type:"SET_WALLET_INFO",payload:e}),h({type:"SET_WALLET",payload:l})}})}catch(e){h({type:"SET_ERROR",payload:e instanceof Error?e.message:"Failed to connect"}),h({type:"SET_CONNECTING",payload:!1})}},[l]),w=o.useCallback(async()=>{await l.logout(),h({type:"RESET"})},[l]);o.useEffect(()=>{var e;"phantom"===E.getWalletType()&&l.getPhantomAdapter()&&(null===(e=l.getPhantomAdapter())||void 0===e||e.on("disconnect",()=>{w()}))},[l]);const v={...f,connect:y,disconnect:w};return m.default.createElement(Lg.Provider,{value:v},e)},exports.injectStyles=Rg,exports.isVersionedTransaction=b,exports.theme=sg,exports.useActiveWallet=function(){const{wallet:e}=Dg();return{wallet:e}},exports.useCoinbaseOnramp=function(){const{wallet:e}=Dg(),t=null==e?void 0:e.solanaAddress,n=null==e?void 0:e.ethereumAddress;return{getCoinbaseOnrampUrl:async(r,o="solana",s)=>{if(!e||!t||!n)throw new Error("Wallet not found");const a="solana"===o?t:n;return gf({sessionToken:await(null==e?void 0:e.fetchCoinbaseToken(a,o)),presetCryptoAmount:Number(r),redirectUrl:s||window.location.href})}}},exports.useConnect=function(){const{connect:e,disconnect:t,isConnecting:n}=Dg();return{connect:e,disconnect:t,isConnecting:n}},exports.useLoginModal=_g,exports.useWallet=Dg,exports.useWalletStatus=function(){const{error:e,session:t,isInitialized:n,wallet:r}=Dg();return{isAuthenticated:null!==r,authenticated:null!==r,error:e,session:t,isInitialized:n,ready:n}};
|
|
297
297
|
//# sourceMappingURL=index.cjs.map
|